set sim_mode [SplitReply [plc_simulation]] if {$sim_mode == "false"} { MakeAsyncQueue plc_chan SafetyPLC [dict get $::PLC_HOSTPORT HOST] [dict get $::PLC_HOSTPORT PORT] MakeSafetyPLC plc plc_chan 0 } # Configuration Note: # # A default setting has been set in safetyplc.c code. following configuration # settings are only required when necessacy. # # fields Collimationgate, Detectorgate, Fastshutter, SecondTerShutter # and IndTerShutter NOT belong to dafault fields and need to be configured # based on particular instrument during deployment # values: 1 -- will display in PLC List # 0 -- wont show in PLC List set bitstream "" foreach {para paraval} { Key 1 Secondary 1 Tertiary 1 MotionControl 1 Access 1 DC 1 Exit 1 Trip 1 Fault 1 Operate 1 Relay 1 Ready 1 Collimationgate 0 Detectorgate 0 Fastshutter 1 SecondTerShutter 0 IndTerShutter 0 } { append bitstream $paraval } plc setlist $bitstream proc shutter {args} { set cmd "set shutter=$args\r\n" sct_shutter transact $cmd } proc focuslight {args} { set cmd "set focuslight=$args\r\n" sct_shutter transact $cmd } proc tertiary {sw} { set sw [string tolower $sw] switch $sw { "open" { wait 1 plc_chan send set output=0 wait 1 plc_chan send set output=3 wait 1 plc_chan send set output=1 wait 1 plc_chan send set output=3 } "close" { wait 1 plc_chan send set output=0 wait 1 plc_chan send set output=3 wait 1 plc_chan send set output=2 wait 1 plc_chan send set output=3 } default { clientput ERROR: [info level 0] command should be open or close not $sw } } } publish shutter user publish focuslight user publish tertiary user source $cfPath(plc)/plc_common_1.tcl set plc_t "plc" MakeSICSObj $plc SCT_OBJECT sicslist setatt $plc_t klass environment sicslist setatt $plc_t long_name $plc_t set scobj_hpath /sics/$plc_t proc ::scobj::plc::getPlcValue {nextstate} { plc_chan transact "READ" return $nextstate } proc ::scobj::plc::rdPlcValue {} { set replyData [string trimright [sct result] " \r\n"] set d1 [clock format [clock seconds] -format %d%h%Y] set fd [open "../log/plc.log" a] puts $fd "[clock format [clock seconds] -format "%D %T "] [string trim $replyData "{}"]" close $fd return idle } set ns ::::scobj::plc hsetprop $scobj_hpath read ${ns}::getPlcValue getPlcValueState hsetprop $scobj_hpath getPlcValueState ${ns}::rdPlcValue plc_chan poll $scobj_hpath 5