|
AIDA
GELINA
BRIKEN
nToF
CRIB
ISOLDE
CIRCE
nTOFCapture
DESPEC
DTAS
EDI_PSA
179Ta
CARME
StellarModelling
DCF
K40
|
AIDA |
 |
|
Message ID: 216
Entry time: Tue May 10 16:03:50 2016
|
Author: |
TD & VFEP |
Subject: |
Latest version of Rly16 |
|
|
Do not forget to backup the current versions of the attached files before
installing the latest versions. The latest version features the sequential
power up of each of the eight mains relays - this will help minimise instantaneous
network loads during power/boot up.
On 05/05/2016 06:45, Thomas Davinson wrote:
Hello
Coould we have a copy of the latest USB power replay .tml file please?
Our current version does not permit sequential power on and Patrick says
that may be helpful when attempting to start 32 FEEs.
attached
=> /MIDAS/TclHttpd/Aida/Rly16
Vic |
|
|
# variable started 0
if {![info exists started]} {variable started 0}
if {$started != 0} {
variable JS ""
variable LogFlag
if {$LogFlag == 1} {InsertLog "Last Updated: [clock format [clock seconds] -format "%B %d, %Y %H:%M:%S"]"}
do_click
}
if {$started == 0} { ;# first time load code and define local variables
set started 1
variable LogText ""
variable LogFlag 0
variable LogCount 0
variable ShowLogFlag 0
variable JS ""
variable Port /dev/ttyUSB0
variable Baud 19200
variable Data 8
variable Parity n
variable Stop 2
variable Flow none
variable channelId 0
variable VERSION 0
variable DC 0
variable STATUS 0
proc show_variables {} {
variable LogFlag
variable LogCount
variable ShowLogFlag
InsertLog "LogFlag=$LogFlag; LogCount=$LogCount; ShowLogFlag=$ShowLogFlag"
InsertLog "DC=[DC]; Status=[Status]"
}
proc do_connect {} {
global env
variable channelId
variable Port
variable Baud
variable Data
variable Parity
variable Stop
variable Flow
if {$channelId != 0} {
InsertLog "Already connected: Disconnect first"
return
}
for {set p 0} {$p < 8} {incr p} {
set Port /dev/ttyUSB$p
if {$env(os) == "Linux" || $env(os) == "Linux64"} {
set z [catch {exec sudo -n chmod 666 $Port} m] ;# need rw access to serial port
if {$z != 0} {InsertLog "failed to change access mode to I/O port\n$m"; continue}
}
set rc [catch {open $Port RDWR} m]
if {$rc == 0} {set channelId $m; InsertLog "Using $Port"} else {InsertLog "$Port: $m"}
if {$channelId != 0} {
fconfigure $channelId -mode $Baud,$Parity,$Data,$Stop -handshake $Flow
fconfigure $channelId -blocking no -buffering none -translation binary
fileevent $channelId readable GetData
set V [VERS]
InsertLog "firmware version = $V"
if {$V > 0} {break} else {do_disconnect}
}
}
}
proc do_disconnect {} {
variable channelId
variable Port
if {$channelId == 0} {
# InsertLog "Already disconnected"
} else {
set z [catch {close $channelId} m]
set channelId 0
}
}
proc SetOff {n} {
variable channelId
if {$channelId == 0} {do_connect}
if {$channelId == 0} {InsertLog "Not connected"; return}
switch $n {
1 {puts $channelId "o"}
2 {puts $channelId "p"}
3 {puts $channelId "q"}
4 {puts $channelId "r"}
5 {puts $channelId "s"}
6 {puts $channelId "t"}
7 {puts $channelId "u"}
8 {puts $channelId "v"}
default {}
}
Status
}
proc SetOn {n} {
variable channelId
if {$channelId == 0} {do_connect}
if {$channelId == 0} {InsertLog "Not connected"; return}
switch $n {
1 {puts $channelId "e"}
2 {puts $channelId "f"}
3 {puts $channelId "g"}
4 {puts $channelId "h"}
5 {puts $channelId "i"}
6 {puts $channelId "j"}
7 {puts $channelId "k"}
8 {puts $channelId "l"}
default {}
}
Status
}
proc SequenceOn {} {
variable channelId
if {$channelId == 0} {do_connect}
if {$channelId == 0} {InsertLog "Not connected"; return}
foreach chan { 1 2 3 4 5 6 7 8 } {
SetOn $chan
after 500
}
}
proc AllOff {} {
variable channelId
if {$channelId == 0} {do_connect}
if {$channelId == 0} {InsertLog "Not connected"; return}
set z [catch {puts $channelId "n"} m]
if {$z != 0} {return}
Status
}
proc AllOn {} {
variable channelId
if {$channelId == 0} {do_connect}
if {$channelId == 0} {InsertLog "Not connected"; return}
set z [catch {puts $channelId "d"} m]
if {$z != 0} {return}
Status
}
proc DC {} {
variable channelId
variable DC
if {$channelId == 0} {do_connect}
if {$channelId == 0} {InsertLog "Not connected"; return}
set z [catch {puts $channelId "\]"} m]
if {$z != 0} {return}
after 200
set DC [expr 0x[GetData]]
}
proc VERS {} {
variable channelId
variable VERSION
if {$channelId == 0} {do_connect}
if {$channelId == 0} {InsertLog "Not connected"; return}
set z [catch {puts $channelId "Z"} m]
if {$z != 0} {return}
after 200
set VERSION [GetData]
}
proc Status {} {
variable channelId
variable STATUS
if {$channelId == 0} {do_connect}
if {$channelId == 0} {InsertLog "Not connected"; return}
set z [catch {puts $channelId "["} m]
if {$z != 0} {return}
after 500
set z [catch {set STATUS [expr 0x[GetData]]} m]
}
proc GetData {args} {
variable channelId
if {$channelId == 0} {do_connect}
if {$channelId == 0} {InsertLog "Not connected"; return 0}
set data [read $channelId 132]
if {[string length $data] == 0} {return 0}
set line ""
for {set i 0} {$i < [string length $data]} {incr i} {
set c1 [string range $data $i $i]
binary scan $c1 H2 c2
append line "[set c2]"
}
return "$line"
}
proc do_click {} {
variable cgidata
variable started
variable LogFlag
variable ShowLogFlag
variable JS
set cgidata [ncgi::nvlist]
if {$LogFlag == 1} {InsertLog "cgidata= ([llength $cgidata]) $cgidata"}
if {[llength $cgidata] == 0} then {return}
if {[llength $cgidata] < 2} then {
InsertLog "CGI data is too short: $cgidata"
} else {
if {[lindex $cgidata 0] != "Widget"} then {
InsertLog "Invalid CGI data: $cgidata"
} else {
set w [first [lindex $cgidata 1]]
set vl [second [lindex $cgidata 1]]
switch -glob $w {
RESET {catch {do_disconnect}; set started 0}
CLEAR {EmptyLog}
ELOG {PrintLog}
RELOAD {}
VARIABLES {show_variables}
HIDE {set ShowLogFlag 0}
SHOW {set ShowLogFlag 1}
LOGON {set LogFlag 1}
LOGOFF {set LogFlag 0}
SEQ {SequenceOn}
ALLON {AllOn}
ALLOFF {AllOff}
RELAYON {SetOn $vl}
RELAYOFF {SetOff $vl}
MainLog {}
undefined {}
default {InsertLog "unexpected CGI data: [lindex $w 0]: $cgidata"}
}
}
}
catch {Status}
}
... 6 more lines ...
|
|