AIDA GELINA BRIKEN nToF CRIB ISOLDE CIRCE nTOFCapture DESPEC DTAS EDI_PSA 179Ta CARME StellarModelling DCF K40
  AIDA  ELOG logo
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 
Attachment 1: Rly16.js  471 Bytes  | Hide | Hide all


function click_SEQ (Obj) {
    Obj.Widget.value = "SEQ";
    Obj.submit();
}
function click_ALLON (Obj) {
    Obj.Widget.value = "ALLON";
    Obj.submit();
}
function click_ALLOFF (Obj) {
    Obj.Widget.value = "ALLOFF";
    Obj.submit();
}

function click_RELAYON (Obj,vl) {
    Obj.Widget.value = "RELAYON" + " " + vl;
    Obj.submit();
}

function click_RELAYOFF (Obj,vl) {
    Obj.Widget.value = "RELAYOFF" + " " + vl;
    Obj.submit();
}

Attachment 2: Rly16.tcl  6 kB  | Hide | Hide all


# 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 ...
Attachment 3: Rly16.tml  5 kB  | Hide | Hide all

[Doc_Dynamic]

<!
[global env; set env(MIDASBASE) /MIDAS]
>

[global env; source [file join $env(MIDASBASE) TclHttpd Html settings.tml]]

<!
[global Httpd; upvar #0 Httpd[set Httpd(currentSocket)] data; set ClientIPAddress $data(ipaddr); set MyInfo $data(self)]
>

<html>
<head>

<title>Rly16 Service @ [global env; set env(ComputerName)]</title>

<script type="text/javascript" language="JavaScript" src="/js/Common.js"></script>
<script type="text/javascript" language="JavaScript" src="/js/FormChek.js"></script>
<script type="text/javascript" language="JavaScript" src="Rly16.js"></script>

</head>

<body>

<NOSCRIPT>
<hr>
<h2>
Your browser does not support JavaScript.
This service requires a JavaScript compatible browser. </h2> <hr> </NOSCRIPT> <p align=center> <table cellpadding=0 cellspacing=0 border=0 width=100%> <tr> <td align=left> <font size=4><b>Rly16 Control @ [set MyInfo]</b></font> </td> <td align=right> <font size=4><b>client address is [set ClientIPAddress]</b></font> </td> <td align=right> <input type=image src="/images/midas.gif" name=MIDAS title="MIDAS Home Page" onClick="click_MIDAS()"> <input type=image src="/images/tclp.gif" name=TCL title="Tcl/Tk Home Page" onClick="click_TCL()"> </td> </tr> </table> </p> <hr> <! [namespace eval Rly16 {global env; cd [file join $env(MIDASBASE) TclHttpd Html AIDA]}] [namespace eval Rly16 { global env source [file join $env(MIDASBASE) TclHttpd tcl Common common.tcl] cd [file join $env(MIDASBASE) TclHttpd Html AIDA Rly16] source Rly16.tcl }] > <form action=[ncgi::urlStub] name=Rly16 method=post> <input type=hidden name=Widget value=Rly16> <p align="center"> <table cellpadding=0 cellspacing=0 border=0 width=100%> <tr> <td width=33% align=left> Port: [namespace eval Rly16 {set Port}] </td> <td width=33% align=left> Version: [namespace eval Rly16 {VERS; set VERSION}] </td> <td width=33% align=left> DC: [namespace eval Rly16 {DC; set vl [expr $DC/10.0]V}] </td> </tr> </table> </p> <p align=center> <table cellpadding=0 cellspacing=0 border=0 width=100%> <tr> [namespace eval Rly16 { set html "<td width=12% align=left>Switch ON</td>" set j 0 for {set i 1} {$i <= 8} {incr i} { append html "<td width=11% align=left>" if {([expr $STATUS >> $j] & 1) == 0} { append html "<input type=button name=RON$i value=\"Relay $i\" onClick=\"click_RELAYON(document.Rly16, $i)\">" } append html "</td>" incr j } set html }] </tr> <tr> [namespace eval Rly16 { set html "<td width=12% align=left>Switch OFF</td>" set j 0 for {set i 1} {$i <= 8} {incr i} { append html "<td width=11% align=left>" if {([expr $STATUS >> $j] & 1) == 1} { append html "<input type=button name=ROFF$i value=\"Relay $i\" onClick=\"click_RELAYOFF(document.Rly16, $i)\">" } append html "</td>" incr j } set html }] </tr> </table> </p> <p align=center> <input type=button name=SEQ value="Sequence ALL On" onClick="click_SEQ(document.Rly16)"> <input type=button name=ALLON value="Switch ALL On" onClick="click_ALLON(document.Rly16)"> <input type=button name=ALLOFF value="Switch ALL Off" onClick="click_ALLOFF(document.Rly16)"> </p> [namespace eval Rly16 { if {$ShowLogFlag == 1} then { set html "" append html "<p align=center>" append html "<textarea name=MainLog readonly=true wrap=soft rows=12 cols=80>" append html [set LogText] append html "</textarea>" append html "</p>" set html } }] <p> <input type=button name=CLEAR value="Empty Log Window" onClick="click_clear(document.Rly16)" title="Empty the log window"> <input type=button name=ELOG value="Send Log Window to ELog" onClick="click_elog(document.Rly16)" title="Sends the contents of the log window to your ELog"> <input type=button name=RELOAD value="Reload" onClick="click_reload(document.Rly16)" title="Reload the page and cause the displayed hardware parameters to be refreshed"> <input type=button name=RESET value="Reset" onClick="click_reset(document.Rly16)" title="Cause the page code to be fully reloaded in the server"> <input type=button name=VARIABLES value="Show Variables" onClick="click_variables(document.Rly16)" title="Display selected internal variables in the log window"> [namespace eval Rly16 { if {$ShowLogFlag == 1} then { set html "<input type=button name=HIDE value=\"Hide Log Window\" onClick=\"click_hidelog(document.Rly16)\" title=\"Do not display the log window\">" } else { set html "<input type=button name=SHOW value=\"Show Log Window\" onClick=\"click_showlog(document.Rly16)\" title=\"Cause the log window to be displayed\">" } set html }] [namespace eval Rly16 { if {$LogFlag == 1} then { set html "<input type=button name=LOGOFF value=\"Disable Logging\" onClick=\"click_disablelog(document.Rly16)\">" } else { set html "<input type=button name=LOGON value=\"Enable Logging\" onClick=\"click_enablelog(document.Rly16)\">" } set html }] </p> </form> <p align=right> Last Updated: [clock format [clock seconds] -format "%B %d, %Y %H:%M:%S"] </p> <hr> [namespace eval Rly16 { if {$JS != ""} { append JS "\");" set html "<script>[set JS]</script>" } }]
ELOG V3.1.4-unknown