From 99dea317f0ee31125ff182725e30df4e717fa7da Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Thu, 21 Aug 2014 09:42:19 +1000 Subject: [PATCH 01/68] Refactor free of command/transaction code to function --- asyncqueue.c | 36 ++++++++++++++++++------------------ 1 file changed, 18 insertions(+), 18 deletions(-) diff --git a/asyncqueue.c b/asyncqueue.c index e1c52173..5d262c62 100644 --- a/asyncqueue.c +++ b/asyncqueue.c @@ -90,6 +90,22 @@ static const char *state_name(AsyncState the_state) return ""; } +/* + * Free the command and transaction structures and their contents + */ +static void free_command(pAQ_Cmd myCmd) +{ + free(myCmd->tran->out_buf); + free(myCmd->tran->inp_buf); + if (myCmd->tran->proto_private) + if (myCmd->tran->kill_private) + myCmd->tran->kill_private(myCmd->tran); + else + free(myCmd->tran->proto_private); + free(myCmd->tran); + free(myCmd); +} + /* ---------------------------- Local ------------------------------------ CreateSocketAdress stolen from Tcl. Thanks to John Ousterhout */ @@ -165,15 +181,7 @@ static void AQ_Purge(pAsyncQueue self) self->command_head = myCmd->next; } else self->command_head = self->command_tail = NULL; - free(myCmd->tran->out_buf); - free(myCmd->tran->inp_buf); - if (myCmd->tran->proto_private) - if (myCmd->tran->kill_private) - myCmd->tran->kill_private(myCmd->tran); - else - free(myCmd->tran->proto_private); - free(myCmd->tran); - free(myCmd); + free_command(myCmd); myCmd = self->command_head; } } @@ -458,15 +466,7 @@ static int PopCommand(pAsyncQueue self) StartCommand(self); } else self->command_head = self->command_tail = NULL; - free(myCmd->tran->out_buf); - free(myCmd->tran->inp_buf); - if (myCmd->tran->proto_private) - if (myCmd->tran->kill_private) - myCmd->tran->kill_private(myCmd->tran); - else - free(myCmd->tran->proto_private); - free(myCmd->tran); - free(myCmd); + free_command(myCmd); return 1; } From 6054eeeae94690ba8a13aa73fc5b4548c1f38361 Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Thu, 21 Aug 2014 17:23:42 +1000 Subject: [PATCH 02/68] Restructure free_command to afford protocol module more control This allows the protocol module first cleanup opportunity on Txn --- asyncqueue.c | 27 ++++++++++++++++++--------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/asyncqueue.c b/asyncqueue.c index 5d262c62..6695a2b8 100644 --- a/asyncqueue.c +++ b/asyncqueue.c @@ -95,15 +95,24 @@ static const char *state_name(AsyncState the_state) */ static void free_command(pAQ_Cmd myCmd) { - free(myCmd->tran->out_buf); - free(myCmd->tran->inp_buf); - if (myCmd->tran->proto_private) - if (myCmd->tran->kill_private) - myCmd->tran->kill_private(myCmd->tran); - else - free(myCmd->tran->proto_private); - free(myCmd->tran); - free(myCmd); + if (myCmd) { + pAsyncTxn myTxn = myCmd->tran; + if (myTxn) { + /* + * Allow kill_private to clean it all if it wants + */ + if (myTxn->kill_private) + myTxn->kill_private(myTxn); + if (myTxn->out_buf) + free(myTxn->out_buf); + if (myTxn->inp_buf) + free(myTxn->inp_buf); + if (myTxn->proto_private) + free(myTxn->proto_private); + free(myTxn); + } + free(myCmd); + } } /* ---------------------------- Local ------------------------------------ From a0acd1e5b43434289863134dff96e4c53c2896f1 Mon Sep 17 00:00:00 2001 From: Ferdi Franceschini Date: Thu, 21 Aug 2014 10:19:55 +1000 Subject: [PATCH 03/68] SICS-458: Add dsc command to run a DSC acquisition on Quokka. Also added dsc.py utility which finds the start of a DSC profile in hdf files. --- .../sans/config/commands/growfile.tcl | 96 +++++++++++++++++++ .../instrument/sans/quokka_configuration.tcl | 1 + site_ansto/instrument/sans/util/dsc.py | 94 ++++++++++++++++++ 3 files changed, 191 insertions(+) create mode 100644 site_ansto/instrument/sans/config/commands/growfile.tcl create mode 100755 site_ansto/instrument/sans/util/dsc.py diff --git a/site_ansto/instrument/sans/config/commands/growfile.tcl b/site_ansto/instrument/sans/config/commands/growfile.tcl new file mode 100644 index 00000000..b92c8703 --- /dev/null +++ b/site_ansto/instrument/sans/config/commands/growfile.tcl @@ -0,0 +1,96 @@ +# \file Implements 'dsc actime interval' command. +set GROWFILE_STATE "DISABLED" +set growfileSaveIndex 0 + + +proc doGrowFile {} { + global GROWFILE_STATE + global growfileSaveIndex + +# Reset the GROWFILE_STATE variable in case some naughty user sets it directly + set GROWFILE_STATE "ENABLED" + set HMSTATE [SplitReply [hmm configure daq]] + set FSTATE [SplitReply [file_status]] +# broadcast CALLED: [info level 0], HMSTATE = $HMSTATE, FSTATE = $FSTATE + if { $FSTATE != "UNKNOWN" && $FSTATE != "OPEN" && $HMSTATE == "Started"} { +# broadcast growfile $growfileSaveIndex + save $growfileSaveIndex "growfile" + incr growfileSaveIndex + } else { + if {$growfileSaveIndex == 0} { + broadcast ERROR: GROWFILE HMSTATE = $HMSTATE, FSTATE = $FSTATE. The histmem must be running and you must create a newfile before calling "growfile" + } else { + broadcast STOP GROWFILE Acquisition finished. HMSTATE = $HMSTATE, FSTATE = $FSTATE. + save $growfileSaveIndex "growfile" + newfile clear + broadcast Saved [hval /experiment/file_name] + } + set growfileSaveIndex 0 + sicspoll del doGrowFile + set GROWFILE_STATE "DISABLED" + hsetprop /instrument/detector/hmm mutable true + } +} +publish doGrowFile user + + +proc growfile { {interval 300} } { + global GROWFILE_STATE + global growfileSaveIndex + + set GROWFILE_STATE "DISABLED" + set growfileSaveIndex 0 + + set as_error 0 + + set myrights [set_rights manager] + if {$myrights == -1} { + return -code error "ERROR: You are not authorized for this operation" + } + set interval [string tolower $interval] + if {$interval == "check" || $interval == "status"} { + if { $GROWFILE_STATE == "ENABLED" } { + return "GROWFILE $GROWFILE_STATE [sicspoll intervall doGrowFile]" + } else { + return "GROWFILE $GROWFILE_STATE" + } + } elseif {[string is integer $interval]} { + if {$interval <= 0} { + if { $GROWFILE_STATE == "ENABLED" } { + sicspoll del doGrowFile + set GROWFILE_STATE "DISABLED" + } + } else { + if {$GROWFILE_STATE == "DISABLED"} { + sicspoll add doGrowFile script $interval doGrowFile +# sicspoll listen # WARNING:When the listening client exits it leaves SICSPOLL task with a corrupt connection object. + set GROWFILE_STATE "ENABLED" + } else { + sicspoll intervall doGrowFile $interval + } + } + } else { + set as_error 1 + } + + set_rights $myrights + + if {$as_error} { + return -code error "ERROR: Invalid argument in '[info level 0]', should be an integer or 'check'" + } +} +publish growfile user + +# \brief Run histogram for the specified time and save XY binned data at the given interval. +# \param actime Acquisition time in seconds. +# \param saveint Save interval in seconds. +proc dsc {actime saveint} { + hsetprop /instrument/detector/hmm mutable false + newfile HISTOGRAM_XY + histmem mode time + histmem preset $actime + histmem start + growfile $saveint +} + +publish dsc user diff --git a/site_ansto/instrument/sans/quokka_configuration.tcl b/site_ansto/instrument/sans/quokka_configuration.tcl index 6bdce7e5..3bf7f0d0 100644 --- a/site_ansto/instrument/sans/quokka_configuration.tcl +++ b/site_ansto/instrument/sans/quokka_configuration.tcl @@ -73,6 +73,7 @@ fileeval $cfPath(environment)/sct_antonparr_MCR500.tcl fileeval $cfPath(beamline)/spin_flipper.tcl fileeval $cfPath(commands)/pulser.tcl fileeval $cfPath(commands)/hvcommands.tcl +fileeval $cfPath(commands)/growfile.tcl source gumxml.tcl diff --git a/site_ansto/instrument/sans/util/dsc.py b/site_ansto/instrument/sans/util/dsc.py new file mode 100755 index 00000000..379900f2 --- /dev/null +++ b/site_ansto/instrument/sans/util/dsc.py @@ -0,0 +1,94 @@ +#!/usr/bin/env python +# vim: ft=python ts=8 sts=4 sw=4 expandtab autoindent smartindent +""" Find the trigger time for Differenctial Scanning Calorimetry data in nx.hdf files. """ + +import sys +import os +import h5py +import argparse +import time +from collections import defaultdict + +class SkipFile(BaseException): + """This exception should be raised to skip processing a file""" + pass + +PARSER = argparse.ArgumentParser( + description = """Report the time offset for the start of the DSC profile relative to the start time of the histogram data. + This program can process multiple hdf files by specifying the path to the first file and the number of files to process. + You can also speficy a list of 'file_path numfile' pairs.""", + usage='dsc file_path numfile {file_path numfile}' +) +PARSER.add_argument('files', nargs='+', help = 'List of "file_path numfile" pairs') +ARGS = PARSER.parse_args() + +FAILS = defaultdict(list) +for startfile, num in zip(ARGS.files[0::2], ARGS.files[1::2]): + numfiles = int(num) + hfdir = os.path.dirname(startfile) + hfbase = os.path.basename(startfile) + idx = hfbase.find('.') + startFID = hfbase[:idx] + ext = hfbase[idx:] + idnum = int(startFID[3:]) + inst_abname = hfbase[:3] + + hfval = {} + print + for i in range(numfiles): + try: + currid = idnum + i + fileID = inst_abname + '%07d' % currid + if (hfdir == ''): + nxfile = fileID + ext + else: + nxfile = hfdir + '/' + fileID + ext + + try: + hf = h5py.File(nxfile, 'r') + except: + FAILS['badfile'].append(nxfile) + continue + + if (hfbase.startswith('QKK')): + rootpath = fileID + '/' + else: + rootpath = 'entry1/' + + for dpath in ['time_stamp', 'instrument/detector/start_time', 'sample/dsc_val']: + dscpath = rootpath + dpath + if dscpath in hf: + hfval[dpath] = hf[dscpath][:] + else: + FAILS['badpath:{0}'.format(dpath)].append(nxfile) + hf.close() + raise SkipFile + + print fileID + datiter = {} + dat_hasnext = 0 + time_tuple = time.strptime(hf[rootpath + 'start_time'][0], '%Y-%m-%d %H:%M:%S') + hfval['time_stamp'] += time.mktime(time_tuple) + hfval['time_stamp'] -= hfval['instrument/detector/start_time'] + dsc0 = hfval['sample/dsc_val'][0] + no_transition = True + for i in range(1, len(hfval['sample/dsc_val'][1:])): + dsc1 = hfval['sample/dsc_val'][i] + if abs(dsc1 - dsc0) > 1.9: + no_transition = False + msg = 'dsc_val transition from {dsc0} to {dsc1} volts at {time} seconds from detector start time, array index = {index}' + print msg.format(dsc0=dsc0, dsc1=dsc1, time=hfval['time_stamp'][i], index=i) + dsc0 = dsc1 + + if no_transition: + print 'dsc_val no transition' + + print + hf.close() + except SkipFile: + continue + +for k in FAILS.keys(): + if (len(FAILS[k])): + print >> sys.stderr, 'Skipped following files. Reason = ', k + print >> sys.stderr, FAILS[k] From 78cfe7f5a9ee1e4f435cbfd021b823627fb99121 Mon Sep 17 00:00:00 2001 From: Ferdi Franceschini Date: Fri, 22 Aug 2014 12:00:33 +1000 Subject: [PATCH 04/68] SICS-770 Fixed SICS reports 'bad status code' when scanning the schp motor --- .../instrument/pelican/config/chopper/fermimot.tcl | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) diff --git a/site_ansto/instrument/pelican/config/chopper/fermimot.tcl b/site_ansto/instrument/pelican/config/chopper/fermimot.tcl index be3d6648..ba5aae80 100644 --- a/site_ansto/instrument/pelican/config/chopper/fermimot.tcl +++ b/site_ansto/instrument/pelican/config/chopper/fermimot.tcl @@ -423,13 +423,16 @@ namespace eval ::chopper { set catch_status [ catch { if [hgetpropval $hpath/$node abort] { hsetprop $hpath/$node abort 0 - clientput "ERROR: User requested stop. Aborting operation" + set errStr "ERROR: User requested stop. Aborting operation" + clientput $errStr + hsetprop $hpath/$node errmsg $errStr return $SCode(HWFault) } set devErr [hval $hpath/$node/control/device_error] if {$devErr != ""} { - clientput "ERROR: Drive request failed. Aborting operation" - clientput $devErr + set errStr "ERROR: Drive request failed. Aborting operation: device_error = $devErr" + clientput $errStr + hsetprop $hpath/$node errmsg $errStr return $SCode(HWFault) } if [hpropexists $hpath geterror] { @@ -458,6 +461,8 @@ namespace eval ::chopper { return $SCode(HWBusy) } elseif {[expr $readtime - $timecheck] > $timeout} { return $SCode(HWIdle) + } else { + return $SCode(HWBusy) } } else { if {$timecheck != -1} { @@ -498,6 +503,9 @@ namespace eval ::chopper { proc imot_PhRun {hpath node addr name target} { global SCode + if {[hval $hpath/$node/control/device_error] != ""} { + hset $hpath/$node/control/device_error "" + } hset $hpath/$node/control/set_ref_delay $target hsetprop $hpath/$node/control timecheck -1 set readtime [hgetpropval $hpath read_time] From 47d3d0a7e853560145d2e2c40cfae38c8c1636a3 Mon Sep 17 00:00:00 2001 From: Ferdi Franceschini Date: Mon, 25 Aug 2014 08:44:08 +1000 Subject: [PATCH 05/68] Pelican doesn't seem to have a PLC interface. --- site_ansto/instrument/pelican/config/plc/plc.tcl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/site_ansto/instrument/pelican/config/plc/plc.tcl b/site_ansto/instrument/pelican/config/plc/plc.tcl index 10635f3f..3fd03f03 100644 --- a/site_ansto/instrument/pelican/config/plc/plc.tcl +++ b/site_ansto/instrument/pelican/config/plc/plc.tcl @@ -1,7 +1,11 @@ +#FIXME Does pelican have a PLC interface? +plc_simulation false + set sim_mode [SplitReply [plc_simulation]] + if {$sim_mode == "false"} { -# MakeAsyncQueue plc_chan SafetyPLC 137.157.204.79 31001 -# MakeSafetyPLC plc plc_chan 0 + MakeAsyncQueue plc_chan SafetyPLC IP? PORT? + MakeSafetyPLC plc plc_chan 0 } source $cfPath(plc)/plc_common_1.tcl From 3ff6377f85aaa675bb4219c0956488f07bff36d1 Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Fri, 22 Aug 2014 17:10:31 +1000 Subject: [PATCH 06/68] Copy the protocol name and adjust the kill code in asyncprotocol --- asyncprotocol.c | 23 +++++++++++++++-------- asyncprotocol.h | 2 +- 2 files changed, 16 insertions(+), 9 deletions(-) diff --git a/asyncprotocol.c b/asyncprotocol.c index fc243d1a..cdfeae05 100644 --- a/asyncprotocol.c +++ b/asyncprotocol.c @@ -286,7 +286,6 @@ int AsyncProtocolAction(SConnection * pCon, SicsInterp * pSics, void defaultKillPrivate(pAsyncProtocol p) { if (p->privateData) { - /* TODO: should we do anything? */ free(p->privateData); } } @@ -295,15 +294,22 @@ void AsyncProtocolKill(void *pData) { pAsyncProtocol self = (pAsyncProtocol) pData; int i; - if (self->pDes) - DeleteDescriptor(self->pDes); - if (self->sendTerminator != NULL) - free(self->sendTerminator); - for (i = 0; i < 10; ++i) - if (self->replyTerminator[i] != NULL) - free(self->replyTerminator[i]); if (self->killPrivate) self->killPrivate(self); + if (self->pDes) + DeleteDescriptor(self->pDes); + self->pDes = NULL; + if (self->protocolName) + free(self->protocolName); + self->protocolName = NULL; + if (self->sendTerminator != NULL) + free(self->sendTerminator); + self->sendTerminator = NULL; + for (i = 0; i < 10; ++i) { + if (self->replyTerminator[i] != NULL) + free(self->replyTerminator[i]); + self->replyTerminator[i] = NULL; + } } pAsyncProtocol AsyncProtocolCreate(SicsInterp * pSics, @@ -338,6 +344,7 @@ pAsyncProtocol AsyncProtocolCreate(SicsInterp * pSics, AsyncProtocolKill(self); return NULL; } + self->protocolName = strdup(protocolName); self->sendCommand = defaultSendCommand; self->handleInput = defaultHandleInput; self->handleEvent = defaultHandleEvent; diff --git a/asyncprotocol.h b/asyncprotocol.h index 259e12cc..5e79e968 100644 --- a/asyncprotocol.h +++ b/asyncprotocol.h @@ -45,7 +45,7 @@ struct __async_txn { int inp_idx; /**< index of next character (number already received) */ AsyncTxnHandler handleResponse; /**< Txn response handler of command sender */ void *proto_private; /**< Protocol Private structure */ - void (*kill_private) (struct __async_txn *pTxn); /**< if it needs killing */ + void (*kill_private) (pAsyncTxn pTxn); /**< if it needs killing */ void *cntx; /**< opaque context used by command sender */ /* The cntx field may be used by protocol handler from sendCommand * as long as it is restored when response is complete From ee40adceb2736a3ba93b85e61bb46f7503e1ef7c Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Tue, 26 Aug 2014 13:30:39 +1000 Subject: [PATCH 07/68] Add asyncqueue 'transact' command and list the protocol --- asyncqueue.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/asyncqueue.c b/asyncqueue.c index 6695a2b8..3a315a0e 100644 --- a/asyncqueue.c +++ b/asyncqueue.c @@ -892,7 +892,7 @@ int AsyncQueueAction(SConnection * pCon, SicsInterp * pSics, char line[132]; pAsyncQueue self = (pAsyncQueue) pData; if (argc > 1) { - if (strcasecmp("send", argv[1]) == 0) { + if (strcasecmp("send", argv[1]) == 0 || strcasecmp("transact", argv[1]) == 0) { AsyncUnit myUnit; char cmd[10240]; char rsp[10240]; @@ -1117,6 +1117,8 @@ int AsyncQueueAction(SConnection * pCon, SicsInterp * pSics, SCPrintf(pCon, eValue, "%s.trace = %d", argv[0], self->trace); if (self->noreply_text) SCPrintf(pCon, eValue, "%s.noreply = %s", argv[0], self->noreply_text); + if (self->protocol && self->protocol->protocolName) + SCPrintf(pCon, eValue, "%s.protocol = %s", argv[0], self->protocol->protocolName); return OKOK; } } From a43461b20013d700e90734df3053ade307a5b9f8 Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Tue, 26 Aug 2014 14:30:19 +1000 Subject: [PATCH 08/68] Reworked AsyncQueue sendCommand processing Squashed commit of the following: commit 42fb7d3cde591d40060cc740ccbc47f1ae7a5a50 Author: Douglas Clowes Date: Tue Aug 26 13:31:11 2014 +1000 Get the MODBUS_AP working commit da785c1434a04c4186d4174eb2dfbaefc850c8e7 Author: Douglas Clowes Date: Mon Aug 25 18:01:50 2014 +1000 Bring Modbus protocol closer to Huber, Knauer and Omron commit ef06ed7b6911cb49b35c19fe73e55f7c57cfd049 Author: Douglas Clowes Date: Mon Aug 25 18:01:18 2014 +1000 Make Huber, Knauer and Omron protocols more aligned (diffable) commit 3ef1bb06b3f865502ad7dffc4bf5dba4814d9334 Author: Douglas Clowes Date: Fri Aug 22 17:47:50 2014 +1000 Get the Huber and Knauer protocols to be more alike commit 2c9932e83f6735e894278648afdcadece654d43b Author: Douglas Clowes Date: Fri Aug 22 17:12:31 2014 +1000 Clean up the Knauer dual-mode protocol and refactor commit 333300b19b0e61916e261300ac6ae2b6bab5df09 Author: Douglas Clowes Date: Thu Aug 21 15:38:39 2014 +1000 Get the Knauer dual-mode protocol working(-ish) commit b1f9d82f1b9eb8a1ff54694adc3482984b0d3d72 Author: Douglas Clowes Date: Thu Aug 21 15:37:44 2014 +1000 Make private functions static (and not duplicated) commit 0b077414eef9e4351956a2b971d7751cced0d3cd Author: Douglas Clowes Date: Thu Aug 21 12:46:10 2014 +1000 Knauer moving toward dual protocol commit 13199bea38a1595ce06923e83474b738b10db94d Author: Douglas Clowes Date: Thu Aug 21 12:42:48 2014 +1000 Restructure default sendCommand processing in asyncqueue commit 99a8ea3174ca0636503b0ce0cdb6016790315558 Author: Douglas Clowes Date: Thu Aug 21 09:48:50 2014 +1000 Add a Modbus Protocol handler derived from sct_tcpmodbus commit 3adf49fb7c8402c8260a0bb20729d551ac88537b Author: Douglas Clowes Date: Thu Aug 21 09:43:54 2014 +1000 Leave the free of private data to the asyncqueue mechanism --- asyncqueue.c | 11 +- site_ansto/hardsup/aqp_opalstatus.c | 13 +- site_ansto/hardsup/cameradriver.c | 14 +- site_ansto/hardsup/huber_asyncprotocol.c | 351 +++++++++++++++---- site_ansto/hardsup/knauer_asyncprotocol.c | 375 ++++++++++++++++----- site_ansto/hardsup/omron_asyncprotocol.c | 391 +++++++++++++++++----- site_ansto/ls340.c | 38 +-- site_ansto/lssmonitor.c | 19 +- site_ansto/motor_dmc2280.c | 21 +- site_ansto/orhvps.c | 24 +- site_ansto/safetyplc.c | 19 +- 11 files changed, 897 insertions(+), 379 deletions(-) diff --git a/asyncqueue.c b/asyncqueue.c index 3a315a0e..e754eb73 100644 --- a/asyncqueue.c +++ b/asyncqueue.c @@ -394,7 +394,16 @@ static int StartCommand(pAsyncQueue self) } myCmd->tran->txn_status = ATX_ACTIVE; - iRet = self->protocol->sendCommand(self->protocol, myCmd->tran); + if (self->protocol->sendCommand) { + iRet = self->protocol->sendCommand(self->protocol, myCmd->tran); + } else { + pAsyncTxn txn = myCmd->tran; + iRet = AsyncUnitWrite(txn->unit, txn->out_buf, txn->out_len); + if (iRet < 0) + iRet = 0; + else + iRet = 1; + } /* * Handle case of no response expected */ diff --git a/site_ansto/hardsup/aqp_opalstatus.c b/site_ansto/hardsup/aqp_opalstatus.c index 7760e910..b0de390b 100644 --- a/site_ansto/hardsup/aqp_opalstatus.c +++ b/site_ansto/hardsup/aqp_opalstatus.c @@ -20,17 +20,6 @@ enum replystates {START, HEADER, CHKHEADEREND, MSG}; static pAsyncProtocol OPAL_Protocol = NULL; -static int OPAL_Tx(pAsyncProtocol p, pAsyncTxn txn) { - if (txn == NULL) { - return 0; - } - txn->txn_status = ATX_ACTIVE; - if (AsyncUnitWrite(txn->unit, txn->out_buf, txn->out_len) < 0) { - return 0; - } - return 1; -} - /* The header and message are followed by the character sequences given below, * HEADER cr lf cr lf cr lf * MESSAGE cr lf 0x30 cr lf cr lf @@ -137,7 +126,7 @@ static int OPAL_PrepareTxn(pAsyncProtocol p, pAsyncTxn txn, const char* cmd, int void OpalStatusInitProtocol(SicsInterp *pSics) { if (OPAL_Protocol == NULL) { OPAL_Protocol = AsyncProtocolCreate(pSics, "OPALSTAT", NULL, NULL); - OPAL_Protocol->sendCommand = OPAL_Tx; + OPAL_Protocol->sendCommand = NULL; OPAL_Protocol->handleInput = OPAL_Rx; OPAL_Protocol->killPrivate = NULL; OPAL_Protocol->handleEvent = OPAL_Ev; diff --git a/site_ansto/hardsup/cameradriver.c b/site_ansto/hardsup/cameradriver.c index 0a1c75df..e77114fb 100644 --- a/site_ansto/hardsup/cameradriver.c +++ b/site_ansto/hardsup/cameradriver.c @@ -183,18 +183,6 @@ static void CAM_Notify(void* context, int event) { return; } -static int CAM_Tx(pAsyncProtocol p, pAsyncTxn txn) { - - if (txn == NULL) { - return 0; - } - txn->txn_status = ATX_ACTIVE; - if (AsyncUnitWrite(txn->unit, txn->out_buf, txn->out_len) < 0) { - return 0; - } - return 1; -} - int defaultHandleInput(pAsyncProtocol p, pAsyncTxn txn, int ch); static int CAM_Rx(pAsyncProtocol p, pAsyncTxn txn, int ch) { int ret = 1; @@ -221,7 +209,7 @@ static int CAM_Ev(pAsyncProtocol p, pAsyncTxn pTxn, int event) { void CameraInitProtocol(SicsInterp *pSics) { if (CAM_Protocol == NULL) { CAM_Protocol = AsyncProtocolCreate(pSics, "CAMERA", NULL, NULL); - CAM_Protocol->sendCommand = CAM_Tx; + CAM_Protocol->sendCommand = NULL; CAM_Protocol->handleInput = CAM_Rx; CAM_Protocol->prepareTxn = NULL; CAM_Protocol->killPrivate = NULL; diff --git a/site_ansto/hardsup/huber_asyncprotocol.c b/site_ansto/hardsup/huber_asyncprotocol.c index 62ed18b7..7ed7c43f 100644 --- a/site_ansto/hardsup/huber_asyncprotocol.c +++ b/site_ansto/hardsup/huber_asyncprotocol.c @@ -1,80 +1,163 @@ #include "huber_asyncprotocol.h" #include "asyncprotocol.h" #include "asyncqueue.h" +#include "ascon.i" +#include "dynstring.h" +#include +#define PROTOCOL_CONTINUE 0 +#define PROTOCOL_COMPLETE 1 +#define PROTOCOL_ERROR (-1) + +/* Sample Messages +structure: + 7B - LEFT BRACE + xx - text + 0D 0A - CR LF +*/ +#define PROTOCOL_NAME "HUBER_AP" +#define PROTOCOL_INIT HUBERInitProtocol #define LBRACE '{' #define CR '\r' #define LF '\n' /* - * Protocol transmit function - * Called by AsyncQueue to transmit a line + * Protocol Private data block */ -static int HUBER_Tx(pAsyncProtocol p, pAsyncTxn pTxn) { - int iRet = 1; +typedef struct proto_private_t { + int state; /**< protocol state machine */ + int len; /**< length from the protocol */ + pDynString wrBuffer; /**< transmitted message */ + pDynString rxBuffer; /**< received message */ +} ProtoPrivate; - if (pTxn) { - pTxn->txn_status = ATX_ACTIVE; - iRet = AsyncUnitWrite(pTxn->unit, pTxn->out_buf, pTxn->out_len); - /* TODO handle errors */ - if (iRet < 0) { /* TODO: EOF */ - /* - iRet = AsyncUnitReconnect(pTxn->unit); - if (iRet == 0) - */ - return 0; +static ProtoPrivate *makeProtoPrivate() +{ + ProtoPrivate *priv = calloc(sizeof(ProtoPrivate), 1); + priv->wrBuffer = CreateDynString(100, 100); + priv->rxBuffer = CreateDynString(100, 100); + return priv; +} + +static ProtoPrivate *Proto_KillPrivate(ProtoPrivate *priv) +{ + if (priv) { + if (priv->rxBuffer) { + DeleteDynString(priv->rxBuffer); + priv->rxBuffer = NULL; } + free(priv); } - return 1; + return NULL; +} + +/* + * Protocol Specific Support Functions + */ +/* + * Protocol Prepare Output + */ +static int Proto_Prepare(ProtoPrivate *priv, pDynString wrBuffer) +{ + DynStringInsert(wrBuffer, "{", 0); + DynStringConcatChar(wrBuffer, CR); + DynStringConcatChar(wrBuffer, LF); + return PROTOCOL_COMPLETE; } /* * Protocol receive character - characater by character */ -static int HUBER_Rx(pAsyncProtocol p, pAsyncTxn pTxn, int rxchar) { - int iRet = 1; - - switch (pTxn->txn_state) { - case 0: /* first character */ +static int Proto_RxChar(ProtoPrivate *priv, int rxchar) +{ + enum RX_STATE { + RX_START=0, + RX_TEXT=1, + RX_LAST=2, /* LF */ + RX_STOP=99 + }; + rxchar &= 0xFF; + switch (priv->state) { + case RX_START: if (rxchar != LBRACE) { - /* TODO: error */ - pTxn->txn_state = 99; - pTxn->txn_status = ATX_COMPLETE; - break; + priv->state = RX_STOP; + return PROTOCOL_ERROR; } - /* normal data */ - pTxn->txn_state = 1; - /* note fallthrough */ - case 1: /* receiving reply */ - if (pTxn->inp_idx < pTxn->inp_len) - pTxn->inp_buf[pTxn->inp_idx++] = rxchar; - if (rxchar == CR) - pTxn->txn_state = 2; - break; - case 2: /* receiving LF */ - if (pTxn->inp_idx < pTxn->inp_len) - pTxn->inp_buf[pTxn->inp_idx++] = rxchar; - if (rxchar != LF) { - /* TODO: error */ + priv->state = RX_TEXT; + return PROTOCOL_CONTINUE; + case RX_TEXT: + if (rxchar == CR) { + priv->state = RX_LAST; + return PROTOCOL_CONTINUE; } - pTxn->txn_state = 99; - pTxn->inp_idx -= 3; - memmove(pTxn->inp_buf, pTxn->inp_buf + 1, pTxn->inp_idx); - break; + DynStringConcatChar(priv->rxBuffer, rxchar); + return PROTOCOL_CONTINUE; + case RX_LAST: + if (rxchar == LF) { + priv->state = RX_STOP; + return PROTOCOL_COMPLETE; + } else { + priv->state = RX_STOP; + return PROTOCOL_ERROR; + } + + default: + return PROTOCOL_ERROR; } - if (pTxn->txn_state == 99) { - iRet = 0; + return PROTOCOL_ERROR; +} + +/* + * AsyncProtocol handling + * ====================== + */ + +static void Async_KillPrivate(pAsyncTxn pTxn) +{ + Proto_KillPrivate((ProtoPrivate *) pTxn->proto_private); + pTxn->proto_private = NULL; +} + +/* + * AsyncProtocol Receive Character + */ +static int Async_Rx(pAsyncProtocol p, pAsyncTxn pTxn, int rxchar) { + int iRet, str_len; + ProtoPrivate *priv = (ProtoPrivate *) pTxn->proto_private; + + iRet = Proto_RxChar(priv, rxchar); + /* + * Keep inp_buf and inp_idx up-to-date after each character + */ + str_len = GetDynStringLength(priv->rxBuffer); + if (str_len > pTxn->inp_idx && pTxn->inp_idx < pTxn->inp_len) { + int xfr_len; + char *tgt = &pTxn->inp_buf[pTxn->inp_idx]; + char *loc = &GetCharArray(priv->rxBuffer)[pTxn->inp_idx]; + if (str_len > pTxn->inp_len) + xfr_len = pTxn->inp_len - pTxn->inp_idx; + else + xfr_len = str_len - pTxn->inp_idx; + memcpy(tgt, loc, xfr_len); + pTxn->inp_idx += xfr_len; } - if (iRet == 0) { /* end of command */ - return AQU_POP_CMD; + + if (iRet == PROTOCOL_CONTINUE) { + return 1; /* Keep Going */ } - return iRet; + + if (iRet == PROTOCOL_ERROR) { + return -1; /* Error condition */ + } + + /* Message Complete */ + return AQU_POP_CMD; } /* * AsyncProtocol Event callback */ -static int HUBER_Ev(pAsyncProtocol p, pAsyncTxn pTxn, int event) { +static int Async_Ev(pAsyncProtocol p, pAsyncTxn pTxn, int event) { if (event == AQU_TIMEOUT) { /* handle command timeout */ pTxn->txn_status = ATX_TIMEOUT; @@ -83,34 +166,168 @@ static int HUBER_Ev(pAsyncProtocol p, pAsyncTxn pTxn, int event) { return AQU_POP_CMD; } -static int HUBER_PrepareTxn(pAsyncProtocol p, pAsyncTxn pTxn, const char* cmd, int cmd_len, int rsp_len) { - int i, bcc; - pTxn->out_buf = (char*) malloc(cmd_len + 3); - if (pTxn->out_buf == NULL) { - SICSLogWrite("ERROR: Out of memory in HUBER_PrepareTxn", eError); +/* + * AsyncProtocol Prepare Transaction + */ +static int Async_PrepareTxn(pAsyncProtocol p, pAsyncTxn pTxn, const char* cmd, int cmd_len, int rsp_len) { + ProtoPrivate *priv; + priv = makeProtoPrivate(); + if (priv == NULL) { + SICSLogWrite("ERROR: Out of memory in Async_PrepareTxn", eError); return 0; } - memcpy(pTxn->out_buf + 1, cmd, cmd_len); - pTxn->out_buf[0] = LBRACE; - pTxn->out_buf[cmd_len + 1] = CR; - pTxn->out_buf[cmd_len + 2] = LF; - pTxn->out_len = cmd_len + 3; + priv->state = 0; + priv->len = 0; + DynStringConcatBytes(priv->wrBuffer, cmd, cmd_len); + Proto_Prepare(priv, priv->wrBuffer); + pTxn->out_len = GetDynStringLength(priv->wrBuffer); + pTxn->out_buf = (char*) malloc(pTxn->out_len); + if (pTxn->out_buf == NULL) { + SICSLogPrintf(eError, "ERROR: Out of memory in %s:%s", __FILE__, __FUNCTION__); + Proto_KillPrivate(priv); + return 0; + } + pTxn->proto_private = priv; + pTxn->kill_private = Async_KillPrivate; + memcpy(pTxn->out_buf, GetCharArray(priv->wrBuffer), pTxn->out_len); + return 1; } -static pAsyncProtocol HUBER_Protocol = NULL; +/* + * Ascon Protocol handling + * ======================= + */ + +static void Ascon_KillPrivate(void *priv) +{ + Proto_KillPrivate((ProtoPrivate *) priv); +} + +/* + * Ascon Protocol WriteStart + */ +static int Ascon_Prepare(Ascon *a) { + ProtoPrivate *priv = (ProtoPrivate *) a->private; + Proto_Prepare(priv, a->wrBuffer); + a->wrPos = 0; + a->state = AsconWriting; + return 1; +} + +/* + * Ascon Protocol Read Poll + */ +static int Ascon_Rx(Ascon *a) { + int ret, status; + char chr = '\0'; + ProtoPrivate *priv = (ProtoPrivate *) a->private; + + ret = AsconReadChar(a->fd, &chr); + while (ret > 0) { + a->start = DoubleTime(); + status = Proto_RxChar(priv, chr); + if (GetDynStringLength(priv->rxBuffer) > GetDynStringLength(a->rdBuffer)) { + int len_rd = GetDynStringLength(a->rdBuffer); + int len_rx = GetDynStringLength(priv->rxBuffer); + char *loc = &GetCharArray(priv->rxBuffer)[len_rd]; + DynStringConcatBytes(a->rdBuffer, loc, len_rx - len_rd); + } + if (status > 0) { /* Complete */ + a->state = AsconReadDone; + return 1; + } + else if (status < 0) { /* Error */ + AsconError(a, "Protocol Input Error:", status); + /*TODO This hack stops ascon.c:AsconTask() from needlessly closing the connection. Remove this when it's no longer needed */ + a->lastReconnect = DoubleTime(); + return 1; + } + ret = AsconReadChar(a->fd, &chr); + } + if (ret < 0) { + AsconError(a, "AsconReadChar failed:", errno); + return 1; + } + if (a->state != AsconReadDone) { + if (a->timeout > 0) { + if (DoubleTime() - a->start > a->timeout) { + AsconError(a, "read timeout", 0); + a->state = AsconTimeout; + } + } + } + return 1; +} + +/* + * Ascon Protocol Poll Loop + */ +static int AsconProtHandler(Ascon *a) { + ProtoPrivate *priv = (ProtoPrivate *) a->private; + int ret; + + switch(a->state){ + case AsconWriteStart: + ret = Ascon_Prepare(a); + return ret; + case AsconReadStart: + DynStringClear(priv->rxBuffer); + a->start = DoubleTime(); + priv->state = 0; + priv->len = 0; + ret = AsconStdHandler(a); + return ret; + case AsconReading: + ret = Ascon_Rx(a); + return ret; + default: + ret = AsconStdHandler(a); + return ret; + } + return 1; +} + +/* + * Ascon Protocol Connection Init + */ +static int AsconInit(Ascon *a, SConnection *con, int argc, char *argv[]) +{ + int iRet; + ProtoPrivate *priv; + + iRet = AsconStdInit(a, con, argc, argv); + priv = makeProtoPrivate(); + a->private = priv; + a->killPrivate = Ascon_KillPrivate; + return iRet; +} + +static AsyncProtocol *My_Async_Protocol = NULL; +static AsconProtocol *My_Ascon_Protocol = NULL; /* * Protocol Initialisation */ -void HUBERInitProtocol(SicsInterp *pSics) { - if (HUBER_Protocol == NULL) { - HUBER_Protocol = AsyncProtocolCreate(pSics, "HUBER_AP", NULL, NULL); - HUBER_Protocol->sendCommand = HUBER_Tx; - HUBER_Protocol->handleInput = HUBER_Rx; - HUBER_Protocol->handleEvent = HUBER_Ev; - HUBER_Protocol->prepareTxn = HUBER_PrepareTxn; - HUBER_Protocol->killPrivate = NULL; +void PROTOCOL_INIT(SicsInterp *pSics) { + if (My_Async_Protocol == NULL) { + AsyncProtocol *prot; + prot = AsyncProtocolCreate(pSics, PROTOCOL_NAME, NULL, NULL); + prot->sendCommand = NULL; + prot->handleInput = Async_Rx; + prot->handleEvent = Async_Ev; + prot->prepareTxn = Async_PrepareTxn; + My_Async_Protocol = prot; + } + + if (My_Ascon_Protocol == NULL) { + AsconProtocol *prot; + prot = calloc(sizeof(AsconProtocol), 1); + prot->name = strdup(PROTOCOL_NAME); + prot->init = AsconInit; + prot->handler = AsconProtHandler; + AsconInsertProtocol(prot); + My_Ascon_Protocol = prot; } } diff --git a/site_ansto/hardsup/knauer_asyncprotocol.c b/site_ansto/hardsup/knauer_asyncprotocol.c index aada3c97..f8ad2497 100644 --- a/site_ansto/hardsup/knauer_asyncprotocol.c +++ b/site_ansto/hardsup/knauer_asyncprotocol.c @@ -1,105 +1,175 @@ #include "knauer_asyncprotocol.h" #include "asyncprotocol.h" #include "asyncqueue.h" +#include "ascon.i" +#include "dynstring.h" +#include -#define SYN1 0x55 -#define SYN2 0xAA -#define CR '\r' -#define LF '\n' +#define PROTOCOL_CONTINUE 0 +#define PROTOCOL_COMPLETE 1 +#define PROTOCOL_ERROR (-1) /* Sample Messages 55 aa 00 08 52 45 4d 4f 54 45 3a 30 55 aa 00 16 45 52 52 4f 52 3a 34 38 2c 4e 6f 74 20 73 75 70 70 6f 72 74 65 64 55 aa 00 18 45 52 52 4f 52 3a 31 36 2c 49 6e 76 61 6c 69 64 20 63 6f 6d 6d 61 6e 64 +structure: + 55 aa - sync bytes + 00 xx - length of following bytes + yy .. zz - count(00 xx) message bytes with no terminator */ -typedef struct knauer_private_t Private, *pPrivate; -struct knauer_private_t { - int len; -}; +#define PROTOCOL_NAME "KNAUER_AP" +#define PROTOCOL_INIT KNAUERInitProtocol +#define SYN1 0x55 +#define SYN2 0xAA +#define CR '\r' +#define LF '\n' /* - * Protocol transmit function - * Called by AsyncQueue to transmit a line + * Protocol Private data block */ -static int KNAUER_Tx(pAsyncProtocol p, pAsyncTxn pTxn) { - int iRet = 1; +typedef struct proto_private_t { + int state; /**< protocol state machine */ + int len; /**< length from the protocol */ + pDynString wrBuffer; /**< transmitted message */ + pDynString rxBuffer; /**< received message */ +} ProtoPrivate; - if (pTxn) { - pTxn->txn_status = ATX_ACTIVE; - iRet = AsyncUnitWrite(pTxn->unit, pTxn->out_buf, pTxn->out_len); - /* TODO handle errors */ - if (iRet < 0) { /* TODO: EOF */ - /* - iRet = AsyncUnitReconnect(pTxn->unit); - if (iRet == 0) - */ - return 0; +static ProtoPrivate *makeProtoPrivate() +{ + ProtoPrivate *priv = calloc(sizeof(ProtoPrivate), 1); + priv->wrBuffer = CreateDynString(100, 100); + priv->rxBuffer = CreateDynString(100, 100); + return priv; +} + +static ProtoPrivate *Proto_KillPrivate(ProtoPrivate *priv) +{ + if (priv) { + if (priv->rxBuffer) { + DeleteDynString(priv->rxBuffer); + priv->rxBuffer = NULL; } + free(priv); } - return 1; + return NULL; +} + +/* + * Protocol Specific Support Functions + */ +/* + * Protocol Prepare Output + */ +static int Proto_Prepare(ProtoPrivate *priv, pDynString wrBuffer) +{ + DynStringConcatChar(wrBuffer, CR); + return PROTOCOL_COMPLETE; } /* * Protocol receive character - characater by character */ -static int KNAUER_Rx(pAsyncProtocol p, pAsyncTxn pTxn, int rxchar) { - int iRet = 1; - pPrivate myPriv = (pPrivate) pTxn->proto_private; - +static int Proto_RxChar(ProtoPrivate *priv, int rxchar) +{ + enum RX_STATE { + RX_START=0, + RX_TEXT=1, + RX_SYN2=2, + RX_LEN1=3, + RX_LEN2=4, + RX_STOP=99 + }; rxchar &= 0xFF; - switch (pTxn->txn_state) { - case 0: /* first SYN byte */ + switch (priv->state) { + case RX_START: if (rxchar != SYN1) { - /* TODO: error */ - pTxn->txn_state = 99; - pTxn->txn_status = ATX_COMPLETE; - break; + priv->state = RX_STOP; + return PROTOCOL_ERROR; } - pTxn->txn_state = 1; - break; - case 1: /* second SYN byte */ + priv->state = RX_SYN2; + return PROTOCOL_CONTINUE; + case RX_SYN2: if (rxchar != SYN2) { - /* TODO: error */ - pTxn->txn_state = 99; - pTxn->txn_status = ATX_COMPLETE; - break; + priv->state = RX_STOP; + return PROTOCOL_ERROR; } - pTxn->txn_state = 2; - break; - case 2: /* MS length byte */ - myPriv->len = 256 * rxchar; - pTxn->txn_state = 3; - break; - case 3: /* LS length byte */ - myPriv->len += rxchar; - pTxn->txn_state = 4; - break; - case 4: /* receiving text */ - if (pTxn->inp_idx < pTxn->inp_len) - pTxn->inp_buf[pTxn->inp_idx++] = rxchar; - if (pTxn->inp_idx >= myPriv->len) { - pTxn->txn_state = 99; - pTxn->txn_status = ATX_COMPLETE; + priv->state = RX_LEN1; + return PROTOCOL_CONTINUE; + case RX_LEN1: + priv->len = 256 * rxchar; + priv->state = RX_LEN2; + return PROTOCOL_CONTINUE; + case RX_LEN2: + priv->len += rxchar; + priv->state = RX_TEXT; + return PROTOCOL_CONTINUE; + case RX_TEXT: + DynStringConcatChar(priv->rxBuffer, rxchar); + if (GetDynStringLength(priv->rxBuffer) >= priv->len) { + priv->state = RX_STOP; + return PROTOCOL_COMPLETE; + } else { + return PROTOCOL_CONTINUE; } - break; + + default: + return PROTOCOL_ERROR; } - if (pTxn->txn_state == 99) { - iRet = 0; + return PROTOCOL_ERROR; +} + +/* + * AsyncProtocol handling + * ====================== + */ + +static void Async_KillPrivate(pAsyncTxn pTxn) +{ + Proto_KillPrivate((ProtoPrivate *) pTxn->proto_private); + pTxn->proto_private = NULL; +} + +/* + * AsyncProtocol Receive Character + */ +static int Async_Rx(pAsyncProtocol p, pAsyncTxn pTxn, int rxchar) { + int iRet, str_len; + ProtoPrivate *priv = (ProtoPrivate *) pTxn->proto_private; + + iRet = Proto_RxChar(priv, rxchar); + /* + * Keep inp_buf and inp_idx up-to-date after each character + */ + str_len = GetDynStringLength(priv->rxBuffer); + if (str_len > pTxn->inp_idx && pTxn->inp_idx < pTxn->inp_len) { + int xfr_len; + char *tgt = &pTxn->inp_buf[pTxn->inp_idx]; + char *loc = &GetCharArray(priv->rxBuffer)[pTxn->inp_idx]; + if (str_len > pTxn->inp_len) + xfr_len = pTxn->inp_len - pTxn->inp_idx; + else + xfr_len = str_len - pTxn->inp_idx; + memcpy(tgt, loc, xfr_len); + pTxn->inp_idx += xfr_len; } - if (iRet == 0) { /* end of command */ - free(pTxn->proto_private); - pTxn->proto_private = NULL; - return AQU_POP_CMD; + + if (iRet == PROTOCOL_CONTINUE) { + return 1; /* Keep Going */ } - return iRet; + + if (iRet == PROTOCOL_ERROR) { + return -1; /* Error condition */ + } + + /* Message Complete */ + return AQU_POP_CMD; } /* * AsyncProtocol Event callback */ -static int KNAUER_Ev(pAsyncProtocol p, pAsyncTxn pTxn, int event) { - free(pTxn->proto_private); - pTxn->proto_private = NULL; +static int Async_Ev(pAsyncProtocol p, pAsyncTxn pTxn, int event) { if (event == AQU_TIMEOUT) { /* handle command timeout */ pTxn->txn_status = ATX_TIMEOUT; @@ -108,41 +178,168 @@ static int KNAUER_Ev(pAsyncProtocol p, pAsyncTxn pTxn, int event) { return AQU_POP_CMD; } -static int KNAUER_PrepareTxn(pAsyncProtocol p, pAsyncTxn pTxn, const char* cmd, int cmd_len, int rsp_len) { - pPrivate myPriv = (pPrivate) malloc(sizeof(Private)); - if (myPriv == NULL) { - SICSLogWrite("ERROR: Out of memory in KNAUER_PrepareTxn", eError); +/* + * AsyncProtocol Prepare Transaction + */ +static int Async_PrepareTxn(pAsyncProtocol p, pAsyncTxn pTxn, const char* cmd, int cmd_len, int rsp_len) { + ProtoPrivate *priv; + priv = makeProtoPrivate(); + if (priv == NULL) { + SICSLogWrite("ERROR: Out of memory in Async_PrepareTxn", eError); return 0; } - myPriv->len = 0; - pTxn->out_buf = (char*) malloc(cmd_len + 1); + priv->state = 0; + priv->len = 0; + DynStringConcatBytes(priv->wrBuffer, cmd, cmd_len); + Proto_Prepare(priv, priv->wrBuffer); + pTxn->out_len = GetDynStringLength(priv->wrBuffer); + pTxn->out_buf = (char*) malloc(pTxn->out_len); if (pTxn->out_buf == NULL) { - SICSLogWrite("ERROR: Out of memory in KNAUER_PrepareTxn", eError); - free(myPriv); + SICSLogPrintf(eError, "ERROR: Out of memory in %s:%s", __FILE__, __FUNCTION__); + Proto_KillPrivate(priv); return 0; } - pTxn->proto_private = myPriv; - memcpy(pTxn->out_buf, cmd, cmd_len); - pTxn->out_buf[cmd_len] = CR; - pTxn->out_len = cmd_len + 1; + pTxn->proto_private = priv; + pTxn->kill_private = Async_KillPrivate; + memcpy(pTxn->out_buf, GetCharArray(priv->wrBuffer), pTxn->out_len); return 1; } -static pAsyncProtocol KNAUER_Protocol = NULL; +/* + * Ascon Protocol handling + * ======================= + */ + +static void Ascon_KillPrivate(void *priv) +{ + Proto_KillPrivate((ProtoPrivate *) priv); +} + +/* + * Ascon Protocol WriteStart + */ +static int Ascon_Prepare(Ascon *a) { + ProtoPrivate *priv = (ProtoPrivate *) a->private; + Proto_Prepare(priv, a->wrBuffer); + a->wrPos = 0; + a->state = AsconWriting; + return 1; +} + +/* + * Ascon Protocol Read Poll + */ +static int Ascon_Rx(Ascon *a) { + int ret, status; + char chr = '\0'; + ProtoPrivate *priv = (ProtoPrivate *) a->private; + + ret = AsconReadChar(a->fd, &chr); + while (ret > 0) { + a->start = DoubleTime(); + status = Proto_RxChar(priv, chr); + if (GetDynStringLength(priv->rxBuffer) > GetDynStringLength(a->rdBuffer)) { + int len_rd = GetDynStringLength(a->rdBuffer); + int len_rx = GetDynStringLength(priv->rxBuffer); + char *loc = &GetCharArray(priv->rxBuffer)[len_rd]; + DynStringConcatBytes(a->rdBuffer, loc, len_rx - len_rd); + } + if (status > 0) { /* Complete */ + a->state = AsconReadDone; + return 1; + } + else if (status < 0) { /* Error */ + AsconError(a, "Protocol Input Error:", status); + /*TODO This hack stops ascon.c:AsconTask() from needlessly closing the connection. Remove this when it's no longer needed */ + a->lastReconnect = DoubleTime(); + return 1; + } + ret = AsconReadChar(a->fd, &chr); + } + if (ret < 0) { + AsconError(a, "AsconReadChar failed:", errno); + return 1; + } + if (a->state != AsconReadDone) { + if (a->timeout > 0) { + if (DoubleTime() - a->start > a->timeout) { + AsconError(a, "read timeout", 0); + a->state = AsconTimeout; + } + } + } + return 1; +} + +/* + * Ascon Protocol Poll Loop + */ +static int AsconProtHandler(Ascon *a) { + ProtoPrivate *priv = (ProtoPrivate *) a->private; + int ret; + + switch(a->state){ + case AsconWriteStart: + ret = Ascon_Prepare(a); + return ret; + case AsconReadStart: + DynStringClear(priv->rxBuffer); + a->start = DoubleTime(); + priv->state = 0; + priv->len = 0; + ret = AsconStdHandler(a); + return ret; + case AsconReading: + ret = Ascon_Rx(a); + return ret; + default: + ret = AsconStdHandler(a); + return ret; + } + return 1; +} + +/* + * Ascon Protocol Connection Init + */ +static int AsconInit(Ascon *a, SConnection *con, int argc, char *argv[]) +{ + int iRet; + ProtoPrivate *priv; + + iRet = AsconStdInit(a, con, argc, argv); + priv = makeProtoPrivate(); + a->private = priv; + a->killPrivate = Ascon_KillPrivate; + return iRet; +} + +static AsyncProtocol *My_Async_Protocol = NULL; +static AsconProtocol *My_Ascon_Protocol = NULL; /* * Protocol Initialisation */ -void KNAUERInitProtocol(SicsInterp *pSics) { - if (KNAUER_Protocol == NULL) { - KNAUER_Protocol = AsyncProtocolCreate(pSics, "KNAUER_AP", NULL, NULL); - KNAUER_Protocol->sendCommand = KNAUER_Tx; - KNAUER_Protocol->handleInput = KNAUER_Rx; - KNAUER_Protocol->handleEvent = KNAUER_Ev; - KNAUER_Protocol->prepareTxn = KNAUER_PrepareTxn; - KNAUER_Protocol->killPrivate = NULL; +void PROTOCOL_INIT(SicsInterp *pSics) { + if (My_Async_Protocol == NULL) { + AsyncProtocol *prot; + prot = AsyncProtocolCreate(pSics, PROTOCOL_NAME, NULL, NULL); + prot->sendCommand = NULL; + prot->handleInput = Async_Rx; + prot->handleEvent = Async_Ev; + prot->prepareTxn = Async_PrepareTxn; + My_Async_Protocol = prot; + } + + if (My_Ascon_Protocol == NULL) { + AsconProtocol *prot; + prot = calloc(sizeof(AsconProtocol), 1); + prot->name = strdup(PROTOCOL_NAME); + prot->init = AsconInit; + prot->handler = AsconProtHandler; + AsconInsertProtocol(prot); + My_Ascon_Protocol = prot; } } - diff --git a/site_ansto/hardsup/omron_asyncprotocol.c b/site_ansto/hardsup/omron_asyncprotocol.c index 2266d07a..ddd264bf 100644 --- a/site_ansto/hardsup/omron_asyncprotocol.c +++ b/site_ansto/hardsup/omron_asyncprotocol.c @@ -1,105 +1,186 @@ #include "omron_asyncprotocol.h" #include "asyncprotocol.h" #include "asyncqueue.h" +#include "ascon.i" +#include "dynstring.h" +#include +#define PROTOCOL_CONTINUE 0 +#define PROTOCOL_COMPLETE 1 +#define PROTOCOL_ERROR (-1) + +/* Sample Messages + * structure: + * STX + * data + * ETX + * BCC +*/ +#define PROTOCOL_NAME "OMRON_AP" +#define PROTOCOL_INIT OMRONInitProtocol #define STX 2 #define ETX 3 -static int calc_bcc(const char* text) +/* + * Protocol Private data block + */ +typedef struct proto_private_t { + int state; /**< protocol state machine */ + int len; /**< length from the protocol */ + pDynString wrBuffer; /**< transmitted message */ + pDynString rxBuffer; /**< received message */ +} ProtoPrivate; + +static ProtoPrivate *makeProtoPrivate() { - int bcc = 0; - int i = 0; - int c; - while (i < 1024) { - c = text[i] & 0xFF; - if (c == STX) { - bcc = 0; - } else { - bcc ^= c; + ProtoPrivate *priv = calloc(sizeof(ProtoPrivate), 1); + priv->wrBuffer = CreateDynString(100, 100); + priv->rxBuffer = CreateDynString(100, 100); + return priv; +} + +static ProtoPrivate *Proto_KillPrivate(ProtoPrivate *priv) +{ + if (priv) { + if (priv->rxBuffer) { + DeleteDynString(priv->rxBuffer); + priv->rxBuffer = NULL; } - SICSLogPrintf(eLog, "BCC %02d: char %02X, bcc = %02X", i, c, bcc); - if (c == ETX) - break; - ++text; + free(priv); } + return NULL; +} + +/* + * Protocol Specific Support Functions + */ + +static int calc_bcc(const char* text, int len) +{ + int idx = 0; + int bcc = 0; + int c = 0; + for (idx = 0; idx < len; ++idx) { + c = text[idx] & 0xFF; + bcc ^= c; + } + bcc ^= ETX; return bcc; } - /* - * Protocol transmit function - * Called by AsyncQueue to transmit a line + * Protocol Prepare Output */ -static int OMRON_Tx(pAsyncProtocol p, pAsyncTxn pTxn) { - int iRet = 1; - - if (pTxn) { - pTxn->txn_status = ATX_ACTIVE; - iRet = AsyncUnitWrite(pTxn->unit, pTxn->out_buf, pTxn->out_len); - /* TODO handle errors */ - if (iRet < 0) { /* TODO: EOF */ - /* - iRet = AsyncUnitReconnect(pTxn->unit); - if (iRet == 0) - */ - return 0; - } - } - return 1; +static int Proto_Prepare(ProtoPrivate *priv, pDynString wrBuffer) +{ + int bcc; + char stx[2] = {STX, '\0'}; + bcc = calc_bcc(GetCharArray(wrBuffer), GetDynStringLength(wrBuffer)); + DynStringInsert(wrBuffer, stx, 0); + DynStringConcatChar(wrBuffer, ETX); + DynStringConcatChar(wrBuffer, bcc); + return PROTOCOL_COMPLETE; } /* * Protocol receive character - characater by character */ -static int OMRON_Rx(pAsyncProtocol p, pAsyncTxn pTxn, int rxchar) { - int iRet = 1; - - switch (pTxn->txn_state) { - case 0: /* first character */ - if (rxchar != STX) { /* STX */ - /* TODO: error */ - pTxn->txn_state = 99; - pTxn->txn_status = ATX_COMPLETE; - break; +static int Proto_RxChar(ProtoPrivate *priv, int rxchar) +{ + enum RX_STATE { + RX_START=0, + RX_TEXT=1, + RX_LAST=2, /* BCC */ + RX_STOP=99 + }; + int bcc; + rxchar &= 0xFF; + switch (priv->state) { + case RX_START: + if (rxchar != STX) { + priv->state = RX_STOP; + return PROTOCOL_ERROR; } - /* normal data */ - pTxn->txn_state = 1; - /* note fallthrough */ - case 1: /* receiving reply */ - if (pTxn->inp_idx < pTxn->inp_len) - pTxn->inp_buf[pTxn->inp_idx++] = rxchar; - if (rxchar == ETX) - pTxn->txn_state = 2; - break; - case 2: /* receiving bcc */ - if (pTxn->inp_idx < pTxn->inp_len) - pTxn->inp_buf[pTxn->inp_idx++] = rxchar; - if (calc_bcc(pTxn->inp_buf) != rxchar) { - /* TODO: fail bcc */ - int bcc = calc_bcc(pTxn->inp_buf); + priv->state = RX_TEXT; + return PROTOCOL_CONTINUE; + case RX_TEXT: + if (rxchar == ETX) { + priv->state = RX_LAST; + return PROTOCOL_CONTINUE; + } + DynStringConcatChar(priv->rxBuffer, rxchar); + return PROTOCOL_CONTINUE; + case RX_LAST: + bcc = calc_bcc(GetCharArray(priv->rxBuffer), GetDynStringLength(priv->rxBuffer)); + if (bcc == rxchar) { + priv->state = RX_STOP; + return PROTOCOL_COMPLETE; + } else { SICSLogPrintf(eError, "Omron BCC mismatch, expected %02X but received %02X on message:", bcc, rxchar); - SICSLogWriteHex(pTxn->inp_buf, pTxn->inp_idx, eError); + SICSLogWriteHex(GetCharArray(priv->rxBuffer), GetDynStringLength(priv->rxBuffer), eError); + priv->state = RX_STOP; + return PROTOCOL_ERROR; } - pTxn->txn_state = 99; - pTxn->inp_idx -= 3; - memmove(pTxn->inp_buf, pTxn->inp_buf + 1, pTxn->inp_idx); - break; + + default: + return PROTOCOL_ERROR; } - if (pTxn->txn_state == 99) { - iRet = 0; + return PROTOCOL_ERROR; +} + +/* + * AsyncProtocol handling + * ====================== + */ + +static void Async_KillPrivate(pAsyncTxn pTxn) +{ + Proto_KillPrivate((ProtoPrivate *) pTxn->proto_private); + pTxn->proto_private = NULL; +} + +/* + * AsyncProtocol Receive Character + */ +static int Async_Rx(pAsyncProtocol p, pAsyncTxn pTxn, int rxchar) { + int iRet, str_len; + ProtoPrivate *priv = (ProtoPrivate *) pTxn->proto_private; + + iRet = Proto_RxChar(priv, rxchar); + /* + * Keep inp_buf and inp_idx up-to-date after each character + */ + str_len = GetDynStringLength(priv->rxBuffer); + if (str_len > pTxn->inp_idx && pTxn->inp_idx < pTxn->inp_len) { + int xfr_len; + char *tgt = &pTxn->inp_buf[pTxn->inp_idx]; + char *loc = &GetCharArray(priv->rxBuffer)[pTxn->inp_idx]; + if (str_len > pTxn->inp_len) + xfr_len = pTxn->inp_len - pTxn->inp_idx; + else + xfr_len = str_len - pTxn->inp_idx; + memcpy(tgt, loc, xfr_len); + pTxn->inp_idx += xfr_len; } - if (iRet == 0) { /* end of command */ - return AQU_POP_CMD; + + if (iRet == PROTOCOL_CONTINUE) { + return 1; /* Keep Going */ } - return iRet; + + if (iRet == PROTOCOL_ERROR) { + return -1; /* Error condition */ + } + + /* Message Complete */ + return AQU_POP_CMD; } /* * AsyncProtocol Event callback */ -static int OMRON_Ev(pAsyncProtocol p, pAsyncTxn pTxn, int event) { +static int Async_Ev(pAsyncProtocol p, pAsyncTxn pTxn, int event) { if (event == AQU_TIMEOUT) { /* handle command timeout */ pTxn->txn_status = ATX_TIMEOUT; @@ -108,34 +189,168 @@ static int OMRON_Ev(pAsyncProtocol p, pAsyncTxn pTxn, int event) { return AQU_POP_CMD; } -static int OMRON_PrepareTxn(pAsyncProtocol p, pAsyncTxn pTxn, const char* cmd, int cmd_len, int rsp_len) { - int i, bcc; - pTxn->out_buf = (char*) malloc(cmd_len + 3); - if (pTxn->out_buf == NULL) { - SICSLogWrite("ERROR: Out of memory in OMRON_PrepareTxn", eError); +/* + * AsyncProtocol Prepare Transaction + */ +static int Async_PrepareTxn(pAsyncProtocol p, pAsyncTxn pTxn, const char* cmd, int cmd_len, int rsp_len) { + ProtoPrivate *priv; + priv = makeProtoPrivate(); + if (priv == NULL) { + SICSLogWrite("ERROR: Out of memory in Async_PrepareTxn", eError); return 0; } - memcpy(pTxn->out_buf + 1, cmd, cmd_len); - pTxn->out_buf[0] = STX; - pTxn->out_buf[cmd_len + 1] = ETX; - pTxn->out_buf[cmd_len + 2] = calc_bcc(pTxn->out_buf); - pTxn->out_len = cmd_len + 3; + priv->state = 0; + priv->len = 0; + DynStringConcatBytes(priv->wrBuffer, cmd, cmd_len); + Proto_Prepare(priv, priv->wrBuffer); + pTxn->out_len = GetDynStringLength(priv->wrBuffer); + pTxn->out_buf = (char*) malloc(pTxn->out_len); + if (pTxn->out_buf == NULL) { + SICSLogPrintf(eError, "ERROR: Out of memory in %s:%s", __FILE__, __FUNCTION__); + Proto_KillPrivate(priv); + return 0; + } + pTxn->proto_private = priv; + pTxn->kill_private = Async_KillPrivate; + memcpy(pTxn->out_buf, GetCharArray(priv->wrBuffer), pTxn->out_len); + return 1; } -static pAsyncProtocol OMRON_Protocol = NULL; +/* + * Ascon Protocol handling + * ======================= + */ + +static void Ascon_KillPrivate(void *priv) +{ + Proto_KillPrivate((ProtoPrivate *) priv); +} + +/* + * Ascon Protocol WriteStart + */ +static int Ascon_Prepare(Ascon *a) { + ProtoPrivate *priv = (ProtoPrivate *) a->private; + Proto_Prepare(priv, a->wrBuffer); + a->wrPos = 0; + a->state = AsconWriting; + return 1; +} + +/* + * Ascon Protocol Read Poll + */ +static int Ascon_Rx(Ascon *a) { + int ret, status; + char chr = '\0'; + ProtoPrivate *priv = (ProtoPrivate *) a->private; + + ret = AsconReadChar(a->fd, &chr); + while (ret > 0) { + a->start = DoubleTime(); + status = Proto_RxChar(priv, chr); + if (GetDynStringLength(priv->rxBuffer) > GetDynStringLength(a->rdBuffer)) { + int len_rd = GetDynStringLength(a->rdBuffer); + int len_rx = GetDynStringLength(priv->rxBuffer); + char *loc = &GetCharArray(priv->rxBuffer)[len_rd]; + DynStringConcatBytes(a->rdBuffer, loc, len_rx - len_rd); + } + if (status > 0) { /* Complete */ + a->state = AsconReadDone; + return 1; + } + else if (status < 0) { /* Error */ + AsconError(a, "Protocol Input Error:", status); + /*TODO This hack stops ascon.c:AsconTask() from needlessly closing the connection. Remove this when it's no longer needed */ + a->lastReconnect = DoubleTime(); + return 1; + } + ret = AsconReadChar(a->fd, &chr); + } + if (ret < 0) { + AsconError(a, "AsconReadChar failed:", errno); + return 1; + } + if (a->state != AsconReadDone) { + if (a->timeout > 0) { + if (DoubleTime() - a->start > a->timeout) { + AsconError(a, "read timeout", 0); + a->state = AsconTimeout; + } + } + } + return 1; +} + +/* + * Ascon Protocol Poll Loop + */ +static int AsconProtHandler(Ascon *a) { + ProtoPrivate *priv = (ProtoPrivate *) a->private; + int ret; + + switch(a->state){ + case AsconWriteStart: + ret = Ascon_Prepare(a); + return ret; + case AsconReadStart: + DynStringClear(priv->rxBuffer); + a->start = DoubleTime(); + priv->state = 0; + priv->len = 0; + ret = AsconStdHandler(a); + return ret; + case AsconReading: + ret = Ascon_Rx(a); + return ret; + default: + ret = AsconStdHandler(a); + return ret; + } + return 1; +} + +/* + * Ascon Protocol Connection Init + */ +static int AsconInit(Ascon *a, SConnection *con, int argc, char *argv[]) +{ + int iRet; + ProtoPrivate *priv; + + iRet = AsconStdInit(a, con, argc, argv); + priv = makeProtoPrivate(); + a->private = priv; + a->killPrivate = Ascon_KillPrivate; + return iRet; +} + +static AsyncProtocol *My_Async_Protocol = NULL; +static AsconProtocol *My_Ascon_Protocol = NULL; /* * Protocol Initialisation */ -void OMRONInitProtocol(SicsInterp *pSics) { - if (OMRON_Protocol == NULL) { - OMRON_Protocol = AsyncProtocolCreate(pSics, "OMRON_AP", NULL, NULL); - OMRON_Protocol->sendCommand = OMRON_Tx; - OMRON_Protocol->handleInput = OMRON_Rx; - OMRON_Protocol->handleEvent = OMRON_Ev; - OMRON_Protocol->prepareTxn = OMRON_PrepareTxn; - OMRON_Protocol->killPrivate = NULL; +void PROTOCOL_INIT(SicsInterp *pSics) { + if (My_Async_Protocol == NULL) { + AsyncProtocol *prot; + prot = AsyncProtocolCreate(pSics, PROTOCOL_NAME, NULL, NULL); + prot->sendCommand = NULL; + prot->handleInput = Async_Rx; + prot->handleEvent = Async_Ev; + prot->prepareTxn = Async_PrepareTxn; + My_Async_Protocol = prot; + } + + if (My_Ascon_Protocol == NULL) { + AsconProtocol *prot; + prot = calloc(sizeof(AsconProtocol), 1); + prot->name = strdup(PROTOCOL_NAME); + prot->init = AsconInit; + prot->handler = AsconProtHandler; + AsconInsertProtocol(prot); + My_Ascon_Protocol = prot; } } diff --git a/site_ansto/ls340.c b/site_ansto/ls340.c index e1d69f55..ef4b9a41 100644 --- a/site_ansto/ls340.c +++ b/site_ansto/ls340.c @@ -786,33 +786,6 @@ static void LS340Notify(void* context, int event) static pAsyncProtocol LS340_Protocol = NULL; -static int LS340_Tx(pAsyncProtocol p, pAsyncTxn ctx) -{ - int iRet = 1; - pAsyncTxn myCmd = (pAsyncTxn) ctx; - - if (myCmd) { - - if (strchr(myCmd->out_buf, '?')) { - myCmd->txn_status = ATX_ACTIVE; - } else { - myCmd->txn_status = ATX_COMPLETE; - } - - iRet = AsyncUnitWrite(myCmd->unit, myCmd->out_buf, myCmd->out_len); - - /* TODO handle errors */ - if (iRet < 0) { /* TODO: EOF */ - /* - iRet = AsyncUnitReconnect(myCmd->unit); - if (iRet == 0) - */ - return 0; - } - } - return 1; -} - static int LS340_Rx(pAsyncProtocol p, pAsyncTxn ctx, int rxchar) { int iRet = 1; pAsyncTxn myCmd = (pAsyncTxn) ctx; @@ -856,17 +829,22 @@ static int LS340_PrepareTxn(pAsyncProtocol p, pAsyncTxn txn, const char* cmd, in if (txn->out_buf[txn->out_len-1] != '\r') { txn->out_buf[txn->out_len++] = '\r'; -// txn->out_buf[txn->out_len++] = '\r'; } -// txn->out_buf[txn->out_len++] = '\0'; + /* + * If this message does not contain a Question Mark (?) + * Then it does not request a reply + */ + if (!strchr(cmd, '?')) + txn->inp_len = 0; + return 1; } void LS340InitProtocol(SicsInterp *pSics) { if (LS340_Protocol == NULL) { LS340_Protocol = AsyncProtocolCreate(pSics, "ls340", NULL, NULL); - LS340_Protocol->sendCommand = LS340_Tx; + LS340_Protocol->sendCommand = NULL; LS340_Protocol->handleInput = LS340_Rx; LS340_Protocol->handleEvent = LS340_Ev; LS340_Protocol->prepareTxn = LS340_PrepareTxn; diff --git a/site_ansto/lssmonitor.c b/site_ansto/lssmonitor.c index 94df0c68..bab86590 100644 --- a/site_ansto/lssmonitor.c +++ b/site_ansto/lssmonitor.c @@ -97,23 +97,6 @@ mxml_node_t *tree; static int LSS_GetState(void *pData, char *param, LSS_STATUS *retState); -static int LSS_Tx(pAsyncProtocol p, pAsyncTxn myCmd) -{ - int iRet = 1; - - if (myCmd) { - myCmd->txn_status = ATX_ACTIVE; - iRet = AsyncUnitWrite(myCmd->unit, myCmd->out_buf, myCmd->out_len); - /* TODO handle errors */ - if (iRet < 0) { /* TODO: EOF */ - iRet = AsyncUnitReconnect(myCmd->unit); - if (iRet == 0) - return 0; - } - } - return 1; -} - static int LSS_Rx(pAsyncProtocol p, pAsyncTxn myCmd, int rxchar) { int iRet = 1; @@ -512,7 +495,7 @@ static void LSS_Kill(void* pData) void LSSInitProtocol(SicsInterp *pSics) { if (LSS_Protocol == NULL) { LSS_Protocol = AsyncProtocolCreate(pSics, "LSS", NULL, NULL); - LSS_Protocol->sendCommand = LSS_Tx; + LSS_Protocol->sendCommand = NULL; LSS_Protocol->handleInput = LSS_Rx; LSS_Protocol->handleEvent = LSS_Ev; LSS_Protocol->prepareTxn = NULL; diff --git a/site_ansto/motor_dmc2280.c b/site_ansto/motor_dmc2280.c index c6a4ee71..b625f2ef 100644 --- a/site_ansto/motor_dmc2280.c +++ b/site_ansto/motor_dmc2280.c @@ -933,25 +933,6 @@ static int motCreep(pDMC2280Driv self, double target) { return target_steps; } -static int DMC_Tx(pAsyncProtocol p, pAsyncTxn ctx) { - int iRet = 1; - pAsyncTxn myCmd = (pAsyncTxn) ctx; - - if (myCmd) { - myCmd->txn_status = ATX_ACTIVE; - iRet = AsyncUnitWrite(myCmd->unit, myCmd->out_buf, myCmd->out_len); - /* TODO handle errors */ - if (iRet < 0) { /* TODO: EOF */ - /* - iRet = AsyncUnitReconnect(myCmd->unit); - if (iRet == 0) - */ - return 0; - } - } - return 1; -} - static int DMC_Rx(pAsyncProtocol p, pAsyncTxn ctx, int rxchar) { int iRet = 1; pAsyncTxn myCmd = (pAsyncTxn) ctx; @@ -6367,7 +6348,7 @@ int DMC2280Action(SConnection *pCon, SicsInterp *pSics, void *pData, void DMC2280InitProtocol(SicsInterp *pSics) { if (DMC2280_Protocol == NULL) { DMC2280_Protocol = AsyncProtocolCreate(pSics, "DMC2280", NULL, NULL); - DMC2280_Protocol->sendCommand = DMC_Tx; + DMC2280_Protocol->sendCommand = NULL; DMC2280_Protocol->handleInput = DMC_Rx; DMC2280_Protocol->handleEvent = DMC_Ev; DMC2280_Protocol->prepareTxn = NULL; diff --git a/site_ansto/orhvps.c b/site_ansto/orhvps.c index 03cf129b..88b0e705 100644 --- a/site_ansto/orhvps.c +++ b/site_ansto/orhvps.c @@ -778,28 +778,6 @@ static void ORHVPSKillPrivate(void *pData) { } } -/* - * Protocol transmit function - * Called by AsyncQueue to transmit a line - */ -static int ORHVPS_Tx(pAsyncProtocol p, pAsyncTxn myCmd) { - int iRet = 1; - - if (myCmd) { - myCmd->txn_status = ATX_ACTIVE; - iRet = AsyncUnitWrite(myCmd->unit, myCmd->out_buf, myCmd->out_len); - /* TODO handle errors */ - if (iRet < 0) { /* TODO: EOF */ - /* - iRet = AsyncUnitReconnect(myCmd->unit); - if (iRet == 0) - */ - return 0; - } - } - return 1; -} - /* * Protocol receive character - characater by character */ @@ -907,7 +885,7 @@ static pAsyncProtocol ORHVPS_Protocol = NULL; void ORHVPSInitProtocol(SicsInterp *pSics) { if (ORHVPS_Protocol == NULL) { ORHVPS_Protocol = AsyncProtocolCreate(pSics, "ORHVPS", NULL, NULL); - ORHVPS_Protocol->sendCommand = ORHVPS_Tx; + ORHVPS_Protocol->sendCommand = NULL; ORHVPS_Protocol->handleInput = ORHVPS_Rx; ORHVPS_Protocol->handleEvent = ORHVPS_Ev; ORHVPS_Protocol->prepareTxn = ORHVPS_PrepareTxn; diff --git a/site_ansto/safetyplc.c b/site_ansto/safetyplc.c index 5febf900..35486d55 100644 --- a/site_ansto/safetyplc.c +++ b/site_ansto/safetyplc.c @@ -77,23 +77,6 @@ struct __SafetyPLCController { static int PLC_GetState(void *pData, char *param, PLC_STATUS *retState); -static int PLC_Tx(pAsyncProtocol p, pAsyncTxn myCmd) -{ - int iRet = 1; - - if (myCmd) { - myCmd->txn_status = ATX_ACTIVE; - iRet = AsyncUnitWrite(myCmd->unit, myCmd->out_buf, myCmd->out_len); - /* TODO handle errors */ - if (iRet < 0) { /* TODO: EOF */ - iRet = AsyncUnitReconnect(myCmd->unit); - if (iRet == 0) - return 0; - } - } - return 1; -} - static int PLC_Rx(pAsyncProtocol p, pAsyncTxn myCmd, int rxchar) { int iRet = 1; @@ -477,7 +460,7 @@ static void PLC_Kill(void* pData) void SafetyPLCInitProtocol(SicsInterp *pSics) { if (PLC_Protocol == NULL) { PLC_Protocol = AsyncProtocolCreate(pSics, "SafetyPLC", NULL, NULL); - PLC_Protocol->sendCommand = PLC_Tx; + PLC_Protocol->sendCommand = NULL; PLC_Protocol->handleInput = PLC_Rx; PLC_Protocol->handleEvent = PLC_Ev; PLC_Protocol->prepareTxn = NULL; From e76f6376eec1dc1c3abe4f991ee74fe568b04de3 Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Tue, 26 Aug 2014 14:30:43 +1000 Subject: [PATCH 09/68] Added Modbus Protocol --- site_ansto/hardsup/loader_asyncprotocol.c | 2 + site_ansto/hardsup/makefile | 1 + site_ansto/hardsup/modbus_asyncprotocol.c | 718 ++++++++++++++++++++++ site_ansto/hardsup/modbus_asyncprotocol.h | 5 + 4 files changed, 726 insertions(+) create mode 100644 site_ansto/hardsup/modbus_asyncprotocol.c create mode 100644 site_ansto/hardsup/modbus_asyncprotocol.h diff --git a/site_ansto/hardsup/loader_asyncprotocol.c b/site_ansto/hardsup/loader_asyncprotocol.c index cb1c7441..9dd4816a 100644 --- a/site_ansto/hardsup/loader_asyncprotocol.c +++ b/site_ansto/hardsup/loader_asyncprotocol.c @@ -1,6 +1,7 @@ #include "loader_asyncprotocol.h" #include "huber_asyncprotocol.h" #include "knauer_asyncprotocol.h" +#include "modbus_asyncprotocol.h" #include "omron_asyncprotocol.h" #include "sics.h" @@ -8,5 +9,6 @@ void LOADERInitProtocol(SicsInterp *pSics) { HUBERInitProtocol(pSics); KNAUERInitProtocol(pSics); + MODBUSInitProtocol(pSics); OMRONInitProtocol(pSics); } diff --git a/site_ansto/hardsup/makefile b/site_ansto/hardsup/makefile index dcac1541..aef194cb 100644 --- a/site_ansto/hardsup/makefile +++ b/site_ansto/hardsup/makefile @@ -38,6 +38,7 @@ HOBJ += aqp_opalstatus.o HOBJ += omron_asyncprotocol.o HOBJ += huber_asyncprotocol.o HOBJ += knauer_asyncprotocol.o +HOBJ += modbus_asyncprotocol.o HOBJ += loader_asyncprotocol.o libhlib.a: $(HOBJ) diff --git a/site_ansto/hardsup/modbus_asyncprotocol.c b/site_ansto/hardsup/modbus_asyncprotocol.c new file mode 100644 index 00000000..13cdec68 --- /dev/null +++ b/site_ansto/hardsup/modbus_asyncprotocol.c @@ -0,0 +1,718 @@ +#include "modbus_asyncprotocol.h" +#include "asyncprotocol.h" +#include "asyncqueue.h" +#include "ascon.i" +#include "dynstring.h" +#include +#include +#include + +#define PROTOCOL_CONTINUE 0 +#define PROTOCOL_COMPLETE 1 +#define PROTOCOL_ERROR (-1) + +/* Sample Messages + * structure: + * STX + * data + * ETX + * BCC +*/ +#define PROTOCOL_NAME "MODBUS_AP" +#define PROTOCOL_INIT MODBUSInitProtocol +#define ADUSIZE 17 + +/* + * MODBUS DataTypes + */ +enum mbDtypes {U16, U32, F32}; + +/* + * NumVal = number of values to read or write, + * ie number of coils, input/outputs or registers. + * Number of bytes = NumVal * (number of bytes in Dtype) + */ +struct cmdPar { + unsigned int MBAddr; /**< MODBUS Address */ + unsigned int Fcode; /**< Function Code */ + unsigned int SAddr; + unsigned int NumVal; /**< Number of Values */ + unsigned int NumBytes; + unsigned int NumRd; + unsigned int NumWr; + enum mbDtypes Dtype; + double MBdata[2000]; +}; + +enum MBFCODES { RdCoil=1, RdInp=2, RdHldReg=3, RdInpReg=4, WrCoil=5, WrReg=6, WrMCoils=15, WrMRegs=16 }; + +typedef struct modbus_private_t Private, *pPrivate; +struct modbus_private_t { + struct cmdPar MBcmd; + int BO[4]; + int aduLen; + int RespLen; + int DatLen; + unsigned char ADU[ADUSIZE]; /* Allows upto 8 bytes if data */ + pDynString rdBuffer; +}; + +/* + * Protocol Private data block + */ +typedef struct proto_private_t { + int state; /**< protocol state machine */ + int len; /**< length from the protocol */ + pDynString wrBuffer; /**< transmitted message */ + pDynString rxBuffer; /**< received message */ + Private mb_priv; +} ProtoPrivate; + +static ProtoPrivate *makeProtoPrivate() +{ + ProtoPrivate *priv = calloc(sizeof(ProtoPrivate), 1); + priv->wrBuffer = CreateDynString(100, 100); + priv->rxBuffer = CreateDynString(100, 100); + return priv; +} + +static ProtoPrivate *Proto_KillPrivate(ProtoPrivate *priv) +{ + if (priv) { + if (priv->rxBuffer) { + DeleteDynString(priv->rxBuffer); + priv->rxBuffer = NULL; + } + free(priv); + } + return NULL; +} + +/* + * Protocol Specific Support Functions + */ + +/* IEEE code copied from psi/modbus.c */ +static void double2ieee(double input, unsigned char ieee[4]) { + + /* convert double to IEEE 32 bit floating number + * (denormalized numbers are considered as zero) + */ + + long mantissa; + int exponent; + + if (input == 0) { + ieee[0]= 0; + ieee[1]= 0; + ieee[2]= 0; + ieee[3]= 0; + } else { + /* frexp -> 0.f * 2^23 */ + /* 2^24 * fract instead of 2^23 + * because we get 0.(f/2) not 1.f from frexp and exponent = e + 1 + */ + mantissa = 0x1000000 * (frexp(fabs(input), &exponent)); + exponent = exponent - 1 + 127; + if (exponent < 0) { + exponent = 0; + } else if (exponent > 0xFE) { + exponent = 0xFE; + } + if (input < 0) { + ieee[0] = 0x80 | (exponent >> 1); + } else { + ieee[0] = exponent >> 1; + } + ieee[1] = (exponent & 1) << 7 | ((mantissa & 0x7F0000) >> 16); + ieee[2] = (mantissa & 0xFF00) >> 8; + ieee[3] = mantissa & 0xFF; + } + return; +} + +/*-------------------------------------------------------------------------*/ +static double ieee2double(unsigned char ieee[4]) { + + /* IEEE 32 bit floating number to double + * (denormalized numbers are considered as zero) + */ + + long mantissa; + double output, norm = 1; + int exponent, bias = 127; + + mantissa = ((ieee[1] << 16) & 0x7F0000) + | ((ieee[2] << 8) & 0xFF00) + | ((ieee[3] ) & 0xFF); + + exponent = (ieee[0] & 0x7F) * 2 + ((ieee[1] >> 7) & 1); /* raw exponent */ + if (exponent == 255) { + if (mantissa == 0) { + /*TODO INF */ + } else { + /*TODO NAN */ + } + } + if (exponent == 0) { + if (mantissa == 0) { + return 0.0; + } else { + bias = 126; + norm = 0; + } + } + output = ldexp(mantissa, -23) + norm; + if (ieee[0] & 0x80) { + output = -output; + } + return output * ldexp(1, exponent - bias); +} +/*-------------------------------------------------------------------------*/ + +/** @brief Parse a command string of the form "MBAddr:Fcode:SAddr:Dtype:MBdata" +Dtype U16, U32, F32 with optional byte order array eg U32[3,2,1,0] +*/ +static void parseCmd(char *cmdLine, struct cmdPar *MBC, int *BO) { + int len; + unsigned int i; + char *nextPar, dataType[4]; + double dVal; + + MBC->MBAddr = strtoul(cmdLine, &nextPar, 0); + cmdLine = nextPar+1; + MBC->Fcode = strtoul(cmdLine, &nextPar, 0); + cmdLine = nextPar+1; + MBC->SAddr = strtoul(cmdLine, &nextPar, 0); + cmdLine = nextPar+1; + if (MBC->Fcode != WrCoil) { + MBC->NumVal = strtod(cmdLine, &nextPar); + cmdLine = nextPar + 1; + strncpy(dataType,cmdLine,3); + dataType[3] = '\0'; + cmdLine += 3; + nextPar = cmdLine; + if (strcmp(dataType, "U16") == 0) { + MBC->Dtype = U16; + } else if (strcmp(dataType, "U32") == 0) { + MBC->Dtype = U32; + } else if (strcmp(dataType, "F32") == 0) { + MBC->Dtype = F32; + } + if (*cmdLine == '[') { + cmdLine++; + BO[0] = strtol(cmdLine, &nextPar, 10); + cmdLine = nextPar + 1; + BO[1] = strtol(cmdLine, &nextPar, 10); + cmdLine = nextPar + 1; + BO[2] = strtol(cmdLine, &nextPar, 10); + cmdLine = nextPar + 1; + BO[3] = strtol(cmdLine, &nextPar, 10); + } + cmdLine = nextPar + 1; + } + switch (MBC->Fcode) { + case RdCoil: + /* Coils are numbered from 1 but addressed from 0 */ + MBC->SAddr--; + MBC->NumBytes = MBC->NumVal; + MBC->NumRd = MBC->NumVal; + break; + case WrCoil: + MBC->SAddr--; + dVal = strtod(cmdLine, &nextPar); + if (dVal == 1) { + MBC->MBdata[0] = 255; + } else if (dVal == 0) { + MBC->MBdata[0] = 0; + } else { + /* TODO ERROR */ + } + break; + case RdHldReg: + if (MBC->Dtype == F32 || MBC->Dtype == U32) { + MBC->NumRd = MBC->NumVal * 2; + } else if (MBC->Dtype == U16) { + MBC->NumRd = MBC->NumVal; + } else { + /* TODO ERROR */ + } + break; + case WrMRegs: + for (i=0; i < MBC->NumVal; i++) { + MBC->MBdata[i] = strtod(cmdLine, &nextPar); + cmdLine = nextPar + 1; + } + if (MBC->Dtype == F32 || MBC->Dtype == U32) { + MBC->NumWr = MBC->NumVal * 2; + MBC->NumBytes = MBC->NumVal * 4; + } else if (MBC->Dtype == U16) { + MBC->NumWr = MBC->NumVal; + MBC->NumBytes = MBC->NumVal * 2; + } + break; + } +} + +static int ModbusOutput(pPrivate myPriv, pDynString wrBuffer, pDynString send_buffer) { + int ADUlen, PDUlenPlusUID; + unsigned int i, j; + char *cmdLine; + unsigned char ADU[32], ieee[4]; + + cmdLine = GetCharArray(wrBuffer); + for (i=0; i < 4; i++) + myPriv->BO[i] = i; + parseCmd(cmdLine, &myPriv->MBcmd, myPriv->BO); + + ADU[0] = 0; + ADU[1] = 0; + ADU[2] = 0; + ADU[3] = 0; + ADU[6] = myPriv->MBcmd.MBAddr; + ADU[7] = myPriv->MBcmd.Fcode; + switch (myPriv->MBcmd.Fcode) { + case RdCoil: + case RdHldReg: + /* TODO Max NumRd = 125 */ + ADU[8] = (myPriv->MBcmd.SAddr & 0xFF00) >> 8; + ADU[9] = myPriv->MBcmd.SAddr & 0xFF; + ADU[10] = (myPriv->MBcmd.NumRd & 0xFF00) >> 8; + ADU[11] = myPriv->MBcmd.NumRd & 0xFF; + ADUlen = 12; + break; + case WrCoil: + ADU[8] = (myPriv->MBcmd.SAddr & 0xFF00) >> 8; + ADU[9] = myPriv->MBcmd.SAddr & 0xFF; + ADU[10] = myPriv->MBcmd.MBdata[0]; + ADU[11] = 0; + ADUlen = 12; + break; + case WrMRegs: + ADU[8] = (myPriv->MBcmd.SAddr & 0xFF00) >> 8; + ADU[9] = myPriv->MBcmd.SAddr & 0xFF; + ADU[10] = (myPriv->MBcmd.NumWr & 0xFF00) >> 8; + ADU[11] = myPriv->MBcmd.NumWr & 0xFF; + ADU[12] = myPriv->MBcmd.NumBytes; + switch (myPriv->MBcmd.Dtype) { + case U16: + for (i=0, j=13; i < myPriv->MBcmd.NumVal; i++, j+=4) { + ADU[j + myPriv->BO[0]] = ((unsigned int)myPriv->MBcmd.MBdata[i] & 0xFF00) >> 8; + ADU[j + myPriv->BO[1]] = (unsigned int)myPriv->MBcmd.MBdata[i] & 0xFF; + } + break; + case U32: + for (i=0, j=13; i < myPriv->MBcmd.NumVal; i++, j+=4) { + ADU[j + myPriv->BO[0]] = ((unsigned int)myPriv->MBcmd.MBdata[i] & 0xFF000000) >> 24; + ADU[j + myPriv->BO[1]] = ((unsigned int)myPriv->MBcmd.MBdata[i] & 0xFF0000) >> 16; + ADU[j + myPriv->BO[2]] = ((unsigned int)myPriv->MBcmd.MBdata[i] & 0xFF00) >> 8; + ADU[j + myPriv->BO[3]] = (unsigned int)myPriv->MBcmd.MBdata[i] & 0xFF; + } + break; + case F32: + for (i=0, j=13; i < myPriv->MBcmd.NumVal; i++, j+=4) { + double2ieee(myPriv->MBcmd.MBdata[i], ieee); + ADU[j + myPriv->BO[0]] = ieee[0]; + ADU[j + myPriv->BO[1]] = ieee[1]; + ADU[j + myPriv->BO[2]] = ieee[2]; + ADU[j + myPriv->BO[3]] = ieee[3]; + } + break; + } + ADUlen = 13 + myPriv->MBcmd.NumBytes; + break; + default: + // Not Implemented + break; + } + /* Length field in MBAP includes byte 7 of the MBAP, so Length = ADU length - 6. */ + PDUlenPlusUID = ADUlen - 6; + ADU[4] = (PDUlenPlusUID & 0xFF00) >> 8; + ADU[5] = PDUlenPlusUID & 0xFF; + DynStringClear(send_buffer); + DynStringConcatBytes(send_buffer, (char *) ADU, ADUlen); + return 1; +} + + +/** @brief decode modbus response +*/ +/* ADU[4] = MSB of DatLen, ADU[5] = LSB of DatLen */ + +/* NOTE: Min aduLen is 9. The header (7 bytes) + an Error code and Exception code */ +static const int TIDidx=0; +static const int PIDidx=2; +static const int LENidx=4; +static const int UIDidx=6; +static const int CODEidx=7; +static const int DATLENidx=8; +static const int DATAidx=9; + +static void StartIn(pPrivate myPriv) { + myPriv->aduLen = 0; + myPriv->RespLen = 0; + myPriv->DatLen = 0; +} + +static int ModbusInput(pPrivate myPriv, unsigned char chr, pDynString rdBuffer) { + int i, byteCnt; + unsigned char ieee[4]; + double dVal; + long int liVal; + + if (myPriv->aduLen == 0) + DynStringClear(rdBuffer); + + myPriv->ADU[myPriv->aduLen++] = chr; + if (myPriv->RespLen == 0) { + if (myPriv->aduLen >= UIDidx) { + myPriv->RespLen = (myPriv->ADU[LENidx] << 8) + myPriv->ADU[LENidx+1]; + if (myPriv->RespLen <= 0) { + DynStringReplace(rdBuffer, "ASCERR: Length field exception", 0); + return PROTOCOL_ERROR; + } + } else { + return PROTOCOL_CONTINUE; + } + } + if (myPriv->aduLen < (6 + myPriv->RespLen)) { + return PROTOCOL_CONTINUE; + } + + if (myPriv->ADU[CODEidx] > 0x80) { + /* snprintf(errMsg, ERRLEN, "TCPMODBUS: Function code %d exception %d:", ADU[CODEidx] & 0x0F, ADU[8] &0x0F); */ + DynStringReplace(rdBuffer, "ASCERR: Function code exception", 0); + return PROTOCOL_ERROR; + } else if (myPriv->ADU[CODEidx] != myPriv->MBcmd.Fcode) { + /* snprintf(errMsg, ERRLEN, "TCPMODBUS: Requested function %d but got response for %d:", MBcmd.Fcode, ADU[CODEidx]); */ + DynStringReplace(rdBuffer, "ASCERR: Function code response exception", 0); + return PROTOCOL_ERROR; + } else { + char temp[65]; + DynStringClear(rdBuffer); + switch (myPriv->MBcmd.Fcode) { + case RdCoil: + byteCnt = myPriv->ADU[8]; + for (i=0; i < byteCnt; i++) { + snprintf(temp, 64, "%d", myPriv->ADU[9+i]); + DynStringConcat(rdBuffer, temp); + DynStringConcatChar(rdBuffer, ' '); + } + break; + case RdHldReg: + byteCnt = myPriv->ADU[8]; + switch (myPriv->MBcmd.Dtype) { + case U16: + for (i=0; i < byteCnt/2; i++) { + ieee[ myPriv->BO[0] ] = myPriv->ADU[9+i*2]; + ieee[ myPriv->BO[1] ] = myPriv->ADU[10+i*2]; + liVal = (ieee[0] << 8) | ieee[1]; + snprintf(temp, 64, "%ld", liVal); + DynStringConcat(rdBuffer, temp); + DynStringConcatChar(rdBuffer, ' '); + } + break; + case U32: + case F32: + for (i=0; i < byteCnt/4; i++) { + ieee[ myPriv->BO[0] ] = myPriv->ADU[9+i*4]; + ieee[ myPriv->BO[1] ] = myPriv->ADU[10+i*4]; + ieee[ myPriv->BO[2] ] = myPriv->ADU[11+i*4]; + ieee[ myPriv->BO[3] ] = myPriv->ADU[12+i*4]; + if (myPriv->MBcmd.Dtype == F32) { + dVal = ieee2double(ieee); + snprintf(temp, 64, "%g", dVal); + } else if (myPriv->MBcmd.Dtype == U32) { + liVal = (ieee[0] << 24) | (ieee[1] << 16) | (ieee[2] << 8) | ieee[3]; + snprintf(temp, 64, "%ld", liVal); + } + DynStringConcat(rdBuffer, temp); + DynStringConcatChar(rdBuffer, ' '); + } + break; + default: + break; + } + break; + case WrCoil: + if (myPriv->ADU[7] == myPriv->MBcmd.Fcode && (myPriv->ADU[8] * 256 | myPriv->ADU[9]) == myPriv->MBcmd.SAddr && + myPriv->ADU[10] == myPriv->MBcmd.MBdata[0]) { + DynStringReplace(rdBuffer, "OK", 0); + } else { + DynStringReplace(rdBuffer, "ASCERR: Response doesn't match set request", 0); + return PROTOCOL_ERROR; + } + break; + case WrMRegs: + if (myPriv->ADU[7] == myPriv->MBcmd.Fcode && (myPriv->ADU[8] * 256 | myPriv->ADU[9]) == myPriv->MBcmd.SAddr && + (myPriv->ADU[10] * 256 | myPriv->ADU[11]) == myPriv->MBcmd.NumWr) { + DynStringReplace(rdBuffer, "OK", 0); + } else { + DynStringReplace(rdBuffer, "ASCERR: Response doesn't match set request", 0); + return PROTOCOL_ERROR; + } + break; + default: + break; + } + } + myPriv->aduLen = 0, myPriv->DatLen = 0, myPriv->RespLen = 0; + memset(myPriv->ADU, 0, ADUSIZE); + return PROTOCOL_COMPLETE; +} + +/* + * Protocol Prepare Output + */ +static int Proto_Prepare(ProtoPrivate *priv, pDynString wrBuffer) +{ + ModbusOutput(&priv->mb_priv, wrBuffer, wrBuffer); + StartIn(&priv->mb_priv); + return PROTOCOL_COMPLETE; +} + +/* + * Protocol receive character - characater by character + */ +static int Proto_RxChar(ProtoPrivate *priv, int rxchar) +{ + enum RX_STATE { + RX_START=0, + RX_TEXT=1, + RX_LAST=2, /* BCC */ + RX_STOP=99 + }; + int iRet; + rxchar &= 0xFF; + iRet = ModbusInput(&priv->mb_priv, rxchar, priv->rxBuffer); + if (iRet == PROTOCOL_COMPLETE) + return PROTOCOL_COMPLETE; + if (iRet == PROTOCOL_CONTINUE) + return PROTOCOL_CONTINUE; + return PROTOCOL_ERROR; +} + +/* + * AsyncProtocol handling + * ====================== + */ + +static void Async_KillPrivate(pAsyncTxn pTxn) +{ + Proto_KillPrivate((ProtoPrivate *) pTxn->proto_private); + pTxn->proto_private = NULL; +} + +/* + * AsyncProtocol Receive Character + */ +static int Async_Rx(pAsyncProtocol p, pAsyncTxn pTxn, int rxchar) { + int iRet, str_len; + ProtoPrivate *priv = (ProtoPrivate *) pTxn->proto_private; + + iRet = Proto_RxChar(priv, rxchar); + /* + * Keep inp_buf and inp_idx up-to-date after each character + */ + str_len = GetDynStringLength(priv->rxBuffer); + if (str_len > pTxn->inp_idx && pTxn->inp_idx < pTxn->inp_len) { + int xfr_len; + char *tgt = &pTxn->inp_buf[pTxn->inp_idx]; + char *loc = &GetCharArray(priv->rxBuffer)[pTxn->inp_idx]; + if (str_len > pTxn->inp_len) + xfr_len = pTxn->inp_len - pTxn->inp_idx; + else + xfr_len = str_len - pTxn->inp_idx; + memcpy(tgt, loc, xfr_len); + pTxn->inp_idx += xfr_len; + } + + if (iRet == PROTOCOL_CONTINUE) { + return 1; /* Keep Going */ + } + + if (iRet == PROTOCOL_ERROR) { + return -1; /* Error condition */ + } + + /* Message Complete */ + return AQU_POP_CMD; +} + +/* + * AsyncProtocol Event callback + */ +static int Async_Ev(pAsyncProtocol p, pAsyncTxn pTxn, int event) { + if (event == AQU_TIMEOUT) { + /* handle command timeout */ + pTxn->txn_status = ATX_TIMEOUT; + return AQU_POP_CMD; + } + return AQU_POP_CMD; +} + +/* + * AsyncProtocol Prepare Transaction + */ +static int Async_PrepareTxn(pAsyncProtocol p, pAsyncTxn pTxn, const char* cmd, int cmd_len, int rsp_len) { + ProtoPrivate *priv; + priv = makeProtoPrivate(); + if (priv == NULL) { + SICSLogWrite("ERROR: Out of memory in Async_PrepareTxn", eError); + return 0; + } + priv->state = 0; + priv->len = 0; + DynStringConcatBytes(priv->wrBuffer, (char *) cmd, cmd_len); + Proto_Prepare(priv, priv->wrBuffer); + pTxn->out_len = GetDynStringLength(priv->wrBuffer); + pTxn->out_buf = (char*) malloc(pTxn->out_len); + if (pTxn->out_buf == NULL) { + SICSLogPrintf(eError, "ERROR: Out of memory in %s:%s", __FILE__, __FUNCTION__); + Proto_KillPrivate(priv); + return 0; + } + pTxn->proto_private = priv; + pTxn->kill_private = Async_KillPrivate; + memcpy(pTxn->out_buf, GetCharArray(priv->wrBuffer), pTxn->out_len); + + return 1; +} + +/* + * Ascon Protocol handling + * ======================= + */ + +static void Ascon_KillPrivate(void *priv) +{ + Proto_KillPrivate((ProtoPrivate *) priv); +} + +/* + * Ascon Protocol WriteStart + */ +static int Ascon_Prepare(Ascon *a) { + ProtoPrivate *priv = (ProtoPrivate *) a->private; + Proto_Prepare(priv, a->wrBuffer); + a->wrPos = 0; + a->state = AsconWriting; + return 1; +} + +/* + * Ascon Protocol Read Poll + */ +static int Ascon_Rx(Ascon *a) { + int ret, status; + char chr = '\0'; + ProtoPrivate *priv = (ProtoPrivate *) a->private; + + ret = AsconReadChar(a->fd, &chr); + while (ret > 0) { + a->start = DoubleTime(); + status = Proto_RxChar(priv, chr); + if (GetDynStringLength(priv->rxBuffer) > GetDynStringLength(a->rdBuffer)) { + int len_rd = GetDynStringLength(a->rdBuffer); + int len_rx = GetDynStringLength(priv->rxBuffer); + char *loc = &GetCharArray(priv->rxBuffer)[len_rd]; + DynStringConcatBytes(a->rdBuffer, loc, len_rx - len_rd); + } + if (status > 0) { /* Complete */ + a->state = AsconReadDone; + return 1; + } + else if (status < 0) { /* Error */ + AsconError(a, "Protocol Input Error:", status); + /*TODO This hack stops ascon.c:AsconTask() from needlessly closing the connection. Remove this when it's no longer needed */ + a->lastReconnect = DoubleTime(); + return 1; + } + ret = AsconReadChar(a->fd, &chr); + } + if (ret < 0) { + AsconError(a, "AsconReadChar failed:", errno); + return 1; + } + if (a->state != AsconReadDone) { + if (a->timeout > 0) { + if (DoubleTime() - a->start > a->timeout) { + AsconError(a, "read timeout", 0); + a->state = AsconTimeout; + } + } + } + return 1; +} + +/* + * Ascon Protocol Poll Loop + */ +static int AsconProtHandler(Ascon *a) { + ProtoPrivate *priv = (ProtoPrivate *) a->private; + int ret; + + switch(a->state){ + case AsconWriteStart: + ret = Ascon_Prepare(a); + return ret; + case AsconReadStart: + DynStringClear(priv->rxBuffer); + a->start = DoubleTime(); + priv->state = 0; + priv->len = 0; + ret = AsconStdHandler(a); + return ret; + case AsconReading: + ret = Ascon_Rx(a); + return ret; + default: + ret = AsconStdHandler(a); + return ret; + } + return 1; +} + +/* + * Ascon Protocol Connection Init + */ +static int AsconInit(Ascon *a, SConnection *con, int argc, char *argv[]) +{ + int iRet; + ProtoPrivate *priv; + + iRet = AsconStdInit(a, con, argc, argv); + priv = makeProtoPrivate(); + a->private = priv; + a->killPrivate = Ascon_KillPrivate; + return iRet; +} + +static AsyncProtocol *My_Async_Protocol = NULL; +static AsconProtocol *My_Ascon_Protocol = NULL; + +/* + * Protocol Initialisation + */ +void PROTOCOL_INIT(SicsInterp *pSics) { + if (My_Async_Protocol == NULL) { + AsyncProtocol *prot; + prot = AsyncProtocolCreate(pSics, PROTOCOL_NAME, NULL, NULL); + prot->sendCommand = NULL; + prot->handleInput = Async_Rx; + prot->handleEvent = Async_Ev; + prot->prepareTxn = Async_PrepareTxn; + My_Async_Protocol = prot; + } + + if (My_Ascon_Protocol == NULL) { + AsconProtocol *prot; + prot = calloc(sizeof(AsconProtocol), 1); + prot->name = strdup(PROTOCOL_NAME); + prot->init = AsconInit; + prot->handler = AsconProtHandler; + AsconInsertProtocol(prot); + My_Ascon_Protocol = prot; + } +} + diff --git a/site_ansto/hardsup/modbus_asyncprotocol.h b/site_ansto/hardsup/modbus_asyncprotocol.h new file mode 100644 index 00000000..fa1d05c5 --- /dev/null +++ b/site_ansto/hardsup/modbus_asyncprotocol.h @@ -0,0 +1,5 @@ +#ifndef MODBUS_ASYNCPROTOCOL_H +#define MODBUS_ASYNCPROTOCOL_H +#include "sics.h" +void MODBUSInitProtocol(SicsInterp *pSics); +#endif From 4ea8678b442766e74554776ec87af911f3722a59 Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Wed, 27 Aug 2014 16:49:56 +1000 Subject: [PATCH 10/68] Pull in Makefile changes from RELEASE-3_2 --- site_ansto/Makefile | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) mode change 100644 => 100755 site_ansto/Makefile diff --git a/site_ansto/Makefile b/site_ansto/Makefile old mode 100644 new mode 100755 index 6da99396..51d68603 --- a/site_ansto/Makefile +++ b/site_ansto/Makefile @@ -7,6 +7,8 @@ # Markus Zolliker, March 2003 #========================================================================== +.PHONY: sct + default: all # ANSTO rules and variables @@ -16,7 +18,7 @@ PSI_LIBS = \ -ldl -lz -lm -lc $(LIB_MXML) $(LIB_JSON) CC = gcc INCFLAGS = -Ihardsup -I.. $(INC_HDF5) $(INC_TCL8) -# NOTE -std=gnu99 adds c99 support with gnu extensions, it eliminates implicit function warnings +# NOTE -std=gnu99 adds c99 support with gnu extensions, it eliminates implicit function warnings # for c99 functions like roundf. We don't use -std=c99 because it generates compiler errors in # code modules that use the timeval struct without including sys/time.h, c99 also generates # implicit function declaration warnings on string functions like strdup. @@ -25,7 +27,9 @@ INCFLAGS = -Ihardsup -I.. $(INC_HDF5) $(INC_TCL8) # may be in different locations. This code tries to find the include files and # libraries required in descending order of preference. -libsearch = $(wildcard /usr/lib*/lib$(1).so /usr/lib*/lib$(1).so.? /usr/lib*/lib$(1).so.??* /usr/lib*/lib$(1).a) +libsearcha = $(wildcard /usr/lib*/lib$(1).a) +libsearchso = $(wildcard /usr/lib*/lib$(1).so /usr/lib*/lib$(1).so.? /usr/lib*/lib$(1).so.??*) +libsearch = $(firstword $(call libsearcha,$(1)) $(call libsearchso,$(1))) libsearch1 = $(firstword $(call libsearch,$(1))) incsearch = $(wildcard /usr/include/$(1) /usr/local/include/$(1)) incsearch1 = $(firstword $(call incsearch,$(1))) @@ -41,7 +45,7 @@ $(foreach myinc,$(myincs),$(info incsearch1($(myinc)) = $(call incsearch1,$(myin endif # TCL 8.5 or 8.4 -LIB_TCL8 = $(firstword $(call libsearch1,tcl8.5) $(call libsearch1,tcl8.4)) +LIB_TCL8 = $(firstword $(call libsearchso,tcl8.5) $(call libsearchso,tcl8.4)) INC_TCL8 = $(firstword $(call incsearch1,tcl.h) $(call incsearch1,tcl8.5/tcl.h) $(call incsearch1,tcl8.4/tcl.h)) ifeq (,$(LIB_TCL8)) @@ -123,7 +127,7 @@ SITEHARDSUP = hardsup/libhlib.a HARDSUPDIR = $(SITEDIR)/hardsup SUBLIBS = libansto.a hardsup/libhlib.a $(PSI_SLIBS) libansto.a hardsup/libhlib.a $(PSI_LIBS) -.SUFFIXES: +.SUFFIXES: .SUFFIXES: .c .o .f GHTTP_LIBS = $(LIB_HTTP) @@ -154,7 +158,9 @@ OBJ= site_ansto.o anstoutil.o\ beamstopaction.o action.o \ tclClock.o tclDate.o tclUnixTime.o -all: config libsics libansto.a libhardsup +all: | config libsics libhardsup SICServer + +SICServer: ../SICSmain.o libansto.a hardsup/libhlib.a ../libsics.a ../matrix/libmatrix.a | config libsics libhardsup $(CC) -g -o SICServer ../SICSmain.o $(SUBLIBS) $(GHTTP_LIBS) config: From cf24ac127b7ae1d9566f430abca66e525f7fa1fc Mon Sep 17 00:00:00 2001 From: Ferdi Franceschini Date: Thu, 28 Aug 2014 17:08:30 +1000 Subject: [PATCH 11/68] Update motor configuration from ics1-taipan. --- .../tas/config/motors/motor_configuration.tcl | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/site_ansto/instrument/tas/config/motors/motor_configuration.tcl b/site_ansto/instrument/tas/config/motors/motor_configuration.tcl index 873b9411..1268994e 100644 --- a/site_ansto/instrument/tas/config/motors/motor_configuration.tcl +++ b/site_ansto/instrument/tas/config/motors/motor_configuration.tcl @@ -246,7 +246,7 @@ m2 softupperlim 80 m2 home 20 m2 motOnDelay 0 m2 motOffDelay 0 -m2 backlash_offset 0.1 +m2 backlash_offset -0.1 m2 creep_offset 0.1 m2 creep_precision 0.005 m2 speed 0.4 @@ -533,7 +533,7 @@ Motor mhfocus $motor_driver_type [params \ maxSpeed 3.6\ maxAccel 1.728\ maxDecel 1.728\ - stepsPerX [expr 25000.0 * 50.0 / 360.0]\ + stepsPerX [expr -25000.0 * 50.0 / 360.0]\ absEnc 1\ bias_bits 12\ bias_bias 1540\ @@ -563,14 +563,14 @@ Motor m1 $motor_driver_type [params \ maxDecel 0.25\ stepsPerX 100000\ absEnc 1\ - absEncHome 16323070\ + absEncHome 16189898\ cntsPerX -2048] m1 part crystal m1 long_name m1 m1 softlowerlim 5 m1 softupperlim 40 -m1 home 20.45933 -m1 backlash_offset 0.1 +m1 home 0 +m1 backlash_offset -1.0 # mc4: Analyzer Tilt 1 -- Two-theta Angle Motor atilt $motor_driver_type [params \ From 6070706571d51705a25f12d80f1759c8265b2118 Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Tue, 2 Sep 2014 12:00:56 +1000 Subject: [PATCH 12/68] Stanford Research Systems Model SR630 Thermocouple Monitor --- .../environment/temperature/srs_sr630.sct | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 site_ansto/instrument/config/environment/temperature/srs_sr630.sct diff --git a/site_ansto/instrument/config/environment/temperature/srs_sr630.sct b/site_ansto/instrument/config/environment/temperature/srs_sr630.sct new file mode 100644 index 00000000..8c5bb0ec --- /dev/null +++ b/site_ansto/instrument/config/environment/temperature/srs_sr630.sct @@ -0,0 +1,43 @@ +# Stanford Research Systems SR630 Thermocouple Monitor +# vim: ts=8 sts=2 sw=2 expandtab autoindent smartindent +driver stanford_sr630 = { + vendor=StanfordResearchSystems; device=SR630; + protocol=std; + class=environment; + simulation_group = environment_simulation; + + group = { + priv = user; + var id = { + readable = 10; + type = text; + read_function = read_id; + read_command = ""; + } + var senor_01 = { + readable = 10; + type = float; + read_function = readSensor; + read_command = "1"; + } + var senor_02 = { + readable = 10; + type = float; + fetch_function = getSensor; + read_function = readSensor; + read_command = "2"; + } + } + code read_id = { + @TCL + @END + } + code getSensor = { + @TCL + @END + } + code readSensor = { + @TCL + @END + } +} From 8af9116667c03df972bb87a092c1f7adada7ba80 Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Wed, 3 Sep 2014 13:01:35 +1000 Subject: [PATCH 13/68] Update the Stanford SR630 SCT file for ten channels --- .../temperature/sct_stanford_sr630.tcl | 473 ++++++++++++++++++ .../environment/temperature/srs_sr630.sct | 46 +- 2 files changed, 502 insertions(+), 17 deletions(-) create mode 100644 site_ansto/instrument/config/environment/temperature/sct_stanford_sr630.tcl diff --git a/site_ansto/instrument/config/environment/temperature/sct_stanford_sr630.tcl b/site_ansto/instrument/config/environment/temperature/sct_stanford_sr630.tcl new file mode 100644 index 00000000..b27d9820 --- /dev/null +++ b/site_ansto/instrument/config/environment/temperature/sct_stanford_sr630.tcl @@ -0,0 +1,473 @@ +# Generated driver for stanford_sr630 +# vim: ft=tcl tabstop=8 softtabstop=2 shiftwidth=2 nocindent smartindent +# + +namespace eval ::scobj::stanford_sr630 { + set debug_threshold 5 +} + +proc ::scobj::stanford_sr630::debug_log {tc_root debug_level debug_string} { + set catch_status [ catch { + set debug_threshold [hgetpropval ${tc_root} debug_threshold] + if {${debug_level} >= ${debug_threshold}} { + set fd [open "../log/stanford_sr630_[basename ${tc_root}].log" "a"] + set line "[clock format [clock seconds] -format "%T"] ${debug_string}" + puts ${fd} "${line}" + close ${fd} + } + } catch_message ] +} + +proc ::scobj::stanford_sr630::sics_log {debug_level debug_string} { + set catch_status [ catch { + set debug_threshold ${::scobj::stanford_sr630::debug_threshold} + if {${debug_level} >= ${debug_threshold}} { + sicslog "::scobj::stanford_sr630::${debug_string}" + } + } catch_message ] +} + +# check function for hset change +proc ::scobj::stanford_sr630::checkrange {tc_root} { + set catch_status [ catch { + debug_log ${tc_root} 1 "checkrange tc_root=${tc_root} sct=[sct] target=[sct target]" + set setpoint [sct target] + if { [hpropexists [sct] lowerlimit] } { + set lolimit [sct lowerlimit] + } else { + # lowerlimit not set, use target + set lolimit [sct target] + } + if { [hpropexists [sct] upperlimit] } { + set hilimit [sct upperlimit] + } else { + # upperlimit not set, use target + set hilimit [sct target] + } +# checkrange hook code goes here + if { ${setpoint} < ${lolimit} || ${setpoint} > ${hilimit} } { + error "setpoint ${setpoint} violates limits (${lolimit}..${hilimit}) on [sct]" + } + return OK + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +# function to request the read of a parameter on a device +proc ::scobj::stanford_sr630::fetch_id {tc_root nextState cmd_str} { + set catch_status [ catch { + debug_log ${tc_root} 1 "fetch_id tc_root=${tc_root} sct=[sct] cmd=${cmd_str}" + if { [hpropexists [sct] geterror] } { + hdelprop [sct] geterror + } + set cmd "${cmd_str}" +# fetch_id hook code starts + if {[hval [sct]] == "UNKNOWN"} { + set cmd "[clock format [clock seconds] -format "DATE %m,%d,%Y;TIME %H,%M,%S;*IDN?"]" + } else { + set cmd "*IDN?;DATE?;TIME?" + } +# fetch_id hook code ends + if { [hpropexists [sct] geterror] } { + debug_log ${tc_root} 9 "[sct] error: [sct geterror]" + error "[sct geterror]" + } + debug_log ${tc_root} 1 "fetch_id sct send ${cmd}" + if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} { + sct send "${cmd}" + } + return ${nextState} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +# function to request the read of a parameter on a device +proc ::scobj::stanford_sr630::getSensor {tc_root nextState cmd_str} { + set catch_status [ catch { + debug_log ${tc_root} 1 "getSensor tc_root=${tc_root} sct=[sct] cmd=${cmd_str}" + if { [hpropexists [sct] geterror] } { + hdelprop [sct] geterror + } + set cmd "${cmd_str}" +# getSensor hook code starts + set cmd "UNIT ${cmd_str},ABS;MEAS? ${cmd_str}" +# getSensor hook code ends + if { [hpropexists [sct] geterror] } { + debug_log ${tc_root} 9 "[sct] error: [sct geterror]" + error "[sct geterror]" + } + debug_log ${tc_root} 1 "getSensor sct send ${cmd}" + if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} { + sct send "${cmd}" + } + return ${nextState} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +# function to check the write parameter on a device +proc ::scobj::stanford_sr630::noResponse {tc_root} { + set catch_status [ catch { + debug_log ${tc_root} 1 "noResponse tc_root=${tc_root} sct=[sct] resp=[sct result]" +# noResponse hook code goes here + return "idle" + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +# function to parse the read of a parameter on a device +proc ::scobj::stanford_sr630::readSensor {tc_root} { + set catch_status [ catch { + debug_log ${tc_root} 1 "readSensor tc_root=${tc_root} sct=[sct] result=[sct result]" + if { [hpropexists [sct] geterror] } { + hdelprop [sct] geterror + } + set data [sct result] + set nextState "idle" + if {[string equal -nocase -length 7 ${data} "ASCERR:"]} { + # the protocol driver has reported an error + sct geterror "${data}" + error "[sct geterror]" + } +# readSensor hook code goes here + if { ${data} != [sct oldval] } { + debug_log ${tc_root} 1 "[sct] changed to new:${data}, from old:[sct oldval]" + sct oldval ${data} + sct update ${data} + sct utime readtime + } + return ${nextState} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +# function to parse the read of a parameter on a device +proc ::scobj::stanford_sr630::read_id {tc_root} { + set catch_status [ catch { + debug_log ${tc_root} 1 "read_id tc_root=${tc_root} sct=[sct] result=[sct result]" + if { [hpropexists [sct] geterror] } { + hdelprop [sct] geterror + } + set data [sct result] + set nextState "idle" + if {[string equal -nocase -length 7 ${data} "ASCERR:"]} { + # the protocol driver has reported an error + sct geterror "${data}" + error "[sct geterror]" + } +# read_id hook code goes here + if { ${data} != [sct oldval] } { + debug_log ${tc_root} 1 "[sct] changed to new:${data}, from old:[sct oldval]" + sct oldval ${data} + sct update ${data} + sct utime readtime + } + return ${nextState} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +# function to write a parameter value on a device +proc ::scobj::stanford_sr630::setValue {tc_root nextState cmd_str} { + set catch_status [ catch { + debug_log ${tc_root} 1 "setValue tc_root=${tc_root} sct=[sct] cmd=${cmd_str}" + if { [hpropexists [sct] geterror] } { + hdelprop [sct] geterror + } + set par [sct target] + set cmd "${cmd_str}${par}" +# setValue hook code goes here + if { [hpropexists [sct] driving] } { + if { [hpropexists [sct] writestatus] && [sct writestatus] == "start" } { + sct driving 1 + } + } + debug_log ${tc_root} 1 "setValue sct send ${cmd}" + if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} { + sct send "${cmd}" + } + return ${nextState} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +proc ::scobj::stanford_sr630::mkDriver { sct_controller name ip_address tcp_port } { + ::scobj::stanford_sr630::sics_log 9 "::scobj::stanford_sr630::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port}" + set ns "[namespace current]" + set catch_status [ catch { + + MakeSICSObj ${name} SCT_OBJECT + + sicslist setatt ${name} klass environment + sicslist setatt ${name} long_name ${name} + + set scobj_hpath /sics/${name} + + hfactory ${scobj_hpath}/id plain user text + hsetprop ${scobj_hpath}/id read ${ns}::fetch_id ${scobj_hpath} read_id {@} + hsetprop ${scobj_hpath}/id read_id ${ns}::read_id ${scobj_hpath} + hsetprop ${scobj_hpath}/id control true + hsetprop ${scobj_hpath}/id data true + hsetprop ${scobj_hpath}/id mutable true + hsetprop ${scobj_hpath}/id nxsave true + hsetprop ${scobj_hpath}/id oldval UNKNOWN + hset ${scobj_hpath}/id UNKNOWN + hsetprop ${scobj_hpath}/id klass "parameter" + hsetprop ${scobj_hpath}/id sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/id type "part" + hsetprop ${scobj_hpath}/id nxalias "${name}_id" + + hfactory ${scobj_hpath}/sensor_01 plain user float + hsetprop ${scobj_hpath}/sensor_01 read ${ns}::getSensor ${scobj_hpath} readSensor {1} + hsetprop ${scobj_hpath}/sensor_01 readSensor ${ns}::readSensor ${scobj_hpath} + hsetprop ${scobj_hpath}/sensor_01 control true + hsetprop ${scobj_hpath}/sensor_01 data true + hsetprop ${scobj_hpath}/sensor_01 mutable true + hsetprop ${scobj_hpath}/sensor_01 nxsave true + hsetprop ${scobj_hpath}/sensor_01 oldval 0.0 + hsetprop ${scobj_hpath}/sensor_01 klass "parameter" + hsetprop ${scobj_hpath}/sensor_01 sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/sensor_01 type "part" + hsetprop ${scobj_hpath}/sensor_01 nxalias "${name}_sensor_01" + + hfactory ${scobj_hpath}/sensor_02 plain user float + hsetprop ${scobj_hpath}/sensor_02 read ${ns}::getSensor ${scobj_hpath} readSensor {2} + hsetprop ${scobj_hpath}/sensor_02 readSensor ${ns}::readSensor ${scobj_hpath} + hsetprop ${scobj_hpath}/sensor_02 control true + hsetprop ${scobj_hpath}/sensor_02 data true + hsetprop ${scobj_hpath}/sensor_02 mutable true + hsetprop ${scobj_hpath}/sensor_02 nxsave true + hsetprop ${scobj_hpath}/sensor_02 oldval 0.0 + hsetprop ${scobj_hpath}/sensor_02 klass "parameter" + hsetprop ${scobj_hpath}/sensor_02 sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/sensor_02 type "part" + hsetprop ${scobj_hpath}/sensor_02 nxalias "${name}_sensor_02" + + hfactory ${scobj_hpath}/sensor_03 plain user float + hsetprop ${scobj_hpath}/sensor_03 read ${ns}::getSensor ${scobj_hpath} readSensor {3} + hsetprop ${scobj_hpath}/sensor_03 readSensor ${ns}::readSensor ${scobj_hpath} + hsetprop ${scobj_hpath}/sensor_03 control true + hsetprop ${scobj_hpath}/sensor_03 data true + hsetprop ${scobj_hpath}/sensor_03 mutable true + hsetprop ${scobj_hpath}/sensor_03 nxsave true + hsetprop ${scobj_hpath}/sensor_03 oldval 0.0 + hsetprop ${scobj_hpath}/sensor_03 klass "parameter" + hsetprop ${scobj_hpath}/sensor_03 sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/sensor_03 type "part" + hsetprop ${scobj_hpath}/sensor_03 nxalias "${name}_sensor_03" + + hfactory ${scobj_hpath}/sensor_04 plain user float + hsetprop ${scobj_hpath}/sensor_04 read ${ns}::getSensor ${scobj_hpath} readSensor {4} + hsetprop ${scobj_hpath}/sensor_04 readSensor ${ns}::readSensor ${scobj_hpath} + hsetprop ${scobj_hpath}/sensor_04 control true + hsetprop ${scobj_hpath}/sensor_04 data true + hsetprop ${scobj_hpath}/sensor_04 mutable true + hsetprop ${scobj_hpath}/sensor_04 nxsave true + hsetprop ${scobj_hpath}/sensor_04 oldval 0.0 + hsetprop ${scobj_hpath}/sensor_04 klass "parameter" + hsetprop ${scobj_hpath}/sensor_04 sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/sensor_04 type "part" + hsetprop ${scobj_hpath}/sensor_04 nxalias "${name}_sensor_04" + + hfactory ${scobj_hpath}/sensor_05 plain user float + hsetprop ${scobj_hpath}/sensor_05 read ${ns}::getSensor ${scobj_hpath} readSensor {5} + hsetprop ${scobj_hpath}/sensor_05 readSensor ${ns}::readSensor ${scobj_hpath} + hsetprop ${scobj_hpath}/sensor_05 control true + hsetprop ${scobj_hpath}/sensor_05 data true + hsetprop ${scobj_hpath}/sensor_05 mutable true + hsetprop ${scobj_hpath}/sensor_05 nxsave true + hsetprop ${scobj_hpath}/sensor_05 oldval 0.0 + hsetprop ${scobj_hpath}/sensor_05 klass "parameter" + hsetprop ${scobj_hpath}/sensor_05 sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/sensor_05 type "part" + hsetprop ${scobj_hpath}/sensor_05 nxalias "${name}_sensor_05" + + hfactory ${scobj_hpath}/sensor_06 plain user float + hsetprop ${scobj_hpath}/sensor_06 read ${ns}::getSensor ${scobj_hpath} readSensor {6} + hsetprop ${scobj_hpath}/sensor_06 readSensor ${ns}::readSensor ${scobj_hpath} + hsetprop ${scobj_hpath}/sensor_06 control true + hsetprop ${scobj_hpath}/sensor_06 data true + hsetprop ${scobj_hpath}/sensor_06 mutable true + hsetprop ${scobj_hpath}/sensor_06 nxsave true + hsetprop ${scobj_hpath}/sensor_06 oldval 0.0 + hsetprop ${scobj_hpath}/sensor_06 klass "parameter" + hsetprop ${scobj_hpath}/sensor_06 sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/sensor_06 type "part" + hsetprop ${scobj_hpath}/sensor_06 nxalias "${name}_sensor_06" + + hfactory ${scobj_hpath}/sensor_07 plain user float + hsetprop ${scobj_hpath}/sensor_07 read ${ns}::getSensor ${scobj_hpath} readSensor {7} + hsetprop ${scobj_hpath}/sensor_07 readSensor ${ns}::readSensor ${scobj_hpath} + hsetprop ${scobj_hpath}/sensor_07 control true + hsetprop ${scobj_hpath}/sensor_07 data true + hsetprop ${scobj_hpath}/sensor_07 mutable true + hsetprop ${scobj_hpath}/sensor_07 nxsave true + hsetprop ${scobj_hpath}/sensor_07 oldval 0.0 + hsetprop ${scobj_hpath}/sensor_07 klass "parameter" + hsetprop ${scobj_hpath}/sensor_07 sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/sensor_07 type "part" + hsetprop ${scobj_hpath}/sensor_07 nxalias "${name}_sensor_07" + + hfactory ${scobj_hpath}/sensor_08 plain user float + hsetprop ${scobj_hpath}/sensor_08 read ${ns}::getSensor ${scobj_hpath} readSensor {8} + hsetprop ${scobj_hpath}/sensor_08 readSensor ${ns}::readSensor ${scobj_hpath} + hsetprop ${scobj_hpath}/sensor_08 control true + hsetprop ${scobj_hpath}/sensor_08 data true + hsetprop ${scobj_hpath}/sensor_08 mutable true + hsetprop ${scobj_hpath}/sensor_08 nxsave true + hsetprop ${scobj_hpath}/sensor_08 oldval 0.0 + hsetprop ${scobj_hpath}/sensor_08 klass "parameter" + hsetprop ${scobj_hpath}/sensor_08 sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/sensor_08 type "part" + hsetprop ${scobj_hpath}/sensor_08 nxalias "${name}_sensor_08" + + hfactory ${scobj_hpath}/sensor_09 plain user float + hsetprop ${scobj_hpath}/sensor_09 read ${ns}::getSensor ${scobj_hpath} readSensor {9} + hsetprop ${scobj_hpath}/sensor_09 readSensor ${ns}::readSensor ${scobj_hpath} + hsetprop ${scobj_hpath}/sensor_09 control true + hsetprop ${scobj_hpath}/sensor_09 data true + hsetprop ${scobj_hpath}/sensor_09 mutable true + hsetprop ${scobj_hpath}/sensor_09 nxsave true + hsetprop ${scobj_hpath}/sensor_09 oldval 0.0 + hsetprop ${scobj_hpath}/sensor_09 klass "parameter" + hsetprop ${scobj_hpath}/sensor_09 sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/sensor_09 type "part" + hsetprop ${scobj_hpath}/sensor_09 nxalias "${name}_sensor_09" + + hfactory ${scobj_hpath}/sensor_10 plain user float + hsetprop ${scobj_hpath}/sensor_10 read ${ns}::getSensor ${scobj_hpath} readSensor {10} + hsetprop ${scobj_hpath}/sensor_10 readSensor ${ns}::readSensor ${scobj_hpath} + hsetprop ${scobj_hpath}/sensor_10 control true + hsetprop ${scobj_hpath}/sensor_10 data true + hsetprop ${scobj_hpath}/sensor_10 mutable true + hsetprop ${scobj_hpath}/sensor_10 nxsave true + hsetprop ${scobj_hpath}/sensor_10 oldval 0.0 + hsetprop ${scobj_hpath}/sensor_10 klass "parameter" + hsetprop ${scobj_hpath}/sensor_10 sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/sensor_10 type "part" + hsetprop ${scobj_hpath}/sensor_10 nxalias "${name}_sensor_10" + + hsetprop ${scobj_hpath} data "true" + hsetprop ${scobj_hpath} klass "@none" + hsetprop ${scobj_hpath} type "part" + + if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + ${sct_controller} poll ${scobj_hpath}/id 10 + ${sct_controller} poll ${scobj_hpath}/sensor_01 1 + ${sct_controller} poll ${scobj_hpath}/sensor_02 60 + ${sct_controller} poll ${scobj_hpath}/sensor_03 60 + ${sct_controller} poll ${scobj_hpath}/sensor_04 60 + ${sct_controller} poll ${scobj_hpath}/sensor_05 60 + ${sct_controller} poll ${scobj_hpath}/sensor_06 60 + ${sct_controller} poll ${scobj_hpath}/sensor_07 60 + ${sct_controller} poll ${scobj_hpath}/sensor_08 60 + ${sct_controller} poll ${scobj_hpath}/sensor_09 60 + ${sct_controller} poll ${scobj_hpath}/sensor_10 60 + } else { + ::scobj::stanford_sr630::sics_log 9 "[environment_simulation] => No poll/write for stanford_sr630" + } + hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} data true + hsetprop ${scobj_hpath} debug_threshold 5 +# mkDriver hook code goes here + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +namespace eval ::scobj::stanford_sr630 { + namespace export debug_threshold + namespace export debug_log + namespace export sics_log + namespace export mkDriver +} + +proc add_stanford_sr630 {name ip_address tcp_port} { + set catch_status [ catch { + ::scobj::stanford_sr630::sics_log 9 "add_stanford_sr630 ${name} ${ip_address} ${tcp_port}" + if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "aqadapter" "${ip_address}"]} { + ::scobj::stanford_sr630::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" + makesctcontroller sct_${name} aqadapter ${tcp_port} + } else { + ::scobj::stanford_sr630::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}" + makesctcontroller sct_${name} std ${ip_address}:${tcp_port} + } + } else { + ::scobj::stanford_sr630::sics_log 9 "[environment_simulation] => No sctcontroller for stanford_sr630" + } + ::scobj::stanford_sr630::sics_log 1 "::scobj::stanford_sr630::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port}" + ::scobj::stanford_sr630::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +clientput "file evaluation of sct_stanford_sr630.tcl" +::scobj::stanford_sr630::sics_log 9 "file evaluation of sct_stanford_sr630.tcl" + +proc ::scobj::stanford_sr630::read_config {} { + set catch_status [ catch { + set ns "::scobj::stanford_sr630" + dict for {k u} $::config_dict { + if { [dict exists $u "implementation"] } { + if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { + continue + } + set enabled [string tolower [dict get $u "enabled"]] + if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { + continue + } + set name [dict get $u name] + set implementation [dict get $u "implementation"] + if { !([dict exists $::config_dict $implementation]) } { + continue + } + set v [dict get $::config_dict $implementation] + if { !([dict exists $v "driver"]) } { + continue + } + if { [string equal -nocase [dict get $v "driver"] "stanford_sr630"] } { + if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + set asyncqueue "null" + ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + } elseif { [dict exists $v "asyncqueue"] } { + set asyncqueue [dict get $v "asyncqueue"] + if { [string equal -nocase ${asyncqueue} "sct"] } { + set ip_address [dict get $v ip] + set tcp_port [dict get $v port] + } + } else { + if { [dict exists $v "asyncprotocol"] } { + set asyncprotocol [dict get $v "asyncprotocol"] + } else { + set asyncprotocol ${name}_protocol + MakeAsyncProtocol ${asyncprotocol} + if { [dict exists $v "terminator"] } { + ${asyncprotocol} sendterminator "[dict get $v "terminator"]" + ${asyncprotocol} replyterminator "[dict get $v "terminator"]" + } + } + set asyncqueue ${name}_queue + set ip_address [dict get $v ip] + set tcp_port [dict get $v port] + MakeAsyncQueue ${asyncqueue} ${asyncprotocol} ${ip_address} ${tcp_port} + if { [dict exists $v "timeout"] } { + ${asyncqueue} timeout "[dict get $v "timeout"]" + } + } + if { [string equal -nocase ${asyncqueue} "sct"] } { + add_stanford_sr630 ${name} ${ip_address} ${tcp_port} + } else { + add_stanford_sr630 ${name} "aqadapter" ${asyncqueue} + } + } + } + } + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +if { [info exists ::config_dict] } { + ::scobj::stanford_sr630::read_config +} else { + ::scobj::stanford_sr630::sics_log 5 "No config dict" +} diff --git a/site_ansto/instrument/config/environment/temperature/srs_sr630.sct b/site_ansto/instrument/config/environment/temperature/srs_sr630.sct index 8c5bb0ec..0cb68d30 100644 --- a/site_ansto/instrument/config/environment/temperature/srs_sr630.sct +++ b/site_ansto/instrument/config/environment/temperature/srs_sr630.sct @@ -1,9 +1,9 @@ # Stanford Research Systems SR630 Thermocouple Monitor -# vim: ts=8 sts=2 sw=2 expandtab autoindent smartindent +# vim: ts=8 sts=2 sw=2 expandtab nocindent autoindent smartindent driver stanford_sr630 = { - vendor=StanfordResearchSystems; device=SR630; - protocol=std; - class=environment; + vendor = StanfordResearchSystems; device=SR630; + protocol = std; + class = environment; simulation_group = environment_simulation; group = { @@ -11,22 +11,33 @@ driver stanford_sr630 = { var id = { readable = 10; type = text; + fetch_function = fetch_id; read_function = read_id; - read_command = ""; + read_command = "@"; + value = "UNKNOWN"; } - var senor_01 = { - readable = 10; - type = float; - read_function = readSensor; - read_command = "1"; - } - var senor_02 = { - readable = 10; - type = float; - fetch_function = getSensor; - read_function = readSensor; - read_command = "2"; + type = float; + fetch_function = getSensor; + read_function = readSensor; + var sensor_01 = { readable = 1; read_command = "1"; } + var sensor_02 = { readable = 60; read_command = "2"; } + var sensor_03 = { readable = 60; read_command = "3"; } + var sensor_04 = { readable = 60; read_command = "4"; } + var sensor_05 = { readable = 60; read_command = "5"; } + var sensor_06 = { readable = 60; read_command = "6"; } + var sensor_07 = { readable = 60; read_command = "7"; } + var sensor_08 = { readable = 60; read_command = "8"; } + var sensor_09 = { readable = 60; read_command = "9"; } + var sensor_10 = { readable = 60; read_command = "10"; } + } + code fetch_id = { + @TCL + if {[hval [sct]] == "UNKNOWN"} { + set cmd "[clock format [clock seconds] -format "DATE %m,%d,%Y;TIME %H,%M,%S;*IDN?"]" + } else { + set cmd "*IDN?;DATE?;TIME?" } + @END } code read_id = { @TCL @@ -34,6 +45,7 @@ driver stanford_sr630 = { } code getSensor = { @TCL + set cmd "UNIT ${cmd_str},ABS;MEAS? ${cmd_str}" @END } code readSensor = { From 24c87924671c4a8bfa74a7c930e22a765214a40c Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Thu, 4 Sep 2014 09:26:03 +1000 Subject: [PATCH 14/68] SR630 reduce to 8 channels and 600 second polls, change driver name --- ...t_stanford_sr630.tcl => sct_srs_sr630.tcl} | 116 +++++++----------- .../environment/temperature/srs_sr630.sct | 48 +++----- 2 files changed, 63 insertions(+), 101 deletions(-) rename site_ansto/instrument/config/environment/temperature/{sct_stanford_sr630.tcl => sct_srs_sr630.tcl} (77%) diff --git a/site_ansto/instrument/config/environment/temperature/sct_stanford_sr630.tcl b/site_ansto/instrument/config/environment/temperature/sct_srs_sr630.tcl similarity index 77% rename from site_ansto/instrument/config/environment/temperature/sct_stanford_sr630.tcl rename to site_ansto/instrument/config/environment/temperature/sct_srs_sr630.tcl index b27d9820..d3511719 100644 --- a/site_ansto/instrument/config/environment/temperature/sct_stanford_sr630.tcl +++ b/site_ansto/instrument/config/environment/temperature/sct_srs_sr630.tcl @@ -1,16 +1,16 @@ -# Generated driver for stanford_sr630 +# Generated driver for srs_sr630 # vim: ft=tcl tabstop=8 softtabstop=2 shiftwidth=2 nocindent smartindent # -namespace eval ::scobj::stanford_sr630 { +namespace eval ::scobj::srs_sr630 { set debug_threshold 5 } -proc ::scobj::stanford_sr630::debug_log {tc_root debug_level debug_string} { +proc ::scobj::srs_sr630::debug_log {tc_root debug_level debug_string} { set catch_status [ catch { set debug_threshold [hgetpropval ${tc_root} debug_threshold] if {${debug_level} >= ${debug_threshold}} { - set fd [open "../log/stanford_sr630_[basename ${tc_root}].log" "a"] + set fd [open "../log/srs_sr630_[basename ${tc_root}].log" "a"] set line "[clock format [clock seconds] -format "%T"] ${debug_string}" puts ${fd} "${line}" close ${fd} @@ -18,17 +18,17 @@ proc ::scobj::stanford_sr630::debug_log {tc_root debug_level debug_string} { } catch_message ] } -proc ::scobj::stanford_sr630::sics_log {debug_level debug_string} { +proc ::scobj::srs_sr630::sics_log {debug_level debug_string} { set catch_status [ catch { - set debug_threshold ${::scobj::stanford_sr630::debug_threshold} + set debug_threshold ${::scobj::srs_sr630::debug_threshold} if {${debug_level} >= ${debug_threshold}} { - sicslog "::scobj::stanford_sr630::${debug_string}" + sicslog "::scobj::srs_sr630::${debug_string}" } } catch_message ] } # check function for hset change -proc ::scobj::stanford_sr630::checkrange {tc_root} { +proc ::scobj::srs_sr630::checkrange {tc_root} { set catch_status [ catch { debug_log ${tc_root} 1 "checkrange tc_root=${tc_root} sct=[sct] target=[sct target]" set setpoint [sct target] @@ -54,7 +54,7 @@ proc ::scobj::stanford_sr630::checkrange {tc_root} { } # function to request the read of a parameter on a device -proc ::scobj::stanford_sr630::fetch_id {tc_root nextState cmd_str} { +proc ::scobj::srs_sr630::fetch_id {tc_root nextState cmd_str} { set catch_status [ catch { debug_log ${tc_root} 1 "fetch_id tc_root=${tc_root} sct=[sct] cmd=${cmd_str}" if { [hpropexists [sct] geterror] } { @@ -65,7 +65,7 @@ proc ::scobj::stanford_sr630::fetch_id {tc_root nextState cmd_str} { if {[hval [sct]] == "UNKNOWN"} { set cmd "[clock format [clock seconds] -format "DATE %m,%d,%Y;TIME %H,%M,%S;*IDN?"]" } else { - set cmd "*IDN?;DATE?;TIME?" + set cmd "*IDN?" } # fetch_id hook code ends if { [hpropexists [sct] geterror] } { @@ -82,7 +82,7 @@ proc ::scobj::stanford_sr630::fetch_id {tc_root nextState cmd_str} { } # function to request the read of a parameter on a device -proc ::scobj::stanford_sr630::getSensor {tc_root nextState cmd_str} { +proc ::scobj::srs_sr630::getSensor {tc_root nextState cmd_str} { set catch_status [ catch { debug_log ${tc_root} 1 "getSensor tc_root=${tc_root} sct=[sct] cmd=${cmd_str}" if { [hpropexists [sct] geterror] } { @@ -106,7 +106,7 @@ proc ::scobj::stanford_sr630::getSensor {tc_root nextState cmd_str} { } # function to check the write parameter on a device -proc ::scobj::stanford_sr630::noResponse {tc_root} { +proc ::scobj::srs_sr630::noResponse {tc_root} { set catch_status [ catch { debug_log ${tc_root} 1 "noResponse tc_root=${tc_root} sct=[sct] resp=[sct result]" # noResponse hook code goes here @@ -116,7 +116,7 @@ proc ::scobj::stanford_sr630::noResponse {tc_root} { } # function to parse the read of a parameter on a device -proc ::scobj::stanford_sr630::readSensor {tc_root} { +proc ::scobj::srs_sr630::readSensor {tc_root} { set catch_status [ catch { debug_log ${tc_root} 1 "readSensor tc_root=${tc_root} sct=[sct] result=[sct result]" if { [hpropexists [sct] geterror] } { @@ -142,7 +142,7 @@ proc ::scobj::stanford_sr630::readSensor {tc_root} { } # function to parse the read of a parameter on a device -proc ::scobj::stanford_sr630::read_id {tc_root} { +proc ::scobj::srs_sr630::read_id {tc_root} { set catch_status [ catch { debug_log ${tc_root} 1 "read_id tc_root=${tc_root} sct=[sct] result=[sct result]" if { [hpropexists [sct] geterror] } { @@ -168,7 +168,7 @@ proc ::scobj::stanford_sr630::read_id {tc_root} { } # function to write a parameter value on a device -proc ::scobj::stanford_sr630::setValue {tc_root nextState cmd_str} { +proc ::scobj::srs_sr630::setValue {tc_root nextState cmd_str} { set catch_status [ catch { debug_log ${tc_root} 1 "setValue tc_root=${tc_root} sct=[sct] cmd=${cmd_str}" if { [hpropexists [sct] geterror] } { @@ -191,8 +191,8 @@ proc ::scobj::stanford_sr630::setValue {tc_root nextState cmd_str} { handle_exception ${catch_status} ${catch_message} } -proc ::scobj::stanford_sr630::mkDriver { sct_controller name ip_address tcp_port } { - ::scobj::stanford_sr630::sics_log 9 "::scobj::stanford_sr630::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port}" +proc ::scobj::srs_sr630::mkDriver { sct_controller name ip_address tcp_port } { + ::scobj::srs_sr630::sics_log 9 "::scobj::srs_sr630::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port}" set ns "[namespace current]" set catch_status [ catch { @@ -321,50 +321,22 @@ proc ::scobj::stanford_sr630::mkDriver { sct_controller name ip_address tcp_port hsetprop ${scobj_hpath}/sensor_08 type "part" hsetprop ${scobj_hpath}/sensor_08 nxalias "${name}_sensor_08" - hfactory ${scobj_hpath}/sensor_09 plain user float - hsetprop ${scobj_hpath}/sensor_09 read ${ns}::getSensor ${scobj_hpath} readSensor {9} - hsetprop ${scobj_hpath}/sensor_09 readSensor ${ns}::readSensor ${scobj_hpath} - hsetprop ${scobj_hpath}/sensor_09 control true - hsetprop ${scobj_hpath}/sensor_09 data true - hsetprop ${scobj_hpath}/sensor_09 mutable true - hsetprop ${scobj_hpath}/sensor_09 nxsave true - hsetprop ${scobj_hpath}/sensor_09 oldval 0.0 - hsetprop ${scobj_hpath}/sensor_09 klass "parameter" - hsetprop ${scobj_hpath}/sensor_09 sdsinfo "::nexus::scobj::sdsinfo" - hsetprop ${scobj_hpath}/sensor_09 type "part" - hsetprop ${scobj_hpath}/sensor_09 nxalias "${name}_sensor_09" - - hfactory ${scobj_hpath}/sensor_10 plain user float - hsetprop ${scobj_hpath}/sensor_10 read ${ns}::getSensor ${scobj_hpath} readSensor {10} - hsetprop ${scobj_hpath}/sensor_10 readSensor ${ns}::readSensor ${scobj_hpath} - hsetprop ${scobj_hpath}/sensor_10 control true - hsetprop ${scobj_hpath}/sensor_10 data true - hsetprop ${scobj_hpath}/sensor_10 mutable true - hsetprop ${scobj_hpath}/sensor_10 nxsave true - hsetprop ${scobj_hpath}/sensor_10 oldval 0.0 - hsetprop ${scobj_hpath}/sensor_10 klass "parameter" - hsetprop ${scobj_hpath}/sensor_10 sdsinfo "::nexus::scobj::sdsinfo" - hsetprop ${scobj_hpath}/sensor_10 type "part" - hsetprop ${scobj_hpath}/sensor_10 nxalias "${name}_sensor_10" - hsetprop ${scobj_hpath} data "true" hsetprop ${scobj_hpath} klass "@none" hsetprop ${scobj_hpath} type "part" if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { - ${sct_controller} poll ${scobj_hpath}/id 10 - ${sct_controller} poll ${scobj_hpath}/sensor_01 1 - ${sct_controller} poll ${scobj_hpath}/sensor_02 60 - ${sct_controller} poll ${scobj_hpath}/sensor_03 60 - ${sct_controller} poll ${scobj_hpath}/sensor_04 60 - ${sct_controller} poll ${scobj_hpath}/sensor_05 60 - ${sct_controller} poll ${scobj_hpath}/sensor_06 60 - ${sct_controller} poll ${scobj_hpath}/sensor_07 60 - ${sct_controller} poll ${scobj_hpath}/sensor_08 60 - ${sct_controller} poll ${scobj_hpath}/sensor_09 60 - ${sct_controller} poll ${scobj_hpath}/sensor_10 60 + ${sct_controller} poll ${scobj_hpath}/id 5 + ${sct_controller} poll ${scobj_hpath}/sensor_01 60 + ${sct_controller} poll ${scobj_hpath}/sensor_02 5 + ${sct_controller} poll ${scobj_hpath}/sensor_03 5 + ${sct_controller} poll ${scobj_hpath}/sensor_04 5 + ${sct_controller} poll ${scobj_hpath}/sensor_05 5 + ${sct_controller} poll ${scobj_hpath}/sensor_06 5 + ${sct_controller} poll ${scobj_hpath}/sensor_07 5 + ${sct_controller} poll ${scobj_hpath}/sensor_08 5 } else { - ::scobj::stanford_sr630::sics_log 9 "[environment_simulation] => No poll/write for stanford_sr630" + ::scobj::srs_sr630::sics_log 9 "[environment_simulation] => No poll/write for srs_sr630" } hsetprop ${scobj_hpath} klass environment hsetprop ${scobj_hpath} data true @@ -374,39 +346,39 @@ proc ::scobj::stanford_sr630::mkDriver { sct_controller name ip_address tcp_port handle_exception ${catch_status} ${catch_message} } -namespace eval ::scobj::stanford_sr630 { +namespace eval ::scobj::srs_sr630 { namespace export debug_threshold namespace export debug_log namespace export sics_log namespace export mkDriver } -proc add_stanford_sr630 {name ip_address tcp_port} { +proc add_srs_sr630 {name ip_address tcp_port} { set catch_status [ catch { - ::scobj::stanford_sr630::sics_log 9 "add_stanford_sr630 ${name} ${ip_address} ${tcp_port}" + ::scobj::srs_sr630::sics_log 9 "add_srs_sr630 ${name} ${ip_address} ${tcp_port}" if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { if {[string equal -nocase "aqadapter" "${ip_address}"]} { - ::scobj::stanford_sr630::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" + ::scobj::srs_sr630::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" makesctcontroller sct_${name} aqadapter ${tcp_port} } else { - ::scobj::stanford_sr630::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}" + ::scobj::srs_sr630::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}" makesctcontroller sct_${name} std ${ip_address}:${tcp_port} } } else { - ::scobj::stanford_sr630::sics_log 9 "[environment_simulation] => No sctcontroller for stanford_sr630" + ::scobj::srs_sr630::sics_log 9 "[environment_simulation] => No sctcontroller for srs_sr630" } - ::scobj::stanford_sr630::sics_log 1 "::scobj::stanford_sr630::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port}" - ::scobj::stanford_sr630::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} + ::scobj::srs_sr630::sics_log 1 "::scobj::srs_sr630::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port}" + ::scobj::srs_sr630::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} } catch_message ] handle_exception ${catch_status} ${catch_message} } -clientput "file evaluation of sct_stanford_sr630.tcl" -::scobj::stanford_sr630::sics_log 9 "file evaluation of sct_stanford_sr630.tcl" +clientput "file evaluation of sct_srs_sr630.tcl" +::scobj::srs_sr630::sics_log 9 "file evaluation of sct_srs_sr630.tcl" -proc ::scobj::stanford_sr630::read_config {} { +proc ::scobj::srs_sr630::read_config {} { set catch_status [ catch { - set ns "::scobj::stanford_sr630" + set ns "::scobj::srs_sr630" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { @@ -425,7 +397,7 @@ proc ::scobj::stanford_sr630::read_config {} { if { !([dict exists $v "driver"]) } { continue } - if { [string equal -nocase [dict get $v "driver"] "stanford_sr630"] } { + if { [string equal -nocase [dict get $v "driver"] "srs_sr630"] } { if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { set asyncqueue "null" ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" @@ -455,9 +427,9 @@ proc ::scobj::stanford_sr630::read_config {} { } } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_stanford_sr630 ${name} ${ip_address} ${tcp_port} + add_srs_sr630 ${name} ${ip_address} ${tcp_port} } else { - add_stanford_sr630 ${name} "aqadapter" ${asyncqueue} + add_srs_sr630 ${name} "aqadapter" ${asyncqueue} } } } @@ -467,7 +439,7 @@ proc ::scobj::stanford_sr630::read_config {} { } if { [info exists ::config_dict] } { - ::scobj::stanford_sr630::read_config + ::scobj::srs_sr630::read_config } else { - ::scobj::stanford_sr630::sics_log 5 "No config dict" + ::scobj::srs_sr630::sics_log 5 "No config dict" } diff --git a/site_ansto/instrument/config/environment/temperature/srs_sr630.sct b/site_ansto/instrument/config/environment/temperature/srs_sr630.sct index 0cb68d30..ec3c4914 100644 --- a/site_ansto/instrument/config/environment/temperature/srs_sr630.sct +++ b/site_ansto/instrument/config/environment/temperature/srs_sr630.sct @@ -1,6 +1,6 @@ # Stanford Research Systems SR630 Thermocouple Monitor # vim: ts=8 sts=2 sw=2 expandtab nocindent autoindent smartindent -driver stanford_sr630 = { +driver srs_sr630 = { vendor = StanfordResearchSystems; device=SR630; protocol = std; class = environment; @@ -9,7 +9,7 @@ driver stanford_sr630 = { group = { priv = user; var id = { - readable = 10; + readable = 600; type = text; fetch_function = fetch_id; read_function = read_id; @@ -19,37 +19,27 @@ driver stanford_sr630 = { type = float; fetch_function = getSensor; read_function = readSensor; - var sensor_01 = { readable = 1; read_command = "1"; } - var sensor_02 = { readable = 60; read_command = "2"; } - var sensor_03 = { readable = 60; read_command = "3"; } - var sensor_04 = { readable = 60; read_command = "4"; } - var sensor_05 = { readable = 60; read_command = "5"; } - var sensor_06 = { readable = 60; read_command = "6"; } - var sensor_07 = { readable = 60; read_command = "7"; } - var sensor_08 = { readable = 60; read_command = "8"; } - var sensor_09 = { readable = 60; read_command = "9"; } - var sensor_10 = { readable = 60; read_command = "10"; } + var sensor_01 = { readable = 60; read_command = "1"; } + var sensor_02 = { readable = 600; read_command = "2"; } + var sensor_03 = { readable = 600; read_command = "3"; } + var sensor_04 = { readable = 600; read_command = "4"; } + var sensor_05 = { readable = 600; read_command = "5"; } + var sensor_06 = { readable = 600; read_command = "6"; } + var sensor_07 = { readable = 600; read_command = "7"; } + var sensor_08 = { readable = 600; read_command = "8"; } } - code fetch_id = { - @TCL + code fetch_id = {%% if {[hval [sct]] == "UNKNOWN"} { set cmd "[clock format [clock seconds] -format "DATE %m,%d,%Y;TIME %H,%M,%S;*IDN?"]" } else { - set cmd "*IDN?;DATE?;TIME?" + set cmd "*IDN?" } - @END - } - code read_id = { - @TCL - @END - } - code getSensor = { - @TCL + %%} + code read_id = {%% + %%} + code getSensor = {%% set cmd "UNIT ${cmd_str},ABS;MEAS? ${cmd_str}" - @END - } - code readSensor = { - @TCL - @END - } + %%} + code readSensor = {%% + %%} } From ef0c7cc0d52927db1ca263928e6a990188224377 Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Thu, 4 Sep 2014 10:53:07 +1000 Subject: [PATCH 15/68] Extend poll_period to (1,3600) seconds --- site_ansto/instrument/util/gen_sct.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/site_ansto/instrument/util/gen_sct.py b/site_ansto/instrument/util/gen_sct.py index 1f0b6450..4b9c9b70 100755 --- a/site_ansto/instrument/util/gen_sct.py +++ b/site_ansto/instrument/util/gen_sct.py @@ -1370,8 +1370,10 @@ def put_group(MyDriver, MyGroup): nodename = groupname + MyVar['name'] if MyVar['readable'] > 0: poll_period = MyVar['readable'] - if poll_period < 1 or poll_period > 300: - poll_period = 5 + if poll_period < 1: + poll_period = 1 + if poll_period > 3600: + poll_period = 3600 txt += [' ${sct_controller} poll ${scobj_hpath}/%s %s' % (nodename, poll_period)] for var in sorted(MyGroup['Vars']): MyVar = MyGroup['Vars'][var] From 13a0547f5d9146e43160dcc0e2767660d69dead7 Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Fri, 29 Aug 2014 12:34:53 +1000 Subject: [PATCH 16/68] A bit of reformatting and set the ADUlen in the default case --- site_ansto/hardsup/modbus_asyncprotocol.c | 51 ++++++++++++++--------- 1 file changed, 31 insertions(+), 20 deletions(-) diff --git a/site_ansto/hardsup/modbus_asyncprotocol.c b/site_ansto/hardsup/modbus_asyncprotocol.c index 13cdec68..cde567e9 100644 --- a/site_ansto/hardsup/modbus_asyncprotocol.c +++ b/site_ansto/hardsup/modbus_asyncprotocol.c @@ -17,7 +17,7 @@ * data * ETX * BCC -*/ + */ #define PROTOCOL_NAME "MODBUS_AP" #define PROTOCOL_INIT MODBUSInitProtocol #define ADUSIZE 17 @@ -44,7 +44,17 @@ struct cmdPar { double MBdata[2000]; }; -enum MBFCODES { RdCoil=1, RdInp=2, RdHldReg=3, RdInpReg=4, WrCoil=5, WrReg=6, WrMCoils=15, WrMRegs=16 }; +enum MBFCODES { + RdCoil=1, /* Read Coil - single output bit */ + RdInp=2, /* Read Input - single input bit */ + RdHldReg=3, /* Read Holding Register */ + RdInpReg=4, /* Read Input Register */ + WrCoil=5, /* Write Coil - force output bit */ + WrReg=6, /* Write Register */ + WrLoop=8, /* Write Loopback */ + WrMCoils=15, /* Write Multiple Coils */ + WrMRegs=16 /* Write Multiple Registers */ +}; typedef struct modbus_private_t Private, *pPrivate; struct modbus_private_t { @@ -143,8 +153,8 @@ static double ieee2double(unsigned char ieee[4]) { int exponent, bias = 127; mantissa = ((ieee[1] << 16) & 0x7F0000) - | ((ieee[2] << 8) & 0xFF00) - | ((ieee[3] ) & 0xFF); + | ((ieee[2] << 8) & 0xFF00) + | ((ieee[3] ) & 0xFF); exponent = (ieee[0] & 0x7F) * 2 + ((ieee[1] >> 7) & 1); /* raw exponent */ if (exponent == 255) { @@ -171,8 +181,8 @@ static double ieee2double(unsigned char ieee[4]) { /*-------------------------------------------------------------------------*/ /** @brief Parse a command string of the form "MBAddr:Fcode:SAddr:Dtype:MBdata" -Dtype U16, U32, F32 with optional byte order array eg U32[3,2,1,0] -*/ + Dtype U16, U32, F32 with optional byte order array eg U32[3,2,1,0] + */ static void parseCmd(char *cmdLine, struct cmdPar *MBC, int *BO) { int len; unsigned int i; @@ -213,11 +223,11 @@ static void parseCmd(char *cmdLine, struct cmdPar *MBC, int *BO) { } switch (MBC->Fcode) { case RdCoil: - /* Coils are numbered from 1 but addressed from 0 */ + /* Coils are numbered from 1 but addressed from 0 */ MBC->SAddr--; MBC->NumBytes = MBC->NumVal; MBC->NumRd = MBC->NumVal; - break; + break; case WrCoil: MBC->SAddr--; dVal = strtod(cmdLine, &nextPar); @@ -228,7 +238,7 @@ static void parseCmd(char *cmdLine, struct cmdPar *MBC, int *BO) { } else { /* TODO ERROR */ } - break; + break; case RdHldReg: if (MBC->Dtype == F32 || MBC->Dtype == U32) { MBC->NumRd = MBC->NumVal * 2; @@ -237,7 +247,7 @@ static void parseCmd(char *cmdLine, struct cmdPar *MBC, int *BO) { } else { /* TODO ERROR */ } - break; + break; case WrMRegs: for (i=0; i < MBC->NumVal; i++) { MBC->MBdata[i] = strtod(cmdLine, &nextPar); @@ -250,7 +260,7 @@ static void parseCmd(char *cmdLine, struct cmdPar *MBC, int *BO) { MBC->NumWr = MBC->NumVal; MBC->NumBytes = MBC->NumVal * 2; } - break; + break; } } @@ -274,20 +284,20 @@ static int ModbusOutput(pPrivate myPriv, pDynString wrBuffer, pDynString send_bu switch (myPriv->MBcmd.Fcode) { case RdCoil: case RdHldReg: - /* TODO Max NumRd = 125 */ + /* TODO Max NumRd = 125 */ ADU[8] = (myPriv->MBcmd.SAddr & 0xFF00) >> 8; ADU[9] = myPriv->MBcmd.SAddr & 0xFF; ADU[10] = (myPriv->MBcmd.NumRd & 0xFF00) >> 8; ADU[11] = myPriv->MBcmd.NumRd & 0xFF; ADUlen = 12; - break; + break; case WrCoil: ADU[8] = (myPriv->MBcmd.SAddr & 0xFF00) >> 8; ADU[9] = myPriv->MBcmd.SAddr & 0xFF; ADU[10] = myPriv->MBcmd.MBdata[0]; ADU[11] = 0; ADUlen = 12; - break; + break; case WrMRegs: ADU[8] = (myPriv->MBcmd.SAddr & 0xFF00) >> 8; ADU[9] = myPriv->MBcmd.SAddr & 0xFF; @@ -300,7 +310,7 @@ static int ModbusOutput(pPrivate myPriv, pDynString wrBuffer, pDynString send_bu ADU[j + myPriv->BO[0]] = ((unsigned int)myPriv->MBcmd.MBdata[i] & 0xFF00) >> 8; ADU[j + myPriv->BO[1]] = (unsigned int)myPriv->MBcmd.MBdata[i] & 0xFF; } - break; + break; case U32: for (i=0, j=13; i < myPriv->MBcmd.NumVal; i++, j+=4) { ADU[j + myPriv->BO[0]] = ((unsigned int)myPriv->MBcmd.MBdata[i] & 0xFF000000) >> 24; @@ -308,7 +318,7 @@ static int ModbusOutput(pPrivate myPriv, pDynString wrBuffer, pDynString send_bu ADU[j + myPriv->BO[2]] = ((unsigned int)myPriv->MBcmd.MBdata[i] & 0xFF00) >> 8; ADU[j + myPriv->BO[3]] = (unsigned int)myPriv->MBcmd.MBdata[i] & 0xFF; } - break; + break; case F32: for (i=0, j=13; i < myPriv->MBcmd.NumVal; i++, j+=4) { double2ieee(myPriv->MBcmd.MBdata[i], ieee); @@ -317,13 +327,14 @@ static int ModbusOutput(pPrivate myPriv, pDynString wrBuffer, pDynString send_bu ADU[j + myPriv->BO[2]] = ieee[2]; ADU[j + myPriv->BO[3]] = ieee[3]; } - break; + break; } ADUlen = 13 + myPriv->MBcmd.NumBytes; - break; + break; default: - // Not Implemented - break; + // Not Implemented + ADUlen = 7; + break; } /* Length field in MBAP includes byte 7 of the MBAP, so Length = ADU length - 6. */ PDUlenPlusUID = ADUlen - 6; From 55a0055bd3d6cbd60a24c90257ca9aa1995ba276 Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Fri, 5 Sep 2014 16:09:36 +1000 Subject: [PATCH 17/68] West 6100 driver --- .../environment/temperature/sct_west_6100.tcl | 581 ++++++++++++++++++ .../environment/temperature/west_6100.sct | 71 +++ 2 files changed, 652 insertions(+) create mode 100644 site_ansto/instrument/config/environment/temperature/sct_west_6100.tcl create mode 100644 site_ansto/instrument/config/environment/temperature/west_6100.sct diff --git a/site_ansto/instrument/config/environment/temperature/sct_west_6100.tcl b/site_ansto/instrument/config/environment/temperature/sct_west_6100.tcl new file mode 100644 index 00000000..5b1bd613 --- /dev/null +++ b/site_ansto/instrument/config/environment/temperature/sct_west_6100.tcl @@ -0,0 +1,581 @@ +# Generated driver for west_6100 +# vim: ft=tcl tabstop=8 softtabstop=2 shiftwidth=2 nocindent smartindent +# + +namespace eval ::scobj::west_6100 { + set debug_threshold 5 +} + +proc ::scobj::west_6100::debug_log {tc_root debug_level debug_string} { + set catch_status [ catch { + set debug_threshold [hgetpropval ${tc_root} debug_threshold] + if {${debug_level} >= ${debug_threshold}} { + set fd [open "../log/west_6100_[basename ${tc_root}].log" "a"] + set line "[clock format [clock seconds] -format "%T"] ${debug_string}" + puts ${fd} "${line}" + close ${fd} + } + } catch_message ] +} + +proc ::scobj::west_6100::sics_log {debug_level debug_string} { + set catch_status [ catch { + set debug_threshold ${::scobj::west_6100::debug_threshold} + if {${debug_level} >= ${debug_threshold}} { + sicslog "::scobj::west_6100::${debug_string}" + } + } catch_message ] +} + +# check function for hset change +proc ::scobj::west_6100::checkrange {tc_root} { + set catch_status [ catch { + debug_log ${tc_root} 1 "checkrange tc_root=${tc_root} sct=[sct] target=[sct target]" + set setpoint [sct target] + if { [hpropexists [sct] lowerlimit] } { + set lolimit [sct lowerlimit] + } else { + # lowerlimit not set, use target + set lolimit [sct target] + } + if { [hpropexists [sct] upperlimit] } { + set hilimit [sct upperlimit] + } else { + # upperlimit not set, use target + set hilimit [sct target] + } +# checkrange hook code goes here + if { ${setpoint} < ${lolimit} || ${setpoint} > ${hilimit} } { + error "setpoint ${setpoint} violates limits (${lolimit}..${hilimit}) on [sct]" + } + return OK + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +# function to request the read of a parameter on a device +proc ::scobj::west_6100::getDecimal {tc_root nextState cmd_str} { + set catch_status [ catch { + debug_log ${tc_root} 1 "getDecimal tc_root=${tc_root} sct=[sct] cmd=${cmd_str}" + if { [hpropexists [sct] geterror] } { + hdelprop [sct] geterror + } + set cmd "${cmd_str}" +# getDecimal hook code starts + set cmd "1:3:${cmd_str}:1:U16" +# getDecimal hook code ends + if { [hpropexists [sct] geterror] } { + debug_log ${tc_root} 9 "[sct] error: [sct geterror]" + error "[sct geterror]" + } + debug_log ${tc_root} 1 "getDecimal sct send ${cmd}" + if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} { + sct send "${cmd}" + } + return ${nextState} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +# function to request the read of a parameter on a device +proc ::scobj::west_6100::getInteger {tc_root nextState cmd_str} { + set catch_status [ catch { + debug_log ${tc_root} 1 "getInteger tc_root=${tc_root} sct=[sct] cmd=${cmd_str}" + if { [hpropexists [sct] geterror] } { + hdelprop [sct] geterror + } + set cmd "${cmd_str}" +# getInteger hook code starts + set cmd "1:3:${cmd_str}:1:U16" +# getInteger hook code ends + if { [hpropexists [sct] geterror] } { + debug_log ${tc_root} 9 "[sct] error: [sct geterror]" + error "[sct geterror]" + } + debug_log ${tc_root} 1 "getInteger sct send ${cmd}" + if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} { + sct send "${cmd}" + } + return ${nextState} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +# function to check the write parameter on a device +proc ::scobj::west_6100::noResponse {tc_root} { + set catch_status [ catch { + debug_log ${tc_root} 1 "noResponse tc_root=${tc_root} sct=[sct] resp=[sct result]" +# noResponse hook code goes here + return "idle" + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +# function to parse the read of a parameter on a device +proc ::scobj::west_6100::rdDecimal {tc_root} { + set catch_status [ catch { + debug_log ${tc_root} 1 "rdDecimal tc_root=${tc_root} sct=[sct] result=[sct result]" + if { [hpropexists [sct] geterror] } { + hdelprop [sct] geterror + } + set data [sct result] + set nextState "idle" + if {[string equal -nocase -length 7 ${data} "ASCERR:"]} { + # the protocol driver has reported an error + sct geterror "${data}" + error "[sct geterror]" + } +# rdDecimal hook code starts + set data [expr {0.10 * ${data}}] +# rdDecimal hook code ends + if { [hpropexists [sct] geterror] } { + debug_log ${tc_root} 9 "[sct] error: [sct geterror]" + error "[sct geterror]" + } + if { ${data} != [sct oldval] } { + debug_log ${tc_root} 1 "[sct] changed to new:${data}, from old:[sct oldval]" + sct oldval ${data} + sct update ${data} + sct utime readtime + } + return ${nextState} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +# function to parse the read of a parameter on a device +proc ::scobj::west_6100::rdInteger {tc_root} { + set catch_status [ catch { + debug_log ${tc_root} 1 "rdInteger tc_root=${tc_root} sct=[sct] result=[sct result]" + if { [hpropexists [sct] geterror] } { + hdelprop [sct] geterror + } + set data [sct result] + set nextState "idle" + if {[string equal -nocase -length 7 ${data} "ASCERR:"]} { + # the protocol driver has reported an error + sct geterror "${data}" + error "[sct geterror]" + } +# rdInteger hook code goes here + if { ${data} != [sct oldval] } { + debug_log ${tc_root} 1 "[sct] changed to new:${data}, from old:[sct oldval]" + sct oldval ${data} + sct update ${data} + sct utime readtime + } + return ${nextState} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +# function to write a parameter value on a device +proc ::scobj::west_6100::setValue {tc_root nextState cmd_str} { + set catch_status [ catch { + debug_log ${tc_root} 1 "setValue tc_root=${tc_root} sct=[sct] cmd=${cmd_str}" + if { [hpropexists [sct] geterror] } { + hdelprop [sct] geterror + } + set par [sct target] + set cmd "${cmd_str}${par}" +# setValue hook code goes here + if { [hpropexists [sct] driving] } { + if { [hpropexists [sct] writestatus] && [sct writestatus] == "start" } { + sct driving 1 + } + } + debug_log ${tc_root} 1 "setValue sct send ${cmd}" + if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} { + sct send "${cmd}" + } + return ${nextState} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +# function to write a parameter value on a device +proc ::scobj::west_6100::wrDecimal {tc_root nextState cmd_str} { + set catch_status [ catch { + debug_log ${tc_root} 1 "wrDecimal tc_root=${tc_root} sct=[sct] cmd=${cmd_str}" + if { [hpropexists [sct] geterror] } { + hdelprop [sct] geterror + } + set par [sct target] + set cmd "${cmd_str}${par}" +# wrDecimal hook code starts + set par [expr {round(10.0 * [sct target])}] + set cmd "1:16:${cmd_str}:1:U16:${par}" +# wrDecimal hook code ends + if { [hpropexists [sct] geterror] } { + debug_log ${tc_root} 9 "[sct] error: [sct geterror]" + error "[sct geterror]" + } + if { [hpropexists [sct] driving] } { + if { [hpropexists [sct] writestatus] && [sct writestatus] == "start" } { + sct driving 1 + } + } + debug_log ${tc_root} 1 "wrDecimal sct send ${cmd}" + if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} { + sct send "${cmd}" + } + return ${nextState} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +# function to write a parameter value on a device +proc ::scobj::west_6100::wrInteger {tc_root nextState cmd_str} { + set catch_status [ catch { + debug_log ${tc_root} 1 "wrInteger tc_root=${tc_root} sct=[sct] cmd=${cmd_str}" + if { [hpropexists [sct] geterror] } { + hdelprop [sct] geterror + } + set par [sct target] + set cmd "${cmd_str}${par}" +# wrInteger hook code starts + set cmd "1:16:${cmd_str}:1:U16:${par}" +# wrInteger hook code ends + if { [hpropexists [sct] geterror] } { + debug_log ${tc_root} 9 "[sct] error: [sct geterror]" + error "[sct geterror]" + } + if { [hpropexists [sct] driving] } { + if { [hpropexists [sct] writestatus] && [sct writestatus] == "start" } { + sct driving 1 + } + } + debug_log ${tc_root} 1 "wrInteger sct send ${cmd}" + if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} { + sct send "${cmd}" + } + return ${nextState} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +proc ::scobj::west_6100::mkDriver { sct_controller name ip_address tcp_port dev_id } { + ::scobj::west_6100::sics_log 9 "::scobj::west_6100::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port} ${dev_id}" + set ns "[namespace current]" + set catch_status [ catch { + + MakeSICSObj ${name} SCT_OBJECT + + sicslist setatt ${name} klass environment + sicslist setatt ${name} long_name ${name} + + set scobj_hpath /sics/${name} + + hfactory ${scobj_hpath}/alarm1 plain user float + hsetprop ${scobj_hpath}/alarm1 read ${ns}::getDecimal ${scobj_hpath} rdDecimal {13} + hsetprop ${scobj_hpath}/alarm1 rdDecimal ${ns}::rdDecimal ${scobj_hpath} + hsetprop ${scobj_hpath}/alarm1 write ${ns}::wrDecimal ${scobj_hpath} noResponse {13} + hsetprop ${scobj_hpath}/alarm1 noResponse ${ns}::noResponse ${scobj_hpath} + hsetprop ${scobj_hpath}/alarm1 check ${ns}::checkrange ${scobj_hpath} + hsetprop ${scobj_hpath}/alarm1 control true + hsetprop ${scobj_hpath}/alarm1 data true + hsetprop ${scobj_hpath}/alarm1 mutable true + hsetprop ${scobj_hpath}/alarm1 nxsave true + hsetprop ${scobj_hpath}/alarm1 oldval 0.0 + hsetprop ${scobj_hpath}/alarm1 klass "parameter" + hsetprop ${scobj_hpath}/alarm1 sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/alarm1 type "part" + hsetprop ${scobj_hpath}/alarm1 nxalias "${name}_alarm1" + + hfactory ${scobj_hpath}/alarm2 plain user float + hsetprop ${scobj_hpath}/alarm2 read ${ns}::getDecimal ${scobj_hpath} rdDecimal {14} + hsetprop ${scobj_hpath}/alarm2 rdDecimal ${ns}::rdDecimal ${scobj_hpath} + hsetprop ${scobj_hpath}/alarm2 write ${ns}::wrDecimal ${scobj_hpath} noResponse {14} + hsetprop ${scobj_hpath}/alarm2 noResponse ${ns}::noResponse ${scobj_hpath} + hsetprop ${scobj_hpath}/alarm2 check ${ns}::checkrange ${scobj_hpath} + hsetprop ${scobj_hpath}/alarm2 control true + hsetprop ${scobj_hpath}/alarm2 data true + hsetprop ${scobj_hpath}/alarm2 mutable true + hsetprop ${scobj_hpath}/alarm2 nxsave true + hsetprop ${scobj_hpath}/alarm2 oldval 0.0 + hsetprop ${scobj_hpath}/alarm2 klass "parameter" + hsetprop ${scobj_hpath}/alarm2 sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/alarm2 type "part" + hsetprop ${scobj_hpath}/alarm2 nxalias "${name}_alarm2" + + hfactory ${scobj_hpath}/power plain user int + hsetprop ${scobj_hpath}/power read ${ns}::getInteger ${scobj_hpath} rdInteger {3} + hsetprop ${scobj_hpath}/power rdInteger ${ns}::rdInteger ${scobj_hpath} + hsetprop ${scobj_hpath}/power control true + hsetprop ${scobj_hpath}/power data true + hsetprop ${scobj_hpath}/power mutable true + hsetprop ${scobj_hpath}/power nxsave true + hsetprop ${scobj_hpath}/power oldval 0 + hsetprop ${scobj_hpath}/power klass "parameter" + hsetprop ${scobj_hpath}/power sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/power type "part" + hsetprop ${scobj_hpath}/power nxalias "${name}_power" + + hfactory ${scobj_hpath}/powermax plain user int + hsetprop ${scobj_hpath}/powermax read ${ns}::getInteger ${scobj_hpath} rdInteger {20} + hsetprop ${scobj_hpath}/powermax rdInteger ${ns}::rdInteger ${scobj_hpath} + hsetprop ${scobj_hpath}/powermax write ${ns}::wrInteger ${scobj_hpath} noResponse {20} + hsetprop ${scobj_hpath}/powermax noResponse ${ns}::noResponse ${scobj_hpath} + hsetprop ${scobj_hpath}/powermax check ${ns}::checkrange ${scobj_hpath} + hsetprop ${scobj_hpath}/powermax control true + hsetprop ${scobj_hpath}/powermax data true + hsetprop ${scobj_hpath}/powermax mutable true + hsetprop ${scobj_hpath}/powermax nxsave true + hsetprop ${scobj_hpath}/powermax oldval 0 + hsetprop ${scobj_hpath}/powermax klass "parameter" + hsetprop ${scobj_hpath}/powermax sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/powermax type "part" + hsetprop ${scobj_hpath}/powermax nxalias "${name}_powermax" + + hfactory ${scobj_hpath}/ramprate plain user float + hsetprop ${scobj_hpath}/ramprate read ${ns}::getDecimal ${scobj_hpath} rdDecimal {24} + hsetprop ${scobj_hpath}/ramprate rdDecimal ${ns}::rdDecimal ${scobj_hpath} + hsetprop ${scobj_hpath}/ramprate write ${ns}::wrDecimal ${scobj_hpath} noResponse {24} + hsetprop ${scobj_hpath}/ramprate noResponse ${ns}::noResponse ${scobj_hpath} + hsetprop ${scobj_hpath}/ramprate check ${ns}::checkrange ${scobj_hpath} + hsetprop ${scobj_hpath}/ramprate control true + hsetprop ${scobj_hpath}/ramprate data true + hsetprop ${scobj_hpath}/ramprate mutable true + hsetprop ${scobj_hpath}/ramprate nxsave true + hsetprop ${scobj_hpath}/ramprate oldval 0.0 + hsetprop ${scobj_hpath}/ramprate klass "parameter" + hsetprop ${scobj_hpath}/ramprate sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/ramprate type "part" + hsetprop ${scobj_hpath}/ramprate nxalias "${name}_ramprate" + + hfactory ${scobj_hpath}/sensor plain user float + hsetprop ${scobj_hpath}/sensor read ${ns}::getDecimal ${scobj_hpath} rdDecimal {1} + hsetprop ${scobj_hpath}/sensor rdDecimal ${ns}::rdDecimal ${scobj_hpath} + hsetprop ${scobj_hpath}/sensor control true + hsetprop ${scobj_hpath}/sensor data true + hsetprop ${scobj_hpath}/sensor mutable true + hsetprop ${scobj_hpath}/sensor nxsave true + hsetprop ${scobj_hpath}/sensor oldval 0.0 + hsetprop ${scobj_hpath}/sensor klass "parameter" + hsetprop ${scobj_hpath}/sensor sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/sensor type "part" + hsetprop ${scobj_hpath}/sensor nxalias "${name}_sensor" + + hfactory ${scobj_hpath}/setpoint plain user float + hsetprop ${scobj_hpath}/setpoint read ${ns}::getDecimal ${scobj_hpath} rdDecimal {2} + hsetprop ${scobj_hpath}/setpoint rdDecimal ${ns}::rdDecimal ${scobj_hpath} + hsetprop ${scobj_hpath}/setpoint write ${ns}::wrDecimal ${scobj_hpath} noResponse {2} + hsetprop ${scobj_hpath}/setpoint noResponse ${ns}::noResponse ${scobj_hpath} + hsetprop ${scobj_hpath}/setpoint check ${ns}::checkrange ${scobj_hpath} + hsetprop ${scobj_hpath}/setpoint control true + hsetprop ${scobj_hpath}/setpoint data true + hsetprop ${scobj_hpath}/setpoint mutable true + hsetprop ${scobj_hpath}/setpoint nxsave true + hsetprop ${scobj_hpath}/setpoint oldval 0.0 + hsetprop ${scobj_hpath}/setpoint klass "parameter" + hsetprop ${scobj_hpath}/setpoint sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/setpoint type "part" + hsetprop ${scobj_hpath}/setpoint nxalias "${name}_setpoint" + + hfactory ${scobj_hpath}/w_sp plain user float + hsetprop ${scobj_hpath}/w_sp read ${ns}::getDecimal ${scobj_hpath} rdDecimal {21} + hsetprop ${scobj_hpath}/w_sp rdDecimal ${ns}::rdDecimal ${scobj_hpath} + hsetprop ${scobj_hpath}/w_sp write ${ns}::wrDecimal ${scobj_hpath} noResponse {21} + hsetprop ${scobj_hpath}/w_sp noResponse ${ns}::noResponse ${scobj_hpath} + hsetprop ${scobj_hpath}/w_sp check ${ns}::checkrange ${scobj_hpath} + hsetprop ${scobj_hpath}/w_sp control true + hsetprop ${scobj_hpath}/w_sp data true + hsetprop ${scobj_hpath}/w_sp mutable true + hsetprop ${scobj_hpath}/w_sp nxsave true + hsetprop ${scobj_hpath}/w_sp oldval 0.0 + hsetprop ${scobj_hpath}/w_sp klass "parameter" + hsetprop ${scobj_hpath}/w_sp sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/w_sp type "part" + hsetprop ${scobj_hpath}/w_sp nxalias "${name}_w_sp" + + hsetprop ${scobj_hpath} data "true" + hsetprop ${scobj_hpath} klass "@none" + hsetprop ${scobj_hpath} type "part" + + if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + ${sct_controller} poll ${scobj_hpath}/alarm1 1 + ${sct_controller} poll ${scobj_hpath}/alarm2 1 + ${sct_controller} poll ${scobj_hpath}/power 1 + ${sct_controller} poll ${scobj_hpath}/powermax 1 + ${sct_controller} poll ${scobj_hpath}/ramprate 1 + ${sct_controller} poll ${scobj_hpath}/sensor 1 + ${sct_controller} poll ${scobj_hpath}/setpoint 1 + ${sct_controller} poll ${scobj_hpath}/w_sp 1 + ${sct_controller} write ${scobj_hpath}/alarm1 + ${sct_controller} write ${scobj_hpath}/alarm2 + ${sct_controller} write ${scobj_hpath}/powermax + ${sct_controller} write ${scobj_hpath}/ramprate + ${sct_controller} write ${scobj_hpath}/setpoint + ${sct_controller} write ${scobj_hpath}/w_sp + } else { + ::scobj::west_6100::sics_log 9 "[environment_simulation] => No poll/write for west_6100" + } + + hfactory ${scobj_hpath}/aux plain spy none + hsetprop ${scobj_hpath}/aux data "false" + hsetprop ${scobj_hpath}/aux klass "@none" + hsetprop ${scobj_hpath}/aux type "part" + + hfactory ${scobj_hpath}/aux/decimal plain user int + hsetprop ${scobj_hpath}/aux/decimal read ${ns}::getInteger ${scobj_hpath} rdInteger {18} + hsetprop ${scobj_hpath}/aux/decimal rdInteger ${ns}::rdInteger ${scobj_hpath} + hsetprop ${scobj_hpath}/aux/decimal control false + hsetprop ${scobj_hpath}/aux/decimal data false + hsetprop ${scobj_hpath}/aux/decimal mutable false + hsetprop ${scobj_hpath}/aux/decimal nxsave false + hsetprop ${scobj_hpath}/aux/decimal oldval 0 + hsetprop ${scobj_hpath}/aux/decimal sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/aux/decimal type "part" + hsetprop ${scobj_hpath}/aux/decimal nxalias "${name}_aux_decimal" + + hfactory ${scobj_hpath}/aux/instatus plain user int + hsetprop ${scobj_hpath}/aux/instatus read ${ns}::getInteger ${scobj_hpath} rdInteger {133} + hsetprop ${scobj_hpath}/aux/instatus rdInteger ${ns}::rdInteger ${scobj_hpath} + hsetprop ${scobj_hpath}/aux/instatus control false + hsetprop ${scobj_hpath}/aux/instatus data false + hsetprop ${scobj_hpath}/aux/instatus mutable false + hsetprop ${scobj_hpath}/aux/instatus nxsave false + hsetprop ${scobj_hpath}/aux/instatus oldval 0 + hsetprop ${scobj_hpath}/aux/instatus sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/aux/instatus type "part" + hsetprop ${scobj_hpath}/aux/instatus nxalias "${name}_aux_instatus" + + hfactory ${scobj_hpath}/aux/model plain user int + hsetprop ${scobj_hpath}/aux/model read ${ns}::getInteger ${scobj_hpath} rdInteger {122} + hsetprop ${scobj_hpath}/aux/model rdInteger ${ns}::rdInteger ${scobj_hpath} + hsetprop ${scobj_hpath}/aux/model control false + hsetprop ${scobj_hpath}/aux/model data false + hsetprop ${scobj_hpath}/aux/model mutable false + hsetprop ${scobj_hpath}/aux/model nxsave false + hsetprop ${scobj_hpath}/aux/model oldval 0 + hsetprop ${scobj_hpath}/aux/model sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/aux/model type "part" + hsetprop ${scobj_hpath}/aux/model nxalias "${name}_aux_model" + + if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + ${sct_controller} poll ${scobj_hpath}/aux/decimal 2 + ${sct_controller} poll ${scobj_hpath}/aux/instatus 2 + ${sct_controller} poll ${scobj_hpath}/aux/model 2 + } else { + ::scobj::west_6100::sics_log 9 "[environment_simulation] => No poll/write for west_6100" + } + hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} data true + hsetprop ${scobj_hpath} debug_threshold 5 +# mkDriver hook code goes here + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +namespace eval ::scobj::west_6100 { + namespace export debug_threshold + namespace export debug_log + namespace export sics_log + namespace export mkDriver +} + +proc add_west_6100 {name ip_address tcp_port dev_id} { + set catch_status [ catch { + ::scobj::west_6100::sics_log 9 "add_west_6100 ${name} ${ip_address} ${tcp_port} ${dev_id}" + if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "aqadapter" "${ip_address}"]} { + ::scobj::west_6100::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" + makesctcontroller sct_${name} aqadapter ${tcp_port} + } else { + ::scobj::west_6100::sics_log 9 "makesctcontroller sct_${name} modbus_ap ${ip_address}:${tcp_port}" + makesctcontroller sct_${name} modbus_ap ${ip_address}:${tcp_port} + } + } else { + ::scobj::west_6100::sics_log 9 "[environment_simulation] => No sctcontroller for west_6100" + } + ::scobj::west_6100::sics_log 1 "::scobj::west_6100::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${dev_id}" + ::scobj::west_6100::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${dev_id} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +clientput "file evaluation of sct_west_6100.tcl" +::scobj::west_6100::sics_log 9 "file evaluation of sct_west_6100.tcl" + +proc ::scobj::west_6100::read_config {} { + set catch_status [ catch { + set ns "::scobj::west_6100" + dict for {k u} $::config_dict { + if { [dict exists $u "implementation"] } { + if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { + continue + } + set enabled [string tolower [dict get $u "enabled"]] + if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { + continue + } + set name [dict get $u name] + set implementation [dict get $u "implementation"] + if { !([dict exists $::config_dict $implementation]) } { + continue + } + set v [dict get $::config_dict $implementation] + if { !([dict exists $v "driver"]) } { + continue + } + if { [string equal -nocase [dict get $v "driver"] "west_6100"] } { + if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + set asyncqueue "null" + ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + } elseif { [dict exists $v "asyncqueue"] } { + set asyncqueue [dict get $v "asyncqueue"] + if { [string equal -nocase ${asyncqueue} "sct"] } { + set ip_address [dict get $v ip] + set tcp_port [dict get $v port] + } + } else { + if { [dict exists $v "asyncprotocol"] } { + set asyncprotocol [dict get $v "asyncprotocol"] + } else { + set asyncprotocol ${name}_protocol + MakeAsyncProtocol ${asyncprotocol} + if { [dict exists $v "terminator"] } { + ${asyncprotocol} sendterminator "[dict get $v "terminator"]" + ${asyncprotocol} replyterminator "[dict get $v "terminator"]" + } + } + set asyncqueue ${name}_queue + set ip_address [dict get $v ip] + set tcp_port [dict get $v port] + MakeAsyncQueue ${asyncqueue} ${asyncprotocol} ${ip_address} ${tcp_port} + if { [dict exists $v "timeout"] } { + ${asyncqueue} timeout "[dict get $v "timeout"]" + } + } + set arg_list [list] + set missing_list [list] + foreach arg {dev_id} { + if {[dict exists $u $arg]} { + lappend arg_list "[dict get $u $arg]" + } elseif {[dict exists $v $arg]} { + lappend arg_list "[dict get $v $arg]" + } else { + ${ns}::sics_log 9 "Missing configuration value $arg" + lappend missing_list $arg + } + } + if { [llength $missing_list] > 0 } { + error "$name is missing configuration values $missing_list" + } + if { [string equal -nocase ${asyncqueue} "sct"] } { + add_west_6100 ${name} ${ip_address} ${tcp_port} {*}$arg_list + } else { + add_west_6100 ${name} "aqadapter" ${asyncqueue} {*}$arg_list + } + } + } + } + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +if { [info exists ::config_dict] } { + ::scobj::west_6100::read_config +} else { + ::scobj::west_6100::sics_log 5 "No config dict" +} diff --git a/site_ansto/instrument/config/environment/temperature/west_6100.sct b/site_ansto/instrument/config/environment/temperature/west_6100.sct new file mode 100644 index 00000000..72ff7050 --- /dev/null +++ b/site_ansto/instrument/config/environment/temperature/west_6100.sct @@ -0,0 +1,71 @@ +# vim: ts=8 sts=2 sw=2 expandtab autoindent smartindent nocindent +driver west_6100 = { + protocol = modbus_ap + class = environment + simulation_group = environment_simulation + add_args = 'dev_id' + make_args = 'dev_id' + Group = { + priv = user; data = true; control = true; mutable = true; + type = float; + readable = 1; + fetch_function = getDecimal; + read_function = rdDecimal; + write_function = wrDecimal; + var sensor = { read_command = "1"; } + var setpoint = { read_command = "2"; write_command = "2"; writeable = 1; } + var w_sp = { read_command = "21"; write_command = "21"; writeable = 1; } + var ramprate = { read_command = "24"; write_command = "24"; writeable = 1; } + var alarm1 = { read_command = "13"; write_command = "13"; writeable = 1; } + var alarm2 = { read_command = "14"; write_command = "14"; writeable = 1; } + type = int; + fetch_function = getInteger; + read_function = rdInteger; + write_function = wrInteger; + var power = { read_command = "3";} + var powermax = { read_command = "20"; write_command = "20"; writeable = 1; } + } + group aux = { + data = false; + control = false; + mutable = false; + readable = 2; + nxsave = false; + fetch_function = getInteger; + read_function = rdInteger; + var model = { type = int; read_command = "122"; } + var decimal = { type = int; read_command = "18"; } + var instatus = { type = int; read_command = "133"; } + } + code fetch_function getInteger = { + @TCL + set cmd "1:3:${cmd_str}:1:U16" + @END + } + code read_function rdInteger = { + @TCL + @END + } + code write_function wrInteger = { + @TCL + set cmd "1:16:${cmd_str}:1:U16:${par}" + @END + } +# Decimal Adjusted fields + code fetch_function getDecimal = { + @TCL + set cmd "1:3:${cmd_str}:1:U16" + @END + } + code read_function rdDecimal = { + @TCL + set data [expr {0.10 * ${data}}] + @END + } + code write_function wrDecimal = { + @TCL + set par [expr {round(10.0 * [sct target])}] + set cmd "1:16:${cmd_str}:1:U16:${par}" + @END + } +} From fb0f746b96deed258356724a859407e843b8f568 Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Fri, 5 Sep 2014 15:29:25 +1000 Subject: [PATCH 18/68] Create a PATCH.TXT with "git diff" and include in the deplopment This allows us to track what the differences are to the git version We also include it into .gitignore. --- .gitignore | 1 + site_ansto/extract_version.sh | 3 +++ site_ansto/instrument/deploySICS.sh | 4 ++++ 3 files changed, 8 insertions(+) diff --git a/.gitignore b/.gitignore index a452371f..49b99919 100644 --- a/.gitignore +++ b/.gitignore @@ -1,5 +1,6 @@ SICServer made_config.h +PATCH.TXT *.aux *.pdf *.sw[op] diff --git a/site_ansto/extract_version.sh b/site_ansto/extract_version.sh index 61f3ca57..d3f257ac 100755 --- a/site_ansto/extract_version.sh +++ b/site_ansto/extract_version.sh @@ -45,6 +45,9 @@ else if [[ ${SICS_PLUS} > 0 ]] then SICS_REV="${SICS_REV}+${SICS_PLUS}" + git diff > PATCH.TXT + else + rm PATCH.TXT fi else SICS_VER="$USER" diff --git a/site_ansto/instrument/deploySICS.sh b/site_ansto/instrument/deploySICS.sh index 1d26b95d..e2fffe72 100755 --- a/site_ansto/instrument/deploySICS.sh +++ b/site_ansto/instrument/deploySICS.sh @@ -241,6 +241,10 @@ echo "Date: $(date -Iminutes)" > $TEMPDIR/$DESTDIR/${NEWSERVER}/DEPLOYMENT.TXT echo "User: $USER" >> $TEMPDIR/$DESTDIR/${NEWSERVER}/DEPLOYMENT.TXT DEPLOYED_VERSION="$(bash ../extract_version.sh all)" echo "Version:" $DEPLOYED_VERSION >> $TEMPDIR/$DESTDIR/${NEWSERVER}/DEPLOYMENT.TXT +if [ -e PATCH.TXT ] +then +cat PATCH.TXT > $TEMPDIR/$DESTDIR/${NEWSERVER}/PATCH.TXT +fi cat $SRCDIR/MANIFEST.TXT $SRCDIR/$INSTSRC/MANIFEST.TXT > $TEMPDIR/$DESTDIR/${NEWSERVER}/MANIFEST.TXT cd $TEMPDIR From bc0606394b5f832adfc20052e968fd152834ca4d Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Mon, 8 Sep 2014 11:37:10 +1000 Subject: [PATCH 19/68] Make gitloader and gitrefer executable --- site_ansto/instrument/util/gitloader.py | 0 site_ansto/instrument/util/gitrefer.py | 0 2 files changed, 0 insertions(+), 0 deletions(-) mode change 100644 => 100755 site_ansto/instrument/util/gitloader.py mode change 100644 => 100755 site_ansto/instrument/util/gitrefer.py diff --git a/site_ansto/instrument/util/gitloader.py b/site_ansto/instrument/util/gitloader.py old mode 100644 new mode 100755 diff --git a/site_ansto/instrument/util/gitrefer.py b/site_ansto/instrument/util/gitrefer.py old mode 100644 new mode 100755 From e6925423e39c2aa2a8f695c26d4295bd43f3e60e Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Mon, 8 Sep 2014 13:45:40 +1000 Subject: [PATCH 20/68] Regenerate the SR630 driver with 600 second polls --- .../environment/temperature/sct_srs_sr630.tcl | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/site_ansto/instrument/config/environment/temperature/sct_srs_sr630.tcl b/site_ansto/instrument/config/environment/temperature/sct_srs_sr630.tcl index d3511719..d9d11943 100644 --- a/site_ansto/instrument/config/environment/temperature/sct_srs_sr630.tcl +++ b/site_ansto/instrument/config/environment/temperature/sct_srs_sr630.tcl @@ -326,15 +326,15 @@ proc ::scobj::srs_sr630::mkDriver { sct_controller name ip_address tcp_port } { hsetprop ${scobj_hpath} type "part" if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { - ${sct_controller} poll ${scobj_hpath}/id 5 + ${sct_controller} poll ${scobj_hpath}/id 600 ${sct_controller} poll ${scobj_hpath}/sensor_01 60 - ${sct_controller} poll ${scobj_hpath}/sensor_02 5 - ${sct_controller} poll ${scobj_hpath}/sensor_03 5 - ${sct_controller} poll ${scobj_hpath}/sensor_04 5 - ${sct_controller} poll ${scobj_hpath}/sensor_05 5 - ${sct_controller} poll ${scobj_hpath}/sensor_06 5 - ${sct_controller} poll ${scobj_hpath}/sensor_07 5 - ${sct_controller} poll ${scobj_hpath}/sensor_08 5 + ${sct_controller} poll ${scobj_hpath}/sensor_02 600 + ${sct_controller} poll ${scobj_hpath}/sensor_03 600 + ${sct_controller} poll ${scobj_hpath}/sensor_04 600 + ${sct_controller} poll ${scobj_hpath}/sensor_05 600 + ${sct_controller} poll ${scobj_hpath}/sensor_06 600 + ${sct_controller} poll ${scobj_hpath}/sensor_07 600 + ${sct_controller} poll ${scobj_hpath}/sensor_08 600 } else { ::scobj::srs_sr630::sics_log 9 "[environment_simulation] => No poll/write for srs_sr630" } From 5e282649097fea4a33a5e6bd14d843dd71b80841 Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Mon, 8 Sep 2014 15:53:52 +1000 Subject: [PATCH 21/68] Allow sics_config and device simulation flags in another file --- site_ansto/instrument/server_config.tcl | 42 ++++++++++++++----------- 1 file changed, 24 insertions(+), 18 deletions(-) diff --git a/site_ansto/instrument/server_config.tcl b/site_ansto/instrument/server_config.tcl index f01d4d6a..8f4b5908 100644 --- a/site_ansto/instrument/server_config.tcl +++ b/site_ansto/instrument/server_config.tcl @@ -15,23 +15,27 @@ set quieckport 60004 # false: The real driver will be used. # icsval column = settings when running on the Instrument Control Server (ie SICS_SIMULATION not defined) # fakedev column = settings for test platforms (ie SICS_SIMULATION=fakedev) -foreach {simflag icsval fakedev} { - opal_simulation false true - detector_simulation false true - hmm_simulation false true - environment_simulation false false - counter_simulation false true - motor_simulation false false - chopper_simulation false true - velsel_simulation false true - plc_simulation false true - rfgen_simulation false true - goniometer_simulation false true - magnetic_simulation false true -} { - dict set SIMFLAG_VAL $simflag ICSVAL $icsval - dict set SIMFLAG_VAL $simflag FAKEDEV $fakedev - VarMake $simflag Text internal +if [file exists ./sics_simulation.tcl] { + source ./sics_simulation.tcl +} else { + foreach {simflag icsval fakedev} { + opal_simulation false true + detector_simulation false true + hmm_simulation false true + environment_simulation false false + counter_simulation false true + motor_simulation false false + chopper_simulation false true + velsel_simulation false true + plc_simulation false true + rfgen_simulation false true + goniometer_simulation false true + magnetic_simulation false true + } { + dict set SIMFLAG_VAL $simflag ICSVAL $icsval + dict set SIMFLAG_VAL $simflag FAKEDEV $fakedev + VarMake $simflag Text internal + } } VarMake sics_simulation Text internal @@ -120,7 +124,9 @@ if {[info exists env(SICS_SIMULATION)] != 1} { } fileeval util/config_reader.tcl -if [file exists ../sics_config.ini] { +if [file exists ./sics_config.ini] { + set config_dict [config_reader::parse_file ./sics_config.ini] +} elseif [file exists ../sics_config.ini] { set config_dict [config_reader::parse_file ../sics_config.ini] } From ab6a70ad9705039d774599ce4444fc1808b3e931 Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Mon, 8 Sep 2014 15:54:29 +1000 Subject: [PATCH 22/68] Add an external sics_simulation file for Echidna --- site_ansto/instrument/hrpd/MANIFEST.TXT | 1 + 1 file changed, 1 insertion(+) diff --git a/site_ansto/instrument/hrpd/MANIFEST.TXT b/site_ansto/instrument/hrpd/MANIFEST.TXT index edd6fa3e..b6c6a16e 100644 --- a/site_ansto/instrument/hrpd/MANIFEST.TXT +++ b/site_ansto/instrument/hrpd/MANIFEST.TXT @@ -7,3 +7,4 @@ config util hostport_config.tcl hostport_config_test.tcl +sics_simulation.tcl From 6738a0844d237b12b66252245b99f4796a8a49d3 Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Mon, 8 Sep 2014 15:56:20 +1000 Subject: [PATCH 23/68] Add the Robots (Robbie and Rosie) for Echidna --- .../instrument/config/robots/epson_pandp.sct | 15 ++ .../config/robots/sct_epson_pandp.tcl | 144 ++++++++++++++++++ .../instrument/hrpd/echidna_configuration.tcl | 1 + .../instrument/hrpd/util/sics_config.ini | 23 +++ 4 files changed, 183 insertions(+) create mode 100644 site_ansto/instrument/config/robots/epson_pandp.sct create mode 100644 site_ansto/instrument/config/robots/sct_epson_pandp.tcl diff --git a/site_ansto/instrument/config/robots/epson_pandp.sct b/site_ansto/instrument/config/robots/epson_pandp.sct new file mode 100644 index 00000000..865ebb6c --- /dev/null +++ b/site_ansto/instrument/config/robots/epson_pandp.sct @@ -0,0 +1,15 @@ +# Simple driver generator for the Epson Pick and Place Robots +# vim: ts=8 sts=2 sw=2 expandtab autoindent smartindent +driver epson_pandp = { + vendor = Epson; device = 'Pick and Place Robot'; protocol = std; + class = environment; + simulation_group = environment_simulation; + add_args = "robot_name" + make_args = "robot_name" + wrapper_property nosctcontroller = True; + + code mkWrapper = {%% + clientput "add_robot ${robot_name} ${ip_address} ${tcp_port}" + add_robot ${robot_name} ${ip_address} ${tcp_port} + %%} +} diff --git a/site_ansto/instrument/config/robots/sct_epson_pandp.tcl b/site_ansto/instrument/config/robots/sct_epson_pandp.tcl new file mode 100644 index 00000000..a2bb8796 --- /dev/null +++ b/site_ansto/instrument/config/robots/sct_epson_pandp.tcl @@ -0,0 +1,144 @@ +# Generated driver for epson_pandp +# vim: ft=tcl tabstop=8 softtabstop=2 shiftwidth=2 nocindent smartindent +# + +namespace eval ::scobj::epson_pandp { + set debug_threshold 5 +} + +proc ::scobj::epson_pandp::debug_log {tc_root debug_level debug_string} { + set catch_status [ catch { + set debug_threshold [hgetpropval ${tc_root} debug_threshold] + if {${debug_level} >= ${debug_threshold}} { + set fd [open "../log/epson_pandp_[basename ${tc_root}].log" "a"] + set line "[clock format [clock seconds] -format "%T"] ${debug_string}" + puts ${fd} "${line}" + close ${fd} + } + } catch_message ] +} + +proc ::scobj::epson_pandp::sics_log {debug_level debug_string} { + set catch_status [ catch { + set debug_threshold ${::scobj::epson_pandp::debug_threshold} + if {${debug_level} >= ${debug_threshold}} { + sicslog "::scobj::epson_pandp::${debug_string}" + } + } catch_message ] +} + +proc ::scobj::epson_pandp::mkDriver { sct_controller name ip_address tcp_port robot_name } { + ::scobj::epson_pandp::sics_log 9 "::scobj::epson_pandp::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port} ${robot_name}" + set ns "[namespace current]" + set catch_status [ catch { + +# mkWrapper hook code starts + clientput "add_robot ${robot_name} ${ip_address} ${tcp_port}" + add_robot ${robot_name} ${ip_address} ${tcp_port} +# mkWrapper hook code ends + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +namespace eval ::scobj::epson_pandp { + namespace export debug_threshold + namespace export debug_log + namespace export sics_log + namespace export mkDriver +} + +proc add_epson_pandp {name ip_address tcp_port robot_name} { + set catch_status [ catch { + ::scobj::epson_pandp::sics_log 9 "add_epson_pandp ${name} ${ip_address} ${tcp_port} ${robot_name}" + ::scobj::epson_pandp::sics_log 9 "No sctcontroller for epson_pandp" + ::scobj::epson_pandp::sics_log 1 "::scobj::epson_pandp::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${robot_name}" + ::scobj::epson_pandp::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${robot_name} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +clientput "file evaluation of sct_epson_pandp.tcl" +::scobj::epson_pandp::sics_log 9 "file evaluation of sct_epson_pandp.tcl" + +proc ::scobj::epson_pandp::read_config {} { + set catch_status [ catch { + set ns "::scobj::epson_pandp" + dict for {k u} $::config_dict { + if { [dict exists $u "implementation"] } { + if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { + continue + } + set enabled [string tolower [dict get $u "enabled"]] + if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { + continue + } + set name [dict get $u name] + set implementation [dict get $u "implementation"] + if { !([dict exists $::config_dict $implementation]) } { + continue + } + set v [dict get $::config_dict $implementation] + if { !([dict exists $v "driver"]) } { + continue + } + if { [string equal -nocase [dict get $v "driver"] "epson_pandp"] } { + if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + set asyncqueue "null" + ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + } elseif { [dict exists $v "asyncqueue"] } { + set asyncqueue [dict get $v "asyncqueue"] + if { [string equal -nocase ${asyncqueue} "sct"] } { + set ip_address [dict get $v ip] + set tcp_port [dict get $v port] + } + } else { + if { [dict exists $v "asyncprotocol"] } { + set asyncprotocol [dict get $v "asyncprotocol"] + } else { + set asyncprotocol ${name}_protocol + MakeAsyncProtocol ${asyncprotocol} + if { [dict exists $v "terminator"] } { + ${asyncprotocol} sendterminator "[dict get $v "terminator"]" + ${asyncprotocol} replyterminator "[dict get $v "terminator"]" + } + } + set asyncqueue ${name}_queue + set ip_address [dict get $v ip] + set tcp_port [dict get $v port] + MakeAsyncQueue ${asyncqueue} ${asyncprotocol} ${ip_address} ${tcp_port} + if { [dict exists $v "timeout"] } { + ${asyncqueue} timeout "[dict get $v "timeout"]" + } + } + set arg_list [list] + set missing_list [list] + foreach arg {robot_name} { + if {[dict exists $u $arg]} { + lappend arg_list "[dict get $u $arg]" + } elseif {[dict exists $v $arg]} { + lappend arg_list "[dict get $v $arg]" + } else { + ${ns}::sics_log 9 "Missing configuration value $arg" + lappend missing_list $arg + } + } + if { [llength $missing_list] > 0 } { + error "$name is missing configuration values $missing_list" + } + if { [string equal -nocase ${asyncqueue} "sct"] } { + add_epson_pandp ${name} ${ip_address} ${tcp_port} {*}$arg_list + } else { + add_epson_pandp ${name} "aqadapter" ${asyncqueue} {*}$arg_list + } + } + } + } + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +if { [info exists ::config_dict] } { + ::scobj::epson_pandp::read_config +} else { + ::scobj::epson_pandp::sics_log 5 "No config dict" +} diff --git a/site_ansto/instrument/hrpd/echidna_configuration.tcl b/site_ansto/instrument/hrpd/echidna_configuration.tcl index b7a27da0..d8b7e518 100644 --- a/site_ansto/instrument/hrpd/echidna_configuration.tcl +++ b/site_ansto/instrument/hrpd/echidna_configuration.tcl @@ -47,6 +47,7 @@ fileeval $cfPath(commands)/commands.tcl fileeval $cfPath(anticollider)/anticollider.tcl #fileeval $cfPath(environment)/robby_configuration.tcl fileeval $cfPath(robots)/sct_pickandplace.tcl +fileeval $cfPath(robots)/sct_epson_pandp.tcl source gumxml.tcl diff --git a/site_ansto/instrument/hrpd/util/sics_config.ini b/site_ansto/instrument/hrpd/util/sics_config.ini index 3a98c09f..b8011634 100644 --- a/site_ansto/instrument/hrpd/util/sics_config.ini +++ b/site_ansto/instrument/hrpd/util/sics_config.ini @@ -94,6 +94,11 @@ id = 2 implementation = none name = volts2 optype = multimeter +[robot] +enabled = True +implementation = robbie +name = robot +optype = pickandplace [sample_stage] enabled = Always implementation = normal_sample_stage @@ -283,6 +288,24 @@ imptype = multimeter ip = 10.157.205.37 port = 4001 +[robbie] +asyncqueue = sct +desc = "Robbie: Epson Pick and Place Robot" +driver = epson_pandp +imptype = pickandplace +ip = 137.157.201.26 +port = 6000 +robot_name = robbie + +[rosie] +asyncqueue = sct +desc = "Rosie: Epson Six Axis Robot in Pick and Place Mode" +driver = epson_pandp +imptype = pickandplace +ip = 137.157.201.26 +port = 6000 +robot_name = rosie + [small_omega] desc = "Load the small omega configuration" imptype = motion_axis From c2a73720e9111348a9e4f47304361555f01f040d Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Tue, 9 Sep 2014 14:17:01 +1000 Subject: [PATCH 24/68] Add "restore cleanerr [locked|missing]" to clean status.tcl error messages "cleanerr" removes duplicate message "cleanerr locked" removes locked variable errors as well "cleanerr missing" removes variable not found errors as well --- statusfile.c | 98 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 98 insertions(+) diff --git a/statusfile.c b/statusfile.c index ba3915af..8c2e78d4 100644 --- a/statusfile.c +++ b/statusfile.c @@ -52,6 +52,9 @@ #include "lld.h" #include "exebuf.h" +#define CLEAN_LOCKED 1 +#define CLEAN_MISSING 2 + static int parameterChange = 0; /*-----------------------------------------------------------------------*/ int StatusFileTask(void *data) @@ -217,6 +220,94 @@ static int listRestoreErr(pRestoreObj self, SConnection * pCon) return 1; } +/*-----------------------------------------------------------------------*/ +static int cleanRestoreErr(pRestoreObj self, SConnection * pCon, int hard) +{ + char command[1024]; + char message[1024]; + char *errMsg = NULL; + int status; + int newErrList; + pDynString data = NULL; + pStringDict dict; + int count_in = 0; + int count_ex = 0; + + if (!self->errList) + return 1; + + data = CreateDynString(256,256); + if (data == NULL) { + SCWrite(pCon,"ERROR: out of memory cleaning errors",eError); + return 0; + } + dict = CreateStringDict(); + if (dict == NULL) { + SCWrite(pCon,"ERROR: out of memory cleaning errors",eError); + DeleteDynString(data); + return 0; + } + /* create new list */ + newErrList = LLDstringCreate(); + if (newErrList < 0) { + SCWrite(pCon,"ERROR: out of blobs cleaning errors",eError); + DeleteDynString(data); + DeleteStringDict(dict); + return 0; + } + status = LLDnodePtr2First(self->errList); + while (status == 1) { + LLDstringData(self->errList, command); + status = LLDnodePtr2Next(self->errList); + if (status != 1) { + /* Error */ + errMsg = "ERROR: unpaired error cleaning errors"; + break; + } + LLDstringData(self->errList, message); + if (command[0] == '#' || message[0] != '#') { + /* Error */ + errMsg = "ERROR: sequence error cleaning errors"; + break; + } + DynStringClear(data); + DynStringConcat(data, command); + DynStringConcat(data, message); + status = LLDnodePtr2Next(self->errList); + ++count_in; + /* Skip duplicate messages */ + if (StringDictExists(dict, GetCharArray(data))) + continue; + /* Skip "configured locked!" messages */ + if (hard == CLEAN_LOCKED && + strstr(message, "#ERR: ERROR: variable ") && + strstr(message, " is configured locked!")) + continue; + /* Skip "not found" messages */ + if (hard == CLEAN_MISSING && + strstr(message, "#ERR: Object ") && + strstr(message, "not found")) + continue; + /* add to dictionary and new list */ + StringDictAddPair(dict, GetCharArray(data), ""); + LLDstringAppend(newErrList, command); + LLDstringAppend(newErrList, message); + ++count_ex; + } + if (errMsg) { + SCWrite(pCon, errMsg, eError); + LLDstringDelete(newErrList); + } else { + /* swap lists */ + LLDstringDelete(self->errList); + self->errList = newErrList; + SCPrintf(pCon, eLog, "CleanErr: %d pairs in, %d pairs out", count_in, count_ex); + } + DeleteDynString(data); + DeleteStringDict(dict); + return 1; +} + /*-----------------------------------------------------------------------*/ int RestoreStatus(SConnection * pCon, SicsInterp * pSics, void *pData, int argc, char *argv[]) @@ -245,6 +336,13 @@ int RestoreStatus(SConnection * pCon, SicsInterp * pSics, void *pData, } else { if (strcasecmp(argv[1], "listerr") == 0) { return listRestoreErr(self, pCon); + } else if (strcasecmp(argv[1], "cleanerr") == 0) { + if (argc > 2 && strcasecmp(argv[2], "locked") == 0) + return cleanRestoreErr(self, pCon, CLEAN_LOCKED); + else if (argc > 2 && strcasecmp(argv[2], "missing") == 0) + return cleanRestoreErr(self, pCon, CLEAN_MISSING); + else + return cleanRestoreErr(self, pCon, 0); } else if (strcasecmp(argv[1], "killerr") == 0) { if (self->errList >= 0) { LLDdeleteBlob(self->errList); From c8057a89aa677e8d5c67eb1dcecd2532732f264a Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Tue, 9 Sep 2014 14:52:47 +1000 Subject: [PATCH 25/68] Changes pulled back from Wombat 2014-09-09 --- .../hipd/config/commands/eulerscan.tcl | 52 ---------- .../instrument/hipd/config/hmm/hmm_rapid.tcl | 97 ++++++++++--------- .../config/motors/motor_configuration.tcl | 4 +- .../instrument/hipd/wombat_configuration.tcl | 4 +- 4 files changed, 56 insertions(+), 101 deletions(-) diff --git a/site_ansto/instrument/hipd/config/commands/eulerscan.tcl b/site_ansto/instrument/hipd/config/commands/eulerscan.tcl index 954453cd..45b0724b 100644 --- a/site_ansto/instrument/hipd/config/commands/eulerscan.tcl +++ b/site_ansto/instrument/hipd/config/commands/eulerscan.tcl @@ -2,58 +2,6 @@ # AJS Dec 2010 -# SetHistoSync: sets the histogram to receive $framenum worth of frames on receiving -# TTL pulse in frame sync input. Note: Framebuffer should be set to OFF for long runs - -proc SetHistoSync {framenum} { - histmem stop - bat_table -set NO_BAT_ENTRIES $framenum NO_BAT_PERIODS $framenum - bat_table -set NO_REPEAT_ENTRY 1 NO_REPEAT_TABLE 1 NO_EXECUTE_TABLE 1 PERIOD_INDICES { 0 1 } - fat_table -set NOS_PERIODS $framenum - oat_table -set T {0 2200000} NTC 1 - histmem loadconf - histmem fsrce EXTERNAL -} - -publish SetHistoSync user - -# SetHistoNormal: resets the histo for standard operation - -proc SetHistoNormal {} { - histmem stop - bat_table -set NO_BAT_ENTRIES 1 NO_BAT_PERIODS 1 - bat_table -set NO_REPEAT_ENTRY 0 NO_REPEAT_TABLE 0 NO_EXECUTE_TABLE 0 PERIOD_INDICES { 0} - fat_table -set NOS_PERIODS 1 - oat_table -set T {0 2200000} NTC 1 - oat_table -set Y {-0.5 3.5} NYC 128 - histmem loadconf - histmem fsrce INTERNAL - proc ::histogram_memory::pre_count {} {} -} - -publish SetHistoNormal user - -proc SetHistoOneShot {frq framenum } { - histmem stop - oct speed 0.25 - oct accel 0.25 - oct decel 0.25 - drive oct 0 - bat_table -set NO_BAT_ENTRIES $framenum NO_BAT_PERIODS $framenum - bat_table -set NO_REPEAT_ENTRY 1 NO_REPEAT_TABLE 1 NO_EXECUTE_TABLE 1 PERIOD_INDICES { 0 1 } - fat_table -set NOS_PERIODS $framenum - oat_table -set T {0 2200000} NTC 1 - oat_table -set Y {-0.5 15.5} NYC 16 - histmem freq $frq - - histmem loadconf - histmem fsrce INTERNAL - histmem mode unlimited - -} - - -publish SetHistoOneShot user # continous scan for EPHI- the euler cradle phi stage (innermost axis) # note make sure controller 2 has the PHISCAN code in it diff --git a/site_ansto/instrument/hipd/config/hmm/hmm_rapid.tcl b/site_ansto/instrument/hipd/config/hmm/hmm_rapid.tcl index 43f851a0..fd7c040f 100644 --- a/site_ansto/instrument/hipd/config/hmm/hmm_rapid.tcl +++ b/site_ansto/instrument/hipd/config/hmm/hmm_rapid.tcl @@ -29,6 +29,7 @@ proc histset_XYTperiod {} { proc histmem_period_single { } { # Because bugs may not yet have been corrected in hmm_configuration_common_1.tcl, # apply the default settings before attempting del/clear. + histmem astop global n_periods set n_periods 1 FAT_TABLE -set NOS_PERIODS 1 @@ -41,23 +42,9 @@ proc histmem_period_single { } { } Publish histmem_period_single User -# orig version of this pre Oct 09 -# -#proc histmem_period_sequence { Np Nf } { -# Note - sequence needs to be at least 2 periods. -# global n_periods -# set n_periods $Np -# set fatstr "FAT_TABLE -set NOS_PERIODS $Np" -# set fatstr2 "FAT_TABLE -set PERIOD_INDICES { 0 1 }" -# set batstr "BAT_TABLE -set NO_BAT_ENTRIES $Np NO_BAT_PERIODS $Np NO_REPEAT_ENTRY $Nf NO_REPEAT_TABLE 1 NO_EXECUTE_TABLE 1" -# eval $fatstr -# eval $fatstr2 -# eval $batstr -# histmem loadconf -# -#} - proc histmem_period_sequence {Np Nt} { + histmem stop + hmm astop global n_periods set n_periods $Np #FAT_TABLE -set NOS_PERIODS $Np @@ -69,9 +56,12 @@ proc histmem_period_sequence {Np Nt} { # newfile HISTOGRAM_XYT } +Publish histmem_period_sequence User proc histmem_period_sequence_off {} { + histmem stop + hmm astop global n_periods set n_periods $Np FAT_TABLE -set NOS_PERIODS 1 @@ -79,7 +69,7 @@ proc histmem_period_sequence_off {} { histmem loadconf histset_XYperiod } -Publish histmem_period_sequence User +Publish histmem_period_sequence_off User @@ -95,6 +85,8 @@ proc histmem_save_period_sequence { } { Publish histmem_save_period_sequence User proc histmem_period_strobo {Freq Bins} { + histmem stop + hmm astop global nos_bins set nos_bins $Bins set bintime [expr int(1000000./($Freq*$Bins))] @@ -108,6 +100,7 @@ proc histmem_period_strobo {Freq Bins} { Publish histmem_period_strobo User proc histmem_strobo_off {} { + hmm astop histmem fsrce INTERNAL OAT_TABLE -set T { 0 200000 } NTC 1 histmem loadconf @@ -115,44 +108,56 @@ proc histmem_strobo_off {} { } Publish histmem_strobo_off User +# SetHistoSync: sets the histogram to receive $framenum worth of frames on receiving +# TTL pulse in frame sync input. Note: Framebuffer should be set to OFF for long runs - -proc histmem_acquire_period_sequence { Np Nf } { - - newfile HISTOGRAM_XYT - +proc SetHistoSync {framenum} { histmem stop - histmem_period_sequence $Np $Nf + hmm astop + bat_table -set NO_BAT_ENTRIES $framenum NO_BAT_PERIODS $framenum + bat_table -set NO_REPEAT_ENTRY 1 NO_REPEAT_TABLE 1 NO_EXECUTE_TABLE 1 PERIOD_INDICES { 0 1 } + fat_table -set NOS_PERIODS $framenum + oat_table -set T {0 2200000} NTC 1 histmem loadconf - histmem start + histmem fsrce EXTERNAL +} - set dlytime [ expr int( 1000 * $Nf / 50. ) ] -# clientput "Waiting for" $dlytime "ms..." - after $dlytime +publish SetHistoSync user -# clientput "tc1 reading is: " [tc1 get] +# SetHistoNormal: resets the histo for standard operation - global n_periods - for { set i 0 } { $i < $n_periods } { incr i } { -# after $dlytime -# set current_period -1 -# while { $current_period < $i } { -# update -# after 500 -# # hmm count -# # hmm init 2 -# clientput [hmm configure current_period] -# set current_period [lindex [split [hmm configure current_period] " "] 2] -# clientput "i = " $i " and the current period is " $current_period -# } +proc SetHistoNormal {} { + histmem stop + hmm astop + bat_table -set NO_BAT_ENTRIES 1 NO_BAT_PERIODS 1 + bat_table -set NO_REPEAT_ENTRY 0 NO_REPEAT_TABLE 0 NO_EXECUTE_TABLE 0 PERIOD_INDICES { 0} + fat_table -set NOS_PERIODS 1 + oat_table -set T {0 2200000} NTC 1 + oat_table -set Y {-0.5 3.5} NYC 128 + histmem loadconf + histmem fsrce INTERNAL + proc ::histogram_memory::pre_count {} {} +} - hmm configure read_data_period_number $i - save [expr $i] - } +publish SetHistoNormal user - clientput "Acquisition completed." +proc SetHistoOneShot {frq framenum } { + histmem stop + hmm astop + bat_table -set NO_BAT_ENTRIES $framenum NO_BAT_PERIODS $framenum + bat_table -set NO_REPEAT_ENTRY 1 NO_REPEAT_TABLE 1 NO_EXECUTE_TABLE 1 PERIOD_INDICES { 0 1 } + fat_table -set NOS_PERIODS $framenum + oat_table -set T {0 2200000} NTC 1 + oat_table -set Y {-0.5 15.5} NYC 16 + histmem freq $frq + + histmem loadconf + histmem fsrce INTERNAL + histmem mode unlimited } -Publish histmem_acquire_period_sequence User + + +publish SetHistoOneShot user diff --git a/site_ansto/instrument/hipd/config/motors/motor_configuration.tcl b/site_ansto/instrument/hipd/config/motors/motor_configuration.tcl index a6fac755..e3953a9f 100644 --- a/site_ansto/instrument/hipd/config/motors/motor_configuration.tcl +++ b/site_ansto/instrument/hipd/config/motors/motor_configuration.tcl @@ -345,8 +345,8 @@ Motor $sample_stage_rotate $motor_driver_type [params \ hardlowerlim -71\ hardupperlim 116\ maxSpeed 5\ - maxAccel 1\ - maxDecel 1\ + maxAccel 3\ + maxDecel 3\ stepsPerX 12500\ absEnc 1\ absEncHome $som_Home\ diff --git a/site_ansto/instrument/hipd/wombat_configuration.tcl b/site_ansto/instrument/hipd/wombat_configuration.tcl index 07290c1c..e92da140 100644 --- a/site_ansto/instrument/hipd/wombat_configuration.tcl +++ b/site_ansto/instrument/hipd/wombat_configuration.tcl @@ -56,12 +56,14 @@ fileeval $cfPath(environment)/magneticField/sct_oxford_labview.tcl fileeval $cfPath(environment)/magneticField/sct_oxford12tlv.tcl fileeval $cfPath(environment)/he3/sct_he3.tcl fileeval $cfPath(environment)/magneticField/sct_green_magnet.tcl +fileeval $cfPath(environment)/magneticField/sct_green_magnet_labview.tcl fileeval $cfPath(hmm)/hmm_configuration.tcl fileeval $cfPath(nexus)/nxscripts.tcl fileeval $cfPath(scan)/scan.tcl fileeval $cfPath(commands)/commands.tcl fileeval $cfPath(commands)/pulser.tcl fileeval $cfPath(commands)/hvcommands.tcl +fileeval $cfPath(commands)/vactex.tcl fileeval $cfPath(commands)/eulerscan.tcl fileeval $cfPath(anticollider)/anticollider.tcl fileeval $cfPath(hmm)/hmm_rapid.tcl @@ -81,7 +83,7 @@ SetVoltScale 2000.0 # Eurotherm # add_et2000 name IP PORT MODBUS_ADDR TOL # add_et2000 et2000 10.157.205.19 502 1 5 -# add tcf1 west400 10.157.205.19 502 +# add_west400 tcf1 157.205.25 502 # Using a Keithley 2700 mulitimeter to read pressure # add_k2700 pressure 137.157.201.86 4004 "\r" From 499c5c422d22a9c4f8bbd95595fb7042278d2f9d Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Tue, 9 Sep 2014 15:14:57 +1000 Subject: [PATCH 26/68] Break simulation flagss out of the server_config.tcl These are the most frequent instrument-specific changes --- .../instrument/bilby/sics_simulation.tcl | 23 +++++++++++++++++++ .../instrument/dingo/sics_simulation.tcl | 23 +++++++++++++++++++ .../instrument/hipd/sics_simulation.tcl | 23 +++++++++++++++++++ .../instrument/hrpd/sics_simulation.tcl | 23 +++++++++++++++++++ .../instrument/kookaburra/sics_simulation.tcl | 23 +++++++++++++++++++ .../instrument/pelican/sics_simulation.tcl | 23 +++++++++++++++++++ .../reflectometer/sics_simulation.tcl | 23 +++++++++++++++++++ site_ansto/instrument/rsd/sics_simulation.tcl | 23 +++++++++++++++++++ .../instrument/sans/sics_simulation.tcl | 23 +++++++++++++++++++ site_ansto/instrument/tas/sics_simulation.tcl | 23 +++++++++++++++++++ 10 files changed, 230 insertions(+) create mode 100644 site_ansto/instrument/bilby/sics_simulation.tcl create mode 100644 site_ansto/instrument/dingo/sics_simulation.tcl create mode 100644 site_ansto/instrument/hipd/sics_simulation.tcl create mode 100644 site_ansto/instrument/hrpd/sics_simulation.tcl create mode 100644 site_ansto/instrument/kookaburra/sics_simulation.tcl create mode 100644 site_ansto/instrument/pelican/sics_simulation.tcl create mode 100644 site_ansto/instrument/reflectometer/sics_simulation.tcl create mode 100644 site_ansto/instrument/rsd/sics_simulation.tcl create mode 100644 site_ansto/instrument/sans/sics_simulation.tcl create mode 100644 site_ansto/instrument/tas/sics_simulation.tcl diff --git a/site_ansto/instrument/bilby/sics_simulation.tcl b/site_ansto/instrument/bilby/sics_simulation.tcl new file mode 100644 index 00000000..61074dae --- /dev/null +++ b/site_ansto/instrument/bilby/sics_simulation.tcl @@ -0,0 +1,23 @@ +# Simulation flags, possible values = true or false +# true: The simulated driver will be used. +# false: The real driver will be used. +# icsval column = settings when running on the Instrument Control Server (ie SICS_SIMULATION not defined) +# fakedev column = settings for test platforms (ie SICS_SIMULATION=fakedev) +foreach {simflag icsval fakedev} { + opal_simulation false true + detector_simulation false true + hmm_simulation false true + environment_simulation false false + counter_simulation true true + motor_simulation false false + chopper_simulation false true + velsel_simulation false true + plc_simulation false true + rfgen_simulation false true + goniometer_simulation false true + magnetic_simulation false true +} { + dict set SIMFLAG_VAL $simflag ICSVAL $icsval + dict set SIMFLAG_VAL $simflag FAKEDEV $fakedev + VarMake $simflag Text internal +} diff --git a/site_ansto/instrument/dingo/sics_simulation.tcl b/site_ansto/instrument/dingo/sics_simulation.tcl new file mode 100644 index 00000000..d1fad2a9 --- /dev/null +++ b/site_ansto/instrument/dingo/sics_simulation.tcl @@ -0,0 +1,23 @@ +# Simulation flags, possible values = true or false +# true: The simulated driver will be used. +# false: The real driver will be used. +# icsval column = settings when running on the Instrument Control Server (ie SICS_SIMULATION not defined) +# fakedev column = settings for test platforms (ie SICS_SIMULATION=fakedev) +foreach {simflag icsval fakedev} { + opal_simulation true true + detector_simulation true true + hmm_simulation true true + environment_simulation false false + counter_simulation true true + motor_simulation false false + chopper_simulation false true + velsel_simulation false true + plc_simulation true true + rfgen_simulation false true + goniometer_simulation false true + magnetic_simulation false true +} { + dict set SIMFLAG_VAL $simflag ICSVAL $icsval + dict set SIMFLAG_VAL $simflag FAKEDEV $fakedev + VarMake $simflag Text internal +} diff --git a/site_ansto/instrument/hipd/sics_simulation.tcl b/site_ansto/instrument/hipd/sics_simulation.tcl new file mode 100644 index 00000000..20a84063 --- /dev/null +++ b/site_ansto/instrument/hipd/sics_simulation.tcl @@ -0,0 +1,23 @@ +# Simulation flags, possible values = true or false +# true: The simulated driver will be used. +# false: The real driver will be used. +# icsval column = settings when running on the Instrument Control Server (ie SICS_SIMULATION not defined) +# fakedev column = settings for test platforms (ie SICS_SIMULATION=fakedev) +foreach {simflag icsval fakedev} { + opal_simulation true true + detector_simulation false true + hmm_simulation false true + environment_simulation false false + counter_simulation false true + motor_simulation false false + chopper_simulation false true + velsel_simulation false true + plc_simulation false true + rfgen_simulation false true + goniometer_simulation false true + magnetic_simulation false true +} { + dict set SIMFLAG_VAL $simflag ICSVAL $icsval + dict set SIMFLAG_VAL $simflag FAKEDEV $fakedev + VarMake $simflag Text internal +} diff --git a/site_ansto/instrument/hrpd/sics_simulation.tcl b/site_ansto/instrument/hrpd/sics_simulation.tcl new file mode 100644 index 00000000..15f7173b --- /dev/null +++ b/site_ansto/instrument/hrpd/sics_simulation.tcl @@ -0,0 +1,23 @@ +# Simulation flags, possible values = true or false +# true: The simulated driver will be used. +# false: The real driver will be used. +# icsval column = settings when running on the Instrument Control Server (ie SICS_SIMULATION not defined) +# fakedev column = settings for test platforms (ie SICS_SIMULATION=fakedev) +foreach {simflag icsval fakedev} { + opal_simulation false true + detector_simulation false true + hmm_simulation false true + environment_simulation false true + counter_simulation false false + motor_simulation false false + chopper_simulation false false + velsel_simulation false false + plc_simulation false true + rfgen_simulation false false + goniometer_simulation false true + magnetic_simulation false true +} { + dict set SIMFLAG_VAL $simflag ICSVAL $icsval + dict set SIMFLAG_VAL $simflag FAKEDEV $fakedev + VarMake $simflag Text internal +} diff --git a/site_ansto/instrument/kookaburra/sics_simulation.tcl b/site_ansto/instrument/kookaburra/sics_simulation.tcl new file mode 100644 index 00000000..429a24b8 --- /dev/null +++ b/site_ansto/instrument/kookaburra/sics_simulation.tcl @@ -0,0 +1,23 @@ +# Simulation flags, possible values = true or false +# true: The simulated driver will be used. +# false: The real driver will be used. +# icsval column = settings when running on the Instrument Control Server (ie SICS_SIMULATION not defined) +# fakedev column = settings for test platforms (ie SICS_SIMULATION=fakedev) +foreach {simflag icsval fakedev} { + opal_simulation true true + detector_simulation false true + hmm_simulation false true + environment_simulation false false + counter_simulation false true + motor_simulation false false + chopper_simulation false true + velsel_simulation false true + plc_simulation true true + rfgen_simulation false true + goniometer_simulation false true + magnetic_simulation false true +} { + dict set SIMFLAG_VAL $simflag ICSVAL $icsval + dict set SIMFLAG_VAL $simflag FAKEDEV $fakedev + VarMake $simflag Text internal +} diff --git a/site_ansto/instrument/pelican/sics_simulation.tcl b/site_ansto/instrument/pelican/sics_simulation.tcl new file mode 100644 index 00000000..25fdc9a7 --- /dev/null +++ b/site_ansto/instrument/pelican/sics_simulation.tcl @@ -0,0 +1,23 @@ +# Simulation flags, possible values = true or false +# true: The simulated driver will be used. +# false: The real driver will be used. +# icsval column = settings when running on the Instrument Control Server (ie SICS_SIMULATION not defined) +# fakedev column = settings for test platforms (ie SICS_SIMULATION=fakedev) +foreach {simflag icsval fakedev} { + opal_simulation false true + detector_simulation false true + hmm_simulation false true + environment_simulation false false + counter_simulation false true + motor_simulation false false + chopper_simulation false true + velsel_simulation false true + plc_simulation true true + rfgen_simulation false true + goniometer_simulation false true + magnetic_simulation false true +} { + dict set SIMFLAG_VAL $simflag ICSVAL $icsval + dict set SIMFLAG_VAL $simflag FAKEDEV $fakedev + VarMake $simflag Text internal +} diff --git a/site_ansto/instrument/reflectometer/sics_simulation.tcl b/site_ansto/instrument/reflectometer/sics_simulation.tcl new file mode 100644 index 00000000..e940d6ae --- /dev/null +++ b/site_ansto/instrument/reflectometer/sics_simulation.tcl @@ -0,0 +1,23 @@ +# Simulation flags, possible values = true or false +# true: The simulated driver will be used. +# false: The real driver will be used. +# icsval column = settings when running on the Instrument Control Server (ie SICS_SIMULATION not defined) +# fakedev column = settings for test platforms (ie SICS_SIMULATION=fakedev) +foreach {simflag icsval fakedev} { + opal_simulation true true + detector_simulation false true + hmm_simulation false true + environment_simulation false true + counter_simulation false false + motor_simulation false false + chopper_simulation false false + velsel_simulation false false + plc_simulation false true + rfgen_simulation false false + goniometer_simulation false true + magnetic_simulation false true +} { + dict set SIMFLAG_VAL $simflag ICSVAL $icsval + dict set SIMFLAG_VAL $simflag FAKEDEV $fakedev + VarMake $simflag Text internal +} diff --git a/site_ansto/instrument/rsd/sics_simulation.tcl b/site_ansto/instrument/rsd/sics_simulation.tcl new file mode 100644 index 00000000..15f7173b --- /dev/null +++ b/site_ansto/instrument/rsd/sics_simulation.tcl @@ -0,0 +1,23 @@ +# Simulation flags, possible values = true or false +# true: The simulated driver will be used. +# false: The real driver will be used. +# icsval column = settings when running on the Instrument Control Server (ie SICS_SIMULATION not defined) +# fakedev column = settings for test platforms (ie SICS_SIMULATION=fakedev) +foreach {simflag icsval fakedev} { + opal_simulation false true + detector_simulation false true + hmm_simulation false true + environment_simulation false true + counter_simulation false false + motor_simulation false false + chopper_simulation false false + velsel_simulation false false + plc_simulation false true + rfgen_simulation false false + goniometer_simulation false true + magnetic_simulation false true +} { + dict set SIMFLAG_VAL $simflag ICSVAL $icsval + dict set SIMFLAG_VAL $simflag FAKEDEV $fakedev + VarMake $simflag Text internal +} diff --git a/site_ansto/instrument/sans/sics_simulation.tcl b/site_ansto/instrument/sans/sics_simulation.tcl new file mode 100644 index 00000000..20a84063 --- /dev/null +++ b/site_ansto/instrument/sans/sics_simulation.tcl @@ -0,0 +1,23 @@ +# Simulation flags, possible values = true or false +# true: The simulated driver will be used. +# false: The real driver will be used. +# icsval column = settings when running on the Instrument Control Server (ie SICS_SIMULATION not defined) +# fakedev column = settings for test platforms (ie SICS_SIMULATION=fakedev) +foreach {simflag icsval fakedev} { + opal_simulation true true + detector_simulation false true + hmm_simulation false true + environment_simulation false false + counter_simulation false true + motor_simulation false false + chopper_simulation false true + velsel_simulation false true + plc_simulation false true + rfgen_simulation false true + goniometer_simulation false true + magnetic_simulation false true +} { + dict set SIMFLAG_VAL $simflag ICSVAL $icsval + dict set SIMFLAG_VAL $simflag FAKEDEV $fakedev + VarMake $simflag Text internal +} diff --git a/site_ansto/instrument/tas/sics_simulation.tcl b/site_ansto/instrument/tas/sics_simulation.tcl new file mode 100644 index 00000000..6fb592b5 --- /dev/null +++ b/site_ansto/instrument/tas/sics_simulation.tcl @@ -0,0 +1,23 @@ +# Simulation flags, possible values = true or false +# true: The simulated driver will be used. +# false: The real driver will be used. +# icsval column = settings when running on the Instrument Control Server (ie SICS_SIMULATION not defined) +# fakedev column = settings for test platforms (ie SICS_SIMULATION=fakedev) +foreach {simflag icsval fakedev} { + opal_simulation true true + detector_simulation false true + hmm_simulation false true + environment_simulation false true + counter_simulation false false + motor_simulation false false + chopper_simulation false false + velsel_simulation false false + plc_simulation true true + rfgen_simulation false false + goniometer_simulation false true + magnetic_simulation false true +} { + dict set SIMFLAG_VAL $simflag ICSVAL $icsval + dict set SIMFLAG_VAL $simflag FAKEDEV $fakedev + VarMake $simflag Text internal +} From c608e5e6410e1b68f00926ee93bfd9fcfb0c5355 Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Tue, 9 Sep 2014 16:38:44 +1000 Subject: [PATCH 27/68] Merge changes from Dingo 2014-09-09 --- .../config/motors/motor_configuration.tcl | 35 +++++++++++++++ .../instrument/dingo/dingo_configuration.tcl | 44 ++++++++++++++++--- 2 files changed, 74 insertions(+), 5 deletions(-) diff --git a/site_ansto/instrument/dingo/config/motors/motor_configuration.tcl b/site_ansto/instrument/dingo/config/motors/motor_configuration.tcl index 07129102..aa4a1f69 100644 --- a/site_ansto/instrument/dingo/config/motors/motor_configuration.tcl +++ b/site_ansto/instrument/dingo/config/motors/motor_configuration.tcl @@ -199,6 +199,41 @@ dz softlowerlim 0 dz softupperlim 170 dz home 0 +# mc1:H Sample rotation axis +# Resolver 2,048 counts per degree +# Motor 12,500 steps per degree +# Positive steps are CCW viewed from above +set soma_Home 9867748 +#set somaStepRate [expr -$motorrate*100.0] +set somaStepRate 12500 +Motor soma $motor_driver_type [params \ + asyncqueue mc1\ + host mc1-dingo\ + port pmc1-dingo\ + axis H\ + units degree\ + hardlowerlim -722\ + hardupperlim 722\ + maxSpeed 12\ + maxAccel 1\ + maxDecel 1\ + stepsPerX $somaStepRate\ + absEnc 1\ + absEncHome $soma_Home\ + nopowersave 1\ + cntsPerX 2048 ] +soma speed 0.1 +soma accel 0.1 +soma decel 0.1 +soma part sample +soma long_name soma +soma softlowerlim -1 +soma softupperlim 361 +soma home 0 +#soma bias_bits 25 +#soma rotary_bits 25 +soma creep_offset 0.05 + ############################ # Motor Controller 2 diff --git a/site_ansto/instrument/dingo/dingo_configuration.tcl b/site_ansto/instrument/dingo/dingo_configuration.tcl index d808ae00..0c6c3804 100644 --- a/site_ansto/instrument/dingo/dingo_configuration.tcl +++ b/site_ansto/instrument/dingo/dingo_configuration.tcl @@ -1,8 +1,8 @@ -# Author: Ferdi Franceschini (ffr@ansto.gov.au) +# Author: Jing Chen (jgn@ansto.gov.au) # Required by server_config.tcl VarMake Instrument Text Internal -Instrument bare_dingo +Instrument dingo Instrument lock #START SERVER CONFIGURATION SECTION @@ -14,12 +14,46 @@ MakeDrive ######################################## # INSTRUMENT SPECIFIC CONFIGURATION + +source $cfPath(hipadaba)/hipadaba_configuration.tcl + fileeval $cfPath(source)/source.tcl -fileeval $cfPath(plc)/plc.tcl fileeval $cfPath(motors)/motor_configuration.tcl +#fileeval $cfPath(motors)/positmotor_configuration.tcl +#fileeval $cfPath(motors)/extraconfig.tcl +#fileeval $cfPath(plc)/plc.tcl +#fileeval $cfPath(counter)/counter.tcl +#fileeval $cfPath(hmm)/hmm_configuration.tcl +fileeval $cfPath(nexus)/nxscripts.tcl fileeval $cfPath(scan)/scan.tcl +fileeval $cfPath(commands)/commands.tcl +#fileeval $cfPath(commands)/pulser.tcl +#fileeval $cfPath(commands)/hvcommands.tcl +fileeval $cfPath(anticollider)/anticollider.tcl + +source gumxml.tcl + +#::utility::mkVar ::anticollider::protect_detector text manager protect_detector false detector true false +#::anticollider::protect_detector "true" + +# fix all motors +if {1} { + set motorlist "[sicslist type motor]" + puts $motorlist + foreach m $motorlist { + if {$m == "motor" || $m == "dummy_motor"} { + # skipit + } else { + $m fixed 1 + } + } +} server_init -exe batchpath ../batch -exe syspath ../batch + clientput "serverport [get_portnum $::serverport]" + +########################################### +# WARNING: Do not add any code below server_init, if you do SICS may fail to initialise properly. + +# You can add extra-configuration code in ../extraconfig.tcl From d0d2b3817782697355829654e6e545a4fadbc087 Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Tue, 9 Sep 2014 16:50:08 +1000 Subject: [PATCH 28/68] Kookaburra local changes Conflicts: sics/site_ansto/instrument/config/hmm/hmm_configuration_common_1.tcl --- .../config/motors/motor_configuration.tcl | 14 +++++++++++--- .../instrument/kookaburra/hostport_config.tcl | 4 +--- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/site_ansto/instrument/kookaburra/config/motors/motor_configuration.tcl b/site_ansto/instrument/kookaburra/config/motors/motor_configuration.tcl index dafbb1ae..0f36b949 100644 --- a/site_ansto/instrument/kookaburra/config/motors/motor_configuration.tcl +++ b/site_ansto/instrument/kookaburra/config/motors/motor_configuration.tcl @@ -232,7 +232,8 @@ Motor m1chi $motor_driver_type [params \ stepsPerX -$m1chiSetRate\ absEnc 1\ absEncHome $m1chi_Home\ - cntsPerX [expr 131072*100.0/68.681] ] + cntsPerX [expr 131072*100.0/68.681]\ + nopowersave 1] m1chi precision 0.001 m1chi speed 0.200 m1chi part crystal @@ -317,7 +318,7 @@ Motor ss1u $motor_driver_type [params \ axis D\ units mm\ hardlowerlim -33.5\ - hardupperlim 37.8\ + hardupperlim 35.9\ maxSpeed [expr $maxSpeedSlit/$ss1uSetRate]\ maxAccel [expr 5000.0/$ss1uSetRate/0.5]\ maxDecel [expr 5000.0/$ss1uSetRate/0.5]\ @@ -585,7 +586,8 @@ Motor m2chi $motor_driver_type [params \ stepsPerX -$m2chiSetRate\ absEnc 1\ absEncHome $m2chi_Home\ - cntsPerX [expr 131072*100.0/68.681]] + cntsPerX [expr 131072*100.0/68.681]\ + nopowersave 1] m2chi precision 0.001 m2chi speed 0.200 m2chi part crystal @@ -686,6 +688,12 @@ m2y softupperlim 355 m2y home 0 +make_gap_motors ss1vg ss1vg ss1vo ss1vo ss1u ss1d mm gaps +make_gap_motors ss1hg ss1hg ss1ho ss1ho ss1r ss1l mm gaps + +make_gap_motors ss2vg ss2vg ss2vo ss2vo ss2u ss2d mm gaps +make_gap_motors ss2hg ss2hg ss2ho ss2ho ss2r ss2l mm gaps + proc motor_set_sobj_attributes {} { } diff --git a/site_ansto/instrument/kookaburra/hostport_config.tcl b/site_ansto/instrument/kookaburra/hostport_config.tcl index 42f63978..84ec2936 100644 --- a/site_ansto/instrument/kookaburra/hostport_config.tcl +++ b/site_ansto/instrument/kookaburra/hostport_config.tcl @@ -12,9 +12,7 @@ foreach {mc host port} { # BEAM MONITOR HOST AND PORT foreach {bm host port} { - MONITOR_1 das1-kookaburra 30000 - MONITOR_2 das1-kookaburra 30001 - MONITOR_3 das1-kookaburra 30002 + MONITOR_1 137.157.205.24 30000 } { dict set MONITOR_HOSTPORT $bm HOST $host dict set MONITOR_HOSTPORT $bm PORT $port From b127f49b33e1d2706e80c45971ed0f39f50676bf Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Tue, 9 Sep 2014 16:56:29 +1000 Subject: [PATCH 29/68] Pullback change from Quokka 2014-09-09 --- .../config/environment/temperature/sct_lakeshore_340.tcl | 2 ++ 1 file changed, 2 insertions(+) diff --git a/site_ansto/instrument/config/environment/temperature/sct_lakeshore_340.tcl b/site_ansto/instrument/config/environment/temperature/sct_lakeshore_340.tcl index 8e2e8738..77c10c3a 100644 --- a/site_ansto/instrument/config/environment/temperature/sct_lakeshore_340.tcl +++ b/site_ansto/instrument/config/environment/temperature/sct_lakeshore_340.tcl @@ -989,6 +989,8 @@ proc sendCmd {tc_root nextState cmd {idx ""}} { set sensorValue $tc_root/sensor/sensorValue$whichSensor if {$whichCtrlLoop <= 2} { set nodename $tc_root/sensor/setpoint$whichCtrlLoop + hset $tc_root/control/tolerance1 1 + hset $tc_root/control/tolerance2 1 hset $nodename [hval $sensorValue] hsetprop $nodename driving 0 } From 99fae91ff904ac9e584ac6f8949fde9e6814f782 Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Wed, 10 Sep 2014 10:14:46 +1000 Subject: [PATCH 30/68] Add sics_simulation.tcl to each instrument MANIFEST.TXT file --- site_ansto/instrument/bilby/MANIFEST.TXT | 1 + site_ansto/instrument/dingo/MANIFEST.TXT | 1 + site_ansto/instrument/hipd/MANIFEST.TXT | 1 + site_ansto/instrument/kookaburra/MANIFEST.TXT | 1 + site_ansto/instrument/lyrebird/MANIFEST.TXT | 1 + site_ansto/instrument/pelican/MANIFEST.TXT | 1 + site_ansto/instrument/qld/MANIFEST.TXT | 1 + site_ansto/instrument/reflectometer/MANIFEST.TXT | 1 + site_ansto/instrument/rsd/MANIFEST.TXT | 1 + site_ansto/instrument/sans/MANIFEST.TXT | 1 + site_ansto/instrument/tas/MANIFEST.TXT | 1 + 11 files changed, 11 insertions(+) diff --git a/site_ansto/instrument/bilby/MANIFEST.TXT b/site_ansto/instrument/bilby/MANIFEST.TXT index 06aa801e..333ba0cf 100644 --- a/site_ansto/instrument/bilby/MANIFEST.TXT +++ b/site_ansto/instrument/bilby/MANIFEST.TXT @@ -4,3 +4,4 @@ config util hostport_config.tcl hostport_config_test.tcl +sics_simulation.tcl diff --git a/site_ansto/instrument/dingo/MANIFEST.TXT b/site_ansto/instrument/dingo/MANIFEST.TXT index 5efb8a9a..808602de 100644 --- a/site_ansto/instrument/dingo/MANIFEST.TXT +++ b/site_ansto/instrument/dingo/MANIFEST.TXT @@ -8,3 +8,4 @@ hostport_config.tcl hostport_config_test.tcl camtest_configuration.tcl dingo.hdd +sics_simulation.tcl diff --git a/site_ansto/instrument/hipd/MANIFEST.TXT b/site_ansto/instrument/hipd/MANIFEST.TXT index 280229d1..b82887fe 100644 --- a/site_ansto/instrument/hipd/MANIFEST.TXT +++ b/site_ansto/instrument/hipd/MANIFEST.TXT @@ -7,3 +7,4 @@ config util hostport_config.tcl hostport_config_test.tcl +sics_simulation.tcl diff --git a/site_ansto/instrument/kookaburra/MANIFEST.TXT b/site_ansto/instrument/kookaburra/MANIFEST.TXT index 7a061e4e..6040e6af 100644 --- a/site_ansto/instrument/kookaburra/MANIFEST.TXT +++ b/site_ansto/instrument/kookaburra/MANIFEST.TXT @@ -6,3 +6,4 @@ config util hostport_config.tcl hostport_config_test.tcl +sics_simulation.tcl diff --git a/site_ansto/instrument/lyrebird/MANIFEST.TXT b/site_ansto/instrument/lyrebird/MANIFEST.TXT index e7b7eb2e..79f965e4 100644 --- a/site_ansto/instrument/lyrebird/MANIFEST.TXT +++ b/site_ansto/instrument/lyrebird/MANIFEST.TXT @@ -6,3 +6,4 @@ config util hostport_config.tcl hostport_config_test.tcl +sics_simulation.tcl diff --git a/site_ansto/instrument/pelican/MANIFEST.TXT b/site_ansto/instrument/pelican/MANIFEST.TXT index f5807a59..0ae5a1d1 100644 --- a/site_ansto/instrument/pelican/MANIFEST.TXT +++ b/site_ansto/instrument/pelican/MANIFEST.TXT @@ -6,3 +6,4 @@ config util hostport_config.tcl hostport_config_test.tcl +sics_simulation.tcl diff --git a/site_ansto/instrument/qld/MANIFEST.TXT b/site_ansto/instrument/qld/MANIFEST.TXT index 386c1f4f..80d4dd24 100644 --- a/site_ansto/instrument/qld/MANIFEST.TXT +++ b/site_ansto/instrument/qld/MANIFEST.TXT @@ -6,3 +6,4 @@ koala.hdd troubleshoot_setup.tcl extraconfig.tcl InstXML.xml +sics_simulation.tcl diff --git a/site_ansto/instrument/reflectometer/MANIFEST.TXT b/site_ansto/instrument/reflectometer/MANIFEST.TXT index c48c7d9a..4e5b24ad 100644 --- a/site_ansto/instrument/reflectometer/MANIFEST.TXT +++ b/site_ansto/instrument/reflectometer/MANIFEST.TXT @@ -7,3 +7,4 @@ config util hostport_config.tcl hostport_config_test.tcl +sics_simulation.tcl diff --git a/site_ansto/instrument/rsd/MANIFEST.TXT b/site_ansto/instrument/rsd/MANIFEST.TXT index 47be8e1a..23eab905 100644 --- a/site_ansto/instrument/rsd/MANIFEST.TXT +++ b/site_ansto/instrument/rsd/MANIFEST.TXT @@ -7,3 +7,4 @@ config util hostport_config.tcl hostport_config_test.tcl +sics_simulation.tcl diff --git a/site_ansto/instrument/sans/MANIFEST.TXT b/site_ansto/instrument/sans/MANIFEST.TXT index 92a3f6d5..930f85a3 100644 --- a/site_ansto/instrument/sans/MANIFEST.TXT +++ b/site_ansto/instrument/sans/MANIFEST.TXT @@ -7,3 +7,4 @@ config util hostport_config.tcl hostport_config_test.tcl +sics_simulation.tcl diff --git a/site_ansto/instrument/tas/MANIFEST.TXT b/site_ansto/instrument/tas/MANIFEST.TXT index d223330f..7c1d3315 100644 --- a/site_ansto/instrument/tas/MANIFEST.TXT +++ b/site_ansto/instrument/tas/MANIFEST.TXT @@ -6,3 +6,4 @@ config util hostport_config.tcl hostport_config_test.tcl +sics_simulation.tcl From 0867f5a315c88cd6dea8fcc467115c0341e6948d Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Wed, 10 Sep 2014 14:22:50 +1000 Subject: [PATCH 31/68] Update "Decimal" processing for 4100/6100 --- .../environment/temperature/sct_west_6100.tcl | 13 +++++++++++-- .../config/environment/temperature/west_6100.sct | 14 +++++++++++--- 2 files changed, 22 insertions(+), 5 deletions(-) diff --git a/site_ansto/instrument/config/environment/temperature/sct_west_6100.tcl b/site_ansto/instrument/config/environment/temperature/sct_west_6100.tcl index 5b1bd613..11de806d 100644 --- a/site_ansto/instrument/config/environment/temperature/sct_west_6100.tcl +++ b/site_ansto/instrument/config/environment/temperature/sct_west_6100.tcl @@ -126,7 +126,10 @@ proc ::scobj::west_6100::rdDecimal {tc_root} { error "[sct geterror]" } # rdDecimal hook code starts - set data [expr {0.10 * ${data}}] + set decimal [hval ${tc_root}/aux/decimal] + if { ${decimal} > 0 } { + set data [expr {pow(10, -${decimal}) * ${data}}] + } # rdDecimal hook code ends if { [hpropexists [sct] geterror] } { debug_log ${tc_root} 9 "[sct] error: [sct geterror]" @@ -203,7 +206,12 @@ proc ::scobj::west_6100::wrDecimal {tc_root nextState cmd_str} { set par [sct target] set cmd "${cmd_str}${par}" # wrDecimal hook code starts - set par [expr {round(10.0 * [sct target])}] + set decimal [hval ${tc_root}/aux/decimal] + set par [sct target] + if { ${decimal} > 0 } { + set par [expr {pow(10, ${decimal}) * ${par}}] + } + set par [expr {round(${par})}] set cmd "1:16:${cmd_str}:1:U16:${par}" # wrDecimal hook code ends if { [hpropexists [sct] geterror] } { @@ -424,6 +432,7 @@ proc ::scobj::west_6100::mkDriver { sct_controller name ip_address tcp_port dev_ hsetprop ${scobj_hpath}/aux/decimal mutable false hsetprop ${scobj_hpath}/aux/decimal nxsave false hsetprop ${scobj_hpath}/aux/decimal oldval 0 + hset ${scobj_hpath}/aux/decimal 0 hsetprop ${scobj_hpath}/aux/decimal sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/aux/decimal type "part" hsetprop ${scobj_hpath}/aux/decimal nxalias "${name}_aux_decimal" diff --git a/site_ansto/instrument/config/environment/temperature/west_6100.sct b/site_ansto/instrument/config/environment/temperature/west_6100.sct index 72ff7050..178d25b7 100644 --- a/site_ansto/instrument/config/environment/temperature/west_6100.sct +++ b/site_ansto/instrument/config/environment/temperature/west_6100.sct @@ -34,7 +34,7 @@ driver west_6100 = { fetch_function = getInteger; read_function = rdInteger; var model = { type = int; read_command = "122"; } - var decimal = { type = int; read_command = "18"; } + var decimal = { type = int; read_command = "18"; value = 0; } var instatus = { type = int; read_command = "133"; } } code fetch_function getInteger = { @@ -59,12 +59,20 @@ driver west_6100 = { } code read_function rdDecimal = { @TCL - set data [expr {0.10 * ${data}}] + set decimal [hval ${tc_root}/aux/decimal] + if { ${decimal} > 0 } { + set data [expr {pow(10, -${decimal}) * ${data}}] + } @END } code write_function wrDecimal = { @TCL - set par [expr {round(10.0 * [sct target])}] + set decimal [hval ${tc_root}/aux/decimal] + set par [sct target] + if { ${decimal} > 0 } { + set par [expr {pow(10, ${decimal}) * ${par}}] + } + set par [expr {round(${par})}] set cmd "1:16:${cmd_str}:1:U16:${par}" @END } From c6d2245941f58bea84b439ae0a0e2778408614e1 Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Wed, 10 Sep 2014 14:26:16 +1000 Subject: [PATCH 32/68] Move ls218, nhq200, sr630 from environment to detector --- site_ansto/instrument/config/environment/nhq_200.sct | 4 ++-- .../config/environment/temperature/lakeshore_218.sct | 2 +- .../instrument/config/environment/temperature/srs_sr630.sct | 4 ++-- 3 files changed, 5 insertions(+), 5 deletions(-) diff --git a/site_ansto/instrument/config/environment/nhq_200.sct b/site_ansto/instrument/config/environment/nhq_200.sct index 1b98f4f1..29dd4cc8 100644 --- a/site_ansto/instrument/config/environment/nhq_200.sct +++ b/site_ansto/instrument/config/environment/nhq_200.sct @@ -3,8 +3,8 @@ # driver nhq_200 = { vendor = FastComTech; device = NHQ; protocol = std; - class = environment; - simulation_group = environment_simulation; + class = NXdetector; + simulation_group = detector_simulation; group = { readable = 10; diff --git a/site_ansto/instrument/config/environment/temperature/lakeshore_218.sct b/site_ansto/instrument/config/environment/temperature/lakeshore_218.sct index f081597b..64a87296 100644 --- a/site_ansto/instrument/config/environment/temperature/lakeshore_218.sct +++ b/site_ansto/instrument/config/environment/temperature/lakeshore_218.sct @@ -1,6 +1,6 @@ driver lakeshore_218 = { vendor = lakeshore; device = ls218; protocol = std; - class = environment; simulation_group = environment_simulation; + class = NXdetector; simulation_group = detector_simulation; group = { data = false; diff --git a/site_ansto/instrument/config/environment/temperature/srs_sr630.sct b/site_ansto/instrument/config/environment/temperature/srs_sr630.sct index ec3c4914..b62b14d3 100644 --- a/site_ansto/instrument/config/environment/temperature/srs_sr630.sct +++ b/site_ansto/instrument/config/environment/temperature/srs_sr630.sct @@ -3,8 +3,8 @@ driver srs_sr630 = { vendor = StanfordResearchSystems; device=SR630; protocol = std; - class = environment; - simulation_group = environment_simulation; + class = NXdetector; + simulation_group = detector_simulation; group = { priv = user; From a9a20b48552d9672cea06e0543f30bdc785d9626 Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Wed, 10 Sep 2014 14:27:11 +1000 Subject: [PATCH 33/68] Regenerate the ls218, nhq200 and sr630 drivers --- .../config/environment/sct_nhq_200.tcl | 26 +++++++++---------- .../temperature/sct_lakeshore_218.tcl | 20 +++++++------- .../environment/temperature/sct_srs_sr630.tcl | 16 ++++++------ 3 files changed, 31 insertions(+), 31 deletions(-) diff --git a/site_ansto/instrument/config/environment/sct_nhq_200.tcl b/site_ansto/instrument/config/environment/sct_nhq_200.tcl index dabf95a9..4aef7fb3 100644 --- a/site_ansto/instrument/config/environment/sct_nhq_200.tcl +++ b/site_ansto/instrument/config/environment/sct_nhq_200.tcl @@ -276,7 +276,7 @@ proc ::scobj::nhq_200::mkDriver { sct_controller name ip_address tcp_port } { MakeSICSObj ${name} SCT_OBJECT - sicslist setatt ${name} klass environment + sicslist setatt ${name} klass NXdetector sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} @@ -311,11 +311,11 @@ proc ::scobj::nhq_200::mkDriver { sct_controller name ip_address tcp_port } { hsetprop ${scobj_hpath} klass "@none" hsetprop ${scobj_hpath} type "part" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase [SplitReply [detector_simulation]] "false"]} { ${sct_controller} poll ${scobj_hpath}/break 10 ${sct_controller} poll ${scobj_hpath}/id 10 } else { - ::scobj::nhq_200::sics_log 9 "[environment_simulation] => No poll/write for nhq_200" + ::scobj::nhq_200::sics_log 9 "[detector_simulation] => No poll/write for nhq_200" } hfactory ${scobj_hpath}/ch1 plain spy none @@ -488,7 +488,7 @@ proc ::scobj::nhq_200::mkDriver { sct_controller name ip_address tcp_port } { hsetprop ${scobj_hpath}/ch1/voltage type "part" hsetprop ${scobj_hpath}/ch1/voltage nxalias "${name}_ch1_voltage" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase [SplitReply [detector_simulation]] "false"]} { ${sct_controller} poll ${scobj_hpath}/ch1/auto_start 5 ${sct_controller} poll ${scobj_hpath}/ch1/current 5 ${sct_controller} poll ${scobj_hpath}/ch1/i_lim 5 @@ -505,7 +505,7 @@ proc ::scobj::nhq_200::mkDriver { sct_controller name ip_address tcp_port } { ${sct_controller} write ${scobj_hpath}/ch1/v_ramp ${sct_controller} write ${scobj_hpath}/ch1/v_sp } else { - ::scobj::nhq_200::sics_log 9 "[environment_simulation] => No poll/write for nhq_200" + ::scobj::nhq_200::sics_log 9 "[detector_simulation] => No poll/write for nhq_200" } hfactory ${scobj_hpath}/ch2 plain spy none @@ -678,7 +678,7 @@ proc ::scobj::nhq_200::mkDriver { sct_controller name ip_address tcp_port } { hsetprop ${scobj_hpath}/ch2/voltage type "part" hsetprop ${scobj_hpath}/ch2/voltage nxalias "${name}_ch2_voltage" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase [SplitReply [detector_simulation]] "false"]} { ${sct_controller} poll ${scobj_hpath}/ch2/auto_start 5 ${sct_controller} poll ${scobj_hpath}/ch2/current 5 ${sct_controller} poll ${scobj_hpath}/ch2/i_lim 5 @@ -695,12 +695,12 @@ proc ::scobj::nhq_200::mkDriver { sct_controller name ip_address tcp_port } { ${sct_controller} write ${scobj_hpath}/ch2/v_ramp ${sct_controller} write ${scobj_hpath}/ch2/v_sp } else { - ::scobj::nhq_200::sics_log 9 "[environment_simulation] => No poll/write for nhq_200" + ::scobj::nhq_200::sics_log 9 "[detector_simulation] => No poll/write for nhq_200" } - hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} klass NXdetector hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase [SplitReply [detector_simulation]] "false"]} { ansto_makesctdrive ${name}_ch1_v_sp ${scobj_hpath}/ch1/v_sp ${scobj_hpath}/ch1/voltage ${sct_controller} ansto_makesctdrive ${name}_ch2_v_sp ${scobj_hpath}/ch2/v_sp ${scobj_hpath}/ch2/voltage ${sct_controller} } @@ -719,7 +719,7 @@ namespace eval ::scobj::nhq_200 { proc add_nhq_200 {name ip_address tcp_port} { set catch_status [ catch { ::scobj::nhq_200::sics_log 9 "add_nhq_200 ${name} ${ip_address} ${tcp_port}" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase [SplitReply [detector_simulation]] "false"]} { if {[string equal -nocase "aqadapter" "${ip_address}"]} { ::scobj::nhq_200::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" makesctcontroller sct_${name} aqadapter ${tcp_port} @@ -728,7 +728,7 @@ proc add_nhq_200 {name ip_address tcp_port} { makesctcontroller sct_${name} std ${ip_address}:${tcp_port} } } else { - ::scobj::nhq_200::sics_log 9 "[environment_simulation] => No sctcontroller for nhq_200" + ::scobj::nhq_200::sics_log 9 "[detector_simulation] => No sctcontroller for nhq_200" } ::scobj::nhq_200::sics_log 1 "::scobj::nhq_200::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port}" ::scobj::nhq_200::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} @@ -761,9 +761,9 @@ proc ::scobj::nhq_200::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "nhq_200"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase [SplitReply [detector_simulation]] "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${ns}::sics_log 9 "[detector_simulation] => using null asyncqueue" } elseif { [dict exists $v "asyncqueue"] } { set asyncqueue [dict get $v "asyncqueue"] if { [string equal -nocase ${asyncqueue} "sct"] } { diff --git a/site_ansto/instrument/config/environment/temperature/sct_lakeshore_218.tcl b/site_ansto/instrument/config/environment/temperature/sct_lakeshore_218.tcl index f01dc469..60da9895 100644 --- a/site_ansto/instrument/config/environment/temperature/sct_lakeshore_218.tcl +++ b/site_ansto/instrument/config/environment/temperature/sct_lakeshore_218.tcl @@ -164,7 +164,7 @@ proc ::scobj::lakeshore_218::mkDriver { sct_controller name ip_address tcp_port MakeSICSObj ${name} SCT_OBJECT - sicslist setatt ${name} klass environment + sicslist setatt ${name} klass NXdetector sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} @@ -186,10 +186,10 @@ proc ::scobj::lakeshore_218::mkDriver { sct_controller name ip_address tcp_port hsetprop ${scobj_hpath} klass "@none" hsetprop ${scobj_hpath} type "part" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase [SplitReply [detector_simulation]] "false"]} { ${sct_controller} poll ${scobj_hpath}/krdg 1 } else { - ::scobj::lakeshore_218::sics_log 9 "[environment_simulation] => No poll/write for lakeshore_218" + ::scobj::lakeshore_218::sics_log 9 "[detector_simulation] => No poll/write for lakeshore_218" } hfactory ${scobj_hpath}/sensor plain spy none @@ -301,7 +301,7 @@ proc ::scobj::lakeshore_218::mkDriver { sct_controller name ip_address tcp_port hsetprop ${scobj_hpath}/sensor/ch8 type "part" hsetprop ${scobj_hpath}/sensor/ch8 nxalias "${name}_sensor_ch8" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase [SplitReply [detector_simulation]] "false"]} { ${sct_controller} poll ${scobj_hpath}/sensor/ch1 1 ${sct_controller} poll ${scobj_hpath}/sensor/ch2 1 ${sct_controller} poll ${scobj_hpath}/sensor/ch3 1 @@ -311,9 +311,9 @@ proc ::scobj::lakeshore_218::mkDriver { sct_controller name ip_address tcp_port ${sct_controller} poll ${scobj_hpath}/sensor/ch7 1 ${sct_controller} poll ${scobj_hpath}/sensor/ch8 1 } else { - ::scobj::lakeshore_218::sics_log 9 "[environment_simulation] => No poll/write for lakeshore_218" + ::scobj::lakeshore_218::sics_log 9 "[detector_simulation] => No poll/write for lakeshore_218" } - hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} klass NXdetector hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 # mkDriver hook code goes here @@ -331,7 +331,7 @@ namespace eval ::scobj::lakeshore_218 { proc add_lakeshore_218 {name ip_address tcp_port} { set catch_status [ catch { ::scobj::lakeshore_218::sics_log 9 "add_lakeshore_218 ${name} ${ip_address} ${tcp_port}" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase [SplitReply [detector_simulation]] "false"]} { if {[string equal -nocase "aqadapter" "${ip_address}"]} { ::scobj::lakeshore_218::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" makesctcontroller sct_${name} aqadapter ${tcp_port} @@ -340,7 +340,7 @@ proc add_lakeshore_218 {name ip_address tcp_port} { makesctcontroller sct_${name} std ${ip_address}:${tcp_port} } } else { - ::scobj::lakeshore_218::sics_log 9 "[environment_simulation] => No sctcontroller for lakeshore_218" + ::scobj::lakeshore_218::sics_log 9 "[detector_simulation] => No sctcontroller for lakeshore_218" } ::scobj::lakeshore_218::sics_log 1 "::scobj::lakeshore_218::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port}" ::scobj::lakeshore_218::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} @@ -373,9 +373,9 @@ proc ::scobj::lakeshore_218::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "lakeshore_218"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase [SplitReply [detector_simulation]] "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${ns}::sics_log 9 "[detector_simulation] => using null asyncqueue" } elseif { [dict exists $v "asyncqueue"] } { set asyncqueue [dict get $v "asyncqueue"] if { [string equal -nocase ${asyncqueue} "sct"] } { diff --git a/site_ansto/instrument/config/environment/temperature/sct_srs_sr630.tcl b/site_ansto/instrument/config/environment/temperature/sct_srs_sr630.tcl index d9d11943..3f31e76d 100644 --- a/site_ansto/instrument/config/environment/temperature/sct_srs_sr630.tcl +++ b/site_ansto/instrument/config/environment/temperature/sct_srs_sr630.tcl @@ -198,7 +198,7 @@ proc ::scobj::srs_sr630::mkDriver { sct_controller name ip_address tcp_port } { MakeSICSObj ${name} SCT_OBJECT - sicslist setatt ${name} klass environment + sicslist setatt ${name} klass NXdetector sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} @@ -325,7 +325,7 @@ proc ::scobj::srs_sr630::mkDriver { sct_controller name ip_address tcp_port } { hsetprop ${scobj_hpath} klass "@none" hsetprop ${scobj_hpath} type "part" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase [SplitReply [detector_simulation]] "false"]} { ${sct_controller} poll ${scobj_hpath}/id 600 ${sct_controller} poll ${scobj_hpath}/sensor_01 60 ${sct_controller} poll ${scobj_hpath}/sensor_02 600 @@ -336,9 +336,9 @@ proc ::scobj::srs_sr630::mkDriver { sct_controller name ip_address tcp_port } { ${sct_controller} poll ${scobj_hpath}/sensor_07 600 ${sct_controller} poll ${scobj_hpath}/sensor_08 600 } else { - ::scobj::srs_sr630::sics_log 9 "[environment_simulation] => No poll/write for srs_sr630" + ::scobj::srs_sr630::sics_log 9 "[detector_simulation] => No poll/write for srs_sr630" } - hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} klass NXdetector hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 # mkDriver hook code goes here @@ -356,7 +356,7 @@ namespace eval ::scobj::srs_sr630 { proc add_srs_sr630 {name ip_address tcp_port} { set catch_status [ catch { ::scobj::srs_sr630::sics_log 9 "add_srs_sr630 ${name} ${ip_address} ${tcp_port}" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase [SplitReply [detector_simulation]] "false"]} { if {[string equal -nocase "aqadapter" "${ip_address}"]} { ::scobj::srs_sr630::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" makesctcontroller sct_${name} aqadapter ${tcp_port} @@ -365,7 +365,7 @@ proc add_srs_sr630 {name ip_address tcp_port} { makesctcontroller sct_${name} std ${ip_address}:${tcp_port} } } else { - ::scobj::srs_sr630::sics_log 9 "[environment_simulation] => No sctcontroller for srs_sr630" + ::scobj::srs_sr630::sics_log 9 "[detector_simulation] => No sctcontroller for srs_sr630" } ::scobj::srs_sr630::sics_log 1 "::scobj::srs_sr630::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port}" ::scobj::srs_sr630::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} @@ -398,9 +398,9 @@ proc ::scobj::srs_sr630::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "srs_sr630"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase [SplitReply [detector_simulation]] "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${ns}::sics_log 9 "[detector_simulation] => using null asyncqueue" } elseif { [dict exists $v "asyncqueue"] } { set asyncqueue [dict get $v "asyncqueue"] if { [string equal -nocase ${asyncqueue} "sct"] } { From 377405d2a4ca25f16212857c43c9d3fe4d8508dd Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Wed, 10 Sep 2014 14:39:00 +1000 Subject: [PATCH 34/68] Pullback ls340_pelican and ls218 changes on Pelican --- .../instrument/pelican/util/sics_config.ini | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/site_ansto/instrument/pelican/util/sics_config.ini b/site_ansto/instrument/pelican/util/sics_config.ini index 53dfc3e2..e2576474 100644 --- a/site_ansto/instrument/pelican/util/sics_config.ini +++ b/site_ansto/instrument/pelican/util/sics_config.ini @@ -8,7 +8,7 @@ enabled = False cascade = T1:ls336_01,T2:ls340_11,sample_stage:normal_sample_stage enabled = False [Default] -cascade = sample_stage:normal_sample_stage +cascade = sample_stage:normal_sample_stage,T1:ls340_pelican enabled = True [OC1] cascade = T1:OC1_ls340,sample_stage:normal_sample_stage @@ -43,9 +43,9 @@ name = curr2 optype = multimeter [T1] datype = T -enabled = False +enabled = True id = 1 -implementation = none +implementation = ls340_pelican name = tc1 optype = temperature [T2] @@ -83,6 +83,11 @@ id = 2 implementation = none name = volts2 optype = multimeter +[ls218] +enabled = Always +implementation = ls218-01 +name = ls218 +optype = lakeshore_218 [sample_stage] enabled = Always implementation = normal_sample_stage @@ -120,6 +125,13 @@ imptype = function_generator ip = 10.157.205.16 port = 5025 +[ls218-01] +desc = "Lakeshore 218 Temperature Monitor" +driver = "lakeshore_218" +imptype = lakeshore_218 +ip = ca2-pelican +port = 4002 + [ls336_01] asyncqueue = sct desc = "Lakeshore 336 temperature controller" From b0812e5feaf4131221012b311cd8626700e3c76e Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Wed, 10 Sep 2014 14:57:07 +1000 Subject: [PATCH 35/68] Pullback Bilby sics_config.ini to new bilby/util directory --- site_ansto/instrument/bilby/util/sics_config.ini | 11 +++++++++++ 1 file changed, 11 insertions(+) create mode 100644 site_ansto/instrument/bilby/util/sics_config.ini diff --git a/site_ansto/instrument/bilby/util/sics_config.ini b/site_ansto/instrument/bilby/util/sics_config.ini new file mode 100644 index 00000000..462d7341 --- /dev/null +++ b/site_ansto/instrument/bilby/util/sics_config.ini @@ -0,0 +1,11 @@ +[disk_chopper] +enabled = Always +implementation = astrium_chopper +name = chopper +optype = disk_chopper +[astrium_chopper] +driver = astrium_chopper +imptype = disk_chopper +ip = 137.157.203.39 +port = 3302 +terminator = \r\n From 5ce867719548538807f3f73a53ba9618fb40abe4 Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Wed, 10 Sep 2014 15:15:20 +1000 Subject: [PATCH 36/68] Pull back config changes from Wombat and add the west_6100 blue furnaces --- .../instrument/hipd/util/sics_config.ini | 41 ++++++++++++++++--- 1 file changed, 36 insertions(+), 5 deletions(-) diff --git a/site_ansto/instrument/hipd/util/sics_config.ini b/site_ansto/instrument/hipd/util/sics_config.ini index 6e3403e8..ab40aac9 100644 --- a/site_ansto/instrument/hipd/util/sics_config.ini +++ b/site_ansto/instrument/hipd/util/sics_config.ini @@ -103,7 +103,6 @@ implementation = normal_sample_stage name = sample_stage optype = motion_axis [12tmagnet_oxford] -asyncqueue = sct desc = "12 Tesla Oxford Magnet" driver = "oxford_labview" imptype = magnetic_field @@ -130,6 +129,7 @@ desc = "Function Generator" driver = agilent_33220A imptype = function_generator ip = 10.157.205.16 +name = pulser port = 5025 [eularian_cradle] @@ -185,7 +185,7 @@ asyncqueue = sct desc = "Lakeshore 336 temperature controller" driver = "ls336" imptype = temperature -ip = 137.157.201.21 +ip = 10.157.205.30 port = 7777 terminator = \r\n tol1 = 1.0 @@ -290,10 +290,41 @@ port = 4001 desc = "Load the small omega configuration" imptype = motion_axis -[west4100] -desc = "Blue furnace temperature controller" +[vf1_west4100] +asyncqueue = sct +desc = "VF1 Blue furnace temperature controller" dev_id = 1 driver = "west4100" imptype = temperature -ip = 10.157.205.19 +ip = 10.157.205.24 +port = 502 + +[vf1_west6100] +asyncprotocol = modbus_ap +desc = "VF1 Blue furnace 6100 temperature controller" +dev_id = 1 +driver = "west_6100" +imptype = temperature +ip = 10.157.205.24 +port = 502 +timeout = 2000 + +[vf2_west4100] +asyncqueue = sct +desc = "VF2 Blue furnace temperature controller" +dev_id = 1 +driver = "west4100" +imptype = temperature +ip = 10.157.205.25 +port = 502 + +[vf2_west6100] +asyncprotocol = modbus_ap +desc = "VF2 Blue furnace 6100 temperature controller" +dev_id = 1 +driver = "west_6100" +imptype = temperature +ip = 10.157.205.25 +port = 502 +timeout = 2000 From f4eb6c63d83770194c0438275043d64eb398dd0e Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Wed, 10 Sep 2014 15:15:53 +1000 Subject: [PATCH 37/68] Pullback sics_config changes from Quokka --- .../instrument/sans/util/sics_config.ini | 37 ++++++++++++++++++- 1 file changed, 36 insertions(+), 1 deletion(-) diff --git a/site_ansto/instrument/sans/util/sics_config.ini b/site_ansto/instrument/sans/util/sics_config.ini index 7257c7a3..2f4734ef 100644 --- a/site_ansto/instrument/sans/util/sics_config.ini +++ b/site_ansto/instrument/sans/util/sics_config.ini @@ -4,6 +4,9 @@ enabled = False [12Tmagnet_setup] cascade = B1:12tmagnet_oxford,sample_stage:Oxford_12tmagnet_sample_insert,T1:mercury_scpi_01 enabled = False +[20_position_pulser] +cascade = T1:julabo_lh45,Function_Generator:agilent_33220A,High_Voltage:protek_02,sample_stage:20_pos_sample_stage +enabled = False [20_position_setup] cascade = T1:julabo_lh45,sample_stage:20_pos_sample_stage enabled = False @@ -70,6 +73,13 @@ id = 2 implementation = none name = curr2 optype = multimeter +[Power Supply] +datype = V +enabled = False +id = 1 +implementation = none +name = isops +optype = power_supply [Rheometry] enabled = False implementation = none @@ -155,11 +165,19 @@ optype = motion_axis desc = "Load the ten position sample changer configuration" imptype = motion_axis +[11tmagnet_oxford] +desc = "11/10 Tesla Oxford Magnet" +driver = "oxford_labview" +imptype = magnetic_field +interval = 5 +ip = 10.157.205.44 +port = 55001 + [12tmagnet_oxford] -asyncqueue = sct desc = "12 Tesla Oxford Magnet" driver = "oxford_labview" imptype = magnetic_field +interval = 5 ip = 10.157.205.3 port = 55001 @@ -217,6 +235,13 @@ ip = 10.157.205.13 port = 4444 type = B +[isotech_ps] +desc = "Isotech Power Supply:Baud=2400,Data=8,Stop=1,Parity=None,Flow=None" +driver = "isotech_ps" +imptype = power_supply +ip = 137.157.202.79 +port = 4001 + [julabo_lh45] ctrl_sensor = "bath" desc = "Julabo temperature controller" @@ -315,6 +340,16 @@ terminator = \r\n tol1 = 1.0 tol2 = 1.0 +[ls340_09] +desc = "Lakeshore 340 temperature controller" +driver = "ls340" +imptype = temperature +ip = 137.157.202.79 +port = 4002 +terminator = \r\n +tol1 = 1.0 +tol2 = 1.0 + [ls340_11] desc = "Lakeshore 340 temperature controller" driver = "ls340" From d1920069aecff8a2c02c4f24d0b94b69bd75ecb4 Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Wed, 10 Sep 2014 15:25:26 +1000 Subject: [PATCH 38/68] Pullback motor changes on Taipan --- .../tas/config/motors/motor_configuration.tcl | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/site_ansto/instrument/tas/config/motors/motor_configuration.tcl b/site_ansto/instrument/tas/config/motors/motor_configuration.tcl index 1268994e..b37eaad2 100644 --- a/site_ansto/instrument/tas/config/motors/motor_configuration.tcl +++ b/site_ansto/instrument/tas/config/motors/motor_configuration.tcl @@ -229,7 +229,7 @@ Motor m2 $motor_driver_type [params \ port pmc1-taipan\ axis F\ units degrees\ - precision 0.01\ + precision 0.001\ hardlowerlim 17\ hardupperlim 80\ maxSpeed 0.414\ @@ -246,9 +246,9 @@ m2 softupperlim 80 m2 home 20 m2 motOnDelay 0 m2 motOffDelay 0 -m2 backlash_offset -0.1 +m2 backlash_offset -0.5 m2 creep_offset 0.1 -m2 creep_precision 0.005 +m2 creep_precision 0.0 m2 speed 0.4 m2 accel 0.04 m2 decel 0.04 @@ -533,7 +533,7 @@ Motor mhfocus $motor_driver_type [params \ maxSpeed 3.6\ maxAccel 1.728\ maxDecel 1.728\ - stepsPerX [expr -25000.0 * 50.0 / 360.0]\ + stepsPerX [expr 25000.0 * 50.0 / 360.0]\ absEnc 1\ bias_bits 12\ bias_bias 1540\ @@ -563,13 +563,13 @@ Motor m1 $motor_driver_type [params \ maxDecel 0.25\ stepsPerX 100000\ absEnc 1\ - absEncHome 16189898\ + absEncHome 16323070\ cntsPerX -2048] m1 part crystal m1 long_name m1 m1 softlowerlim 5 m1 softupperlim 40 -m1 home 0 +m1 home 20.45933 m1 backlash_offset -1.0 # mc4: Analyzer Tilt 1 -- Two-theta Angle From 1fa1595821d6ed68136a260c3ea6b0f5d0af4081 Mon Sep 17 00:00:00 2001 From: Ferdi Franceschini Date: Wed, 10 Sep 2014 15:58:54 +1000 Subject: [PATCH 39/68] SICS-733 Added gumtree_version, gumtree_status and gumtree_time_estimate to /experiment. Only gumtree_version is saved to the hdf file. --- site_ansto/instrument/server_config.tcl | 3 +++ 1 file changed, 3 insertions(+) diff --git a/site_ansto/instrument/server_config.tcl b/site_ansto/instrument/server_config.tcl index 8f4b5908..64e1ece4 100644 --- a/site_ansto/instrument/server_config.tcl +++ b/site_ansto/instrument/server_config.tcl @@ -204,6 +204,9 @@ SicsDataPath lock ::utility::mkVar Email Text user email true user true true ::utility::mkVar Phone Text user phone true user true true ::utility::mkVar starttime Text user start true experiment true true +::utility::mkVar gumtree_version Text user gumtree_version true experiment true true +::utility::mkVar gumtree_status Text user gumtree_status true experiment true false +::utility::mkVar gumtree_time_estimate float user gumtree_time_estimate true experiment true false exe batchpath ../batch exe syspath ../batch From 8b4bcc4c9eb5345adf54b5e573bd3757364b55a4 Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Wed, 10 Sep 2014 17:01:50 +1000 Subject: [PATCH 40/68] Pelican does not currently have a PLC interface --- site_ansto/instrument/pelican/config/plc/plc.tcl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site_ansto/instrument/pelican/config/plc/plc.tcl b/site_ansto/instrument/pelican/config/plc/plc.tcl index 3fd03f03..16245347 100644 --- a/site_ansto/instrument/pelican/config/plc/plc.tcl +++ b/site_ansto/instrument/pelican/config/plc/plc.tcl @@ -1,5 +1,5 @@ #FIXME Does pelican have a PLC interface? -plc_simulation false +plc_simulation true set sim_mode [SplitReply [plc_simulation]] From 65b50f3fccb484f0c2e2658874f69504ca0a26b1 Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Thu, 11 Sep 2014 13:27:09 +1000 Subject: [PATCH 41/68] Allow sct drivers to get device_class and simulation_group from ini file --- site_ansto/instrument/util/gen_sct.py | 86 +++++++++++++++++---------- 1 file changed, 54 insertions(+), 32 deletions(-) diff --git a/site_ansto/instrument/util/gen_sct.py b/site_ansto/instrument/util/gen_sct.py index 4b9c9b70..3cddcfc8 100755 --- a/site_ansto/instrument/util/gen_sct.py +++ b/site_ansto/instrument/util/gen_sct.py @@ -1364,7 +1364,7 @@ def put_group(MyDriver, MyGroup): txt += [' hsetprop ${scobj_hpath} %s "%s"' % (key, MyGroup['GroupProperty'][key])] if readable_or_writeable: txt += [''] - txt += [' if {[string equal -nocase [SplitReply [%s]] "false"]} {' % MyDriver['simulation_group']] + txt += [' if {[string equal -nocase "${simulation_flag}" "false"]} {'] for var in sorted(MyGroup['Vars']): MyVar = MyGroup['Vars'][var] nodename = groupname + MyVar['name'] @@ -1385,7 +1385,7 @@ def put_group(MyDriver, MyGroup): driveable = '${name}_' + make_path(MyVar) MyDriver['Deferred'] += ['ansto_makesctdrive %s ${scobj_hpath}/%s ${scobj_hpath}/%s ${sct_controller}' % (driveable, nodename, MyVar['driveable'])] txt += [' } else {'] - txt += [' %s::sics_log 9 "[%s] => No poll/write for %s"' % (MyDriver['namespace'], MyDriver['simulation_group'], MyDriver['name'])] + txt += [' %s::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for %s"' % (MyDriver['namespace'], MyDriver['name'])] txt += [' }'] for grp in sorted(MyGroup['Groups']): txt += put_group(MyDriver, MyGroup['Groups'][grp]) @@ -1394,15 +1394,15 @@ def put_group(MyDriver, MyGroup): def put_mkDriver(MyDriver): txt = [''] if 'make_args' in MyDriver: - line = 'proc %s::mkDriver { sct_controller name ip_address tcp_port %s } {' % (MyDriver['namespace'], MyDriver['make_args']) + line = 'proc %s::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port %s } {' % (MyDriver['namespace'], MyDriver['make_args']) else: - line = 'proc %s::mkDriver { sct_controller name ip_address tcp_port } {' % (MyDriver['namespace']) + line = 'proc %s::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port } {' % (MyDriver['namespace']) txt += [line] if 'make_args' in MyDriver: make_args = ' '.join(["${%s}"%arg for arg in MyDriver['make_args'].split()]) - txt += [' %s::sics_log 9 "%s::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port} %s"' % (MyDriver['namespace'], MyDriver['namespace'], make_args)] + txt += [' %s::sics_log 9 "%s::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} %s"' % (MyDriver['namespace'], MyDriver['namespace'], make_args)] else: - txt += [' %s::sics_log 9 "%s::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port}"' % (MyDriver['namespace'], MyDriver['namespace'])] + txt += [' %s::sics_log 9 "%s::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}"' % (MyDriver['namespace'], MyDriver['namespace'])] txt += [' set ns "[namespace current]"'] txt += [' set catch_status [ catch {'] txt += [''] @@ -1425,7 +1425,7 @@ def put_mkDriver(MyDriver): ms_line = ' MakeSICSObj ${name} SCT_OBJECT' txt += [ms_line] txt += [''] - txt += [' sicslist setatt ${name} klass %s' % MyDriver['class']] + txt += [' sicslist setatt ${name} klass ${device_class}'] txt += [' sicslist setatt ${name} long_name ${name}'] if 'DriverProperty' in MyDriver: for key in MyDriver['DriverProperty']: @@ -1436,11 +1436,11 @@ def put_mkDriver(MyDriver): for group in sorted(MyDriver['Groups']): txt += put_group(MyDriver, MyDriver['Groups'][group]) - txt += [' hsetprop ${scobj_hpath} klass %s' % MyDriver['class']] + txt += [' hsetprop ${scobj_hpath} klass ${device_class}'] txt += [' hsetprop ${scobj_hpath} data true'] txt += [' hsetprop ${scobj_hpath} debug_threshold %s' % str(MyDriver['debug_threshold'])] if len(MyDriver['Deferred']) > 0: - txt += [' if {[string equal -nocase [SplitReply [%s]] "false"]} {' % MyDriver['simulation_group']] + txt += [' if {[string equal -nocase "${simulation_flag}" "false"]} {'] for line in MyDriver['Deferred']: txt += [' ' + line] txt += [' }'] @@ -1458,28 +1458,21 @@ def put_mkDriver(MyDriver): def put_postamble(MyDriver): txt = [''] - txt += ['namespace eval %s {' % MyDriver['namespace']] - txt += [' namespace export debug_threshold'] - txt += [' namespace export debug_log'] - txt += [' namespace export sics_log'] - txt += [' namespace export mkDriver'] - txt += ['}'] - txt += [''] if 'add_args' in MyDriver: - line = 'proc add_%s {name ip_address tcp_port %s} {' % (MyDriver['name'], MyDriver['add_args']) + line = 'proc %s::add_driver {name device_class simulation_flag ip_address tcp_port %s} {' % (MyDriver['namespace'], MyDriver['add_args']) else: - line = 'proc add_%s {name ip_address tcp_port} {' % MyDriver['name'] + line = 'proc %s::add_driver {name device_class simulation_flag ip_address tcp_port} {' % (MyDriver['namespace']) txt += [line] txt += [' set catch_status [ catch {'] if 'make_args' in MyDriver: make_args = ' '.join(["${%s}"%arg for arg in MyDriver['make_args'].split()]) - txt += [' %s::sics_log 9 "add_%s ${name} ${ip_address} ${tcp_port} %s"' % (MyDriver['namespace'], MyDriver['name'], make_args)] + txt += [' %s::sics_log 9 "%s::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} %s"' % (MyDriver['namespace'], MyDriver['namespace'], make_args)] else: - txt += [' %s::sics_log 9 "add_%s ${name} ${ip_address} ${tcp_port}"' % (MyDriver['namespace'], MyDriver['name'])] + txt += [' %s::sics_log 9 "%s::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}"' % (MyDriver['namespace'], MyDriver['namespace'])] if ('WrapperProperty' in MyDriver) and ('nosctcontroller' in MyDriver['WrapperProperty']): txt += [' %s::sics_log 9 "No sctcontroller for %s"' % (MyDriver['namespace'], MyDriver['name'])] else: - txt += [' if {[string equal -nocase [SplitReply [%s]] "false"]} {' % MyDriver['simulation_group']] + txt += [' if {[string equal -nocase "${simulation_flag}" "false"]} {'] txt += [' if {[string equal -nocase "aqadapter" "${ip_address}"]} {'] txt += [' %s::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}"' % MyDriver['namespace']] txt += [' makesctcontroller sct_${name} aqadapter ${tcp_port}'] @@ -1493,15 +1486,15 @@ def put_postamble(MyDriver): txt += [' makesctcontroller sct_${name} %s ${ip_address}:${tcp_port}' % MyDriver['protocol']] txt += [' }'] txt += [' } else {'] - txt += [' %s::sics_log 9 "[%s] => No sctcontroller for %s"' % (MyDriver['namespace'], MyDriver['simulation_group'], MyDriver['name'])] + txt += [' %s::sics_log 9 "simulation_flag={simulation_flag} => No sctcontroller for %s"' % (MyDriver['namespace'], MyDriver['name'])] txt += [' }'] if 'make_args' in MyDriver: make_args = ' '.join(["${%s}"%arg for arg in MyDriver['make_args'].split()]) - txt += [' %s::sics_log 1 "%s::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} %s"' % (MyDriver['namespace'], MyDriver['namespace'], make_args)] - txt += [' %s::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} %s' % (MyDriver['namespace'], make_args)] + txt += [' %s::sics_log 1 "%s::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} %s"' % (MyDriver['namespace'], MyDriver['namespace'], make_args)] + txt += [' %s::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} %s' % (MyDriver['namespace'], make_args)] else: - txt += [' %s::sics_log 1 "%s::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port}"' % (MyDriver['namespace'], MyDriver['namespace'])] - txt += [' %s::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port}' % (MyDriver['namespace'])] + txt += [' %s::sics_log 1 "%s::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}"' % (MyDriver['namespace'], MyDriver['namespace'])] + txt += [' %s::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}' % (MyDriver['namespace'])] # TODO #txt += [' %s::sics_log "makesctemon ${name} /sics/${name}/emon/monmode /sics/${name}/emon/isintol /sics/${name}/emon/errhandler"' % (MyDriver['namespace'])] # txt += [' makesctemon ${name} /sics/${name}/emon/monmode /sics/${name}/emon/isintol /sics/${name}/emon/errhandler'] @@ -1509,6 +1502,27 @@ def put_postamble(MyDriver): txt += [' handle_exception ${catch_status} ${catch_message}'] txt += ['}'] txt += [''] + txt += ['namespace eval %s {' % MyDriver['namespace']] + txt += [' namespace export debug_threshold'] + txt += [' namespace export debug_log'] + txt += [' namespace export sics_log'] + txt += [' namespace export mkDriver'] + txt += [' namespace export add_driver'] + txt += ['}'] + txt += [''] + if 'add_args' in MyDriver: + line = 'proc add_%s {name ip_address tcp_port %s} {' % (MyDriver['name'], MyDriver['add_args']) + else: + line = 'proc add_%s {name ip_address tcp_port} {' % MyDriver['name'] + txt += [line] + txt += [' set simulation_flag "[string tolower [SplitReply [%s]]]"' % MyDriver['simulation_group']] + line = ' %s::add_driver ${name} "%s" "${simulation_flag}" ${ip_address} ${tcp_port}' % (MyDriver['namespace'], MyDriver['class']) + if 'add_args' in MyDriver: + for arg in MyDriver['add_args'].split(): + line += ' "${%s}"' % arg + txt += [line] + txt += ['}'] + txt += [''] txt += ['clientput "file evaluation of sct_%s.tcl"' % MyDriver['name']] txt += ['%s::sics_log 9 "file evaluation of sct_%s.tcl"' % (MyDriver['namespace'], MyDriver['name'])] emit(txt) @@ -1520,6 +1534,8 @@ def put_read_config(MyDriver): txt += [' set ns "%s"' % MyDriver['namespace']] txt += [' dict for {k u} $::config_dict {'] txt += [' if { [dict exists $u "implementation"] } {'] + txt += [' set simulation_flag "[string tolower [SplitReply [%s]]]"' % MyDriver['simulation_group']] + txt += [' set device_class "%s"' % MyDriver['class']] txt += [' if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } {'] txt += [' continue'] txt += [' }'] @@ -1527,6 +1543,12 @@ def put_read_config(MyDriver): txt += [' if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } {'] txt += [' continue'] txt += [' }'] + txt += [' if { [dict exists $u "simulation_group"] } {'] + txt += [' set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]]'] + txt += [' }'] + txt += [' if { [dict exists $u "device_class"] } {'] + txt += [' set device_class "[dict get $u "device_class"]"'] + txt += [' }'] txt += [' set name [dict get $u name]'] txt += [' set implementation [dict get $u "implementation"]'] txt += [' if { !([dict exists $::config_dict $implementation]) } {'] @@ -1537,9 +1559,9 @@ def put_read_config(MyDriver): txt += [' continue'] txt += [' }'] txt += [' if { [string equal -nocase [dict get $v "driver"] "%s"] } {' % MyDriver['name']] - txt += [' if { ![string equal -nocase [SplitReply [%s]] "false"] } {' % MyDriver['simulation_group']] + txt += [' if { ![string equal -nocase "${simulation_flag}" "false"] } {'] txt += [' set asyncqueue "null"'] - txt += [' ${ns}::sics_log 9 "[%s] => using null asyncqueue"' % MyDriver['simulation_group']] + txt += [' ${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue"'] txt += [' } elseif { [dict exists $v "asyncqueue"] } {'] txt += [' set asyncqueue [dict get $v "asyncqueue"]'] txt += [' if { [string equal -nocase ${asyncqueue} "sct"] } {'] @@ -1582,15 +1604,15 @@ def put_read_config(MyDriver): txt += [' error "$name is missing configuration values $missing_list"'] txt += [' }'] txt += [' if { [string equal -nocase ${asyncqueue} "sct"] } {'] - txt += [' add_%s ${name} ${ip_address} ${tcp_port} {*}$arg_list' % MyDriver['name']] + txt += [' ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list'] txt += [' } else {'] - txt += [' add_%s ${name} "aqadapter" ${asyncqueue} {*}$arg_list' % MyDriver['name']] + txt += [' ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list'] txt += [' }'] else: txt += [' if { [string equal -nocase ${asyncqueue} "sct"] } {'] - txt += [' add_%s ${name} ${ip_address} ${tcp_port}' % MyDriver['name']] + txt += [' ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}'] txt += [' } else {'] - txt += [' add_%s ${name} "aqadapter" ${asyncqueue}' % MyDriver['name']] + txt += [' ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue}'] txt += [' }'] txt += [' }'] txt += [' }'] From 0cb3f4f91c02bce3c5af6dfbfa720327e31205d6 Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Thu, 11 Sep 2014 13:29:52 +1000 Subject: [PATCH 42/68] Regenerated drivers --- .../config/chopper/sct_astrium_chopper.tcl | 80 ++++++++++-------- .../bilby/config/motors/sct_shutters.tcl | 68 +++++++++------ .../bilby/config/motors/sct_tank.tcl | 68 +++++++++------ .../sct_green_magnet_labview.tcl | 40 ++++++--- .../magneticField/sct_oxford12tlv.tcl | 56 ++++++++----- .../environment/magneticField/sct_tsi_smc.tcl | 78 ++++++++++-------- .../config/environment/sct_agilent_33220A.tcl | 40 ++++++--- .../config/environment/sct_hiden_xcs.tcl | 74 ++++++++++------- .../config/environment/sct_huber_pilot.tcl | 70 +++++++++------- .../config/environment/sct_isotech_ps.tcl | 68 +++++++++------ .../config/environment/sct_keithley_m2700.tcl | 56 ++++++++----- .../config/environment/sct_nhq_200.tcl | 78 ++++++++++-------- .../config/environment/sct_omron_hldc.tcl | 68 +++++++++------ .../config/environment/sct_protekmm.tcl | 56 ++++++++----- .../temperature/sct_eurotherm_m2000.tcl | 56 ++++++++----- .../temperature/sct_julabo_lh45_gen.tcl | 70 +++++++++------- .../temperature/sct_lakeshore_218.tcl | 72 +++++++++------- .../temperature/sct_lakeshore_m370.tcl | 56 ++++++++----- .../environment/temperature/sct_ls336.tcl | 56 ++++++++----- .../environment/temperature/sct_ls340.tcl | 56 ++++++++----- .../temperature/sct_mercury_base.tcl | 70 +++++++++------- .../temperature/sct_mercury_level.tcl | 68 +++++++++------ .../temperature/sct_mercury_pres.tcl | 70 +++++++++------- .../temperature/sct_mercury_scpi.tcl | 82 +++++++++++-------- .../temperature/sct_mercury_temp.tcl | 70 +++++++++------- .../temperature/sct_mercury_valve.tcl | 70 +++++++++------- .../environment/temperature/sct_nprvasm2.tcl | 56 ++++++++----- .../temperature/sct_pfeiffer_hg.tcl | 62 ++++++++------ .../environment/temperature/sct_srs_sr630.tcl | 68 +++++++++------ .../temperature/sct_watlow_mpm.tcl | 56 ++++++++----- .../temperature/sct_watlow_mrm.tcl | 56 ++++++++----- .../temperature/sct_watlow_mst4.tcl | 56 ++++++++----- .../environment/temperature/sct_west4100.tcl | 40 ++++++--- .../environment/temperature/sct_west_6100.tcl | 72 +++++++++------- .../config/robots/sct_epson_pandp.tcl | 40 ++++++--- .../config/source/sct_reactor_status.tcl | 68 +++++++++------ 36 files changed, 1387 insertions(+), 883 deletions(-) diff --git a/site_ansto/instrument/bilby/config/chopper/sct_astrium_chopper.tcl b/site_ansto/instrument/bilby/config/chopper/sct_astrium_chopper.tcl index ee696490..d0c0c135 100644 --- a/site_ansto/instrument/bilby/config/chopper/sct_astrium_chopper.tcl +++ b/site_ansto/instrument/bilby/config/chopper/sct_astrium_chopper.tcl @@ -230,14 +230,14 @@ proc ::scobj::astrium_chopper::setValue {tc_root nextState cmd_str} { handle_exception ${catch_status} ${catch_message} } -proc ::scobj::astrium_chopper::mkDriver { sct_controller name ip_address tcp_port } { - ::scobj::astrium_chopper::sics_log 9 "::scobj::astrium_chopper::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port}" +proc ::scobj::astrium_chopper::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port } { + ::scobj::astrium_chopper::sics_log 9 "::scobj::astrium_chopper::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT - sicslist setatt ${name} klass NXdisk_chopper + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} @@ -316,10 +316,10 @@ proc ::scobj::astrium_chopper::mkDriver { sct_controller name ip_address tcp_por hsetprop ${scobj_hpath}/blade_1/state type "part" hsetprop ${scobj_hpath}/blade_1/state nxalias "${name}_blade_1_state" - if {[string equal -nocase [SplitReply [chopper_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/blade_1/state 1 } else { - ::scobj::astrium_chopper::sics_log 9 "[chopper_simulation] => No poll/write for astrium_chopper" + ::scobj::astrium_chopper::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for astrium_chopper" } hfactory ${scobj_hpath}/blade_2 plain spy none @@ -396,10 +396,10 @@ proc ::scobj::astrium_chopper::mkDriver { sct_controller name ip_address tcp_por hsetprop ${scobj_hpath}/blade_2/state type "part" hsetprop ${scobj_hpath}/blade_2/state nxalias "${name}_blade_2_state" - if {[string equal -nocase [SplitReply [chopper_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/blade_2/state 1 } else { - ::scobj::astrium_chopper::sics_log 9 "[chopper_simulation] => No poll/write for astrium_chopper" + ::scobj::astrium_chopper::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for astrium_chopper" } hfactory ${scobj_hpath}/blade_3 plain spy none @@ -476,10 +476,10 @@ proc ::scobj::astrium_chopper::mkDriver { sct_controller name ip_address tcp_por hsetprop ${scobj_hpath}/blade_3/state type "part" hsetprop ${scobj_hpath}/blade_3/state nxalias "${name}_blade_3_state" - if {[string equal -nocase [SplitReply [chopper_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/blade_3/state 1 } else { - ::scobj::astrium_chopper::sics_log 9 "[chopper_simulation] => No poll/write for astrium_chopper" + ::scobj::astrium_chopper::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for astrium_chopper" } hfactory ${scobj_hpath}/blade_4 plain spy none @@ -556,12 +556,12 @@ proc ::scobj::astrium_chopper::mkDriver { sct_controller name ip_address tcp_por hsetprop ${scobj_hpath}/blade_4/state type "part" hsetprop ${scobj_hpath}/blade_4/state nxalias "${name}_blade_4_state" - if {[string equal -nocase [SplitReply [chopper_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/blade_4/state 1 } else { - ::scobj::astrium_chopper::sics_log 9 "[chopper_simulation] => No poll/write for astrium_chopper" + ::scobj::astrium_chopper::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for astrium_chopper" } - hsetprop ${scobj_hpath} klass NXdisk_chopper + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 # mkDriver hook code starts @@ -570,31 +570,37 @@ proc ::scobj::astrium_chopper::mkDriver { sct_controller name ip_address tcp_por handle_exception ${catch_status} ${catch_message} } +proc ::scobj::astrium_chopper::add_driver {name device_class simulation_flag ip_address tcp_port} { + set catch_status [ catch { + ::scobj::astrium_chopper::sics_log 9 "::scobj::astrium_chopper::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" + if {[string equal -nocase "${simulation_flag}" "false"]} { + if {[string equal -nocase "aqadapter" "${ip_address}"]} { + ::scobj::astrium_chopper::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" + makesctcontroller sct_${name} aqadapter ${tcp_port} + } else { + ::scobj::astrium_chopper::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}" + makesctcontroller sct_${name} std ${ip_address}:${tcp_port} + } + } else { + ::scobj::astrium_chopper::sics_log 9 "simulation_flag={simulation_flag} => No sctcontroller for astrium_chopper" + } + ::scobj::astrium_chopper::sics_log 1 "::scobj::astrium_chopper::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" + ::scobj::astrium_chopper::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + namespace eval ::scobj::astrium_chopper { namespace export debug_threshold namespace export debug_log namespace export sics_log namespace export mkDriver + namespace export add_driver } proc add_astrium_chopper {name ip_address tcp_port} { - set catch_status [ catch { - ::scobj::astrium_chopper::sics_log 9 "add_astrium_chopper ${name} ${ip_address} ${tcp_port}" - if {[string equal -nocase [SplitReply [chopper_simulation]] "false"]} { - if {[string equal -nocase "aqadapter" "${ip_address}"]} { - ::scobj::astrium_chopper::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" - makesctcontroller sct_${name} aqadapter ${tcp_port} - } else { - ::scobj::astrium_chopper::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}" - makesctcontroller sct_${name} std ${ip_address}:${tcp_port} - } - } else { - ::scobj::astrium_chopper::sics_log 9 "[chopper_simulation] => No sctcontroller for astrium_chopper" - } - ::scobj::astrium_chopper::sics_log 1 "::scobj::astrium_chopper::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port}" - ::scobj::astrium_chopper::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} - } catch_message ] - handle_exception ${catch_status} ${catch_message} + set simulation_flag "[string tolower [SplitReply [chopper_simulation]]]" + ::scobj::astrium_chopper::add_driver ${name} "NXdisk_chopper" "${simulation_flag}" ${ip_address} ${tcp_port} } clientput "file evaluation of sct_astrium_chopper.tcl" @@ -605,6 +611,8 @@ proc ::scobj::astrium_chopper::read_config {} { set ns "::scobj::astrium_chopper" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [chopper_simulation]]]" + set device_class "NXdisk_chopper" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -612,6 +620,12 @@ proc ::scobj::astrium_chopper::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -622,9 +636,9 @@ proc ::scobj::astrium_chopper::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "astrium_chopper"] } { - if { ![string equal -nocase [SplitReply [chopper_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[chopper_simulation] => using null asyncqueue" + ${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue" } elseif { [dict exists $v "asyncqueue"] } { set asyncqueue [dict get $v "asyncqueue"] if { [string equal -nocase ${asyncqueue} "sct"] } { @@ -651,9 +665,9 @@ proc ::scobj::astrium_chopper::read_config {} { } } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_astrium_chopper ${name} ${ip_address} ${tcp_port} + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} } else { - add_astrium_chopper ${name} "aqadapter" ${asyncqueue} + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} } } } diff --git a/site_ansto/instrument/bilby/config/motors/sct_shutters.tcl b/site_ansto/instrument/bilby/config/motors/sct_shutters.tcl index 0c209e86..be3528b4 100644 --- a/site_ansto/instrument/bilby/config/motors/sct_shutters.tcl +++ b/site_ansto/instrument/bilby/config/motors/sct_shutters.tcl @@ -193,14 +193,14 @@ proc ::scobj::shutters::write_switch {tc_root nextState cmd_str} { handle_exception ${catch_status} ${catch_message} } -proc ::scobj::shutters::mkDriver { sct_controller name ip_address tcp_port } { - ::scobj::shutters::sics_log 9 "::scobj::shutters::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port}" +proc ::scobj::shutters::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port } { + ::scobj::shutters::sics_log 9 "::scobj::shutters::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT - sicslist setatt ${name} klass instrument + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} @@ -257,16 +257,16 @@ proc ::scobj::shutters::mkDriver { sct_controller name ip_address tcp_port } { hsetprop ${scobj_hpath} nxsave "true" hsetprop ${scobj_hpath} type "part" - if {[string equal -nocase [SplitReply [motor_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/fast_shutter 1 ${sct_controller} poll ${scobj_hpath}/rough_100 1 ${sct_controller} poll ${scobj_hpath}/rough_40 1 ${sct_controller} write ${scobj_hpath}/rough_100 ${sct_controller} write ${scobj_hpath}/rough_40 } else { - ::scobj::shutters::sics_log 9 "[motor_simulation] => No poll/write for shutters" + ::scobj::shutters::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for shutters" } - hsetprop ${scobj_hpath} klass instrument + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 # mkDriver hook code starts @@ -275,31 +275,37 @@ proc ::scobj::shutters::mkDriver { sct_controller name ip_address tcp_port } { handle_exception ${catch_status} ${catch_message} } +proc ::scobj::shutters::add_driver {name device_class simulation_flag ip_address tcp_port} { + set catch_status [ catch { + ::scobj::shutters::sics_log 9 "::scobj::shutters::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" + if {[string equal -nocase "${simulation_flag}" "false"]} { + if {[string equal -nocase "aqadapter" "${ip_address}"]} { + ::scobj::shutters::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" + makesctcontroller sct_${name} aqadapter ${tcp_port} + } else { + ::scobj::shutters::sics_log 9 "makesctcontroller sct_${name} dmc2280 ${ip_address}:${tcp_port}" + makesctcontroller sct_${name} dmc2280 ${ip_address}:${tcp_port} + } + } else { + ::scobj::shutters::sics_log 9 "simulation_flag={simulation_flag} => No sctcontroller for shutters" + } + ::scobj::shutters::sics_log 1 "::scobj::shutters::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" + ::scobj::shutters::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + namespace eval ::scobj::shutters { namespace export debug_threshold namespace export debug_log namespace export sics_log namespace export mkDriver + namespace export add_driver } proc add_shutters {name ip_address tcp_port} { - set catch_status [ catch { - ::scobj::shutters::sics_log 9 "add_shutters ${name} ${ip_address} ${tcp_port}" - if {[string equal -nocase [SplitReply [motor_simulation]] "false"]} { - if {[string equal -nocase "aqadapter" "${ip_address}"]} { - ::scobj::shutters::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" - makesctcontroller sct_${name} aqadapter ${tcp_port} - } else { - ::scobj::shutters::sics_log 9 "makesctcontroller sct_${name} dmc2280 ${ip_address}:${tcp_port}" - makesctcontroller sct_${name} dmc2280 ${ip_address}:${tcp_port} - } - } else { - ::scobj::shutters::sics_log 9 "[motor_simulation] => No sctcontroller for shutters" - } - ::scobj::shutters::sics_log 1 "::scobj::shutters::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port}" - ::scobj::shutters::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} - } catch_message ] - handle_exception ${catch_status} ${catch_message} + set simulation_flag "[string tolower [SplitReply [motor_simulation]]]" + ::scobj::shutters::add_driver ${name} "instrument" "${simulation_flag}" ${ip_address} ${tcp_port} } clientput "file evaluation of sct_shutters.tcl" @@ -310,6 +316,8 @@ proc ::scobj::shutters::read_config {} { set ns "::scobj::shutters" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [motor_simulation]]]" + set device_class "instrument" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -317,6 +325,12 @@ proc ::scobj::shutters::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -327,9 +341,9 @@ proc ::scobj::shutters::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "shutters"] } { - if { ![string equal -nocase [SplitReply [motor_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[motor_simulation] => using null asyncqueue" + ${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue" } elseif { [dict exists $v "asyncqueue"] } { set asyncqueue [dict get $v "asyncqueue"] if { [string equal -nocase ${asyncqueue} "sct"] } { @@ -356,9 +370,9 @@ proc ::scobj::shutters::read_config {} { } } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_shutters ${name} ${ip_address} ${tcp_port} + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} } else { - add_shutters ${name} "aqadapter" ${asyncqueue} + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} } } } diff --git a/site_ansto/instrument/bilby/config/motors/sct_tank.tcl b/site_ansto/instrument/bilby/config/motors/sct_tank.tcl index 9d0f5c72..2ca7adf4 100644 --- a/site_ansto/instrument/bilby/config/motors/sct_tank.tcl +++ b/site_ansto/instrument/bilby/config/motors/sct_tank.tcl @@ -201,14 +201,14 @@ proc ::scobj::tank::setValue {tc_root nextState cmd_str} { handle_exception ${catch_status} ${catch_message} } -proc ::scobj::tank::mkDriver { sct_controller name ip_address tcp_port } { - ::scobj::tank::sics_log 9 "::scobj::tank::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port}" +proc ::scobj::tank::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port } { + ::scobj::tank::sics_log 9 "::scobj::tank::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT - sicslist setatt ${name} klass instrument + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} @@ -230,10 +230,10 @@ proc ::scobj::tank::mkDriver { sct_controller name ip_address tcp_port } { hsetprop ${scobj_hpath} klass "@none" hsetprop ${scobj_hpath} type "part" - if {[string equal -nocase [SplitReply [motor_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/pos 1 } else { - ::scobj::tank::sics_log 9 "[motor_simulation] => No poll/write for tank" + ::scobj::tank::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for tank" } hfactory ${scobj_hpath}/limits plain spy none @@ -267,11 +267,11 @@ proc ::scobj::tank::mkDriver { sct_controller name ip_address tcp_port } { hsetprop ${scobj_hpath}/limits/reverse type "part" hsetprop ${scobj_hpath}/limits/reverse nxalias "${name}_limits_reverse" - if {[string equal -nocase [SplitReply [motor_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/limits/forward 1 ${sct_controller} poll ${scobj_hpath}/limits/reverse 1 } else { - ::scobj::tank::sics_log 9 "[motor_simulation] => No poll/write for tank" + ::scobj::tank::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for tank" } hfactory ${scobj_hpath}/switches plain spy none @@ -305,13 +305,13 @@ proc ::scobj::tank::mkDriver { sct_controller name ip_address tcp_port } { hsetprop ${scobj_hpath}/switches/reverse type "part" hsetprop ${scobj_hpath}/switches/reverse nxalias "${name}_switches_reverse" - if {[string equal -nocase [SplitReply [motor_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/switches/forward 1 ${sct_controller} poll ${scobj_hpath}/switches/reverse 1 } else { - ::scobj::tank::sics_log 9 "[motor_simulation] => No poll/write for tank" + ::scobj::tank::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for tank" } - hsetprop ${scobj_hpath} klass instrument + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 # mkDriver hook code starts @@ -323,17 +323,10 @@ proc ::scobj::tank::mkDriver { sct_controller name ip_address tcp_port } { handle_exception ${catch_status} ${catch_message} } -namespace eval ::scobj::tank { - namespace export debug_threshold - namespace export debug_log - namespace export sics_log - namespace export mkDriver -} - -proc add_tank {name ip_address tcp_port} { +proc ::scobj::tank::add_driver {name device_class simulation_flag ip_address tcp_port} { set catch_status [ catch { - ::scobj::tank::sics_log 9 "add_tank ${name} ${ip_address} ${tcp_port}" - if {[string equal -nocase [SplitReply [motor_simulation]] "false"]} { + ::scobj::tank::sics_log 9 "::scobj::tank::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" + if {[string equal -nocase "${simulation_flag}" "false"]} { if {[string equal -nocase "aqadapter" "${ip_address}"]} { ::scobj::tank::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" makesctcontroller sct_${name} aqadapter ${tcp_port} @@ -342,14 +335,27 @@ proc add_tank {name ip_address tcp_port} { makesctcontroller sct_${name} dmc2280 ${ip_address}:${tcp_port} } } else { - ::scobj::tank::sics_log 9 "[motor_simulation] => No sctcontroller for tank" + ::scobj::tank::sics_log 9 "simulation_flag={simulation_flag} => No sctcontroller for tank" } - ::scobj::tank::sics_log 1 "::scobj::tank::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port}" - ::scobj::tank::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} + ::scobj::tank::sics_log 1 "::scobj::tank::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" + ::scobj::tank::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} } catch_message ] handle_exception ${catch_status} ${catch_message} } +namespace eval ::scobj::tank { + namespace export debug_threshold + namespace export debug_log + namespace export sics_log + namespace export mkDriver + namespace export add_driver +} + +proc add_tank {name ip_address tcp_port} { + set simulation_flag "[string tolower [SplitReply [motor_simulation]]]" + ::scobj::tank::add_driver ${name} "instrument" "${simulation_flag}" ${ip_address} ${tcp_port} +} + clientput "file evaluation of sct_tank.tcl" ::scobj::tank::sics_log 9 "file evaluation of sct_tank.tcl" @@ -358,6 +364,8 @@ proc ::scobj::tank::read_config {} { set ns "::scobj::tank" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [motor_simulation]]]" + set device_class "instrument" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -365,6 +373,12 @@ proc ::scobj::tank::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -375,9 +389,9 @@ proc ::scobj::tank::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "tank"] } { - if { ![string equal -nocase [SplitReply [motor_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[motor_simulation] => using null asyncqueue" + ${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue" } elseif { [dict exists $v "asyncqueue"] } { set asyncqueue [dict get $v "asyncqueue"] if { [string equal -nocase ${asyncqueue} "sct"] } { @@ -404,9 +418,9 @@ proc ::scobj::tank::read_config {} { } } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_tank ${name} ${ip_address} ${tcp_port} + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} } else { - add_tank ${name} "aqadapter" ${asyncqueue} + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} } } } diff --git a/site_ansto/instrument/config/environment/magneticField/sct_green_magnet_labview.tcl b/site_ansto/instrument/config/environment/magneticField/sct_green_magnet_labview.tcl index d9cad5dd..d7fa10d9 100644 --- a/site_ansto/instrument/config/environment/magneticField/sct_green_magnet_labview.tcl +++ b/site_ansto/instrument/config/environment/magneticField/sct_green_magnet_labview.tcl @@ -27,8 +27,8 @@ proc ::scobj::green_magnet_labview::sics_log {debug_level debug_string} { } catch_message ] } -proc ::scobj::green_magnet_labview::mkDriver { sct_controller name ip_address tcp_port } { - ::scobj::green_magnet_labview::sics_log 9 "::scobj::green_magnet_labview::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port}" +proc ::scobj::green_magnet_labview::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port } { + ::scobj::green_magnet_labview::sics_log 9 "::scobj::green_magnet_labview::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" set ns "[namespace current]" set catch_status [ catch { @@ -46,21 +46,27 @@ proc ::scobj::green_magnet_labview::mkDriver { sct_controller name ip_address tc handle_exception ${catch_status} ${catch_message} } +proc ::scobj::green_magnet_labview::add_driver {name device_class simulation_flag ip_address tcp_port} { + set catch_status [ catch { + ::scobj::green_magnet_labview::sics_log 9 "::scobj::green_magnet_labview::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" + ::scobj::green_magnet_labview::sics_log 9 "No sctcontroller for green_magnet_labview" + ::scobj::green_magnet_labview::sics_log 1 "::scobj::green_magnet_labview::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" + ::scobj::green_magnet_labview::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + namespace eval ::scobj::green_magnet_labview { namespace export debug_threshold namespace export debug_log namespace export sics_log namespace export mkDriver + namespace export add_driver } proc add_green_magnet_labview {name ip_address tcp_port} { - set catch_status [ catch { - ::scobj::green_magnet_labview::sics_log 9 "add_green_magnet_labview ${name} ${ip_address} ${tcp_port}" - ::scobj::green_magnet_labview::sics_log 9 "No sctcontroller for green_magnet_labview" - ::scobj::green_magnet_labview::sics_log 1 "::scobj::green_magnet_labview::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port}" - ::scobj::green_magnet_labview::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} - } catch_message ] - handle_exception ${catch_status} ${catch_message} + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + ::scobj::green_magnet_labview::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} } clientput "file evaluation of sct_green_magnet_labview.tcl" @@ -71,6 +77,8 @@ proc ::scobj::green_magnet_labview::read_config {} { set ns "::scobj::green_magnet_labview" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + set device_class "environment" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -78,6 +86,12 @@ proc ::scobj::green_magnet_labview::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -88,9 +102,9 @@ proc ::scobj::green_magnet_labview::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "green_magnet_labview"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue" } elseif { [dict exists $v "asyncqueue"] } { set asyncqueue [dict get $v "asyncqueue"] if { [string equal -nocase ${asyncqueue} "sct"] } { @@ -117,9 +131,9 @@ proc ::scobj::green_magnet_labview::read_config {} { } } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_green_magnet_labview ${name} ${ip_address} ${tcp_port} + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} } else { - add_green_magnet_labview ${name} "aqadapter" ${asyncqueue} + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} } } } diff --git a/site_ansto/instrument/config/environment/magneticField/sct_oxford12tlv.tcl b/site_ansto/instrument/config/environment/magneticField/sct_oxford12tlv.tcl index c4ae5dfd..d0d0025f 100644 --- a/site_ansto/instrument/config/environment/magneticField/sct_oxford12tlv.tcl +++ b/site_ansto/instrument/config/environment/magneticField/sct_oxford12tlv.tcl @@ -27,18 +27,18 @@ proc ::scobj::oxford12tlv::sics_log {debug_level debug_string} { } catch_message ] } -proc ::scobj::oxford12tlv::mkDriver { sct_controller name ip_address tcp_port id datype interval } { - ::scobj::oxford12tlv::sics_log 9 "::scobj::oxford12tlv::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${interval}" +proc ::scobj::oxford12tlv::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port id datype interval } { + ::scobj::oxford12tlv::sics_log 9 "::scobj::oxford12tlv::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${interval}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT - sicslist setatt ${name} klass environment + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} - hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 # mkDriver hook code starts @@ -53,17 +53,10 @@ proc ::scobj::oxford12tlv::mkDriver { sct_controller name ip_address tcp_port id handle_exception ${catch_status} ${catch_message} } -namespace eval ::scobj::oxford12tlv { - namespace export debug_threshold - namespace export debug_log - namespace export sics_log - namespace export mkDriver -} - -proc add_oxford12tlv {name ip_address tcp_port id datype interval} { +proc ::scobj::oxford12tlv::add_driver {name device_class simulation_flag ip_address tcp_port id datype interval} { set catch_status [ catch { - ::scobj::oxford12tlv::sics_log 9 "add_oxford12tlv ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${interval}" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + ::scobj::oxford12tlv::sics_log 9 "::scobj::oxford12tlv::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${interval}" + if {[string equal -nocase "${simulation_flag}" "false"]} { if {[string equal -nocase "aqadapter" "${ip_address}"]} { ::scobj::oxford12tlv::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" makesctcontroller sct_${name} aqadapter ${tcp_port} @@ -72,14 +65,27 @@ proc add_oxford12tlv {name ip_address tcp_port id datype interval} { makesctcontroller sct_${name} std ${ip_address}:${tcp_port} } } else { - ::scobj::oxford12tlv::sics_log 9 "[environment_simulation] => No sctcontroller for oxford12tlv" + ::scobj::oxford12tlv::sics_log 9 "simulation_flag={simulation_flag} => No sctcontroller for oxford12tlv" } - ::scobj::oxford12tlv::sics_log 1 "::scobj::oxford12tlv::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${interval}" - ::scobj::oxford12tlv::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${interval} + ::scobj::oxford12tlv::sics_log 1 "::scobj::oxford12tlv::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${interval}" + ::scobj::oxford12tlv::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${interval} } catch_message ] handle_exception ${catch_status} ${catch_message} } +namespace eval ::scobj::oxford12tlv { + namespace export debug_threshold + namespace export debug_log + namespace export sics_log + namespace export mkDriver + namespace export add_driver +} + +proc add_oxford12tlv {name ip_address tcp_port id datype interval} { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + ::scobj::oxford12tlv::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${id}" "${datype}" "${interval}" +} + clientput "file evaluation of sct_oxford12tlv.tcl" ::scobj::oxford12tlv::sics_log 9 "file evaluation of sct_oxford12tlv.tcl" @@ -88,6 +94,8 @@ proc ::scobj::oxford12tlv::read_config {} { set ns "::scobj::oxford12tlv" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + set device_class "environment" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -95,6 +103,12 @@ proc ::scobj::oxford12tlv::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -105,9 +119,9 @@ proc ::scobj::oxford12tlv::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "oxford12tlv"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue" } elseif { [dict exists $v "asyncqueue"] } { set asyncqueue [dict get $v "asyncqueue"] if { [string equal -nocase ${asyncqueue} "sct"] } { @@ -149,9 +163,9 @@ proc ::scobj::oxford12tlv::read_config {} { error "$name is missing configuration values $missing_list" } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_oxford12tlv ${name} ${ip_address} ${tcp_port} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list } else { - add_oxford12tlv ${name} "aqadapter" ${asyncqueue} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list } } } diff --git a/site_ansto/instrument/config/environment/magneticField/sct_tsi_smc.tcl b/site_ansto/instrument/config/environment/magneticField/sct_tsi_smc.tcl index 9b35dded..cc91ca94 100644 --- a/site_ansto/instrument/config/environment/magneticField/sct_tsi_smc.tcl +++ b/site_ansto/instrument/config/environment/magneticField/sct_tsi_smc.tcl @@ -263,14 +263,14 @@ proc ::scobj::tsi_smc::setValue {tc_root nextState cmd_str} { handle_exception ${catch_status} ${catch_message} } -proc ::scobj::tsi_smc::mkDriver { sct_controller name ip_address tcp_port id } { - ::scobj::tsi_smc::sics_log 9 "::scobj::tsi_smc::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port} ${id}" +proc ::scobj::tsi_smc::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port id } { + ::scobj::tsi_smc::sics_log 9 "::scobj::tsi_smc::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT - sicslist setatt ${name} klass environment + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} @@ -320,10 +320,10 @@ proc ::scobj::tsi_smc::mkDriver { sct_controller name ip_address tcp_port id } { hsetprop ${scobj_hpath} klass "@none" hsetprop ${scobj_hpath} type "part" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} write ${scobj_hpath}/setpoint } else { - ::scobj::tsi_smc::sics_log 9 "[environment_simulation] => No poll/write for tsi_smc" + ::scobj::tsi_smc::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for tsi_smc" } hfactory ${scobj_hpath}/a plain spy none @@ -404,7 +404,7 @@ proc ::scobj::tsi_smc::mkDriver { sct_controller name ip_address tcp_port id } { hsetprop ${scobj_hpath}/a/S type "part" hsetprop ${scobj_hpath}/a/S nxalias "${name}_a_S" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/a/G 1 ${sct_controller} poll ${scobj_hpath}/a/J 1 ${sct_controller} poll ${scobj_hpath}/a/K 1 @@ -412,7 +412,7 @@ proc ::scobj::tsi_smc::mkDriver { sct_controller name ip_address tcp_port id } { ${sct_controller} poll ${scobj_hpath}/a/O 1 ${sct_controller} poll ${scobj_hpath}/a/S 1 } else { - ::scobj::tsi_smc::sics_log 9 "[environment_simulation] => No poll/write for tsi_smc" + ::scobj::tsi_smc::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for tsi_smc" } hfactory ${scobj_hpath}/b plain spy none @@ -485,18 +485,18 @@ proc ::scobj::tsi_smc::mkDriver { sct_controller name ip_address tcp_port id } { hsetprop ${scobj_hpath}/b/Rate type "part" hsetprop ${scobj_hpath}/b/Rate nxalias "${name}_b_Rate" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} write ${scobj_hpath}/b/Lower ${sct_controller} write ${scobj_hpath}/b/Pause ${sct_controller} write ${scobj_hpath}/b/Ramp ${sct_controller} write ${scobj_hpath}/b/Rate } else { - ::scobj::tsi_smc::sics_log 9 "[environment_simulation] => No poll/write for tsi_smc" + ::scobj::tsi_smc::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for tsi_smc" } - hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ansto_makesctdrive ${name}_setpoint ${scobj_hpath}/setpoint ${scobj_hpath}/value ${sct_controller} } # mkDriver hook code goes here @@ -504,31 +504,37 @@ proc ::scobj::tsi_smc::mkDriver { sct_controller name ip_address tcp_port id } { handle_exception ${catch_status} ${catch_message} } +proc ::scobj::tsi_smc::add_driver {name device_class simulation_flag ip_address tcp_port {id 1}} { + set catch_status [ catch { + ::scobj::tsi_smc::sics_log 9 "::scobj::tsi_smc::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id}" + if {[string equal -nocase "${simulation_flag}" "false"]} { + if {[string equal -nocase "aqadapter" "${ip_address}"]} { + ::scobj::tsi_smc::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" + makesctcontroller sct_${name} aqadapter ${tcp_port} + } else { + ::scobj::tsi_smc::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}" + makesctcontroller sct_${name} std ${ip_address}:${tcp_port} + } + } else { + ::scobj::tsi_smc::sics_log 9 "simulation_flag={simulation_flag} => No sctcontroller for tsi_smc" + } + ::scobj::tsi_smc::sics_log 1 "::scobj::tsi_smc::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id}" + ::scobj::tsi_smc::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + namespace eval ::scobj::tsi_smc { namespace export debug_threshold namespace export debug_log namespace export sics_log namespace export mkDriver + namespace export add_driver } proc add_tsi_smc {name ip_address tcp_port {id 1}} { - set catch_status [ catch { - ::scobj::tsi_smc::sics_log 9 "add_tsi_smc ${name} ${ip_address} ${tcp_port} ${id}" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { - if {[string equal -nocase "aqadapter" "${ip_address}"]} { - ::scobj::tsi_smc::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" - makesctcontroller sct_${name} aqadapter ${tcp_port} - } else { - ::scobj::tsi_smc::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}" - makesctcontroller sct_${name} std ${ip_address}:${tcp_port} - } - } else { - ::scobj::tsi_smc::sics_log 9 "[environment_simulation] => No sctcontroller for tsi_smc" - } - ::scobj::tsi_smc::sics_log 1 "::scobj::tsi_smc::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id}" - ::scobj::tsi_smc::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} - } catch_message ] - handle_exception ${catch_status} ${catch_message} + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + ::scobj::tsi_smc::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${{id}" "${1}}" } clientput "file evaluation of sct_tsi_smc.tcl" @@ -539,6 +545,8 @@ proc ::scobj::tsi_smc::read_config {} { set ns "::scobj::tsi_smc" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + set device_class "environment" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -546,6 +554,12 @@ proc ::scobj::tsi_smc::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -556,9 +570,9 @@ proc ::scobj::tsi_smc::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "tsi_smc"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue" } elseif { [dict exists $v "asyncqueue"] } { set asyncqueue [dict get $v "asyncqueue"] if { [string equal -nocase ${asyncqueue} "sct"] } { @@ -600,9 +614,9 @@ proc ::scobj::tsi_smc::read_config {} { error "$name is missing configuration values $missing_list" } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_tsi_smc ${name} ${ip_address} ${tcp_port} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list } else { - add_tsi_smc ${name} "aqadapter" ${asyncqueue} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list } } } diff --git a/site_ansto/instrument/config/environment/sct_agilent_33220A.tcl b/site_ansto/instrument/config/environment/sct_agilent_33220A.tcl index b93207db..1b335090 100644 --- a/site_ansto/instrument/config/environment/sct_agilent_33220A.tcl +++ b/site_ansto/instrument/config/environment/sct_agilent_33220A.tcl @@ -27,8 +27,8 @@ proc ::scobj::agilent_33220A::sics_log {debug_level debug_string} { } catch_message ] } -proc ::scobj::agilent_33220A::mkDriver { sct_controller name ip_address tcp_port } { - ::scobj::agilent_33220A::sics_log 9 "::scobj::agilent_33220A::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port}" +proc ::scobj::agilent_33220A::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port } { + ::scobj::agilent_33220A::sics_log 9 "::scobj::agilent_33220A::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" set ns "[namespace current]" set catch_status [ catch { @@ -40,21 +40,27 @@ proc ::scobj::agilent_33220A::mkDriver { sct_controller name ip_address tcp_port handle_exception ${catch_status} ${catch_message} } +proc ::scobj::agilent_33220A::add_driver {name device_class simulation_flag ip_address tcp_port} { + set catch_status [ catch { + ::scobj::agilent_33220A::sics_log 9 "::scobj::agilent_33220A::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" + ::scobj::agilent_33220A::sics_log 9 "No sctcontroller for agilent_33220A" + ::scobj::agilent_33220A::sics_log 1 "::scobj::agilent_33220A::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" + ::scobj::agilent_33220A::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + namespace eval ::scobj::agilent_33220A { namespace export debug_threshold namespace export debug_log namespace export sics_log namespace export mkDriver + namespace export add_driver } proc add_agilent_33220A {name ip_address tcp_port} { - set catch_status [ catch { - ::scobj::agilent_33220A::sics_log 9 "add_agilent_33220A ${name} ${ip_address} ${tcp_port}" - ::scobj::agilent_33220A::sics_log 9 "No sctcontroller for agilent_33220A" - ::scobj::agilent_33220A::sics_log 1 "::scobj::agilent_33220A::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port}" - ::scobj::agilent_33220A::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} - } catch_message ] - handle_exception ${catch_status} ${catch_message} + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + ::scobj::agilent_33220A::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} } clientput "file evaluation of sct_agilent_33220A.tcl" @@ -65,6 +71,8 @@ proc ::scobj::agilent_33220A::read_config {} { set ns "::scobj::agilent_33220A" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + set device_class "environment" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -72,6 +80,12 @@ proc ::scobj::agilent_33220A::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -82,9 +96,9 @@ proc ::scobj::agilent_33220A::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "agilent_33220A"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue" } elseif { [dict exists $v "asyncqueue"] } { set asyncqueue [dict get $v "asyncqueue"] if { [string equal -nocase ${asyncqueue} "sct"] } { @@ -111,9 +125,9 @@ proc ::scobj::agilent_33220A::read_config {} { } } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_agilent_33220A ${name} ${ip_address} ${tcp_port} + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} } else { - add_agilent_33220A ${name} "aqadapter" ${asyncqueue} + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} } } } diff --git a/site_ansto/instrument/config/environment/sct_hiden_xcs.tcl b/site_ansto/instrument/config/environment/sct_hiden_xcs.tcl index 58585188..0801bad6 100644 --- a/site_ansto/instrument/config/environment/sct_hiden_xcs.tcl +++ b/site_ansto/instrument/config/environment/sct_hiden_xcs.tcl @@ -745,14 +745,14 @@ proc ::scobj::hiden_xcs::write_twelve {tc_root nextState cmd_str} { handle_exception ${catch_status} ${catch_message} } -proc ::scobj::hiden_xcs::mkDriver { sct_controller name ip_address tcp_port id } { - ::scobj::hiden_xcs::sics_log 9 "::scobj::hiden_xcs::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port} ${id}" +proc ::scobj::hiden_xcs::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port id } { + ::scobj::hiden_xcs::sics_log 9 "::scobj::hiden_xcs::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT - sicslist setatt ${name} klass environment + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} @@ -837,11 +837,11 @@ proc ::scobj::hiden_xcs::mkDriver { sct_controller name ip_address tcp_port id } hsetprop ${scobj_hpath} nxsave "true" hsetprop ${scobj_hpath} type "part" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/enabled 10 ${sct_controller} write ${scobj_hpath}/enabled } else { - ::scobj::hiden_xcs::sics_log 9 "[environment_simulation] => No poll/write for hiden_xcs" + ::scobj::hiden_xcs::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for hiden_xcs" } hfactory ${scobj_hpath}/analog plain spy none @@ -984,7 +984,7 @@ proc ::scobj::hiden_xcs::mkDriver { sct_controller name ip_address tcp_port id } hsetprop ${scobj_hpath}/analog/sp3 type "part" hsetprop ${scobj_hpath}/analog/sp3 nxalias "${name}_analog_sp3" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/analog/ansto_temp 5 ${sct_controller} poll ${scobj_hpath}/analog/pv1 5 ${sct_controller} poll ${scobj_hpath}/analog/pv2 5 @@ -998,7 +998,7 @@ proc ::scobj::hiden_xcs::mkDriver { sct_controller name ip_address tcp_port id } ${sct_controller} write ${scobj_hpath}/analog/sp2 ${sct_controller} write ${scobj_hpath}/analog/sp3 } else { - ::scobj::hiden_xcs::sics_log 9 "[environment_simulation] => No poll/write for hiden_xcs" + ::scobj::hiden_xcs::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for hiden_xcs" } hfactory ${scobj_hpath}/flow plain spy none @@ -1054,11 +1054,11 @@ proc ::scobj::hiden_xcs::mkDriver { sct_controller name ip_address tcp_port id } hsetprop ${scobj_hpath}/flow/setpoint type "drivable" hsetprop ${scobj_hpath}/flow/setpoint nxalias "${name}_flow_setpoint" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/flow/sensor 1 ${sct_controller} write ${scobj_hpath}/flow/setpoint } else { - ::scobj::hiden_xcs::sics_log 9 "[environment_simulation] => No poll/write for hiden_xcs" + ::scobj::hiden_xcs::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for hiden_xcs" } hfactory ${scobj_hpath}/humidity plain spy none @@ -1114,16 +1114,16 @@ proc ::scobj::hiden_xcs::mkDriver { sct_controller name ip_address tcp_port id } hsetprop ${scobj_hpath}/humidity/setpoint type "drivable" hsetprop ${scobj_hpath}/humidity/setpoint nxalias "${name}_humidity_setpoint" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/humidity/sensor 1 ${sct_controller} write ${scobj_hpath}/humidity/setpoint } else { - ::scobj::hiden_xcs::sics_log 9 "[environment_simulation] => No poll/write for hiden_xcs" + ::scobj::hiden_xcs::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for hiden_xcs" } - hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ansto_makesctdrive ${name}_flow_setpoint ${scobj_hpath}/flow/setpoint ${scobj_hpath}/flow/sensor ${sct_controller} ansto_makesctdrive ${name}_humidity_setpoint ${scobj_hpath}/humidity/setpoint ${scobj_hpath}/humidity/sensor ${sct_controller} } @@ -1133,17 +1133,10 @@ proc ::scobj::hiden_xcs::mkDriver { sct_controller name ip_address tcp_port id } handle_exception ${catch_status} ${catch_message} } -namespace eval ::scobj::hiden_xcs { - namespace export debug_threshold - namespace export debug_log - namespace export sics_log - namespace export mkDriver -} - -proc add_hiden_xcs {name ip_address tcp_port id} { +proc ::scobj::hiden_xcs::add_driver {name device_class simulation_flag ip_address tcp_port id} { set catch_status [ catch { - ::scobj::hiden_xcs::sics_log 9 "add_hiden_xcs ${name} ${ip_address} ${tcp_port} ${id}" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + ::scobj::hiden_xcs::sics_log 9 "::scobj::hiden_xcs::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id}" + if {[string equal -nocase "${simulation_flag}" "false"]} { if {[string equal -nocase "aqadapter" "${ip_address}"]} { ::scobj::hiden_xcs::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" makesctcontroller sct_${name} aqadapter ${tcp_port} @@ -1152,14 +1145,27 @@ proc add_hiden_xcs {name ip_address tcp_port id} { makesctcontroller sct_${name} std ${ip_address}:${tcp_port} } } else { - ::scobj::hiden_xcs::sics_log 9 "[environment_simulation] => No sctcontroller for hiden_xcs" + ::scobj::hiden_xcs::sics_log 9 "simulation_flag={simulation_flag} => No sctcontroller for hiden_xcs" } - ::scobj::hiden_xcs::sics_log 1 "::scobj::hiden_xcs::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id}" - ::scobj::hiden_xcs::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} + ::scobj::hiden_xcs::sics_log 1 "::scobj::hiden_xcs::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id}" + ::scobj::hiden_xcs::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} } catch_message ] handle_exception ${catch_status} ${catch_message} } +namespace eval ::scobj::hiden_xcs { + namespace export debug_threshold + namespace export debug_log + namespace export sics_log + namespace export mkDriver + namespace export add_driver +} + +proc add_hiden_xcs {name ip_address tcp_port id} { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + ::scobj::hiden_xcs::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${id}" +} + clientput "file evaluation of sct_hiden_xcs.tcl" ::scobj::hiden_xcs::sics_log 9 "file evaluation of sct_hiden_xcs.tcl" @@ -1168,6 +1174,8 @@ proc ::scobj::hiden_xcs::read_config {} { set ns "::scobj::hiden_xcs" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + set device_class "environment" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -1175,6 +1183,12 @@ proc ::scobj::hiden_xcs::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -1185,9 +1199,9 @@ proc ::scobj::hiden_xcs::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "hiden_xcs"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue" } elseif { [dict exists $v "asyncqueue"] } { set asyncqueue [dict get $v "asyncqueue"] if { [string equal -nocase ${asyncqueue} "sct"] } { @@ -1229,9 +1243,9 @@ proc ::scobj::hiden_xcs::read_config {} { error "$name is missing configuration values $missing_list" } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_hiden_xcs ${name} ${ip_address} ${tcp_port} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list } else { - add_hiden_xcs ${name} "aqadapter" ${asyncqueue} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list } } } diff --git a/site_ansto/instrument/config/environment/sct_huber_pilot.tcl b/site_ansto/instrument/config/environment/sct_huber_pilot.tcl index aaa19519..76f5f0c1 100644 --- a/site_ansto/instrument/config/environment/sct_huber_pilot.tcl +++ b/site_ansto/instrument/config/environment/sct_huber_pilot.tcl @@ -287,8 +287,8 @@ proc ::scobj::huber_pilot::setValue {tc_root nextState cmd_str} { handle_exception ${catch_status} ${catch_message} } -proc ::scobj::huber_pilot::mkDriver { sct_controller name ip_address tcp_port } { - ::scobj::huber_pilot::sics_log 9 "::scobj::huber_pilot::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port}" +proc ::scobj::huber_pilot::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port } { + ::scobj::huber_pilot::sics_log 9 "::scobj::huber_pilot::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" set ns "[namespace current]" set catch_status [ catch { @@ -296,7 +296,7 @@ proc ::scobj::huber_pilot::mkDriver { sct_controller name ip_address tcp_port } MakeSICSObj ${name} SCT_OBJECT - sicslist setatt ${name} klass environment + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} @@ -415,7 +415,7 @@ proc ::scobj::huber_pilot::mkDriver { sct_controller name ip_address tcp_port } hsetprop ${scobj_hpath}/Loop1/vTmpMode type "part" hsetprop ${scobj_hpath}/Loop1/vTmpMode nxalias "${name}_Loop1_vTmpMode" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/Loop1/sensor_int 1 ${sct_controller} poll ${scobj_hpath}/Loop1/setpoint 1 ${sct_controller} poll ${scobj_hpath}/Loop1/vMaxSP 1 @@ -425,12 +425,12 @@ proc ::scobj::huber_pilot::mkDriver { sct_controller name ip_address tcp_port } ${sct_controller} poll ${scobj_hpath}/Loop1/vTmpMode 1 ${sct_controller} write ${scobj_hpath}/Loop1/setpoint } else { - ::scobj::huber_pilot::sics_log 9 "[environment_simulation] => No poll/write for huber_pilot" + ::scobj::huber_pilot::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for huber_pilot" } - hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ansto_makesctdrive ${name}_Loop1_setpoint ${scobj_hpath}/Loop1/setpoint ${scobj_hpath}/Loop1/sensor_int ${sct_controller} } # mkDriver hook code goes here @@ -438,31 +438,37 @@ proc ::scobj::huber_pilot::mkDriver { sct_controller name ip_address tcp_port } handle_exception ${catch_status} ${catch_message} } +proc ::scobj::huber_pilot::add_driver {name device_class simulation_flag ip_address tcp_port} { + set catch_status [ catch { + ::scobj::huber_pilot::sics_log 9 "::scobj::huber_pilot::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" + if {[string equal -nocase "${simulation_flag}" "false"]} { + if {[string equal -nocase "aqadapter" "${ip_address}"]} { + ::scobj::huber_pilot::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" + makesctcontroller sct_${name} aqadapter ${tcp_port} + } else { + ::scobj::huber_pilot::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}" + makesctcontroller sct_${name} std ${ip_address}:${tcp_port} + } + } else { + ::scobj::huber_pilot::sics_log 9 "simulation_flag={simulation_flag} => No sctcontroller for huber_pilot" + } + ::scobj::huber_pilot::sics_log 1 "::scobj::huber_pilot::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" + ::scobj::huber_pilot::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + namespace eval ::scobj::huber_pilot { namespace export debug_threshold namespace export debug_log namespace export sics_log namespace export mkDriver + namespace export add_driver } proc add_huber_pilot {name ip_address tcp_port} { - set catch_status [ catch { - ::scobj::huber_pilot::sics_log 9 "add_huber_pilot ${name} ${ip_address} ${tcp_port}" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { - if {[string equal -nocase "aqadapter" "${ip_address}"]} { - ::scobj::huber_pilot::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" - makesctcontroller sct_${name} aqadapter ${tcp_port} - } else { - ::scobj::huber_pilot::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}" - makesctcontroller sct_${name} std ${ip_address}:${tcp_port} - } - } else { - ::scobj::huber_pilot::sics_log 9 "[environment_simulation] => No sctcontroller for huber_pilot" - } - ::scobj::huber_pilot::sics_log 1 "::scobj::huber_pilot::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port}" - ::scobj::huber_pilot::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} - } catch_message ] - handle_exception ${catch_status} ${catch_message} + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + ::scobj::huber_pilot::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} } clientput "file evaluation of sct_huber_pilot.tcl" @@ -473,6 +479,8 @@ proc ::scobj::huber_pilot::read_config {} { set ns "::scobj::huber_pilot" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + set device_class "environment" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -480,6 +488,12 @@ proc ::scobj::huber_pilot::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -490,9 +504,9 @@ proc ::scobj::huber_pilot::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "huber_pilot"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue" } elseif { [dict exists $v "asyncqueue"] } { set asyncqueue [dict get $v "asyncqueue"] if { [string equal -nocase ${asyncqueue} "sct"] } { @@ -519,9 +533,9 @@ proc ::scobj::huber_pilot::read_config {} { } } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_huber_pilot ${name} ${ip_address} ${tcp_port} + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} } else { - add_huber_pilot ${name} "aqadapter" ${asyncqueue} + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} } } } diff --git a/site_ansto/instrument/config/environment/sct_isotech_ps.tcl b/site_ansto/instrument/config/environment/sct_isotech_ps.tcl index dadc4372..5a92cb66 100644 --- a/site_ansto/instrument/config/environment/sct_isotech_ps.tcl +++ b/site_ansto/instrument/config/environment/sct_isotech_ps.tcl @@ -240,14 +240,14 @@ proc ::scobj::isotech_ps::write_voltage {tc_root nextState cmd_str} { handle_exception ${catch_status} ${catch_message} } -proc ::scobj::isotech_ps::mkDriver { sct_controller name ip_address tcp_port } { - ::scobj::isotech_ps::sics_log 9 "::scobj::isotech_ps::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port}" +proc ::scobj::isotech_ps::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port } { + ::scobj::isotech_ps::sics_log 9 "::scobj::isotech_ps::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT - sicslist setatt ${name} klass environment + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} @@ -303,16 +303,16 @@ proc ::scobj::isotech_ps::mkDriver { sct_controller name ip_address tcp_port } { hsetprop ${scobj_hpath} klass "@none" hsetprop ${scobj_hpath} type "part" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/amps 5 ${sct_controller} poll ${scobj_hpath}/relay 5 ${sct_controller} poll ${scobj_hpath}/volts 5 ${sct_controller} write ${scobj_hpath}/relay ${sct_controller} write ${scobj_hpath}/volts } else { - ::scobj::isotech_ps::sics_log 9 "[environment_simulation] => No poll/write for isotech_ps" + ::scobj::isotech_ps::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for isotech_ps" } - hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 # mkDriver hook code goes here @@ -320,31 +320,37 @@ proc ::scobj::isotech_ps::mkDriver { sct_controller name ip_address tcp_port } { handle_exception ${catch_status} ${catch_message} } +proc ::scobj::isotech_ps::add_driver {name device_class simulation_flag ip_address tcp_port} { + set catch_status [ catch { + ::scobj::isotech_ps::sics_log 9 "::scobj::isotech_ps::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" + if {[string equal -nocase "${simulation_flag}" "false"]} { + if {[string equal -nocase "aqadapter" "${ip_address}"]} { + ::scobj::isotech_ps::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" + makesctcontroller sct_${name} aqadapter ${tcp_port} + } else { + ::scobj::isotech_ps::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port} \"\\r\"" + makesctcontroller sct_${name} std ${ip_address}:${tcp_port} "\r" + } + } else { + ::scobj::isotech_ps::sics_log 9 "simulation_flag={simulation_flag} => No sctcontroller for isotech_ps" + } + ::scobj::isotech_ps::sics_log 1 "::scobj::isotech_ps::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" + ::scobj::isotech_ps::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + namespace eval ::scobj::isotech_ps { namespace export debug_threshold namespace export debug_log namespace export sics_log namespace export mkDriver + namespace export add_driver } proc add_isotech_ps {name ip_address tcp_port} { - set catch_status [ catch { - ::scobj::isotech_ps::sics_log 9 "add_isotech_ps ${name} ${ip_address} ${tcp_port}" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { - if {[string equal -nocase "aqadapter" "${ip_address}"]} { - ::scobj::isotech_ps::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" - makesctcontroller sct_${name} aqadapter ${tcp_port} - } else { - ::scobj::isotech_ps::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port} \"\\r\"" - makesctcontroller sct_${name} std ${ip_address}:${tcp_port} "\r" - } - } else { - ::scobj::isotech_ps::sics_log 9 "[environment_simulation] => No sctcontroller for isotech_ps" - } - ::scobj::isotech_ps::sics_log 1 "::scobj::isotech_ps::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port}" - ::scobj::isotech_ps::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} - } catch_message ] - handle_exception ${catch_status} ${catch_message} + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + ::scobj::isotech_ps::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} } clientput "file evaluation of sct_isotech_ps.tcl" @@ -355,6 +361,8 @@ proc ::scobj::isotech_ps::read_config {} { set ns "::scobj::isotech_ps" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + set device_class "environment" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -362,6 +370,12 @@ proc ::scobj::isotech_ps::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -372,9 +386,9 @@ proc ::scobj::isotech_ps::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "isotech_ps"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue" } elseif { [dict exists $v "asyncqueue"] } { set asyncqueue [dict get $v "asyncqueue"] if { [string equal -nocase ${asyncqueue} "sct"] } { @@ -401,9 +415,9 @@ proc ::scobj::isotech_ps::read_config {} { } } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_isotech_ps ${name} ${ip_address} ${tcp_port} + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} } else { - add_isotech_ps ${name} "aqadapter" ${asyncqueue} + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} } } } diff --git a/site_ansto/instrument/config/environment/sct_keithley_m2700.tcl b/site_ansto/instrument/config/environment/sct_keithley_m2700.tcl index 8c0e70d5..e4ff9fbf 100644 --- a/site_ansto/instrument/config/environment/sct_keithley_m2700.tcl +++ b/site_ansto/instrument/config/environment/sct_keithley_m2700.tcl @@ -27,18 +27,18 @@ proc ::scobj::keithley_m2700::sics_log {debug_level debug_string} { } catch_message ] } -proc ::scobj::keithley_m2700::mkDriver { sct_controller name ip_address tcp_port id datype tol } { - ::scobj::keithley_m2700::sics_log 9 "::scobj::keithley_m2700::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${tol}" +proc ::scobj::keithley_m2700::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port id datype tol } { + ::scobj::keithley_m2700::sics_log 9 "::scobj::keithley_m2700::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${tol}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT user float - sicslist setatt ${name} klass environment + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} - hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 # mkDriver hook code starts @@ -48,17 +48,10 @@ proc ::scobj::keithley_m2700::mkDriver { sct_controller name ip_address tcp_port handle_exception ${catch_status} ${catch_message} } -namespace eval ::scobj::keithley_m2700 { - namespace export debug_threshold - namespace export debug_log - namespace export sics_log - namespace export mkDriver -} - -proc add_keithley_m2700 {name ip_address tcp_port id datype tol} { +proc ::scobj::keithley_m2700::add_driver {name device_class simulation_flag ip_address tcp_port id datype tol} { set catch_status [ catch { - ::scobj::keithley_m2700::sics_log 9 "add_keithley_m2700 ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${tol}" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + ::scobj::keithley_m2700::sics_log 9 "::scobj::keithley_m2700::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${tol}" + if {[string equal -nocase "${simulation_flag}" "false"]} { if {[string equal -nocase "aqadapter" "${ip_address}"]} { ::scobj::keithley_m2700::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" makesctcontroller sct_${name} aqadapter ${tcp_port} @@ -67,14 +60,27 @@ proc add_keithley_m2700 {name ip_address tcp_port id datype tol} { makesctcontroller sct_${name} std ${ip_address}:${tcp_port} } } else { - ::scobj::keithley_m2700::sics_log 9 "[environment_simulation] => No sctcontroller for keithley_m2700" + ::scobj::keithley_m2700::sics_log 9 "simulation_flag={simulation_flag} => No sctcontroller for keithley_m2700" } - ::scobj::keithley_m2700::sics_log 1 "::scobj::keithley_m2700::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${tol}" - ::scobj::keithley_m2700::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${tol} + ::scobj::keithley_m2700::sics_log 1 "::scobj::keithley_m2700::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${tol}" + ::scobj::keithley_m2700::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${tol} } catch_message ] handle_exception ${catch_status} ${catch_message} } +namespace eval ::scobj::keithley_m2700 { + namespace export debug_threshold + namespace export debug_log + namespace export sics_log + namespace export mkDriver + namespace export add_driver +} + +proc add_keithley_m2700 {name ip_address tcp_port id datype tol} { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + ::scobj::keithley_m2700::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${id}" "${datype}" "${tol}" +} + clientput "file evaluation of sct_keithley_m2700.tcl" ::scobj::keithley_m2700::sics_log 9 "file evaluation of sct_keithley_m2700.tcl" @@ -83,6 +89,8 @@ proc ::scobj::keithley_m2700::read_config {} { set ns "::scobj::keithley_m2700" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + set device_class "environment" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -90,6 +98,12 @@ proc ::scobj::keithley_m2700::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -100,9 +114,9 @@ proc ::scobj::keithley_m2700::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "keithley_m2700"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue" } elseif { [dict exists $v "asyncqueue"] } { set asyncqueue [dict get $v "asyncqueue"] if { [string equal -nocase ${asyncqueue} "sct"] } { @@ -144,9 +158,9 @@ proc ::scobj::keithley_m2700::read_config {} { error "$name is missing configuration values $missing_list" } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_keithley_m2700 ${name} ${ip_address} ${tcp_port} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list } else { - add_keithley_m2700 ${name} "aqadapter" ${asyncqueue} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list } } } diff --git a/site_ansto/instrument/config/environment/sct_nhq_200.tcl b/site_ansto/instrument/config/environment/sct_nhq_200.tcl index 4aef7fb3..23288ca5 100644 --- a/site_ansto/instrument/config/environment/sct_nhq_200.tcl +++ b/site_ansto/instrument/config/environment/sct_nhq_200.tcl @@ -269,14 +269,14 @@ proc ::scobj::nhq_200::setValue {tc_root nextState cmd_str} { handle_exception ${catch_status} ${catch_message} } -proc ::scobj::nhq_200::mkDriver { sct_controller name ip_address tcp_port } { - ::scobj::nhq_200::sics_log 9 "::scobj::nhq_200::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port}" +proc ::scobj::nhq_200::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port } { + ::scobj::nhq_200::sics_log 9 "::scobj::nhq_200::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT - sicslist setatt ${name} klass NXdetector + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} @@ -311,11 +311,11 @@ proc ::scobj::nhq_200::mkDriver { sct_controller name ip_address tcp_port } { hsetprop ${scobj_hpath} klass "@none" hsetprop ${scobj_hpath} type "part" - if {[string equal -nocase [SplitReply [detector_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/break 10 ${sct_controller} poll ${scobj_hpath}/id 10 } else { - ::scobj::nhq_200::sics_log 9 "[detector_simulation] => No poll/write for nhq_200" + ::scobj::nhq_200::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for nhq_200" } hfactory ${scobj_hpath}/ch1 plain spy none @@ -488,7 +488,7 @@ proc ::scobj::nhq_200::mkDriver { sct_controller name ip_address tcp_port } { hsetprop ${scobj_hpath}/ch1/voltage type "part" hsetprop ${scobj_hpath}/ch1/voltage nxalias "${name}_ch1_voltage" - if {[string equal -nocase [SplitReply [detector_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/ch1/auto_start 5 ${sct_controller} poll ${scobj_hpath}/ch1/current 5 ${sct_controller} poll ${scobj_hpath}/ch1/i_lim 5 @@ -505,7 +505,7 @@ proc ::scobj::nhq_200::mkDriver { sct_controller name ip_address tcp_port } { ${sct_controller} write ${scobj_hpath}/ch1/v_ramp ${sct_controller} write ${scobj_hpath}/ch1/v_sp } else { - ::scobj::nhq_200::sics_log 9 "[detector_simulation] => No poll/write for nhq_200" + ::scobj::nhq_200::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for nhq_200" } hfactory ${scobj_hpath}/ch2 plain spy none @@ -678,7 +678,7 @@ proc ::scobj::nhq_200::mkDriver { sct_controller name ip_address tcp_port } { hsetprop ${scobj_hpath}/ch2/voltage type "part" hsetprop ${scobj_hpath}/ch2/voltage nxalias "${name}_ch2_voltage" - if {[string equal -nocase [SplitReply [detector_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/ch2/auto_start 5 ${sct_controller} poll ${scobj_hpath}/ch2/current 5 ${sct_controller} poll ${scobj_hpath}/ch2/i_lim 5 @@ -695,12 +695,12 @@ proc ::scobj::nhq_200::mkDriver { sct_controller name ip_address tcp_port } { ${sct_controller} write ${scobj_hpath}/ch2/v_ramp ${sct_controller} write ${scobj_hpath}/ch2/v_sp } else { - ::scobj::nhq_200::sics_log 9 "[detector_simulation] => No poll/write for nhq_200" + ::scobj::nhq_200::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for nhq_200" } - hsetprop ${scobj_hpath} klass NXdetector + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 - if {[string equal -nocase [SplitReply [detector_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ansto_makesctdrive ${name}_ch1_v_sp ${scobj_hpath}/ch1/v_sp ${scobj_hpath}/ch1/voltage ${sct_controller} ansto_makesctdrive ${name}_ch2_v_sp ${scobj_hpath}/ch2/v_sp ${scobj_hpath}/ch2/voltage ${sct_controller} } @@ -709,31 +709,37 @@ proc ::scobj::nhq_200::mkDriver { sct_controller name ip_address tcp_port } { handle_exception ${catch_status} ${catch_message} } +proc ::scobj::nhq_200::add_driver {name device_class simulation_flag ip_address tcp_port} { + set catch_status [ catch { + ::scobj::nhq_200::sics_log 9 "::scobj::nhq_200::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" + if {[string equal -nocase "${simulation_flag}" "false"]} { + if {[string equal -nocase "aqadapter" "${ip_address}"]} { + ::scobj::nhq_200::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" + makesctcontroller sct_${name} aqadapter ${tcp_port} + } else { + ::scobj::nhq_200::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}" + makesctcontroller sct_${name} std ${ip_address}:${tcp_port} + } + } else { + ::scobj::nhq_200::sics_log 9 "simulation_flag={simulation_flag} => No sctcontroller for nhq_200" + } + ::scobj::nhq_200::sics_log 1 "::scobj::nhq_200::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" + ::scobj::nhq_200::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + namespace eval ::scobj::nhq_200 { namespace export debug_threshold namespace export debug_log namespace export sics_log namespace export mkDriver + namespace export add_driver } proc add_nhq_200 {name ip_address tcp_port} { - set catch_status [ catch { - ::scobj::nhq_200::sics_log 9 "add_nhq_200 ${name} ${ip_address} ${tcp_port}" - if {[string equal -nocase [SplitReply [detector_simulation]] "false"]} { - if {[string equal -nocase "aqadapter" "${ip_address}"]} { - ::scobj::nhq_200::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" - makesctcontroller sct_${name} aqadapter ${tcp_port} - } else { - ::scobj::nhq_200::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}" - makesctcontroller sct_${name} std ${ip_address}:${tcp_port} - } - } else { - ::scobj::nhq_200::sics_log 9 "[detector_simulation] => No sctcontroller for nhq_200" - } - ::scobj::nhq_200::sics_log 1 "::scobj::nhq_200::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port}" - ::scobj::nhq_200::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} - } catch_message ] - handle_exception ${catch_status} ${catch_message} + set simulation_flag "[string tolower [SplitReply [detector_simulation]]]" + ::scobj::nhq_200::add_driver ${name} "NXdetector" "${simulation_flag}" ${ip_address} ${tcp_port} } clientput "file evaluation of sct_nhq_200.tcl" @@ -744,6 +750,8 @@ proc ::scobj::nhq_200::read_config {} { set ns "::scobj::nhq_200" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [detector_simulation]]]" + set device_class "NXdetector" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -751,6 +759,12 @@ proc ::scobj::nhq_200::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -761,9 +775,9 @@ proc ::scobj::nhq_200::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "nhq_200"] } { - if { ![string equal -nocase [SplitReply [detector_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[detector_simulation] => using null asyncqueue" + ${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue" } elseif { [dict exists $v "asyncqueue"] } { set asyncqueue [dict get $v "asyncqueue"] if { [string equal -nocase ${asyncqueue} "sct"] } { @@ -790,9 +804,9 @@ proc ::scobj::nhq_200::read_config {} { } } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_nhq_200 ${name} ${ip_address} ${tcp_port} + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} } else { - add_nhq_200 ${name} "aqadapter" ${asyncqueue} + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} } } } diff --git a/site_ansto/instrument/config/environment/sct_omron_hldc.tcl b/site_ansto/instrument/config/environment/sct_omron_hldc.tcl index 8390cbe5..d78fffb3 100644 --- a/site_ansto/instrument/config/environment/sct_omron_hldc.tcl +++ b/site_ansto/instrument/config/environment/sct_omron_hldc.tcl @@ -190,14 +190,14 @@ proc ::scobj::omron_hldc::setValue {tc_root nextState cmd_str} { handle_exception ${catch_status} ${catch_message} } -proc ::scobj::omron_hldc::mkDriver { sct_controller name ip_address tcp_port } { - ::scobj::omron_hldc::sics_log 9 "::scobj::omron_hldc::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port}" +proc ::scobj::omron_hldc::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port } { + ::scobj::omron_hldc::sics_log 9 "::scobj::omron_hldc::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT - sicslist setatt ${name} klass environment + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} @@ -232,13 +232,13 @@ proc ::scobj::omron_hldc::mkDriver { sct_controller name ip_address tcp_port } { hsetprop ${scobj_hpath} klass "@none" hsetprop ${scobj_hpath} type "part" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/distance 1 ${sct_controller} poll ${scobj_hpath}/id 10 } else { - ::scobj::omron_hldc::sics_log 9 "[environment_simulation] => No poll/write for omron_hldc" + ::scobj::omron_hldc::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for omron_hldc" } - hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 # mkDriver hook code goes here @@ -246,31 +246,37 @@ proc ::scobj::omron_hldc::mkDriver { sct_controller name ip_address tcp_port } { handle_exception ${catch_status} ${catch_message} } +proc ::scobj::omron_hldc::add_driver {name device_class simulation_flag ip_address tcp_port} { + set catch_status [ catch { + ::scobj::omron_hldc::sics_log 9 "::scobj::omron_hldc::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" + if {[string equal -nocase "${simulation_flag}" "false"]} { + if {[string equal -nocase "aqadapter" "${ip_address}"]} { + ::scobj::omron_hldc::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" + makesctcontroller sct_${name} aqadapter ${tcp_port} + } else { + ::scobj::omron_hldc::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}" + makesctcontroller sct_${name} std ${ip_address}:${tcp_port} + } + } else { + ::scobj::omron_hldc::sics_log 9 "simulation_flag={simulation_flag} => No sctcontroller for omron_hldc" + } + ::scobj::omron_hldc::sics_log 1 "::scobj::omron_hldc::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" + ::scobj::omron_hldc::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + namespace eval ::scobj::omron_hldc { namespace export debug_threshold namespace export debug_log namespace export sics_log namespace export mkDriver + namespace export add_driver } proc add_omron_hldc {name ip_address tcp_port} { - set catch_status [ catch { - ::scobj::omron_hldc::sics_log 9 "add_omron_hldc ${name} ${ip_address} ${tcp_port}" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { - if {[string equal -nocase "aqadapter" "${ip_address}"]} { - ::scobj::omron_hldc::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" - makesctcontroller sct_${name} aqadapter ${tcp_port} - } else { - ::scobj::omron_hldc::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}" - makesctcontroller sct_${name} std ${ip_address}:${tcp_port} - } - } else { - ::scobj::omron_hldc::sics_log 9 "[environment_simulation] => No sctcontroller for omron_hldc" - } - ::scobj::omron_hldc::sics_log 1 "::scobj::omron_hldc::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port}" - ::scobj::omron_hldc::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} - } catch_message ] - handle_exception ${catch_status} ${catch_message} + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + ::scobj::omron_hldc::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} } clientput "file evaluation of sct_omron_hldc.tcl" @@ -281,6 +287,8 @@ proc ::scobj::omron_hldc::read_config {} { set ns "::scobj::omron_hldc" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + set device_class "environment" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -288,6 +296,12 @@ proc ::scobj::omron_hldc::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -298,9 +312,9 @@ proc ::scobj::omron_hldc::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "omron_hldc"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue" } elseif { [dict exists $v "asyncqueue"] } { set asyncqueue [dict get $v "asyncqueue"] if { [string equal -nocase ${asyncqueue} "sct"] } { @@ -327,9 +341,9 @@ proc ::scobj::omron_hldc::read_config {} { } } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_omron_hldc ${name} ${ip_address} ${tcp_port} + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} } else { - add_omron_hldc ${name} "aqadapter" ${asyncqueue} + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} } } } diff --git a/site_ansto/instrument/config/environment/sct_protekmm.tcl b/site_ansto/instrument/config/environment/sct_protekmm.tcl index f648948a..c0be60ee 100644 --- a/site_ansto/instrument/config/environment/sct_protekmm.tcl +++ b/site_ansto/instrument/config/environment/sct_protekmm.tcl @@ -27,18 +27,18 @@ proc ::scobj::protekmm::sics_log {debug_level debug_string} { } catch_message ] } -proc ::scobj::protekmm::mkDriver { sct_controller name ip_address tcp_port id datype } { - ::scobj::protekmm::sics_log 9 "::scobj::protekmm::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port} ${id} ${datype}" +proc ::scobj::protekmm::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port id datype } { + ::scobj::protekmm::sics_log 9 "::scobj::protekmm::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT user float - sicslist setatt ${name} klass environment + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} - hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 # mkDriver hook code starts @@ -48,17 +48,10 @@ proc ::scobj::protekmm::mkDriver { sct_controller name ip_address tcp_port id da handle_exception ${catch_status} ${catch_message} } -namespace eval ::scobj::protekmm { - namespace export debug_threshold - namespace export debug_log - namespace export sics_log - namespace export mkDriver -} - -proc add_protekmm {name ip_address tcp_port id datype} { +proc ::scobj::protekmm::add_driver {name device_class simulation_flag ip_address tcp_port id datype} { set catch_status [ catch { - ::scobj::protekmm::sics_log 9 "add_protekmm ${name} ${ip_address} ${tcp_port} ${id} ${datype}" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + ::scobj::protekmm::sics_log 9 "::scobj::protekmm::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype}" + if {[string equal -nocase "${simulation_flag}" "false"]} { if {[string equal -nocase "aqadapter" "${ip_address}"]} { ::scobj::protekmm::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" makesctcontroller sct_${name} aqadapter ${tcp_port} @@ -67,14 +60,27 @@ proc add_protekmm {name ip_address tcp_port id datype} { makesctcontroller sct_${name} protek608 ${ip_address}:${tcp_port} } } else { - ::scobj::protekmm::sics_log 9 "[environment_simulation] => No sctcontroller for protekmm" + ::scobj::protekmm::sics_log 9 "simulation_flag={simulation_flag} => No sctcontroller for protekmm" } - ::scobj::protekmm::sics_log 1 "::scobj::protekmm::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${datype}" - ::scobj::protekmm::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${datype} + ::scobj::protekmm::sics_log 1 "::scobj::protekmm::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype}" + ::scobj::protekmm::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} } catch_message ] handle_exception ${catch_status} ${catch_message} } +namespace eval ::scobj::protekmm { + namespace export debug_threshold + namespace export debug_log + namespace export sics_log + namespace export mkDriver + namespace export add_driver +} + +proc add_protekmm {name ip_address tcp_port id datype} { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + ::scobj::protekmm::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${id}" "${datype}" +} + clientput "file evaluation of sct_protekmm.tcl" ::scobj::protekmm::sics_log 9 "file evaluation of sct_protekmm.tcl" @@ -83,6 +89,8 @@ proc ::scobj::protekmm::read_config {} { set ns "::scobj::protekmm" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + set device_class "environment" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -90,6 +98,12 @@ proc ::scobj::protekmm::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -100,9 +114,9 @@ proc ::scobj::protekmm::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "protekmm"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue" } elseif { [dict exists $v "asyncqueue"] } { set asyncqueue [dict get $v "asyncqueue"] if { [string equal -nocase ${asyncqueue} "sct"] } { @@ -144,9 +158,9 @@ proc ::scobj::protekmm::read_config {} { error "$name is missing configuration values $missing_list" } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_protekmm ${name} ${ip_address} ${tcp_port} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list } else { - add_protekmm ${name} "aqadapter" ${asyncqueue} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list } } } diff --git a/site_ansto/instrument/config/environment/temperature/sct_eurotherm_m2000.tcl b/site_ansto/instrument/config/environment/temperature/sct_eurotherm_m2000.tcl index cf09e93e..0d8f901c 100644 --- a/site_ansto/instrument/config/environment/temperature/sct_eurotherm_m2000.tcl +++ b/site_ansto/instrument/config/environment/temperature/sct_eurotherm_m2000.tcl @@ -27,18 +27,18 @@ proc ::scobj::eurotherm_m2000::sics_log {debug_level debug_string} { } catch_message ] } -proc ::scobj::eurotherm_m2000::mkDriver { sct_controller name ip_address tcp_port id datype dev_id tol } { - ::scobj::eurotherm_m2000::sics_log 9 "::scobj::eurotherm_m2000::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol}" +proc ::scobj::eurotherm_m2000::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port id datype dev_id tol } { + ::scobj::eurotherm_m2000::sics_log 9 "::scobj::eurotherm_m2000::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT user float - sicslist setatt ${name} klass environment + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} - hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 # mkDriver hook code starts @@ -48,17 +48,10 @@ proc ::scobj::eurotherm_m2000::mkDriver { sct_controller name ip_address tcp_por handle_exception ${catch_status} ${catch_message} } -namespace eval ::scobj::eurotherm_m2000 { - namespace export debug_threshold - namespace export debug_log - namespace export sics_log - namespace export mkDriver -} - -proc add_eurotherm_m2000 {name ip_address tcp_port id datype dev_id tol} { +proc ::scobj::eurotherm_m2000::add_driver {name device_class simulation_flag ip_address tcp_port id datype dev_id tol} { set catch_status [ catch { - ::scobj::eurotherm_m2000::sics_log 9 "add_eurotherm_m2000 ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol}" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + ::scobj::eurotherm_m2000::sics_log 9 "::scobj::eurotherm_m2000::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol}" + if {[string equal -nocase "${simulation_flag}" "false"]} { if {[string equal -nocase "aqadapter" "${ip_address}"]} { ::scobj::eurotherm_m2000::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" makesctcontroller sct_${name} aqadapter ${tcp_port} @@ -67,14 +60,27 @@ proc add_eurotherm_m2000 {name ip_address tcp_port id datype dev_id tol} { makesctcontroller sct_${name} std ${ip_address}:${tcp_port} } } else { - ::scobj::eurotherm_m2000::sics_log 9 "[environment_simulation] => No sctcontroller for eurotherm_m2000" + ::scobj::eurotherm_m2000::sics_log 9 "simulation_flag={simulation_flag} => No sctcontroller for eurotherm_m2000" } - ::scobj::eurotherm_m2000::sics_log 1 "::scobj::eurotherm_m2000::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol}" - ::scobj::eurotherm_m2000::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol} + ::scobj::eurotherm_m2000::sics_log 1 "::scobj::eurotherm_m2000::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol}" + ::scobj::eurotherm_m2000::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol} } catch_message ] handle_exception ${catch_status} ${catch_message} } +namespace eval ::scobj::eurotherm_m2000 { + namespace export debug_threshold + namespace export debug_log + namespace export sics_log + namespace export mkDriver + namespace export add_driver +} + +proc add_eurotherm_m2000 {name ip_address tcp_port id datype dev_id tol} { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + ::scobj::eurotherm_m2000::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${id}" "${datype}" "${dev_id}" "${tol}" +} + clientput "file evaluation of sct_eurotherm_m2000.tcl" ::scobj::eurotherm_m2000::sics_log 9 "file evaluation of sct_eurotherm_m2000.tcl" @@ -83,6 +89,8 @@ proc ::scobj::eurotherm_m2000::read_config {} { set ns "::scobj::eurotherm_m2000" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + set device_class "environment" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -90,6 +98,12 @@ proc ::scobj::eurotherm_m2000::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -100,9 +114,9 @@ proc ::scobj::eurotherm_m2000::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "eurotherm_m2000"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue" } elseif { [dict exists $v "asyncqueue"] } { set asyncqueue [dict get $v "asyncqueue"] if { [string equal -nocase ${asyncqueue} "sct"] } { @@ -144,9 +158,9 @@ proc ::scobj::eurotherm_m2000::read_config {} { error "$name is missing configuration values $missing_list" } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_eurotherm_m2000 ${name} ${ip_address} ${tcp_port} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list } else { - add_eurotherm_m2000 ${name} "aqadapter" ${asyncqueue} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list } } } diff --git a/site_ansto/instrument/config/environment/temperature/sct_julabo_lh45_gen.tcl b/site_ansto/instrument/config/environment/temperature/sct_julabo_lh45_gen.tcl index 3850e656..aa790cec 100644 --- a/site_ansto/instrument/config/environment/temperature/sct_julabo_lh45_gen.tcl +++ b/site_ansto/instrument/config/environment/temperature/sct_julabo_lh45_gen.tcl @@ -364,14 +364,14 @@ proc ::scobj::julabo_lh45_gen::setValue {tc_root nextState cmd_str} { handle_exception ${catch_status} ${catch_message} } -proc ::scobj::julabo_lh45_gen::mkDriver { sct_controller name ip_address tcp_port id ctrl_sensor tol } { - ::scobj::julabo_lh45_gen::sics_log 9 "::scobj::julabo_lh45_gen::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port} ${id} ${ctrl_sensor} ${tol}" +proc ::scobj::julabo_lh45_gen::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port id ctrl_sensor tol } { + ::scobj::julabo_lh45_gen::sics_log 9 "::scobj::julabo_lh45_gen::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${ctrl_sensor} ${tol}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT - sicslist setatt ${name} klass environment + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} @@ -481,7 +481,7 @@ proc ::scobj::julabo_lh45_gen::mkDriver { sct_controller name ip_address tcp_por hsetprop ${scobj_hpath} klass "@none" hsetprop ${scobj_hpath} type "part" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/heating_power_percent 1 ${sct_controller} poll ${scobj_hpath}/lh45_state 1 ${sct_controller} poll ${scobj_hpath}/overtemp_warnlimit 1 @@ -489,7 +489,7 @@ proc ::scobj::julabo_lh45_gen::mkDriver { sct_controller name ip_address tcp_por ${sct_controller} poll ${scobj_hpath}/subtemp_warnlimit 1 ${sct_controller} write ${scobj_hpath}/setpoint } else { - ::scobj::julabo_lh45_gen::sics_log 9 "[environment_simulation] => No poll/write for julabo_lh45_gen" + ::scobj::julabo_lh45_gen::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for julabo_lh45_gen" } hfactory ${scobj_hpath}/mode plain spy none @@ -529,13 +529,13 @@ proc ::scobj::julabo_lh45_gen::mkDriver { sct_controller name ip_address tcp_por hsetprop ${scobj_hpath}/mode/on_else_off type "part" hsetprop ${scobj_hpath}/mode/on_else_off nxalias "${name}_mode_on_else_off" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/mode/ext_else_bath 1 ${sct_controller} poll ${scobj_hpath}/mode/on_else_off 1 ${sct_controller} write ${scobj_hpath}/mode/ext_else_bath ${sct_controller} write ${scobj_hpath}/mode/on_else_off } else { - ::scobj::julabo_lh45_gen::sics_log 9 "[environment_simulation] => No poll/write for julabo_lh45_gen" + ::scobj::julabo_lh45_gen::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for julabo_lh45_gen" } hfactory ${scobj_hpath}/sensor plain spy none @@ -611,16 +611,16 @@ proc ::scobj::julabo_lh45_gen::mkDriver { sct_controller name ip_address tcp_por hsetprop ${scobj_hpath}/sensor/value units "C" hsetprop ${scobj_hpath}/sensor/value nxalias "${name}_sensor_value" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/sensor/bathtemp 1 ${sct_controller} poll ${scobj_hpath}/sensor/external 1 } else { - ::scobj::julabo_lh45_gen::sics_log 9 "[environment_simulation] => No poll/write for julabo_lh45_gen" + ::scobj::julabo_lh45_gen::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for julabo_lh45_gen" } - hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ansto_makesctdrive ${name}_setpoint ${scobj_hpath}/setpoint ${scobj_hpath}/sensor/value ${sct_controller} } # mkDriver hook code starts @@ -635,17 +635,10 @@ proc ::scobj::julabo_lh45_gen::mkDriver { sct_controller name ip_address tcp_por handle_exception ${catch_status} ${catch_message} } -namespace eval ::scobj::julabo_lh45_gen { - namespace export debug_threshold - namespace export debug_log - namespace export sics_log - namespace export mkDriver -} - -proc add_julabo_lh45_gen {name ip_address tcp_port {id 1} {ctrl_sensor "bath"} {tol 5.0}} { +proc ::scobj::julabo_lh45_gen::add_driver {name device_class simulation_flag ip_address tcp_port {id 1} {ctrl_sensor "bath"} {tol 5.0}} { set catch_status [ catch { - ::scobj::julabo_lh45_gen::sics_log 9 "add_julabo_lh45_gen ${name} ${ip_address} ${tcp_port} ${id} ${ctrl_sensor} ${tol}" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + ::scobj::julabo_lh45_gen::sics_log 9 "::scobj::julabo_lh45_gen::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${ctrl_sensor} ${tol}" + if {[string equal -nocase "${simulation_flag}" "false"]} { if {[string equal -nocase "aqadapter" "${ip_address}"]} { ::scobj::julabo_lh45_gen::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" makesctcontroller sct_${name} aqadapter ${tcp_port} @@ -654,14 +647,27 @@ proc add_julabo_lh45_gen {name ip_address tcp_port {id 1} {ctrl_sensor "bath"} { makesctcontroller sct_${name} std ${ip_address}:${tcp_port} "\r" } } else { - ::scobj::julabo_lh45_gen::sics_log 9 "[environment_simulation] => No sctcontroller for julabo_lh45_gen" + ::scobj::julabo_lh45_gen::sics_log 9 "simulation_flag={simulation_flag} => No sctcontroller for julabo_lh45_gen" } - ::scobj::julabo_lh45_gen::sics_log 1 "::scobj::julabo_lh45_gen::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${ctrl_sensor} ${tol}" - ::scobj::julabo_lh45_gen::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${ctrl_sensor} ${tol} + ::scobj::julabo_lh45_gen::sics_log 1 "::scobj::julabo_lh45_gen::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${ctrl_sensor} ${tol}" + ::scobj::julabo_lh45_gen::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${ctrl_sensor} ${tol} } catch_message ] handle_exception ${catch_status} ${catch_message} } +namespace eval ::scobj::julabo_lh45_gen { + namespace export debug_threshold + namespace export debug_log + namespace export sics_log + namespace export mkDriver + namespace export add_driver +} + +proc add_julabo_lh45_gen {name ip_address tcp_port {id 1} {ctrl_sensor "bath"} {tol 5.0}} { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + ::scobj::julabo_lh45_gen::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${{id}" "${1}}" "${{ctrl_sensor}" "${"bath"}}" "${{tol}" "${5.0}}" +} + clientput "file evaluation of sct_julabo_lh45_gen.tcl" ::scobj::julabo_lh45_gen::sics_log 9 "file evaluation of sct_julabo_lh45_gen.tcl" @@ -670,6 +676,8 @@ proc ::scobj::julabo_lh45_gen::read_config {} { set ns "::scobj::julabo_lh45_gen" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + set device_class "environment" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -677,6 +685,12 @@ proc ::scobj::julabo_lh45_gen::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -687,9 +701,9 @@ proc ::scobj::julabo_lh45_gen::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "julabo_lh45_gen"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue" } elseif { [dict exists $v "asyncqueue"] } { set asyncqueue [dict get $v "asyncqueue"] if { [string equal -nocase ${asyncqueue} "sct"] } { @@ -731,9 +745,9 @@ proc ::scobj::julabo_lh45_gen::read_config {} { error "$name is missing configuration values $missing_list" } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_julabo_lh45_gen ${name} ${ip_address} ${tcp_port} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list } else { - add_julabo_lh45_gen ${name} "aqadapter" ${asyncqueue} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list } } } diff --git a/site_ansto/instrument/config/environment/temperature/sct_lakeshore_218.tcl b/site_ansto/instrument/config/environment/temperature/sct_lakeshore_218.tcl index 60da9895..e0aba1ab 100644 --- a/site_ansto/instrument/config/environment/temperature/sct_lakeshore_218.tcl +++ b/site_ansto/instrument/config/environment/temperature/sct_lakeshore_218.tcl @@ -157,14 +157,14 @@ proc ::scobj::lakeshore_218::setValue {tc_root nextState cmd_str} { handle_exception ${catch_status} ${catch_message} } -proc ::scobj::lakeshore_218::mkDriver { sct_controller name ip_address tcp_port } { - ::scobj::lakeshore_218::sics_log 9 "::scobj::lakeshore_218::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port}" +proc ::scobj::lakeshore_218::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port } { + ::scobj::lakeshore_218::sics_log 9 "::scobj::lakeshore_218::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT - sicslist setatt ${name} klass NXdetector + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} @@ -186,10 +186,10 @@ proc ::scobj::lakeshore_218::mkDriver { sct_controller name ip_address tcp_port hsetprop ${scobj_hpath} klass "@none" hsetprop ${scobj_hpath} type "part" - if {[string equal -nocase [SplitReply [detector_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/krdg 1 } else { - ::scobj::lakeshore_218::sics_log 9 "[detector_simulation] => No poll/write for lakeshore_218" + ::scobj::lakeshore_218::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for lakeshore_218" } hfactory ${scobj_hpath}/sensor plain spy none @@ -301,7 +301,7 @@ proc ::scobj::lakeshore_218::mkDriver { sct_controller name ip_address tcp_port hsetprop ${scobj_hpath}/sensor/ch8 type "part" hsetprop ${scobj_hpath}/sensor/ch8 nxalias "${name}_sensor_ch8" - if {[string equal -nocase [SplitReply [detector_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/sensor/ch1 1 ${sct_controller} poll ${scobj_hpath}/sensor/ch2 1 ${sct_controller} poll ${scobj_hpath}/sensor/ch3 1 @@ -311,9 +311,9 @@ proc ::scobj::lakeshore_218::mkDriver { sct_controller name ip_address tcp_port ${sct_controller} poll ${scobj_hpath}/sensor/ch7 1 ${sct_controller} poll ${scobj_hpath}/sensor/ch8 1 } else { - ::scobj::lakeshore_218::sics_log 9 "[detector_simulation] => No poll/write for lakeshore_218" + ::scobj::lakeshore_218::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for lakeshore_218" } - hsetprop ${scobj_hpath} klass NXdetector + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 # mkDriver hook code goes here @@ -321,31 +321,37 @@ proc ::scobj::lakeshore_218::mkDriver { sct_controller name ip_address tcp_port handle_exception ${catch_status} ${catch_message} } +proc ::scobj::lakeshore_218::add_driver {name device_class simulation_flag ip_address tcp_port} { + set catch_status [ catch { + ::scobj::lakeshore_218::sics_log 9 "::scobj::lakeshore_218::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" + if {[string equal -nocase "${simulation_flag}" "false"]} { + if {[string equal -nocase "aqadapter" "${ip_address}"]} { + ::scobj::lakeshore_218::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" + makesctcontroller sct_${name} aqadapter ${tcp_port} + } else { + ::scobj::lakeshore_218::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}" + makesctcontroller sct_${name} std ${ip_address}:${tcp_port} + } + } else { + ::scobj::lakeshore_218::sics_log 9 "simulation_flag={simulation_flag} => No sctcontroller for lakeshore_218" + } + ::scobj::lakeshore_218::sics_log 1 "::scobj::lakeshore_218::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" + ::scobj::lakeshore_218::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + namespace eval ::scobj::lakeshore_218 { namespace export debug_threshold namespace export debug_log namespace export sics_log namespace export mkDriver + namespace export add_driver } proc add_lakeshore_218 {name ip_address tcp_port} { - set catch_status [ catch { - ::scobj::lakeshore_218::sics_log 9 "add_lakeshore_218 ${name} ${ip_address} ${tcp_port}" - if {[string equal -nocase [SplitReply [detector_simulation]] "false"]} { - if {[string equal -nocase "aqadapter" "${ip_address}"]} { - ::scobj::lakeshore_218::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" - makesctcontroller sct_${name} aqadapter ${tcp_port} - } else { - ::scobj::lakeshore_218::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}" - makesctcontroller sct_${name} std ${ip_address}:${tcp_port} - } - } else { - ::scobj::lakeshore_218::sics_log 9 "[detector_simulation] => No sctcontroller for lakeshore_218" - } - ::scobj::lakeshore_218::sics_log 1 "::scobj::lakeshore_218::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port}" - ::scobj::lakeshore_218::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} - } catch_message ] - handle_exception ${catch_status} ${catch_message} + set simulation_flag "[string tolower [SplitReply [detector_simulation]]]" + ::scobj::lakeshore_218::add_driver ${name} "NXdetector" "${simulation_flag}" ${ip_address} ${tcp_port} } clientput "file evaluation of sct_lakeshore_218.tcl" @@ -356,6 +362,8 @@ proc ::scobj::lakeshore_218::read_config {} { set ns "::scobj::lakeshore_218" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [detector_simulation]]]" + set device_class "NXdetector" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -363,6 +371,12 @@ proc ::scobj::lakeshore_218::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -373,9 +387,9 @@ proc ::scobj::lakeshore_218::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "lakeshore_218"] } { - if { ![string equal -nocase [SplitReply [detector_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[detector_simulation] => using null asyncqueue" + ${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue" } elseif { [dict exists $v "asyncqueue"] } { set asyncqueue [dict get $v "asyncqueue"] if { [string equal -nocase ${asyncqueue} "sct"] } { @@ -402,9 +416,9 @@ proc ::scobj::lakeshore_218::read_config {} { } } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_lakeshore_218 ${name} ${ip_address} ${tcp_port} + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} } else { - add_lakeshore_218 ${name} "aqadapter" ${asyncqueue} + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} } } } diff --git a/site_ansto/instrument/config/environment/temperature/sct_lakeshore_m370.tcl b/site_ansto/instrument/config/environment/temperature/sct_lakeshore_m370.tcl index f40dbae3..401527b9 100644 --- a/site_ansto/instrument/config/environment/temperature/sct_lakeshore_m370.tcl +++ b/site_ansto/instrument/config/environment/temperature/sct_lakeshore_m370.tcl @@ -27,18 +27,18 @@ proc ::scobj::lakeshore_m370::sics_log {debug_level debug_string} { } catch_message ] } -proc ::scobj::lakeshore_m370::mkDriver { sct_controller name ip_address tcp_port id tol } { - ::scobj::lakeshore_m370::sics_log 9 "::scobj::lakeshore_m370::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port} ${id} ${tol}" +proc ::scobj::lakeshore_m370::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port id tol } { + ::scobj::lakeshore_m370::sics_log 9 "::scobj::lakeshore_m370::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${tol}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT user float - sicslist setatt ${name} klass environment + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} - hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 # mkDriver hook code starts @@ -52,17 +52,10 @@ proc ::scobj::lakeshore_m370::mkDriver { sct_controller name ip_address tcp_port handle_exception ${catch_status} ${catch_message} } -namespace eval ::scobj::lakeshore_m370 { - namespace export debug_threshold - namespace export debug_log - namespace export sics_log - namespace export mkDriver -} - -proc add_lakeshore_m370 {name ip_address tcp_port id tol} { +proc ::scobj::lakeshore_m370::add_driver {name device_class simulation_flag ip_address tcp_port id tol} { set catch_status [ catch { - ::scobj::lakeshore_m370::sics_log 9 "add_lakeshore_m370 ${name} ${ip_address} ${tcp_port} ${id} ${tol}" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + ::scobj::lakeshore_m370::sics_log 9 "::scobj::lakeshore_m370::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${tol}" + if {[string equal -nocase "${simulation_flag}" "false"]} { if {[string equal -nocase "aqadapter" "${ip_address}"]} { ::scobj::lakeshore_m370::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" makesctcontroller sct_${name} aqadapter ${tcp_port} @@ -71,14 +64,27 @@ proc add_lakeshore_m370 {name ip_address tcp_port id tol} { makesctcontroller sct_${name} std ${ip_address}:${tcp_port} } } else { - ::scobj::lakeshore_m370::sics_log 9 "[environment_simulation] => No sctcontroller for lakeshore_m370" + ::scobj::lakeshore_m370::sics_log 9 "simulation_flag={simulation_flag} => No sctcontroller for lakeshore_m370" } - ::scobj::lakeshore_m370::sics_log 1 "::scobj::lakeshore_m370::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${tol}" - ::scobj::lakeshore_m370::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${tol} + ::scobj::lakeshore_m370::sics_log 1 "::scobj::lakeshore_m370::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${tol}" + ::scobj::lakeshore_m370::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${tol} } catch_message ] handle_exception ${catch_status} ${catch_message} } +namespace eval ::scobj::lakeshore_m370 { + namespace export debug_threshold + namespace export debug_log + namespace export sics_log + namespace export mkDriver + namespace export add_driver +} + +proc add_lakeshore_m370 {name ip_address tcp_port id tol} { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + ::scobj::lakeshore_m370::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${id}" "${tol}" +} + clientput "file evaluation of sct_lakeshore_m370.tcl" ::scobj::lakeshore_m370::sics_log 9 "file evaluation of sct_lakeshore_m370.tcl" @@ -87,6 +93,8 @@ proc ::scobj::lakeshore_m370::read_config {} { set ns "::scobj::lakeshore_m370" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + set device_class "environment" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -94,6 +102,12 @@ proc ::scobj::lakeshore_m370::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -104,9 +118,9 @@ proc ::scobj::lakeshore_m370::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "lakeshore_m370"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue" } elseif { [dict exists $v "asyncqueue"] } { set asyncqueue [dict get $v "asyncqueue"] if { [string equal -nocase ${asyncqueue} "sct"] } { @@ -148,9 +162,9 @@ proc ::scobj::lakeshore_m370::read_config {} { error "$name is missing configuration values $missing_list" } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_lakeshore_m370 ${name} ${ip_address} ${tcp_port} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list } else { - add_lakeshore_m370 ${name} "aqadapter" ${asyncqueue} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list } } } diff --git a/site_ansto/instrument/config/environment/temperature/sct_ls336.tcl b/site_ansto/instrument/config/environment/temperature/sct_ls336.tcl index fa70e8b1..f965579c 100644 --- a/site_ansto/instrument/config/environment/temperature/sct_ls336.tcl +++ b/site_ansto/instrument/config/environment/temperature/sct_ls336.tcl @@ -27,18 +27,18 @@ proc ::scobj::ls336::sics_log {debug_level debug_string} { } catch_message ] } -proc ::scobj::ls336::mkDriver { sct_controller name ip_address tcp_port id datype tol1 tol2 } { - ::scobj::ls336::sics_log 9 "::scobj::ls336::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${tol1} ${tol2}" +proc ::scobj::ls336::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port id datype tol1 tol2 } { + ::scobj::ls336::sics_log 9 "::scobj::ls336::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${tol1} ${tol2}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT - sicslist setatt ${name} klass environment + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} - hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 # mkDriver hook code starts @@ -48,17 +48,10 @@ proc ::scobj::ls336::mkDriver { sct_controller name ip_address tcp_port id datyp handle_exception ${catch_status} ${catch_message} } -namespace eval ::scobj::ls336 { - namespace export debug_threshold - namespace export debug_log - namespace export sics_log - namespace export mkDriver -} - -proc add_ls336 {name ip_address tcp_port id datype {tol1 1.0} {tol2 1.0}} { +proc ::scobj::ls336::add_driver {name device_class simulation_flag ip_address tcp_port id datype {tol1 1.0} {tol2 1.0}} { set catch_status [ catch { - ::scobj::ls336::sics_log 9 "add_ls336 ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${tol1} ${tol2}" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + ::scobj::ls336::sics_log 9 "::scobj::ls336::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${tol1} ${tol2}" + if {[string equal -nocase "${simulation_flag}" "false"]} { if {[string equal -nocase "aqadapter" "${ip_address}"]} { ::scobj::ls336::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" makesctcontroller sct_${name} aqadapter ${tcp_port} @@ -67,14 +60,27 @@ proc add_ls336 {name ip_address tcp_port id datype {tol1 1.0} {tol2 1.0}} { makesctcontroller sct_${name} std ${ip_address}:${tcp_port} } } else { - ::scobj::ls336::sics_log 9 "[environment_simulation] => No sctcontroller for ls336" + ::scobj::ls336::sics_log 9 "simulation_flag={simulation_flag} => No sctcontroller for ls336" } - ::scobj::ls336::sics_log 1 "::scobj::ls336::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${tol1} ${tol2}" - ::scobj::ls336::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${tol1} ${tol2} + ::scobj::ls336::sics_log 1 "::scobj::ls336::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${tol1} ${tol2}" + ::scobj::ls336::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${tol1} ${tol2} } catch_message ] handle_exception ${catch_status} ${catch_message} } +namespace eval ::scobj::ls336 { + namespace export debug_threshold + namespace export debug_log + namespace export sics_log + namespace export mkDriver + namespace export add_driver +} + +proc add_ls336 {name ip_address tcp_port id datype {tol1 1.0} {tol2 1.0}} { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + ::scobj::ls336::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${id}" "${datype}" "${{tol1}" "${1.0}}" "${{tol2}" "${1.0}}" +} + clientput "file evaluation of sct_ls336.tcl" ::scobj::ls336::sics_log 9 "file evaluation of sct_ls336.tcl" @@ -83,6 +89,8 @@ proc ::scobj::ls336::read_config {} { set ns "::scobj::ls336" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + set device_class "environment" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -90,6 +98,12 @@ proc ::scobj::ls336::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -100,9 +114,9 @@ proc ::scobj::ls336::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "ls336"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue" } elseif { [dict exists $v "asyncqueue"] } { set asyncqueue [dict get $v "asyncqueue"] if { [string equal -nocase ${asyncqueue} "sct"] } { @@ -144,9 +158,9 @@ proc ::scobj::ls336::read_config {} { error "$name is missing configuration values $missing_list" } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_ls336 ${name} ${ip_address} ${tcp_port} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list } else { - add_ls336 ${name} "aqadapter" ${asyncqueue} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list } } } diff --git a/site_ansto/instrument/config/environment/temperature/sct_ls340.tcl b/site_ansto/instrument/config/environment/temperature/sct_ls340.tcl index b2a7f642..f607f937 100644 --- a/site_ansto/instrument/config/environment/temperature/sct_ls340.tcl +++ b/site_ansto/instrument/config/environment/temperature/sct_ls340.tcl @@ -27,18 +27,18 @@ proc ::scobj::ls340::sics_log {debug_level debug_string} { } catch_message ] } -proc ::scobj::ls340::mkDriver { sct_controller name ip_address tcp_port id datype tol1 tol2 } { - ::scobj::ls340::sics_log 9 "::scobj::ls340::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${tol1} ${tol2}" +proc ::scobj::ls340::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port id datype tol1 tol2 } { + ::scobj::ls340::sics_log 9 "::scobj::ls340::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${tol1} ${tol2}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT - sicslist setatt ${name} klass environment + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} - hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 # mkDriver hook code starts @@ -48,17 +48,10 @@ proc ::scobj::ls340::mkDriver { sct_controller name ip_address tcp_port id datyp handle_exception ${catch_status} ${catch_message} } -namespace eval ::scobj::ls340 { - namespace export debug_threshold - namespace export debug_log - namespace export sics_log - namespace export mkDriver -} - -proc add_ls340 {name ip_address tcp_port id datype {tol1 1.0} {tol2 1.0}} { +proc ::scobj::ls340::add_driver {name device_class simulation_flag ip_address tcp_port id datype {tol1 1.0} {tol2 1.0}} { set catch_status [ catch { - ::scobj::ls340::sics_log 9 "add_ls340 ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${tol1} ${tol2}" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + ::scobj::ls340::sics_log 9 "::scobj::ls340::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${tol1} ${tol2}" + if {[string equal -nocase "${simulation_flag}" "false"]} { if {[string equal -nocase "aqadapter" "${ip_address}"]} { ::scobj::ls340::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" makesctcontroller sct_${name} aqadapter ${tcp_port} @@ -67,14 +60,27 @@ proc add_ls340 {name ip_address tcp_port id datype {tol1 1.0} {tol2 1.0}} { makesctcontroller sct_${name} std ${ip_address}:${tcp_port} } } else { - ::scobj::ls340::sics_log 9 "[environment_simulation] => No sctcontroller for ls340" + ::scobj::ls340::sics_log 9 "simulation_flag={simulation_flag} => No sctcontroller for ls340" } - ::scobj::ls340::sics_log 1 "::scobj::ls340::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${tol1} ${tol2}" - ::scobj::ls340::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${tol1} ${tol2} + ::scobj::ls340::sics_log 1 "::scobj::ls340::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${tol1} ${tol2}" + ::scobj::ls340::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${tol1} ${tol2} } catch_message ] handle_exception ${catch_status} ${catch_message} } +namespace eval ::scobj::ls340 { + namespace export debug_threshold + namespace export debug_log + namespace export sics_log + namespace export mkDriver + namespace export add_driver +} + +proc add_ls340 {name ip_address tcp_port id datype {tol1 1.0} {tol2 1.0}} { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + ::scobj::ls340::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${id}" "${datype}" "${{tol1}" "${1.0}}" "${{tol2}" "${1.0}}" +} + clientput "file evaluation of sct_ls340.tcl" ::scobj::ls340::sics_log 9 "file evaluation of sct_ls340.tcl" @@ -83,6 +89,8 @@ proc ::scobj::ls340::read_config {} { set ns "::scobj::ls340" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + set device_class "environment" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -90,6 +98,12 @@ proc ::scobj::ls340::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -100,9 +114,9 @@ proc ::scobj::ls340::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "ls340"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue" } elseif { [dict exists $v "asyncqueue"] } { set asyncqueue [dict get $v "asyncqueue"] if { [string equal -nocase ${asyncqueue} "sct"] } { @@ -144,9 +158,9 @@ proc ::scobj::ls340::read_config {} { error "$name is missing configuration values $missing_list" } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_ls340 ${name} ${ip_address} ${tcp_port} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list } else { - add_ls340 ${name} "aqadapter" ${asyncqueue} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list } } } diff --git a/site_ansto/instrument/config/environment/temperature/sct_mercury_base.tcl b/site_ansto/instrument/config/environment/temperature/sct_mercury_base.tcl index b83c09b6..ff95de1d 100644 --- a/site_ansto/instrument/config/environment/temperature/sct_mercury_base.tcl +++ b/site_ansto/instrument/config/environment/temperature/sct_mercury_base.tcl @@ -266,14 +266,14 @@ proc ::scobj::mercury_base::setValue {tc_root nextState cmd_str} { handle_exception ${catch_status} ${catch_message} } -proc ::scobj::mercury_base::mkDriver { sct_controller name ip_address tcp_port id tol } { - ::scobj::mercury_base::sics_log 9 "::scobj::mercury_base::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port} ${id} ${tol}" +proc ::scobj::mercury_base::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port id tol } { + ::scobj::mercury_base::sics_log 9 "::scobj::mercury_base::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${tol}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT - sicslist setatt ${name} klass environment + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} @@ -351,14 +351,14 @@ proc ::scobj::mercury_base::mkDriver { sct_controller name ip_address tcp_port i hsetprop ${scobj_hpath}/Loop1/setpoint type "drivable" hsetprop ${scobj_hpath}/Loop1/setpoint nxalias "${name}_Loop1_setpoint" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/Loop1/nick 15 ${sct_controller} poll ${scobj_hpath}/Loop1/power 5 ${sct_controller} poll ${scobj_hpath}/Loop1/sensor 1 ${sct_controller} poll ${scobj_hpath}/Loop1/setpoint 5 ${sct_controller} write ${scobj_hpath}/Loop1/setpoint } else { - ::scobj::mercury_base::sics_log 9 "[environment_simulation] => No poll/write for mercury_base" + ::scobj::mercury_base::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for mercury_base" } hfactory ${scobj_hpath}/Loop2 plain spy none @@ -434,14 +434,14 @@ proc ::scobj::mercury_base::mkDriver { sct_controller name ip_address tcp_port i hsetprop ${scobj_hpath}/Loop2/setpoint type "drivable" hsetprop ${scobj_hpath}/Loop2/setpoint nxalias "${name}_Loop2_setpoint" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/Loop2/nick 15 ${sct_controller} poll ${scobj_hpath}/Loop2/power 5 ${sct_controller} poll ${scobj_hpath}/Loop2/sensor 1 ${sct_controller} poll ${scobj_hpath}/Loop2/setpoint 5 ${sct_controller} write ${scobj_hpath}/Loop2/setpoint } else { - ::scobj::mercury_base::sics_log 9 "[environment_simulation] => No poll/write for mercury_base" + ::scobj::mercury_base::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for mercury_base" } hfactory ${scobj_hpath}/Loop3 plain spy none @@ -517,19 +517,19 @@ proc ::scobj::mercury_base::mkDriver { sct_controller name ip_address tcp_port i hsetprop ${scobj_hpath}/Loop3/setpoint type "drivable" hsetprop ${scobj_hpath}/Loop3/setpoint nxalias "${name}_Loop3_setpoint" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/Loop3/nick 15 ${sct_controller} poll ${scobj_hpath}/Loop3/power 5 ${sct_controller} poll ${scobj_hpath}/Loop3/sensor 1 ${sct_controller} poll ${scobj_hpath}/Loop3/setpoint 5 ${sct_controller} write ${scobj_hpath}/Loop3/setpoint } else { - ::scobj::mercury_base::sics_log 9 "[environment_simulation] => No poll/write for mercury_base" + ::scobj::mercury_base::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for mercury_base" } - hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ansto_makesctdrive ${name}_Loop1_setpoint ${scobj_hpath}/Loop1/setpoint ${scobj_hpath}/Loop1/sensor ${sct_controller} ansto_makesctdrive ${name}_Loop2_setpoint ${scobj_hpath}/Loop2/setpoint ${scobj_hpath}/Loop2/sensor ${sct_controller} ansto_makesctdrive ${name}_Loop3_setpoint ${scobj_hpath}/Loop3/setpoint ${scobj_hpath}/Loop3/sensor ${sct_controller} @@ -539,17 +539,10 @@ proc ::scobj::mercury_base::mkDriver { sct_controller name ip_address tcp_port i handle_exception ${catch_status} ${catch_message} } -namespace eval ::scobj::mercury_base { - namespace export debug_threshold - namespace export debug_log - namespace export sics_log - namespace export mkDriver -} - -proc add_mercury_base {name ip_address tcp_port {id 99} {tol 1}} { +proc ::scobj::mercury_base::add_driver {name device_class simulation_flag ip_address tcp_port {id 99} {tol 1}} { set catch_status [ catch { - ::scobj::mercury_base::sics_log 9 "add_mercury_base ${name} ${ip_address} ${tcp_port} ${id} ${tol}" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + ::scobj::mercury_base::sics_log 9 "::scobj::mercury_base::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${tol}" + if {[string equal -nocase "${simulation_flag}" "false"]} { if {[string equal -nocase "aqadapter" "${ip_address}"]} { ::scobj::mercury_base::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" makesctcontroller sct_${name} aqadapter ${tcp_port} @@ -558,14 +551,27 @@ proc add_mercury_base {name ip_address tcp_port {id 99} {tol 1}} { makesctcontroller sct_${name} std ${ip_address}:${tcp_port} } } else { - ::scobj::mercury_base::sics_log 9 "[environment_simulation] => No sctcontroller for mercury_base" + ::scobj::mercury_base::sics_log 9 "simulation_flag={simulation_flag} => No sctcontroller for mercury_base" } - ::scobj::mercury_base::sics_log 1 "::scobj::mercury_base::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${tol}" - ::scobj::mercury_base::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${tol} + ::scobj::mercury_base::sics_log 1 "::scobj::mercury_base::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${tol}" + ::scobj::mercury_base::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${tol} } catch_message ] handle_exception ${catch_status} ${catch_message} } +namespace eval ::scobj::mercury_base { + namespace export debug_threshold + namespace export debug_log + namespace export sics_log + namespace export mkDriver + namespace export add_driver +} + +proc add_mercury_base {name ip_address tcp_port {id 99} {tol 1}} { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + ::scobj::mercury_base::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${{id}" "${99}}" "${{tol}" "${1}}" +} + clientput "file evaluation of sct_mercury_base.tcl" ::scobj::mercury_base::sics_log 9 "file evaluation of sct_mercury_base.tcl" @@ -574,6 +580,8 @@ proc ::scobj::mercury_base::read_config {} { set ns "::scobj::mercury_base" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + set device_class "environment" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -581,6 +589,12 @@ proc ::scobj::mercury_base::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -591,9 +605,9 @@ proc ::scobj::mercury_base::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "mercury_base"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue" } elseif { [dict exists $v "asyncqueue"] } { set asyncqueue [dict get $v "asyncqueue"] if { [string equal -nocase ${asyncqueue} "sct"] } { @@ -635,9 +649,9 @@ proc ::scobj::mercury_base::read_config {} { error "$name is missing configuration values $missing_list" } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_mercury_base ${name} ${ip_address} ${tcp_port} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list } else { - add_mercury_base ${name} "aqadapter" ${asyncqueue} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list } } } diff --git a/site_ansto/instrument/config/environment/temperature/sct_mercury_level.tcl b/site_ansto/instrument/config/environment/temperature/sct_mercury_level.tcl index 40f084b5..897c6c71 100644 --- a/site_ansto/instrument/config/environment/temperature/sct_mercury_level.tcl +++ b/site_ansto/instrument/config/environment/temperature/sct_mercury_level.tcl @@ -137,14 +137,14 @@ proc ::scobj::mercury_level::setValue {tc_root nextState cmd_str} { handle_exception ${catch_status} ${catch_message} } -proc ::scobj::mercury_level::mkDriver { sct_controller name ip_address tcp_port id } { - ::scobj::mercury_level::sics_log 9 "::scobj::mercury_level::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port} ${id}" +proc ::scobj::mercury_level::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port id } { + ::scobj::mercury_level::sics_log 9 "::scobj::mercury_level::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT - sicslist setatt ${name} klass environment + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} @@ -184,13 +184,13 @@ proc ::scobj::mercury_level::mkDriver { sct_controller name ip_address tcp_port hsetprop ${scobj_hpath}/Level/Nitrogen type "part" hsetprop ${scobj_hpath}/Level/Nitrogen nxalias "${name}_Level_Nitrogen" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/Level/Helium 15 ${sct_controller} poll ${scobj_hpath}/Level/Nitrogen 15 } else { - ::scobj::mercury_level::sics_log 9 "[environment_simulation] => No poll/write for mercury_level" + ::scobj::mercury_level::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for mercury_level" } - hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 # mkDriver hook code goes here @@ -198,31 +198,37 @@ proc ::scobj::mercury_level::mkDriver { sct_controller name ip_address tcp_port handle_exception ${catch_status} ${catch_message} } +proc ::scobj::mercury_level::add_driver {name device_class simulation_flag ip_address tcp_port {id 99}} { + set catch_status [ catch { + ::scobj::mercury_level::sics_log 9 "::scobj::mercury_level::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id}" + if {[string equal -nocase "${simulation_flag}" "false"]} { + if {[string equal -nocase "aqadapter" "${ip_address}"]} { + ::scobj::mercury_level::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" + makesctcontroller sct_${name} aqadapter ${tcp_port} + } else { + ::scobj::mercury_level::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}" + makesctcontroller sct_${name} std ${ip_address}:${tcp_port} + } + } else { + ::scobj::mercury_level::sics_log 9 "simulation_flag={simulation_flag} => No sctcontroller for mercury_level" + } + ::scobj::mercury_level::sics_log 1 "::scobj::mercury_level::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id}" + ::scobj::mercury_level::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + namespace eval ::scobj::mercury_level { namespace export debug_threshold namespace export debug_log namespace export sics_log namespace export mkDriver + namespace export add_driver } proc add_mercury_level {name ip_address tcp_port {id 99}} { - set catch_status [ catch { - ::scobj::mercury_level::sics_log 9 "add_mercury_level ${name} ${ip_address} ${tcp_port} ${id}" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { - if {[string equal -nocase "aqadapter" "${ip_address}"]} { - ::scobj::mercury_level::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" - makesctcontroller sct_${name} aqadapter ${tcp_port} - } else { - ::scobj::mercury_level::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}" - makesctcontroller sct_${name} std ${ip_address}:${tcp_port} - } - } else { - ::scobj::mercury_level::sics_log 9 "[environment_simulation] => No sctcontroller for mercury_level" - } - ::scobj::mercury_level::sics_log 1 "::scobj::mercury_level::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id}" - ::scobj::mercury_level::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} - } catch_message ] - handle_exception ${catch_status} ${catch_message} + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + ::scobj::mercury_level::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${{id}" "${99}}" } clientput "file evaluation of sct_mercury_level.tcl" @@ -233,6 +239,8 @@ proc ::scobj::mercury_level::read_config {} { set ns "::scobj::mercury_level" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + set device_class "environment" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -240,6 +248,12 @@ proc ::scobj::mercury_level::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -250,9 +264,9 @@ proc ::scobj::mercury_level::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "mercury_level"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue" } elseif { [dict exists $v "asyncqueue"] } { set asyncqueue [dict get $v "asyncqueue"] if { [string equal -nocase ${asyncqueue} "sct"] } { @@ -294,9 +308,9 @@ proc ::scobj::mercury_level::read_config {} { error "$name is missing configuration values $missing_list" } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_mercury_level ${name} ${ip_address} ${tcp_port} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list } else { - add_mercury_level ${name} "aqadapter" ${asyncqueue} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list } } } diff --git a/site_ansto/instrument/config/environment/temperature/sct_mercury_pres.tcl b/site_ansto/instrument/config/environment/temperature/sct_mercury_pres.tcl index 874a2f7d..47493269 100644 --- a/site_ansto/instrument/config/environment/temperature/sct_mercury_pres.tcl +++ b/site_ansto/instrument/config/environment/temperature/sct_mercury_pres.tcl @@ -272,14 +272,14 @@ proc ::scobj::mercury_pres::setValue {tc_root nextState cmd_str} { handle_exception ${catch_status} ${catch_message} } -proc ::scobj::mercury_pres::mkDriver { sct_controller name ip_address tcp_port id tol } { - ::scobj::mercury_pres::sics_log 9 "::scobj::mercury_pres::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port} ${id} ${tol}" +proc ::scobj::mercury_pres::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port id tol } { + ::scobj::mercury_pres::sics_log 9 "::scobj::mercury_pres::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${tol}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT - sicslist setatt ${name} klass environment + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} @@ -346,18 +346,18 @@ proc ::scobj::mercury_pres::mkDriver { sct_controller name ip_address tcp_port i hsetprop ${scobj_hpath}/Loop8/setpoint type "drivable" hsetprop ${scobj_hpath}/Loop8/setpoint nxalias "${name}_Loop8_setpoint" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/Loop8/nick 15 ${sct_controller} poll ${scobj_hpath}/Loop8/sensor 1 ${sct_controller} poll ${scobj_hpath}/Loop8/setpoint 5 ${sct_controller} write ${scobj_hpath}/Loop8/setpoint } else { - ::scobj::mercury_pres::sics_log 9 "[environment_simulation] => No poll/write for mercury_pres" + ::scobj::mercury_pres::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for mercury_pres" } - hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ansto_makesctdrive ${name}_Loop8_setpoint ${scobj_hpath}/Loop8/setpoint ${scobj_hpath}/Loop8/sensor ${sct_controller} } # mkDriver hook code goes here @@ -365,31 +365,37 @@ proc ::scobj::mercury_pres::mkDriver { sct_controller name ip_address tcp_port i handle_exception ${catch_status} ${catch_message} } +proc ::scobj::mercury_pres::add_driver {name device_class simulation_flag ip_address tcp_port {id 99} {tol 1}} { + set catch_status [ catch { + ::scobj::mercury_pres::sics_log 9 "::scobj::mercury_pres::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${tol}" + if {[string equal -nocase "${simulation_flag}" "false"]} { + if {[string equal -nocase "aqadapter" "${ip_address}"]} { + ::scobj::mercury_pres::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" + makesctcontroller sct_${name} aqadapter ${tcp_port} + } else { + ::scobj::mercury_pres::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}" + makesctcontroller sct_${name} std ${ip_address}:${tcp_port} + } + } else { + ::scobj::mercury_pres::sics_log 9 "simulation_flag={simulation_flag} => No sctcontroller for mercury_pres" + } + ::scobj::mercury_pres::sics_log 1 "::scobj::mercury_pres::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${tol}" + ::scobj::mercury_pres::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${tol} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + namespace eval ::scobj::mercury_pres { namespace export debug_threshold namespace export debug_log namespace export sics_log namespace export mkDriver + namespace export add_driver } proc add_mercury_pres {name ip_address tcp_port {id 99} {tol 1}} { - set catch_status [ catch { - ::scobj::mercury_pres::sics_log 9 "add_mercury_pres ${name} ${ip_address} ${tcp_port} ${id} ${tol}" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { - if {[string equal -nocase "aqadapter" "${ip_address}"]} { - ::scobj::mercury_pres::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" - makesctcontroller sct_${name} aqadapter ${tcp_port} - } else { - ::scobj::mercury_pres::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}" - makesctcontroller sct_${name} std ${ip_address}:${tcp_port} - } - } else { - ::scobj::mercury_pres::sics_log 9 "[environment_simulation] => No sctcontroller for mercury_pres" - } - ::scobj::mercury_pres::sics_log 1 "::scobj::mercury_pres::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${tol}" - ::scobj::mercury_pres::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${tol} - } catch_message ] - handle_exception ${catch_status} ${catch_message} + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + ::scobj::mercury_pres::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${{id}" "${99}}" "${{tol}" "${1}}" } clientput "file evaluation of sct_mercury_pres.tcl" @@ -400,6 +406,8 @@ proc ::scobj::mercury_pres::read_config {} { set ns "::scobj::mercury_pres" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + set device_class "environment" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -407,6 +415,12 @@ proc ::scobj::mercury_pres::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -417,9 +431,9 @@ proc ::scobj::mercury_pres::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "mercury_pres"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue" } elseif { [dict exists $v "asyncqueue"] } { set asyncqueue [dict get $v "asyncqueue"] if { [string equal -nocase ${asyncqueue} "sct"] } { @@ -461,9 +475,9 @@ proc ::scobj::mercury_pres::read_config {} { error "$name is missing configuration values $missing_list" } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_mercury_pres ${name} ${ip_address} ${tcp_port} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list } else { - add_mercury_pres ${name} "aqadapter" ${asyncqueue} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list } } } diff --git a/site_ansto/instrument/config/environment/temperature/sct_mercury_scpi.tcl b/site_ansto/instrument/config/environment/temperature/sct_mercury_scpi.tcl index 0b9435b3..57b30b93 100644 --- a/site_ansto/instrument/config/environment/temperature/sct_mercury_scpi.tcl +++ b/site_ansto/instrument/config/environment/temperature/sct_mercury_scpi.tcl @@ -300,14 +300,14 @@ proc ::scobj::mercury_scpi::setValve {tc_root nextState cmd_str} { handle_exception ${catch_status} ${catch_message} } -proc ::scobj::mercury_scpi::mkDriver { sct_controller name ip_address tcp_port id permlink tol valve_tol } { - ::scobj::mercury_scpi::sics_log 9 "::scobj::mercury_scpi::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port} ${id} ${permlink} ${tol} ${valve_tol}" +proc ::scobj::mercury_scpi::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port id permlink tol valve_tol } { + ::scobj::mercury_scpi::sics_log 9 "::scobj::mercury_scpi::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${permlink} ${tol} ${valve_tol}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT - sicslist setatt ${name} klass environment + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} @@ -347,11 +347,11 @@ proc ::scobj::mercury_scpi::mkDriver { sct_controller name ip_address tcp_port i hsetprop ${scobj_hpath}/Level/Nitrogen type "part" hsetprop ${scobj_hpath}/Level/Nitrogen nxalias "${name}_Level_Nitrogen" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/Level/Helium 15 ${sct_controller} poll ${scobj_hpath}/Level/Nitrogen 15 } else { - ::scobj::mercury_scpi::sics_log 9 "[environment_simulation] => No poll/write for mercury_scpi" + ::scobj::mercury_scpi::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for mercury_scpi" } hfactory ${scobj_hpath}/Loop1 plain spy none @@ -427,14 +427,14 @@ proc ::scobj::mercury_scpi::mkDriver { sct_controller name ip_address tcp_port i hsetprop ${scobj_hpath}/Loop1/setpoint type "drivable" hsetprop ${scobj_hpath}/Loop1/setpoint nxalias "${name}_Loop1_setpoint" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/Loop1/nick 15 ${sct_controller} poll ${scobj_hpath}/Loop1/power 5 ${sct_controller} poll ${scobj_hpath}/Loop1/sensor 1 ${sct_controller} poll ${scobj_hpath}/Loop1/setpoint 5 ${sct_controller} write ${scobj_hpath}/Loop1/setpoint } else { - ::scobj::mercury_scpi::sics_log 9 "[environment_simulation] => No poll/write for mercury_scpi" + ::scobj::mercury_scpi::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for mercury_scpi" } hfactory ${scobj_hpath}/Loop2 plain spy none @@ -510,14 +510,14 @@ proc ::scobj::mercury_scpi::mkDriver { sct_controller name ip_address tcp_port i hsetprop ${scobj_hpath}/Loop2/setpoint type "drivable" hsetprop ${scobj_hpath}/Loop2/setpoint nxalias "${name}_Loop2_setpoint" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/Loop2/nick 15 ${sct_controller} poll ${scobj_hpath}/Loop2/power 5 ${sct_controller} poll ${scobj_hpath}/Loop2/sensor 1 ${sct_controller} poll ${scobj_hpath}/Loop2/setpoint 5 ${sct_controller} write ${scobj_hpath}/Loop2/setpoint } else { - ::scobj::mercury_scpi::sics_log 9 "[environment_simulation] => No poll/write for mercury_scpi" + ::scobj::mercury_scpi::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for mercury_scpi" } hfactory ${scobj_hpath}/Loop3 plain spy none @@ -593,14 +593,14 @@ proc ::scobj::mercury_scpi::mkDriver { sct_controller name ip_address tcp_port i hsetprop ${scobj_hpath}/Loop3/setpoint type "drivable" hsetprop ${scobj_hpath}/Loop3/setpoint nxalias "${name}_Loop3_setpoint" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/Loop3/nick 15 ${sct_controller} poll ${scobj_hpath}/Loop3/power 5 ${sct_controller} poll ${scobj_hpath}/Loop3/sensor 1 ${sct_controller} poll ${scobj_hpath}/Loop3/setpoint 5 ${sct_controller} write ${scobj_hpath}/Loop3/setpoint } else { - ::scobj::mercury_scpi::sics_log 9 "[environment_simulation] => No poll/write for mercury_scpi" + ::scobj::mercury_scpi::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for mercury_scpi" } hfactory ${scobj_hpath}/Loop4 plain spy none @@ -676,14 +676,14 @@ proc ::scobj::mercury_scpi::mkDriver { sct_controller name ip_address tcp_port i hsetprop ${scobj_hpath}/Loop4/setpoint type "drivable" hsetprop ${scobj_hpath}/Loop4/setpoint nxalias "${name}_Loop4_setpoint" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/Loop4/nick 15 ${sct_controller} poll ${scobj_hpath}/Loop4/power 5 ${sct_controller} poll ${scobj_hpath}/Loop4/sensor 1 ${sct_controller} poll ${scobj_hpath}/Loop4/setpoint 5 ${sct_controller} write ${scobj_hpath}/Loop4/setpoint } else { - ::scobj::mercury_scpi::sics_log 9 "[environment_simulation] => No poll/write for mercury_scpi" + ::scobj::mercury_scpi::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for mercury_scpi" } hfactory ${scobj_hpath}/Valve plain spy none @@ -731,16 +731,16 @@ proc ::scobj::mercury_scpi::mkDriver { sct_controller name ip_address tcp_port i hsetprop ${scobj_hpath}/Valve/setpoint type "drivable" hsetprop ${scobj_hpath}/Valve/setpoint nxalias "${name}_Valve_setpoint" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/Valve/sensor 5 ${sct_controller} write ${scobj_hpath}/Valve/setpoint } else { - ::scobj::mercury_scpi::sics_log 9 "[environment_simulation] => No poll/write for mercury_scpi" + ::scobj::mercury_scpi::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for mercury_scpi" } - hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ansto_makesctdrive ${name}_Loop1_setpoint ${scobj_hpath}/Loop1/setpoint ${scobj_hpath}/Loop1/sensor ${sct_controller} ansto_makesctdrive ${name}_Loop2_setpoint ${scobj_hpath}/Loop2/setpoint ${scobj_hpath}/Loop2/sensor ${sct_controller} ansto_makesctdrive ${name}_Loop3_setpoint ${scobj_hpath}/Loop3/setpoint ${scobj_hpath}/Loop3/sensor ${sct_controller} @@ -752,17 +752,10 @@ proc ::scobj::mercury_scpi::mkDriver { sct_controller name ip_address tcp_port i handle_exception ${catch_status} ${catch_message} } -namespace eval ::scobj::mercury_scpi { - namespace export debug_threshold - namespace export debug_log - namespace export sics_log - namespace export mkDriver -} - -proc add_mercury_scpi {name ip_address tcp_port {id 99} {permlink LT} {tol 1} {valve_tol 2}} { +proc ::scobj::mercury_scpi::add_driver {name device_class simulation_flag ip_address tcp_port {id 99} {permlink LT} {tol 1} {valve_tol 2}} { set catch_status [ catch { - ::scobj::mercury_scpi::sics_log 9 "add_mercury_scpi ${name} ${ip_address} ${tcp_port} ${id} ${permlink} ${tol} ${valve_tol}" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + ::scobj::mercury_scpi::sics_log 9 "::scobj::mercury_scpi::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${permlink} ${tol} ${valve_tol}" + if {[string equal -nocase "${simulation_flag}" "false"]} { if {[string equal -nocase "aqadapter" "${ip_address}"]} { ::scobj::mercury_scpi::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" makesctcontroller sct_${name} aqadapter ${tcp_port} @@ -771,14 +764,27 @@ proc add_mercury_scpi {name ip_address tcp_port {id 99} {permlink LT} {tol 1} {v makesctcontroller sct_${name} std ${ip_address}:${tcp_port} } } else { - ::scobj::mercury_scpi::sics_log 9 "[environment_simulation] => No sctcontroller for mercury_scpi" + ::scobj::mercury_scpi::sics_log 9 "simulation_flag={simulation_flag} => No sctcontroller for mercury_scpi" } - ::scobj::mercury_scpi::sics_log 1 "::scobj::mercury_scpi::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${permlink} ${tol} ${valve_tol}" - ::scobj::mercury_scpi::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${permlink} ${tol} ${valve_tol} + ::scobj::mercury_scpi::sics_log 1 "::scobj::mercury_scpi::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${permlink} ${tol} ${valve_tol}" + ::scobj::mercury_scpi::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${permlink} ${tol} ${valve_tol} } catch_message ] handle_exception ${catch_status} ${catch_message} } +namespace eval ::scobj::mercury_scpi { + namespace export debug_threshold + namespace export debug_log + namespace export sics_log + namespace export mkDriver + namespace export add_driver +} + +proc add_mercury_scpi {name ip_address tcp_port {id 99} {permlink LT} {tol 1} {valve_tol 2}} { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + ::scobj::mercury_scpi::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${{id}" "${99}}" "${{permlink}" "${LT}}" "${{tol}" "${1}}" "${{valve_tol}" "${2}}" +} + clientput "file evaluation of sct_mercury_scpi.tcl" ::scobj::mercury_scpi::sics_log 9 "file evaluation of sct_mercury_scpi.tcl" @@ -787,6 +793,8 @@ proc ::scobj::mercury_scpi::read_config {} { set ns "::scobj::mercury_scpi" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + set device_class "environment" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -794,6 +802,12 @@ proc ::scobj::mercury_scpi::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -804,9 +818,9 @@ proc ::scobj::mercury_scpi::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "mercury_scpi"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue" } elseif { [dict exists $v "asyncqueue"] } { set asyncqueue [dict get $v "asyncqueue"] if { [string equal -nocase ${asyncqueue} "sct"] } { @@ -848,9 +862,9 @@ proc ::scobj::mercury_scpi::read_config {} { error "$name is missing configuration values $missing_list" } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_mercury_scpi ${name} ${ip_address} ${tcp_port} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list } else { - add_mercury_scpi ${name} "aqadapter" ${asyncqueue} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list } } } diff --git a/site_ansto/instrument/config/environment/temperature/sct_mercury_temp.tcl b/site_ansto/instrument/config/environment/temperature/sct_mercury_temp.tcl index 16cfbd37..68d6391a 100644 --- a/site_ansto/instrument/config/environment/temperature/sct_mercury_temp.tcl +++ b/site_ansto/instrument/config/environment/temperature/sct_mercury_temp.tcl @@ -266,14 +266,14 @@ proc ::scobj::mercury_temp::setValue {tc_root nextState cmd_str} { handle_exception ${catch_status} ${catch_message} } -proc ::scobj::mercury_temp::mkDriver { sct_controller name ip_address tcp_port id tol } { - ::scobj::mercury_temp::sics_log 9 "::scobj::mercury_temp::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port} ${id} ${tol}" +proc ::scobj::mercury_temp::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port id tol } { + ::scobj::mercury_temp::sics_log 9 "::scobj::mercury_temp::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${tol}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT - sicslist setatt ${name} klass environment + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} @@ -351,19 +351,19 @@ proc ::scobj::mercury_temp::mkDriver { sct_controller name ip_address tcp_port i hsetprop ${scobj_hpath}/Loop4/setpoint type "drivable" hsetprop ${scobj_hpath}/Loop4/setpoint nxalias "${name}_Loop4_setpoint" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/Loop4/nick 15 ${sct_controller} poll ${scobj_hpath}/Loop4/power 5 ${sct_controller} poll ${scobj_hpath}/Loop4/sensor 1 ${sct_controller} poll ${scobj_hpath}/Loop4/setpoint 5 ${sct_controller} write ${scobj_hpath}/Loop4/setpoint } else { - ::scobj::mercury_temp::sics_log 9 "[environment_simulation] => No poll/write for mercury_temp" + ::scobj::mercury_temp::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for mercury_temp" } - hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ansto_makesctdrive ${name}_Loop4_setpoint ${scobj_hpath}/Loop4/setpoint ${scobj_hpath}/Loop4/sensor ${sct_controller} } # mkDriver hook code goes here @@ -371,31 +371,37 @@ proc ::scobj::mercury_temp::mkDriver { sct_controller name ip_address tcp_port i handle_exception ${catch_status} ${catch_message} } +proc ::scobj::mercury_temp::add_driver {name device_class simulation_flag ip_address tcp_port {id 99} {tol 1}} { + set catch_status [ catch { + ::scobj::mercury_temp::sics_log 9 "::scobj::mercury_temp::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${tol}" + if {[string equal -nocase "${simulation_flag}" "false"]} { + if {[string equal -nocase "aqadapter" "${ip_address}"]} { + ::scobj::mercury_temp::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" + makesctcontroller sct_${name} aqadapter ${tcp_port} + } else { + ::scobj::mercury_temp::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}" + makesctcontroller sct_${name} std ${ip_address}:${tcp_port} + } + } else { + ::scobj::mercury_temp::sics_log 9 "simulation_flag={simulation_flag} => No sctcontroller for mercury_temp" + } + ::scobj::mercury_temp::sics_log 1 "::scobj::mercury_temp::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${tol}" + ::scobj::mercury_temp::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${tol} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + namespace eval ::scobj::mercury_temp { namespace export debug_threshold namespace export debug_log namespace export sics_log namespace export mkDriver + namespace export add_driver } proc add_mercury_temp {name ip_address tcp_port {id 99} {tol 1}} { - set catch_status [ catch { - ::scobj::mercury_temp::sics_log 9 "add_mercury_temp ${name} ${ip_address} ${tcp_port} ${id} ${tol}" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { - if {[string equal -nocase "aqadapter" "${ip_address}"]} { - ::scobj::mercury_temp::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" - makesctcontroller sct_${name} aqadapter ${tcp_port} - } else { - ::scobj::mercury_temp::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}" - makesctcontroller sct_${name} std ${ip_address}:${tcp_port} - } - } else { - ::scobj::mercury_temp::sics_log 9 "[environment_simulation] => No sctcontroller for mercury_temp" - } - ::scobj::mercury_temp::sics_log 1 "::scobj::mercury_temp::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${tol}" - ::scobj::mercury_temp::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${tol} - } catch_message ] - handle_exception ${catch_status} ${catch_message} + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + ::scobj::mercury_temp::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${{id}" "${99}}" "${{tol}" "${1}}" } clientput "file evaluation of sct_mercury_temp.tcl" @@ -406,6 +412,8 @@ proc ::scobj::mercury_temp::read_config {} { set ns "::scobj::mercury_temp" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + set device_class "environment" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -413,6 +421,12 @@ proc ::scobj::mercury_temp::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -423,9 +437,9 @@ proc ::scobj::mercury_temp::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "mercury_temp"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue" } elseif { [dict exists $v "asyncqueue"] } { set asyncqueue [dict get $v "asyncqueue"] if { [string equal -nocase ${asyncqueue} "sct"] } { @@ -467,9 +481,9 @@ proc ::scobj::mercury_temp::read_config {} { error "$name is missing configuration values $missing_list" } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_mercury_temp ${name} ${ip_address} ${tcp_port} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list } else { - add_mercury_temp ${name} "aqadapter" ${asyncqueue} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list } } } diff --git a/site_ansto/instrument/config/environment/temperature/sct_mercury_valve.tcl b/site_ansto/instrument/config/environment/temperature/sct_mercury_valve.tcl index ab21a31d..76151dee 100644 --- a/site_ansto/instrument/config/environment/temperature/sct_mercury_valve.tcl +++ b/site_ansto/instrument/config/environment/temperature/sct_mercury_valve.tcl @@ -244,14 +244,14 @@ proc ::scobj::mercury_valve::setValve {tc_root nextState cmd_str} { handle_exception ${catch_status} ${catch_message} } -proc ::scobj::mercury_valve::mkDriver { sct_controller name ip_address tcp_port id valve_tol } { - ::scobj::mercury_valve::sics_log 9 "::scobj::mercury_valve::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port} ${id} ${valve_tol}" +proc ::scobj::mercury_valve::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port id valve_tol } { + ::scobj::mercury_valve::sics_log 9 "::scobj::mercury_valve::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${valve_tol}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT - sicslist setatt ${name} klass environment + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} @@ -301,16 +301,16 @@ proc ::scobj::mercury_valve::mkDriver { sct_controller name ip_address tcp_port hsetprop ${scobj_hpath}/Valve/setpoint type "drivable" hsetprop ${scobj_hpath}/Valve/setpoint nxalias "${name}_Valve_setpoint" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/Valve/sensor 5 ${sct_controller} write ${scobj_hpath}/Valve/setpoint } else { - ::scobj::mercury_valve::sics_log 9 "[environment_simulation] => No poll/write for mercury_valve" + ::scobj::mercury_valve::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for mercury_valve" } - hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ansto_makesctdrive ${name}_Valve_setpoint ${scobj_hpath}/Valve/setpoint ${scobj_hpath}/Valve/sensor ${sct_controller} } # mkDriver hook code goes here @@ -318,31 +318,37 @@ proc ::scobj::mercury_valve::mkDriver { sct_controller name ip_address tcp_port handle_exception ${catch_status} ${catch_message} } +proc ::scobj::mercury_valve::add_driver {name device_class simulation_flag ip_address tcp_port {id 99} {valve_tol 2}} { + set catch_status [ catch { + ::scobj::mercury_valve::sics_log 9 "::scobj::mercury_valve::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${valve_tol}" + if {[string equal -nocase "${simulation_flag}" "false"]} { + if {[string equal -nocase "aqadapter" "${ip_address}"]} { + ::scobj::mercury_valve::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" + makesctcontroller sct_${name} aqadapter ${tcp_port} + } else { + ::scobj::mercury_valve::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}" + makesctcontroller sct_${name} std ${ip_address}:${tcp_port} + } + } else { + ::scobj::mercury_valve::sics_log 9 "simulation_flag={simulation_flag} => No sctcontroller for mercury_valve" + } + ::scobj::mercury_valve::sics_log 1 "::scobj::mercury_valve::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${valve_tol}" + ::scobj::mercury_valve::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${valve_tol} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + namespace eval ::scobj::mercury_valve { namespace export debug_threshold namespace export debug_log namespace export sics_log namespace export mkDriver + namespace export add_driver } proc add_mercury_valve {name ip_address tcp_port {id 99} {valve_tol 2}} { - set catch_status [ catch { - ::scobj::mercury_valve::sics_log 9 "add_mercury_valve ${name} ${ip_address} ${tcp_port} ${id} ${valve_tol}" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { - if {[string equal -nocase "aqadapter" "${ip_address}"]} { - ::scobj::mercury_valve::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" - makesctcontroller sct_${name} aqadapter ${tcp_port} - } else { - ::scobj::mercury_valve::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}" - makesctcontroller sct_${name} std ${ip_address}:${tcp_port} - } - } else { - ::scobj::mercury_valve::sics_log 9 "[environment_simulation] => No sctcontroller for mercury_valve" - } - ::scobj::mercury_valve::sics_log 1 "::scobj::mercury_valve::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${valve_tol}" - ::scobj::mercury_valve::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${valve_tol} - } catch_message ] - handle_exception ${catch_status} ${catch_message} + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + ::scobj::mercury_valve::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${{id}" "${99}}" "${{valve_tol}" "${2}}" } clientput "file evaluation of sct_mercury_valve.tcl" @@ -353,6 +359,8 @@ proc ::scobj::mercury_valve::read_config {} { set ns "::scobj::mercury_valve" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + set device_class "environment" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -360,6 +368,12 @@ proc ::scobj::mercury_valve::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -370,9 +384,9 @@ proc ::scobj::mercury_valve::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "mercury_valve"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue" } elseif { [dict exists $v "asyncqueue"] } { set asyncqueue [dict get $v "asyncqueue"] if { [string equal -nocase ${asyncqueue} "sct"] } { @@ -414,9 +428,9 @@ proc ::scobj::mercury_valve::read_config {} { error "$name is missing configuration values $missing_list" } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_mercury_valve ${name} ${ip_address} ${tcp_port} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list } else { - add_mercury_valve ${name} "aqadapter" ${asyncqueue} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list } } } diff --git a/site_ansto/instrument/config/environment/temperature/sct_nprvasm2.tcl b/site_ansto/instrument/config/environment/temperature/sct_nprvasm2.tcl index b6ffdb6a..24bac7f1 100644 --- a/site_ansto/instrument/config/environment/temperature/sct_nprvasm2.tcl +++ b/site_ansto/instrument/config/environment/temperature/sct_nprvasm2.tcl @@ -27,18 +27,18 @@ proc ::scobj::nprvasm2::sics_log {debug_level debug_string} { } catch_message ] } -proc ::scobj::nprvasm2::mkDriver { sct_controller name ip_address tcp_port tol } { - ::scobj::nprvasm2::sics_log 9 "::scobj::nprvasm2::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port} ${tol}" +proc ::scobj::nprvasm2::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port tol } { + ::scobj::nprvasm2::sics_log 9 "::scobj::nprvasm2::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${tol}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT - sicslist setatt ${name} klass environment + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} - hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 # mkDriver hook code starts @@ -48,17 +48,10 @@ proc ::scobj::nprvasm2::mkDriver { sct_controller name ip_address tcp_port tol } handle_exception ${catch_status} ${catch_message} } -namespace eval ::scobj::nprvasm2 { - namespace export debug_threshold - namespace export debug_log - namespace export sics_log - namespace export mkDriver -} - -proc add_nprvasm2 {name ip_address tcp_port {tol 1.0}} { +proc ::scobj::nprvasm2::add_driver {name device_class simulation_flag ip_address tcp_port {tol 1.0}} { set catch_status [ catch { - ::scobj::nprvasm2::sics_log 9 "add_nprvasm2 ${name} ${ip_address} ${tcp_port} ${tol}" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + ::scobj::nprvasm2::sics_log 9 "::scobj::nprvasm2::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${tol}" + if {[string equal -nocase "${simulation_flag}" "false"]} { if {[string equal -nocase "aqadapter" "${ip_address}"]} { ::scobj::nprvasm2::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" makesctcontroller sct_${name} aqadapter ${tcp_port} @@ -67,14 +60,27 @@ proc add_nprvasm2 {name ip_address tcp_port {tol 1.0}} { makesctcontroller sct_${name} std ${ip_address}:${tcp_port} } } else { - ::scobj::nprvasm2::sics_log 9 "[environment_simulation] => No sctcontroller for nprvasm2" + ::scobj::nprvasm2::sics_log 9 "simulation_flag={simulation_flag} => No sctcontroller for nprvasm2" } - ::scobj::nprvasm2::sics_log 1 "::scobj::nprvasm2::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${tol}" - ::scobj::nprvasm2::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${tol} + ::scobj::nprvasm2::sics_log 1 "::scobj::nprvasm2::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${tol}" + ::scobj::nprvasm2::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${tol} } catch_message ] handle_exception ${catch_status} ${catch_message} } +namespace eval ::scobj::nprvasm2 { + namespace export debug_threshold + namespace export debug_log + namespace export sics_log + namespace export mkDriver + namespace export add_driver +} + +proc add_nprvasm2 {name ip_address tcp_port {tol 1.0}} { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + ::scobj::nprvasm2::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${{tol}" "${1.0}}" +} + clientput "file evaluation of sct_nprvasm2.tcl" ::scobj::nprvasm2::sics_log 9 "file evaluation of sct_nprvasm2.tcl" @@ -83,6 +89,8 @@ proc ::scobj::nprvasm2::read_config {} { set ns "::scobj::nprvasm2" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + set device_class "environment" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -90,6 +98,12 @@ proc ::scobj::nprvasm2::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -100,9 +114,9 @@ proc ::scobj::nprvasm2::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "nprvasm2"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue" } elseif { [dict exists $v "asyncqueue"] } { set asyncqueue [dict get $v "asyncqueue"] if { [string equal -nocase ${asyncqueue} "sct"] } { @@ -144,9 +158,9 @@ proc ::scobj::nprvasm2::read_config {} { error "$name is missing configuration values $missing_list" } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_nprvasm2 ${name} ${ip_address} ${tcp_port} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list } else { - add_nprvasm2 ${name} "aqadapter" ${asyncqueue} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list } } } diff --git a/site_ansto/instrument/config/environment/temperature/sct_pfeiffer_hg.tcl b/site_ansto/instrument/config/environment/temperature/sct_pfeiffer_hg.tcl index 8e65436b..a9e1ebc6 100644 --- a/site_ansto/instrument/config/environment/temperature/sct_pfeiffer_hg.tcl +++ b/site_ansto/instrument/config/environment/temperature/sct_pfeiffer_hg.tcl @@ -370,8 +370,8 @@ proc ::scobj::pfeiffer_hg::setValue {tc_root nextState cmd_str} { handle_exception ${catch_status} ${catch_message} } -proc ::scobj::pfeiffer_hg::mkDriver { sct_controller name ip_address tcp_port } { - ::scobj::pfeiffer_hg::sics_log 9 "::scobj::pfeiffer_hg::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port}" +proc ::scobj::pfeiffer_hg::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port } { + ::scobj::pfeiffer_hg::sics_log 9 "::scobj::pfeiffer_hg::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" set ns "[namespace current]" set catch_status [ catch { @@ -379,7 +379,7 @@ proc ::scobj::pfeiffer_hg::mkDriver { sct_controller name ip_address tcp_port } MakeSICSObj ${name} SCT_OBJECT - sicslist setatt ${name} klass environment + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} @@ -453,16 +453,16 @@ proc ::scobj::pfeiffer_hg::mkDriver { sct_controller name ip_address tcp_port } hsetprop ${scobj_hpath}/pressure/setpoint type "drivable" hsetprop ${scobj_hpath}/pressure/setpoint nxalias "${name}_pressure_setpoint" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/pressure/sensor 1 ${sct_controller} write ${scobj_hpath}/pressure/setpoint } else { - ::scobj::pfeiffer_hg::sics_log 9 "[environment_simulation] => No poll/write for pfeiffer_hg" + ::scobj::pfeiffer_hg::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for pfeiffer_hg" } - hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ansto_makesctdrive ${name}_pressure_setpoint ${scobj_hpath}/pressure/setpoint ${scobj_hpath}/pressure/sensor ${sct_controller} } # mkDriver hook code starts @@ -473,17 +473,10 @@ proc ::scobj::pfeiffer_hg::mkDriver { sct_controller name ip_address tcp_port } handle_exception ${catch_status} ${catch_message} } -namespace eval ::scobj::pfeiffer_hg { - namespace export debug_threshold - namespace export debug_log - namespace export sics_log - namespace export mkDriver -} - -proc add_pfeiffer_hg {name ip_address tcp_port} { +proc ::scobj::pfeiffer_hg::add_driver {name device_class simulation_flag ip_address tcp_port} { set catch_status [ catch { - ::scobj::pfeiffer_hg::sics_log 9 "add_pfeiffer_hg ${name} ${ip_address} ${tcp_port}" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + ::scobj::pfeiffer_hg::sics_log 9 "::scobj::pfeiffer_hg::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" + if {[string equal -nocase "${simulation_flag}" "false"]} { if {[string equal -nocase "aqadapter" "${ip_address}"]} { ::scobj::pfeiffer_hg::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" makesctcontroller sct_${name} aqadapter ${tcp_port} @@ -492,14 +485,27 @@ proc add_pfeiffer_hg {name ip_address tcp_port} { makesctcontroller sct_${name} std ${ip_address}:${tcp_port} } } else { - ::scobj::pfeiffer_hg::sics_log 9 "[environment_simulation] => No sctcontroller for pfeiffer_hg" + ::scobj::pfeiffer_hg::sics_log 9 "simulation_flag={simulation_flag} => No sctcontroller for pfeiffer_hg" } - ::scobj::pfeiffer_hg::sics_log 1 "::scobj::pfeiffer_hg::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port}" - ::scobj::pfeiffer_hg::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} + ::scobj::pfeiffer_hg::sics_log 1 "::scobj::pfeiffer_hg::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" + ::scobj::pfeiffer_hg::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} } catch_message ] handle_exception ${catch_status} ${catch_message} } +namespace eval ::scobj::pfeiffer_hg { + namespace export debug_threshold + namespace export debug_log + namespace export sics_log + namespace export mkDriver + namespace export add_driver +} + +proc add_pfeiffer_hg {name ip_address tcp_port} { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + ::scobj::pfeiffer_hg::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} +} + clientput "file evaluation of sct_pfeiffer_hg.tcl" ::scobj::pfeiffer_hg::sics_log 9 "file evaluation of sct_pfeiffer_hg.tcl" @@ -508,6 +514,8 @@ proc ::scobj::pfeiffer_hg::read_config {} { set ns "::scobj::pfeiffer_hg" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + set device_class "environment" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -515,6 +523,12 @@ proc ::scobj::pfeiffer_hg::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -525,9 +539,9 @@ proc ::scobj::pfeiffer_hg::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "pfeiffer_hg"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue" } elseif { [dict exists $v "asyncqueue"] } { set asyncqueue [dict get $v "asyncqueue"] if { [string equal -nocase ${asyncqueue} "sct"] } { @@ -554,9 +568,9 @@ proc ::scobj::pfeiffer_hg::read_config {} { } } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_pfeiffer_hg ${name} ${ip_address} ${tcp_port} + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} } else { - add_pfeiffer_hg ${name} "aqadapter" ${asyncqueue} + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} } } } diff --git a/site_ansto/instrument/config/environment/temperature/sct_srs_sr630.tcl b/site_ansto/instrument/config/environment/temperature/sct_srs_sr630.tcl index 3f31e76d..e6bb69eb 100644 --- a/site_ansto/instrument/config/environment/temperature/sct_srs_sr630.tcl +++ b/site_ansto/instrument/config/environment/temperature/sct_srs_sr630.tcl @@ -191,14 +191,14 @@ proc ::scobj::srs_sr630::setValue {tc_root nextState cmd_str} { handle_exception ${catch_status} ${catch_message} } -proc ::scobj::srs_sr630::mkDriver { sct_controller name ip_address tcp_port } { - ::scobj::srs_sr630::sics_log 9 "::scobj::srs_sr630::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port}" +proc ::scobj::srs_sr630::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port } { + ::scobj::srs_sr630::sics_log 9 "::scobj::srs_sr630::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT - sicslist setatt ${name} klass NXdetector + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} @@ -325,7 +325,7 @@ proc ::scobj::srs_sr630::mkDriver { sct_controller name ip_address tcp_port } { hsetprop ${scobj_hpath} klass "@none" hsetprop ${scobj_hpath} type "part" - if {[string equal -nocase [SplitReply [detector_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/id 600 ${sct_controller} poll ${scobj_hpath}/sensor_01 60 ${sct_controller} poll ${scobj_hpath}/sensor_02 600 @@ -336,9 +336,9 @@ proc ::scobj::srs_sr630::mkDriver { sct_controller name ip_address tcp_port } { ${sct_controller} poll ${scobj_hpath}/sensor_07 600 ${sct_controller} poll ${scobj_hpath}/sensor_08 600 } else { - ::scobj::srs_sr630::sics_log 9 "[detector_simulation] => No poll/write for srs_sr630" + ::scobj::srs_sr630::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for srs_sr630" } - hsetprop ${scobj_hpath} klass NXdetector + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 # mkDriver hook code goes here @@ -346,31 +346,37 @@ proc ::scobj::srs_sr630::mkDriver { sct_controller name ip_address tcp_port } { handle_exception ${catch_status} ${catch_message} } +proc ::scobj::srs_sr630::add_driver {name device_class simulation_flag ip_address tcp_port} { + set catch_status [ catch { + ::scobj::srs_sr630::sics_log 9 "::scobj::srs_sr630::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" + if {[string equal -nocase "${simulation_flag}" "false"]} { + if {[string equal -nocase "aqadapter" "${ip_address}"]} { + ::scobj::srs_sr630::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" + makesctcontroller sct_${name} aqadapter ${tcp_port} + } else { + ::scobj::srs_sr630::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}" + makesctcontroller sct_${name} std ${ip_address}:${tcp_port} + } + } else { + ::scobj::srs_sr630::sics_log 9 "simulation_flag={simulation_flag} => No sctcontroller for srs_sr630" + } + ::scobj::srs_sr630::sics_log 1 "::scobj::srs_sr630::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" + ::scobj::srs_sr630::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + namespace eval ::scobj::srs_sr630 { namespace export debug_threshold namespace export debug_log namespace export sics_log namespace export mkDriver + namespace export add_driver } proc add_srs_sr630 {name ip_address tcp_port} { - set catch_status [ catch { - ::scobj::srs_sr630::sics_log 9 "add_srs_sr630 ${name} ${ip_address} ${tcp_port}" - if {[string equal -nocase [SplitReply [detector_simulation]] "false"]} { - if {[string equal -nocase "aqadapter" "${ip_address}"]} { - ::scobj::srs_sr630::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" - makesctcontroller sct_${name} aqadapter ${tcp_port} - } else { - ::scobj::srs_sr630::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}" - makesctcontroller sct_${name} std ${ip_address}:${tcp_port} - } - } else { - ::scobj::srs_sr630::sics_log 9 "[detector_simulation] => No sctcontroller for srs_sr630" - } - ::scobj::srs_sr630::sics_log 1 "::scobj::srs_sr630::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port}" - ::scobj::srs_sr630::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} - } catch_message ] - handle_exception ${catch_status} ${catch_message} + set simulation_flag "[string tolower [SplitReply [detector_simulation]]]" + ::scobj::srs_sr630::add_driver ${name} "NXdetector" "${simulation_flag}" ${ip_address} ${tcp_port} } clientput "file evaluation of sct_srs_sr630.tcl" @@ -381,6 +387,8 @@ proc ::scobj::srs_sr630::read_config {} { set ns "::scobj::srs_sr630" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [detector_simulation]]]" + set device_class "NXdetector" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -388,6 +396,12 @@ proc ::scobj::srs_sr630::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -398,9 +412,9 @@ proc ::scobj::srs_sr630::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "srs_sr630"] } { - if { ![string equal -nocase [SplitReply [detector_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[detector_simulation] => using null asyncqueue" + ${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue" } elseif { [dict exists $v "asyncqueue"] } { set asyncqueue [dict get $v "asyncqueue"] if { [string equal -nocase ${asyncqueue} "sct"] } { @@ -427,9 +441,9 @@ proc ::scobj::srs_sr630::read_config {} { } } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_srs_sr630 ${name} ${ip_address} ${tcp_port} + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} } else { - add_srs_sr630 ${name} "aqadapter" ${asyncqueue} + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} } } } diff --git a/site_ansto/instrument/config/environment/temperature/sct_watlow_mpm.tcl b/site_ansto/instrument/config/environment/temperature/sct_watlow_mpm.tcl index 553141b1..b36881c3 100644 --- a/site_ansto/instrument/config/environment/temperature/sct_watlow_mpm.tcl +++ b/site_ansto/instrument/config/environment/temperature/sct_watlow_mpm.tcl @@ -27,18 +27,18 @@ proc ::scobj::watlow_mpm::sics_log {debug_level debug_string} { } catch_message ] } -proc ::scobj::watlow_mpm::mkDriver { sct_controller name ip_address tcp_port id datype dev_id tol } { - ::scobj::watlow_mpm::sics_log 9 "::scobj::watlow_mpm::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol}" +proc ::scobj::watlow_mpm::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port id datype dev_id tol } { + ::scobj::watlow_mpm::sics_log 9 "::scobj::watlow_mpm::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT user float - sicslist setatt ${name} klass environment + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} - hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 # mkDriver hook code starts @@ -48,17 +48,10 @@ proc ::scobj::watlow_mpm::mkDriver { sct_controller name ip_address tcp_port id handle_exception ${catch_status} ${catch_message} } -namespace eval ::scobj::watlow_mpm { - namespace export debug_threshold - namespace export debug_log - namespace export sics_log - namespace export mkDriver -} - -proc add_watlow_mpm {name ip_address tcp_port id datype dev_id tol} { +proc ::scobj::watlow_mpm::add_driver {name device_class simulation_flag ip_address tcp_port id datype dev_id tol} { set catch_status [ catch { - ::scobj::watlow_mpm::sics_log 9 "add_watlow_mpm ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol}" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + ::scobj::watlow_mpm::sics_log 9 "::scobj::watlow_mpm::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol}" + if {[string equal -nocase "${simulation_flag}" "false"]} { if {[string equal -nocase "aqadapter" "${ip_address}"]} { ::scobj::watlow_mpm::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" makesctcontroller sct_${name} aqadapter ${tcp_port} @@ -67,14 +60,27 @@ proc add_watlow_mpm {name ip_address tcp_port id datype dev_id tol} { makesctcontroller sct_${name} std ${ip_address}:${tcp_port} } } else { - ::scobj::watlow_mpm::sics_log 9 "[environment_simulation] => No sctcontroller for watlow_mpm" + ::scobj::watlow_mpm::sics_log 9 "simulation_flag={simulation_flag} => No sctcontroller for watlow_mpm" } - ::scobj::watlow_mpm::sics_log 1 "::scobj::watlow_mpm::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol}" - ::scobj::watlow_mpm::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol} + ::scobj::watlow_mpm::sics_log 1 "::scobj::watlow_mpm::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol}" + ::scobj::watlow_mpm::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol} } catch_message ] handle_exception ${catch_status} ${catch_message} } +namespace eval ::scobj::watlow_mpm { + namespace export debug_threshold + namespace export debug_log + namespace export sics_log + namespace export mkDriver + namespace export add_driver +} + +proc add_watlow_mpm {name ip_address tcp_port id datype dev_id tol} { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + ::scobj::watlow_mpm::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${id}" "${datype}" "${dev_id}" "${tol}" +} + clientput "file evaluation of sct_watlow_mpm.tcl" ::scobj::watlow_mpm::sics_log 9 "file evaluation of sct_watlow_mpm.tcl" @@ -83,6 +89,8 @@ proc ::scobj::watlow_mpm::read_config {} { set ns "::scobj::watlow_mpm" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + set device_class "environment" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -90,6 +98,12 @@ proc ::scobj::watlow_mpm::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -100,9 +114,9 @@ proc ::scobj::watlow_mpm::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "watlow_mpm"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue" } elseif { [dict exists $v "asyncqueue"] } { set asyncqueue [dict get $v "asyncqueue"] if { [string equal -nocase ${asyncqueue} "sct"] } { @@ -144,9 +158,9 @@ proc ::scobj::watlow_mpm::read_config {} { error "$name is missing configuration values $missing_list" } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_watlow_mpm ${name} ${ip_address} ${tcp_port} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list } else { - add_watlow_mpm ${name} "aqadapter" ${asyncqueue} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list } } } diff --git a/site_ansto/instrument/config/environment/temperature/sct_watlow_mrm.tcl b/site_ansto/instrument/config/environment/temperature/sct_watlow_mrm.tcl index 39105958..6258c1d4 100644 --- a/site_ansto/instrument/config/environment/temperature/sct_watlow_mrm.tcl +++ b/site_ansto/instrument/config/environment/temperature/sct_watlow_mrm.tcl @@ -27,18 +27,18 @@ proc ::scobj::watlow_mrm::sics_log {debug_level debug_string} { } catch_message ] } -proc ::scobj::watlow_mrm::mkDriver { sct_controller name ip_address tcp_port id datype dev_id tol } { - ::scobj::watlow_mrm::sics_log 9 "::scobj::watlow_mrm::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol}" +proc ::scobj::watlow_mrm::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port id datype dev_id tol } { + ::scobj::watlow_mrm::sics_log 9 "::scobj::watlow_mrm::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT user float - sicslist setatt ${name} klass environment + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} - hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 # mkDriver hook code starts @@ -48,17 +48,10 @@ proc ::scobj::watlow_mrm::mkDriver { sct_controller name ip_address tcp_port id handle_exception ${catch_status} ${catch_message} } -namespace eval ::scobj::watlow_mrm { - namespace export debug_threshold - namespace export debug_log - namespace export sics_log - namespace export mkDriver -} - -proc add_watlow_mrm {name ip_address tcp_port id datype dev_id tol} { +proc ::scobj::watlow_mrm::add_driver {name device_class simulation_flag ip_address tcp_port id datype dev_id tol} { set catch_status [ catch { - ::scobj::watlow_mrm::sics_log 9 "add_watlow_mrm ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol}" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + ::scobj::watlow_mrm::sics_log 9 "::scobj::watlow_mrm::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol}" + if {[string equal -nocase "${simulation_flag}" "false"]} { if {[string equal -nocase "aqadapter" "${ip_address}"]} { ::scobj::watlow_mrm::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" makesctcontroller sct_${name} aqadapter ${tcp_port} @@ -67,14 +60,27 @@ proc add_watlow_mrm {name ip_address tcp_port id datype dev_id tol} { makesctcontroller sct_${name} std ${ip_address}:${tcp_port} } } else { - ::scobj::watlow_mrm::sics_log 9 "[environment_simulation] => No sctcontroller for watlow_mrm" + ::scobj::watlow_mrm::sics_log 9 "simulation_flag={simulation_flag} => No sctcontroller for watlow_mrm" } - ::scobj::watlow_mrm::sics_log 1 "::scobj::watlow_mrm::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol}" - ::scobj::watlow_mrm::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol} + ::scobj::watlow_mrm::sics_log 1 "::scobj::watlow_mrm::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol}" + ::scobj::watlow_mrm::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol} } catch_message ] handle_exception ${catch_status} ${catch_message} } +namespace eval ::scobj::watlow_mrm { + namespace export debug_threshold + namespace export debug_log + namespace export sics_log + namespace export mkDriver + namespace export add_driver +} + +proc add_watlow_mrm {name ip_address tcp_port id datype dev_id tol} { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + ::scobj::watlow_mrm::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${id}" "${datype}" "${dev_id}" "${tol}" +} + clientput "file evaluation of sct_watlow_mrm.tcl" ::scobj::watlow_mrm::sics_log 9 "file evaluation of sct_watlow_mrm.tcl" @@ -83,6 +89,8 @@ proc ::scobj::watlow_mrm::read_config {} { set ns "::scobj::watlow_mrm" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + set device_class "environment" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -90,6 +98,12 @@ proc ::scobj::watlow_mrm::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -100,9 +114,9 @@ proc ::scobj::watlow_mrm::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "watlow_mrm"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue" } elseif { [dict exists $v "asyncqueue"] } { set asyncqueue [dict get $v "asyncqueue"] if { [string equal -nocase ${asyncqueue} "sct"] } { @@ -144,9 +158,9 @@ proc ::scobj::watlow_mrm::read_config {} { error "$name is missing configuration values $missing_list" } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_watlow_mrm ${name} ${ip_address} ${tcp_port} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list } else { - add_watlow_mrm ${name} "aqadapter" ${asyncqueue} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list } } } diff --git a/site_ansto/instrument/config/environment/temperature/sct_watlow_mst4.tcl b/site_ansto/instrument/config/environment/temperature/sct_watlow_mst4.tcl index 87103a6b..c81cf81b 100644 --- a/site_ansto/instrument/config/environment/temperature/sct_watlow_mst4.tcl +++ b/site_ansto/instrument/config/environment/temperature/sct_watlow_mst4.tcl @@ -27,18 +27,18 @@ proc ::scobj::watlow_mst4::sics_log {debug_level debug_string} { } catch_message ] } -proc ::scobj::watlow_mst4::mkDriver { sct_controller name ip_address tcp_port id datype dev_id tol } { - ::scobj::watlow_mst4::sics_log 9 "::scobj::watlow_mst4::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol}" +proc ::scobj::watlow_mst4::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port id datype dev_id tol } { + ::scobj::watlow_mst4::sics_log 9 "::scobj::watlow_mst4::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT user float - sicslist setatt ${name} klass environment + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} - hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 # mkDriver hook code starts @@ -48,17 +48,10 @@ proc ::scobj::watlow_mst4::mkDriver { sct_controller name ip_address tcp_port id handle_exception ${catch_status} ${catch_message} } -namespace eval ::scobj::watlow_mst4 { - namespace export debug_threshold - namespace export debug_log - namespace export sics_log - namespace export mkDriver -} - -proc add_watlow_mst4 {name ip_address tcp_port id datype dev_id tol} { +proc ::scobj::watlow_mst4::add_driver {name device_class simulation_flag ip_address tcp_port id datype dev_id tol} { set catch_status [ catch { - ::scobj::watlow_mst4::sics_log 9 "add_watlow_mst4 ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol}" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + ::scobj::watlow_mst4::sics_log 9 "::scobj::watlow_mst4::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol}" + if {[string equal -nocase "${simulation_flag}" "false"]} { if {[string equal -nocase "aqadapter" "${ip_address}"]} { ::scobj::watlow_mst4::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" makesctcontroller sct_${name} aqadapter ${tcp_port} @@ -67,14 +60,27 @@ proc add_watlow_mst4 {name ip_address tcp_port id datype dev_id tol} { makesctcontroller sct_${name} std ${ip_address}:${tcp_port} } } else { - ::scobj::watlow_mst4::sics_log 9 "[environment_simulation] => No sctcontroller for watlow_mst4" + ::scobj::watlow_mst4::sics_log 9 "simulation_flag={simulation_flag} => No sctcontroller for watlow_mst4" } - ::scobj::watlow_mst4::sics_log 1 "::scobj::watlow_mst4::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol}" - ::scobj::watlow_mst4::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol} + ::scobj::watlow_mst4::sics_log 1 "::scobj::watlow_mst4::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol}" + ::scobj::watlow_mst4::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${datype} ${dev_id} ${tol} } catch_message ] handle_exception ${catch_status} ${catch_message} } +namespace eval ::scobj::watlow_mst4 { + namespace export debug_threshold + namespace export debug_log + namespace export sics_log + namespace export mkDriver + namespace export add_driver +} + +proc add_watlow_mst4 {name ip_address tcp_port id datype dev_id tol} { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + ::scobj::watlow_mst4::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${id}" "${datype}" "${dev_id}" "${tol}" +} + clientput "file evaluation of sct_watlow_mst4.tcl" ::scobj::watlow_mst4::sics_log 9 "file evaluation of sct_watlow_mst4.tcl" @@ -83,6 +89,8 @@ proc ::scobj::watlow_mst4::read_config {} { set ns "::scobj::watlow_mst4" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + set device_class "environment" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -90,6 +98,12 @@ proc ::scobj::watlow_mst4::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -100,9 +114,9 @@ proc ::scobj::watlow_mst4::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "watlow_mst4"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue" } elseif { [dict exists $v "asyncqueue"] } { set asyncqueue [dict get $v "asyncqueue"] if { [string equal -nocase ${asyncqueue} "sct"] } { @@ -144,9 +158,9 @@ proc ::scobj::watlow_mst4::read_config {} { error "$name is missing configuration values $missing_list" } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_watlow_mst4 ${name} ${ip_address} ${tcp_port} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list } else { - add_watlow_mst4 ${name} "aqadapter" ${asyncqueue} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list } } } diff --git a/site_ansto/instrument/config/environment/temperature/sct_west4100.tcl b/site_ansto/instrument/config/environment/temperature/sct_west4100.tcl index fc09b87f..d72629bc 100644 --- a/site_ansto/instrument/config/environment/temperature/sct_west4100.tcl +++ b/site_ansto/instrument/config/environment/temperature/sct_west4100.tcl @@ -27,8 +27,8 @@ proc ::scobj::west4100::sics_log {debug_level debug_string} { } catch_message ] } -proc ::scobj::west4100::mkDriver { sct_controller name ip_address tcp_port dev_id } { - ::scobj::west4100::sics_log 9 "::scobj::west4100::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port} ${dev_id}" +proc ::scobj::west4100::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port dev_id } { + ::scobj::west4100::sics_log 9 "::scobj::west4100::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${dev_id}" set ns "[namespace current]" set catch_status [ catch { @@ -39,21 +39,27 @@ proc ::scobj::west4100::mkDriver { sct_controller name ip_address tcp_port dev_i handle_exception ${catch_status} ${catch_message} } +proc ::scobj::west4100::add_driver {name device_class simulation_flag ip_address tcp_port dev_id} { + set catch_status [ catch { + ::scobj::west4100::sics_log 9 "::scobj::west4100::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${dev_id}" + ::scobj::west4100::sics_log 9 "No sctcontroller for west4100" + ::scobj::west4100::sics_log 1 "::scobj::west4100::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${dev_id}" + ::scobj::west4100::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${dev_id} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + namespace eval ::scobj::west4100 { namespace export debug_threshold namespace export debug_log namespace export sics_log namespace export mkDriver + namespace export add_driver } proc add_west4100 {name ip_address tcp_port dev_id} { - set catch_status [ catch { - ::scobj::west4100::sics_log 9 "add_west4100 ${name} ${ip_address} ${tcp_port} ${dev_id}" - ::scobj::west4100::sics_log 9 "No sctcontroller for west4100" - ::scobj::west4100::sics_log 1 "::scobj::west4100::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${dev_id}" - ::scobj::west4100::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${dev_id} - } catch_message ] - handle_exception ${catch_status} ${catch_message} + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + ::scobj::west4100::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${dev_id}" } clientput "file evaluation of sct_west4100.tcl" @@ -64,6 +70,8 @@ proc ::scobj::west4100::read_config {} { set ns "::scobj::west4100" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + set device_class "environment" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -71,6 +79,12 @@ proc ::scobj::west4100::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -81,9 +95,9 @@ proc ::scobj::west4100::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "west4100"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue" } elseif { [dict exists $v "asyncqueue"] } { set asyncqueue [dict get $v "asyncqueue"] if { [string equal -nocase ${asyncqueue} "sct"] } { @@ -125,9 +139,9 @@ proc ::scobj::west4100::read_config {} { error "$name is missing configuration values $missing_list" } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_west4100 ${name} ${ip_address} ${tcp_port} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list } else { - add_west4100 ${name} "aqadapter" ${asyncqueue} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list } } } diff --git a/site_ansto/instrument/config/environment/temperature/sct_west_6100.tcl b/site_ansto/instrument/config/environment/temperature/sct_west_6100.tcl index 11de806d..1372950a 100644 --- a/site_ansto/instrument/config/environment/temperature/sct_west_6100.tcl +++ b/site_ansto/instrument/config/environment/temperature/sct_west_6100.tcl @@ -262,14 +262,14 @@ proc ::scobj::west_6100::wrInteger {tc_root nextState cmd_str} { handle_exception ${catch_status} ${catch_message} } -proc ::scobj::west_6100::mkDriver { sct_controller name ip_address tcp_port dev_id } { - ::scobj::west_6100::sics_log 9 "::scobj::west_6100::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port} ${dev_id}" +proc ::scobj::west_6100::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port dev_id } { + ::scobj::west_6100::sics_log 9 "::scobj::west_6100::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${dev_id}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT - sicslist setatt ${name} klass environment + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} @@ -400,7 +400,7 @@ proc ::scobj::west_6100::mkDriver { sct_controller name ip_address tcp_port dev_ hsetprop ${scobj_hpath} klass "@none" hsetprop ${scobj_hpath} type "part" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/alarm1 1 ${sct_controller} poll ${scobj_hpath}/alarm2 1 ${sct_controller} poll ${scobj_hpath}/power 1 @@ -416,7 +416,7 @@ proc ::scobj::west_6100::mkDriver { sct_controller name ip_address tcp_port dev_ ${sct_controller} write ${scobj_hpath}/setpoint ${sct_controller} write ${scobj_hpath}/w_sp } else { - ::scobj::west_6100::sics_log 9 "[environment_simulation] => No poll/write for west_6100" + ::scobj::west_6100::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for west_6100" } hfactory ${scobj_hpath}/aux plain spy none @@ -461,14 +461,14 @@ proc ::scobj::west_6100::mkDriver { sct_controller name ip_address tcp_port dev_ hsetprop ${scobj_hpath}/aux/model type "part" hsetprop ${scobj_hpath}/aux/model nxalias "${name}_aux_model" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/aux/decimal 2 ${sct_controller} poll ${scobj_hpath}/aux/instatus 2 ${sct_controller} poll ${scobj_hpath}/aux/model 2 } else { - ::scobj::west_6100::sics_log 9 "[environment_simulation] => No poll/write for west_6100" + ::scobj::west_6100::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for west_6100" } - hsetprop ${scobj_hpath} klass environment + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 # mkDriver hook code goes here @@ -476,31 +476,37 @@ proc ::scobj::west_6100::mkDriver { sct_controller name ip_address tcp_port dev_ handle_exception ${catch_status} ${catch_message} } +proc ::scobj::west_6100::add_driver {name device_class simulation_flag ip_address tcp_port dev_id} { + set catch_status [ catch { + ::scobj::west_6100::sics_log 9 "::scobj::west_6100::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${dev_id}" + if {[string equal -nocase "${simulation_flag}" "false"]} { + if {[string equal -nocase "aqadapter" "${ip_address}"]} { + ::scobj::west_6100::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" + makesctcontroller sct_${name} aqadapter ${tcp_port} + } else { + ::scobj::west_6100::sics_log 9 "makesctcontroller sct_${name} modbus_ap ${ip_address}:${tcp_port}" + makesctcontroller sct_${name} modbus_ap ${ip_address}:${tcp_port} + } + } else { + ::scobj::west_6100::sics_log 9 "simulation_flag={simulation_flag} => No sctcontroller for west_6100" + } + ::scobj::west_6100::sics_log 1 "::scobj::west_6100::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${dev_id}" + ::scobj::west_6100::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${dev_id} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + namespace eval ::scobj::west_6100 { namespace export debug_threshold namespace export debug_log namespace export sics_log namespace export mkDriver + namespace export add_driver } proc add_west_6100 {name ip_address tcp_port dev_id} { - set catch_status [ catch { - ::scobj::west_6100::sics_log 9 "add_west_6100 ${name} ${ip_address} ${tcp_port} ${dev_id}" - if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { - if {[string equal -nocase "aqadapter" "${ip_address}"]} { - ::scobj::west_6100::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" - makesctcontroller sct_${name} aqadapter ${tcp_port} - } else { - ::scobj::west_6100::sics_log 9 "makesctcontroller sct_${name} modbus_ap ${ip_address}:${tcp_port}" - makesctcontroller sct_${name} modbus_ap ${ip_address}:${tcp_port} - } - } else { - ::scobj::west_6100::sics_log 9 "[environment_simulation] => No sctcontroller for west_6100" - } - ::scobj::west_6100::sics_log 1 "::scobj::west_6100::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${dev_id}" - ::scobj::west_6100::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${dev_id} - } catch_message ] - handle_exception ${catch_status} ${catch_message} + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + ::scobj::west_6100::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${dev_id}" } clientput "file evaluation of sct_west_6100.tcl" @@ -511,6 +517,8 @@ proc ::scobj::west_6100::read_config {} { set ns "::scobj::west_6100" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + set device_class "environment" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -518,6 +526,12 @@ proc ::scobj::west_6100::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -528,9 +542,9 @@ proc ::scobj::west_6100::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "west_6100"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue" } elseif { [dict exists $v "asyncqueue"] } { set asyncqueue [dict get $v "asyncqueue"] if { [string equal -nocase ${asyncqueue} "sct"] } { @@ -572,9 +586,9 @@ proc ::scobj::west_6100::read_config {} { error "$name is missing configuration values $missing_list" } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_west_6100 ${name} ${ip_address} ${tcp_port} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list } else { - add_west_6100 ${name} "aqadapter" ${asyncqueue} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list } } } diff --git a/site_ansto/instrument/config/robots/sct_epson_pandp.tcl b/site_ansto/instrument/config/robots/sct_epson_pandp.tcl index a2bb8796..5a3a318d 100644 --- a/site_ansto/instrument/config/robots/sct_epson_pandp.tcl +++ b/site_ansto/instrument/config/robots/sct_epson_pandp.tcl @@ -27,8 +27,8 @@ proc ::scobj::epson_pandp::sics_log {debug_level debug_string} { } catch_message ] } -proc ::scobj::epson_pandp::mkDriver { sct_controller name ip_address tcp_port robot_name } { - ::scobj::epson_pandp::sics_log 9 "::scobj::epson_pandp::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port} ${robot_name}" +proc ::scobj::epson_pandp::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port robot_name } { + ::scobj::epson_pandp::sics_log 9 "::scobj::epson_pandp::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${robot_name}" set ns "[namespace current]" set catch_status [ catch { @@ -40,21 +40,27 @@ proc ::scobj::epson_pandp::mkDriver { sct_controller name ip_address tcp_port ro handle_exception ${catch_status} ${catch_message} } +proc ::scobj::epson_pandp::add_driver {name device_class simulation_flag ip_address tcp_port robot_name} { + set catch_status [ catch { + ::scobj::epson_pandp::sics_log 9 "::scobj::epson_pandp::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${robot_name}" + ::scobj::epson_pandp::sics_log 9 "No sctcontroller for epson_pandp" + ::scobj::epson_pandp::sics_log 1 "::scobj::epson_pandp::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${robot_name}" + ::scobj::epson_pandp::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${robot_name} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + namespace eval ::scobj::epson_pandp { namespace export debug_threshold namespace export debug_log namespace export sics_log namespace export mkDriver + namespace export add_driver } proc add_epson_pandp {name ip_address tcp_port robot_name} { - set catch_status [ catch { - ::scobj::epson_pandp::sics_log 9 "add_epson_pandp ${name} ${ip_address} ${tcp_port} ${robot_name}" - ::scobj::epson_pandp::sics_log 9 "No sctcontroller for epson_pandp" - ::scobj::epson_pandp::sics_log 1 "::scobj::epson_pandp::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${robot_name}" - ::scobj::epson_pandp::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} ${robot_name} - } catch_message ] - handle_exception ${catch_status} ${catch_message} + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + ::scobj::epson_pandp::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${robot_name}" } clientput "file evaluation of sct_epson_pandp.tcl" @@ -65,6 +71,8 @@ proc ::scobj::epson_pandp::read_config {} { set ns "::scobj::epson_pandp" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + set device_class "environment" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -72,6 +80,12 @@ proc ::scobj::epson_pandp::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -82,9 +96,9 @@ proc ::scobj::epson_pandp::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "epson_pandp"] } { - if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" + ${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue" } elseif { [dict exists $v "asyncqueue"] } { set asyncqueue [dict get $v "asyncqueue"] if { [string equal -nocase ${asyncqueue} "sct"] } { @@ -126,9 +140,9 @@ proc ::scobj::epson_pandp::read_config {} { error "$name is missing configuration values $missing_list" } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_epson_pandp ${name} ${ip_address} ${tcp_port} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list } else { - add_epson_pandp ${name} "aqadapter" ${asyncqueue} {*}$arg_list + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list } } } diff --git a/site_ansto/instrument/config/source/sct_reactor_status.tcl b/site_ansto/instrument/config/source/sct_reactor_status.tcl index 95985475..a5635221 100644 --- a/site_ansto/instrument/config/source/sct_reactor_status.tcl +++ b/site_ansto/instrument/config/source/sct_reactor_status.tcl @@ -216,14 +216,14 @@ proc ::scobj::reactor_status::setValue {tc_root nextState cmd_str} { handle_exception ${catch_status} ${catch_message} } -proc ::scobj::reactor_status::mkDriver { sct_controller name ip_address tcp_port } { - ::scobj::reactor_status::sics_log 9 "::scobj::reactor_status::mkDriver ${sct_controller} ${name} ${ip_address} ${tcp_port}" +proc ::scobj::reactor_status::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port } { + ::scobj::reactor_status::sics_log 9 "::scobj::reactor_status::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" set ns "[namespace current]" set catch_status [ catch { MakeSICSObj ${name} SCT_OBJECT - sicslist setatt ${name} klass NXsource + sicslist setatt ${name} klass ${device_class} sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} @@ -300,12 +300,12 @@ proc ::scobj::reactor_status::mkDriver { sct_controller name ip_address tcp_port hsetprop ${scobj_hpath} klass "@none" hsetprop ${scobj_hpath} type "part" - if {[string equal -nocase [SplitReply [opal_simulation]] "false"]} { + if {[string equal -nocase "${simulation_flag}" "false"]} { ${sct_controller} poll ${scobj_hpath}/status 30 } else { - ::scobj::reactor_status::sics_log 9 "[opal_simulation] => No poll/write for reactor_status" + ::scobj::reactor_status::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for reactor_status" } - hsetprop ${scobj_hpath} klass NXsource + hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 5 # mkDriver hook code starts @@ -314,31 +314,37 @@ proc ::scobj::reactor_status::mkDriver { sct_controller name ip_address tcp_port handle_exception ${catch_status} ${catch_message} } +proc ::scobj::reactor_status::add_driver {name device_class simulation_flag ip_address tcp_port} { + set catch_status [ catch { + ::scobj::reactor_status::sics_log 9 "::scobj::reactor_status::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" + if {[string equal -nocase "${simulation_flag}" "false"]} { + if {[string equal -nocase "aqadapter" "${ip_address}"]} { + ::scobj::reactor_status::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" + makesctcontroller sct_${name} aqadapter ${tcp_port} + } else { + ::scobj::reactor_status::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}" + makesctcontroller sct_${name} std ${ip_address}:${tcp_port} + } + } else { + ::scobj::reactor_status::sics_log 9 "simulation_flag={simulation_flag} => No sctcontroller for reactor_status" + } + ::scobj::reactor_status::sics_log 1 "::scobj::reactor_status::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" + ::scobj::reactor_status::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + namespace eval ::scobj::reactor_status { namespace export debug_threshold namespace export debug_log namespace export sics_log namespace export mkDriver + namespace export add_driver } proc add_reactor_status {name ip_address tcp_port} { - set catch_status [ catch { - ::scobj::reactor_status::sics_log 9 "add_reactor_status ${name} ${ip_address} ${tcp_port}" - if {[string equal -nocase [SplitReply [opal_simulation]] "false"]} { - if {[string equal -nocase "aqadapter" "${ip_address}"]} { - ::scobj::reactor_status::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" - makesctcontroller sct_${name} aqadapter ${tcp_port} - } else { - ::scobj::reactor_status::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}" - makesctcontroller sct_${name} std ${ip_address}:${tcp_port} - } - } else { - ::scobj::reactor_status::sics_log 9 "[opal_simulation] => No sctcontroller for reactor_status" - } - ::scobj::reactor_status::sics_log 1 "::scobj::reactor_status::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port}" - ::scobj::reactor_status::mkDriver sct_${name} ${name} ${ip_address} ${tcp_port} - } catch_message ] - handle_exception ${catch_status} ${catch_message} + set simulation_flag "[string tolower [SplitReply [opal_simulation]]]" + ::scobj::reactor_status::add_driver ${name} "NXsource" "${simulation_flag}" ${ip_address} ${tcp_port} } clientput "file evaluation of sct_reactor_status.tcl" @@ -349,6 +355,8 @@ proc ::scobj::reactor_status::read_config {} { set ns "::scobj::reactor_status" dict for {k u} $::config_dict { if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [opal_simulation]]]" + set device_class "NXsource" if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { continue } @@ -356,6 +364,12 @@ proc ::scobj::reactor_status::read_config {} { if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } set name [dict get $u name] set implementation [dict get $u "implementation"] if { !([dict exists $::config_dict $implementation]) } { @@ -366,9 +380,9 @@ proc ::scobj::reactor_status::read_config {} { continue } if { [string equal -nocase [dict get $v "driver"] "reactor_status"] } { - if { ![string equal -nocase [SplitReply [opal_simulation]] "false"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "[opal_simulation] => using null asyncqueue" + ${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue" } elseif { [dict exists $v "asyncqueue"] } { set asyncqueue [dict get $v "asyncqueue"] if { [string equal -nocase ${asyncqueue} "sct"] } { @@ -395,9 +409,9 @@ proc ::scobj::reactor_status::read_config {} { } } if { [string equal -nocase ${asyncqueue} "sct"] } { - add_reactor_status ${name} ${ip_address} ${tcp_port} + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} } else { - add_reactor_status ${name} "aqadapter" ${asyncqueue} + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} } } } From 6b6fd5131cf619533d8422d8991918bfef109d5e Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Thu, 11 Sep 2014 13:48:38 +1000 Subject: [PATCH 43/68] Add vactex.tcl found on wombat (fixed) --- .../hipd/config/commands/vactex.tcl | 108 ++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 site_ansto/instrument/hipd/config/commands/vactex.tcl diff --git a/site_ansto/instrument/hipd/config/commands/vactex.tcl b/site_ansto/instrument/hipd/config/commands/vactex.tcl new file mode 100644 index 00000000..4910f138 --- /dev/null +++ b/site_ansto/instrument/hipd/config/commands/vactex.tcl @@ -0,0 +1,108 @@ +#vactex + +set currentoct 0 + +set somdir 1 +set somstart 0 +set somend 0 +set octrange 0 + +proc SetUpVacTex {_somstart _somend} { + global currentoct somdir somstart somend octrange + + set somstart $_somstart + set somend $_somend +# set octrange $_octrange + + set currentrun 0 + set somdir 1 +# set currentoct [expr $octrange/2.0] + oct accel 2 +# oct speed 0.5 + oct decel 2 + som accel 3 + som decel 3 + som speed 3 + drive som $somstart + som speed 3 +} + +publish SetUpVacTex user + +proc VacTex {somstep} { + global currentoct somdir somstart somend octrange + +# set octspeed [expr {$octrange*1.0/$somtime}] +# oct speed $octspeed + + set i_bool 0 + if {$somdir == 1} { + set currentsom $somstart + set i 0 + } else { + set currentsom $somend + set i [expr {int(($somend-$somstart)/$somstep)}] + } + histmem mode unlimited + newfile HISTOGRAM_XY + while {$i_bool==0} { + + set currentoct [expr {$currentoct *-1}] + drive som $currentsom +# run oct $currentoct + oct oscillate_count 1 + oct oscillate start + hmm countblock + save $i + broadcast $i $currentsom $currentoct + + if {($somdir > 0)} { + set currentsom [expr {$currentsom + $somstep}] + if {$currentsom > $somend} {set i_bool 1} + incr i + } else { + set currentsom [expr {$currentsom - $somstep}] + if {$currentsom < $somstart} {set i_bool 1} + incr i -1 + } + + + + + } + set somdir [expr {(-1*$somdir)}] +} +publish VacTex user + +proc VacRamp {temp rate somstep} { + set tstart [SplitReply [tc1 setpoint]] + set tim1 [clock seconds] + set tlength [expr abs($tstart-$temp)/($rate/3600.0)] + tc1 ramprate $rate + tc1 setpoint $temp + set bool 0 +# RadCollOn $oscno + while {$bool==0} { + VacTex $somstep + set tim2 [expr [clock seconds]-$tim1] + if {$tim2>$tlength} {set bool 1} + } +} + +publish VacRamp user + + +proc VacRun {tmins somstep} { + set tim1 [clock seconds] + set tlength [expr {$tmins * 60}] + set bool 0 +# RadCollOn $oscno + while {$bool==0} { + VacTex $somstep + set tim2 [expr [clock seconds]-$tim1] + if {$tim2>$tlength} {set bool 1} + } +} + +publish VacRun user + From 48794002f6a6a025916c0f8f5ea16d341fb95021 Mon Sep 17 00:00:00 2001 From: Ferdi Franceschini Date: Thu, 11 Sep 2014 13:09:49 +1000 Subject: [PATCH 44/68] Moved dOmega and gDQv on Kookaburra as requested by Christine. See email Subj RE:Slight Modification ..., Date 7/5/2014 --- .../instrument/kookaburra/config/parameters/parameters.tcl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/site_ansto/instrument/kookaburra/config/parameters/parameters.tcl b/site_ansto/instrument/kookaburra/config/parameters/parameters.tcl index 4c0ba7f2..6ee343e6 100644 --- a/site_ansto/instrument/kookaburra/config/parameters/parameters.tcl +++ b/site_ansto/instrument/kookaburra/config/parameters/parameters.tcl @@ -8,14 +8,14 @@ # Note EndFacePosY and RotApPosY are surveyed positions foreach {var lname type priv units klass} { wavelength wavelength float user Angstrom crystal + dOmega dOmega float user degrees crystal + gDQv gDQv float user none crystal MainDeadTime MainDeadTime float user s detector TransDeadTime TransDeadTime float user s detector TransmissionTube TransmissionTube int user none detector bkgLevel bkgLevel float user 1 experiment deg2QConv deg2QConv float user none experiment - dOmega dOmega float user degrees experiment empLevel empLevel float user none experiment - gDQv gDQv float user none experiment level level float user none experiment thickness thickness float user mm sample defaultMCR defaultMCR float user count/sec monitor From 863eef237864a17486a8ffc055ff8dfceba85ae5 Mon Sep 17 00:00:00 2001 From: Ferdi Franceschini Date: Thu, 11 Sep 2014 14:05:32 +1000 Subject: [PATCH 45/68] SICS-753: Add named positions for kookaburra sample changer samz. --- .../kookaburra/config/motors/motor_configuration.tcl | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/site_ansto/instrument/kookaburra/config/motors/motor_configuration.tcl b/site_ansto/instrument/kookaburra/config/motors/motor_configuration.tcl index 0f36b949..3a3cc835 100644 --- a/site_ansto/instrument/kookaburra/config/motors/motor_configuration.tcl +++ b/site_ansto/instrument/kookaburra/config/motors/motor_configuration.tcl @@ -441,7 +441,8 @@ samz long_name samz samz softlowerlim 0 samz softupperlim 660 samz home 0 - +samz positions 33.5 178.5 323.5 468.5 613.5 +samz position_names 1 2 3 4 5 ############################ # Motor Controller 3 From 4a4f464485729fb2559d6109b4fbb3e85ee41f76 Mon Sep 17 00:00:00 2001 From: Ferdi Franceschini Date: Thu, 11 Sep 2014 14:27:39 +1000 Subject: [PATCH 46/68] Copied prun and pdrive from RELEASE-3_2 branch. --- site_ansto/instrument/util/motor_utility.tcl | 22 ++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/site_ansto/instrument/util/motor_utility.tcl b/site_ansto/instrument/util/motor_utility.tcl index 4c289525..0a4b10ea 100644 --- a/site_ansto/instrument/util/motor_utility.tcl +++ b/site_ansto/instrument/util/motor_utility.tcl @@ -49,6 +49,28 @@ proc reldrive {args} { } publish reldrive user +# \brief Posit run command for positional motors +# \parameter List of motor names and position names +proc prun {args} { + foreach {mot pname} $args { + lappend drlist $mot [SplitReply [$mot posit2unit $pname]] + } + clientput run {*}$drlist + run {*}$drlist +} +publish prun user + +# \brief Posit drive command for positional motors +# \parameter List of motor names and position names +proc pdrive {args} { + foreach {mot pname} $args { + lappend drlist $mot [SplitReply [$mot posit2unit $pname]] + } + clientput drive {*}$drlist + drive {*}$drlist +} +publish pdrive user + ## # @brief A convenience command for fetching motor parameter values # From 00f4dfe58801e61771469511eb749d86de3afcb5 Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Thu, 11 Sep 2014 15:35:31 +1000 Subject: [PATCH 47/68] Fix directories for quokka_configuration.tcl --- site_ansto/instrument/sans/quokka_configuration.tcl | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/site_ansto/instrument/sans/quokka_configuration.tcl b/site_ansto/instrument/sans/quokka_configuration.tcl index 3bf7f0d0..d558d904 100644 --- a/site_ansto/instrument/sans/quokka_configuration.tcl +++ b/site_ansto/instrument/sans/quokka_configuration.tcl @@ -34,13 +34,13 @@ fileeval $cfPath(environment)/temperature/sct_eurotherm_2000.tcl fileeval $cfPath(environment)/temperature/sct_eurotherm_m2000.tcl fileeval $cfPath(environment)/sct_keithley_2700.tcl fileeval $cfPath(environment)/sct_keithley_m2700.tcl -fileeval $cfPath(environment)/sct_lakeshore_218.tcl +fileeval $cfPath(environment)/temperature/sct_lakeshore_218.tcl fileeval $cfPath(environment)/temperature/sct_lakeshore_336.tcl fileeval $cfPath(environment)/temperature/sct_ls336.tcl fileeval $cfPath(environment)/temperature/sct_lakeshore_340.tcl fileeval $cfPath(environment)/temperature/sct_ls340.tcl fileeval $cfPath(environment)/temperature/sct_lakeshore_370.tcl -fileeval $cfPath(environment)/sct_lakeshore_m370.tcl +fileeval $cfPath(environment)/temperature/sct_lakeshore_m370.tcl fileeval $cfPath(environment)/temperature/sct_mercury_scpi.tcl fileeval $cfPath(environment)/sct_nhq_200.tcl fileeval $cfPath(environment)/sct_omron_hldc.tcl From e8ec81ad5d43ae7add4ecbfde3ba382ecd7ae2e8 Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Fri, 12 Sep 2014 10:35:33 +1000 Subject: [PATCH 48/68] SICS-776 Close the anti-collider file --- .../config/anticollider/anticollider_common.tcl | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/site_ansto/instrument/config/anticollider/anticollider_common.tcl b/site_ansto/instrument/config/anticollider/anticollider_common.tcl index c9b0ec8a..209a3522 100644 --- a/site_ansto/instrument/config/anticollider/anticollider_common.tcl +++ b/site_ansto/instrument/config/anticollider/anticollider_common.tcl @@ -45,13 +45,18 @@ proc handle_acscript_exception {status message args} { proc ::anticollider::loadscript {args} { variable veto_rules - set fh [open $::cfPath(anticollider)/[lindex $args 0] RDONLY ] - while {[gets $fh line] >= 0} { - # Skip empty lines and comments - if [regexp {^\s*$|^ *#} $line] { - continue + catch { + set fh [open $::cfPath(anticollider)/[lindex $args 0] RDONLY ] + while {[gets $fh line] >= 0} { + # Skip empty lines and comments + if [regexp {^\s*$|^ *#} $line] { + continue + } + lappend veto_rules $line } - lappend veto_rules $line + } + catch { + close $fh } } From c93b4d30a3a7144db800b8d471518ac9867b071c Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Fri, 12 Sep 2014 10:41:22 +1000 Subject: [PATCH 49/68] SICS-777 Allow the log directory to be set by SICS_INIT_LOGPATH environement variable --- servlog.c | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/servlog.c b/servlog.c index 72cf3825..da51c839 100644 --- a/servlog.c +++ b/servlog.c @@ -270,8 +270,8 @@ static FILE *fLogFile = NULL; static int iFile = 0; static int iLineCount = 0; static int iLogUsable = 1; -static char filnam[512]; -static char prevfilnam[512]; +static char filnam[1024]; +static char prevfilnam[1024]; /*---------------------------------------------------------------------------*/ int OpenVerifyLogFile() @@ -280,17 +280,21 @@ int OpenVerifyLogFile() char *pChar = NULL; char fPath[1024]; -/* snprintf(fPath, 1023, "%s/", getenv("SICS_INIT_LOGPATH")); */ - snprintf(fPath, 1023, "%s/", "../log"); + pChar = getenv("SICS_INIT_LOGPATH"); + if (!pChar) { + snprintf(fPath, sizeof(fPath) - 1, "%s/", "../log"); + } else { + snprintf(fPath, sizeof(fPath) - 1, "%s/", pChar); + } pChar = IFindOption(pSICSOptions, "LogFileBaseName"); if (!pChar) { /* Try to write to file "server" in */ strcpy(pFile, "server"); } else { - strlcpy(pFile, pChar, 255); + strlcpy(pFile, pChar, sizeof(pFile) - 1); } - snprintf(filnam, 511, "%s%s_%19.19s.%02d.log", fPath, pFile, timestamp(NULL, '-'), iFile); + snprintf(filnam, sizeof(filnam) - 1, "%s%s_%19.19s.%02d.log", fPath, pFile, timestamp(NULL, '-'), iFile); iFile++; if (iFile >= MAXFILES) { iFile = 0; From cc9d59ee73b37e9eb050c37a6d6fe035a0c9549b Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Fri, 12 Sep 2014 10:42:00 +1000 Subject: [PATCH 50/68] SICS-777 Use SICS_INIT_LOGPATH to move script_validator logs in runsics.py --- site_ansto/instrument/runsics.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site_ansto/instrument/runsics.py b/site_ansto/instrument/runsics.py index 3c3f3692..85cc110f 100755 --- a/site_ansto/instrument/runsics.py +++ b/site_ansto/instrument/runsics.py @@ -64,7 +64,7 @@ def start_cmd(server, args): 'none': '', 'fullsim': 'SICS_SIMULATION=full%s' % soffset, 'fakedev': 'SICS_SIMULATION=fakedev%s' % soffset, - 'scriptval': 'SICS_SIMULATION=script_validator%s' % soffset + 'scriptval': 'SICS_INIT_LOGPATH="../script_validator/log" SICS_SIMULATION=script_validator%s' % soffset } # Set SICS_SIMULATION environment variable if (server == 'scriptval'): From 042119898d637367054db557b8f56e9b4b81a320 Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Fri, 12 Sep 2014 13:00:26 +1000 Subject: [PATCH 51/68] SICS-778 Fix crash in conman.c hookFunc --- conman.c | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/conman.c b/conman.c index 6afdc5cc..e069cc51 100644 --- a/conman.c +++ b/conman.c @@ -2127,8 +2127,17 @@ static void hookFunc(const char *pText, OutCode eOut, void*pData) { SConnection *pCon = (SConnection *) pData; int text_len = strlen(pText); + char txt[5]; - ANETwrite(pCon->sockHandle, pText, text_len); + if (!VerifyConnection(pCon)) { + return; + } + if (!ANETvalidHandle(pCon->sockHandle)) { + return; + } + snprintf(txt, 5, "%3s:", OutCodeToTxt(eOut)); + ANETwrite(pCon->sockHandle, txt, 4); + ANETwrite(pCon->sockHandle, (char *)pText, text_len); if (pText[text_len - 1] != '\n') ANETwrite(pCon->sockHandle, "\n", 1); } @@ -2151,9 +2160,13 @@ int KillCapture(SConnection * pCon) int LogCapture(SConnection * pCon, SicsInterp * pSics, void *pData, int argc, char *argv[]) { + SConnection * pConMaster; char pBueffel[512]; int i; + pConMaster = SCfindMaster(pCon); + if (pConMaster == NULL) + return 0; /* check no af args */ if (argc < 2) { snprintf(pBueffel,sizeof(pBueffel)-1, "Insufficient number of arguments to %s", argv[0]); @@ -2164,18 +2177,19 @@ int LogCapture(SConnection * pCon, SicsInterp * pSics, void *pData, /* Branch according to argv[1] */ if (strcmp(argv[1], "kill") == 0) { - KillCapture(pCon); + KillCapture(pConMaster); return 1; } else if (strcmp(argv[1], "all") == 0) { - AddSICSLogHook(hookFunc, "all", pCon); + AddSICSLogHook(hookFunc, "all", pConMaster); return 1; } else if (argc == 2) { /* must be outcode, try find it */ - AddSICSLogHook(hookFunc, argv[1], pCon); + AddSICSLogHook(hookFunc, argv[1], pConMaster); return 1; } else { /* make it a list */ - int i, len; + int i; + size_t len; char *pBuff; for (i = 1, len = 0; i < argc; ++i) len += strlen(argv[i]) + 1; @@ -2193,7 +2207,7 @@ int LogCapture(SConnection * pCon, SicsInterp * pSics, void *pData, strcpy(&pBuff[len], argv[i]); len += strlen(argv[i]); } - AddSICSLogHook(hookFunc, pBuff, pCon); + AddSICSLogHook(hookFunc, pBuff, pConMaster); if (pBuff != pBueffel) free(pBuff); return 1; @@ -2212,7 +2226,8 @@ int LogOutput(SConnection * pCon, SicsInterp * pSics, void *pData, { char pBueffel[512]; char *pBuff; - int i, len, result, start; + int i, result, start; + size_t len; OutCode outcode; /* check no af args */ @@ -2323,7 +2338,7 @@ int SCTaskFunction(void *pData) pPassword = strtok(NULL, " \t\r\n"); iRet = IsValidUser(pUser, pPassword); if (iRet >= 0) { - SCWrite(self, "Login OK", eError); + SCWrite(self, "Login OK", eLog); self->iLogin = 1; SCSetRights(self, iRet); pHost[0] = '\0'; From 0606e66f9012d908bd58668ccf54b760e0c5a951 Mon Sep 17 00:00:00 2001 From: Ferdi Franceschini Date: Fri, 12 Sep 2014 13:35:20 +1000 Subject: [PATCH 52/68] Add new sics_config.ini for Taipan TODO SICS-779 Changing sample_stage to 12tmagnet_sample_insert doesn't work. --- .../tas/config/motors/motor_configuration.tcl | 113 ++--- .../instrument/tas/util/sics_config.ini | 400 ++++++++++++------ 2 files changed, 331 insertions(+), 182 deletions(-) diff --git a/site_ansto/instrument/tas/config/motors/motor_configuration.tcl b/site_ansto/instrument/tas/config/motors/motor_configuration.tcl index b37eaad2..a63341d2 100644 --- a/site_ansto/instrument/tas/config/motors/motor_configuration.tcl +++ b/site_ansto/instrument/tas/config/motors/motor_configuration.tcl @@ -4,9 +4,6 @@ # FastShutter is currently set on Quokka only #::utility::mkVar FastShutter text manager FastShutter false instrument true false -# SET TO 1 TO USE THE TILT STAGE ie sample phi and chi -set use_tiltstage 0 - set animal taipan set sim_mode [SplitReply [motor_simulation]] @@ -93,6 +90,40 @@ set move_count 100 ############################ # +# CHOOSE HERE for sample stage configuration +########################################## +# Set axis_config as follows to use different axis configurations +# 0: normal stage configuration +# 1: Oxford magnet sample stick +set axis_config 0 + +if { [ info exists ::config_dict ] } { + if { [ dict exists $::config_dict sample_stage implementation ] } { + set implementation [ dict get $::config_dict sample_stage implementation ] + if {$implementation == "normal_sample_stage"} { + set axis_config 0 + } elseif {$implementation == "12tmagnet_sample_insert"} { + set axis_config 1 + } else { + set axis_config 0 + } + } +} + +switch $axis_config { + 0 { + set use_normal_config "true" + } + 1 { + set magmot "ms1" + set magmot_aq "mc2" + set magmot_axis "A" + set use_normal_config "false" + fileeval $cfPath(motors)/magnet_configuration.tcl + } +} + + # Dummy translation motor, useful for testing scans Motor dummy_motor asim [params \ @@ -138,36 +169,6 @@ dummy_s1 softupperlim 180 dummy_s1 precision 0.02 dummy_s1 home 0 -if { [ info exists ::config_dict ] && [ dict get $::config_dict s1_sample_insert enabled ] } { - set samp_stage_name "s1ss" - set tilt_motor_driver_type asim - - Motor s1 $motor_driver_type [params \ - asyncqueue mc2\ - host mc2-taipan\ - port pmc2-taipan\ - axis A\ - units degrees\ - hardlowerlim -1440\ - hardupperlim 1440\ - maxSpeed 1\ - maxAccel 1\ - maxDecel 1\ - stepsPerX [expr 67.0 * 25000 / 360]\ - absEnc 1\ - absEncHome 31275743\ - cntsPerX [expr 67.0 * 8192 / 360]] - s1 part sample - s1 long_name s1 - s1 softlowerlim -180 - s1 softupperlim 180 - s1 home 0 -} else { - set samp_stage_name "s1" - set tilt_motor_driver_type $motor_driver_type -} - -#if $use_tiltstage { # mc1: Monochromator crystal selection rotation/Tilt Motor mtilt $motor_driver_type [params \ asyncqueue mc1\ @@ -189,9 +190,7 @@ mtilt long_name mtilt mtilt softlowerlim -5 mtilt softupperlim 5 mtilt home 0 -#} -set atest mtilt # mc1: Monochromator Linear (Translate) Motor mtrans $motor_driver_type [params \ @@ -384,27 +383,29 @@ stl home 0.0 stl backlash_offset -0.2 # mc2: Sample Rotate -Motor $samp_stage_name $motor_driver_type [params \ - asyncqueue mc2\ - host mc2-taipan\ - port pmc2-taipan\ - axis E\ - units degrees\ - hardlowerlim -194\ - hardupperlim 134\ - maxSpeed 4\ - maxAccel 2\ - maxDecel 2\ - stepsPerX 12495\ - absEnc 1\ - absEncHome 10695068\ - cntsPerX 4096] -$samp_stage_name part sample -$samp_stage_name long_name $samp_stage_name -$samp_stage_name softlowerlim -170 -$samp_stage_name softupperlim 120 -$samp_stage_name home 35.997 -$samp_stage_name backlash_offset -0.2 +if {$use_normal_config == "true"} { + Motor s1 $motor_driver_type [params \ + asyncqueue mc2\ + host mc2-taipan\ + port pmc2-taipan\ + axis E\ + units degrees\ + hardlowerlim -194\ + hardupperlim 134\ + maxSpeed 4\ + maxAccel 2\ + maxDecel 2\ + stepsPerX 12495\ + absEnc 1\ + absEncHome 10695068\ + cntsPerX 4096] + s1 part sample + s1 long_name s1 + s1 softlowerlim -170 + s1 softupperlim 120 + s1 home 35.997 + s1 backlash_offset -0.2 +} # mc2: Analyser Detector Rotate -- Sample Scattering Angle # absEncHome 20728908\ at -50 diff --git a/site_ansto/instrument/tas/util/sics_config.ini b/site_ansto/instrument/tas/util/sics_config.ini index a6d20e29..2051ff37 100644 --- a/site_ansto/instrument/tas/util/sics_config.ini +++ b/site_ansto/instrument/tas/util/sics_config.ini @@ -1,156 +1,304 @@ -[12tmagnet] -desc = "12 Tesla Oxford Magnet" -driver = "12tmagnet" -enabled = False -group = environment:magnet -id = 11 -ip = 10.157.205.3 -name = magnetic -port = 55001 -type = B - [12tmagnet_setup] -cascade = 12tmagnet,s1_sample_insert,mercury_scpi +cascade = B1:12tmagnet_oxford,sample_stage:12tmagnet_sample_insert,T1:mercury_scpi_01 enabled = False -group = 0setup - -[ls336_1] -desc = "tc1: Lakeshore 336 temperature controller" -driver = "ls336" +[CF1] +cascade = T1:CF1_ls340,sample_stage:normal_sample_stage +enabled = False +[Default] +cascade = sample_stage:normal_sample_stage +enabled = True +[B1] +datype = B enabled = False -group = environment:temperature id = 1 -ip = 10.157.205.28 -name = tc1 -port = 7777 -terminator = \r\n -tol1 = 1.0 -tol2 = 1.0 -type = T - -[ls336_12] -desc = "tc6: Lakeshore 336 temperature controller" -driver = "ls336" +implementation = none +name = magnet1 +optype = magnetic_field +[Function_Generator] +datype = V enabled = False -group = environment:temperature -id = 6 -ip = 10.157.205.31 -name = tc6 -port = 7777 -terminator = \r\n -tol1 = 1.0 -tol2 = 1.0 -type = T - -[ls336_2] -desc = "tc2: Lakeshore 336 temperature controller" -driver = "ls336" +id = 1 +implementation = none +name = pulser +optype = function_generator +[I1] +datype = I +enabled = False +id = 1 +implementation = none +name = curr1 +optype = multimeter +[I2] +datype = I enabled = False -group = environment:temperature id = 2 -ip = 10.157.205.29 +implementation = none +name = curr2 +optype = multimeter +[T1] +datype = T +enabled = False +id = 1 +implementation = none +name = tc1 +optype = temperature +[T2] +datype = T +enabled = False +id = 2 +implementation = none name = tc2 -port = 7777 -terminator = \r\n -tol1 = 1.0 -tol2 = 1.0 -type = T - -[ls336_4] -desc = "tc3: Lakeshore 336 temperature controller" -driver = "ls336" +optype = temperature +[T3] +datype = T enabled = False -group = environment:temperature id = 3 -ip = 10.157.205.30 +implementation = none name = tc3 -port = 7777 -terminator = \r\n -tol1 = 1.0 -tol2 = 1.0 -type = T - -[ls336_5] -desc = "tc4: Lakeshore 336 temperature controller" -driver = "ls336" +optype = temperature +[T4] +datype = T enabled = False -group = environment:temperature id = 4 -ip = 137.157.201.21 +implementation = none name = tc4 -port = 7777 -terminator = \r\n -tol1 = 1.0 -tol2 = 1.0 -type = T - -[ls336_6] -desc = "tc5: Lakeshore 336 temperature controller" -driver = "ls336" +optype = temperature +[V1] +datype = V enabled = False -group = environment:temperature -id = 5 -ip = 137.157.201.21 -name = tc5 -port = 7777 -terminator = \r\n -tol1 = 1.0 -tol2 = 1.0 -type = T +id = 1 +implementation = none +name = volts1 +optype = multimeter +[V2] +datype = V +enabled = False +id = 2 +implementation = none +name = volts2 +optype = multimeter +[sample_stage] +enabled = Always +implementation = normal_sample_stage +name = sample_stage +optype = motion_axis +[12tmagnet_oxford] +asyncqueue = sct +desc = "12 Tesla Oxford Magnet" +driver = "oxford12tlv" +imptype = magnetic_field +interval = 5 +ip = 10.157.205.3 +port = 55001 -[ls340_1] -desc = "tc13: Lakeshore 340 temperature controller" +[12tmagnet_sample_insert] +desc = "s1 will be redefined as the magnet sample insert rotation." +imptype = motion_axis + +[CF1_ls340] +desc = "cf1: Bottom loading cryofurnace" driver = "ls340" -enabled = False -group = environment:temperature -id = 13 -ip = 137.157.203.137 -name = tc13 +imptype = temperature +ip = 10.157.205.43 port = 4001 terminator = \r\n tol1 = 1.0 tol2 = 1.0 -type = T -[ls370] -desc = "tc8: Lakeshore 370 temperature controller" -driver = "ls370" -enabled = False -group = environment:temperature -id = 8 -ip = 137.157.203.137 -name = tc8 -port = 4003 +[agilent_33220A] +asyncqueue = sct +desc = "Function Generator" +driver = agilent_33220A +imptype = function_generator +ip = 10.157.205.16 +name = pulser +port = 5025 + +[ls336_01] +asyncqueue = sct +desc = "Lakeshore 336 temperature controller" +driver = "ls336" +imptype = temperature +ip = 10.157.205.28 +port = 7777 terminator = \r\n -tol = 2.0 -type = T +tol1 = 1.0 +tol2 = 1.0 -[mercury_scpi] -desc = "tc9: Oxford Mercury temperature controller in Mercury mode" -driver = "mercury_scpi" -enabled = False -group = environment:temperature -id = 9 +[ls336_02] +asyncqueue = sct +desc = "Lakeshore 336 temperature controller" +driver = "ls336" +imptype = temperature +ip = 10.157.205.29 +port = 7777 +terminator = \r\n +tol1 = 1.0 +tol2 = 1.0 + +[ls336_04] +asyncqueue = sct +desc = "Lakeshore 336 temperature controller" +driver = "ls336" +imptype = temperature +ip = 10.157.205.30 +port = 7777 +terminator = \r\n +tol1 = 1.0 +tol2 = 1.0 + +[ls336_05] +asyncqueue = sct +desc = "Lakeshore 336 temperature controller" +driver = "ls336" +imptype = temperature +ip = 137.157.201.21 +port = 7777 +terminator = \r\n +tol1 = 1.0 +tol2 = 1.0 + +[ls336_06] +asyncqueue = sct +desc = "Lakeshore 336 temperature controller" +driver = "ls336" +imptype = temperature +ip = 10.157.205.30 +port = 7777 +terminator = \r\n +tol1 = 1.0 +tol2 = 1.0 + +[ls336_11] +desc = "Lakeshore 336 temperature controller" +driver = "ls336" +imptype = temperature +ip = 10.157.205.27 +port = 7777 +terminator = \r\n +tol1 = 1.0 +tol2 = 1.0 + +[ls336_12] +asyncqueue = sct +desc = "Lakeshore 336 temperature controller" +driver = "ls336" +imptype = temperature +ip = 10.157.205.31 +port = 7777 +terminator = \r\n +tol1 = 1.0 +tol2 = 1.0 + +[ls340_01] +asyncqueue = sct +desc = "Lakeshore 340 temperature controller" +driver = "ls340" +imptype = temperature +ip = 137.157.201.86 +port = 4001 +terminator = \r\n +tol1 = 1.0 +tol2 = 1.0 + +[ls340_02] +asyncqueue = sct +desc = "Lakeshore 340 temperature controller" +driver = "ls340" +imptype = temperature +ip = 137.157.201.86 +port = 4002 +terminator = \r\n +tol1 = 1.0 +tol2 = 1.0 + +[ls340_11] +desc = "Lakeshore 340 temperature controller" +driver = "ls340" +imptype = temperature +ip = 137.157.201.86 +port = 4001 +terminator = \r\n +tol1 = 1.0 +tol2 = 1.0 + +[mercury_scpi_01] +desc = "Oxford Mercury temperature controller with three temperature loops." +driver = "mercury_base" +imptype = temperature ip = 10.157.205.5 -name = tc9 -offifon = mercury_itc500 +permlink = LT port = 7020 -terminator = \r -tol = 2.0 -type = T +terminator = \r\n +tol = 1.0 +valve_tol = 2 -[s1_sample_insert] -desc = "s1 will be defined as the sample insert rotation. Sample stage will be renamed to s1ss and sgu and sgl will be simulated" -enabled = False -group = motors +[mercury_scpi_02] +desc = "Oxford Mercury temperature controller with four temperature loops and needle valve control" +driver = "mercury_scpi" +imptype = temperature +ip = 10.157.205.47 +permlink = LT +port = 7020 +terminator = \r\n +tol = 1.0 +valve_tol = 2 -[west4100] -desc = "tc10: Blue furnace temperature controller" +[normal_sample_stage] +desc = "This is the default sample stage configuration" +imptype = motion_axis + +[protek_01] +asyncqueue = sct +desc = "Protek Multimeter" +driver = "protekmm" +imptype = multimeter +ip = 10.157.205.36 +port = 4001 + +[protek_02] +asyncqueue = sct +desc = "Protek Multimeter" +driver = "protekmm" +imptype = multimeter +ip = 10.157.205.37 +port = 4001 + +[vf1_west4100] +asyncqueue = sct +desc = "VF1 Blue furnace temperature controller" +dev_id = 1 driver = "west4100" -enabled = False -group = environment:temperature -id = 10 -ip = 10.157.205.19 -name = tc10 -type = T +imptype = temperature +ip = 10.157.205.24 +port = 502 + +[vf1_west6100] +asyncprotocol = modbus_ap +desc = "VF1 Blue furnace 6100 temperature controller" +dev_id = 1 +driver = "west_6100" +imptype = temperature +ip = 10.157.205.24 +port = 502 +timeout = 2000 + +[vf2_west4100] +asyncqueue = sct +desc = "VF2 Blue furnace temperature controller" +dev_id = 1 +driver = "west4100" +imptype = temperature +ip = 10.157.205.25 +port = 502 + +[vf2_west6100] +asyncprotocol = modbus_ap +desc = "VF2 Blue furnace 6100 temperature controller" +dev_id = 1 +driver = "west_6100" +imptype = temperature +ip = 10.157.205.25 +port = 502 +timeout = 2000 From 2852cc9d794d3a0ac0766066627c687a4ad50955 Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Tue, 16 Sep 2014 11:27:37 +1000 Subject: [PATCH 53/68] Fix IP address of Pelican HV --- site_ansto/instrument/pelican/config/hmm/sct_hv.tcl | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/site_ansto/instrument/pelican/config/hmm/sct_hv.tcl b/site_ansto/instrument/pelican/config/hmm/sct_hv.tcl index 2aa761c7..8e21185e 100644 --- a/site_ansto/instrument/pelican/config/hmm/sct_hv.tcl +++ b/site_ansto/instrument/pelican/config/hmm/sct_hv.tcl @@ -418,7 +418,7 @@ publish set_data_record user MakeAsyncProtocol std -MakeAsyncQueue hvport std 10.157.205.10 4001 +MakeAsyncQueue hvport std 137.157.202.215 55011 # Main process call to create the driver ::scobj::hv::mkHV { name "hv" @@ -427,9 +427,3 @@ MakeAsyncQueue hvport std 10.157.205.10 4001 tuning 1 interval 5 } - - - - - - From 12d4e7dce5dba57bbc2d133445a525c82ff76fa5 Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Thu, 18 Sep 2014 17:07:00 +1000 Subject: [PATCH 54/68] First pass driver for the Knauer BlueShadow Pump 40P --- .../config/environment/knauer_pump.sct | 286 ++++++++++++++++++ 1 file changed, 286 insertions(+) create mode 100644 site_ansto/instrument/config/environment/knauer_pump.sct diff --git a/site_ansto/instrument/config/environment/knauer_pump.sct b/site_ansto/instrument/config/environment/knauer_pump.sct new file mode 100644 index 00000000..e2288c48 --- /dev/null +++ b/site_ansto/instrument/config/environment/knauer_pump.sct @@ -0,0 +1,286 @@ +# +# Template driver for the Knauer BlueShadow Pump 40P +# vim: ts=8 sts=2 sw=2 expandtab autoindent smartindent nocindent +# +driver knauer_pump = { + debug_threshold = 0; + vendor = knauer; device = pump40p; protocol = knauer_ap; + class = environment; + simulation_group = environment_simulation +# + group dummy = { + type = text; readable = 1; data = false; control = false; nxsave = false; + var status = { read_command = 'STATUS?'; read_function = read_status; } + var glp = { read_command = 'GLP?'; read_function = read_glp; } + } + + group volume = { + type = float; + property 'units' = 'mL'; + var sensor = { + readable = 1; + read_command = ' '; + fetch_function = volume_fetch; + #checkrange_function = volume_reject; + } + var setpoint = { + writeable = 1; + write_command = ' '; + write_function = volume_write; + driveable = volume/sensor; + checkstatus_function = volume_checkstatus; + halt_function = volume_halt; + lowerlimit = 0; upperlimit = 100; tolerance = 0.01; + readable = 1; + read_command = ' '; + fetch_function = volume_checkpumping; + } + } + group ratios = { + type = text; + property 'units' = 'percent'; + var sensor = { + readable = 1; read_command = ' '; fetch_function = ratios_fetch; + } + var setpoint = { + writeable = 1; write_command = ' '; write_function = ratios_write; checkrange_function = ratios_check; + } + } + group flow = { + type = float; + property 'units' = 'mL/min'; + var sensor = { + readable = 1; read_command = ' '; fetch_function = flow_fetch; + } + var setpoint = { + writeable = 1; write_command = ' '; write_function = flow_write; + lowerlimit = 0; upperlimit = 10; + } + } + + group stuff = { + readable = 60; + type = text; + var an_out = { read_command = 'AN_OUT?'; } + var boardinfo = { read_command = 'BOARDINFO?'; } + var config = { read_command = 'CONFIG?'; } + var cprofinfo = { read_command = 'CPROFINFO?'; } + var dout = { read_command = 'DOUT?'; } + var error = { read_command = 'ERROR?'; } + var errors = { read_command = 'ERRORS?'; } + var flushpmp = { read_command = 'FLUSHPMP?'; } + var head = { read_command = 'HEAD?'; } + var head_par = { read_command = 'HEAD_PAR?'; } + var identify = { read_command = 'IDENTIFY?'; } + var lpg = { read_command = 'LPG?'; } + var oem = { read_command = 'OEM?'; } + var opt = { read_command = 'OPT?'; } + var plim = { read_command = 'PLIM?'; } + var pressure = { read_command = 'PRESSURE?'; } + var prfastacq = { read_command = 'PRFASTACQ?'; } + var purge = { read_command = 'PURGE?'; } + var remote = { read_command = 'REMOTE?'; } + var rfid = { read_command = 'RFID?'; } + var service = { read_command = 'SERVICE?'; } + var sysinfo = { read_command = 'SYSINFO?'; } + var 'units' = { read_command = 'UNITS?'; } + var valves = { read_command = 'VALVES?'; } + } + group prog = { + readable = 30; + type = text; + var line_01 = { read_command = "TT_GET:1,1"; } + var line_02 = { read_command = "TT_GET:1,2"; } + var line_03 = { read_command = "TT_GET:1,3"; } + var line_04 = { read_command = "TT_GET:1,4"; } + var line_05 = { read_command = "TT_GET:1,5"; } + } + group glp = { + type = text; + readable = 1; + fetch_function = fetch_from_glp; + var board_time = { read_command = '0'; } + var motor_time = { read_command = '1'; } + var head_count = { read_command = '3'; } + var head_time = { read_command = '4'; } + var head_volm = { read_command = '5'; } + var head_voln = { read_command = '6'; } + var head_pwrhi = { read_command = '7'; } + var head_pwrlo = { read_command = '8'; } + var pump_revs = { read_command = '9'; } + var pump_volm = { read_command = '10'; } + var pump_voln = { read_command = '11'; } + var pump_pwrhi = { read_command = '12'; } + var pump_pwrlo = { read_command = '13'; } + } + group status = { + type = text; + readable = 1; + fetch_function = fetch_from_status; + var state = { read_command = '1'; } + var cur_error = { read_command = '2'; } + var cur_run_time = { read_command = '3'; } + var flow_rate = { read_command = '4'; } + var lpg_0 = { read_command = '5'; } + var lpg_1 = { read_command = '6'; } + var lpg_2 = { read_command = '7'; } + var lpg_3 = { read_command = '8'; } + var evt_0 = { read_command = '9'; } + var evt_1 = { read_command = '10'; } + var evt_2 = { read_command = '11'; } + var evt_3 = { read_command = '12'; } + var evt_4 = { read_command = '13'; } + var evt_5 = { read_command = '14'; } + var evt_6 = { read_command = '15'; } + var evt_7 = { read_command = '16'; } + var cur_pres = { read_command = '17'; } + var start_in = { read_command = '18'; } + var error_in = { read_command = '19'; } + } + + code fetch_from_glp = {%% + set index ${cmd_str} + set data [hgetpropval ${tc_root}/dummy/glp real_data] + set dlist [split ${data} ","] + sct result [lindex ${dlist} ${index}] + set cmd "@@NOSEND@@" + %%} + + code fetch_from_status = {%% + set index ${cmd_str} + set data [hgetpropval ${tc_root}/dummy/status real_data] + set dlist [split ${data} ","] + sct result [lindex ${dlist} ${index}] + set cmd "@@NOSEND@@" + %%} + + code read_glp = {%% + set dlist [split [lindex [split ${data} ":"] 1] ","] + sct real_data "[join [lrange ${dlist} 0 end] ,]" + set data "Hidden in real_data property" + %%} + code read_status = {%% + set dlist [split [lindex [split ${data} ":"] 1] ","] + sct real_data "[join [lrange ${dlist} 0 end] ,]" + set data "Hidden in real_data property" + %%} + + code halt = {%% + set ratios [hval ${tc_root}/ratios/setpoint] + set ratios [join [split ${ratios} /] ,] + set cmd "RAMP:0,0,${ratios},0,0,0,0,0,0,0,0,2" + %%} + + code flow_fetch = {%% + set data [hgetpropval ${tc_root}/dummy/status real_data] + set dlist [split ${data} ","] + set flow [lindex ${dlist} 4] + sct result [expr {0.001 * ${flow}}] + set cmd "@@NOSEND@@" + %%} + code flow_write = {%% + set data [sct target] + set cmd "@@NOSEND@@" + set nextState idle + if { ${data} != [sct oldval] } { + debug_log ${tc_root} 1 "[sct] changed to new:${data}, from old:[sct oldval]" + sct oldval ${data} + sct update ${data} + sct utime readtime + } + %%} + + code ratios_check = {%% + set ratios [split ${setpoint} /] + if { [llength ${ratios}] != 4 } { + sct geterror "${setpoint} has [llength ${ratios}] components, needs 4" + error [sct geterror] + } + set sum [expr [lindex ${ratios} 0] + [lindex ${ratios} 1] + [lindex ${ratios} 2] + [lindex ${ratios} 3]] + if { ${sum} != 100 } { + sct geterror "sum is ${sum}, must be 100" + error [sct geterror] + } + %%} + + code ratios_fetch = {%% + set data [hgetpropval ${tc_root}/dummy/status real_data] + set dlist [split ${data} ","] + set ratios "[lindex ${dlist} 5]/[lindex ${dlist} 6]/[lindex ${dlist} 7]/[lindex ${dlist} 8]" + sct result ${ratios} + set cmd "@@NOSEND@@" + %%} + code ratios_write = {%% + set data [sct target] + set cmd "@@NOSEND@@" + set nextState idle + if { ${data} != [sct oldval] } { + debug_log ${tc_root} 1 "[sct] changed to new:${data}, from old:[sct oldval]" + sct oldval ${data} + sct update ${data} + sct utime readtime + } + %%} + + code volume_fetch = {%% + set data [hgetpropval ${tc_root}/dummy/glp real_data] + set dlist [split ${data} ","] + if { [llength ${dlist}] > 11 } { + set pump_volm [lindex ${dlist} 10] + set pump_voln [lindex ${dlist} 11] + set volume [expr {${pump_volm} + 0.000001 * ${pump_voln}}] + } else { + set volume 0.0 + } + sct raw_volume ${volume} + if { [hpropexists [sct] base_volume] } { + set volume [expr {${volume} - [sct base_volume]}] + } else { + sct base_volume [sct raw_volume] + } + sct result ${volume} + set cmd "@@NOSEND@@" + %%} + code volume_write = {%% + hsetprop ${tc_root}/[sct driveable] base_volume [hgetpropval ${tc_root}/[sct driveable] raw_volume] + hset ${tc_root}/[sct driveable] 0.0 + set flow [expr {int(1000.0 * [hval ${tc_root}/flow/setpoint])}] + set ratios [hval ${tc_root}/ratios/setpoint] + set ratios [join [split ${ratios} /] ,] + set cmd "RAMP:0,${flow},${ratios},0,0,0,0,0,0,0,0,3" + sct pumping 1 + %%} + + code volume_checkpumping = {%% + set cmd "@@NOSEND@@" + set nextState idle + if { [hpropexists [sct] pumping] && [sct pumping] } { + if { [hpropexists [sct] driving] && [sct driving] } { + volume_checkstatus "${tc_root}" + } + set sp "[sct target]" + set pv "[hval ${tc_root}/[sct driveable]]" + if { (${sp} - ${pv}) <= [sct tolerance] } { + set flow 0 + set ratios [hval ${tc_root}/ratios/setpoint] + set ratios [join [split ${ratios} /] ,] + set cmd "RAMP:0,${flow},${ratios},0,0,0,0,0,0,0,0,2" + set nextState noResponse + sct pumping 0 + } + } + %%} + + code volume_halt = {%% + set flow 0 + set ratios [hval ${tc_root}/ratios/setpoint] + set ratios [join [split ${ratios} /] ,] + set cmd "RAMP:0,${flow},${ratios},0,0,0,0,0,0,0,0,2" + sct send ${cmd} + %%} + + code volume_reject = {%% + sct geterror "cannot use hset on [sct]" + error "[sct geterror]" + %%} +} From 1a15aa5de67c652af5dc3829b9394c743111071a Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Thu, 18 Sep 2014 17:07:30 +1000 Subject: [PATCH 55/68] Generated Knauer driver --- .../config/environment/sct_knauer_pump.tcl | 1820 +++++++++++++++++ 1 file changed, 1820 insertions(+) create mode 100644 site_ansto/instrument/config/environment/sct_knauer_pump.tcl diff --git a/site_ansto/instrument/config/environment/sct_knauer_pump.tcl b/site_ansto/instrument/config/environment/sct_knauer_pump.tcl new file mode 100644 index 00000000..dda04d9f --- /dev/null +++ b/site_ansto/instrument/config/environment/sct_knauer_pump.tcl @@ -0,0 +1,1820 @@ +# Generated driver for knauer_pump +# vim: ft=tcl tabstop=8 softtabstop=2 shiftwidth=2 nocindent smartindent +# + +namespace eval ::scobj::knauer_pump { + set debug_threshold 0 +} + +proc ::scobj::knauer_pump::debug_log {tc_root debug_level debug_string} { + set catch_status [ catch { + set debug_threshold [hgetpropval ${tc_root} debug_threshold] + if {${debug_level} >= ${debug_threshold}} { + set fd [open "../log/knauer_pump_[basename ${tc_root}].log" "a"] + set line "[clock format [clock seconds] -format "%T"] ${debug_string}" + puts ${fd} "${line}" + close ${fd} + } + } catch_message ] +} + +proc ::scobj::knauer_pump::sics_log {debug_level debug_string} { + set catch_status [ catch { + set debug_threshold ${::scobj::knauer_pump::debug_threshold} + if {${debug_level} >= ${debug_threshold}} { + sicslog "::scobj::knauer_pump::${debug_string}" + } + } catch_message ] +} + +# checklimits function for driveable interface +proc ::scobj::knauer_pump::checklimits {tc_root} { + set catch_status [ catch { + debug_log ${tc_root} 1 "checklimits tc_root=${tc_root} sct=[sct] target=[sct target]" + set setpoint [sct target] + if { [hpropexists [sct] lowerlimit] } { + set lolimit [sct lowerlimit] + } else { + # lowerlimit not set, use target + set lolimit [sct target] + } + if { [hpropexists [sct] upperlimit] } { + set hilimit [sct upperlimit] + } else { + # upperlimit not set, use target + set hilimit [sct target] + } +# checklimits hook code goes here + if { ${setpoint} < ${lolimit} || ${setpoint} > ${hilimit} } { + sct driving 0 + error "setpoint ${setpoint} violates limits (${lolimit}..${hilimit}) on [sct]" + } + return OK + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +# check function for hset change +proc ::scobj::knauer_pump::checkrange {tc_root} { + set catch_status [ catch { + debug_log ${tc_root} 1 "checkrange tc_root=${tc_root} sct=[sct] target=[sct target]" + set setpoint [sct target] + if { [hpropexists [sct] lowerlimit] } { + set lolimit [sct lowerlimit] + } else { + # lowerlimit not set, use target + set lolimit [sct target] + } + if { [hpropexists [sct] upperlimit] } { + set hilimit [sct upperlimit] + } else { + # upperlimit not set, use target + set hilimit [sct target] + } +# checkrange hook code goes here + if { ${setpoint} < ${lolimit} || ${setpoint} > ${hilimit} } { + error "setpoint ${setpoint} violates limits (${lolimit}..${hilimit}) on [sct]" + } + return OK + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +# function to request the read of a parameter on a device +proc ::scobj::knauer_pump::fetch_from_glp {tc_root nextState cmd_str} { + set catch_status [ catch { + debug_log ${tc_root} 1 "fetch_from_glp tc_root=${tc_root} sct=[sct] cmd=${cmd_str}" + if { [hpropexists [sct] geterror] } { + hdelprop [sct] geterror + } + set cmd "${cmd_str}" +# fetch_from_glp hook code starts + set index ${cmd_str} + set data [hgetpropval ${tc_root}/dummy/glp real_data] + set dlist [split ${data} ","] + sct result [lindex ${dlist} ${index}] + set cmd "@@NOSEND@@" +# fetch_from_glp hook code ends + if { [hpropexists [sct] geterror] } { + debug_log ${tc_root} 9 "[sct] error: [sct geterror]" + error "[sct geterror]" + } + debug_log ${tc_root} 1 "fetch_from_glp sct send ${cmd}" + if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} { + sct send "${cmd}" + } + return ${nextState} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +# function to request the read of a parameter on a device +proc ::scobj::knauer_pump::fetch_from_status {tc_root nextState cmd_str} { + set catch_status [ catch { + debug_log ${tc_root} 1 "fetch_from_status tc_root=${tc_root} sct=[sct] cmd=${cmd_str}" + if { [hpropexists [sct] geterror] } { + hdelprop [sct] geterror + } + set cmd "${cmd_str}" +# fetch_from_status hook code starts + set index ${cmd_str} + set data [hgetpropval ${tc_root}/dummy/status real_data] + set dlist [split ${data} ","] + sct result [lindex ${dlist} ${index}] + set cmd "@@NOSEND@@" +# fetch_from_status hook code ends + if { [hpropexists [sct] geterror] } { + debug_log ${tc_root} 9 "[sct] error: [sct geterror]" + error "[sct geterror]" + } + debug_log ${tc_root} 1 "fetch_from_status sct send ${cmd}" + if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} { + sct send "${cmd}" + } + return ${nextState} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +# function to request the read of a parameter on a device +proc ::scobj::knauer_pump::flow_fetch {tc_root nextState cmd_str} { + set catch_status [ catch { + debug_log ${tc_root} 1 "flow_fetch tc_root=${tc_root} sct=[sct] cmd=${cmd_str}" + if { [hpropexists [sct] geterror] } { + hdelprop [sct] geterror + } + set cmd "${cmd_str}" +# flow_fetch hook code starts + set data [hgetpropval ${tc_root}/dummy/status real_data] + set dlist [split ${data} ","] + set flow [lindex ${dlist} 4] + sct result [expr {0.001 * ${flow}}] + set cmd "@@NOSEND@@" +# flow_fetch hook code ends + if { [hpropexists [sct] geterror] } { + debug_log ${tc_root} 9 "[sct] error: [sct geterror]" + error "[sct geterror]" + } + debug_log ${tc_root} 1 "flow_fetch sct send ${cmd}" + if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} { + sct send "${cmd}" + } + return ${nextState} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +# function to write a parameter value on a device +proc ::scobj::knauer_pump::flow_write {tc_root nextState cmd_str} { + set catch_status [ catch { + debug_log ${tc_root} 1 "flow_write tc_root=${tc_root} sct=[sct] cmd=${cmd_str}" + if { [hpropexists [sct] geterror] } { + hdelprop [sct] geterror + } + set par [sct target] + set cmd "${cmd_str}${par}" +# flow_write hook code starts + set data [sct target] + set cmd "@@NOSEND@@" + set nextState idle + if { ${data} != [sct oldval] } { + debug_log ${tc_root} 1 "[sct] changed to new:${data}, from old:[sct oldval]" + sct oldval ${data} + sct update ${data} + sct utime readtime + } +# flow_write hook code ends + if { [hpropexists [sct] geterror] } { + debug_log ${tc_root} 9 "[sct] error: [sct geterror]" + error "[sct geterror]" + } + if { [hpropexists [sct] driving] } { + if { [hpropexists [sct] writestatus] && [sct writestatus] == "start" } { + sct driving 1 + } + } + debug_log ${tc_root} 1 "flow_write sct send ${cmd}" + if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} { + sct send "${cmd}" + } + return ${nextState} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +# function to request the read of a parameter on a device +proc ::scobj::knauer_pump::getValue {tc_root nextState cmd_str} { + set catch_status [ catch { + debug_log ${tc_root} 1 "getValue tc_root=${tc_root} sct=[sct] cmd=${cmd_str}" + if { [hpropexists [sct] geterror] } { + hdelprop [sct] geterror + } + set cmd "${cmd_str}" +# getValue hook code goes here + debug_log ${tc_root} 1 "getValue sct send ${cmd}" + if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} { + sct send "${cmd}" + } + return ${nextState} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +# function to check the write parameter on a device +proc ::scobj::knauer_pump::noResponse {tc_root} { + set catch_status [ catch { + debug_log ${tc_root} 1 "noResponse tc_root=${tc_root} sct=[sct] resp=[sct result]" +# noResponse hook code goes here + return "idle" + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +# check function for hset change +proc ::scobj::knauer_pump::ratios_check {tc_root} { + set catch_status [ catch { + debug_log ${tc_root} 1 "ratios_check tc_root=${tc_root} sct=[sct] target=[sct target]" + set setpoint [sct target] + if { [hpropexists [sct] lowerlimit] } { + set lolimit [sct lowerlimit] + } else { + # lowerlimit not set, use target + set lolimit [sct target] + } + if { [hpropexists [sct] upperlimit] } { + set hilimit [sct upperlimit] + } else { + # upperlimit not set, use target + set hilimit [sct target] + } +# ratios_check hook code starts + set ratios [split ${setpoint} /] + if { [llength ${ratios}] != 4 } { + sct geterror "${setpoint} has [llength ${ratios}] components, needs 4" + error [sct geterror] + } + set sum [expr [lindex ${ratios} 0] + [lindex ${ratios} 1] + [lindex ${ratios} 2] + [lindex ${ratios} 3]] + if { ${sum} != 100 } { + sct geterror "sum is ${sum}, must be 100" + error [sct geterror] + } +# ratios_check hook code ends + if { ${setpoint} < ${lolimit} || ${setpoint} > ${hilimit} } { + error "setpoint ${setpoint} violates limits (${lolimit}..${hilimit}) on [sct]" + } + return OK + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +# function to request the read of a parameter on a device +proc ::scobj::knauer_pump::ratios_fetch {tc_root nextState cmd_str} { + set catch_status [ catch { + debug_log ${tc_root} 1 "ratios_fetch tc_root=${tc_root} sct=[sct] cmd=${cmd_str}" + if { [hpropexists [sct] geterror] } { + hdelprop [sct] geterror + } + set cmd "${cmd_str}" +# ratios_fetch hook code starts + set data [hgetpropval ${tc_root}/dummy/status real_data] + set dlist [split ${data} ","] + set ratios "[lindex ${dlist} 5]/[lindex ${dlist} 6]/[lindex ${dlist} 7]/[lindex ${dlist} 8]" + sct result ${ratios} + set cmd "@@NOSEND@@" +# ratios_fetch hook code ends + if { [hpropexists [sct] geterror] } { + debug_log ${tc_root} 9 "[sct] error: [sct geterror]" + error "[sct geterror]" + } + debug_log ${tc_root} 1 "ratios_fetch sct send ${cmd}" + if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} { + sct send "${cmd}" + } + return ${nextState} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +# function to write a parameter value on a device +proc ::scobj::knauer_pump::ratios_write {tc_root nextState cmd_str} { + set catch_status [ catch { + debug_log ${tc_root} 1 "ratios_write tc_root=${tc_root} sct=[sct] cmd=${cmd_str}" + if { [hpropexists [sct] geterror] } { + hdelprop [sct] geterror + } + set par [sct target] + set cmd "${cmd_str}${par}" +# ratios_write hook code starts + set data [sct target] + set cmd "@@NOSEND@@" + set nextState idle + if { ${data} != [sct oldval] } { + debug_log ${tc_root} 1 "[sct] changed to new:${data}, from old:[sct oldval]" + sct oldval ${data} + sct update ${data} + sct utime readtime + } +# ratios_write hook code ends + if { [hpropexists [sct] geterror] } { + debug_log ${tc_root} 9 "[sct] error: [sct geterror]" + error "[sct geterror]" + } + if { [hpropexists [sct] driving] } { + if { [hpropexists [sct] writestatus] && [sct writestatus] == "start" } { + sct driving 1 + } + } + debug_log ${tc_root} 1 "ratios_write sct send ${cmd}" + if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} { + sct send "${cmd}" + } + return ${nextState} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +# function to parse the read of a parameter on a device +proc ::scobj::knauer_pump::rdValue {tc_root} { + set catch_status [ catch { + debug_log ${tc_root} 1 "rdValue tc_root=${tc_root} sct=[sct] result=[sct result]" + if { [hpropexists [sct] geterror] } { + hdelprop [sct] geterror + } + set data [sct result] + set nextState "idle" + if {[string equal -nocase -length 7 ${data} "ASCERR:"]} { + # the protocol driver has reported an error + sct geterror "${data}" + error "[sct geterror]" + } +# rdValue hook code goes here + if { ${data} != [sct oldval] } { + debug_log ${tc_root} 1 "[sct] changed to new:${data}, from old:[sct oldval]" + sct oldval ${data} + sct update ${data} + sct utime readtime + } + return ${nextState} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +# function to parse the read of a parameter on a device +proc ::scobj::knauer_pump::read_glp {tc_root} { + set catch_status [ catch { + debug_log ${tc_root} 1 "read_glp tc_root=${tc_root} sct=[sct] result=[sct result]" + if { [hpropexists [sct] geterror] } { + hdelprop [sct] geterror + } + set data [sct result] + set nextState "idle" + if {[string equal -nocase -length 7 ${data} "ASCERR:"]} { + # the protocol driver has reported an error + sct geterror "${data}" + error "[sct geterror]" + } +# read_glp hook code starts + set dlist [split [lindex [split ${data} ":"] 1] ","] + sct real_data "[join [lrange ${dlist} 0 end] ,]" + set data "Hidden in real_data property" +# read_glp hook code ends + if { [hpropexists [sct] geterror] } { + debug_log ${tc_root} 9 "[sct] error: [sct geterror]" + error "[sct geterror]" + } + if { ${data} != [sct oldval] } { + debug_log ${tc_root} 1 "[sct] changed to new:${data}, from old:[sct oldval]" + sct oldval ${data} + sct update ${data} + sct utime readtime + } + return ${nextState} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +# function to parse the read of a parameter on a device +proc ::scobj::knauer_pump::read_status {tc_root} { + set catch_status [ catch { + debug_log ${tc_root} 1 "read_status tc_root=${tc_root} sct=[sct] result=[sct result]" + if { [hpropexists [sct] geterror] } { + hdelprop [sct] geterror + } + set data [sct result] + set nextState "idle" + if {[string equal -nocase -length 7 ${data} "ASCERR:"]} { + # the protocol driver has reported an error + sct geterror "${data}" + error "[sct geterror]" + } +# read_status hook code starts + set dlist [split [lindex [split ${data} ":"] 1] ","] + sct real_data "[join [lrange ${dlist} 0 end] ,]" + set data "Hidden in real_data property" +# read_status hook code ends + if { [hpropexists [sct] geterror] } { + debug_log ${tc_root} 9 "[sct] error: [sct geterror]" + error "[sct geterror]" + } + if { ${data} != [sct oldval] } { + debug_log ${tc_root} 1 "[sct] changed to new:${data}, from old:[sct oldval]" + sct oldval ${data} + sct update ${data} + sct utime readtime + } + return ${nextState} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +# function to write a parameter value on a device +proc ::scobj::knauer_pump::setValue {tc_root nextState cmd_str} { + set catch_status [ catch { + debug_log ${tc_root} 1 "setValue tc_root=${tc_root} sct=[sct] cmd=${cmd_str}" + if { [hpropexists [sct] geterror] } { + hdelprop [sct] geterror + } + set par [sct target] + set cmd "${cmd_str}${par}" +# setValue hook code goes here + if { [hpropexists [sct] driving] } { + if { [hpropexists [sct] writestatus] && [sct writestatus] == "start" } { + sct driving 1 + } + } + debug_log ${tc_root} 1 "setValue sct send ${cmd}" + if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} { + sct send "${cmd}" + } + return ${nextState} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +# function to request the read of a parameter on a device +proc ::scobj::knauer_pump::volume_checkpumping {tc_root nextState cmd_str} { + set catch_status [ catch { + debug_log ${tc_root} 1 "volume_checkpumping tc_root=${tc_root} sct=[sct] cmd=${cmd_str}" + if { [hpropexists [sct] geterror] } { + hdelprop [sct] geterror + } + set cmd "${cmd_str}" +# volume_checkpumping hook code starts + set cmd "@@NOSEND@@" + set nextState idle + if { [hpropexists [sct] pumping] && [sct pumping] } { + if { [hpropexists [sct] driving] && [sct driving] } { + volume_checkstatus "${tc_root}" + } + set sp "[sct target]" + set pv "[hval ${tc_root}/[sct driveable]]" + if { (${sp} - ${pv}) <= [sct tolerance] } { + set flow 0 + set ratios [hval ${tc_root}/ratios/setpoint] + set ratios [join [split ${ratios} /] ,] + set cmd "RAMP:0,${flow},${ratios},0,0,0,0,0,0,0,0,2" + set nextState noResponse + sct pumping 0 + } + } +# volume_checkpumping hook code ends + if { [hpropexists [sct] geterror] } { + debug_log ${tc_root} 9 "[sct] error: [sct geterror]" + error "[sct geterror]" + } + debug_log ${tc_root} 1 "volume_checkpumping sct send ${cmd}" + if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} { + sct send "${cmd}" + } + return ${nextState} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +# checkstatus function for driveable interface +proc ::scobj::knauer_pump::volume_checkstatus {tc_root} { + set catch_status [ catch { +# volume_checkstatus hook code goes here + if {[sct driving]} { + set sp "[sct target]" + set pv "[hval ${tc_root}/[sct driveable]]" + if { abs(${pv} - ${sp}) <= [sct tolerance] } { + if { [hpropexists [sct] settle_time] } { + if { [hpropexists [sct] settle_time_start] } { + if { [sct utime] - [sct settle_time_start] >= [sct settle_time]} { + sct driving 0 + return "idle" + } + return "busy" + } else { + sct utime settle_time_start + return "busy" + } + } + sct driving 0 + return "idle" + } + if { [hpropexists [sct] settle_time_start] } { + hdelprop [sct] settle_time_start + } + return "busy" + } else { + return "idle" + } + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +# function to request the read of a parameter on a device +proc ::scobj::knauer_pump::volume_fetch {tc_root nextState cmd_str} { + set catch_status [ catch { + debug_log ${tc_root} 1 "volume_fetch tc_root=${tc_root} sct=[sct] cmd=${cmd_str}" + if { [hpropexists [sct] geterror] } { + hdelprop [sct] geterror + } + set cmd "${cmd_str}" +# volume_fetch hook code starts + set data [hgetpropval ${tc_root}/dummy/glp real_data] + set dlist [split ${data} ","] + if { [llength ${dlist}] > 11 } { + set pump_volm [lindex ${dlist} 10] + set pump_voln [lindex ${dlist} 11] + set volume [expr {${pump_volm} + 0.000001 * ${pump_voln}}] + } else { + set volume 0.0 + } + sct raw_volume ${volume} + if { [hpropexists [sct] base_volume] } { + set volume [expr {${volume} - [sct base_volume]}] + } else { + sct base_volume [sct raw_volume] + } + sct result ${volume} + set cmd "@@NOSEND@@" +# volume_fetch hook code ends + if { [hpropexists [sct] geterror] } { + debug_log ${tc_root} 9 "[sct] error: [sct geterror]" + error "[sct geterror]" + } + debug_log ${tc_root} 1 "volume_fetch sct send ${cmd}" + if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} { + sct send "${cmd}" + } + return ${nextState} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +# halt function for driveable interface +proc ::scobj::knauer_pump::volume_halt {tc_root} { + set catch_status [ catch { + debug_log ${tc_root} 1 "volume_halt tc_root=${tc_root} sct=[sct] driving=[sct driving]" + ### TODO hset [sct] [hval [sct]] +# volume_halt hook code starts + set flow 0 + set ratios [hval ${tc_root}/ratios/setpoint] + set ratios [join [split ${ratios} /] ,] + set cmd "RAMP:0,${flow},${ratios},0,0,0,0,0,0,0,0,2" + sct send ${cmd} +# volume_halt hook code ends + sct driving 0 + return "idle" + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +# function to write a parameter value on a device +proc ::scobj::knauer_pump::volume_write {tc_root nextState cmd_str} { + set catch_status [ catch { + debug_log ${tc_root} 1 "volume_write tc_root=${tc_root} sct=[sct] cmd=${cmd_str}" + if { [hpropexists [sct] geterror] } { + hdelprop [sct] geterror + } + set par [sct target] + set cmd "${cmd_str}${par}" +# volume_write hook code starts + hsetprop ${tc_root}/[sct driveable] base_volume [hgetpropval ${tc_root}/[sct driveable] raw_volume] + hset ${tc_root}/[sct driveable] 0.0 + set flow [expr {int(1000.0 * [hval ${tc_root}/flow/setpoint])}] + set ratios [hval ${tc_root}/ratios/setpoint] + set ratios [join [split ${ratios} /] ,] + set cmd "RAMP:0,${flow},${ratios},0,0,0,0,0,0,0,0,3" + sct pumping 1 +# volume_write hook code ends + if { [hpropexists [sct] geterror] } { + debug_log ${tc_root} 9 "[sct] error: [sct geterror]" + error "[sct geterror]" + } + if { [hpropexists [sct] driving] } { + if { [hpropexists [sct] writestatus] && [sct writestatus] == "start" } { + sct driving 1 + } + } + debug_log ${tc_root} 1 "volume_write sct send ${cmd}" + if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} { + sct send "${cmd}" + } + return ${nextState} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +proc ::scobj::knauer_pump::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port } { + ::scobj::knauer_pump::sics_log 9 "::scobj::knauer_pump::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" + set ns "[namespace current]" + set catch_status [ catch { + + MakeSICSObj ${name} SCT_OBJECT + + sicslist setatt ${name} klass ${device_class} + sicslist setatt ${name} long_name ${name} + + set scobj_hpath /sics/${name} + + hfactory ${scobj_hpath}/dummy plain spy none + hsetprop ${scobj_hpath}/dummy data "false" + hsetprop ${scobj_hpath}/dummy klass "@none" + hsetprop ${scobj_hpath}/dummy type "part" + + hfactory ${scobj_hpath}/dummy/glp plain user text + hsetprop ${scobj_hpath}/dummy/glp read ${ns}::getValue ${scobj_hpath} read_glp {GLP?} + hsetprop ${scobj_hpath}/dummy/glp read_glp ${ns}::read_glp ${scobj_hpath} + hsetprop ${scobj_hpath}/dummy/glp control false + hsetprop ${scobj_hpath}/dummy/glp data false + hsetprop ${scobj_hpath}/dummy/glp mutable true + hsetprop ${scobj_hpath}/dummy/glp nxsave false + hsetprop ${scobj_hpath}/dummy/glp oldval UNKNOWN + hsetprop ${scobj_hpath}/dummy/glp sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/dummy/glp type "part" + hsetprop ${scobj_hpath}/dummy/glp nxalias "${name}_dummy_glp" + + hfactory ${scobj_hpath}/dummy/status plain user text + hsetprop ${scobj_hpath}/dummy/status read ${ns}::getValue ${scobj_hpath} read_status {STATUS?} + hsetprop ${scobj_hpath}/dummy/status read_status ${ns}::read_status ${scobj_hpath} + hsetprop ${scobj_hpath}/dummy/status control false + hsetprop ${scobj_hpath}/dummy/status data false + hsetprop ${scobj_hpath}/dummy/status mutable true + hsetprop ${scobj_hpath}/dummy/status nxsave false + hsetprop ${scobj_hpath}/dummy/status oldval UNKNOWN + hsetprop ${scobj_hpath}/dummy/status sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/dummy/status type "part" + hsetprop ${scobj_hpath}/dummy/status nxalias "${name}_dummy_status" + + if {[string equal -nocase "${simulation_flag}" "false"]} { + ${sct_controller} poll ${scobj_hpath}/dummy/glp 1 + ${sct_controller} poll ${scobj_hpath}/dummy/status 1 + } else { + ::scobj::knauer_pump::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for knauer_pump" + } + + hfactory ${scobj_hpath}/flow plain spy none + hsetprop ${scobj_hpath}/flow data "true" + hsetprop ${scobj_hpath}/flow klass "@none" + hsetprop ${scobj_hpath}/flow type "part" + + hfactory ${scobj_hpath}/flow/sensor plain user float + hsetprop ${scobj_hpath}/flow/sensor read ${ns}::flow_fetch ${scobj_hpath} rdValue { } + hsetprop ${scobj_hpath}/flow/sensor rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/flow/sensor control true + hsetprop ${scobj_hpath}/flow/sensor data true + hsetprop ${scobj_hpath}/flow/sensor mutable true + hsetprop ${scobj_hpath}/flow/sensor nxsave true + hsetprop ${scobj_hpath}/flow/sensor oldval 0.0 + hsetprop ${scobj_hpath}/flow/sensor klass "parameter" + hsetprop ${scobj_hpath}/flow/sensor sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/flow/sensor type "part" + hsetprop ${scobj_hpath}/flow/sensor units "mL/min" + hsetprop ${scobj_hpath}/flow/sensor nxalias "${name}_flow_sensor" + + hfactory ${scobj_hpath}/flow/setpoint plain user float + hsetprop ${scobj_hpath}/flow/setpoint write ${ns}::flow_write ${scobj_hpath} noResponse { } + hsetprop ${scobj_hpath}/flow/setpoint noResponse ${ns}::noResponse ${scobj_hpath} + hsetprop ${scobj_hpath}/flow/setpoint check ${ns}::checkrange ${scobj_hpath} + hsetprop ${scobj_hpath}/flow/setpoint control true + hsetprop ${scobj_hpath}/flow/setpoint data true + hsetprop ${scobj_hpath}/flow/setpoint mutable true + hsetprop ${scobj_hpath}/flow/setpoint nxsave true + hsetprop ${scobj_hpath}/flow/setpoint lowerlimit 0 + hsetprop ${scobj_hpath}/flow/setpoint upperlimit 10 + hsetprop ${scobj_hpath}/flow/setpoint oldval 0.0 + hsetprop ${scobj_hpath}/flow/setpoint klass "parameter" + hsetprop ${scobj_hpath}/flow/setpoint sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/flow/setpoint type "part" + hsetprop ${scobj_hpath}/flow/setpoint units "mL/min" + hsetprop ${scobj_hpath}/flow/setpoint nxalias "${name}_flow_setpoint" + + if {[string equal -nocase "${simulation_flag}" "false"]} { + ${sct_controller} poll ${scobj_hpath}/flow/sensor 1 + ${sct_controller} write ${scobj_hpath}/flow/setpoint + } else { + ::scobj::knauer_pump::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for knauer_pump" + } + + hfactory ${scobj_hpath}/glp plain spy none + hsetprop ${scobj_hpath}/glp data "true" + hsetprop ${scobj_hpath}/glp klass "@none" + hsetprop ${scobj_hpath}/glp type "part" + + hfactory ${scobj_hpath}/glp/board_time plain user text + hsetprop ${scobj_hpath}/glp/board_time read ${ns}::fetch_from_glp ${scobj_hpath} rdValue {0} + hsetprop ${scobj_hpath}/glp/board_time rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/glp/board_time control true + hsetprop ${scobj_hpath}/glp/board_time data true + hsetprop ${scobj_hpath}/glp/board_time mutable true + hsetprop ${scobj_hpath}/glp/board_time nxsave true + hsetprop ${scobj_hpath}/glp/board_time oldval UNKNOWN + hsetprop ${scobj_hpath}/glp/board_time klass "parameter" + hsetprop ${scobj_hpath}/glp/board_time sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/glp/board_time type "part" + hsetprop ${scobj_hpath}/glp/board_time nxalias "${name}_glp_board_time" + + hfactory ${scobj_hpath}/glp/head_count plain user text + hsetprop ${scobj_hpath}/glp/head_count read ${ns}::fetch_from_glp ${scobj_hpath} rdValue {3} + hsetprop ${scobj_hpath}/glp/head_count rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/glp/head_count control true + hsetprop ${scobj_hpath}/glp/head_count data true + hsetprop ${scobj_hpath}/glp/head_count mutable true + hsetprop ${scobj_hpath}/glp/head_count nxsave true + hsetprop ${scobj_hpath}/glp/head_count oldval UNKNOWN + hsetprop ${scobj_hpath}/glp/head_count klass "parameter" + hsetprop ${scobj_hpath}/glp/head_count sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/glp/head_count type "part" + hsetprop ${scobj_hpath}/glp/head_count nxalias "${name}_glp_head_count" + + hfactory ${scobj_hpath}/glp/head_pwrhi plain user text + hsetprop ${scobj_hpath}/glp/head_pwrhi read ${ns}::fetch_from_glp ${scobj_hpath} rdValue {7} + hsetprop ${scobj_hpath}/glp/head_pwrhi rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/glp/head_pwrhi control true + hsetprop ${scobj_hpath}/glp/head_pwrhi data true + hsetprop ${scobj_hpath}/glp/head_pwrhi mutable true + hsetprop ${scobj_hpath}/glp/head_pwrhi nxsave true + hsetprop ${scobj_hpath}/glp/head_pwrhi oldval UNKNOWN + hsetprop ${scobj_hpath}/glp/head_pwrhi klass "parameter" + hsetprop ${scobj_hpath}/glp/head_pwrhi sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/glp/head_pwrhi type "part" + hsetprop ${scobj_hpath}/glp/head_pwrhi nxalias "${name}_glp_head_pwrhi" + + hfactory ${scobj_hpath}/glp/head_pwrlo plain user text + hsetprop ${scobj_hpath}/glp/head_pwrlo read ${ns}::fetch_from_glp ${scobj_hpath} rdValue {8} + hsetprop ${scobj_hpath}/glp/head_pwrlo rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/glp/head_pwrlo control true + hsetprop ${scobj_hpath}/glp/head_pwrlo data true + hsetprop ${scobj_hpath}/glp/head_pwrlo mutable true + hsetprop ${scobj_hpath}/glp/head_pwrlo nxsave true + hsetprop ${scobj_hpath}/glp/head_pwrlo oldval UNKNOWN + hsetprop ${scobj_hpath}/glp/head_pwrlo klass "parameter" + hsetprop ${scobj_hpath}/glp/head_pwrlo sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/glp/head_pwrlo type "part" + hsetprop ${scobj_hpath}/glp/head_pwrlo nxalias "${name}_glp_head_pwrlo" + + hfactory ${scobj_hpath}/glp/head_time plain user text + hsetprop ${scobj_hpath}/glp/head_time read ${ns}::fetch_from_glp ${scobj_hpath} rdValue {4} + hsetprop ${scobj_hpath}/glp/head_time rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/glp/head_time control true + hsetprop ${scobj_hpath}/glp/head_time data true + hsetprop ${scobj_hpath}/glp/head_time mutable true + hsetprop ${scobj_hpath}/glp/head_time nxsave true + hsetprop ${scobj_hpath}/glp/head_time oldval UNKNOWN + hsetprop ${scobj_hpath}/glp/head_time klass "parameter" + hsetprop ${scobj_hpath}/glp/head_time sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/glp/head_time type "part" + hsetprop ${scobj_hpath}/glp/head_time nxalias "${name}_glp_head_time" + + hfactory ${scobj_hpath}/glp/head_volm plain user text + hsetprop ${scobj_hpath}/glp/head_volm read ${ns}::fetch_from_glp ${scobj_hpath} rdValue {5} + hsetprop ${scobj_hpath}/glp/head_volm rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/glp/head_volm control true + hsetprop ${scobj_hpath}/glp/head_volm data true + hsetprop ${scobj_hpath}/glp/head_volm mutable true + hsetprop ${scobj_hpath}/glp/head_volm nxsave true + hsetprop ${scobj_hpath}/glp/head_volm oldval UNKNOWN + hsetprop ${scobj_hpath}/glp/head_volm klass "parameter" + hsetprop ${scobj_hpath}/glp/head_volm sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/glp/head_volm type "part" + hsetprop ${scobj_hpath}/glp/head_volm nxalias "${name}_glp_head_volm" + + hfactory ${scobj_hpath}/glp/head_voln plain user text + hsetprop ${scobj_hpath}/glp/head_voln read ${ns}::fetch_from_glp ${scobj_hpath} rdValue {6} + hsetprop ${scobj_hpath}/glp/head_voln rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/glp/head_voln control true + hsetprop ${scobj_hpath}/glp/head_voln data true + hsetprop ${scobj_hpath}/glp/head_voln mutable true + hsetprop ${scobj_hpath}/glp/head_voln nxsave true + hsetprop ${scobj_hpath}/glp/head_voln oldval UNKNOWN + hsetprop ${scobj_hpath}/glp/head_voln klass "parameter" + hsetprop ${scobj_hpath}/glp/head_voln sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/glp/head_voln type "part" + hsetprop ${scobj_hpath}/glp/head_voln nxalias "${name}_glp_head_voln" + + hfactory ${scobj_hpath}/glp/motor_time plain user text + hsetprop ${scobj_hpath}/glp/motor_time read ${ns}::fetch_from_glp ${scobj_hpath} rdValue {1} + hsetprop ${scobj_hpath}/glp/motor_time rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/glp/motor_time control true + hsetprop ${scobj_hpath}/glp/motor_time data true + hsetprop ${scobj_hpath}/glp/motor_time mutable true + hsetprop ${scobj_hpath}/glp/motor_time nxsave true + hsetprop ${scobj_hpath}/glp/motor_time oldval UNKNOWN + hsetprop ${scobj_hpath}/glp/motor_time klass "parameter" + hsetprop ${scobj_hpath}/glp/motor_time sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/glp/motor_time type "part" + hsetprop ${scobj_hpath}/glp/motor_time nxalias "${name}_glp_motor_time" + + hfactory ${scobj_hpath}/glp/pump_pwrhi plain user text + hsetprop ${scobj_hpath}/glp/pump_pwrhi read ${ns}::fetch_from_glp ${scobj_hpath} rdValue {12} + hsetprop ${scobj_hpath}/glp/pump_pwrhi rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/glp/pump_pwrhi control true + hsetprop ${scobj_hpath}/glp/pump_pwrhi data true + hsetprop ${scobj_hpath}/glp/pump_pwrhi mutable true + hsetprop ${scobj_hpath}/glp/pump_pwrhi nxsave true + hsetprop ${scobj_hpath}/glp/pump_pwrhi oldval UNKNOWN + hsetprop ${scobj_hpath}/glp/pump_pwrhi klass "parameter" + hsetprop ${scobj_hpath}/glp/pump_pwrhi sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/glp/pump_pwrhi type "part" + hsetprop ${scobj_hpath}/glp/pump_pwrhi nxalias "${name}_glp_pump_pwrhi" + + hfactory ${scobj_hpath}/glp/pump_pwrlo plain user text + hsetprop ${scobj_hpath}/glp/pump_pwrlo read ${ns}::fetch_from_glp ${scobj_hpath} rdValue {13} + hsetprop ${scobj_hpath}/glp/pump_pwrlo rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/glp/pump_pwrlo control true + hsetprop ${scobj_hpath}/glp/pump_pwrlo data true + hsetprop ${scobj_hpath}/glp/pump_pwrlo mutable true + hsetprop ${scobj_hpath}/glp/pump_pwrlo nxsave true + hsetprop ${scobj_hpath}/glp/pump_pwrlo oldval UNKNOWN + hsetprop ${scobj_hpath}/glp/pump_pwrlo klass "parameter" + hsetprop ${scobj_hpath}/glp/pump_pwrlo sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/glp/pump_pwrlo type "part" + hsetprop ${scobj_hpath}/glp/pump_pwrlo nxalias "${name}_glp_pump_pwrlo" + + hfactory ${scobj_hpath}/glp/pump_revs plain user text + hsetprop ${scobj_hpath}/glp/pump_revs read ${ns}::fetch_from_glp ${scobj_hpath} rdValue {9} + hsetprop ${scobj_hpath}/glp/pump_revs rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/glp/pump_revs control true + hsetprop ${scobj_hpath}/glp/pump_revs data true + hsetprop ${scobj_hpath}/glp/pump_revs mutable true + hsetprop ${scobj_hpath}/glp/pump_revs nxsave true + hsetprop ${scobj_hpath}/glp/pump_revs oldval UNKNOWN + hsetprop ${scobj_hpath}/glp/pump_revs klass "parameter" + hsetprop ${scobj_hpath}/glp/pump_revs sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/glp/pump_revs type "part" + hsetprop ${scobj_hpath}/glp/pump_revs nxalias "${name}_glp_pump_revs" + + hfactory ${scobj_hpath}/glp/pump_volm plain user text + hsetprop ${scobj_hpath}/glp/pump_volm read ${ns}::fetch_from_glp ${scobj_hpath} rdValue {10} + hsetprop ${scobj_hpath}/glp/pump_volm rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/glp/pump_volm control true + hsetprop ${scobj_hpath}/glp/pump_volm data true + hsetprop ${scobj_hpath}/glp/pump_volm mutable true + hsetprop ${scobj_hpath}/glp/pump_volm nxsave true + hsetprop ${scobj_hpath}/glp/pump_volm oldval UNKNOWN + hsetprop ${scobj_hpath}/glp/pump_volm klass "parameter" + hsetprop ${scobj_hpath}/glp/pump_volm sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/glp/pump_volm type "part" + hsetprop ${scobj_hpath}/glp/pump_volm nxalias "${name}_glp_pump_volm" + + hfactory ${scobj_hpath}/glp/pump_voln plain user text + hsetprop ${scobj_hpath}/glp/pump_voln read ${ns}::fetch_from_glp ${scobj_hpath} rdValue {11} + hsetprop ${scobj_hpath}/glp/pump_voln rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/glp/pump_voln control true + hsetprop ${scobj_hpath}/glp/pump_voln data true + hsetprop ${scobj_hpath}/glp/pump_voln mutable true + hsetprop ${scobj_hpath}/glp/pump_voln nxsave true + hsetprop ${scobj_hpath}/glp/pump_voln oldval UNKNOWN + hsetprop ${scobj_hpath}/glp/pump_voln klass "parameter" + hsetprop ${scobj_hpath}/glp/pump_voln sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/glp/pump_voln type "part" + hsetprop ${scobj_hpath}/glp/pump_voln nxalias "${name}_glp_pump_voln" + + if {[string equal -nocase "${simulation_flag}" "false"]} { + ${sct_controller} poll ${scobj_hpath}/glp/board_time 1 + ${sct_controller} poll ${scobj_hpath}/glp/head_count 1 + ${sct_controller} poll ${scobj_hpath}/glp/head_pwrhi 1 + ${sct_controller} poll ${scobj_hpath}/glp/head_pwrlo 1 + ${sct_controller} poll ${scobj_hpath}/glp/head_time 1 + ${sct_controller} poll ${scobj_hpath}/glp/head_volm 1 + ${sct_controller} poll ${scobj_hpath}/glp/head_voln 1 + ${sct_controller} poll ${scobj_hpath}/glp/motor_time 1 + ${sct_controller} poll ${scobj_hpath}/glp/pump_pwrhi 1 + ${sct_controller} poll ${scobj_hpath}/glp/pump_pwrlo 1 + ${sct_controller} poll ${scobj_hpath}/glp/pump_revs 1 + ${sct_controller} poll ${scobj_hpath}/glp/pump_volm 1 + ${sct_controller} poll ${scobj_hpath}/glp/pump_voln 1 + } else { + ::scobj::knauer_pump::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for knauer_pump" + } + + hfactory ${scobj_hpath}/prog plain spy none + hsetprop ${scobj_hpath}/prog data "true" + hsetprop ${scobj_hpath}/prog klass "@none" + hsetprop ${scobj_hpath}/prog type "part" + + hfactory ${scobj_hpath}/prog/line_01 plain user text + hsetprop ${scobj_hpath}/prog/line_01 read ${ns}::getValue ${scobj_hpath} rdValue {TT_GET:1,1} + hsetprop ${scobj_hpath}/prog/line_01 rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/prog/line_01 control true + hsetprop ${scobj_hpath}/prog/line_01 data true + hsetprop ${scobj_hpath}/prog/line_01 mutable true + hsetprop ${scobj_hpath}/prog/line_01 nxsave true + hsetprop ${scobj_hpath}/prog/line_01 oldval UNKNOWN + hsetprop ${scobj_hpath}/prog/line_01 klass "parameter" + hsetprop ${scobj_hpath}/prog/line_01 sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/prog/line_01 type "part" + hsetprop ${scobj_hpath}/prog/line_01 nxalias "${name}_prog_line_01" + + hfactory ${scobj_hpath}/prog/line_02 plain user text + hsetprop ${scobj_hpath}/prog/line_02 read ${ns}::getValue ${scobj_hpath} rdValue {TT_GET:1,2} + hsetprop ${scobj_hpath}/prog/line_02 rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/prog/line_02 control true + hsetprop ${scobj_hpath}/prog/line_02 data true + hsetprop ${scobj_hpath}/prog/line_02 mutable true + hsetprop ${scobj_hpath}/prog/line_02 nxsave true + hsetprop ${scobj_hpath}/prog/line_02 oldval UNKNOWN + hsetprop ${scobj_hpath}/prog/line_02 klass "parameter" + hsetprop ${scobj_hpath}/prog/line_02 sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/prog/line_02 type "part" + hsetprop ${scobj_hpath}/prog/line_02 nxalias "${name}_prog_line_02" + + hfactory ${scobj_hpath}/prog/line_03 plain user text + hsetprop ${scobj_hpath}/prog/line_03 read ${ns}::getValue ${scobj_hpath} rdValue {TT_GET:1,3} + hsetprop ${scobj_hpath}/prog/line_03 rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/prog/line_03 control true + hsetprop ${scobj_hpath}/prog/line_03 data true + hsetprop ${scobj_hpath}/prog/line_03 mutable true + hsetprop ${scobj_hpath}/prog/line_03 nxsave true + hsetprop ${scobj_hpath}/prog/line_03 oldval UNKNOWN + hsetprop ${scobj_hpath}/prog/line_03 klass "parameter" + hsetprop ${scobj_hpath}/prog/line_03 sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/prog/line_03 type "part" + hsetprop ${scobj_hpath}/prog/line_03 nxalias "${name}_prog_line_03" + + hfactory ${scobj_hpath}/prog/line_04 plain user text + hsetprop ${scobj_hpath}/prog/line_04 read ${ns}::getValue ${scobj_hpath} rdValue {TT_GET:1,4} + hsetprop ${scobj_hpath}/prog/line_04 rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/prog/line_04 control true + hsetprop ${scobj_hpath}/prog/line_04 data true + hsetprop ${scobj_hpath}/prog/line_04 mutable true + hsetprop ${scobj_hpath}/prog/line_04 nxsave true + hsetprop ${scobj_hpath}/prog/line_04 oldval UNKNOWN + hsetprop ${scobj_hpath}/prog/line_04 klass "parameter" + hsetprop ${scobj_hpath}/prog/line_04 sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/prog/line_04 type "part" + hsetprop ${scobj_hpath}/prog/line_04 nxalias "${name}_prog_line_04" + + hfactory ${scobj_hpath}/prog/line_05 plain user text + hsetprop ${scobj_hpath}/prog/line_05 read ${ns}::getValue ${scobj_hpath} rdValue {TT_GET:1,5} + hsetprop ${scobj_hpath}/prog/line_05 rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/prog/line_05 control true + hsetprop ${scobj_hpath}/prog/line_05 data true + hsetprop ${scobj_hpath}/prog/line_05 mutable true + hsetprop ${scobj_hpath}/prog/line_05 nxsave true + hsetprop ${scobj_hpath}/prog/line_05 oldval UNKNOWN + hsetprop ${scobj_hpath}/prog/line_05 klass "parameter" + hsetprop ${scobj_hpath}/prog/line_05 sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/prog/line_05 type "part" + hsetprop ${scobj_hpath}/prog/line_05 nxalias "${name}_prog_line_05" + + if {[string equal -nocase "${simulation_flag}" "false"]} { + ${sct_controller} poll ${scobj_hpath}/prog/line_01 30 + ${sct_controller} poll ${scobj_hpath}/prog/line_02 30 + ${sct_controller} poll ${scobj_hpath}/prog/line_03 30 + ${sct_controller} poll ${scobj_hpath}/prog/line_04 30 + ${sct_controller} poll ${scobj_hpath}/prog/line_05 30 + } else { + ::scobj::knauer_pump::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for knauer_pump" + } + + hfactory ${scobj_hpath}/ratios plain spy none + hsetprop ${scobj_hpath}/ratios data "true" + hsetprop ${scobj_hpath}/ratios klass "@none" + hsetprop ${scobj_hpath}/ratios type "part" + + hfactory ${scobj_hpath}/ratios/sensor plain user text + hsetprop ${scobj_hpath}/ratios/sensor read ${ns}::ratios_fetch ${scobj_hpath} rdValue { } + hsetprop ${scobj_hpath}/ratios/sensor rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/ratios/sensor control true + hsetprop ${scobj_hpath}/ratios/sensor data true + hsetprop ${scobj_hpath}/ratios/sensor mutable true + hsetprop ${scobj_hpath}/ratios/sensor nxsave true + hsetprop ${scobj_hpath}/ratios/sensor oldval UNKNOWN + hsetprop ${scobj_hpath}/ratios/sensor klass "parameter" + hsetprop ${scobj_hpath}/ratios/sensor sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/ratios/sensor type "part" + hsetprop ${scobj_hpath}/ratios/sensor units "percent" + hsetprop ${scobj_hpath}/ratios/sensor nxalias "${name}_ratios_sensor" + + hfactory ${scobj_hpath}/ratios/setpoint plain user text + hsetprop ${scobj_hpath}/ratios/setpoint write ${ns}::ratios_write ${scobj_hpath} noResponse { } + hsetprop ${scobj_hpath}/ratios/setpoint noResponse ${ns}::noResponse ${scobj_hpath} + hsetprop ${scobj_hpath}/ratios/setpoint check ${ns}::ratios_check ${scobj_hpath} + hsetprop ${scobj_hpath}/ratios/setpoint control true + hsetprop ${scobj_hpath}/ratios/setpoint data true + hsetprop ${scobj_hpath}/ratios/setpoint mutable true + hsetprop ${scobj_hpath}/ratios/setpoint nxsave true + hsetprop ${scobj_hpath}/ratios/setpoint oldval UNKNOWN + hsetprop ${scobj_hpath}/ratios/setpoint klass "parameter" + hsetprop ${scobj_hpath}/ratios/setpoint sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/ratios/setpoint type "part" + hsetprop ${scobj_hpath}/ratios/setpoint units "percent" + hsetprop ${scobj_hpath}/ratios/setpoint nxalias "${name}_ratios_setpoint" + + if {[string equal -nocase "${simulation_flag}" "false"]} { + ${sct_controller} poll ${scobj_hpath}/ratios/sensor 1 + ${sct_controller} write ${scobj_hpath}/ratios/setpoint + } else { + ::scobj::knauer_pump::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for knauer_pump" + } + + hfactory ${scobj_hpath}/status plain spy none + hsetprop ${scobj_hpath}/status data "true" + hsetprop ${scobj_hpath}/status klass "@none" + hsetprop ${scobj_hpath}/status type "part" + + hfactory ${scobj_hpath}/status/cur_error plain user text + hsetprop ${scobj_hpath}/status/cur_error read ${ns}::fetch_from_status ${scobj_hpath} rdValue {2} + hsetprop ${scobj_hpath}/status/cur_error rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/status/cur_error control true + hsetprop ${scobj_hpath}/status/cur_error data true + hsetprop ${scobj_hpath}/status/cur_error mutable true + hsetprop ${scobj_hpath}/status/cur_error nxsave true + hsetprop ${scobj_hpath}/status/cur_error oldval UNKNOWN + hsetprop ${scobj_hpath}/status/cur_error klass "parameter" + hsetprop ${scobj_hpath}/status/cur_error sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/status/cur_error type "part" + hsetprop ${scobj_hpath}/status/cur_error nxalias "${name}_status_cur_error" + + hfactory ${scobj_hpath}/status/cur_pres plain user text + hsetprop ${scobj_hpath}/status/cur_pres read ${ns}::fetch_from_status ${scobj_hpath} rdValue {17} + hsetprop ${scobj_hpath}/status/cur_pres rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/status/cur_pres control true + hsetprop ${scobj_hpath}/status/cur_pres data true + hsetprop ${scobj_hpath}/status/cur_pres mutable true + hsetprop ${scobj_hpath}/status/cur_pres nxsave true + hsetprop ${scobj_hpath}/status/cur_pres oldval UNKNOWN + hsetprop ${scobj_hpath}/status/cur_pres klass "parameter" + hsetprop ${scobj_hpath}/status/cur_pres sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/status/cur_pres type "part" + hsetprop ${scobj_hpath}/status/cur_pres nxalias "${name}_status_cur_pres" + + hfactory ${scobj_hpath}/status/cur_run_time plain user text + hsetprop ${scobj_hpath}/status/cur_run_time read ${ns}::fetch_from_status ${scobj_hpath} rdValue {3} + hsetprop ${scobj_hpath}/status/cur_run_time rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/status/cur_run_time control true + hsetprop ${scobj_hpath}/status/cur_run_time data true + hsetprop ${scobj_hpath}/status/cur_run_time mutable true + hsetprop ${scobj_hpath}/status/cur_run_time nxsave true + hsetprop ${scobj_hpath}/status/cur_run_time oldval UNKNOWN + hsetprop ${scobj_hpath}/status/cur_run_time klass "parameter" + hsetprop ${scobj_hpath}/status/cur_run_time sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/status/cur_run_time type "part" + hsetprop ${scobj_hpath}/status/cur_run_time nxalias "${name}_status_cur_run_time" + + hfactory ${scobj_hpath}/status/error_in plain user text + hsetprop ${scobj_hpath}/status/error_in read ${ns}::fetch_from_status ${scobj_hpath} rdValue {19} + hsetprop ${scobj_hpath}/status/error_in rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/status/error_in control true + hsetprop ${scobj_hpath}/status/error_in data true + hsetprop ${scobj_hpath}/status/error_in mutable true + hsetprop ${scobj_hpath}/status/error_in nxsave true + hsetprop ${scobj_hpath}/status/error_in oldval UNKNOWN + hsetprop ${scobj_hpath}/status/error_in klass "parameter" + hsetprop ${scobj_hpath}/status/error_in sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/status/error_in type "part" + hsetprop ${scobj_hpath}/status/error_in nxalias "${name}_status_error_in" + + hfactory ${scobj_hpath}/status/evt_0 plain user text + hsetprop ${scobj_hpath}/status/evt_0 read ${ns}::fetch_from_status ${scobj_hpath} rdValue {9} + hsetprop ${scobj_hpath}/status/evt_0 rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/status/evt_0 control true + hsetprop ${scobj_hpath}/status/evt_0 data true + hsetprop ${scobj_hpath}/status/evt_0 mutable true + hsetprop ${scobj_hpath}/status/evt_0 nxsave true + hsetprop ${scobj_hpath}/status/evt_0 oldval UNKNOWN + hsetprop ${scobj_hpath}/status/evt_0 klass "parameter" + hsetprop ${scobj_hpath}/status/evt_0 sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/status/evt_0 type "part" + hsetprop ${scobj_hpath}/status/evt_0 nxalias "${name}_status_evt_0" + + hfactory ${scobj_hpath}/status/evt_1 plain user text + hsetprop ${scobj_hpath}/status/evt_1 read ${ns}::fetch_from_status ${scobj_hpath} rdValue {10} + hsetprop ${scobj_hpath}/status/evt_1 rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/status/evt_1 control true + hsetprop ${scobj_hpath}/status/evt_1 data true + hsetprop ${scobj_hpath}/status/evt_1 mutable true + hsetprop ${scobj_hpath}/status/evt_1 nxsave true + hsetprop ${scobj_hpath}/status/evt_1 oldval UNKNOWN + hsetprop ${scobj_hpath}/status/evt_1 klass "parameter" + hsetprop ${scobj_hpath}/status/evt_1 sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/status/evt_1 type "part" + hsetprop ${scobj_hpath}/status/evt_1 nxalias "${name}_status_evt_1" + + hfactory ${scobj_hpath}/status/evt_2 plain user text + hsetprop ${scobj_hpath}/status/evt_2 read ${ns}::fetch_from_status ${scobj_hpath} rdValue {11} + hsetprop ${scobj_hpath}/status/evt_2 rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/status/evt_2 control true + hsetprop ${scobj_hpath}/status/evt_2 data true + hsetprop ${scobj_hpath}/status/evt_2 mutable true + hsetprop ${scobj_hpath}/status/evt_2 nxsave true + hsetprop ${scobj_hpath}/status/evt_2 oldval UNKNOWN + hsetprop ${scobj_hpath}/status/evt_2 klass "parameter" + hsetprop ${scobj_hpath}/status/evt_2 sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/status/evt_2 type "part" + hsetprop ${scobj_hpath}/status/evt_2 nxalias "${name}_status_evt_2" + + hfactory ${scobj_hpath}/status/evt_3 plain user text + hsetprop ${scobj_hpath}/status/evt_3 read ${ns}::fetch_from_status ${scobj_hpath} rdValue {12} + hsetprop ${scobj_hpath}/status/evt_3 rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/status/evt_3 control true + hsetprop ${scobj_hpath}/status/evt_3 data true + hsetprop ${scobj_hpath}/status/evt_3 mutable true + hsetprop ${scobj_hpath}/status/evt_3 nxsave true + hsetprop ${scobj_hpath}/status/evt_3 oldval UNKNOWN + hsetprop ${scobj_hpath}/status/evt_3 klass "parameter" + hsetprop ${scobj_hpath}/status/evt_3 sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/status/evt_3 type "part" + hsetprop ${scobj_hpath}/status/evt_3 nxalias "${name}_status_evt_3" + + hfactory ${scobj_hpath}/status/evt_4 plain user text + hsetprop ${scobj_hpath}/status/evt_4 read ${ns}::fetch_from_status ${scobj_hpath} rdValue {13} + hsetprop ${scobj_hpath}/status/evt_4 rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/status/evt_4 control true + hsetprop ${scobj_hpath}/status/evt_4 data true + hsetprop ${scobj_hpath}/status/evt_4 mutable true + hsetprop ${scobj_hpath}/status/evt_4 nxsave true + hsetprop ${scobj_hpath}/status/evt_4 oldval UNKNOWN + hsetprop ${scobj_hpath}/status/evt_4 klass "parameter" + hsetprop ${scobj_hpath}/status/evt_4 sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/status/evt_4 type "part" + hsetprop ${scobj_hpath}/status/evt_4 nxalias "${name}_status_evt_4" + + hfactory ${scobj_hpath}/status/evt_5 plain user text + hsetprop ${scobj_hpath}/status/evt_5 read ${ns}::fetch_from_status ${scobj_hpath} rdValue {14} + hsetprop ${scobj_hpath}/status/evt_5 rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/status/evt_5 control true + hsetprop ${scobj_hpath}/status/evt_5 data true + hsetprop ${scobj_hpath}/status/evt_5 mutable true + hsetprop ${scobj_hpath}/status/evt_5 nxsave true + hsetprop ${scobj_hpath}/status/evt_5 oldval UNKNOWN + hsetprop ${scobj_hpath}/status/evt_5 klass "parameter" + hsetprop ${scobj_hpath}/status/evt_5 sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/status/evt_5 type "part" + hsetprop ${scobj_hpath}/status/evt_5 nxalias "${name}_status_evt_5" + + hfactory ${scobj_hpath}/status/evt_6 plain user text + hsetprop ${scobj_hpath}/status/evt_6 read ${ns}::fetch_from_status ${scobj_hpath} rdValue {15} + hsetprop ${scobj_hpath}/status/evt_6 rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/status/evt_6 control true + hsetprop ${scobj_hpath}/status/evt_6 data true + hsetprop ${scobj_hpath}/status/evt_6 mutable true + hsetprop ${scobj_hpath}/status/evt_6 nxsave true + hsetprop ${scobj_hpath}/status/evt_6 oldval UNKNOWN + hsetprop ${scobj_hpath}/status/evt_6 klass "parameter" + hsetprop ${scobj_hpath}/status/evt_6 sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/status/evt_6 type "part" + hsetprop ${scobj_hpath}/status/evt_6 nxalias "${name}_status_evt_6" + + hfactory ${scobj_hpath}/status/evt_7 plain user text + hsetprop ${scobj_hpath}/status/evt_7 read ${ns}::fetch_from_status ${scobj_hpath} rdValue {16} + hsetprop ${scobj_hpath}/status/evt_7 rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/status/evt_7 control true + hsetprop ${scobj_hpath}/status/evt_7 data true + hsetprop ${scobj_hpath}/status/evt_7 mutable true + hsetprop ${scobj_hpath}/status/evt_7 nxsave true + hsetprop ${scobj_hpath}/status/evt_7 oldval UNKNOWN + hsetprop ${scobj_hpath}/status/evt_7 klass "parameter" + hsetprop ${scobj_hpath}/status/evt_7 sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/status/evt_7 type "part" + hsetprop ${scobj_hpath}/status/evt_7 nxalias "${name}_status_evt_7" + + hfactory ${scobj_hpath}/status/flow_rate plain user text + hsetprop ${scobj_hpath}/status/flow_rate read ${ns}::fetch_from_status ${scobj_hpath} rdValue {4} + hsetprop ${scobj_hpath}/status/flow_rate rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/status/flow_rate control true + hsetprop ${scobj_hpath}/status/flow_rate data true + hsetprop ${scobj_hpath}/status/flow_rate mutable true + hsetprop ${scobj_hpath}/status/flow_rate nxsave true + hsetprop ${scobj_hpath}/status/flow_rate oldval UNKNOWN + hsetprop ${scobj_hpath}/status/flow_rate klass "parameter" + hsetprop ${scobj_hpath}/status/flow_rate sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/status/flow_rate type "part" + hsetprop ${scobj_hpath}/status/flow_rate nxalias "${name}_status_flow_rate" + + hfactory ${scobj_hpath}/status/lpg_0 plain user text + hsetprop ${scobj_hpath}/status/lpg_0 read ${ns}::fetch_from_status ${scobj_hpath} rdValue {5} + hsetprop ${scobj_hpath}/status/lpg_0 rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/status/lpg_0 control true + hsetprop ${scobj_hpath}/status/lpg_0 data true + hsetprop ${scobj_hpath}/status/lpg_0 mutable true + hsetprop ${scobj_hpath}/status/lpg_0 nxsave true + hsetprop ${scobj_hpath}/status/lpg_0 oldval UNKNOWN + hsetprop ${scobj_hpath}/status/lpg_0 klass "parameter" + hsetprop ${scobj_hpath}/status/lpg_0 sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/status/lpg_0 type "part" + hsetprop ${scobj_hpath}/status/lpg_0 nxalias "${name}_status_lpg_0" + + hfactory ${scobj_hpath}/status/lpg_1 plain user text + hsetprop ${scobj_hpath}/status/lpg_1 read ${ns}::fetch_from_status ${scobj_hpath} rdValue {6} + hsetprop ${scobj_hpath}/status/lpg_1 rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/status/lpg_1 control true + hsetprop ${scobj_hpath}/status/lpg_1 data true + hsetprop ${scobj_hpath}/status/lpg_1 mutable true + hsetprop ${scobj_hpath}/status/lpg_1 nxsave true + hsetprop ${scobj_hpath}/status/lpg_1 oldval UNKNOWN + hsetprop ${scobj_hpath}/status/lpg_1 klass "parameter" + hsetprop ${scobj_hpath}/status/lpg_1 sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/status/lpg_1 type "part" + hsetprop ${scobj_hpath}/status/lpg_1 nxalias "${name}_status_lpg_1" + + hfactory ${scobj_hpath}/status/lpg_2 plain user text + hsetprop ${scobj_hpath}/status/lpg_2 read ${ns}::fetch_from_status ${scobj_hpath} rdValue {7} + hsetprop ${scobj_hpath}/status/lpg_2 rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/status/lpg_2 control true + hsetprop ${scobj_hpath}/status/lpg_2 data true + hsetprop ${scobj_hpath}/status/lpg_2 mutable true + hsetprop ${scobj_hpath}/status/lpg_2 nxsave true + hsetprop ${scobj_hpath}/status/lpg_2 oldval UNKNOWN + hsetprop ${scobj_hpath}/status/lpg_2 klass "parameter" + hsetprop ${scobj_hpath}/status/lpg_2 sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/status/lpg_2 type "part" + hsetprop ${scobj_hpath}/status/lpg_2 nxalias "${name}_status_lpg_2" + + hfactory ${scobj_hpath}/status/lpg_3 plain user text + hsetprop ${scobj_hpath}/status/lpg_3 read ${ns}::fetch_from_status ${scobj_hpath} rdValue {8} + hsetprop ${scobj_hpath}/status/lpg_3 rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/status/lpg_3 control true + hsetprop ${scobj_hpath}/status/lpg_3 data true + hsetprop ${scobj_hpath}/status/lpg_3 mutable true + hsetprop ${scobj_hpath}/status/lpg_3 nxsave true + hsetprop ${scobj_hpath}/status/lpg_3 oldval UNKNOWN + hsetprop ${scobj_hpath}/status/lpg_3 klass "parameter" + hsetprop ${scobj_hpath}/status/lpg_3 sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/status/lpg_3 type "part" + hsetprop ${scobj_hpath}/status/lpg_3 nxalias "${name}_status_lpg_3" + + hfactory ${scobj_hpath}/status/start_in plain user text + hsetprop ${scobj_hpath}/status/start_in read ${ns}::fetch_from_status ${scobj_hpath} rdValue {18} + hsetprop ${scobj_hpath}/status/start_in rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/status/start_in control true + hsetprop ${scobj_hpath}/status/start_in data true + hsetprop ${scobj_hpath}/status/start_in mutable true + hsetprop ${scobj_hpath}/status/start_in nxsave true + hsetprop ${scobj_hpath}/status/start_in oldval UNKNOWN + hsetprop ${scobj_hpath}/status/start_in klass "parameter" + hsetprop ${scobj_hpath}/status/start_in sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/status/start_in type "part" + hsetprop ${scobj_hpath}/status/start_in nxalias "${name}_status_start_in" + + hfactory ${scobj_hpath}/status/state plain user text + hsetprop ${scobj_hpath}/status/state read ${ns}::fetch_from_status ${scobj_hpath} rdValue {1} + hsetprop ${scobj_hpath}/status/state rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/status/state control true + hsetprop ${scobj_hpath}/status/state data true + hsetprop ${scobj_hpath}/status/state mutable true + hsetprop ${scobj_hpath}/status/state nxsave true + hsetprop ${scobj_hpath}/status/state oldval UNKNOWN + hsetprop ${scobj_hpath}/status/state klass "parameter" + hsetprop ${scobj_hpath}/status/state sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/status/state type "part" + hsetprop ${scobj_hpath}/status/state nxalias "${name}_status_state" + + if {[string equal -nocase "${simulation_flag}" "false"]} { + ${sct_controller} poll ${scobj_hpath}/status/cur_error 1 + ${sct_controller} poll ${scobj_hpath}/status/cur_pres 1 + ${sct_controller} poll ${scobj_hpath}/status/cur_run_time 1 + ${sct_controller} poll ${scobj_hpath}/status/error_in 1 + ${sct_controller} poll ${scobj_hpath}/status/evt_0 1 + ${sct_controller} poll ${scobj_hpath}/status/evt_1 1 + ${sct_controller} poll ${scobj_hpath}/status/evt_2 1 + ${sct_controller} poll ${scobj_hpath}/status/evt_3 1 + ${sct_controller} poll ${scobj_hpath}/status/evt_4 1 + ${sct_controller} poll ${scobj_hpath}/status/evt_5 1 + ${sct_controller} poll ${scobj_hpath}/status/evt_6 1 + ${sct_controller} poll ${scobj_hpath}/status/evt_7 1 + ${sct_controller} poll ${scobj_hpath}/status/flow_rate 1 + ${sct_controller} poll ${scobj_hpath}/status/lpg_0 1 + ${sct_controller} poll ${scobj_hpath}/status/lpg_1 1 + ${sct_controller} poll ${scobj_hpath}/status/lpg_2 1 + ${sct_controller} poll ${scobj_hpath}/status/lpg_3 1 + ${sct_controller} poll ${scobj_hpath}/status/start_in 1 + ${sct_controller} poll ${scobj_hpath}/status/state 1 + } else { + ::scobj::knauer_pump::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for knauer_pump" + } + + hfactory ${scobj_hpath}/stuff plain spy none + hsetprop ${scobj_hpath}/stuff data "true" + hsetprop ${scobj_hpath}/stuff klass "@none" + hsetprop ${scobj_hpath}/stuff type "part" + + hfactory ${scobj_hpath}/stuff/an_out plain user text + hsetprop ${scobj_hpath}/stuff/an_out read ${ns}::getValue ${scobj_hpath} rdValue {AN_OUT?} + hsetprop ${scobj_hpath}/stuff/an_out rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/stuff/an_out control true + hsetprop ${scobj_hpath}/stuff/an_out data true + hsetprop ${scobj_hpath}/stuff/an_out mutable true + hsetprop ${scobj_hpath}/stuff/an_out nxsave true + hsetprop ${scobj_hpath}/stuff/an_out oldval UNKNOWN + hsetprop ${scobj_hpath}/stuff/an_out klass "parameter" + hsetprop ${scobj_hpath}/stuff/an_out sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/stuff/an_out type "part" + hsetprop ${scobj_hpath}/stuff/an_out nxalias "${name}_stuff_an_out" + + hfactory ${scobj_hpath}/stuff/boardinfo plain user text + hsetprop ${scobj_hpath}/stuff/boardinfo read ${ns}::getValue ${scobj_hpath} rdValue {BOARDINFO?} + hsetprop ${scobj_hpath}/stuff/boardinfo rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/stuff/boardinfo control true + hsetprop ${scobj_hpath}/stuff/boardinfo data true + hsetprop ${scobj_hpath}/stuff/boardinfo mutable true + hsetprop ${scobj_hpath}/stuff/boardinfo nxsave true + hsetprop ${scobj_hpath}/stuff/boardinfo oldval UNKNOWN + hsetprop ${scobj_hpath}/stuff/boardinfo klass "parameter" + hsetprop ${scobj_hpath}/stuff/boardinfo sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/stuff/boardinfo type "part" + hsetprop ${scobj_hpath}/stuff/boardinfo nxalias "${name}_stuff_boardinfo" + + hfactory ${scobj_hpath}/stuff/config plain user text + hsetprop ${scobj_hpath}/stuff/config read ${ns}::getValue ${scobj_hpath} rdValue {CONFIG?} + hsetprop ${scobj_hpath}/stuff/config rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/stuff/config control true + hsetprop ${scobj_hpath}/stuff/config data true + hsetprop ${scobj_hpath}/stuff/config mutable true + hsetprop ${scobj_hpath}/stuff/config nxsave true + hsetprop ${scobj_hpath}/stuff/config oldval UNKNOWN + hsetprop ${scobj_hpath}/stuff/config klass "parameter" + hsetprop ${scobj_hpath}/stuff/config sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/stuff/config type "part" + hsetprop ${scobj_hpath}/stuff/config nxalias "${name}_stuff_config" + + hfactory ${scobj_hpath}/stuff/cprofinfo plain user text + hsetprop ${scobj_hpath}/stuff/cprofinfo read ${ns}::getValue ${scobj_hpath} rdValue {CPROFINFO?} + hsetprop ${scobj_hpath}/stuff/cprofinfo rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/stuff/cprofinfo control true + hsetprop ${scobj_hpath}/stuff/cprofinfo data true + hsetprop ${scobj_hpath}/stuff/cprofinfo mutable true + hsetprop ${scobj_hpath}/stuff/cprofinfo nxsave true + hsetprop ${scobj_hpath}/stuff/cprofinfo oldval UNKNOWN + hsetprop ${scobj_hpath}/stuff/cprofinfo klass "parameter" + hsetprop ${scobj_hpath}/stuff/cprofinfo sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/stuff/cprofinfo type "part" + hsetprop ${scobj_hpath}/stuff/cprofinfo nxalias "${name}_stuff_cprofinfo" + + hfactory ${scobj_hpath}/stuff/dout plain user text + hsetprop ${scobj_hpath}/stuff/dout read ${ns}::getValue ${scobj_hpath} rdValue {DOUT?} + hsetprop ${scobj_hpath}/stuff/dout rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/stuff/dout control true + hsetprop ${scobj_hpath}/stuff/dout data true + hsetprop ${scobj_hpath}/stuff/dout mutable true + hsetprop ${scobj_hpath}/stuff/dout nxsave true + hsetprop ${scobj_hpath}/stuff/dout oldval UNKNOWN + hsetprop ${scobj_hpath}/stuff/dout klass "parameter" + hsetprop ${scobj_hpath}/stuff/dout sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/stuff/dout type "part" + hsetprop ${scobj_hpath}/stuff/dout nxalias "${name}_stuff_dout" + + hfactory ${scobj_hpath}/stuff/error plain user text + hsetprop ${scobj_hpath}/stuff/error read ${ns}::getValue ${scobj_hpath} rdValue {ERROR?} + hsetprop ${scobj_hpath}/stuff/error rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/stuff/error control true + hsetprop ${scobj_hpath}/stuff/error data true + hsetprop ${scobj_hpath}/stuff/error mutable true + hsetprop ${scobj_hpath}/stuff/error nxsave true + hsetprop ${scobj_hpath}/stuff/error oldval UNKNOWN + hsetprop ${scobj_hpath}/stuff/error klass "parameter" + hsetprop ${scobj_hpath}/stuff/error sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/stuff/error type "part" + hsetprop ${scobj_hpath}/stuff/error nxalias "${name}_stuff_error" + + hfactory ${scobj_hpath}/stuff/errors plain user text + hsetprop ${scobj_hpath}/stuff/errors read ${ns}::getValue ${scobj_hpath} rdValue {ERRORS?} + hsetprop ${scobj_hpath}/stuff/errors rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/stuff/errors control true + hsetprop ${scobj_hpath}/stuff/errors data true + hsetprop ${scobj_hpath}/stuff/errors mutable true + hsetprop ${scobj_hpath}/stuff/errors nxsave true + hsetprop ${scobj_hpath}/stuff/errors oldval UNKNOWN + hsetprop ${scobj_hpath}/stuff/errors klass "parameter" + hsetprop ${scobj_hpath}/stuff/errors sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/stuff/errors type "part" + hsetprop ${scobj_hpath}/stuff/errors nxalias "${name}_stuff_errors" + + hfactory ${scobj_hpath}/stuff/flushpmp plain user text + hsetprop ${scobj_hpath}/stuff/flushpmp read ${ns}::getValue ${scobj_hpath} rdValue {FLUSHPMP?} + hsetprop ${scobj_hpath}/stuff/flushpmp rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/stuff/flushpmp control true + hsetprop ${scobj_hpath}/stuff/flushpmp data true + hsetprop ${scobj_hpath}/stuff/flushpmp mutable true + hsetprop ${scobj_hpath}/stuff/flushpmp nxsave true + hsetprop ${scobj_hpath}/stuff/flushpmp oldval UNKNOWN + hsetprop ${scobj_hpath}/stuff/flushpmp klass "parameter" + hsetprop ${scobj_hpath}/stuff/flushpmp sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/stuff/flushpmp type "part" + hsetprop ${scobj_hpath}/stuff/flushpmp nxalias "${name}_stuff_flushpmp" + + hfactory ${scobj_hpath}/stuff/head plain user text + hsetprop ${scobj_hpath}/stuff/head read ${ns}::getValue ${scobj_hpath} rdValue {HEAD?} + hsetprop ${scobj_hpath}/stuff/head rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/stuff/head control true + hsetprop ${scobj_hpath}/stuff/head data true + hsetprop ${scobj_hpath}/stuff/head mutable true + hsetprop ${scobj_hpath}/stuff/head nxsave true + hsetprop ${scobj_hpath}/stuff/head oldval UNKNOWN + hsetprop ${scobj_hpath}/stuff/head klass "parameter" + hsetprop ${scobj_hpath}/stuff/head sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/stuff/head type "part" + hsetprop ${scobj_hpath}/stuff/head nxalias "${name}_stuff_head" + + hfactory ${scobj_hpath}/stuff/head_par plain user text + hsetprop ${scobj_hpath}/stuff/head_par read ${ns}::getValue ${scobj_hpath} rdValue {HEAD_PAR?} + hsetprop ${scobj_hpath}/stuff/head_par rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/stuff/head_par control true + hsetprop ${scobj_hpath}/stuff/head_par data true + hsetprop ${scobj_hpath}/stuff/head_par mutable true + hsetprop ${scobj_hpath}/stuff/head_par nxsave true + hsetprop ${scobj_hpath}/stuff/head_par oldval UNKNOWN + hsetprop ${scobj_hpath}/stuff/head_par klass "parameter" + hsetprop ${scobj_hpath}/stuff/head_par sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/stuff/head_par type "part" + hsetprop ${scobj_hpath}/stuff/head_par nxalias "${name}_stuff_head_par" + + hfactory ${scobj_hpath}/stuff/identify plain user text + hsetprop ${scobj_hpath}/stuff/identify read ${ns}::getValue ${scobj_hpath} rdValue {IDENTIFY?} + hsetprop ${scobj_hpath}/stuff/identify rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/stuff/identify control true + hsetprop ${scobj_hpath}/stuff/identify data true + hsetprop ${scobj_hpath}/stuff/identify mutable true + hsetprop ${scobj_hpath}/stuff/identify nxsave true + hsetprop ${scobj_hpath}/stuff/identify oldval UNKNOWN + hsetprop ${scobj_hpath}/stuff/identify klass "parameter" + hsetprop ${scobj_hpath}/stuff/identify sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/stuff/identify type "part" + hsetprop ${scobj_hpath}/stuff/identify nxalias "${name}_stuff_identify" + + hfactory ${scobj_hpath}/stuff/lpg plain user text + hsetprop ${scobj_hpath}/stuff/lpg read ${ns}::getValue ${scobj_hpath} rdValue {LPG?} + hsetprop ${scobj_hpath}/stuff/lpg rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/stuff/lpg control true + hsetprop ${scobj_hpath}/stuff/lpg data true + hsetprop ${scobj_hpath}/stuff/lpg mutable true + hsetprop ${scobj_hpath}/stuff/lpg nxsave true + hsetprop ${scobj_hpath}/stuff/lpg oldval UNKNOWN + hsetprop ${scobj_hpath}/stuff/lpg klass "parameter" + hsetprop ${scobj_hpath}/stuff/lpg sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/stuff/lpg type "part" + hsetprop ${scobj_hpath}/stuff/lpg nxalias "${name}_stuff_lpg" + + hfactory ${scobj_hpath}/stuff/oem plain user text + hsetprop ${scobj_hpath}/stuff/oem read ${ns}::getValue ${scobj_hpath} rdValue {OEM?} + hsetprop ${scobj_hpath}/stuff/oem rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/stuff/oem control true + hsetprop ${scobj_hpath}/stuff/oem data true + hsetprop ${scobj_hpath}/stuff/oem mutable true + hsetprop ${scobj_hpath}/stuff/oem nxsave true + hsetprop ${scobj_hpath}/stuff/oem oldval UNKNOWN + hsetprop ${scobj_hpath}/stuff/oem klass "parameter" + hsetprop ${scobj_hpath}/stuff/oem sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/stuff/oem type "part" + hsetprop ${scobj_hpath}/stuff/oem nxalias "${name}_stuff_oem" + + hfactory ${scobj_hpath}/stuff/opt plain user text + hsetprop ${scobj_hpath}/stuff/opt read ${ns}::getValue ${scobj_hpath} rdValue {OPT?} + hsetprop ${scobj_hpath}/stuff/opt rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/stuff/opt control true + hsetprop ${scobj_hpath}/stuff/opt data true + hsetprop ${scobj_hpath}/stuff/opt mutable true + hsetprop ${scobj_hpath}/stuff/opt nxsave true + hsetprop ${scobj_hpath}/stuff/opt oldval UNKNOWN + hsetprop ${scobj_hpath}/stuff/opt klass "parameter" + hsetprop ${scobj_hpath}/stuff/opt sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/stuff/opt type "part" + hsetprop ${scobj_hpath}/stuff/opt nxalias "${name}_stuff_opt" + + hfactory ${scobj_hpath}/stuff/plim plain user text + hsetprop ${scobj_hpath}/stuff/plim read ${ns}::getValue ${scobj_hpath} rdValue {PLIM?} + hsetprop ${scobj_hpath}/stuff/plim rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/stuff/plim control true + hsetprop ${scobj_hpath}/stuff/plim data true + hsetprop ${scobj_hpath}/stuff/plim mutable true + hsetprop ${scobj_hpath}/stuff/plim nxsave true + hsetprop ${scobj_hpath}/stuff/plim oldval UNKNOWN + hsetprop ${scobj_hpath}/stuff/plim klass "parameter" + hsetprop ${scobj_hpath}/stuff/plim sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/stuff/plim type "part" + hsetprop ${scobj_hpath}/stuff/plim nxalias "${name}_stuff_plim" + + hfactory ${scobj_hpath}/stuff/pressure plain user text + hsetprop ${scobj_hpath}/stuff/pressure read ${ns}::getValue ${scobj_hpath} rdValue {PRESSURE?} + hsetprop ${scobj_hpath}/stuff/pressure rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/stuff/pressure control true + hsetprop ${scobj_hpath}/stuff/pressure data true + hsetprop ${scobj_hpath}/stuff/pressure mutable true + hsetprop ${scobj_hpath}/stuff/pressure nxsave true + hsetprop ${scobj_hpath}/stuff/pressure oldval UNKNOWN + hsetprop ${scobj_hpath}/stuff/pressure klass "parameter" + hsetprop ${scobj_hpath}/stuff/pressure sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/stuff/pressure type "part" + hsetprop ${scobj_hpath}/stuff/pressure nxalias "${name}_stuff_pressure" + + hfactory ${scobj_hpath}/stuff/prfastacq plain user text + hsetprop ${scobj_hpath}/stuff/prfastacq read ${ns}::getValue ${scobj_hpath} rdValue {PRFASTACQ?} + hsetprop ${scobj_hpath}/stuff/prfastacq rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/stuff/prfastacq control true + hsetprop ${scobj_hpath}/stuff/prfastacq data true + hsetprop ${scobj_hpath}/stuff/prfastacq mutable true + hsetprop ${scobj_hpath}/stuff/prfastacq nxsave true + hsetprop ${scobj_hpath}/stuff/prfastacq oldval UNKNOWN + hsetprop ${scobj_hpath}/stuff/prfastacq klass "parameter" + hsetprop ${scobj_hpath}/stuff/prfastacq sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/stuff/prfastacq type "part" + hsetprop ${scobj_hpath}/stuff/prfastacq nxalias "${name}_stuff_prfastacq" + + hfactory ${scobj_hpath}/stuff/purge plain user text + hsetprop ${scobj_hpath}/stuff/purge read ${ns}::getValue ${scobj_hpath} rdValue {PURGE?} + hsetprop ${scobj_hpath}/stuff/purge rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/stuff/purge control true + hsetprop ${scobj_hpath}/stuff/purge data true + hsetprop ${scobj_hpath}/stuff/purge mutable true + hsetprop ${scobj_hpath}/stuff/purge nxsave true + hsetprop ${scobj_hpath}/stuff/purge oldval UNKNOWN + hsetprop ${scobj_hpath}/stuff/purge klass "parameter" + hsetprop ${scobj_hpath}/stuff/purge sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/stuff/purge type "part" + hsetprop ${scobj_hpath}/stuff/purge nxalias "${name}_stuff_purge" + + hfactory ${scobj_hpath}/stuff/remote plain user text + hsetprop ${scobj_hpath}/stuff/remote read ${ns}::getValue ${scobj_hpath} rdValue {REMOTE?} + hsetprop ${scobj_hpath}/stuff/remote rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/stuff/remote control true + hsetprop ${scobj_hpath}/stuff/remote data true + hsetprop ${scobj_hpath}/stuff/remote mutable true + hsetprop ${scobj_hpath}/stuff/remote nxsave true + hsetprop ${scobj_hpath}/stuff/remote oldval UNKNOWN + hsetprop ${scobj_hpath}/stuff/remote klass "parameter" + hsetprop ${scobj_hpath}/stuff/remote sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/stuff/remote type "part" + hsetprop ${scobj_hpath}/stuff/remote nxalias "${name}_stuff_remote" + + hfactory ${scobj_hpath}/stuff/rfid plain user text + hsetprop ${scobj_hpath}/stuff/rfid read ${ns}::getValue ${scobj_hpath} rdValue {RFID?} + hsetprop ${scobj_hpath}/stuff/rfid rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/stuff/rfid control true + hsetprop ${scobj_hpath}/stuff/rfid data true + hsetprop ${scobj_hpath}/stuff/rfid mutable true + hsetprop ${scobj_hpath}/stuff/rfid nxsave true + hsetprop ${scobj_hpath}/stuff/rfid oldval UNKNOWN + hsetprop ${scobj_hpath}/stuff/rfid klass "parameter" + hsetprop ${scobj_hpath}/stuff/rfid sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/stuff/rfid type "part" + hsetprop ${scobj_hpath}/stuff/rfid nxalias "${name}_stuff_rfid" + + hfactory ${scobj_hpath}/stuff/service plain user text + hsetprop ${scobj_hpath}/stuff/service read ${ns}::getValue ${scobj_hpath} rdValue {SERVICE?} + hsetprop ${scobj_hpath}/stuff/service rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/stuff/service control true + hsetprop ${scobj_hpath}/stuff/service data true + hsetprop ${scobj_hpath}/stuff/service mutable true + hsetprop ${scobj_hpath}/stuff/service nxsave true + hsetprop ${scobj_hpath}/stuff/service oldval UNKNOWN + hsetprop ${scobj_hpath}/stuff/service klass "parameter" + hsetprop ${scobj_hpath}/stuff/service sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/stuff/service type "part" + hsetprop ${scobj_hpath}/stuff/service nxalias "${name}_stuff_service" + + hfactory ${scobj_hpath}/stuff/sysinfo plain user text + hsetprop ${scobj_hpath}/stuff/sysinfo read ${ns}::getValue ${scobj_hpath} rdValue {SYSINFO?} + hsetprop ${scobj_hpath}/stuff/sysinfo rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/stuff/sysinfo control true + hsetprop ${scobj_hpath}/stuff/sysinfo data true + hsetprop ${scobj_hpath}/stuff/sysinfo mutable true + hsetprop ${scobj_hpath}/stuff/sysinfo nxsave true + hsetprop ${scobj_hpath}/stuff/sysinfo oldval UNKNOWN + hsetprop ${scobj_hpath}/stuff/sysinfo klass "parameter" + hsetprop ${scobj_hpath}/stuff/sysinfo sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/stuff/sysinfo type "part" + hsetprop ${scobj_hpath}/stuff/sysinfo nxalias "${name}_stuff_sysinfo" + + hfactory ${scobj_hpath}/stuff/units plain user text + hsetprop ${scobj_hpath}/stuff/units read ${ns}::getValue ${scobj_hpath} rdValue {UNITS?} + hsetprop ${scobj_hpath}/stuff/units rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/stuff/units control true + hsetprop ${scobj_hpath}/stuff/units data true + hsetprop ${scobj_hpath}/stuff/units mutable true + hsetprop ${scobj_hpath}/stuff/units nxsave true + hsetprop ${scobj_hpath}/stuff/units oldval UNKNOWN + hsetprop ${scobj_hpath}/stuff/units klass "parameter" + hsetprop ${scobj_hpath}/stuff/units sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/stuff/units type "part" + hsetprop ${scobj_hpath}/stuff/units nxalias "${name}_stuff_units" + + hfactory ${scobj_hpath}/stuff/valves plain user text + hsetprop ${scobj_hpath}/stuff/valves read ${ns}::getValue ${scobj_hpath} rdValue {VALVES?} + hsetprop ${scobj_hpath}/stuff/valves rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/stuff/valves control true + hsetprop ${scobj_hpath}/stuff/valves data true + hsetprop ${scobj_hpath}/stuff/valves mutable true + hsetprop ${scobj_hpath}/stuff/valves nxsave true + hsetprop ${scobj_hpath}/stuff/valves oldval UNKNOWN + hsetprop ${scobj_hpath}/stuff/valves klass "parameter" + hsetprop ${scobj_hpath}/stuff/valves sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/stuff/valves type "part" + hsetprop ${scobj_hpath}/stuff/valves nxalias "${name}_stuff_valves" + + if {[string equal -nocase "${simulation_flag}" "false"]} { + ${sct_controller} poll ${scobj_hpath}/stuff/an_out 60 + ${sct_controller} poll ${scobj_hpath}/stuff/boardinfo 60 + ${sct_controller} poll ${scobj_hpath}/stuff/config 60 + ${sct_controller} poll ${scobj_hpath}/stuff/cprofinfo 60 + ${sct_controller} poll ${scobj_hpath}/stuff/dout 60 + ${sct_controller} poll ${scobj_hpath}/stuff/error 60 + ${sct_controller} poll ${scobj_hpath}/stuff/errors 60 + ${sct_controller} poll ${scobj_hpath}/stuff/flushpmp 60 + ${sct_controller} poll ${scobj_hpath}/stuff/head 60 + ${sct_controller} poll ${scobj_hpath}/stuff/head_par 60 + ${sct_controller} poll ${scobj_hpath}/stuff/identify 60 + ${sct_controller} poll ${scobj_hpath}/stuff/lpg 60 + ${sct_controller} poll ${scobj_hpath}/stuff/oem 60 + ${sct_controller} poll ${scobj_hpath}/stuff/opt 60 + ${sct_controller} poll ${scobj_hpath}/stuff/plim 60 + ${sct_controller} poll ${scobj_hpath}/stuff/pressure 60 + ${sct_controller} poll ${scobj_hpath}/stuff/prfastacq 60 + ${sct_controller} poll ${scobj_hpath}/stuff/purge 60 + ${sct_controller} poll ${scobj_hpath}/stuff/remote 60 + ${sct_controller} poll ${scobj_hpath}/stuff/rfid 60 + ${sct_controller} poll ${scobj_hpath}/stuff/service 60 + ${sct_controller} poll ${scobj_hpath}/stuff/sysinfo 60 + ${sct_controller} poll ${scobj_hpath}/stuff/units 60 + ${sct_controller} poll ${scobj_hpath}/stuff/valves 60 + } else { + ::scobj::knauer_pump::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for knauer_pump" + } + + hfactory ${scobj_hpath}/volume plain spy none + hsetprop ${scobj_hpath}/volume data "true" + hsetprop ${scobj_hpath}/volume klass "@none" + hsetprop ${scobj_hpath}/volume type "part" + + hfactory ${scobj_hpath}/volume/sensor plain user float + hsetprop ${scobj_hpath}/volume/sensor read ${ns}::volume_fetch ${scobj_hpath} rdValue { } + hsetprop ${scobj_hpath}/volume/sensor rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/volume/sensor control true + hsetprop ${scobj_hpath}/volume/sensor data true + hsetprop ${scobj_hpath}/volume/sensor mutable true + hsetprop ${scobj_hpath}/volume/sensor nxsave true + hsetprop ${scobj_hpath}/volume/sensor oldval 0.0 + hsetprop ${scobj_hpath}/volume/sensor klass "parameter" + hsetprop ${scobj_hpath}/volume/sensor sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/volume/sensor type "part" + hsetprop ${scobj_hpath}/volume/sensor units "mL" + hsetprop ${scobj_hpath}/volume/sensor nxalias "${name}_volume_sensor" + + hfactory ${scobj_hpath}/volume/setpoint plain user float + hsetprop ${scobj_hpath}/volume/setpoint read ${ns}::volume_checkpumping ${scobj_hpath} rdValue { } + hsetprop ${scobj_hpath}/volume/setpoint rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/volume/setpoint write ${ns}::volume_write ${scobj_hpath} noResponse { } + hsetprop ${scobj_hpath}/volume/setpoint noResponse ${ns}::noResponse ${scobj_hpath} + hsetprop ${scobj_hpath}/volume/setpoint check ${ns}::checkrange ${scobj_hpath} + hsetprop ${scobj_hpath}/volume/setpoint driving 0 + hsetprop ${scobj_hpath}/volume/setpoint checklimits ${ns}::checklimits ${scobj_hpath} + hsetprop ${scobj_hpath}/volume/setpoint checkstatus ${ns}::volume_checkstatus ${scobj_hpath} + hsetprop ${scobj_hpath}/volume/setpoint halt ${ns}::volume_halt ${scobj_hpath} + hsetprop ${scobj_hpath}/volume/setpoint driveable volume/sensor + hsetprop ${scobj_hpath}/volume/setpoint control true + hsetprop ${scobj_hpath}/volume/setpoint data true + hsetprop ${scobj_hpath}/volume/setpoint mutable true + hsetprop ${scobj_hpath}/volume/setpoint nxsave true + hsetprop ${scobj_hpath}/volume/setpoint lowerlimit 0 + hsetprop ${scobj_hpath}/volume/setpoint upperlimit 100 + hsetprop ${scobj_hpath}/volume/setpoint tolerance 0.01 + hsetprop ${scobj_hpath}/volume/setpoint oldval 0.0 + hsetprop ${scobj_hpath}/volume/setpoint klass "parameter" + hsetprop ${scobj_hpath}/volume/setpoint sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/volume/setpoint type "drivable" + hsetprop ${scobj_hpath}/volume/setpoint units "mL" + hsetprop ${scobj_hpath}/volume/setpoint nxalias "${name}_volume_setpoint" + + if {[string equal -nocase "${simulation_flag}" "false"]} { + ${sct_controller} poll ${scobj_hpath}/volume/sensor 1 + ${sct_controller} poll ${scobj_hpath}/volume/setpoint 1 + ${sct_controller} write ${scobj_hpath}/volume/setpoint + } else { + ::scobj::knauer_pump::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for knauer_pump" + } + hsetprop ${scobj_hpath} klass ${device_class} + hsetprop ${scobj_hpath} data true + hsetprop ${scobj_hpath} debug_threshold 0 + if {[string equal -nocase "${simulation_flag}" "false"]} { + ansto_makesctdrive ${name}_volume_setpoint ${scobj_hpath}/volume/setpoint ${scobj_hpath}/volume/sensor ${sct_controller} + } +# mkDriver hook code goes here + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +proc ::scobj::knauer_pump::add_driver {name device_class simulation_flag ip_address tcp_port} { + set catch_status [ catch { + ::scobj::knauer_pump::sics_log 9 "::scobj::knauer_pump::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" + if {[string equal -nocase "${simulation_flag}" "false"]} { + if {[string equal -nocase "aqadapter" "${ip_address}"]} { + ::scobj::knauer_pump::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" + makesctcontroller sct_${name} aqadapter ${tcp_port} + } else { + ::scobj::knauer_pump::sics_log 9 "makesctcontroller sct_${name} knauer_ap ${ip_address}:${tcp_port}" + makesctcontroller sct_${name} knauer_ap ${ip_address}:${tcp_port} + } + } else { + ::scobj::knauer_pump::sics_log 9 "simulation_flag={simulation_flag} => No sctcontroller for knauer_pump" + } + ::scobj::knauer_pump::sics_log 1 "::scobj::knauer_pump::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port}" + ::scobj::knauer_pump::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +namespace eval ::scobj::knauer_pump { + namespace export debug_threshold + namespace export debug_log + namespace export sics_log + namespace export mkDriver + namespace export add_driver +} + +proc add_knauer_pump {name ip_address tcp_port} { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + ::scobj::knauer_pump::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} +} + +clientput "file evaluation of sct_knauer_pump.tcl" +::scobj::knauer_pump::sics_log 9 "file evaluation of sct_knauer_pump.tcl" + +proc ::scobj::knauer_pump::read_config {} { + set catch_status [ catch { + set ns "::scobj::knauer_pump" + dict for {k u} $::config_dict { + if { [dict exists $u "implementation"] } { + set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" + set device_class "environment" + if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { + continue + } + set enabled [string tolower [dict get $u "enabled"]] + if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { + continue + } + if { [dict exists $u "simulation_group"] } { + set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] + } + if { [dict exists $u "device_class"] } { + set device_class "[dict get $u "device_class"]" + } + set name [dict get $u name] + set implementation [dict get $u "implementation"] + if { !([dict exists $::config_dict $implementation]) } { + continue + } + set v [dict get $::config_dict $implementation] + if { !([dict exists $v "driver"]) } { + continue + } + if { [string equal -nocase [dict get $v "driver"] "knauer_pump"] } { + if { ![string equal -nocase "${simulation_flag}" "false"] } { + set asyncqueue "null" + ${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue" + } elseif { [dict exists $v "asyncqueue"] } { + set asyncqueue [dict get $v "asyncqueue"] + if { [string equal -nocase ${asyncqueue} "sct"] } { + set ip_address [dict get $v ip] + set tcp_port [dict get $v port] + } + } else { + if { [dict exists $v "asyncprotocol"] } { + set asyncprotocol [dict get $v "asyncprotocol"] + } else { + set asyncprotocol ${name}_protocol + MakeAsyncProtocol ${asyncprotocol} + if { [dict exists $v "terminator"] } { + ${asyncprotocol} sendterminator "[dict get $v "terminator"]" + ${asyncprotocol} replyterminator "[dict get $v "terminator"]" + } + } + set asyncqueue ${name}_queue + set ip_address [dict get $v ip] + set tcp_port [dict get $v port] + MakeAsyncQueue ${asyncqueue} ${asyncprotocol} ${ip_address} ${tcp_port} + if { [dict exists $v "timeout"] } { + ${asyncqueue} timeout "[dict get $v "timeout"]" + } + } + if { [string equal -nocase ${asyncqueue} "sct"] } { + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} + } else { + ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} + } + } + } + } + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +if { [info exists ::config_dict] } { + ::scobj::knauer_pump::read_config +} else { + ::scobj::knauer_pump::sics_log 5 "No config dict" +} From 522865f264a46d9655aef42e72e51a7e412393b2 Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Fri, 19 Sep 2014 12:07:51 +1000 Subject: [PATCH 56/68] Restructure knauer_pump.sct --- .../config/environment/knauer_pump.sct | 144 ++++++++++++------ 1 file changed, 95 insertions(+), 49 deletions(-) diff --git a/site_ansto/instrument/config/environment/knauer_pump.sct b/site_ansto/instrument/config/environment/knauer_pump.sct index e2288c48..a8c3bd43 100644 --- a/site_ansto/instrument/config/environment/knauer_pump.sct +++ b/site_ansto/instrument/config/environment/knauer_pump.sct @@ -6,7 +6,7 @@ driver knauer_pump = { debug_threshold = 0; vendor = knauer; device = pump40p; protocol = knauer_ap; class = environment; - simulation_group = environment_simulation + simulation_group = environment_simulation; # group dummy = { type = text; readable = 1; data = false; control = false; nxsave = false; @@ -14,53 +14,68 @@ driver knauer_pump = { var glp = { read_command = 'GLP?'; read_function = read_glp; } } - group volume = { - type = float; - property 'units' = 'mL'; - var sensor = { + group pump = { + var state = { + type = text; + readable = 1; + read_command = ' '; + fetch_function = state_fetch; + } + var status = { + type = text; + readable = 1; + read_command = ' '; + fetch_function = status_fetch; + } + var volume_pv = { + type = float; readable = 1; read_command = ' '; fetch_function = volume_fetch; - #checkrange_function = volume_reject; +#checkrange_function = volume_reject; + property 'units' = 'mL'; } - var setpoint = { + var volume_sp = { + type = float; writeable = 1; write_command = ' '; write_function = volume_write; - driveable = volume/sensor; - checkstatus_function = volume_checkstatus; + driveable = pump/volume_pv + checkstatus_function = volume_checkstatus; halt_function = volume_halt; lowerlimit = 0; upperlimit = 100; tolerance = 0.01; readable = 1; read_command = ' '; fetch_function = volume_checkpumping; + property 'units' = 'mL'; } - } - group ratios = { - type = text; - property 'units' = 'percent'; - var sensor = { + var ratio_pv = { + type = text; readable = 1; read_command = ' '; fetch_function = ratios_fetch; + property 'units' = 'percent'; } - var setpoint = { + var ratio_sp = { + type = text; writeable = 1; write_command = ' '; write_function = ratios_write; checkrange_function = ratios_check; + property 'units' = 'percent'; } - } - group flow = { - type = float; - property 'units' = 'mL/min'; - var sensor = { + var flow_pv = { + type = float; readable = 1; read_command = ' '; fetch_function = flow_fetch; + property 'units' = 'mL/min'; } - var setpoint = { + var flow_sp = { + type = float; writeable = 1; write_command = ' '; write_function = flow_write; lowerlimit = 0; upperlimit = 10; + property 'units' = 'mL/min'; } } group stuff = { readable = 60; type = text; + data = false; control = false; nxsave = false; var an_out = { read_command = 'AN_OUT?'; } var boardinfo = { read_command = 'BOARDINFO?'; } var config = { read_command = 'CONFIG?'; } @@ -164,18 +179,52 @@ driver knauer_pump = { sct real_data "[join [lrange ${dlist} 0 end] ,]" set data "Hidden in real_data property" %%} + code status_fetch = {%% + set index 1 + set data [hgetpropval ${tc_root}/dummy/status real_data] + set dlist [split ${data} ","] + set status_code [lindex ${dlist} ${index}] + set cmd "@@NOSEND@@" + if { ${status_code} == 3 } { + sct result "PUMPING" + } else { + sct result "IDLE" + } + %%} + code state_fetch = {%% + set index 1 + set data [hgetpropval ${tc_root}/dummy/status real_data] + set dlist [split ${data} ","] + set state_code [lindex ${dlist} ${index}] + set cmd "@@NOSEND@@" + if { ${state_code} < 0 || ${state_code} > 9 } { + sct geterror "Invalid device_state ${state_code}" + error "[sct geterror]" + } + set slist [list "SYS_ST_INITIALIZING" \ + "SYS_ST_OFF" \ + "SYS_ST_IDLE" \ + "SYS_ST_RUN" \ + "SYS_ST_HOLD" \ + "SYS_ST_PURGE" \ + "SYS_ST_STANDBY" \ + "SYS_ST_FAILED" \ + "SYS_ST_RUNATEND" \ + ] + sct result [lindex ${slist} ${state_code}] + %%} code halt = {%% - set ratios [hval ${tc_root}/ratios/setpoint] - set ratios [join [split ${ratios} /] ,] - set cmd "RAMP:0,0,${ratios},0,0,0,0,0,0,0,0,2" + set rlist [hval ${tc_root}/pump/ratio_sp] + set ratio_tgt [join [split ${rlist} /] ,] + set cmd "RAMP:0,0,${ratio_tgt},0,0,0,0,0,0,0,0,2" %%} code flow_fetch = {%% set data [hgetpropval ${tc_root}/dummy/status real_data] set dlist [split ${data} ","] - set flow [lindex ${dlist} 4] - sct result [expr {0.001 * ${flow}}] + set flow_pv [lindex ${dlist} 4] + sct result [expr {0.001 * ${flow_pv}}] set cmd "@@NOSEND@@" %%} code flow_write = {%% @@ -191,12 +240,12 @@ driver knauer_pump = { %%} code ratios_check = {%% - set ratios [split ${setpoint} /] - if { [llength ${ratios}] != 4 } { - sct geterror "${setpoint} has [llength ${ratios}] components, needs 4" + set rlist [split ${setpoint} /] + if { [llength ${rlist}] != 4 } { + sct geterror "${setpoint} has [llength ${rlist}] components, needs 4" error [sct geterror] } - set sum [expr [lindex ${ratios} 0] + [lindex ${ratios} 1] + [lindex ${ratios} 2] + [lindex ${ratios} 3]] + set sum [expr [lindex ${rlist} 0] + [lindex ${rlist} 1] + [lindex ${rlist} 2] + [lindex ${rlist} 3]] if { ${sum} != 100 } { sct geterror "sum is ${sum}, must be 100" error [sct geterror] @@ -206,8 +255,8 @@ driver knauer_pump = { code ratios_fetch = {%% set data [hgetpropval ${tc_root}/dummy/status real_data] set dlist [split ${data} ","] - set ratios "[lindex ${dlist} 5]/[lindex ${dlist} 6]/[lindex ${dlist} 7]/[lindex ${dlist} 8]" - sct result ${ratios} + set ratio_vals "[lindex ${dlist} 5]/[lindex ${dlist} 6]/[lindex ${dlist} 7]/[lindex ${dlist} 8]" + sct result ${ratio_vals} set cmd "@@NOSEND@@" %%} code ratios_write = {%% @@ -228,26 +277,25 @@ driver knauer_pump = { if { [llength ${dlist}] > 11 } { set pump_volm [lindex ${dlist} 10] set pump_voln [lindex ${dlist} 11] - set volume [expr {${pump_volm} + 0.000001 * ${pump_voln}}] + set pump_volume [expr {${pump_volm} + 0.000001 * ${pump_voln}}] } else { - set volume 0.0 + set pump_volume 0.0 } - sct raw_volume ${volume} + sct raw_volume ${pump_volume} if { [hpropexists [sct] base_volume] } { - set volume [expr {${volume} - [sct base_volume]}] + set pump_volume [expr {${pump_volume} - [sct base_volume]}] } else { sct base_volume [sct raw_volume] } - sct result ${volume} + sct result ${pump_volume} set cmd "@@NOSEND@@" %%} code volume_write = {%% hsetprop ${tc_root}/[sct driveable] base_volume [hgetpropval ${tc_root}/[sct driveable] raw_volume] hset ${tc_root}/[sct driveable] 0.0 - set flow [expr {int(1000.0 * [hval ${tc_root}/flow/setpoint])}] - set ratios [hval ${tc_root}/ratios/setpoint] - set ratios [join [split ${ratios} /] ,] - set cmd "RAMP:0,${flow},${ratios},0,0,0,0,0,0,0,0,3" + set flow_tgt [expr {int(1000.0 * [hval ${tc_root}/pump/flow_sp])}] + set ratio_tgt [join [split [hval ${tc_root}/pump/ratio_sp] /] ,] + set cmd "RAMP:0,${flow_tgt},${ratio_tgt},0,0,0,0,0,0,0,0,3" sct pumping 1 %%} @@ -261,10 +309,9 @@ driver knauer_pump = { set sp "[sct target]" set pv "[hval ${tc_root}/[sct driveable]]" if { (${sp} - ${pv}) <= [sct tolerance] } { - set flow 0 - set ratios [hval ${tc_root}/ratios/setpoint] - set ratios [join [split ${ratios} /] ,] - set cmd "RAMP:0,${flow},${ratios},0,0,0,0,0,0,0,0,2" + set flow_tgt 0 + set ratio_tgt [join [split [hval ${tc_root}/pump/ratio_sp] /] ,] + set cmd "RAMP:0,${flow_tgt},${ratio_tgt},0,0,0,0,0,0,0,0,2" set nextState noResponse sct pumping 0 } @@ -272,10 +319,9 @@ driver knauer_pump = { %%} code volume_halt = {%% - set flow 0 - set ratios [hval ${tc_root}/ratios/setpoint] - set ratios [join [split ${ratios} /] ,] - set cmd "RAMP:0,${flow},${ratios},0,0,0,0,0,0,0,0,2" + set flow_tgt 0 + set ratio_tgt [join [split [hval ${tc_root}/pump/ratio_sp] /] ,] + set cmd "RAMP:0,${flow_tgt},${ratio_tgt},0,0,0,0,0,0,0,0,2" sct send ${cmd} %%} From b3d8f1bdae55c448c712cc6de307649561f52175 Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Fri, 19 Sep 2014 12:08:13 +1000 Subject: [PATCH 57/68] Regenerate knauer_pump.sct --- .../config/environment/sct_knauer_pump.tcl | 559 ++++++++++-------- 1 file changed, 308 insertions(+), 251 deletions(-) diff --git a/site_ansto/instrument/config/environment/sct_knauer_pump.tcl b/site_ansto/instrument/config/environment/sct_knauer_pump.tcl index dda04d9f..d58d4bf4 100644 --- a/site_ansto/instrument/config/environment/sct_knauer_pump.tcl +++ b/site_ansto/instrument/config/environment/sct_knauer_pump.tcl @@ -147,8 +147,8 @@ proc ::scobj::knauer_pump::flow_fetch {tc_root nextState cmd_str} { # flow_fetch hook code starts set data [hgetpropval ${tc_root}/dummy/status real_data] set dlist [split ${data} ","] - set flow [lindex ${dlist} 4] - sct result [expr {0.001 * ${flow}}] + set flow_pv [lindex ${dlist} 4] + sct result [expr {0.001 * ${flow_pv}}] set cmd "@@NOSEND@@" # flow_fetch hook code ends if { [hpropexists [sct] geterror] } { @@ -248,12 +248,12 @@ proc ::scobj::knauer_pump::ratios_check {tc_root} { set hilimit [sct target] } # ratios_check hook code starts - set ratios [split ${setpoint} /] - if { [llength ${ratios}] != 4 } { - sct geterror "${setpoint} has [llength ${ratios}] components, needs 4" + set rlist [split ${setpoint} /] + if { [llength ${rlist}] != 4 } { + sct geterror "${setpoint} has [llength ${rlist}] components, needs 4" error [sct geterror] } - set sum [expr [lindex ${ratios} 0] + [lindex ${ratios} 1] + [lindex ${ratios} 2] + [lindex ${ratios} 3]] + set sum [expr [lindex ${rlist} 0] + [lindex ${rlist} 1] + [lindex ${rlist} 2] + [lindex ${rlist} 3]] if { ${sum} != 100 } { sct geterror "sum is ${sum}, must be 100" error [sct geterror] @@ -278,8 +278,8 @@ proc ::scobj::knauer_pump::ratios_fetch {tc_root nextState cmd_str} { # ratios_fetch hook code starts set data [hgetpropval ${tc_root}/dummy/status real_data] set dlist [split ${data} ","] - set ratios "[lindex ${dlist} 5]/[lindex ${dlist} 6]/[lindex ${dlist} 7]/[lindex ${dlist} 8]" - sct result ${ratios} + set ratio_vals "[lindex ${dlist} 5]/[lindex ${dlist} 6]/[lindex ${dlist} 7]/[lindex ${dlist} 8]" + sct result ${ratio_vals} set cmd "@@NOSEND@@" # ratios_fetch hook code ends if { [hpropexists [sct] geterror] } { @@ -451,6 +451,82 @@ proc ::scobj::knauer_pump::setValue {tc_root nextState cmd_str} { handle_exception ${catch_status} ${catch_message} } +# function to request the read of a parameter on a device +proc ::scobj::knauer_pump::state_fetch {tc_root nextState cmd_str} { + set catch_status [ catch { + debug_log ${tc_root} 1 "state_fetch tc_root=${tc_root} sct=[sct] cmd=${cmd_str}" + if { [hpropexists [sct] geterror] } { + hdelprop [sct] geterror + } + set cmd "${cmd_str}" +# state_fetch hook code starts + set index 1 + set data [hgetpropval ${tc_root}/dummy/status real_data] + set dlist [split ${data} ","] + set state_code [lindex ${dlist} ${index}] + set cmd "@@NOSEND@@" + if { ${state_code} < 0 || ${state_code} > 9 } { + sct geterror "Invalid device_state ${state_code}" + error "[sct geterror]" + } + set slist [list "SYS_ST_INITIALIZING" \ + "SYS_ST_OFF" \ + "SYS_ST_IDLE" \ + "SYS_ST_RUN" \ + "SYS_ST_HOLD" \ + "SYS_ST_PURGE" \ + "SYS_ST_STANDBY" \ + "SYS_ST_FAILED" \ + "SYS_ST_RUNATEND" \ + ] + sct result [lindex ${slist} ${state_code}] +# state_fetch hook code ends + if { [hpropexists [sct] geterror] } { + debug_log ${tc_root} 9 "[sct] error: [sct geterror]" + error "[sct geterror]" + } + debug_log ${tc_root} 1 "state_fetch sct send ${cmd}" + if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} { + sct send "${cmd}" + } + return ${nextState} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + +# function to request the read of a parameter on a device +proc ::scobj::knauer_pump::status_fetch {tc_root nextState cmd_str} { + set catch_status [ catch { + debug_log ${tc_root} 1 "status_fetch tc_root=${tc_root} sct=[sct] cmd=${cmd_str}" + if { [hpropexists [sct] geterror] } { + hdelprop [sct] geterror + } + set cmd "${cmd_str}" +# status_fetch hook code starts + set index 1 + set data [hgetpropval ${tc_root}/dummy/status real_data] + set dlist [split ${data} ","] + set status_code [lindex ${dlist} ${index}] + set cmd "@@NOSEND@@" + if { ${status_code} == 3 } { + sct result "PUMPING" + } else { + sct result "IDLE" + } +# status_fetch hook code ends + if { [hpropexists [sct] geterror] } { + debug_log ${tc_root} 9 "[sct] error: [sct geterror]" + error "[sct geterror]" + } + debug_log ${tc_root} 1 "status_fetch sct send ${cmd}" + if {![string equal -nocase -length 10 ${cmd} "@@NOSEND@@"]} { + sct send "${cmd}" + } + return ${nextState} + } catch_message ] + handle_exception ${catch_status} ${catch_message} +} + # function to request the read of a parameter on a device proc ::scobj::knauer_pump::volume_checkpumping {tc_root nextState cmd_str} { set catch_status [ catch { @@ -469,10 +545,9 @@ proc ::scobj::knauer_pump::volume_checkpumping {tc_root nextState cmd_str} { set sp "[sct target]" set pv "[hval ${tc_root}/[sct driveable]]" if { (${sp} - ${pv}) <= [sct tolerance] } { - set flow 0 - set ratios [hval ${tc_root}/ratios/setpoint] - set ratios [join [split ${ratios} /] ,] - set cmd "RAMP:0,${flow},${ratios},0,0,0,0,0,0,0,0,2" + set flow_tgt 0 + set ratio_tgt [join [split [hval ${tc_root}/pump/ratio_sp] /] ,] + set cmd "RAMP:0,${flow_tgt},${ratio_tgt},0,0,0,0,0,0,0,0,2" set nextState noResponse sct pumping 0 } @@ -539,17 +614,17 @@ proc ::scobj::knauer_pump::volume_fetch {tc_root nextState cmd_str} { if { [llength ${dlist}] > 11 } { set pump_volm [lindex ${dlist} 10] set pump_voln [lindex ${dlist} 11] - set volume [expr {${pump_volm} + 0.000001 * ${pump_voln}}] + set pump_volume [expr {${pump_volm} + 0.000001 * ${pump_voln}}] } else { - set volume 0.0 + set pump_volume 0.0 } - sct raw_volume ${volume} + sct raw_volume ${pump_volume} if { [hpropexists [sct] base_volume] } { - set volume [expr {${volume} - [sct base_volume]}] + set pump_volume [expr {${pump_volume} - [sct base_volume]}] } else { sct base_volume [sct raw_volume] } - sct result ${volume} + sct result ${pump_volume} set cmd "@@NOSEND@@" # volume_fetch hook code ends if { [hpropexists [sct] geterror] } { @@ -571,10 +646,9 @@ proc ::scobj::knauer_pump::volume_halt {tc_root} { debug_log ${tc_root} 1 "volume_halt tc_root=${tc_root} sct=[sct] driving=[sct driving]" ### TODO hset [sct] [hval [sct]] # volume_halt hook code starts - set flow 0 - set ratios [hval ${tc_root}/ratios/setpoint] - set ratios [join [split ${ratios} /] ,] - set cmd "RAMP:0,${flow},${ratios},0,0,0,0,0,0,0,0,2" + set flow_tgt 0 + set ratio_tgt [join [split [hval ${tc_root}/pump/ratio_sp] /] ,] + set cmd "RAMP:0,${flow_tgt},${ratio_tgt},0,0,0,0,0,0,0,0,2" sct send ${cmd} # volume_halt hook code ends sct driving 0 @@ -595,10 +669,9 @@ proc ::scobj::knauer_pump::volume_write {tc_root nextState cmd_str} { # volume_write hook code starts hsetprop ${tc_root}/[sct driveable] base_volume [hgetpropval ${tc_root}/[sct driveable] raw_volume] hset ${tc_root}/[sct driveable] 0.0 - set flow [expr {int(1000.0 * [hval ${tc_root}/flow/setpoint])}] - set ratios [hval ${tc_root}/ratios/setpoint] - set ratios [join [split ${ratios} /] ,] - set cmd "RAMP:0,${flow},${ratios},0,0,0,0,0,0,0,0,3" + set flow_tgt [expr {int(1000.0 * [hval ${tc_root}/pump/flow_sp])}] + set ratio_tgt [join [split [hval ${tc_root}/pump/ratio_sp] /] ,] + set cmd "RAMP:0,${flow_tgt},${ratio_tgt},0,0,0,0,0,0,0,0,3" sct pumping 1 # volume_write hook code ends if { [hpropexists [sct] geterror] } { @@ -667,49 +740,6 @@ proc ::scobj::knauer_pump::mkDriver { sct_controller name device_class simulatio ::scobj::knauer_pump::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for knauer_pump" } - hfactory ${scobj_hpath}/flow plain spy none - hsetprop ${scobj_hpath}/flow data "true" - hsetprop ${scobj_hpath}/flow klass "@none" - hsetprop ${scobj_hpath}/flow type "part" - - hfactory ${scobj_hpath}/flow/sensor plain user float - hsetprop ${scobj_hpath}/flow/sensor read ${ns}::flow_fetch ${scobj_hpath} rdValue { } - hsetprop ${scobj_hpath}/flow/sensor rdValue ${ns}::rdValue ${scobj_hpath} - hsetprop ${scobj_hpath}/flow/sensor control true - hsetprop ${scobj_hpath}/flow/sensor data true - hsetprop ${scobj_hpath}/flow/sensor mutable true - hsetprop ${scobj_hpath}/flow/sensor nxsave true - hsetprop ${scobj_hpath}/flow/sensor oldval 0.0 - hsetprop ${scobj_hpath}/flow/sensor klass "parameter" - hsetprop ${scobj_hpath}/flow/sensor sdsinfo "::nexus::scobj::sdsinfo" - hsetprop ${scobj_hpath}/flow/sensor type "part" - hsetprop ${scobj_hpath}/flow/sensor units "mL/min" - hsetprop ${scobj_hpath}/flow/sensor nxalias "${name}_flow_sensor" - - hfactory ${scobj_hpath}/flow/setpoint plain user float - hsetprop ${scobj_hpath}/flow/setpoint write ${ns}::flow_write ${scobj_hpath} noResponse { } - hsetprop ${scobj_hpath}/flow/setpoint noResponse ${ns}::noResponse ${scobj_hpath} - hsetprop ${scobj_hpath}/flow/setpoint check ${ns}::checkrange ${scobj_hpath} - hsetprop ${scobj_hpath}/flow/setpoint control true - hsetprop ${scobj_hpath}/flow/setpoint data true - hsetprop ${scobj_hpath}/flow/setpoint mutable true - hsetprop ${scobj_hpath}/flow/setpoint nxsave true - hsetprop ${scobj_hpath}/flow/setpoint lowerlimit 0 - hsetprop ${scobj_hpath}/flow/setpoint upperlimit 10 - hsetprop ${scobj_hpath}/flow/setpoint oldval 0.0 - hsetprop ${scobj_hpath}/flow/setpoint klass "parameter" - hsetprop ${scobj_hpath}/flow/setpoint sdsinfo "::nexus::scobj::sdsinfo" - hsetprop ${scobj_hpath}/flow/setpoint type "part" - hsetprop ${scobj_hpath}/flow/setpoint units "mL/min" - hsetprop ${scobj_hpath}/flow/setpoint nxalias "${name}_flow_setpoint" - - if {[string equal -nocase "${simulation_flag}" "false"]} { - ${sct_controller} poll ${scobj_hpath}/flow/sensor 1 - ${sct_controller} write ${scobj_hpath}/flow/setpoint - } else { - ::scobj::knauer_pump::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for knauer_pump" - } - hfactory ${scobj_hpath}/glp plain spy none hsetprop ${scobj_hpath}/glp data "true" hsetprop ${scobj_hpath}/glp klass "@none" @@ -982,43 +1012,146 @@ proc ::scobj::knauer_pump::mkDriver { sct_controller name device_class simulatio ::scobj::knauer_pump::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for knauer_pump" } - hfactory ${scobj_hpath}/ratios plain spy none - hsetprop ${scobj_hpath}/ratios data "true" - hsetprop ${scobj_hpath}/ratios klass "@none" - hsetprop ${scobj_hpath}/ratios type "part" + hfactory ${scobj_hpath}/pump plain spy none + hsetprop ${scobj_hpath}/pump data "true" + hsetprop ${scobj_hpath}/pump klass "@none" + hsetprop ${scobj_hpath}/pump type "part" - hfactory ${scobj_hpath}/ratios/sensor plain user text - hsetprop ${scobj_hpath}/ratios/sensor read ${ns}::ratios_fetch ${scobj_hpath} rdValue { } - hsetprop ${scobj_hpath}/ratios/sensor rdValue ${ns}::rdValue ${scobj_hpath} - hsetprop ${scobj_hpath}/ratios/sensor control true - hsetprop ${scobj_hpath}/ratios/sensor data true - hsetprop ${scobj_hpath}/ratios/sensor mutable true - hsetprop ${scobj_hpath}/ratios/sensor nxsave true - hsetprop ${scobj_hpath}/ratios/sensor oldval UNKNOWN - hsetprop ${scobj_hpath}/ratios/sensor klass "parameter" - hsetprop ${scobj_hpath}/ratios/sensor sdsinfo "::nexus::scobj::sdsinfo" - hsetprop ${scobj_hpath}/ratios/sensor type "part" - hsetprop ${scobj_hpath}/ratios/sensor units "percent" - hsetprop ${scobj_hpath}/ratios/sensor nxalias "${name}_ratios_sensor" + hfactory ${scobj_hpath}/pump/flow_pv plain user float + hsetprop ${scobj_hpath}/pump/flow_pv read ${ns}::flow_fetch ${scobj_hpath} rdValue { } + hsetprop ${scobj_hpath}/pump/flow_pv rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/pump/flow_pv control true + hsetprop ${scobj_hpath}/pump/flow_pv data true + hsetprop ${scobj_hpath}/pump/flow_pv mutable true + hsetprop ${scobj_hpath}/pump/flow_pv nxsave true + hsetprop ${scobj_hpath}/pump/flow_pv oldval 0.0 + hsetprop ${scobj_hpath}/pump/flow_pv klass "parameter" + hsetprop ${scobj_hpath}/pump/flow_pv sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/pump/flow_pv type "part" + hsetprop ${scobj_hpath}/pump/flow_pv units "mL/min" + hsetprop ${scobj_hpath}/pump/flow_pv nxalias "${name}_pump_flow_pv" - hfactory ${scobj_hpath}/ratios/setpoint plain user text - hsetprop ${scobj_hpath}/ratios/setpoint write ${ns}::ratios_write ${scobj_hpath} noResponse { } - hsetprop ${scobj_hpath}/ratios/setpoint noResponse ${ns}::noResponse ${scobj_hpath} - hsetprop ${scobj_hpath}/ratios/setpoint check ${ns}::ratios_check ${scobj_hpath} - hsetprop ${scobj_hpath}/ratios/setpoint control true - hsetprop ${scobj_hpath}/ratios/setpoint data true - hsetprop ${scobj_hpath}/ratios/setpoint mutable true - hsetprop ${scobj_hpath}/ratios/setpoint nxsave true - hsetprop ${scobj_hpath}/ratios/setpoint oldval UNKNOWN - hsetprop ${scobj_hpath}/ratios/setpoint klass "parameter" - hsetprop ${scobj_hpath}/ratios/setpoint sdsinfo "::nexus::scobj::sdsinfo" - hsetprop ${scobj_hpath}/ratios/setpoint type "part" - hsetprop ${scobj_hpath}/ratios/setpoint units "percent" - hsetprop ${scobj_hpath}/ratios/setpoint nxalias "${name}_ratios_setpoint" + hfactory ${scobj_hpath}/pump/flow_sp plain user float + hsetprop ${scobj_hpath}/pump/flow_sp write ${ns}::flow_write ${scobj_hpath} noResponse { } + hsetprop ${scobj_hpath}/pump/flow_sp noResponse ${ns}::noResponse ${scobj_hpath} + hsetprop ${scobj_hpath}/pump/flow_sp check ${ns}::checkrange ${scobj_hpath} + hsetprop ${scobj_hpath}/pump/flow_sp control true + hsetprop ${scobj_hpath}/pump/flow_sp data true + hsetprop ${scobj_hpath}/pump/flow_sp mutable true + hsetprop ${scobj_hpath}/pump/flow_sp nxsave true + hsetprop ${scobj_hpath}/pump/flow_sp lowerlimit 0 + hsetprop ${scobj_hpath}/pump/flow_sp upperlimit 10 + hsetprop ${scobj_hpath}/pump/flow_sp oldval 0.0 + hsetprop ${scobj_hpath}/pump/flow_sp klass "parameter" + hsetprop ${scobj_hpath}/pump/flow_sp sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/pump/flow_sp type "part" + hsetprop ${scobj_hpath}/pump/flow_sp units "mL/min" + hsetprop ${scobj_hpath}/pump/flow_sp nxalias "${name}_pump_flow_sp" + + hfactory ${scobj_hpath}/pump/ratio_pv plain user text + hsetprop ${scobj_hpath}/pump/ratio_pv read ${ns}::ratios_fetch ${scobj_hpath} rdValue { } + hsetprop ${scobj_hpath}/pump/ratio_pv rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/pump/ratio_pv control true + hsetprop ${scobj_hpath}/pump/ratio_pv data true + hsetprop ${scobj_hpath}/pump/ratio_pv mutable true + hsetprop ${scobj_hpath}/pump/ratio_pv nxsave true + hsetprop ${scobj_hpath}/pump/ratio_pv oldval UNKNOWN + hsetprop ${scobj_hpath}/pump/ratio_pv klass "parameter" + hsetprop ${scobj_hpath}/pump/ratio_pv sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/pump/ratio_pv type "part" + hsetprop ${scobj_hpath}/pump/ratio_pv units "percent" + hsetprop ${scobj_hpath}/pump/ratio_pv nxalias "${name}_pump_ratio_pv" + + hfactory ${scobj_hpath}/pump/ratio_sp plain user text + hsetprop ${scobj_hpath}/pump/ratio_sp write ${ns}::ratios_write ${scobj_hpath} noResponse { } + hsetprop ${scobj_hpath}/pump/ratio_sp noResponse ${ns}::noResponse ${scobj_hpath} + hsetprop ${scobj_hpath}/pump/ratio_sp check ${ns}::ratios_check ${scobj_hpath} + hsetprop ${scobj_hpath}/pump/ratio_sp control true + hsetprop ${scobj_hpath}/pump/ratio_sp data true + hsetprop ${scobj_hpath}/pump/ratio_sp mutable true + hsetprop ${scobj_hpath}/pump/ratio_sp nxsave true + hsetprop ${scobj_hpath}/pump/ratio_sp oldval UNKNOWN + hsetprop ${scobj_hpath}/pump/ratio_sp klass "parameter" + hsetprop ${scobj_hpath}/pump/ratio_sp sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/pump/ratio_sp type "part" + hsetprop ${scobj_hpath}/pump/ratio_sp units "percent" + hsetprop ${scobj_hpath}/pump/ratio_sp nxalias "${name}_pump_ratio_sp" + + hfactory ${scobj_hpath}/pump/state plain user text + hsetprop ${scobj_hpath}/pump/state read ${ns}::state_fetch ${scobj_hpath} rdValue { } + hsetprop ${scobj_hpath}/pump/state rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/pump/state control true + hsetprop ${scobj_hpath}/pump/state data true + hsetprop ${scobj_hpath}/pump/state mutable true + hsetprop ${scobj_hpath}/pump/state nxsave true + hsetprop ${scobj_hpath}/pump/state oldval UNKNOWN + hsetprop ${scobj_hpath}/pump/state klass "parameter" + hsetprop ${scobj_hpath}/pump/state sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/pump/state type "part" + hsetprop ${scobj_hpath}/pump/state nxalias "${name}_pump_state" + + hfactory ${scobj_hpath}/pump/status plain user text + hsetprop ${scobj_hpath}/pump/status read ${ns}::status_fetch ${scobj_hpath} rdValue { } + hsetprop ${scobj_hpath}/pump/status rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/pump/status control true + hsetprop ${scobj_hpath}/pump/status data true + hsetprop ${scobj_hpath}/pump/status mutable true + hsetprop ${scobj_hpath}/pump/status nxsave true + hsetprop ${scobj_hpath}/pump/status oldval UNKNOWN + hsetprop ${scobj_hpath}/pump/status klass "parameter" + hsetprop ${scobj_hpath}/pump/status sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/pump/status type "part" + hsetprop ${scobj_hpath}/pump/status nxalias "${name}_pump_status" + + hfactory ${scobj_hpath}/pump/volume_pv plain user float + hsetprop ${scobj_hpath}/pump/volume_pv read ${ns}::volume_fetch ${scobj_hpath} rdValue { } + hsetprop ${scobj_hpath}/pump/volume_pv rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/pump/volume_pv control true + hsetprop ${scobj_hpath}/pump/volume_pv data true + hsetprop ${scobj_hpath}/pump/volume_pv mutable true + hsetprop ${scobj_hpath}/pump/volume_pv nxsave true + hsetprop ${scobj_hpath}/pump/volume_pv oldval 0.0 + hsetprop ${scobj_hpath}/pump/volume_pv klass "parameter" + hsetprop ${scobj_hpath}/pump/volume_pv sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/pump/volume_pv type "part" + hsetprop ${scobj_hpath}/pump/volume_pv units "mL" + hsetprop ${scobj_hpath}/pump/volume_pv nxalias "${name}_pump_volume_pv" + + hfactory ${scobj_hpath}/pump/volume_sp plain user float + hsetprop ${scobj_hpath}/pump/volume_sp read ${ns}::volume_checkpumping ${scobj_hpath} rdValue { } + hsetprop ${scobj_hpath}/pump/volume_sp rdValue ${ns}::rdValue ${scobj_hpath} + hsetprop ${scobj_hpath}/pump/volume_sp write ${ns}::volume_write ${scobj_hpath} noResponse { } + hsetprop ${scobj_hpath}/pump/volume_sp noResponse ${ns}::noResponse ${scobj_hpath} + hsetprop ${scobj_hpath}/pump/volume_sp check ${ns}::checkrange ${scobj_hpath} + hsetprop ${scobj_hpath}/pump/volume_sp driving 0 + hsetprop ${scobj_hpath}/pump/volume_sp checklimits ${ns}::checklimits ${scobj_hpath} + hsetprop ${scobj_hpath}/pump/volume_sp checkstatus ${ns}::volume_checkstatus ${scobj_hpath} + hsetprop ${scobj_hpath}/pump/volume_sp halt ${ns}::volume_halt ${scobj_hpath} + hsetprop ${scobj_hpath}/pump/volume_sp driveable pump/volume_pv + hsetprop ${scobj_hpath}/pump/volume_sp control true + hsetprop ${scobj_hpath}/pump/volume_sp data true + hsetprop ${scobj_hpath}/pump/volume_sp mutable true + hsetprop ${scobj_hpath}/pump/volume_sp nxsave true + hsetprop ${scobj_hpath}/pump/volume_sp lowerlimit 0 + hsetprop ${scobj_hpath}/pump/volume_sp upperlimit 100 + hsetprop ${scobj_hpath}/pump/volume_sp tolerance 0.01 + hsetprop ${scobj_hpath}/pump/volume_sp oldval 0.0 + hsetprop ${scobj_hpath}/pump/volume_sp klass "parameter" + hsetprop ${scobj_hpath}/pump/volume_sp sdsinfo "::nexus::scobj::sdsinfo" + hsetprop ${scobj_hpath}/pump/volume_sp type "drivable" + hsetprop ${scobj_hpath}/pump/volume_sp units "mL" + hsetprop ${scobj_hpath}/pump/volume_sp nxalias "${name}_pump_volume_sp" if {[string equal -nocase "${simulation_flag}" "false"]} { - ${sct_controller} poll ${scobj_hpath}/ratios/sensor 1 - ${sct_controller} write ${scobj_hpath}/ratios/setpoint + ${sct_controller} poll ${scobj_hpath}/pump/flow_pv 1 + ${sct_controller} poll ${scobj_hpath}/pump/ratio_pv 1 + ${sct_controller} poll ${scobj_hpath}/pump/state 1 + ${sct_controller} poll ${scobj_hpath}/pump/status 1 + ${sct_controller} poll ${scobj_hpath}/pump/volume_pv 1 + ${sct_controller} poll ${scobj_hpath}/pump/volume_sp 1 + ${sct_controller} write ${scobj_hpath}/pump/flow_sp + ${sct_controller} write ${scobj_hpath}/pump/ratio_sp + ${sct_controller} write ${scobj_hpath}/pump/volume_sp } else { ::scobj::knauer_pump::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for knauer_pump" } @@ -1300,19 +1433,18 @@ proc ::scobj::knauer_pump::mkDriver { sct_controller name device_class simulatio } hfactory ${scobj_hpath}/stuff plain spy none - hsetprop ${scobj_hpath}/stuff data "true" + hsetprop ${scobj_hpath}/stuff data "false" hsetprop ${scobj_hpath}/stuff klass "@none" hsetprop ${scobj_hpath}/stuff type "part" hfactory ${scobj_hpath}/stuff/an_out plain user text hsetprop ${scobj_hpath}/stuff/an_out read ${ns}::getValue ${scobj_hpath} rdValue {AN_OUT?} hsetprop ${scobj_hpath}/stuff/an_out rdValue ${ns}::rdValue ${scobj_hpath} - hsetprop ${scobj_hpath}/stuff/an_out control true - hsetprop ${scobj_hpath}/stuff/an_out data true + hsetprop ${scobj_hpath}/stuff/an_out control false + hsetprop ${scobj_hpath}/stuff/an_out data false hsetprop ${scobj_hpath}/stuff/an_out mutable true - hsetprop ${scobj_hpath}/stuff/an_out nxsave true + hsetprop ${scobj_hpath}/stuff/an_out nxsave false hsetprop ${scobj_hpath}/stuff/an_out oldval UNKNOWN - hsetprop ${scobj_hpath}/stuff/an_out klass "parameter" hsetprop ${scobj_hpath}/stuff/an_out sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/stuff/an_out type "part" hsetprop ${scobj_hpath}/stuff/an_out nxalias "${name}_stuff_an_out" @@ -1320,12 +1452,11 @@ proc ::scobj::knauer_pump::mkDriver { sct_controller name device_class simulatio hfactory ${scobj_hpath}/stuff/boardinfo plain user text hsetprop ${scobj_hpath}/stuff/boardinfo read ${ns}::getValue ${scobj_hpath} rdValue {BOARDINFO?} hsetprop ${scobj_hpath}/stuff/boardinfo rdValue ${ns}::rdValue ${scobj_hpath} - hsetprop ${scobj_hpath}/stuff/boardinfo control true - hsetprop ${scobj_hpath}/stuff/boardinfo data true + hsetprop ${scobj_hpath}/stuff/boardinfo control false + hsetprop ${scobj_hpath}/stuff/boardinfo data false hsetprop ${scobj_hpath}/stuff/boardinfo mutable true - hsetprop ${scobj_hpath}/stuff/boardinfo nxsave true + hsetprop ${scobj_hpath}/stuff/boardinfo nxsave false hsetprop ${scobj_hpath}/stuff/boardinfo oldval UNKNOWN - hsetprop ${scobj_hpath}/stuff/boardinfo klass "parameter" hsetprop ${scobj_hpath}/stuff/boardinfo sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/stuff/boardinfo type "part" hsetprop ${scobj_hpath}/stuff/boardinfo nxalias "${name}_stuff_boardinfo" @@ -1333,12 +1464,11 @@ proc ::scobj::knauer_pump::mkDriver { sct_controller name device_class simulatio hfactory ${scobj_hpath}/stuff/config plain user text hsetprop ${scobj_hpath}/stuff/config read ${ns}::getValue ${scobj_hpath} rdValue {CONFIG?} hsetprop ${scobj_hpath}/stuff/config rdValue ${ns}::rdValue ${scobj_hpath} - hsetprop ${scobj_hpath}/stuff/config control true - hsetprop ${scobj_hpath}/stuff/config data true + hsetprop ${scobj_hpath}/stuff/config control false + hsetprop ${scobj_hpath}/stuff/config data false hsetprop ${scobj_hpath}/stuff/config mutable true - hsetprop ${scobj_hpath}/stuff/config nxsave true + hsetprop ${scobj_hpath}/stuff/config nxsave false hsetprop ${scobj_hpath}/stuff/config oldval UNKNOWN - hsetprop ${scobj_hpath}/stuff/config klass "parameter" hsetprop ${scobj_hpath}/stuff/config sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/stuff/config type "part" hsetprop ${scobj_hpath}/stuff/config nxalias "${name}_stuff_config" @@ -1346,12 +1476,11 @@ proc ::scobj::knauer_pump::mkDriver { sct_controller name device_class simulatio hfactory ${scobj_hpath}/stuff/cprofinfo plain user text hsetprop ${scobj_hpath}/stuff/cprofinfo read ${ns}::getValue ${scobj_hpath} rdValue {CPROFINFO?} hsetprop ${scobj_hpath}/stuff/cprofinfo rdValue ${ns}::rdValue ${scobj_hpath} - hsetprop ${scobj_hpath}/stuff/cprofinfo control true - hsetprop ${scobj_hpath}/stuff/cprofinfo data true + hsetprop ${scobj_hpath}/stuff/cprofinfo control false + hsetprop ${scobj_hpath}/stuff/cprofinfo data false hsetprop ${scobj_hpath}/stuff/cprofinfo mutable true - hsetprop ${scobj_hpath}/stuff/cprofinfo nxsave true + hsetprop ${scobj_hpath}/stuff/cprofinfo nxsave false hsetprop ${scobj_hpath}/stuff/cprofinfo oldval UNKNOWN - hsetprop ${scobj_hpath}/stuff/cprofinfo klass "parameter" hsetprop ${scobj_hpath}/stuff/cprofinfo sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/stuff/cprofinfo type "part" hsetprop ${scobj_hpath}/stuff/cprofinfo nxalias "${name}_stuff_cprofinfo" @@ -1359,12 +1488,11 @@ proc ::scobj::knauer_pump::mkDriver { sct_controller name device_class simulatio hfactory ${scobj_hpath}/stuff/dout plain user text hsetprop ${scobj_hpath}/stuff/dout read ${ns}::getValue ${scobj_hpath} rdValue {DOUT?} hsetprop ${scobj_hpath}/stuff/dout rdValue ${ns}::rdValue ${scobj_hpath} - hsetprop ${scobj_hpath}/stuff/dout control true - hsetprop ${scobj_hpath}/stuff/dout data true + hsetprop ${scobj_hpath}/stuff/dout control false + hsetprop ${scobj_hpath}/stuff/dout data false hsetprop ${scobj_hpath}/stuff/dout mutable true - hsetprop ${scobj_hpath}/stuff/dout nxsave true + hsetprop ${scobj_hpath}/stuff/dout nxsave false hsetprop ${scobj_hpath}/stuff/dout oldval UNKNOWN - hsetprop ${scobj_hpath}/stuff/dout klass "parameter" hsetprop ${scobj_hpath}/stuff/dout sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/stuff/dout type "part" hsetprop ${scobj_hpath}/stuff/dout nxalias "${name}_stuff_dout" @@ -1372,12 +1500,11 @@ proc ::scobj::knauer_pump::mkDriver { sct_controller name device_class simulatio hfactory ${scobj_hpath}/stuff/error plain user text hsetprop ${scobj_hpath}/stuff/error read ${ns}::getValue ${scobj_hpath} rdValue {ERROR?} hsetprop ${scobj_hpath}/stuff/error rdValue ${ns}::rdValue ${scobj_hpath} - hsetprop ${scobj_hpath}/stuff/error control true - hsetprop ${scobj_hpath}/stuff/error data true + hsetprop ${scobj_hpath}/stuff/error control false + hsetprop ${scobj_hpath}/stuff/error data false hsetprop ${scobj_hpath}/stuff/error mutable true - hsetprop ${scobj_hpath}/stuff/error nxsave true + hsetprop ${scobj_hpath}/stuff/error nxsave false hsetprop ${scobj_hpath}/stuff/error oldval UNKNOWN - hsetprop ${scobj_hpath}/stuff/error klass "parameter" hsetprop ${scobj_hpath}/stuff/error sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/stuff/error type "part" hsetprop ${scobj_hpath}/stuff/error nxalias "${name}_stuff_error" @@ -1385,12 +1512,11 @@ proc ::scobj::knauer_pump::mkDriver { sct_controller name device_class simulatio hfactory ${scobj_hpath}/stuff/errors plain user text hsetprop ${scobj_hpath}/stuff/errors read ${ns}::getValue ${scobj_hpath} rdValue {ERRORS?} hsetprop ${scobj_hpath}/stuff/errors rdValue ${ns}::rdValue ${scobj_hpath} - hsetprop ${scobj_hpath}/stuff/errors control true - hsetprop ${scobj_hpath}/stuff/errors data true + hsetprop ${scobj_hpath}/stuff/errors control false + hsetprop ${scobj_hpath}/stuff/errors data false hsetprop ${scobj_hpath}/stuff/errors mutable true - hsetprop ${scobj_hpath}/stuff/errors nxsave true + hsetprop ${scobj_hpath}/stuff/errors nxsave false hsetprop ${scobj_hpath}/stuff/errors oldval UNKNOWN - hsetprop ${scobj_hpath}/stuff/errors klass "parameter" hsetprop ${scobj_hpath}/stuff/errors sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/stuff/errors type "part" hsetprop ${scobj_hpath}/stuff/errors nxalias "${name}_stuff_errors" @@ -1398,12 +1524,11 @@ proc ::scobj::knauer_pump::mkDriver { sct_controller name device_class simulatio hfactory ${scobj_hpath}/stuff/flushpmp plain user text hsetprop ${scobj_hpath}/stuff/flushpmp read ${ns}::getValue ${scobj_hpath} rdValue {FLUSHPMP?} hsetprop ${scobj_hpath}/stuff/flushpmp rdValue ${ns}::rdValue ${scobj_hpath} - hsetprop ${scobj_hpath}/stuff/flushpmp control true - hsetprop ${scobj_hpath}/stuff/flushpmp data true + hsetprop ${scobj_hpath}/stuff/flushpmp control false + hsetprop ${scobj_hpath}/stuff/flushpmp data false hsetprop ${scobj_hpath}/stuff/flushpmp mutable true - hsetprop ${scobj_hpath}/stuff/flushpmp nxsave true + hsetprop ${scobj_hpath}/stuff/flushpmp nxsave false hsetprop ${scobj_hpath}/stuff/flushpmp oldval UNKNOWN - hsetprop ${scobj_hpath}/stuff/flushpmp klass "parameter" hsetprop ${scobj_hpath}/stuff/flushpmp sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/stuff/flushpmp type "part" hsetprop ${scobj_hpath}/stuff/flushpmp nxalias "${name}_stuff_flushpmp" @@ -1411,12 +1536,11 @@ proc ::scobj::knauer_pump::mkDriver { sct_controller name device_class simulatio hfactory ${scobj_hpath}/stuff/head plain user text hsetprop ${scobj_hpath}/stuff/head read ${ns}::getValue ${scobj_hpath} rdValue {HEAD?} hsetprop ${scobj_hpath}/stuff/head rdValue ${ns}::rdValue ${scobj_hpath} - hsetprop ${scobj_hpath}/stuff/head control true - hsetprop ${scobj_hpath}/stuff/head data true + hsetprop ${scobj_hpath}/stuff/head control false + hsetprop ${scobj_hpath}/stuff/head data false hsetprop ${scobj_hpath}/stuff/head mutable true - hsetprop ${scobj_hpath}/stuff/head nxsave true + hsetprop ${scobj_hpath}/stuff/head nxsave false hsetprop ${scobj_hpath}/stuff/head oldval UNKNOWN - hsetprop ${scobj_hpath}/stuff/head klass "parameter" hsetprop ${scobj_hpath}/stuff/head sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/stuff/head type "part" hsetprop ${scobj_hpath}/stuff/head nxalias "${name}_stuff_head" @@ -1424,12 +1548,11 @@ proc ::scobj::knauer_pump::mkDriver { sct_controller name device_class simulatio hfactory ${scobj_hpath}/stuff/head_par plain user text hsetprop ${scobj_hpath}/stuff/head_par read ${ns}::getValue ${scobj_hpath} rdValue {HEAD_PAR?} hsetprop ${scobj_hpath}/stuff/head_par rdValue ${ns}::rdValue ${scobj_hpath} - hsetprop ${scobj_hpath}/stuff/head_par control true - hsetprop ${scobj_hpath}/stuff/head_par data true + hsetprop ${scobj_hpath}/stuff/head_par control false + hsetprop ${scobj_hpath}/stuff/head_par data false hsetprop ${scobj_hpath}/stuff/head_par mutable true - hsetprop ${scobj_hpath}/stuff/head_par nxsave true + hsetprop ${scobj_hpath}/stuff/head_par nxsave false hsetprop ${scobj_hpath}/stuff/head_par oldval UNKNOWN - hsetprop ${scobj_hpath}/stuff/head_par klass "parameter" hsetprop ${scobj_hpath}/stuff/head_par sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/stuff/head_par type "part" hsetprop ${scobj_hpath}/stuff/head_par nxalias "${name}_stuff_head_par" @@ -1437,12 +1560,11 @@ proc ::scobj::knauer_pump::mkDriver { sct_controller name device_class simulatio hfactory ${scobj_hpath}/stuff/identify plain user text hsetprop ${scobj_hpath}/stuff/identify read ${ns}::getValue ${scobj_hpath} rdValue {IDENTIFY?} hsetprop ${scobj_hpath}/stuff/identify rdValue ${ns}::rdValue ${scobj_hpath} - hsetprop ${scobj_hpath}/stuff/identify control true - hsetprop ${scobj_hpath}/stuff/identify data true + hsetprop ${scobj_hpath}/stuff/identify control false + hsetprop ${scobj_hpath}/stuff/identify data false hsetprop ${scobj_hpath}/stuff/identify mutable true - hsetprop ${scobj_hpath}/stuff/identify nxsave true + hsetprop ${scobj_hpath}/stuff/identify nxsave false hsetprop ${scobj_hpath}/stuff/identify oldval UNKNOWN - hsetprop ${scobj_hpath}/stuff/identify klass "parameter" hsetprop ${scobj_hpath}/stuff/identify sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/stuff/identify type "part" hsetprop ${scobj_hpath}/stuff/identify nxalias "${name}_stuff_identify" @@ -1450,12 +1572,11 @@ proc ::scobj::knauer_pump::mkDriver { sct_controller name device_class simulatio hfactory ${scobj_hpath}/stuff/lpg plain user text hsetprop ${scobj_hpath}/stuff/lpg read ${ns}::getValue ${scobj_hpath} rdValue {LPG?} hsetprop ${scobj_hpath}/stuff/lpg rdValue ${ns}::rdValue ${scobj_hpath} - hsetprop ${scobj_hpath}/stuff/lpg control true - hsetprop ${scobj_hpath}/stuff/lpg data true + hsetprop ${scobj_hpath}/stuff/lpg control false + hsetprop ${scobj_hpath}/stuff/lpg data false hsetprop ${scobj_hpath}/stuff/lpg mutable true - hsetprop ${scobj_hpath}/stuff/lpg nxsave true + hsetprop ${scobj_hpath}/stuff/lpg nxsave false hsetprop ${scobj_hpath}/stuff/lpg oldval UNKNOWN - hsetprop ${scobj_hpath}/stuff/lpg klass "parameter" hsetprop ${scobj_hpath}/stuff/lpg sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/stuff/lpg type "part" hsetprop ${scobj_hpath}/stuff/lpg nxalias "${name}_stuff_lpg" @@ -1463,12 +1584,11 @@ proc ::scobj::knauer_pump::mkDriver { sct_controller name device_class simulatio hfactory ${scobj_hpath}/stuff/oem plain user text hsetprop ${scobj_hpath}/stuff/oem read ${ns}::getValue ${scobj_hpath} rdValue {OEM?} hsetprop ${scobj_hpath}/stuff/oem rdValue ${ns}::rdValue ${scobj_hpath} - hsetprop ${scobj_hpath}/stuff/oem control true - hsetprop ${scobj_hpath}/stuff/oem data true + hsetprop ${scobj_hpath}/stuff/oem control false + hsetprop ${scobj_hpath}/stuff/oem data false hsetprop ${scobj_hpath}/stuff/oem mutable true - hsetprop ${scobj_hpath}/stuff/oem nxsave true + hsetprop ${scobj_hpath}/stuff/oem nxsave false hsetprop ${scobj_hpath}/stuff/oem oldval UNKNOWN - hsetprop ${scobj_hpath}/stuff/oem klass "parameter" hsetprop ${scobj_hpath}/stuff/oem sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/stuff/oem type "part" hsetprop ${scobj_hpath}/stuff/oem nxalias "${name}_stuff_oem" @@ -1476,12 +1596,11 @@ proc ::scobj::knauer_pump::mkDriver { sct_controller name device_class simulatio hfactory ${scobj_hpath}/stuff/opt plain user text hsetprop ${scobj_hpath}/stuff/opt read ${ns}::getValue ${scobj_hpath} rdValue {OPT?} hsetprop ${scobj_hpath}/stuff/opt rdValue ${ns}::rdValue ${scobj_hpath} - hsetprop ${scobj_hpath}/stuff/opt control true - hsetprop ${scobj_hpath}/stuff/opt data true + hsetprop ${scobj_hpath}/stuff/opt control false + hsetprop ${scobj_hpath}/stuff/opt data false hsetprop ${scobj_hpath}/stuff/opt mutable true - hsetprop ${scobj_hpath}/stuff/opt nxsave true + hsetprop ${scobj_hpath}/stuff/opt nxsave false hsetprop ${scobj_hpath}/stuff/opt oldval UNKNOWN - hsetprop ${scobj_hpath}/stuff/opt klass "parameter" hsetprop ${scobj_hpath}/stuff/opt sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/stuff/opt type "part" hsetprop ${scobj_hpath}/stuff/opt nxalias "${name}_stuff_opt" @@ -1489,12 +1608,11 @@ proc ::scobj::knauer_pump::mkDriver { sct_controller name device_class simulatio hfactory ${scobj_hpath}/stuff/plim plain user text hsetprop ${scobj_hpath}/stuff/plim read ${ns}::getValue ${scobj_hpath} rdValue {PLIM?} hsetprop ${scobj_hpath}/stuff/plim rdValue ${ns}::rdValue ${scobj_hpath} - hsetprop ${scobj_hpath}/stuff/plim control true - hsetprop ${scobj_hpath}/stuff/plim data true + hsetprop ${scobj_hpath}/stuff/plim control false + hsetprop ${scobj_hpath}/stuff/plim data false hsetprop ${scobj_hpath}/stuff/plim mutable true - hsetprop ${scobj_hpath}/stuff/plim nxsave true + hsetprop ${scobj_hpath}/stuff/plim nxsave false hsetprop ${scobj_hpath}/stuff/plim oldval UNKNOWN - hsetprop ${scobj_hpath}/stuff/plim klass "parameter" hsetprop ${scobj_hpath}/stuff/plim sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/stuff/plim type "part" hsetprop ${scobj_hpath}/stuff/plim nxalias "${name}_stuff_plim" @@ -1502,12 +1620,11 @@ proc ::scobj::knauer_pump::mkDriver { sct_controller name device_class simulatio hfactory ${scobj_hpath}/stuff/pressure plain user text hsetprop ${scobj_hpath}/stuff/pressure read ${ns}::getValue ${scobj_hpath} rdValue {PRESSURE?} hsetprop ${scobj_hpath}/stuff/pressure rdValue ${ns}::rdValue ${scobj_hpath} - hsetprop ${scobj_hpath}/stuff/pressure control true - hsetprop ${scobj_hpath}/stuff/pressure data true + hsetprop ${scobj_hpath}/stuff/pressure control false + hsetprop ${scobj_hpath}/stuff/pressure data false hsetprop ${scobj_hpath}/stuff/pressure mutable true - hsetprop ${scobj_hpath}/stuff/pressure nxsave true + hsetprop ${scobj_hpath}/stuff/pressure nxsave false hsetprop ${scobj_hpath}/stuff/pressure oldval UNKNOWN - hsetprop ${scobj_hpath}/stuff/pressure klass "parameter" hsetprop ${scobj_hpath}/stuff/pressure sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/stuff/pressure type "part" hsetprop ${scobj_hpath}/stuff/pressure nxalias "${name}_stuff_pressure" @@ -1515,12 +1632,11 @@ proc ::scobj::knauer_pump::mkDriver { sct_controller name device_class simulatio hfactory ${scobj_hpath}/stuff/prfastacq plain user text hsetprop ${scobj_hpath}/stuff/prfastacq read ${ns}::getValue ${scobj_hpath} rdValue {PRFASTACQ?} hsetprop ${scobj_hpath}/stuff/prfastacq rdValue ${ns}::rdValue ${scobj_hpath} - hsetprop ${scobj_hpath}/stuff/prfastacq control true - hsetprop ${scobj_hpath}/stuff/prfastacq data true + hsetprop ${scobj_hpath}/stuff/prfastacq control false + hsetprop ${scobj_hpath}/stuff/prfastacq data false hsetprop ${scobj_hpath}/stuff/prfastacq mutable true - hsetprop ${scobj_hpath}/stuff/prfastacq nxsave true + hsetprop ${scobj_hpath}/stuff/prfastacq nxsave false hsetprop ${scobj_hpath}/stuff/prfastacq oldval UNKNOWN - hsetprop ${scobj_hpath}/stuff/prfastacq klass "parameter" hsetprop ${scobj_hpath}/stuff/prfastacq sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/stuff/prfastacq type "part" hsetprop ${scobj_hpath}/stuff/prfastacq nxalias "${name}_stuff_prfastacq" @@ -1528,12 +1644,11 @@ proc ::scobj::knauer_pump::mkDriver { sct_controller name device_class simulatio hfactory ${scobj_hpath}/stuff/purge plain user text hsetprop ${scobj_hpath}/stuff/purge read ${ns}::getValue ${scobj_hpath} rdValue {PURGE?} hsetprop ${scobj_hpath}/stuff/purge rdValue ${ns}::rdValue ${scobj_hpath} - hsetprop ${scobj_hpath}/stuff/purge control true - hsetprop ${scobj_hpath}/stuff/purge data true + hsetprop ${scobj_hpath}/stuff/purge control false + hsetprop ${scobj_hpath}/stuff/purge data false hsetprop ${scobj_hpath}/stuff/purge mutable true - hsetprop ${scobj_hpath}/stuff/purge nxsave true + hsetprop ${scobj_hpath}/stuff/purge nxsave false hsetprop ${scobj_hpath}/stuff/purge oldval UNKNOWN - hsetprop ${scobj_hpath}/stuff/purge klass "parameter" hsetprop ${scobj_hpath}/stuff/purge sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/stuff/purge type "part" hsetprop ${scobj_hpath}/stuff/purge nxalias "${name}_stuff_purge" @@ -1541,12 +1656,11 @@ proc ::scobj::knauer_pump::mkDriver { sct_controller name device_class simulatio hfactory ${scobj_hpath}/stuff/remote plain user text hsetprop ${scobj_hpath}/stuff/remote read ${ns}::getValue ${scobj_hpath} rdValue {REMOTE?} hsetprop ${scobj_hpath}/stuff/remote rdValue ${ns}::rdValue ${scobj_hpath} - hsetprop ${scobj_hpath}/stuff/remote control true - hsetprop ${scobj_hpath}/stuff/remote data true + hsetprop ${scobj_hpath}/stuff/remote control false + hsetprop ${scobj_hpath}/stuff/remote data false hsetprop ${scobj_hpath}/stuff/remote mutable true - hsetprop ${scobj_hpath}/stuff/remote nxsave true + hsetprop ${scobj_hpath}/stuff/remote nxsave false hsetprop ${scobj_hpath}/stuff/remote oldval UNKNOWN - hsetprop ${scobj_hpath}/stuff/remote klass "parameter" hsetprop ${scobj_hpath}/stuff/remote sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/stuff/remote type "part" hsetprop ${scobj_hpath}/stuff/remote nxalias "${name}_stuff_remote" @@ -1554,12 +1668,11 @@ proc ::scobj::knauer_pump::mkDriver { sct_controller name device_class simulatio hfactory ${scobj_hpath}/stuff/rfid plain user text hsetprop ${scobj_hpath}/stuff/rfid read ${ns}::getValue ${scobj_hpath} rdValue {RFID?} hsetprop ${scobj_hpath}/stuff/rfid rdValue ${ns}::rdValue ${scobj_hpath} - hsetprop ${scobj_hpath}/stuff/rfid control true - hsetprop ${scobj_hpath}/stuff/rfid data true + hsetprop ${scobj_hpath}/stuff/rfid control false + hsetprop ${scobj_hpath}/stuff/rfid data false hsetprop ${scobj_hpath}/stuff/rfid mutable true - hsetprop ${scobj_hpath}/stuff/rfid nxsave true + hsetprop ${scobj_hpath}/stuff/rfid nxsave false hsetprop ${scobj_hpath}/stuff/rfid oldval UNKNOWN - hsetprop ${scobj_hpath}/stuff/rfid klass "parameter" hsetprop ${scobj_hpath}/stuff/rfid sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/stuff/rfid type "part" hsetprop ${scobj_hpath}/stuff/rfid nxalias "${name}_stuff_rfid" @@ -1567,12 +1680,11 @@ proc ::scobj::knauer_pump::mkDriver { sct_controller name device_class simulatio hfactory ${scobj_hpath}/stuff/service plain user text hsetprop ${scobj_hpath}/stuff/service read ${ns}::getValue ${scobj_hpath} rdValue {SERVICE?} hsetprop ${scobj_hpath}/stuff/service rdValue ${ns}::rdValue ${scobj_hpath} - hsetprop ${scobj_hpath}/stuff/service control true - hsetprop ${scobj_hpath}/stuff/service data true + hsetprop ${scobj_hpath}/stuff/service control false + hsetprop ${scobj_hpath}/stuff/service data false hsetprop ${scobj_hpath}/stuff/service mutable true - hsetprop ${scobj_hpath}/stuff/service nxsave true + hsetprop ${scobj_hpath}/stuff/service nxsave false hsetprop ${scobj_hpath}/stuff/service oldval UNKNOWN - hsetprop ${scobj_hpath}/stuff/service klass "parameter" hsetprop ${scobj_hpath}/stuff/service sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/stuff/service type "part" hsetprop ${scobj_hpath}/stuff/service nxalias "${name}_stuff_service" @@ -1580,12 +1692,11 @@ proc ::scobj::knauer_pump::mkDriver { sct_controller name device_class simulatio hfactory ${scobj_hpath}/stuff/sysinfo plain user text hsetprop ${scobj_hpath}/stuff/sysinfo read ${ns}::getValue ${scobj_hpath} rdValue {SYSINFO?} hsetprop ${scobj_hpath}/stuff/sysinfo rdValue ${ns}::rdValue ${scobj_hpath} - hsetprop ${scobj_hpath}/stuff/sysinfo control true - hsetprop ${scobj_hpath}/stuff/sysinfo data true + hsetprop ${scobj_hpath}/stuff/sysinfo control false + hsetprop ${scobj_hpath}/stuff/sysinfo data false hsetprop ${scobj_hpath}/stuff/sysinfo mutable true - hsetprop ${scobj_hpath}/stuff/sysinfo nxsave true + hsetprop ${scobj_hpath}/stuff/sysinfo nxsave false hsetprop ${scobj_hpath}/stuff/sysinfo oldval UNKNOWN - hsetprop ${scobj_hpath}/stuff/sysinfo klass "parameter" hsetprop ${scobj_hpath}/stuff/sysinfo sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/stuff/sysinfo type "part" hsetprop ${scobj_hpath}/stuff/sysinfo nxalias "${name}_stuff_sysinfo" @@ -1593,12 +1704,11 @@ proc ::scobj::knauer_pump::mkDriver { sct_controller name device_class simulatio hfactory ${scobj_hpath}/stuff/units plain user text hsetprop ${scobj_hpath}/stuff/units read ${ns}::getValue ${scobj_hpath} rdValue {UNITS?} hsetprop ${scobj_hpath}/stuff/units rdValue ${ns}::rdValue ${scobj_hpath} - hsetprop ${scobj_hpath}/stuff/units control true - hsetprop ${scobj_hpath}/stuff/units data true + hsetprop ${scobj_hpath}/stuff/units control false + hsetprop ${scobj_hpath}/stuff/units data false hsetprop ${scobj_hpath}/stuff/units mutable true - hsetprop ${scobj_hpath}/stuff/units nxsave true + hsetprop ${scobj_hpath}/stuff/units nxsave false hsetprop ${scobj_hpath}/stuff/units oldval UNKNOWN - hsetprop ${scobj_hpath}/stuff/units klass "parameter" hsetprop ${scobj_hpath}/stuff/units sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/stuff/units type "part" hsetprop ${scobj_hpath}/stuff/units nxalias "${name}_stuff_units" @@ -1606,12 +1716,11 @@ proc ::scobj::knauer_pump::mkDriver { sct_controller name device_class simulatio hfactory ${scobj_hpath}/stuff/valves plain user text hsetprop ${scobj_hpath}/stuff/valves read ${ns}::getValue ${scobj_hpath} rdValue {VALVES?} hsetprop ${scobj_hpath}/stuff/valves rdValue ${ns}::rdValue ${scobj_hpath} - hsetprop ${scobj_hpath}/stuff/valves control true - hsetprop ${scobj_hpath}/stuff/valves data true + hsetprop ${scobj_hpath}/stuff/valves control false + hsetprop ${scobj_hpath}/stuff/valves data false hsetprop ${scobj_hpath}/stuff/valves mutable true - hsetprop ${scobj_hpath}/stuff/valves nxsave true + hsetprop ${scobj_hpath}/stuff/valves nxsave false hsetprop ${scobj_hpath}/stuff/valves oldval UNKNOWN - hsetprop ${scobj_hpath}/stuff/valves klass "parameter" hsetprop ${scobj_hpath}/stuff/valves sdsinfo "::nexus::scobj::sdsinfo" hsetprop ${scobj_hpath}/stuff/valves type "part" hsetprop ${scobj_hpath}/stuff/valves nxalias "${name}_stuff_valves" @@ -1644,63 +1753,11 @@ proc ::scobj::knauer_pump::mkDriver { sct_controller name device_class simulatio } else { ::scobj::knauer_pump::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for knauer_pump" } - - hfactory ${scobj_hpath}/volume plain spy none - hsetprop ${scobj_hpath}/volume data "true" - hsetprop ${scobj_hpath}/volume klass "@none" - hsetprop ${scobj_hpath}/volume type "part" - - hfactory ${scobj_hpath}/volume/sensor plain user float - hsetprop ${scobj_hpath}/volume/sensor read ${ns}::volume_fetch ${scobj_hpath} rdValue { } - hsetprop ${scobj_hpath}/volume/sensor rdValue ${ns}::rdValue ${scobj_hpath} - hsetprop ${scobj_hpath}/volume/sensor control true - hsetprop ${scobj_hpath}/volume/sensor data true - hsetprop ${scobj_hpath}/volume/sensor mutable true - hsetprop ${scobj_hpath}/volume/sensor nxsave true - hsetprop ${scobj_hpath}/volume/sensor oldval 0.0 - hsetprop ${scobj_hpath}/volume/sensor klass "parameter" - hsetprop ${scobj_hpath}/volume/sensor sdsinfo "::nexus::scobj::sdsinfo" - hsetprop ${scobj_hpath}/volume/sensor type "part" - hsetprop ${scobj_hpath}/volume/sensor units "mL" - hsetprop ${scobj_hpath}/volume/sensor nxalias "${name}_volume_sensor" - - hfactory ${scobj_hpath}/volume/setpoint plain user float - hsetprop ${scobj_hpath}/volume/setpoint read ${ns}::volume_checkpumping ${scobj_hpath} rdValue { } - hsetprop ${scobj_hpath}/volume/setpoint rdValue ${ns}::rdValue ${scobj_hpath} - hsetprop ${scobj_hpath}/volume/setpoint write ${ns}::volume_write ${scobj_hpath} noResponse { } - hsetprop ${scobj_hpath}/volume/setpoint noResponse ${ns}::noResponse ${scobj_hpath} - hsetprop ${scobj_hpath}/volume/setpoint check ${ns}::checkrange ${scobj_hpath} - hsetprop ${scobj_hpath}/volume/setpoint driving 0 - hsetprop ${scobj_hpath}/volume/setpoint checklimits ${ns}::checklimits ${scobj_hpath} - hsetprop ${scobj_hpath}/volume/setpoint checkstatus ${ns}::volume_checkstatus ${scobj_hpath} - hsetprop ${scobj_hpath}/volume/setpoint halt ${ns}::volume_halt ${scobj_hpath} - hsetprop ${scobj_hpath}/volume/setpoint driveable volume/sensor - hsetprop ${scobj_hpath}/volume/setpoint control true - hsetprop ${scobj_hpath}/volume/setpoint data true - hsetprop ${scobj_hpath}/volume/setpoint mutable true - hsetprop ${scobj_hpath}/volume/setpoint nxsave true - hsetprop ${scobj_hpath}/volume/setpoint lowerlimit 0 - hsetprop ${scobj_hpath}/volume/setpoint upperlimit 100 - hsetprop ${scobj_hpath}/volume/setpoint tolerance 0.01 - hsetprop ${scobj_hpath}/volume/setpoint oldval 0.0 - hsetprop ${scobj_hpath}/volume/setpoint klass "parameter" - hsetprop ${scobj_hpath}/volume/setpoint sdsinfo "::nexus::scobj::sdsinfo" - hsetprop ${scobj_hpath}/volume/setpoint type "drivable" - hsetprop ${scobj_hpath}/volume/setpoint units "mL" - hsetprop ${scobj_hpath}/volume/setpoint nxalias "${name}_volume_setpoint" - - if {[string equal -nocase "${simulation_flag}" "false"]} { - ${sct_controller} poll ${scobj_hpath}/volume/sensor 1 - ${sct_controller} poll ${scobj_hpath}/volume/setpoint 1 - ${sct_controller} write ${scobj_hpath}/volume/setpoint - } else { - ::scobj::knauer_pump::sics_log 9 "simulation_flag=${simulation_flag} => No poll/write for knauer_pump" - } hsetprop ${scobj_hpath} klass ${device_class} hsetprop ${scobj_hpath} data true hsetprop ${scobj_hpath} debug_threshold 0 if {[string equal -nocase "${simulation_flag}" "false"]} { - ansto_makesctdrive ${name}_volume_setpoint ${scobj_hpath}/volume/setpoint ${scobj_hpath}/volume/sensor ${sct_controller} + ansto_makesctdrive ${name}_pump_volume_sp ${scobj_hpath}/pump/volume_sp ${scobj_hpath}/pump/volume_pv ${sct_controller} } # mkDriver hook code goes here } catch_message ] From 85cbe1eb389bc1ba125ff2765f3e475e8f808edc Mon Sep 17 00:00:00 2001 From: Ferdi Franceschini Date: Wed, 17 Sep 2014 07:37:26 +1000 Subject: [PATCH 58/68] Use actual motor names when reporting a tasub setup error. --- tasub.c | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/tasub.c b/tasub.c index 45992104..0d476173 100644 --- a/tasub.c +++ b/tasub.c @@ -370,14 +370,14 @@ int TasUBFactory(SConnection * pCon, SicsInterp * pSics, void *pData, /* curvature motors may be missing, anything else is a serious problem */ - status += testMotor(pNew, pCon, "a1", A1); - status += testMotor(pNew, pCon, "a2", A2); - status += testMotor(pNew, pCon, "a3", A3); - status += testMotor(pNew, pCon, "a4", A4); - status += testMotor(pNew, pCon, "sgu", SGU); - status += testMotor(pNew, pCon, "sgl", SGL); - status += testMotor(pNew, pCon, "a5", A5); - status += testMotor(pNew, pCon, "a6", A6); + status += testMotor(pNew, pCon, pNew->motname[A1], A1); + status += testMotor(pNew, pCon, pNew->motname[A2], A2); + status += testMotor(pNew, pCon, pNew->motname[A3], A3); + status += testMotor(pNew, pCon, pNew->motname[A4], A4); + status += testMotor(pNew, pCon, pNew->motname[SGU], SGU); + status += testMotor(pNew, pCon, pNew->motname[SGL], SGL); + status += testMotor(pNew, pCon, pNew->motname[A5], A5); + status += testMotor(pNew, pCon, pNew->motname[A6], A6); if (status != 8) { SCWrite(pCon, "ERROR: a required motor is missing, tasub NOT installed", eError); From 0ba5045fd9a787856170ac9288f28e4338559b3e Mon Sep 17 00:00:00 2001 From: Ferdi Franceschini Date: Wed, 17 Sep 2014 07:47:17 +1000 Subject: [PATCH 59/68] Update motor configuration from ics1-taipan. Also put off renaming s1 to ms1 for magnet config. We need to make sure that there is a sample/s1 link to sample/ms1 and use ms1 in tasub. --- .../tas/config/motors/motor_configuration.tcl | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/site_ansto/instrument/tas/config/motors/motor_configuration.tcl b/site_ansto/instrument/tas/config/motors/motor_configuration.tcl index a63341d2..6e89389b 100644 --- a/site_ansto/instrument/tas/config/motors/motor_configuration.tcl +++ b/site_ansto/instrument/tas/config/motors/motor_configuration.tcl @@ -113,12 +113,14 @@ if { [ info exists ::config_dict ] } { switch $axis_config { 0 { set use_normal_config "true" + set tilt_motor_driver_type $motor_driver_type } 1 { - set magmot "ms1" + set magmot s1 set magmot_aq "mc2" set magmot_axis "A" set use_normal_config "false" + set tilt_motor_driver_type asim fileeval $cfPath(motors)/magnet_configuration.tcl } } @@ -183,7 +185,7 @@ Motor mtilt $motor_driver_type [params \ maxDecel 1\ stepsPerX 25000\ absEnc 1\ - absEncHome 79650\ + absEncHome 27115\ cntsPerX 4096] mtilt part crystal mtilt long_name mtilt @@ -206,7 +208,7 @@ Motor mtrans $motor_driver_type [params \ maxDecel 1\ stepsPerX 25000\ absEnc 1\ - absEncHome 469388\ + absEncHome 859242\ cntsPerX 4096] mtrans part crystal mtrans long_name mtrans @@ -534,7 +536,7 @@ Motor mhfocus $motor_driver_type [params \ maxSpeed 3.6\ maxAccel 1.728\ maxDecel 1.728\ - stepsPerX [expr 25000.0 * 50.0 / 360.0]\ + stepsPerX [expr -25000.0 * 50.0 / 360.0]\ absEnc 1\ bias_bits 12\ bias_bias 1540\ @@ -564,13 +566,13 @@ Motor m1 $motor_driver_type [params \ maxDecel 0.25\ stepsPerX 100000\ absEnc 1\ - absEncHome 16323070\ + absEncHome 16189898\ cntsPerX -2048] m1 part crystal m1 long_name m1 m1 softlowerlim 5 m1 softupperlim 40 -m1 home 20.45933 +m1 home 0 m1 backlash_offset -1.0 # mc4: Analyzer Tilt 1 -- Two-theta Angle From e31737379c42a6bd2292b872534b197b8e6da37f Mon Sep 17 00:00:00 2001 From: Ferdi Franceschini Date: Thu, 18 Sep 2014 17:01:30 +1000 Subject: [PATCH 60/68] SICS-780 Set attributes on environment control objects even if there are errors setting up other objects. --- site_ansto/instrument/server_config.tcl | 33 +++++++++++-------------- 1 file changed, 14 insertions(+), 19 deletions(-) diff --git a/site_ansto/instrument/server_config.tcl b/site_ansto/instrument/server_config.tcl index 64e1ece4..d4a3230d 100644 --- a/site_ansto/instrument/server_config.tcl +++ b/site_ansto/instrument/server_config.tcl @@ -254,25 +254,20 @@ proc waitaction {obj action args} { publish waitaction user proc server_set_sobj_attributes {} { - if [ catch { - motor_set_sobj_attributes - ::utility::set_motor_attributes -#XXX::utility::set_histomem_attributes - ::utility::set_sobj_attributes - ::utility::set_envcontrol_attributes - ::plc::set_sobj_attributes - ::counter::set_sobj_attributes - ::nexus::set_sobj_attributes - ::histogram_memory::set_sobj_attributes - ::utility::set_chopper_attributes - ::utility::set_sct_object_attributes -## TODO move the following to the new ansto gumxml.tcl - sicslist setatt getgumtreexml privilege internal - clientput "serverport $::serverport" - } message ] { - if {$::errorCode=="NONE"} {return $message} - return -code error $message - } + if [ catch { motor_set_sobj_attributes } msg ] { puts $msg } + if [ catch { ::utility::set_motor_attributes } msg ] { puts $msg } + #XXX::utility::set_histomem_attributes + if [ catch { ::utility::set_sobj_attributes } msg ] { puts $msg } + if [ catch { ::utility::set_envcontrol_attributes } msg ] { puts $msg } + if [ catch { ::plc::set_sobj_attributes } msg ] { puts $msg } + if [ catch { ::counter::set_sobj_attributes } msg ] { puts $msg } + if [ catch { ::nexus::set_sobj_attributes } msg ] { puts $msg } + if [ catch { ::histogram_memory::set_sobj_attributes } msg ] { puts $msg } + if [ catch { ::utility::set_chopper_attributes } msg ] { puts $msg } + if [ catch { ::utility::set_sct_object_attributes } msg ] { puts $msg } + ## TODO move the following to the new ansto gumxml.tcl + if [ catch { sicslist setatt getgumtreexml privilege internal } msg ] { puts $msg } + clientput "serverport $::serverport" } proc server_init {} { From cf386ec3efe922d57a251425e47a3bae67cfb394 Mon Sep 17 00:00:00 2001 From: Ferdi Franceschini Date: Thu, 18 Sep 2014 17:02:56 +1000 Subject: [PATCH 61/68] SICS-781 lakeshore 370 driver does not save data. --- .../temperature/lakeshore_m370.sct | 9 +- .../temperature/sct_lakeshore_m370.tcl | 117 ++++++++---------- 2 files changed, 57 insertions(+), 69 deletions(-) diff --git a/site_ansto/instrument/config/environment/temperature/lakeshore_m370.sct b/site_ansto/instrument/config/environment/temperature/lakeshore_m370.sct index 9db80f11..cbd2f769 100644 --- a/site_ansto/instrument/config/environment/temperature/lakeshore_m370.sct +++ b/site_ansto/instrument/config/environment/temperature/lakeshore_m370.sct @@ -1,15 +1,16 @@ # vim: ts=8 sts=2 sw=2 expandtab autoindent smartindent nocindent driver lakeshore_m370 = { protocol = std - sobj_priv_type = 'user float' + sobj_priv_type = 'user none' class = environment simulation_group = environment_simulation add_args = 'id tol' - make_args = 'id tol' + make_args = 'tol' + mkdriver_args = 'id' code mkDriver = {%% ::scobj::lakeshore_370::mk_sct_driver $sct_controller environment $name $tol - hsetprop ${scobj_hpath}/setpoint permlink data_set T[format "%02d" ${id}]SP01 - hsetprop ${scobj_hpath}/setpoint @description T[format "%02d" ${id}]SP01 + hsetprop ${scobj_hpath}/Loop1/setpoint permlink data_set T[format "%02d" ${id}]SP01 + hsetprop ${scobj_hpath}/Loop1/setpoint @description T[format "%02d" ${id}]SP01 hsetprop ${scobj_hpath}/Sensor/value permlink data_set T[format "%02d" ${id}]S01 hsetprop ${scobj_hpath}/Sensor/value @description T[format "%02d" ${id}]S01 %%} diff --git a/site_ansto/instrument/config/environment/temperature/sct_lakeshore_m370.tcl b/site_ansto/instrument/config/environment/temperature/sct_lakeshore_m370.tcl index 401527b9..c959e923 100644 --- a/site_ansto/instrument/config/environment/temperature/sct_lakeshore_m370.tcl +++ b/site_ansto/instrument/config/environment/temperature/sct_lakeshore_m370.tcl @@ -27,24 +27,23 @@ proc ::scobj::lakeshore_m370::sics_log {debug_level debug_string} { } catch_message ] } -proc ::scobj::lakeshore_m370::mkDriver { sct_controller name device_class simulation_flag ip_address tcp_port id tol } { - ::scobj::lakeshore_m370::sics_log 9 "::scobj::lakeshore_m370::mkDriver ${sct_controller} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${tol}" +proc ::scobj::lakeshore_m370::mkDriver { sct_controller name id tol} { + ::scobj::lakeshore_m370::sics_log 9 "::scobj::lakeshore_m370::mkDriver ${sct_controller} ${name} ${id} ${tol}" set ns "[namespace current]" set catch_status [ catch { - MakeSICSObj ${name} SCT_OBJECT user float + MakeSICSObj ${name} SCT_OBJECT user none - sicslist setatt ${name} klass ${device_class} + sicslist setatt ${name} klass environment sicslist setatt ${name} long_name ${name} set scobj_hpath /sics/${name} - hsetprop ${scobj_hpath} klass ${device_class} - hsetprop ${scobj_hpath} data true + hsetprop ${scobj_hpath} klass environment hsetprop ${scobj_hpath} debug_threshold 5 # mkDriver hook code starts ::scobj::lakeshore_370::mk_sct_driver $sct_controller environment $name $tol - hsetprop ${scobj_hpath}/setpoint permlink data_set T[format "%02d" ${id}]SP01 - hsetprop ${scobj_hpath}/setpoint @description T[format "%02d" ${id}]SP01 + hsetprop ${scobj_hpath}/Loop1/setpoint permlink data_set T[format "%02d" ${id}]SP01 + hsetprop ${scobj_hpath}/Loop1/setpoint @description T[format "%02d" ${id}]SP01 hsetprop ${scobj_hpath}/Sensor/value permlink data_set T[format "%02d" ${id}]S01 hsetprop ${scobj_hpath}/Sensor/value @description T[format "%02d" ${id}]S01 # mkDriver hook code ends @@ -52,37 +51,31 @@ proc ::scobj::lakeshore_m370::mkDriver { sct_controller name device_class simula handle_exception ${catch_status} ${catch_message} } -proc ::scobj::lakeshore_m370::add_driver {name device_class simulation_flag ip_address tcp_port id tol} { - set catch_status [ catch { - ::scobj::lakeshore_m370::sics_log 9 "::scobj::lakeshore_m370::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${tol}" - if {[string equal -nocase "${simulation_flag}" "false"]} { - if {[string equal -nocase "aqadapter" "${ip_address}"]} { - ::scobj::lakeshore_m370::sics_log 9 "makesctcontroller sct_${name} aqadapter ${tcp_port}" - makesctcontroller sct_${name} aqadapter ${tcp_port} - } else { - ::scobj::lakeshore_m370::sics_log 9 "makesctcontroller sct_${name} std ${ip_address}:${tcp_port}" - makesctcontroller sct_${name} std ${ip_address}:${tcp_port} - } - } else { - ::scobj::lakeshore_m370::sics_log 9 "simulation_flag={simulation_flag} => No sctcontroller for lakeshore_m370" - } - ::scobj::lakeshore_m370::sics_log 1 "::scobj::lakeshore_m370::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${tol}" - ::scobj::lakeshore_m370::mkDriver sct_${name} ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} ${id} ${tol} - } catch_message ] - handle_exception ${catch_status} ${catch_message} -} - namespace eval ::scobj::lakeshore_m370 { namespace export debug_threshold namespace export debug_log namespace export sics_log namespace export mkDriver - namespace export add_driver } -proc add_lakeshore_m370 {name ip_address tcp_port id tol} { - set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" - ::scobj::lakeshore_m370::add_driver ${name} "environment" "${simulation_flag}" ${ip_address} ${tcp_port} "${id}" "${tol}" +proc add_lakeshore_m370 {name IP port id tol} { + set catch_status [ catch { + ::scobj::lakeshore_m370::sics_log 9 "add_lakeshore_m370 ${name} ${IP} ${port} ${tol}" + if {[string equal -nocase [SplitReply [environment_simulation]] "false"]} { + if {[string equal -nocase "aqadapter" "${IP}"]} { + ::scobj::lakeshore_m370::sics_log 9 "makesctcontroller sct_${name} aqadapter ${port}" + makesctcontroller sct_${name} aqadapter ${port} + } else { + ::scobj::lakeshore_m370::sics_log 9 "makesctcontroller sct_${name} std ${IP}:${port}" + makesctcontroller sct_${name} std ${IP}:${port} + } + } else { + ::scobj::lakeshore_m370::sics_log 9 "[environment_simulation] => No sctcontroller for lakeshore_m370" + } + ::scobj::lakeshore_m370::sics_log 1 "::scobj::lakeshore_m370::mkDriver sct_${name} ${name} ${id} ${tol}" + ::scobj::lakeshore_m370::mkDriver sct_${name} ${name} ${id} ${tol} + } catch_message ] + handle_exception ${catch_status} ${catch_message} } clientput "file evaluation of sct_lakeshore_m370.tcl" @@ -91,41 +84,42 @@ clientput "file evaluation of sct_lakeshore_m370.tcl" proc ::scobj::lakeshore_m370::read_config {} { set catch_status [ catch { set ns "::scobj::lakeshore_m370" - dict for {k u} $::config_dict { - if { [dict exists $u "implementation"] } { - set simulation_flag "[string tolower [SplitReply [environment_simulation]]]" - set device_class "environment" - if { !([dict exists $u "name"] && [dict exists $u "enabled"]) } { + dict for {k v} $::config_dict { + if { [dict exists $v "implementation"] } { + if { !([dict exists $v "name"] && [dict exists $v "enabled"]) } { continue } - set enabled [string tolower [dict get $u "enabled"]] + set enabled [string tolower [dict get $v "enabled"]] if { ! ([string equal -nocase $enabled "true" ] || [string equal -nocase $enabled "always"]) } { continue } - if { [dict exists $u "simulation_group"] } { - set simulation_flag [SplitReply [[string tolower [dict get $u "simulation_group"]]]] - } - if { [dict exists $u "device_class"] } { - set device_class "[dict get $u "device_class"]" - } - set name [dict get $u name] - set implementation [dict get $u "implementation"] + set name [dict get $v name] + set implementation [dict get $v "implementation"] if { !([dict exists $::config_dict $implementation]) } { continue } + set arg_list [list] + foreach arg {id} { + if {[dict exists $v $arg]} { + lappend arg_list "[dict get $v $arg]" + } else { + ${ns}::sics_log 9 "Missing configuration value $arg" + error "Missing configuration value $arg" + } + } set v [dict get $::config_dict $implementation] if { !([dict exists $v "driver"]) } { continue } if { [string equal -nocase [dict get $v "driver"] "lakeshore_m370"] } { - if { ![string equal -nocase "${simulation_flag}" "false"] } { + if { ![string equal -nocase [SplitReply [environment_simulation]] "false"] } { set asyncqueue "null" - ${ns}::sics_log 9 "simulation_flag=${simulation_flag} => using null asyncqueue" + ${ns}::sics_log 9 "[environment_simulation] => using null asyncqueue" } elseif { [dict exists $v "asyncqueue"] } { set asyncqueue [dict get $v "asyncqueue"] if { [string equal -nocase ${asyncqueue} "sct"] } { - set ip_address [dict get $v ip] - set tcp_port [dict get $v port] + set IP [dict get $v ip] + set PORT [dict get $v port] } } else { if { [dict exists $v "asyncprotocol"] } { @@ -139,32 +133,25 @@ proc ::scobj::lakeshore_m370::read_config {} { } } set asyncqueue ${name}_queue - set ip_address [dict get $v ip] - set tcp_port [dict get $v port] - MakeAsyncQueue ${asyncqueue} ${asyncprotocol} ${ip_address} ${tcp_port} + set IP [dict get $v ip] + set PORT [dict get $v port] + MakeAsyncQueue ${asyncqueue} ${asyncprotocol} ${IP} ${PORT} if { [dict exists $v "timeout"] } { ${asyncqueue} timeout "[dict get $v "timeout"]" } } - set arg_list [list] - set missing_list [list] - foreach arg {id tol} { - if {[dict exists $u $arg]} { - lappend arg_list "[dict get $u $arg]" - } elseif {[dict exists $v $arg]} { + foreach arg {tol} { + if {[dict exists $v $arg]} { lappend arg_list "[dict get $v $arg]" } else { ${ns}::sics_log 9 "Missing configuration value $arg" - lappend missing_list $arg + error "Missing configuration value $arg" } } - if { [llength $missing_list] > 0 } { - error "$name is missing configuration values $missing_list" - } if { [string equal -nocase ${asyncqueue} "sct"] } { - ${ns}::add_driver ${name} ${device_class} ${simulation_flag} ${ip_address} ${tcp_port} {*}$arg_list + add_lakeshore_m370 ${name} ${IP} ${PORT} {*}$arg_list } else { - ${ns}::add_driver ${name} ${device_class} ${simulation_flag} "aqadapter" ${asyncqueue} {*}$arg_list + add_lakeshore_m370 ${name} "aqadapter" ${asyncqueue} {*}$arg_list } } } From 018ba901897eb1321f933c5dedff686f5aa46657 Mon Sep 17 00:00:00 2001 From: Ferdi Franceschini Date: Thu, 18 Sep 2014 17:05:01 +1000 Subject: [PATCH 62/68] SICS-783 Load extra environment driver configurations for Echidna. --- .../instrument/hrpd/echidna_configuration.tcl | 36 ++++++++++++++----- .../instrument/hrpd/util/sics_config.ini | 8 +++++ 2 files changed, 35 insertions(+), 9 deletions(-) diff --git a/site_ansto/instrument/hrpd/echidna_configuration.tcl b/site_ansto/instrument/hrpd/echidna_configuration.tcl index d8b7e518..975afd82 100644 --- a/site_ansto/instrument/hrpd/echidna_configuration.tcl +++ b/site_ansto/instrument/hrpd/echidna_configuration.tcl @@ -25,19 +25,37 @@ source $cfPath(hipadaba)/hipadaba_configuration.tcl fileeval $cfPath(motors)/positmotor_configuration.tcl fileeval $cfPath(plc)/plc.tcl fileeval $cfPath(counter)/counter.tcl -#TODO Provide method for choosing environment controller +fileeval $cfPath(environment)/sct_agilent_33220A.tcl +fileeval $cfPath(environment)/sct_hiden_xcs.tcl +fileeval $cfPath(environment)/sct_huber_pilot.tcl +fileeval $cfPath(environment)/sct_isotech_ps.tcl fileeval $cfPath(environment)/temperature/sct_eurotherm_2000.tcl +fileeval $cfPath(environment)/temperature/sct_eurotherm_m2000.tcl fileeval $cfPath(environment)/sct_keithley_2700.tcl -fileeval $cfPath(environment)/magneticField/sct_green_magnet.tcl +fileeval $cfPath(environment)/sct_keithley_m2700.tcl +fileeval $cfPath(environment)/temperature/sct_lakeshore_218.tcl +fileeval $cfPath(environment)/temperature/sct_lakeshore_336.tcl +fileeval $cfPath(environment)/temperature/sct_ls336.tcl +fileeval $cfPath(environment)/temperature/sct_lakeshore_340.tcl +fileeval $cfPath(environment)/temperature/sct_ls340.tcl +fileeval $cfPath(environment)/temperature/sct_lakeshore_370.tcl +fileeval $cfPath(environment)/temperature/sct_lakeshore_m370.tcl +fileeval $cfPath(environment)/temperature/sct_mercury_base.tcl +fileeval $cfPath(environment)/temperature/sct_mercury_level.tcl +fileeval $cfPath(environment)/temperature/sct_mercury_pres.tcl +fileeval $cfPath(environment)/temperature/sct_mercury_scpi.tcl +fileeval $cfPath(environment)/temperature/sct_mercury_temp.tcl +fileeval $cfPath(environment)/temperature/sct_mercury_valve.tcl +fileeval $cfPath(environment)/sct_protek_common.tcl +fileeval $cfPath(environment)/sct_protekmm.tcl +fileeval $cfPath(environment)/temperature/west400.tcl +fileeval $cfPath(environment)/temperature/sct_west4100.tcl +fileeval $cfPath(environment)/temperature/sct_watlow_pm.tcl fileeval $cfPath(environment)/magneticField/sct_oxford_labview.tcl fileeval $cfPath(environment)/magneticField/sct_oxford12tlv.tcl -fileeval $cfPath(environment)/sct_keithley_2700.tcl -fileeval $cfPath(environment)/temperature/sct_lakeshore_336.tcl -fileeval $cfPath(environment)/temperature/sct_lakeshore_340.tcl -fileeval $cfPath(environment)/temperature/sct_oxford_mercury.tcl -fileeval $cfPath(environment)/temperature/sct_mercury_scpi.tcl -fileeval $cfPath(environment)/temperature/west400.tcl -fileeval $cfPath(environment)/temperature/sct_watlow_pm.tcl +fileeval $cfPath(environment)/he3/sct_he3.tcl +fileeval $cfPath(environment)/magneticField/sct_green_magnet.tcl +fileeval $cfPath(environment)/magneticField/sct_green_magnet_labview.tcl fileeval $cfPath(hmm)/hmm_configuration.tcl fileeval $cfPath(nexus)/nxscripts.tcl fileeval $cfPath(scan)/scan.tcl diff --git a/site_ansto/instrument/hrpd/util/sics_config.ini b/site_ansto/instrument/hrpd/util/sics_config.ini index b8011634..41b97e48 100644 --- a/site_ansto/instrument/hrpd/util/sics_config.ini +++ b/site_ansto/instrument/hrpd/util/sics_config.ini @@ -246,6 +246,14 @@ terminator = \r\n tol1 = 1.0 tol2 = 1.0 +[ls370_1] +desc = "Lakeshore 370 Resistance Bridge" +driver = "lakeshore_m370" +imptype = temperature +ip = 10.157.205.42 +port = 4001 +tol = 1.0 + [mercury_scpi_01] desc = "Oxford Mercury temperature controller in Mercury mode" driver = "mercury_scpi" From 84cc1d5b4ce8f1ac470b9fd431366ebbc6174c79 Mon Sep 17 00:00:00 2001 From: Ferdi Franceschini Date: Thu, 18 Sep 2014 17:20:53 +1000 Subject: [PATCH 63/68] SICS-782 Configure autofocussing on Taipan. --- site_ansto/instrument/tas/taipan_configuration.tcl | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/site_ansto/instrument/tas/taipan_configuration.tcl b/site_ansto/instrument/tas/taipan_configuration.tcl index 2e910fc4..189815c0 100644 --- a/site_ansto/instrument/tas/taipan_configuration.tcl +++ b/site_ansto/instrument/tas/taipan_configuration.tcl @@ -61,9 +61,21 @@ source gumxml.tcl # init for the tasUB #make mcv mch acv ach into mvfocus mhfocus avfocus ahfocus when it works puts "doing tasub" -MakeTasUB tasub m1 m2 mcv mch s1 s2 sgu sgl a1 a2 acv ach +MakeTasUB tasub m1 m2 mvfocus mhfocus s1 s2 sgu sgl a1 a2 avfocus ahfocus tasub mono dd 3.35416 tasub ana dd 3.35416 +tasub mono vb1 102.2 +tasub mono vb2 1.78 +tasub mono hb1 184.42 +tasub mono hb2 -60.1 +tasub mono hb3 0.951 +tasub ana vb1 115 +tasub ana vb2 2.13 +tasub ana hb1 45.68 +tasub ana hb2 105.7 +tasub ana hb3 0.945 +tasub focusfn energy +tasub autofocus 0 tasub updatetargets puts "done tasub" From cca9029270c5825964726862cc27ac47c2c3e850 Mon Sep 17 00:00:00 2001 From: Ferdi Franceschini Date: Fri, 19 Sep 2014 12:17:28 +1000 Subject: [PATCH 64/68] Enable plc on Dingo --- site_ansto/instrument/dingo/dingo_configuration.tcl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/site_ansto/instrument/dingo/dingo_configuration.tcl b/site_ansto/instrument/dingo/dingo_configuration.tcl index 0c6c3804..7e044f44 100644 --- a/site_ansto/instrument/dingo/dingo_configuration.tcl +++ b/site_ansto/instrument/dingo/dingo_configuration.tcl @@ -21,7 +21,7 @@ fileeval $cfPath(source)/source.tcl fileeval $cfPath(motors)/motor_configuration.tcl #fileeval $cfPath(motors)/positmotor_configuration.tcl #fileeval $cfPath(motors)/extraconfig.tcl -#fileeval $cfPath(plc)/plc.tcl +fileeval $cfPath(plc)/plc.tcl #fileeval $cfPath(counter)/counter.tcl #fileeval $cfPath(hmm)/hmm_configuration.tcl fileeval $cfPath(nexus)/nxscripts.tcl From 9f8d01bebe01aee2537763bb441cfc6fb4371a8b Mon Sep 17 00:00:00 2001 From: Ferdi Franceschini Date: Fri, 19 Sep 2014 14:53:06 +1000 Subject: [PATCH 65/68] SICS-785 Use scientific notation to return small floats in SICSvariables. --- sicvar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sicvar.c b/sicvar.c index be6d8e07..125277e4 100644 --- a/sicvar.c +++ b/sicvar.c @@ -456,7 +456,7 @@ int VarWrapper(SConnection * pCon, SicsInterp * pInterp, void *pData, return 1; case veFloat: VarGetFloat(pVar, &fVal); - snprintf(pBueffel,sizeof(pBueffel)-1, "%s = %f", argv[0], fVal); + snprintf(pBueffel,sizeof(pBueffel)-1, "%s = %g", argv[0], fVal); SCWrite(pCon, pBueffel, eValue); DeleteTokenList(pList); return 1; From cf775888614cfb18381a2f2896899212e8d3a0a2 Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Fri, 19 Sep 2014 15:14:47 +1000 Subject: [PATCH 66/68] Add some more checking and fix drive end bug --- .../config/environment/knauer_pump.sct | 56 ++++++++++++++++--- 1 file changed, 48 insertions(+), 8 deletions(-) diff --git a/site_ansto/instrument/config/environment/knauer_pump.sct b/site_ansto/instrument/config/environment/knauer_pump.sct index a8c3bd43..7d78e18a 100644 --- a/site_ansto/instrument/config/environment/knauer_pump.sct +++ b/site_ansto/instrument/config/environment/knauer_pump.sct @@ -11,10 +11,15 @@ driver knauer_pump = { group dummy = { type = text; readable = 1; data = false; control = false; nxsave = false; var status = { read_command = 'STATUS?'; read_function = read_status; } - var glp = { read_command = 'GLP?'; read_function = read_glp; } + var glp = { read_command = 'GLP?'; read_function = read_glp; property real_data = ' '; } } group pump = { + var remote = { + type = int; + readable = 1; read_command = 'REMOTE?'; read_function = remote_read; + writeable = 1; write_function = remote_write; + } var state = { type = text; readable = 1; @@ -157,7 +162,11 @@ driver knauer_pump = { set index ${cmd_str} set data [hgetpropval ${tc_root}/dummy/glp real_data] set dlist [split ${data} ","] - sct result [lindex ${dlist} ${index}] + if { [llength ${dlist}] > ${index} } { + sct result [lindex ${dlist} ${index}] + } else { + sct result "" + } set cmd "@@NOSEND@@" %%} @@ -165,14 +174,21 @@ driver knauer_pump = { set index ${cmd_str} set data [hgetpropval ${tc_root}/dummy/status real_data] set dlist [split ${data} ","] - sct result [lindex ${dlist} ${index}] + if { [llength ${dlist}] > ${index} } { + sct result [lindex ${dlist} ${index}] + } else { + sct result "" + } set cmd "@@NOSEND@@" %%} code read_glp = {%% - set dlist [split [lindex [split ${data} ":"] 1] ","] - sct real_data "[join [lrange ${dlist} 0 end] ,]" - set data "Hidden in real_data property" + if { [string equal -nocase -length 6 ${data} "ERROR:"] } { + } else { + set dlist [split [lindex [split ${data} ":"] 1] ","] + sct real_data "[join [lrange ${dlist} 0 end] ,]" + set data "Hidden in real_data property" + } %%} code read_status = {%% set dlist [split [lindex [split ${data} ":"] 1] ","] @@ -271,6 +287,22 @@ driver knauer_pump = { } %%} + code remote_read = {%% + if { [string equal -length 7 ${data} "REMOTE:"] } { + set data [lindex [split ${data} :] 1] + } else { + sct geterror "bad response" + error "[sct geterror]" + } + %%} + + code remote_write = {%% + if { ${par} == 0 } { + set cmd "LOCAL" + } else { + set cmd "REMOTE" + } + %%} code volume_fetch = {%% set data [hgetpropval ${tc_root}/dummy/glp real_data] set dlist [split ${data} ","] @@ -284,10 +316,10 @@ driver knauer_pump = { sct raw_volume ${pump_volume} if { [hpropexists [sct] base_volume] } { set pump_volume [expr {${pump_volume} - [sct base_volume]}] - } else { + } elseif { [hpropexists [sct] raw_volume] } { sct base_volume [sct raw_volume] } - sct result ${pump_volume} + sct result [format "%.2f" ${pump_volume}] set cmd "@@NOSEND@@" %%} code volume_write = {%% @@ -297,6 +329,13 @@ driver knauer_pump = { set ratio_tgt [join [split [hval ${tc_root}/pump/ratio_sp] /] ,] set cmd "RAMP:0,${flow_tgt},${ratio_tgt},0,0,0,0,0,0,0,0,3" sct pumping 1 + set data ${par} + if { ${data} != [sct oldval] } { + debug_log ${tc_root} 1 "[sct] changed to new:${data}, from old:[sct oldval]" + sct oldval ${data} + sct update ${data} + sct utime readtime + } %%} code volume_checkpumping = {%% @@ -313,6 +352,7 @@ driver knauer_pump = { set ratio_tgt [join [split [hval ${tc_root}/pump/ratio_sp] /] ,] set cmd "RAMP:0,${flow_tgt},${ratio_tgt},0,0,0,0,0,0,0,0,2" set nextState noResponse + sct driving 0 sct pumping 0 } } From 98b5a892257283e78134689f9a0f524f8b905379 Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Fri, 26 Sep 2014 15:25:52 +1000 Subject: [PATCH 67/68] There is no mkdriver_args --- .../config/environment/temperature/lakeshore_m370.sct | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/site_ansto/instrument/config/environment/temperature/lakeshore_m370.sct b/site_ansto/instrument/config/environment/temperature/lakeshore_m370.sct index cbd2f769..d33dc87a 100644 --- a/site_ansto/instrument/config/environment/temperature/lakeshore_m370.sct +++ b/site_ansto/instrument/config/environment/temperature/lakeshore_m370.sct @@ -5,8 +5,7 @@ driver lakeshore_m370 = { class = environment simulation_group = environment_simulation add_args = 'id tol' - make_args = 'tol' - mkdriver_args = 'id' + make_args = 'id tol' code mkDriver = {%% ::scobj::lakeshore_370::mk_sct_driver $sct_controller environment $name $tol hsetprop ${scobj_hpath}/Loop1/setpoint permlink data_set T[format "%02d" ${id}]SP01 From 5bedffc9c344711a12d418457e579a0b77f4d308 Mon Sep 17 00:00:00 2001 From: Douglas Clowes Date: Fri, 26 Sep 2014 14:06:04 +1000 Subject: [PATCH 68/68] Strip the date and time from server_date_time in FILEMAP.TXT --- site_ansto/instrument/deploySICS.sh | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/site_ansto/instrument/deploySICS.sh b/site_ansto/instrument/deploySICS.sh index e2fffe72..d5ab79a6 100755 --- a/site_ansto/instrument/deploySICS.sh +++ b/site_ansto/instrument/deploySICS.sh @@ -247,6 +247,10 @@ cat PATCH.TXT > $TEMPDIR/$DESTDIR/${NEWSERVER}/PATCH.TXT fi cat $SRCDIR/MANIFEST.TXT $SRCDIR/$INSTSRC/MANIFEST.TXT > $TEMPDIR/$DESTDIR/${NEWSERVER}/MANIFEST.TXT +# Strip the date and time from FILEMAP +echo sed -i $FILEMAP -e s/${NEWSERVER}/server/ +sed -i $FILEMAP -e s/${NEWSERVER}/server/ + cd $TEMPDIR # remove any .svn directories rm -rf $(find $TARDIR -type d -name .svn)