Add auto/manual switch and setting, change to all lowercase

This commit is contained in:
Douglas Clowes
2014-11-24 12:44:29 +11:00
parent de766e465e
commit f5994bb760

View File

@ -19,44 +19,69 @@ driver oxford_mercury = {
group_property 'cards' = '${cards}';
group_property 'assoc' = '${assoc}';
group Temp0 = {
group temp0 = {
# Always the motherboard, always there
priv = user; type = float; readable = 5;
var sensor = { readable = 1; read_command = 'READ:DEV:MB1.T1:TEMP:SIG:TEMP'; permlink = 'T.S00'; }
var nick = { type=text; readable = 15; read_command = 'READ:DEV:MB1.T1:TEMP:NICK'; read_function = rdText; }
var power = { read_command = 'READ:DEV:MB0.H1:HTR:SIG:POWR'; }
var auto = {
type = int; allowed = '0,1';
read_function = rdOnOff; read_command = 'READ:DEV:MB1.T1:TEMP:LOOP:ENAB';
writeable = 1; write_function = wrOnOff; write_command = 'SET:DEV:MB1.T1:TEMP:LOOP:ENAB:';
}
var setpoint = { read_command = 'READ:DEV:MB1.T1:TEMP:LOOP:TSET';
driveable = Temp0/sensor; lowerlimit = 0; upperlimit = 333; tolerance = '${ttol}'; property settle_time = 15;
driveable = temp0/sensor; lowerlimit = 0; upperlimit = 333; tolerance = '${ttol}'; property settle_time = 15;
writeable = 1; write_function = setPoint; write_command = 'SET:DEV:MB1.T1:TEMP:LOOP:TSET:';
permlink = 'T.SP00';
}
group heater = {
var power = { read_command = 'READ:DEV:MB0.H1:HTR:SIG:POWR'; }
var perc = { read_command = 'READ:DEV:MB0.H1:HTR:SIG:PERC'; }
var hset = {
read_command = 'READ:DEV:MB1.T1:TEMP:LOOP:HSET';
lowerlimit = 0; upperlimit = 100;
writeable = 1; write_command = 'SET:DEV:MB1.T1:TEMP:LOOP:HSET:';
}
}
}
%exec
exec_output = []
for i in range(8):
exec_output += [""]
exec_output += [" group Temp%d = {" % (i+1)]
exec_output += [" group temp%d = {" % (i+1)]
exec_output += [" conditional = '[string equal -nocase [string index ${cards} %d] T]';" % i]
exec_output += [" priv = user; type = float; readable = 5;"]
exec_output += [" var sensor = { readable = 1; read_command = 'READ:DEV:DB%d.T1:TEMP:SIG:TEMP'; permlink = 'T.S%02d'; }" % (i+1,i+1)]
exec_output += [" var nick = { type=text; readable = 15; read_command = 'READ:DEV:DB%d.T1:TEMP:NICK'; read_function = rdText; }" % (i+1)]
if i > 4:
exec_output += [" var power = {"]
exec_output += [" var auto = {"]
exec_output += [" conditional = '[string equal -nocase [string index ${cards} %d] H] && [string equal -nocase [string index ${assoc} %d] %d]';" % (i-5, i, i-4)]
exec_output += [" read_command = 'READ:DEV:DB%d.H1:HTR:SIG:POWR';" % (i - 4)]
exec_output += [" type = int; allowed = '0,1'; read_command = 'READ:DEV:DB%d.T1:TEMP:LOOP:ENAB';" % (i + 1)]
exec_output += [" read_function = rdOnOff; read_command = 'READ:DEV:DB%d.T1:TEMP:LOOP:ENAB';" % (i + 1)]
exec_output += [" writeable = 1; write_function = wrOnOff; write_command = 'SET:DEV:DB%d.T1:TEMP:LOOP:ENAB:';" % (i + 1)]
exec_output += [" }"]
exec_output += [" var setpoint = {"]
exec_output += [" conditional = '[string equal -nocase [string index ${cards} %d] H] && [string equal -nocase [string index ${assoc} %d] %d]';" % (i-5, i, i-4)]
exec_output += [" read_command = 'READ:DEV:DB%d.T1:TEMP:LOOP:TSET';" % (i + 1)]
exec_output += [" driveable = Temp%d/sensor; lowerlimit = 0; upperlimit = 333; tolerance = '${ttol}'; property settle_time = 15;" % (i + 1)]
exec_output += [" driveable = temp%d/sensor; lowerlimit = 0; upperlimit = 333; tolerance = '${ttol}'; property settle_time = 15;" % (i + 1)]
exec_output += [" writeable = 1; write_function = setPoint; write_command = 'SET:DEV:DB%d.T1:TEMP:LOOP:TSET:';" % (i + 1)]
exec_output += [" permlink = 'T.SP%02d';" % (i + 1)]
exec_output += [" }"]
exec_output += [" group heater = {"]
exec_output += [" conditional = '[string equal -nocase [string index ${cards} %d] H] && [string equal -nocase [string index ${assoc} %d] %d]';" % (i-5, i, i-4)]
exec_output += [" var power = { read_command = 'READ:DEV:DB%d.H1:HTR:SIG:POWR'; }" % (i - 4)]
exec_output += [" var perc = { read_command = 'READ:DEV:DB%d.H1:HTR:SIG:PERC'; }" % (i - 4)]
exec_output += [" var hset = {"]
exec_output += [" read_command = 'READ:DEV:DB%d.T1:TEMP:LOOP:HSET';" % (i + 1)]
exec_output += [" lowerlimit = 0; upperlimit = 100;"]
exec_output += [" writeable = 1; write_command = 'SET:DEV:DB%d.T1:TEMP:LOOP:HSET:';" % (i + 1)]
exec_output += [" }"]
exec_output += [" }"]
exec_output += [" }"]
%end
group Pres5 = {
group pres5 = {
conditional = '[string equal -nocase [string index ${cards} 4] P]';
priv = user; type = float; readable = 5;
var sensor = { readable = 1; read_command = 'READ:DEV:DB5.P1:PRES:SIG:PRES'; permlink = 'P.PS05'; units = "mB"; }
@ -65,15 +90,32 @@ for i in range(8):
conditional = '[string equal -nocase [string index ${cards} 3] V] && [string equal -nocase [string index ${assoc} 4] 4]';
read_command = 'READ:DEV:DB4.G1:AUX:SIG:PERC';
}
var enab = {
conditional = '[string equal -nocase [string index ${cards} 3] V] && [string equal -nocase [string index ${assoc} 4] 4]';
type = int; allowed = '0,1';
read_function = rdOnOff; read_command = 'READ:DEV:DB5.P1:PRES:LOOP:ENAB';
writeable = 1; write_function = wrOnOff; write_command = 'SET:DEV:DB5.P1:PRES:LOOP:ENAB:';
}
var auto = {
conditional = '[string equal -nocase [string index ${cards} 3] V] && [string equal -nocase [string index ${assoc} 4] 4]';
type = int; allowed = '0,1';
read_function = rdOnOff; read_command = 'READ:DEV:DB5.P1:PRES:LOOP:FAUT';
writeable = 1; write_function = wrOnOff; write_command = 'SET:DEV:DB5.P1:PRES:LOOP:FAUT:';
}
var setpoint = {
conditional = '[string equal -nocase [string index ${cards} 3] V] && [string equal -nocase [string index ${assoc} 4] 4]';
read_command = 'READ:DEV:DB5.P1:PRES:LOOP:TSET';
driveable = Pres5/sensor; lowerlimit = 0; upperlimit = 333; tolerance = '${ptol}'; property settle_time = 15;
driveable = pres5/sensor; lowerlimit = 0; upperlimit = 333; tolerance = '${ptol}'; property settle_time = 15;
writeable = 1; write_function = setPoint; write_command = 'SET:DEV:DB8.P1:PRES:LOOP:TSET:';
permlink = 'P.PSP05'; units = "mB";
}
var fset = {
read_command = 'READ:DEV:DB5.P1:PRES:LOOP:FSET';
lowerlimit = 0; upperlimit = 100;
writeable = 1; write_command = 'SET:DEV:DB5.P1:PRES:LOOP:FSET:';
}
}
group Pres8 = {
group pres8 = {
conditional = '[string equal -nocase [string index ${cards} 7] P]';
priv = user; type = float; readable = 5;
var sensor = { readable = 1; read_command = 'READ:DEV:DB8.P1:PRES:SIG:PRES'; permlink = 'P.PS08'; units = "mB"; }
@ -82,33 +124,46 @@ for i in range(8):
conditional = '[string equal -nocase [string index ${cards} 3] V] && [string equal -nocase [string index ${assoc} 7] 4]';
read_command = 'READ:DEV:DB4.G1:AUX:SIG:PERC';
}
var enab = {
conditional = '[string equal -nocase [string index ${cards} 3] V] && [string equal -nocase [string index ${assoc} 7] 4]';
type = int; allowed = '0,1';
read_function = rdOnOff; read_command = 'READ:DEV:DB8.P1:PRES:LOOP:ENAB';
writeable = 1; write_function = wrOnOff; write_command = 'SET:DEV:DB8.P1:PRES:LOOP:ENAB:';
}
var auto = {
conditional = '[string equal -nocase [string index ${cards} 3] V] && [string equal -nocase [string index ${assoc} 7] 4]';
type = int; allowed = '0,1';
read_function = rdOnOff; read_command = 'READ:DEV:DB8.P1:PRES:LOOP:FAUT';
writeable = 1; write_function = wrOnOff; write_command = 'SET:DEV:DB8.P1:PRES:LOOP:FAUT:';
}
var setpoint = {
conditional = '[string equal -nocase [string index ${cards} 3] V] && [string equal -nocase [string index ${assoc} 7] 4]';
read_command = 'READ:DEV:DB8.P1:PRES:LOOP:TSET';
driveable = Pres8/sensor; lowerlimit = 0; upperlimit = 333; tolerance = '${ptol}'; property settle_time = 15;
driveable = pres8/sensor; lowerlimit = 0; upperlimit = 333; tolerance = '${ptol}'; property settle_time = 15;
writeable = 1; write_function = setPoint; write_command = 'SET:DEV:DB8.P1:PRES:LOOP:TSET:';
permlink = 'P.PSP08'; units = "mB";
}
var fset = {
read_command = 'READ:DEV:DB8.P1:PRES:LOOP:FSET';
lowerlimit = 0; upperlimit = 100;
writeable = 1; write_command = 'SET:DEV:DB8.P1:PRES:LOOP:FSET:';
}
}
group Valve = {
group valve = {
conditional = '[string equal -nocase [string index ${cards} 3] V]';
priv = user; type = float;
var sensor = {
readable = 5; read_command = 'READ:DEV:DB4.G1:AUX:SIG:PERC';
}
var nick = { type=text; readable = 15; read_command = 'READ:DEV:DB4.G1:AUX:NICK'; read_function = rdText; }
var setpoint = {
driveable = Valve/sensor; lowerlimit = 0; upperlimit = 100; tolerance = '${vtol}'; property settle_time = 30;
writeable = 1; write_function = setValve; write_command = 'SET:DEV:DB4.G1:AUX:SIG:OPEN:';
}
}
group Level = {
group level = {
conditional = '[string equal -nocase [string index ${cards} 4] L]';
priv = user; type = float; readable = 15;
var Nitrogen = { read_command = 'READ:DEV:DB5.L1:LVL:SIG:NIT:LEV'; permlink = 'T.N2'; }
var Helium = { read_command = 'READ:DEV:DB5.L1:LVL:SIG:HEL:LEV'; permlink = 'T.He'; }
var nitrogen = { read_command = 'READ:DEV:DB5.L1:LVL:SIG:NIT:LEV'; permlink = 'T.N2'; }
var helium = { read_command = 'READ:DEV:DB5.L1:LVL:SIG:HEL:LEV'; permlink = 'T.He'; }
var nick = { type=text; readable = 15; read_command = 'READ:DEV:DB5.L1:LVL:NICK'; read_function = rdText; }
}
@ -135,10 +190,31 @@ for i in range(8):
@ scan [lindex [split "$data" ":"] end] "%s" data
}
code Write_function setPoint = {
code write_function setPoint = {
}
code Write_function setValve = {
code write_function setValve = {
}
code read_function rdOnOff = {
@TCL
scan [lindex [split "$data" ":"] end] "%s" data
if {[string equal -nocase ${data} "ON"]} {
set data 1
} else {
set data 0
}
@END
}
code write_function wrOnOff = {
@TCL
if { ${par} == 1 } {
set cmd "${cmd_str}ON"
} else {
set cmd "${cmd_str}OFF"
}
@END
}
code preamble = {
@ -146,7 +222,7 @@ for i in range(8):
proc make_config {sct_controller} {
set syscat [${sct_controller} transact READ:SYS:CAT]
set result ""
set devs [regexp -inline -all {DEV:D[[:alnum:]\.]*:[[:alnum:]]*} ${syscat}]
set devs [regexp -inline -all {DEV:[DM][[:alnum:]\.]*:[[:alnum:]]*} ${syscat}]
foreach dev [lsort ${devs}] {
set typ [string index [lindex [split ${dev} :] end] 0]
set typ [string map {A V} ${typ}]
@ -156,6 +232,34 @@ for i in range(8):
clientput "Result: ${result}"
return ${result}
}
proc read_all {sct_controller} {
set syscat [${sct_controller} transact READ:SYS:CAT]
set devs [regexp -inline -all {DEV:[DM][[:alnum:]\.]*:[[:alnum:]]*} ${syscat}]
foreach dev [lsort ${devs}] {
set response [${sct_controller} transact READ:${dev}]
clientput "Device: ${response}"
}
}
proc read_loop {sct_controller} {
set pat {\m[A-Z]{1,}:[^:]{1,}}
set syscat [${sct_controller} transact READ:SYS:CAT]
set devs [regexp -inline -all {DEV:[DM][[:alnum:]\.]*:[[:alnum:]]*} ${syscat}]
foreach dev [lsort ${devs}] {
set response [${sct_controller} transact READ:${dev}:LOOP]
clientput "Device: ${response}"
clientput " Loop: [regexp -inline -all $pat [string trim ${response}]]"
}
}
proc read_sig {sct_controller} {
set pat {\m[A-Z]{1,}:[^:]{1,}}
set syscat [${sct_controller} transact READ:SYS:CAT]
set devs [regexp -inline -all {DEV:[DM][[:alnum:]\.]*:[[:alnum:]]*} ${syscat}]
foreach dev [lsort ${devs}] {
set response [${sct_controller} transact READ:${dev}:SIG]
clientput "Device: ${response}"
clientput " Sig: [regexp -inline -all $pat [string trim ${response}]]"
}
}
@END
}
}