1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<script src=/js/d.js></script>
<script>hdr();</script>
<div id=content >
<h1>I/O Config</h1>
<hr><h2>${{Digital Inputs}}$</h2>
<div id=c1init>${{LOADING}}$...</div>
<div class=configbox id=cbox1 style="display:none"></div>
<hr><h2>${{Outputs}}$</h2>
<div id=c2init>${{LOADING}}$...</div>
<div class=configbox id=cbox2 style="display:none">
</div>
</div>
<script>
var ho="";
var hi="";
function chRelOpt(iz)
{
os=$('otype_'+iz);
osel=os.selectedIndex;
oselv=parseInt(os[osel].value);
nrel=0;
seq="none";
ctxdiv='block';
if(oselv>0)
nrel=1;
if(oselv>=0xf0)
nrel=2;
if(oselv==0xff)
{
nrel=255;
seq="block";
nrel=0;
ctxdiv='none';
}
if(oselv==244)
$('og'+iz).style.display="block";
else
$('og'+iz).style.display="none";
$('ctxd'+iz).style.display=ctxdiv;
for(nr=1;nr<=2;nr++)
{
nrz=zfill(nr,2);
rdiv="none";
if(nr<=nrel){rdiv='block';}
$('rdiv_'+iz+'_'+nrz).style.display=rdiv;
}
$('seq'+iz).style.display=seq;
}
function addROpt()
{
for(i=1;i<=8;i++)
{
ho=" ";
var iz=zfill(i,2);
ho+='<div id=ctxd'+iz+' style="display:none"><b> Ctx: <select name=o_01_'+iz+'_00_00></b>';
for(k in DmCtx)
{
ho+='<option value="'+DmCtx[k]+'">'+k+'</option>';
}
ho+='</select><br /><br />';
// Output per cancelli
ho+='<div id=og'+iz+' style="display:none"><b>${{startt}}$: </b><input type=text size=3 name=o_12_'+iz+'_00_00 value=0><b>${{opent}}$: </b><input type=text size=3 name=o_13_'+iz+'_00_00 value=0><b>${{pauset}}$: </b><input type=text size=3 name=o_14_'+iz+'_00_00 value=0><br/><b>${{Banging}}$:</b><select name=o_15_'+iz+'_00_00><option value=0>${{No}}$</option><option value=1>${{Yes}}$</option></select></div>';
// Fine output per cancelli
ho+='<br/></div>';
for(nr=1;nr<=2;nr++)
{
var nrz=zfill(nr,2);
ho+='<div id=rdiv_'+iz+'_'+nrz+' style="display:none"><hr><b> R'+nr+': </b><select name=o_05_'+iz+'_'+nrz+'_00><option value="0">${{None}}$</option>';
for(rn=1;rn<=8;rn++)
{
ho+='<option value='+rn+'>${{Relay}}$ '+rn+'</option>';
}
ho+='</select>'+
'<select name=o_07_'+iz+'_'+nrz+'_00><option value=0>NA (${{Open}}$)</option><option value=1>NC (${{Close}}$)</option><option value=2>${{Save}}$</option></select><br/>'+
'<b>${{runtime}}$: </b><input type=text size=3 name=o_09_'+iz+'_'+nrz+'_00 value=0>'+
'<b> ${{Retard}}$: <b><input type=text size=3 name=o_08_'+iz+'_'+nrz+'_00 value=0>'+
'<br/></div>';
}
ho+='<div id=seq'+iz+' style="display:none">${{SEQUENCE}}$</div>';
$("ropt_"+i).innerHTML=ho;
}
}
function chInOpt(iz,tz,sel,i)
{
osel=sel.selectedIndex;
oselv=parseInt(sel[osel].value);
maxact=0;
if(oselv)
{
if(oselv<160) // 0xa0
maxact=1;
else if(oselv<208) // 0xd0
maxact=2;
else
maxact=3;
}
for(a=1;a<=3;a++) {
actvis="none";
if(a<=maxact) {actvis="block";}
$('adiv'+iz+tz+'_'+a).style.display=actvis;
}
}
function addInputOpts(iz,tz,i,pulse)
{
var hi="";
for(a=1;a<=3;a++) {
hi+='<div id=adiv'+iz+tz+'_'+a+' style="display:none">';
if(a>1) { hi+='<br /><hr><br/>'; }
hi+='<b>${{action}}$ '+a+': </b><input type=text size=25 name=i_02_'+iz+'_'+tz+'_0'+a+' value="${{wait}}$..."><br/>';
hi+='<b> ${{msg}}$:</b><select name=i_07_'+iz+'_'+tz+'_0'+a+'>';
for(k in DmMsgType)
{
hi+='<option value="'+DmMsgType[k]+'">'+k+'</option>';
}
hi+='</select>';
hi+='<b> ${{ctx}}$:</b><select name=i_03_'+iz+'_'+tz+'_0'+a+'>';
for(k in DmCtx)
{
hi+='<option value="'+DmCtx[k]+'">'+k+'</option>';
}
hi+='</select><br/>';
hi+='<b> ${{act}}$:</b><select name=i_01_'+iz+'_'+tz+'_0'+a+'>';
for(k in DmAct)
{
hi+='<option value="'+DmAct[k]+'">'+k+'</option>';
}
hi+='</select>';
tval="${{Time}}$";
if(pulse)
{
tval="${{Time/Count}}$";
}
hi+='<b> '+tval+': </b><input type=text size=3 name=i_10_'+iz+'_'+tz+'_0'+a+' value=0>';
hi+='<br/><b> ${{Opt}}$:</b><select name=i_14_'+iz+'_'+tz+'_0'+a+'>';
for(k in DmOpt)
{
hi+='<option value="'+DmOpt[k]+'">'+k+'</option>';
}
hi+='</select>';
hi+='<input type=text size=15 name=i_15_'+iz+'_'+tz+'_0'+a+' value="">';
hi+='<br/><b> ${{Dst}}$: </b><input type=text size=15 name=i_04_'+iz+'_'+tz+'_0'+a+' value="0.0.0.0">';
hi+='</div>';
}
return hi;
}
function addInp(i,seld,name)
{
pulse=0;
InpT=new Object();
for(k in seld){InpT[k]=seld[k];}
if(i<4)
{
for(k in DmISR1){InpT[k]=DmISR1[k];}
pulse=1;
}
var iz=zfill(i,2);
hi+='<form name=diginp_'+iz+'>'+
'<b>'+name+' ${{name}}$:</b><input type=text size=20 name=i_08_'+iz+'_00_00 value="${{wait}}$...">'+
'<span onClick="toggleMe(\'inp'+i+'\',this);" style="padding:1px 1px" class="domoB pressB grayO grayB">${{Expand}}$ ∨</span><br/>'+
'<div id=inp'+i+' style="background-color: #EFEFEF; display:none;">'+
'<div class="tabf" id=tabf-'+i+'>'+
'<div id=tab_1-'+i+' class="tabon" onclick="tabC.chTab(this,'+i+');">${{Status}}$ Default</div>'+
'<div id=tab_2-'+i+' class="taboff" onclick="tabC.chTab(this,'+i+');">${{Status}}$ 2</div>'+
'<div id=tab_3-'+i+' class="taboff" onclick="tabC.chTab(this,'+i+');">${{Status}}$ 3</div>'+
'<div id=tab_4-'+i+' class="taboff" onclick="tabC.chTab(this,'+i+');">${{Status}}$ 4</div>'+
"</div>";
for(t=1;t<=4;t++)
{
var tz=zfill(t,2);
hi+='<div id=tab_'+t+'-'+i+'_data class="tcon" style="background-color:#BBBBBB;display:';
if(t==1) {hi+='table;"><div>';} else {hi+='none;"><div>';}
hi+='<b>${{Status name}}$: </b><input type=text size=25 name=i_09_'+iz+'_'+tz+'_00 value="${{wait}}..."><br/>'+
'<b>${{Enabled}}$:</b><select name=i_05_'+iz+'_'+tz+'_00><option value=0>${{No}}$</option><option value=1>${{Yes}}$</option></select>'+
' <b> ${{type}}$: </b><select name=i_11_'+iz+'_'+tz+'_00 onChange="chInOpt(\''+iz+'\',\''+tz+'\',this,'+i+');">';
for(k in InpT)
{
hi+='<option value="'+InpT[k]+'">'+k+'</option>';
}
hi+='</select><br/>'+
'<b>${{Min time}}$: </b><input type=text size=3 name=i_06_'+iz+'_'+tz+'_00 value=0>';
hi+='<hr>'+
'<div id=iopt_'+iz+'_'+tz+'>';
hi+=addInputOpts(iz,tz,i,pulse);
hi+='</div></div></div>';
}
delete InpT;
var fna='diginp_'+iz;
hi+='<span class="domoB pressB grayO grayB" onclick="hOpt(\''+fna+'\');sForm(\''+fna+'\',\'/ioconf.xml\',null);sOpt(\''+fna+'\');">${{Save}}$</span></form></div>';
}
for(i=1;i<=8;i++)
{
var iz=zfill(i,2);
addInp(i,DmInputType,'${{Input}}$ '+i);
// FINE INPUT
ho+='<form name=relays_'+iz+'>'+
'<b>${{Device name}}$ '+i+':</b> <input type=text size=20 name=o_04_'+iz+'_00_00 value="${{wait}}$..."><span onClick="toggleMe(\'out'+i+'\',this);" style="padding:1px 1px" class="domoB pressB grayO grayB">${{Expand}}$ ∨</span><br />'+
'<div id=out'+i+' style="background-color:#BBBBBB;display:none;">'+
'<b>${{Enabled}}$:</b><select name=o_02_'+iz+'_00_00><option value=0>${{No}}$</option><option value=1>${{Yes}}$</option></select>'+
' <b>${{Output type}}$: </b><select id=otype_'+iz+' name=o_10_'+iz+'_00_00 onChange="chRelOpt(\''+iz+'\');">';
for(k in DmOutputType)
{
ho+='<option value="'+DmOutputType[k]+'">'+k+'</option>';
}
ho+='</select><br/>'+
'<div id=ropt_'+i+'></div>'+
// FINE DEVICE
'<span class="domoB pressB grayO grayB" onclick="sForm(\'relays_'+iz+'\',\'/ioconf.xml\',null);">${{Save}}$</span>'+
'</div></form>';
}
$("cbox1").innerHTML+=hi+"</div>";
$("cbox2").innerHTML+=ho+"</div>";
hi="";
for(i=1;i<9;i++)
{
tabC.addTabs("tabf-"+i,i);
}
addROpt();
function setC(el,val)
{
if(typeof(el)!="undefined") {
var nname=el.nodeName;
if(el.name!="save")
{
if(nname=='SELECT')
{
l=el.length;
while(l){
if(el[--l].value==parseInt(val)){
el.selectedIndex=l;
l=0;
}
}
} else {
el.value=val;
}
}
}
}
function ioCf(xDt)
{
if(xDt)
{
for(f=1;f<9;f++)
{
var iname=getX(xDt,'i'+f);
var fz=zfill(f,2);
ie=$d.forms['diginp_'+fz];
el=ie.elements;
el["i_08_"+fz+"_00_00"].value=iname;
for(t=1;t<=4;t++)
{
tz=zfill(t,2);
var ix=getX(xDt,'i'+f+'s'+t);
var ixv=ix.split(";");
setC(el["i_09_"+fz+"_"+tz+"_00"],ixv[0]);
setC(el["i_06_"+fz+"_"+tz+"_00"],ixv[1]);
setC(el["i_05_"+fz+"_"+tz+"_00"],ixv[2]);
setC(el["i_11_"+fz+"_"+tz+"_00"],ixv[3]);
co=4;
for(ac=1;ac<=3;ac++)
{
acz=zfill(ac,2);
setC(el["i_02_"+fz+"_"+tz+"_"+acz],ixv[co]);
setC(el["i_04_"+fz+"_"+tz+"_"+acz],ixv[co+1]);
setC(el["i_10_"+fz+"_"+tz+"_"+acz],ixv[co+2]);
setC(el["i_03_"+fz+"_"+tz+"_"+acz],ixv[co+3]);
setC(el["i_07_"+fz+"_"+tz+"_"+acz],ixv[co+4]);
setC(el["i_01_"+fz+"_"+tz+"_"+acz],ixv[co+5]);
setC(el["i_14_"+fz+"_"+tz+"_"+acz],ixv[co+6]);
setC(el["i_15_"+fz+"_"+tz+"_"+acz],ixv[co+7]);
//co+=6;
co+=8;
}
chInOpt(fz,tz,el['i_11_'+fz+'_'+tz+'_00'],f);
}
if(f<9)
{
var ox=getX(xDt,'o'+f);
de=$d.forms['relays_'+fz];
el=de.elements;
var oxv=ox.split(";");
el["o_04_"+fz+"_00_00"].value=oxv[0]; // Output Name
setC(el["o_01_"+fz+"_00_00"],oxv[1]);
setC(el["o_09_"+fz+"_01_00"],oxv[2]);
setC(el["o_09_"+fz+"_02_00"],oxv[3]);
setC(el["o_06_"+fz+"_01_00"],oxv[4]);
setC(el["o_11_"+fz+"_01_00"],oxv[5]);
setC(el["o_06_"+fz+"_02_00"],oxv[6]);
setC(el["o_11_"+fz+"_02_00"],oxv[7]);
setC(el["o_08_"+fz+"_01_00"],oxv[8]);
setC(el["o_08_"+fz+"_02_00"],oxv[9]);
setC(el["o_05_"+fz+"_01_00"],oxv[10]);
setC(el["o_05_"+fz+"_02_00"],oxv[11]);
setC(el["o_07_"+fz+"_01_00"],oxv[12]);
setC(el["o_07_"+fz+"_02_00"],oxv[13]);
setC(el["o_03_"+fz+"_01_00"],oxv[14]);
setC(el["o_03_"+fz+"_02_00"],oxv[15]);
setC(el["o_10_"+fz+"_00_00"],oxv[16]);
setC(el["o_02_"+fz+"_00_00"],oxv[17]);
setC(el["o_12_"+fz+"_00_00"],oxv[18]);
setC(el["o_13_"+fz+"_00_00"],oxv[19]);
setC(el["o_14_"+fz+"_00_00"],oxv[20]);
setC(el["o_15_"+fz+"_00_00"],oxv[21]);
chRelOpt(fz);
}
sOpt('diginp_'+fz);
}
$('c1init').style.display="none";
$('c2init').style.display="none";
$('cbox1').style.display="block";
$('cbox2').style.display="block";
} else {
ACmd('ioconf.xml',ioCf);
}
}
ACmd('ioconf.xml',ioCf);
ftr();
</script>