implement device address and refactor modbus-command to send functions
device address was hard coded and command was embedded in each node r3025 | dcl | 2010-09-14 11:33:41 +1000 (Tue, 14 Sep 2010) | 4 lines
This commit is contained in:
@@ -13,27 +13,30 @@ namespace eval ::scobj::et2000 {
|
||||
close $fd
|
||||
}
|
||||
|
||||
proc getValue {nextState cmd} {
|
||||
sct send $cmd
|
||||
proc getValue {tc_root nextState cmd} {
|
||||
set dev "[hval $tc_root/dev_id]"
|
||||
sct send "$dev:3:$cmd"
|
||||
return $nextState
|
||||
}
|
||||
proc setValue {nextState cmd} {
|
||||
proc setValue {tc_root nextState cmd} {
|
||||
set dev "[hval $tc_root/dev_id]"
|
||||
set par [sct target]
|
||||
sct send "$cmd $par"
|
||||
debug_log "setValue $cmd $par"
|
||||
sct send "$dev:16:$cmd $par"
|
||||
debug_log "setValue $dev:16:$cmd $par"
|
||||
return $nextState
|
||||
}
|
||||
|
||||
proc setPoint {tc_root nextState cmd} {
|
||||
set dev "[hval $tc_root/dev_id]"
|
||||
set par [sct target]
|
||||
|
||||
hset $tc_root/status "busy"
|
||||
if {[sct writestatus] == "start"} {
|
||||
# Called by drive adapter
|
||||
hset $tc_root/status "busy"
|
||||
hsetprop $tc_root/setpoint driving 1
|
||||
}
|
||||
sct send "$cmd $par"
|
||||
debug_log "setPoint $cmd $par"
|
||||
sct send "$dev:16:$cmd $par"
|
||||
debug_log "setPoint $dev:16:$cmd $par"
|
||||
return $nextState
|
||||
}
|
||||
|
||||
@@ -44,6 +47,9 @@ debug_log "setPoint $cmd $par"
|
||||
sct geterror $data
|
||||
}
|
||||
default {
|
||||
if { [hpropexists [sct] geterror] } {
|
||||
hdelprop [sct] geterror
|
||||
}
|
||||
if {$data != [sct oldval]} {
|
||||
sct oldval $data
|
||||
sct update $data
|
||||
@@ -55,7 +61,8 @@ debug_log "setPoint $cmd $par"
|
||||
}
|
||||
|
||||
proc getState {tc_root nextState cmd} {
|
||||
sct send "$cmd"
|
||||
set dev "[hval $tc_root/dev_id]"
|
||||
sct send "$dev:3:$cmd"
|
||||
return $nextState
|
||||
}
|
||||
|
||||
@@ -112,6 +119,10 @@ debug_log "rdState driving $tc_root until $data in ($lotemp, $hitemp)"
|
||||
hset $tc_root/status "idle"
|
||||
hsetprop $tc_root/setpoint driving 0
|
||||
}
|
||||
} else {
|
||||
if {[SplitReply [hget $tc_root/status]] != "idle"} {
|
||||
hset $tc_root/status "idle"
|
||||
}
|
||||
}
|
||||
return idle
|
||||
}
|
||||
@@ -162,8 +173,8 @@ debug_log "halt $tc_root"
|
||||
|
||||
set scobj_hpath /sics/$tempobj
|
||||
hfactory $scobj_hpath/setpoint plain user float
|
||||
hsetprop $scobj_hpath/setpoint read ${ns}::getValue rdValue "1:3:2"
|
||||
hsetprop $scobj_hpath/setpoint write ${ns}::setPoint $scobj_hpath noResponse "1:16:2"
|
||||
hsetprop $scobj_hpath/setpoint read ${ns}::getValue $scobj_hpath rdValue "2"
|
||||
hsetprop $scobj_hpath/setpoint write ${ns}::setPoint $scobj_hpath noResponse "2"
|
||||
hsetprop $scobj_hpath/setpoint check ${ns}::check $scobj_hpath
|
||||
hsetprop $scobj_hpath/setpoint rdValue ${ns}::rdValue
|
||||
hsetprop $scobj_hpath/setpoint noResponse ${ns}::noResponse
|
||||
@@ -176,56 +187,56 @@ debug_log "halt $tc_root"
|
||||
hsetprop $scobj_hpath/setpoint halt ${ns}::halt $scobj_hpath
|
||||
|
||||
hfactory $scobj_hpath/overtemp_warnlimit plain user float
|
||||
hsetprop $scobj_hpath/overtemp_warnlimit read ${ns}::getValue rdValue "1:3:14"
|
||||
hsetprop $scobj_hpath/overtemp_warnlimit write ${ns}::setValue noResponse "1:16:14"
|
||||
hsetprop $scobj_hpath/overtemp_warnlimit read ${ns}::getValue $scobj_hpath rdValue "14"
|
||||
hsetprop $scobj_hpath/overtemp_warnlimit write ${ns}::setValue $scobj_hpath noResponse "14"
|
||||
hsetprop $scobj_hpath/overtemp_warnlimit rdValue ${ns}::rdValue
|
||||
hsetprop $scobj_hpath/overtemp_warnlimit noResponse ${ns}::noResponse
|
||||
hsetprop $scobj_hpath/overtemp_warnlimit oldval UNKNOWN
|
||||
|
||||
hfactory $scobj_hpath/subtemp_warnlimit plain user float
|
||||
hsetprop $scobj_hpath/subtemp_warnlimit read ${ns}::getValue rdValue "1:3:13"
|
||||
hsetprop $scobj_hpath/subtemp_warnlimit write ${ns}::setValue noResponse "1:16:13"
|
||||
hsetprop $scobj_hpath/subtemp_warnlimit read ${ns}::getValue $scobj_hpath rdValue "13"
|
||||
hsetprop $scobj_hpath/subtemp_warnlimit write ${ns}::setValue $scobj_hpath noResponse "13"
|
||||
hsetprop $scobj_hpath/subtemp_warnlimit rdValue ${ns}::rdValue
|
||||
hsetprop $scobj_hpath/subtemp_warnlimit noResponse ${ns}::noResponse
|
||||
hsetprop $scobj_hpath/subtemp_warnlimit oldval UNKNOWN
|
||||
|
||||
hfactory $scobj_hpath/sensor plain spy none
|
||||
hfactory $scobj_hpath/sensor/value plain internal float
|
||||
hsetprop $scobj_hpath/sensor/value read ${ns}::getValue rdValue "1:3:1"
|
||||
hsetprop $scobj_hpath/sensor/value read ${ns}::getValue $scobj_hpath rdValue "1"
|
||||
hsetprop $scobj_hpath/sensor/value rdValue ${ns}::rdValue
|
||||
hsetprop $scobj_hpath/sensor/value oldval UNKNOWN
|
||||
hsetprop $scobj_hpath/sensor/value units "C"
|
||||
|
||||
hfactory $scobj_hpath/setpoint_slew_rate plain user float
|
||||
hsetprop $scobj_hpath/setpoint_slew_rate read ${ns}::getValue rdValue "1:3:35"
|
||||
hsetprop $scobj_hpath/setpoint_slew_rate write ${ns}::setValue noResponse "1:16:35"
|
||||
hsetprop $scobj_hpath/setpoint_slew_rate read ${ns}::getValue $scobj_hpath rdValue "35"
|
||||
hsetprop $scobj_hpath/setpoint_slew_rate write ${ns}::setValue $scobj_hpath noResponse "35"
|
||||
hsetprop $scobj_hpath/setpoint_slew_rate rdValue ${ns}::rdValue
|
||||
hsetprop $scobj_hpath/setpoint_slew_rate noResponse ${ns}::noResponse
|
||||
hsetprop $scobj_hpath/setpoint_slew_rate oldval UNKNOWN
|
||||
|
||||
hfactory $scobj_hpath/power_limit_low plain user float
|
||||
hsetprop $scobj_hpath/power_limit_low read ${ns}::getValue rdValue "1:3:31"
|
||||
hsetprop $scobj_hpath/power_limit_low write ${ns}::setValue noResponse "1:16:31"
|
||||
hsetprop $scobj_hpath/power_limit_low read ${ns}::getValue $scobj_hpath rdValue "31"
|
||||
hsetprop $scobj_hpath/power_limit_low write ${ns}::setValue $scobj_hpath noResponse "31"
|
||||
hsetprop $scobj_hpath/power_limit_low rdValue ${ns}::rdValue
|
||||
hsetprop $scobj_hpath/power_limit_low noResponse ${ns}::noResponse
|
||||
hsetprop $scobj_hpath/power_limit_low oldval UNKNOWN
|
||||
|
||||
hfactory $scobj_hpath/power_limit_high plain user float
|
||||
hsetprop $scobj_hpath/power_limit_high read ${ns}::getValue rdValue "1:3:30"
|
||||
hsetprop $scobj_hpath/power_limit_high write ${ns}::setValue noResponse "1:16:30"
|
||||
hsetprop $scobj_hpath/power_limit_high read ${ns}::getValue $scobj_hpath rdValue "30"
|
||||
hsetprop $scobj_hpath/power_limit_high write ${ns}::setValue $scobj_hpath noResponse "30"
|
||||
hsetprop $scobj_hpath/power_limit_high rdValue ${ns}::rdValue
|
||||
hsetprop $scobj_hpath/power_limit_high noResponse ${ns}::noResponse
|
||||
hsetprop $scobj_hpath/power_limit_high oldval UNKNOWN
|
||||
|
||||
hfactory $scobj_hpath/power_slew_rate plain user float
|
||||
hsetprop $scobj_hpath/power_slew_rate read ${ns}::getValue rdValue "1:3:37"
|
||||
hsetprop $scobj_hpath/power_slew_rate write ${ns}::setValue noResponse "1:16:37"
|
||||
hsetprop $scobj_hpath/power_slew_rate read ${ns}::getValue $scobj_hpath rdValue "37"
|
||||
hsetprop $scobj_hpath/power_slew_rate write ${ns}::setValue $scobj_hpath noResponse "37"
|
||||
hsetprop $scobj_hpath/power_slew_rate rdValue ${ns}::rdValue
|
||||
hsetprop $scobj_hpath/power_slew_rate noResponse ${ns}::noResponse
|
||||
hsetprop $scobj_hpath/power_slew_rate oldval UNKNOWN
|
||||
|
||||
hfactory $scobj_hpath/heating_power_percent plain internal float
|
||||
hsetprop $scobj_hpath/heating_power_percent read ${ns}::getValue rdValue "1:3:3"
|
||||
hsetprop $scobj_hpath/heating_power_percent read ${ns}::getValue $scobj_hpath rdValue "3"
|
||||
hsetprop $scobj_hpath/heating_power_percent rdValue ${ns}::rdValue
|
||||
hsetprop $scobj_hpath/heating_power_percent oldval UNKNOWN
|
||||
|
||||
@@ -241,7 +252,7 @@ debug_log "halt $tc_root"
|
||||
hset $scobj_hpath/tolerance $tol
|
||||
|
||||
hfactory $scobj_hpath/dev_id plain user int
|
||||
hsetprop $scobj_hpath/dev_id values 1,2,3,4,5,6,7,8,9
|
||||
hsetprop $scobj_hpath/dev_id values 1,2,3,4,5,6,7,8,9,10,11
|
||||
hset $scobj_hpath/dev_id $dev_id
|
||||
|
||||
hfactory $scobj_hpath/status plain spy text
|
||||
@@ -249,7 +260,7 @@ debug_log "halt $tc_root"
|
||||
hsetprop $scobj_hpath/status values busy,idle
|
||||
|
||||
hfactory $scobj_hpath/et2000_state plain spy text
|
||||
hsetprop $scobj_hpath/et2000_state read ${ns}::getState $scobj_hpath rdState "1:3:1"
|
||||
hsetprop $scobj_hpath/et2000_state read ${ns}::getState $scobj_hpath rdState "1"
|
||||
hsetprop $scobj_hpath/et2000_state rdState ${ns}::rdState $scobj_hpath
|
||||
hsetprop $scobj_hpath/et2000_state oldval UNKNOWN
|
||||
|
||||
@@ -261,7 +272,7 @@ debug_log "halt $tc_root"
|
||||
|
||||
hfactory $scobj_hpath/lowerlimit plain mugger float
|
||||
hsetprop $scobj_hpath/lowerlimit units "C"
|
||||
hset $scobj_hpath/lowerlimit 1
|
||||
hset $scobj_hpath/lowerlimit 0
|
||||
|
||||
hfactory $scobj_hpath/upperlimit plain mugger float
|
||||
hsetprop $scobj_hpath/upperlimit units "C"
|
||||
@@ -338,11 +349,11 @@ debug_log "halt $tc_root"
|
||||
proc add_et2000 {name IP port dev_id {_tol 5.0}} {
|
||||
set fd [open "/tmp/et2000.log" a]
|
||||
if {[SplitReply [environment_simulation]]=="false"} {
|
||||
puts $fd "makesctcontroller sct_et2000 modbus ${IP}:$port"
|
||||
makesctcontroller sct_et2000 modbus ${IP}:$port
|
||||
puts $fd "makesctcontroller sct_${name} modbus ${IP}:$port"
|
||||
makesctcontroller sct_${name} modbus ${IP}:$port
|
||||
}
|
||||
puts $fd "mk_sct_eurotherm_et2000 sct_et2000 environment $name $dev_id $_tol"
|
||||
mk_sct_eurotherm_et2000 sct_et2000 environment $name $dev_id $_tol
|
||||
puts $fd "mk_sct_eurotherm_et2000 sct_${name} environment $name $dev_id $_tol"
|
||||
mk_sct_eurotherm_et2000 sct_${name} environment $name $dev_id $_tol
|
||||
puts $fd "makesctemon $name /sics/$name/emon/monmode /sics/$name/emon/isintol /sics/$name/emon/errhandler"
|
||||
makesctemon $name /sics/$name/emon/monmode /sics/$name/emon/isintol /sics/$name/emon/errhandler
|
||||
close $fd
|
||||
|
||||
Reference in New Issue
Block a user