<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
	<title type="html"><![CDATA[SDS PLC/PAC: Měření Energie & OnlineTechnology.cz - Teplotní čidla - user.htm]]></title>
	<link rel="self" href="https://forum.sds.an-d.cz/extern.php?action=feed&amp;tid=567&amp;type=atom" />
	<updated>2014-05-14T16:17:31Z</updated>
	<generator>PunBB</generator>
	<id>https://forum.sds.an-d.cz/viewtopic.php?id=567</id>
		<entry>
			<title type="html"><![CDATA[Teplotní čidla - user.htm]]></title>
			<link rel="alternate" href="https://forum.sds.an-d.cz/viewtopic.php?pid=4421#p4421" />
			<content type="html"><![CDATA[<p>Zdravím všechny, </p><p>přikládám svůj <strong>user.htm</strong>, používám <strong>SDS micro</strong> na sledování teplot topení, místností, atd</p><p>Náhled výstupu <a href="http://92.62.226.9:8080/user.htm">zde</a></p><p>Kód zobrazuje graf:<br /></p><ul><li><p>aktuální teploty z teplotních čidel </p></li><li><p>hodnoty teplot</p></li><li><p>názvy teplotních čidel</p></li><li><p>stav, zdali se teplota snižuje, zvyšuje či je stejná</p></li><li><p>náhodné barvy sloupců (někomu by se nemuselo líbit - jednoduchá modifikace)</p></li><li><p>refresh tlačítko - pro testování</p></li></ul><p>Snad by se mohlo někomu hodit</p><p>Pokud by jste někdo narazil na nějaké zlepšení či chybu, neváhejte napsat</p><p>PS: kód by se dal zoptimalizovat, či použít jQuery</p><div class="codebox"><pre><code>&lt;!doctype html&gt;
&lt;html lang=&quot;cs&quot;&gt;
    &lt;head&gt;
        &lt;meta charset=&quot;windows-1250&quot; /&gt;
        &lt;style type=&quot;text/css&quot;&gt;
             body, ul, li, span, strong{ margin:0; padding:0; font-size:100%; font-family:serif; }
             #box{ position:fixed; top:50%; left:50%; margin-top:-220px; margin-left:-450px; width:900px; height:440px; }
              #refresh{ position:absolute; right:0; top:0; display:block; width:20px; height:20px; background:red; font- size:0; z-index:999; }
              #graph{ position:relative; top:0; width:100%; height:240px; }
            .bar { position:absolute; bottom:0;width: 50px; height: 0px; border-left: 1px solid #1d1d1d; border-top: 1px solid #1d1d1d; border-right: 1px solid #1d1d1d; -webkit-transition: .22s all linear 0s; -moz-transition: .22s all linear 0s; -ms-transition: .22s all linear 0s; -o-transition: .22s all linear 0s; }
            .bar span{ position:absolute; width:140px; left:-90%; bottom:-120px; text-align:right; white-space:nowrap; -webkit-transform: rotate(270deg);-moz-transform: rotate(270deg);-o-transform: rotate(270deg);writing-mode: lr-tb;}
            .bar strong{ position:absolute; bottom:-25px; display:block; width:50px; text-align:center; margin:0; padding:0;font-size:80%;}
        &lt;/style&gt;
        &lt;script type=&quot;text/javascript&quot;&gt;
            var reqTemp = null;
            var reqTempName = null;
            var boolNames = true;
            var boolColors = true;
            var cas = null;
            var timeout = 1000
            var tempNames = null;
            var barMultiple = 2;
            var barDistance = 56;
            function fceCidla(){
                if(reqTemp.readyState == 4 &amp;&amp; reqTemp.status == 200){
                    if(reqTemp.responseText != &#039;&#039;){
                        var cidlaTeploty = reqTemp.responseText.split(&quot;|&quot;);
                        for(i = 1; i &lt;= cidlaTeploty.length; i++){
                            objTemp = document.getElementById(&#039;temp&#039; + i) ;
                            objName = document.getElementById(&#039;name&#039; + i) ;
                            pom = cidlaTeploty[i-1] / 100;
                            if(pom &gt; 200){
                                objTemp.innerHTML = &#039;-&#039;;
                                objName.innerHTML = &#039;&amp;nbsp;&#039;;
                                pom=0;
                            }else{
                                //objTemp.innerHTML = pom.toFixed(2) + &quot; °C&quot;;
                                objTemp.innerHTML = pom.toFixed(2) + &quot;&quot;;
                                objName.innerHTML = tempNames[i-1];
                            }
                            grow(&#039;bar&#039;, i, Math.round(pom * barMultiple), boolColors);
                        }
                        boolColors = false;
                    }
                }                
            }
            function grow(id, num, height, colors) {
                var obj = document.getElementById(id + num);
                obj.style.height = height + &#039;px&#039;;
                obj.style.left = barDistance * (num - 1) + &#039;px&#039;;
                if(colors){
                 obj.style.backgroundColor = getRandomColor();
                } 
            }    
            
            function getRandomColor () {
              var hex = Math.floor(Math.random() * 0xFFFFFF);
              return &quot;#&quot; + (&quot;000000&quot; + hex.toString(16)).substr(-6);
            }            
            
            function startRequest(){
                if(window.XMLHttpRequest){
                    reqTemp = new XMLHttpRequest();
                    reqTempName = new XMLHttpRequest();
                }else if(window.ActiveXObject){
                    reqTemp = new ActiveXObject(&quot;Microsoft.XMLHTTP&quot;);
                    reqTempName = new ActiveXObject(&quot;Microsoft.XMLHTTP&quot;);
                }
                
                if(reqTempName &amp;&amp; boolNames){
                    boolNames = false;
                    reqTempName.open(&quot;GET&quot;, &quot;get_sys[391]?rn=16&amp;rand=&quot;+Math.random(), true)
                    reqTempName.onreadystatechange = function(){
                        if(reqTempName.readyState == 4 &amp;&amp; reqTempName.status == 200){
                            if(reqTempName.responseText != &#039;&#039;){
                                tempNames = reqTempName.responseText.split(&quot;|&quot;);
                            }
                        }
                    };
                    reqTempName.send(null);
                }
                
                if(reqTemp){
                    reqTemp.open(&quot;GET&quot;, &quot;get_sys[310]?rn=16&amp;rand=&quot;+Math.random(), true)
                    reqTemp.onreadystatechange = fceCidla;
                    reqTemp.send(null);
                }                
                cas = setTimeout(&#039;startRequest()&#039;, timeout);
            }
        &lt;/script&gt;
        &lt;title&gt;SDS live&lt;/title&gt;
    &lt;/head&gt;
    &lt;body onload=&quot;startRequest();&quot;&gt;
        &lt;div id=&quot;box&quot;&gt;
            &lt;a id=&quot;refresh&quot; href=&quot;javascript:window.location.reload()&quot; title=&quot;Refresh&quot;&gt;&amp;nbsp;&lt;/a&gt;
            &lt;div id=&quot;graph&quot;&gt;
                &lt;div id=&quot;bar1&quot; class=&quot;bar&quot;&gt;&lt;span id=&quot;name1&quot;&gt;&lt;/span&gt;&lt;strong id=&quot;temp1&quot;&gt;&lt;/strong&gt;&lt;/div&gt;
                &lt;div id=&quot;bar2&quot; class=&quot;bar&quot;&gt;&lt;span id=&quot;name2&quot;&gt;&lt;/span&gt;&lt;strong id=&quot;temp2&quot;&gt;&lt;/strong&gt;&lt;/div&gt;
                &lt;div id=&quot;bar3&quot; class=&quot;bar&quot;&gt;&lt;span id=&quot;name3&quot;&gt;&lt;/span&gt;&lt;strong id=&quot;temp3&quot;&gt;&lt;/strong&gt;&lt;/div&gt;
                &lt;div id=&quot;bar4&quot; class=&quot;bar&quot;&gt;&lt;span id=&quot;name4&quot;&gt;&lt;/span&gt;&lt;strong id=&quot;temp4&quot;&gt;&lt;/strong&gt;&lt;/div&gt;
                &lt;div id=&quot;bar5&quot; class=&quot;bar&quot;&gt;&lt;span id=&quot;name5&quot;&gt;&lt;/span&gt;&lt;strong id=&quot;temp5&quot;&gt;&lt;/strong&gt;&lt;/div&gt;
                &lt;div id=&quot;bar6&quot; class=&quot;bar&quot;&gt;&lt;span id=&quot;name6&quot;&gt;&lt;/span&gt;&lt;strong id=&quot;temp6&quot;&gt;&lt;/strong&gt;&lt;/div&gt;
                &lt;div id=&quot;bar7&quot; class=&quot;bar&quot;&gt;&lt;span id=&quot;name7&quot;&gt;&lt;/span&gt;&lt;strong id=&quot;temp7&quot;&gt;&lt;/strong&gt;&lt;/div&gt;
                &lt;div id=&quot;bar8&quot; class=&quot;bar&quot;&gt;&lt;span id=&quot;name8&quot;&gt;&lt;/span&gt;&lt;strong id=&quot;temp8&quot;&gt;&lt;/strong&gt;&lt;/div&gt;
                &lt;div id=&quot;bar9&quot; class=&quot;bar&quot;&gt;&lt;span id=&quot;name9&quot;&gt;&lt;/span&gt;&lt;strong id=&quot;temp9&quot;&gt;&lt;/strong&gt;&lt;/div&gt;
                &lt;div id=&quot;bar10&quot; class=&quot;bar&quot;&gt;&lt;span id=&quot;name10&quot;&gt;&lt;/span&gt;&lt;strong id=&quot;temp10&quot;&gt;&lt;/strong&gt;&lt;/div&gt;
                &lt;div id=&quot;bar11&quot; class=&quot;bar&quot;&gt;&lt;span id=&quot;name11&quot;&gt;&lt;/span&gt;&lt;strong id=&quot;temp11&quot;&gt;&lt;/strong&gt;&lt;/div&gt;
                &lt;div id=&quot;bar12&quot; class=&quot;bar&quot;&gt;&lt;span id=&quot;name12&quot;&gt;&lt;/span&gt;&lt;strong id=&quot;temp12&quot;&gt;&lt;/strong&gt;&lt;/div&gt;
                &lt;div id=&quot;bar13&quot; class=&quot;bar&quot;&gt;&lt;span id=&quot;name13&quot;&gt;&lt;/span&gt;&lt;strong id=&quot;temp13&quot;&gt;&lt;/strong&gt;&lt;/div&gt;
                &lt;div id=&quot;bar14&quot; class=&quot;bar&quot;&gt;&lt;span id=&quot;name14&quot;&gt;&lt;/span&gt;&lt;strong id=&quot;temp14&quot;&gt;&lt;/strong&gt;&lt;/div&gt;
                &lt;div id=&quot;bar15&quot; class=&quot;bar&quot;&gt;&lt;span id=&quot;name15&quot;&gt;&lt;/span&gt;&lt;strong id=&quot;temp15&quot;&gt;&lt;/strong&gt;&lt;/div&gt;
                &lt;div id=&quot;bar16&quot; class=&quot;bar&quot;&gt;&lt;span id=&quot;name16&quot;&gt;&lt;/span&gt;&lt;strong id=&quot;temp16&quot;&gt;&lt;/strong&gt;&lt;/div&gt;
            &lt;/div&gt;        
        &lt;/div&gt;        
    &lt;/body&gt;
&lt;/html&gt;</code></pre></div>]]></content>
			<author>
				<name><![CDATA[JeremyCB]]></name>
				<uri>https://forum.sds.an-d.cz/profile.php?id=11530</uri>
			</author>
			<updated>2014-05-14T16:17:31Z</updated>
			<id>https://forum.sds.an-d.cz/viewtopic.php?pid=4421#p4421</id>
		</entry>
</feed>
