Trochu jsem na sobě zapracoval a výsledek mého "zapracování" snad usnadní prácí všem začínajícím majitelům tohoto příjemného kousku hardwaru. Nedělám si iluze, že by to snad nešlo napsat optimálněji a lépe, ale je to funkční.
Děkuji za pozornost
USER PROGRAM
#define REL1 sys[231]
#define REL2 sys[232]
#define D0 sys[301]
var day, tmp, i, itmp, imin, imax, num;
minimax
{
if ( sys[64] ) return;
i = 0;
label for:
itmp = 310 + i; imin = 140 + i; imax = 143 + i;
tmp = sys[itmp];
if ( tmp < 8500 )
{
if ( day != sys[5] )
{
sys[imin] = tmp;
sys[imax] = tmp;
}
if ( tmp < sys[imin] ) { sys[imin] = tmp; }
if ( tmp > sys[imax] ) { sys[imax] = tmp; }
i++;
if ( i < 3 ) goto for;
day = sys[5];
}
sys[64] = 60;
}
ptime
{
i = 8;
label loop:
num = sys[i];
if ( num < 10 ) { echoinline('0'); } echoinline(num); i++;
if ( i < 11 ) { echoinline(':'); goto loop; }
echoinline( ' ',sys[5],'.',sys[6],' ',sys[7] );
}
init
{
sys[147]=0; sys[148]=0; sys[149]=0; sys[150]=1; sys[196]=2; sys[197]=2;
}
main
{
minimax();
if ( sys[147] ) {
if ( REL1 == 0 ) { REL1 = 1; ptime(); echo(' rele1 ZAP'); }
}
else {
if ( REL1 != 0 ) { REL1 = 0; ptime(); echo(' rele1 VYP'); }
}
if ( sys[148] ) {
if ( REL2 == 0 ) { REL2 = 1; ptime(); echo(' rele2 ZAP'); }
}
else {
if ( REL2 != 0 ) { REL2 = 0; ptime(); echo(' rele2 VYP'); }
}
if ( sys[149] ) {
if ( D0 == 0 ) { D0 = 1; ptime(); echo(' D0 out ZAP'); }
}
else {
if ( D0 != 0 ) { D0 = 0; ptime(); echo(' D0 out VYP'); }
}
}
USER WEB PAGE
<!DOCTYPE HTML>
<html lang="cs">
<head>
<TITLE>SDS-MICRO</TITLE>
<META HTTP-EQUIV="CONTENT-TYPE" CONTENT="TEXT/HTML; CHARSET=WINDOWS-1250">
<META HTTP-EQUIV="CACHE-CONTROL" CONTENT="NO-CACHE">
<META HTTP-EQUIV="EXPIRES" CONTENT="0">
<style type="text/css">
body{
background:black;
color:white;
font-family:Verdana;
font-size:18px;
margin:0 auto;
width:450px;
}
div{
background-image:-moz-linear-gradient(top, #404040 0%, #000 100%);
background-image:-o-linear-gradient(top, #404040 0%, #000 100%);
background-image:-ms-linear-gradient(top, #404040 0%, #000 100%);
background-image:-webkit-linear-gradient(top, #404040 0%, #000 100%);
width:100%;
height:2.6em;
border:5px ridge DimGrey;
text-align:center;
padding:2px;
margin:0px 0px 10px;
border-radius: 20px 0px 20px;
}
.opt, .adi, .tem, .tin, .tax, .btn{
padding:5px;
margin:4px;
float:left;
border-radius:10px 0px 10px;
}
.opt, .adi, .tem, .tin, .tax{
border:1px solid DimGrey;
width:5.1em;
}
.btn{
background:DimGrey;
color:white;
font-size:18px;
width:7.85em;
}
.tin{ color:DeepSkyBlue;
}
.tax{ color:Yellow;
}
</style>
<script type="text/javascript">
var i, r, t;
var val = new Array(0, 0, 0);
var reqA = false;
var reqO = false;
var reqT = false;
var reqR = false;
var reqU = false;
var sub = false;
function reqAc() {
if (reqA.readyState === 4) {
if (reqA.status === 200) {
var rE = reqA.responseText.split("|");
for (i = 1; i <= 4; i++) {
r = rE[i - 1] / 34.5;
if ( ! ( isNaN(r) )) {
document.getElementById("adi" + i).innerHTML = r.toFixed(1) + " V";
}
}
}
}
}
function reqOc() {
if (reqO.readyState === 4) {
if (reqO.status === 200) {
var rE = reqO.responseText.split("|");
for (i = 1; i <= 4; i++) {
if (rE[i - 1] == 0) {
document.getElementById("opt" + i).style.background = "Lime";
} else {
document.getElementById("opt" + i).style.background = "DarkGreen";
}
}
}
}
}
function reqTc() {
if (reqT.readyState === 4) {
if (reqT.status === 200) {
var rE = reqT.responseText.split("|");
btnSts(3, (rE[0] == 0) ? 0 : 1);
for (i = 1; i <= 3; i++) {
r = rE[i + 8] / 100;
document.getElementById("tem" + i).innerHTML = r.toFixed(1) + " \u00b0C";
}
}
}
}
function reqRc() {
if (reqR.readyState == 4) {
if (reqR.status == 200) {
var rE = reqR.responseText.split("|");
btnSts(1, (rE[0] == 0) ? 0 : 1);
btnSts(2, (rE[1] == 0) ? 0 : 1);
}
}
}
function reqUc() {
if (reqU.readyState === 4) {
if (reqU.status === 200) {
var rE = reqU.responseText.split("|");
for (i = 1; i <= 3; i++) {
r = rE[i - 1] / 100;
document.getElementById("tin" + i).innerHTML = r.toFixed(1) + " \u00b0C";
r = rE[i + 2] / 100;
document.getElementById("tax" + i).innerHTML = r.toFixed(1) + " \u00b0C";
}
}
}
}
function sdsps() {
reqA = false;
reqO = false;
reqT = false;
reqR = false;
reqU = false;
if (window.XMLHttpRequest) {
reqA = new XMLHttpRequest;
reqO = new XMLHttpRequest;
reqT = new XMLHttpRequest;
reqR = new XMLHttpRequest;
reqU = new XMLHttpRequest;
} else if (window.ActiveXObject) {
reqA = new ActiveXObject("Microsoft.XMLHTTP");
reqO = new ActiveXObject("Microsoft.XMLHTTP");
reqT = new ActiveXObject("Microsoft.XMLHTTP");
reqR = new ActiveXObject("Microsoft.XMLHTTP");
reqU = new ActiveXObject("Microsoft.XMLHTTP");
}
if (reqA) {
reqA.open("GET", "get_sys[431]?rn=4&rand=" + Math.random(), true);
reqA.onreadystatechange = reqAc;
reqA.send(null);
}
if (reqO) {
reqO.open("GET", "get_sys[151]?rn=4&rand=" + Math.random(), true);
reqO.onreadystatechange = reqOc;
reqO.send(null);
}
if (reqT) {
reqT.open("GET", "get_sys[301]?rn=14&rand=" + Math.random(), true);
reqT.onreadystatechange = reqTc;
reqT.send(null);
}
if (reqR) {
reqR.open("GET", "get_sys[231]?rn=2&rand=" + Math.random(), true);
reqR.onreadystatechange = reqRc;
reqR.send(null);
}
if (reqU) {
reqU.open("GET", "get_sys[140]?rn=6&rand=" + Math.random(), true);
reqU.onreadystatechange = reqUc;
reqU.send(null);
}
t = setTimeout("sdsps()", 2000);
}
function getSub() {
sub = false;
if (window.XMLHttpRequest) {
sub = new XMLHttpRequest;
} else {
if (window.ActiveXObject) {
sub = new ActiveXObject("Microsoft.XMLHTTP");
}
}
}
function sdsc_S(sysn) {
r = sysn - 147;
val[r] = (val[r] == 0) ? 1 : 0;
if(!sub) { getSub(); };
if (sub) {
sub.open("GET", "sdscep?sys" + sysn + "=" + val[r], true);
sub.onreadystatechange = reqRc;
sub.send(null);
}
}
function btnSts(id, sw) {
val[id-1] = sw;
if (sw) {
document.getElementById("btn" + id).style.background = "Red";
document.getElementById("btn" + id).value = "ON";
} else {
document.getElementById("btn" + id).style.background = "DarkGreen";
document.getElementById("btn" + id).value = "OFF";
}
}
</script>
</head>
<body onLoad="sdsps();">
<div>
<label class=opt id="opt1">1</label>
<label class=opt id="opt2">2</label>
<label class=opt id="opt3">3</label>
<label class=opt id="opt4">4</label>
</div>
<div>
<label class=adi id="adi1">00.0 V</label>
<label class=adi id="adi2">00.0 V</label>
<label class=adi id="adi3">00.0 V</label>
<label class=adi id="adi4">00.0 V</label>
</div>
<div>
<label class=tem id="tem0">temp</label>
<label class=tem id="tem1">00.0 °C</label>
<label class=tem id="tem2">00.0 °C</label>
<label class=tem id="tem3">00.0 °C</label>
</div>
<div>
<label class=tin id="tin0">t min</label>
<label class=tin id="tin1">00.0 °C</label>
<label class=tin id="tin2">00.0 °C</label>
<label class=tin id="tin3">00.0 °C</label>
</div>
<div>
<label class=tax id="tax0">t max</label>
<label class=tax id="tax1">00.0 °C</label>
<label class=tax id="tax2">00.0 °C</label>
<label class=tax id="tax3">00.0 °C</label>
</div>
<div>
<input type="button" id="btn1" value="..." class="btn" onclick="javascript:sdsc_S(147);">
<input type="button" id="btn2" value="..." class="btn" onclick="javascript:sdsc_S(148);">
<input type="button" id="btn3" value="..." class="btn" onclick="javascript:sdsc_S(149);">
</div>
</body>
</html>
Voltaire: Chceš-li se mnou diskutovat, přesně vysvětli pojmy.