Make sure spin flipper code in rfamp.c is initialised
Fixed drive bugs in lakeshore drivers. r3071 | ffr | 2011-02-25 18:27:31 +1100 (Fri, 25 Feb 2011) | 2 lines
This commit is contained in:
committed by
Douglas Clowes
parent
009fdbfc29
commit
7371a561d9
68
.cproject
Normal file
68
.cproject
Normal file
@@ -0,0 +1,68 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<?fileVersion 4.0.0?>
|
||||
|
||||
<cproject storage_type_id="org.eclipse.cdt.core.XmlProjectDescriptionStorage">
|
||||
<storageModule moduleId="org.eclipse.cdt.core.settings">
|
||||
<cconfiguration id="converted.config.523014">
|
||||
<storageModule moduleId="org.eclipse.cdt.core.pathentry">
|
||||
<pathentry kind="src" path=""/>
|
||||
<pathentry kind="out" path=""/>
|
||||
<pathentry kind="con" path="org.eclipse.cdt.make.core.DISCOVERED_SCANNER_INFO"/>
|
||||
</storageModule>
|
||||
<storageModule moduleId="cdt_indexer">
|
||||
<indexEnabled indexValue="true"/>
|
||||
<indexerProblemsEnabled indexProblemsValue="0"/>
|
||||
</storageModule>
|
||||
<storageModule moduleId="scannerConfiguration">
|
||||
<autodiscovery enabled="true" problemReportingEnabled="true" selectedProfileId="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile"/>
|
||||
<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerProjectProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="true" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
|
||||
<parser enabled="true"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.make.core.GCCStandardMakePerFileProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="false" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="makefileGenerator">
|
||||
<runAction arguments="-f ${project_name}_scd.mk" command="make" useDefault="true"/>
|
||||
<parser enabled="false"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCManagedMakePerProjectProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="false" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
|
||||
<parser enabled="false"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
<profile id="org.eclipse.cdt.managedbuilder.core.GCCWinManagedMakePerProjectProfile">
|
||||
<buildOutputProvider>
|
||||
<openAction enabled="false" filePath=""/>
|
||||
<parser enabled="true"/>
|
||||
</buildOutputProvider>
|
||||
<scannerInfoProvider id="specsFile">
|
||||
<runAction arguments="-E -P -v -dD ${plugin_state_location}/${specs_file}" command="gcc" useDefault="true"/>
|
||||
<parser enabled="false"/>
|
||||
</scannerInfoProvider>
|
||||
</profile>
|
||||
</storageModule>
|
||||
<storageModule buildSystemId="org.eclipse.cdt.core.defaultConfigDataProvider" id="converted.config.523014" moduleId="org.eclipse.cdt.core.settings" name="convertedConfig">
|
||||
<externalSettings/>
|
||||
<extensions>
|
||||
<extension id="org.eclipse.cdt.core.ctagsindexer" point="org.eclipse.cdt.core.CIndexer"/>
|
||||
<extension id="org.eclipse.cdt.core.ELF" point="org.eclipse.cdt.core.BinaryParser"/>
|
||||
</extensions>
|
||||
</storageModule>
|
||||
</cconfiguration>
|
||||
</storageModule>
|
||||
</cproject>
|
||||
@@ -108,6 +108,7 @@ static long SCTDRIVSetValue(void *data, SConnection *pCon, float val){
|
||||
v.dataType = HIPFLOAT;
|
||||
v.v.doubleValue = (double)val;
|
||||
SetHdbProperty(self->write_node,"writestatus", "start");
|
||||
SetHdbProperty(self->write_node,"driving", "1");
|
||||
status = SetHipadabaPar(self->write_node, v, pCon);
|
||||
if(status == 1){
|
||||
return OKOK;
|
||||
|
||||
261
site_ansto/hardsup/oldsct_modbusprot.c
Normal file
261
site_ansto/hardsup/oldsct_modbusprot.c
Normal file
@@ -0,0 +1,261 @@
|
||||
/** @file Modbus protocol handler for script-context based controllers.
|
||||
*
|
||||
*/
|
||||
#include <errno.h>
|
||||
#include <ascon.h>
|
||||
#include <ascon.i>
|
||||
#include <dynstring.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
static int dbgprintf(char* fmtstr, ...);
|
||||
static int dbgprintx(const char* msg, const unsigned char* cp, int blen);
|
||||
static unsigned int debug_modbus = 1;
|
||||
|
||||
/** @brief encode modbus request
|
||||
* TODO: clean me up
|
||||
*/
|
||||
int ModbusWriteStart(Ascon *a) {
|
||||
unsigned int dev, cmd, reg;
|
||||
int len = GetDynStringLength(a->wrBuffer);
|
||||
char* buff = NULL;
|
||||
char temp[32];
|
||||
char* endp = NULL;
|
||||
int idx = 6;
|
||||
bool do_float = false;
|
||||
temp[0] = 0; /* transaction id */
|
||||
temp[1] = 0;
|
||||
temp[2] = 0; /* protocol id */
|
||||
temp[3] = 0;
|
||||
|
||||
DynStringConcatChar(a->wrBuffer, 0);
|
||||
buff = GetCharArray(a->wrBuffer);
|
||||
dbgprintf("modbus-wr:%s\n", buff);
|
||||
dev = strtoul(buff, &endp, 10);
|
||||
if (endp == buff || dev < 1 || dev > 39) {
|
||||
dbgprintf("modbus-er: Bad device id: %d from %s\n", dev, buff);
|
||||
a->state = AsconIdle;
|
||||
AsconError(a, "Bad device id", 0);
|
||||
return 0;
|
||||
}
|
||||
temp[idx++] = dev;
|
||||
buff = endp + 1;
|
||||
cmd = strtoul(buff, &endp, 10);
|
||||
if (endp == buff || (cmd != 3 && cmd != 16 && cmd != 1003 && cmd != 1016)) { /* read/write registers */
|
||||
dbgprintf("modbus-er: Bad command id: %d from %s\n", cmd, buff);
|
||||
a->state = AsconIdle;
|
||||
AsconError(a, "Bad command id", 0);
|
||||
return 0;
|
||||
}
|
||||
if (cmd > 1000) {
|
||||
cmd %= 1000;
|
||||
do_float = true;
|
||||
} else {
|
||||
do_float = false;
|
||||
}
|
||||
temp[idx++] = cmd;
|
||||
buff = endp + 1;
|
||||
reg = strtoul(buff, &endp, 10);
|
||||
if (endp == buff || reg > 65535) {
|
||||
dbgprintf("modbus-er: Bad register id: %d from %s\n", reg, buff);
|
||||
a->state = AsconIdle;
|
||||
AsconError(a, "Bad register id", 0);
|
||||
return 0;
|
||||
}
|
||||
temp[idx++] = (reg >> 8) & 0xFF;
|
||||
temp[idx++] = reg & 0xFF;
|
||||
temp[idx++] = 0; /* word count msbyte */
|
||||
if (do_float)
|
||||
temp[idx++] = 2; /* word count lsbyte */
|
||||
else
|
||||
temp[idx++] = 1; /* word count lsbyte */
|
||||
if (cmd == 16) { /* write registers */
|
||||
buff = endp + 1;
|
||||
if (do_float) {
|
||||
union { unsigned char v[4]; float val; } u;
|
||||
u.val = strtof(buff, &endp);
|
||||
if (endp == buff) {
|
||||
dbgprintf("modbus-er: Bad value: %f from %s\n", u.val, buff);
|
||||
a->state = AsconIdle;
|
||||
AsconError(a, "Bad value", 0);
|
||||
return 0;
|
||||
}
|
||||
temp[idx++] = 4; /* byte count */
|
||||
temp[idx++] = u.v[1];
|
||||
temp[idx++] = u.v[0];
|
||||
temp[idx++] = u.v[3];
|
||||
temp[idx++] = u.v[2];
|
||||
} else {
|
||||
unsigned int val;
|
||||
val = strtoul(buff, &endp, 10);
|
||||
if (endp == buff || val > 65535) {
|
||||
dbgprintf("modbus-er: Bad value: %d from %s\n", val, buff);
|
||||
a->state = AsconIdle;
|
||||
AsconError(a, "Bad value", 0);
|
||||
return 0;
|
||||
}
|
||||
temp[idx++] = 2; /* byte count */
|
||||
temp[idx++] = (val >> 8) & 0xFF;
|
||||
temp[idx++] = val & 0xFF;
|
||||
}
|
||||
}
|
||||
len = idx - 6;
|
||||
temp[4] = len >> 8; /* length msbyte */
|
||||
temp[5] = len & 0xFF; /* length lsbyte */
|
||||
|
||||
if (debug_modbus > 0) {
|
||||
dbgprintx("modbus-xo", (unsigned char*)temp, idx);
|
||||
}
|
||||
DynStringReplaceWithLen(a->wrBuffer, temp, 0, idx);
|
||||
a->state = AsconWriting;
|
||||
a->wrPos = 0;
|
||||
return 1;
|
||||
}
|
||||
|
||||
/** @brief decode modbus response
|
||||
* TODO: clean me up
|
||||
*/
|
||||
int ModbusReading(Ascon *a) {
|
||||
int ret, blen, rlen;
|
||||
char chr = '\0';
|
||||
unsigned char* cp = NULL;
|
||||
|
||||
ret = AsconReadChar(a->fd, &chr);
|
||||
while (ret > 0) {
|
||||
a->start = DoubleTime();
|
||||
|
||||
DynStringConcatChar(a->rdBuffer, chr);
|
||||
cp = (unsigned char*) GetCharArray(a->rdBuffer);
|
||||
blen = GetDynStringLength(a->rdBuffer);
|
||||
if (debug_modbus > 0) {
|
||||
dbgprintx("modbus-xi", cp, blen);
|
||||
}
|
||||
if (blen >= 6) {
|
||||
int mlen = (cp[4] << 8) + cp[5];
|
||||
if (blen - 6 >= mlen) {
|
||||
char temp[64];
|
||||
if (cp[7] == 3 && cp[8] == 2) {
|
||||
rlen = snprintf(temp, 64, "%d", (((unsigned int)cp[9]) << 8) + (unsigned int)cp[10]);
|
||||
}
|
||||
else if (cp[7] == 3 && cp[8] == 4) {
|
||||
union { unsigned char v[4]; float val; } u;
|
||||
u.v[1] = cp[9];
|
||||
u.v[0] = cp[10];
|
||||
u.v[3] = cp[11];
|
||||
u.v[2] = cp[12];
|
||||
rlen = snprintf(temp, 64, "%g", u.val);
|
||||
}
|
||||
else if (cp[7] == 16 && cp[11] == 1) {
|
||||
rlen = snprintf(temp, 64, "OK int");
|
||||
}
|
||||
else if (cp[7] == 16 && cp[11] == 2) {
|
||||
rlen = snprintf(temp, 64, "OK float");
|
||||
}
|
||||
else if (((unsigned int)cp[7]) == 0x83) {
|
||||
rlen = snprintf(temp, 64, "ASCERR:%02x:%d", cp[7], cp[8]);
|
||||
}
|
||||
else if (((unsigned int)cp[7]) == 0x90) {
|
||||
rlen = snprintf(temp, 64, "ASCERR:%02x:%d", cp[7], cp[8]);
|
||||
}
|
||||
else {
|
||||
rlen = snprintf(temp, 64, "ASCERR:%02x:%d", cp[7], cp[8]);
|
||||
}
|
||||
if (debug_modbus > 0) {
|
||||
dbgprintx("modbus-xi", cp, blen);
|
||||
}
|
||||
dbgprintf("modbus-rd:%s\n", temp);
|
||||
DynStringReplaceWithLen(a->rdBuffer, temp, 0, rlen);
|
||||
a->state = AsconReadDone;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
ret = AsconReadChar(a->fd, &chr);
|
||||
}
|
||||
if (ret < 0) {
|
||||
AsconError(a, "AsconReadChar failed:", errno);
|
||||
return 0;
|
||||
}
|
||||
if (a->state == AsconReadDone) {
|
||||
DynStringConcatChar(a->rdBuffer, '\0');
|
||||
} else {
|
||||
if (a->timeout > 0) {
|
||||
if (DoubleTime() - a->start > a->timeout) {
|
||||
AsconError(a, "read timeout", 0);
|
||||
a->state = AsconTimeout;
|
||||
}
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** @brief Modbus TCP protocol handler.
|
||||
* This handler encodes commands and decodes responses
|
||||
* for the Modbus TCP protocol
|
||||
*/
|
||||
int ModbusProtHandler(Ascon *a) {
|
||||
int ret;
|
||||
|
||||
switch(a->state){
|
||||
case AsconWriteStart:
|
||||
ret = ModbusWriteStart(a);
|
||||
return ret;
|
||||
break;
|
||||
case AsconReadStart:
|
||||
a->start = DoubleTime();
|
||||
ret = AsconStdHandler(a);
|
||||
return ret;
|
||||
break;
|
||||
case AsconReading:
|
||||
ret = ModbusReading(a);
|
||||
return ret;
|
||||
break;
|
||||
default:
|
||||
ret = AsconStdHandler(a);
|
||||
return ret;
|
||||
break;
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
||||
void AddModbusProtocoll(){
|
||||
AsconProtocol *prot = NULL;
|
||||
|
||||
prot = calloc(sizeof(AsconProtocol), 1);
|
||||
prot->name = strdup("modbus");
|
||||
prot->init = AsconStdInit;
|
||||
prot->handler = ModbusProtHandler;
|
||||
AsconInsertProtocol(prot);
|
||||
}
|
||||
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
static int dbgprintf(char* fmtstr, ...) {
|
||||
if (debug_modbus > 0) {
|
||||
FILE* fp = NULL;
|
||||
int ret = 0;
|
||||
fp = fopen("/tmp/modbus.txt", "a");
|
||||
if (fp != NULL) {
|
||||
va_list ap;
|
||||
va_start(ap, fmtstr);
|
||||
ret = vfprintf(fp, fmtstr, ap);
|
||||
va_end(ap);
|
||||
fclose(fp);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
static int dbgprintx(const char* msg, const unsigned char* cp, int blen) {
|
||||
if (debug_modbus > 0) {
|
||||
char tmp[128];
|
||||
int i, j;
|
||||
const char hex[] = "0123456789ABCDEF";
|
||||
for (i = 0, j = 0; i < blen && j < 126; ++i) {
|
||||
tmp[j++] = hex[(cp[i] >> 4) & 0xF];
|
||||
tmp[j++] = hex[(cp[i] ) & 0xF];
|
||||
}
|
||||
tmp[j++] = '\0';
|
||||
return dbgprintf("%s: %s\n", msg, tmp);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
@@ -207,6 +207,9 @@ int RFAmpReading (Ascon *a)
|
||||
}
|
||||
address = GetCharArray(a->rdBuffer)[0];
|
||||
ctype = GetCharArray(a->rdBuffer)[1];
|
||||
memset(curr, 0, sizeof(curr));
|
||||
memset(freq, 0, sizeof(freq));
|
||||
memset(voltage, 0, sizeof(voltage));
|
||||
strncpy(curr, &GetCharArray(a->rdBuffer)[2], 2);
|
||||
strncpy(freq, &GetCharArray(a->rdBuffer)[4], 3);
|
||||
strncpy(voltage, &GetCharArray(a->rdBuffer)[7], 2);
|
||||
@@ -231,6 +234,8 @@ int RFAmpReading (Ascon *a)
|
||||
char tmpCurr[3], tmpFreq[4];
|
||||
unsigned char tmpSwitchs;
|
||||
|
||||
memset(tmpCurr, 0 , sizeof(tmpCurr));
|
||||
memset(tmpFreq, 0 , sizeof(tmpFreq));
|
||||
strncpy(tmpCurr, &data->rfCmd[3], 2);
|
||||
strncpy(tmpFreq, &data->rfCmd[5], 3);
|
||||
tmpSwitchs = (unsigned char)data->rfCmd[8];
|
||||
|
||||
@@ -446,19 +446,14 @@ proc setDesiredField {tc_root nextState cmd} {
|
||||
set ns ::scobj::lh45
|
||||
set par [sct target]
|
||||
|
||||
#hset $tc_root/status "busy"
|
||||
set wrStatus [sct writestatus]
|
||||
if {$wrStatus == "start"} {
|
||||
# Called by drive adapter
|
||||
# puts "setDesiredField(): driving set to 1"
|
||||
set nodename $tc_root/sensor/setpoint
|
||||
hsetprop $nodename driving 1
|
||||
}
|
||||
#puts "setDesiredField(wrStatus=$wrStatus): sct send $cmd$par"
|
||||
after $::scobj::bruker_BEC1::bruker_BEC1_MIN_TIME_BETWEEN_COMMANDS
|
||||
sct send "$cmd$par"
|
||||
return $nextState
|
||||
} message ]
|
||||
if {$catch_status == 1} {
|
||||
# TCL_ERROR
|
||||
sct driving 0
|
||||
}
|
||||
handle_exception $catch_status $message "in setDesiredField(). Last write command: $::scobj::bruker_BEC1::bruker_BEC1_lastWriteCmd"
|
||||
}
|
||||
|
||||
@@ -475,19 +470,14 @@ proc setDesiredCurrent {tc_root nextState cmd} {
|
||||
set ns ::scobj::lh45
|
||||
set par [sct target]
|
||||
|
||||
#hset $tc_root/status "busy"
|
||||
set wrStatus [sct writestatus]
|
||||
if {$wrStatus == "start"} {
|
||||
# Called by drive adapter
|
||||
# puts "setDesiredCurrent(): driving set to 1"
|
||||
set nodename $tc_root/sensor/nominal_outp_current
|
||||
hsetprop $nodename driving 1
|
||||
}
|
||||
#puts "setDesiredCurrent(wrStatus=$wrStatus): sct send $cmd$par"
|
||||
after $::scobj::bruker_BEC1::bruker_BEC1_MIN_TIME_BETWEEN_COMMANDS
|
||||
sct send "$cmd$par"
|
||||
return $nextState
|
||||
} message ]
|
||||
if {$catch_status == 1} {
|
||||
# TCL_ERROR
|
||||
sct driving 0
|
||||
}
|
||||
handle_exception $catch_status $message "in setDesiredCurrent(). Last write command: $::scobj::bruker_BEC1::bruker_BEC1_lastWriteCmd"
|
||||
}
|
||||
|
||||
|
||||
@@ -71,9 +71,9 @@ debug_log "setPoint new data for $tc_root [sct] result=$par"
|
||||
hset $tc_root/status "busy"
|
||||
sct print "status: busy"
|
||||
hset $tc_root/drive_state "START"
|
||||
hsetprop $tc_root/setpoint driving 1
|
||||
} catch_message ]
|
||||
if {$catch_status != 0} {
|
||||
hsetprop $tc_root/setpoint driving 0
|
||||
return -code error $catch_message
|
||||
}
|
||||
sct print "setPoint: [hget $tc_root/drive_state]"
|
||||
|
||||
@@ -94,9 +94,9 @@ debug_log "setPoint new data for $tc_root [sct] result=$par"
|
||||
hset $tc_root/status "busy"
|
||||
sct print "status: busy"
|
||||
hset $tc_root/drive_state "START"
|
||||
hsetprop $tc_root/setpoint driving 1
|
||||
} catch_message ]
|
||||
if {$catch_status != 0} {
|
||||
hsetprop $tc_root/setpoint driving 0
|
||||
return -code error $catch_message
|
||||
}
|
||||
sct print "setPoint: [hget $tc_root/drive_state]"
|
||||
@@ -456,6 +456,7 @@ debug_log "rdState $tc_root error scan status = $rslt on $my_status"
|
||||
set lolimit [hval $tc_root/lowerlimit]
|
||||
set hilimit [hval $tc_root/upperlimit]
|
||||
if {$setpoint < $lolimit || $setpoint > $hilimit} {
|
||||
sct driving 0
|
||||
error "setpoint violates limits"
|
||||
}
|
||||
return OK
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -22,6 +22,7 @@ namespace eval ::scobj::lh45 {
|
||||
|
||||
proc setPoint {tc_root nextState cmd} {
|
||||
if {[hval $tc_root/remote_ctrl] == "False"} {
|
||||
sct driving 0
|
||||
return idle
|
||||
}
|
||||
set par [sct target]
|
||||
@@ -33,12 +34,8 @@ namespace eval ::scobj::lh45 {
|
||||
# }
|
||||
hset $tc_root/power 1
|
||||
hset $tc_root/status "busy"
|
||||
if {[sct writestatus] == "start"} {
|
||||
# Called by drive adapter
|
||||
hsetprop $tc_root/setpoint driving 1
|
||||
}
|
||||
sct send "$cmd $par"
|
||||
sct updated 0
|
||||
sct setpoint_pending 0
|
||||
return $nextState
|
||||
}
|
||||
|
||||
@@ -53,7 +50,6 @@ namespace eval ::scobj::lh45 {
|
||||
sct oldval $data
|
||||
sct update $data
|
||||
sct utime readtime
|
||||
sct updated 1
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -88,8 +84,8 @@ namespace eval ::scobj::lh45 {
|
||||
sct update $power
|
||||
}
|
||||
if {$power==1} {
|
||||
set setpoint_updated [hgetpropval $tc_root/setpoint updated]
|
||||
if {$setpoint_updated != 1} {
|
||||
if [hgetpropval $tc_root/setpoint setpoint_pending] {
|
||||
# Don't update status while we're waiting for the new setpoint to be sent
|
||||
return idle
|
||||
}
|
||||
set currtime [sct readtime]
|
||||
@@ -196,8 +192,10 @@ namespace eval ::scobj::lh45 {
|
||||
set lolimit [hval $tc_root/lowerlimit]
|
||||
set hilimit [hval $tc_root/upperlimit]
|
||||
if {$setpoint < $lolimit || $setpoint > $hilimit} {
|
||||
sct driving 0
|
||||
error "setpoint violates limits"
|
||||
}
|
||||
sct setpoint_pending 1
|
||||
return OK
|
||||
}
|
||||
|
||||
@@ -239,7 +237,7 @@ namespace eval ::scobj::lh45 {
|
||||
hsetprop $scobj_hpath/setpoint driving 0
|
||||
hsetprop $scobj_hpath/setpoint writestatus UNKNOWN
|
||||
hsetprop $scobj_hpath/setpoint type drivable
|
||||
hsetprop $scobj_hpath/setpoint updated 0
|
||||
hsetprop $scobj_hpath/setpoint setpoint_pending 0
|
||||
# Drive adapter interface
|
||||
hsetprop $scobj_hpath/setpoint checklimits ${ns}::check $scobj_hpath
|
||||
hsetprop $scobj_hpath/setpoint checkstatus ${ns}::drivestatus $scobj_hpath
|
||||
|
||||
@@ -710,6 +710,9 @@ proc inTolerance {CtrlLoopIdx} {
|
||||
set cmpIdString [string compare -length 13 $data "LSCI,MODEL336"]
|
||||
}
|
||||
if {$cmpIdString == 0 } {
|
||||
if [ hgetpropval $tc_root/sensor/setpoint$CtrlLoopIdx setpoint_pending ] {
|
||||
continue
|
||||
}
|
||||
# set nodename $tc_root/control/config_Loop_$CtrlLoopIdx
|
||||
# set iSensor [hval $nodename]
|
||||
# set iSensor [string range $iSensor 0 0]
|
||||
@@ -900,11 +903,12 @@ proc setPoint {tc_root nextState cmd whichCtrlLoop} {
|
||||
# Called by drive adapter
|
||||
# puts "setPoint(): driving set to 1"
|
||||
set nodename $tc_root/sensor/setpoint$whichCtrlLoop
|
||||
hsetprop $nodename driving 1
|
||||
}
|
||||
#puts "setPoint(wrStatus=$wrStatus): sct send $cmd$par"
|
||||
sct send "$cmd$par"
|
||||
sct setpoint_pending 0
|
||||
} message ]} {
|
||||
hsetprop $nodename driving 0
|
||||
return -code error "in setPoint: $message. Last write command: $::scobj::ls336::ls336_lastWriteCmd"
|
||||
}
|
||||
return $nextState
|
||||
@@ -1175,8 +1179,10 @@ proc check {tc_root whichCtrlLoop} {
|
||||
}
|
||||
}
|
||||
} message ]} {
|
||||
sct driving 0
|
||||
return -code error "in check(): $message. Last write command: $::scobj::ls336::ls336_lastWriteCmd"
|
||||
}
|
||||
sct setpoint_pending 1
|
||||
return OK
|
||||
}
|
||||
|
||||
@@ -1728,6 +1734,7 @@ proc createNode {scobj_hpath sct_controller cmdGroup varName readable writable p
|
||||
hsetprop $nodeName checklimits ${ns}::check $scobj_hpath $idx
|
||||
hsetprop $nodeName checkstatus ${ns}::drivestatus $scobj_hpath
|
||||
hsetprop $nodeName halt ${ns}::halt $scobj_hpath $idx
|
||||
hsetprop $nodeName setpoint_pending 0
|
||||
}
|
||||
} message ]} {
|
||||
return -code error "in createNode $message"
|
||||
|
||||
@@ -710,6 +710,9 @@ proc inTolerance {CtrlLoopIdx} {
|
||||
set cmpIdString [string compare -length 13 $data "LSCI,MODEL336"]
|
||||
}
|
||||
if {$cmpIdString == 0 } {
|
||||
if [ hgetpropval $tc_root/sensor/setpoint$CtrlLoopIdx setpoint_pending ] {
|
||||
continue
|
||||
}
|
||||
# set nodename $tc_root/control/config_Loop_$CtrlLoopIdx
|
||||
# set iSensor [hval $nodename]
|
||||
# set iSensor [string range $iSensor 0 0]
|
||||
@@ -900,11 +903,12 @@ proc setPoint {tc_root nextState cmd whichCtrlLoop} {
|
||||
# Called by drive adapter
|
||||
# puts "setPoint(): driving set to 1"
|
||||
set nodename $tc_root/sensor/setpoint$whichCtrlLoop
|
||||
hsetprop $nodename driving 1
|
||||
}
|
||||
#puts "setPoint(wrStatus=$wrStatus): sct send $cmd$par"
|
||||
sct send "$cmd$par"
|
||||
sct setpoint_pending 0
|
||||
} message ]} {
|
||||
hsetprop $nodename driving 0
|
||||
return -code error "in setPoint: $message. Last write command: $::scobj::ls340::ls340_lastWriteCmd"
|
||||
}
|
||||
return $nextState
|
||||
@@ -1175,8 +1179,10 @@ proc check {tc_root whichCtrlLoop} {
|
||||
}
|
||||
}
|
||||
} message ]} {
|
||||
sct driving 0
|
||||
return -code error "in check(): $message. Last write command: $::scobj::ls340::ls340_lastWriteCmd"
|
||||
}
|
||||
sct setpoint_pending 1
|
||||
return OK
|
||||
}
|
||||
|
||||
@@ -1728,6 +1734,7 @@ proc createNode {scobj_hpath sct_controller cmdGroup varName readable writable p
|
||||
hsetprop $nodeName checklimits ${ns}::check $scobj_hpath $idx
|
||||
hsetprop $nodeName checkstatus ${ns}::drivestatus $scobj_hpath
|
||||
hsetprop $nodeName halt ${ns}::halt $scobj_hpath $idx
|
||||
hsetprop $nodeName setpoint_pending 0
|
||||
}
|
||||
} message ]} {
|
||||
return -code error "in createNode $message"
|
||||
|
||||
@@ -40,11 +40,8 @@ debug_log "setPoint $tc_root $nextState $cmd sct=[sct]"
|
||||
set par "[sct target]"
|
||||
}
|
||||
hset $tc_root/status "busy"
|
||||
if {[sct writestatus] == "start"} {
|
||||
# Called by drive adapter
|
||||
hsetprop $tc_root/setpoint driving 1
|
||||
}
|
||||
sct send "@1$cmd$par"
|
||||
sct setpoint_pending 0
|
||||
debug_log "setPoint $cmd$par"
|
||||
return $nextState
|
||||
}
|
||||
@@ -259,7 +256,7 @@ debug_log "rdState $tc_root: target=$tgt"
|
||||
set tgt [SplitReply [hgetprop $tc_root/setpoint target]]
|
||||
debug_log "rdState $tc_root: initialised target to: target=$tgt"
|
||||
}
|
||||
if {$my_driving > 0} {
|
||||
if {$my_driving > 0 && [sct setpoint_pending] == 0} {
|
||||
if {[hval $tc_root/control_sensor] == "3"} {
|
||||
set temp [hval $tc_root/sensor3/value]
|
||||
} elseif {[hval $tc_root/control_sensor] == "2"} {
|
||||
@@ -299,8 +296,10 @@ debug_log "rdState returns: $nextState"
|
||||
set lolimit [hval $tc_root/lowerlimit]
|
||||
set hilimit [hval $tc_root/upperlimit]
|
||||
if {$setpoint < $lolimit || $setpoint > $hilimit} {
|
||||
sct driving 0
|
||||
error "setpoint violates limits"
|
||||
}
|
||||
sct setpoint_pending 1
|
||||
return OK
|
||||
}
|
||||
|
||||
@@ -341,6 +340,7 @@ debug_log "halt $tc_root"
|
||||
hsetprop $scobj_hpath/setpoint noResponse ${ns}::noResponse
|
||||
hsetprop $scobj_hpath/setpoint oldval UNKNOWN
|
||||
hsetprop $scobj_hpath/setpoint driving 0
|
||||
hsetprop $scobj_hpath/setpoint setpoint_pending 0
|
||||
hsetprop $scobj_hpath/setpoint writestatus UNKNOWN
|
||||
# Drive adapter interface
|
||||
hsetprop $scobj_hpath/setpoint checklimits ${ns}::check $scobj_hpath
|
||||
|
||||
@@ -374,7 +374,6 @@ debug_log "setValue $dev:16:$cmd $par"
|
||||
hset $tc_root/device_control/target [sct target]
|
||||
hset $tc_root/device_control/previous_error [expr [sct target] - [hval $tc_root/samplesensor]]
|
||||
hset $tc_root/status "busy"
|
||||
hsetprop $tc_root/setpoint driving 1
|
||||
return idle
|
||||
}
|
||||
|
||||
@@ -442,6 +441,7 @@ debug_log "setPoint $dev:1016:$cmd $par"
|
||||
set lolimit [hval $tc_root/lowerlimit]
|
||||
set hilimit [hval $tc_root/upperlimit]
|
||||
if {$setpoint < $lolimit || $setpoint > $hilimit} {
|
||||
sct driving 0
|
||||
error "setpoint violates limits"
|
||||
}
|
||||
return OK
|
||||
|
||||
@@ -216,7 +216,6 @@ proc newFileName {idNum postfix} {
|
||||
sicsdatanumber incr
|
||||
}
|
||||
if [catch {nxscript $create_type $FileName $nxdict_path} message] {
|
||||
killfile
|
||||
error $message
|
||||
}
|
||||
set state(file,open) false
|
||||
|
||||
@@ -137,9 +137,9 @@ debug_log "sct send $cmd"
|
||||
}
|
||||
hset $tc_root/status "busy"
|
||||
sct print "status: busy"
|
||||
hsetprop $tc_root/setpoint driving 1
|
||||
} catch_message ]
|
||||
if {$catch_status != 0} {
|
||||
hsetprop $tc_root/setpoint driving 0
|
||||
return -code error $catch_message
|
||||
}
|
||||
sct print "setPoint: [hget $tc_root/drive_state]"
|
||||
@@ -246,6 +246,7 @@ debug_log "getState returns: $nextState"
|
||||
set lolimit [hval $tc_root/lowerlimit]
|
||||
set hilimit [hval $tc_root/upperlimit]
|
||||
if {$setpoint < $lolimit || $setpoint > $hilimit} {
|
||||
sct driving 0
|
||||
error "setpoint violates limits"
|
||||
}
|
||||
return OK
|
||||
|
||||
222
site_ansto/instrument/deploySICS.sh.new
Executable file
222
site_ansto/instrument/deploySICS.sh.new
Executable file
@@ -0,0 +1,222 @@
|
||||
#!/bin/sh
|
||||
# $Revision: 1.28.10.1 $
|
||||
# $Date: 2010-01-27 03:15:13 $
|
||||
# Author: Ferdi Franceschini (ffr@ansto.gov.au)
|
||||
# Last revision by $Author: jgn $
|
||||
|
||||
# Deploys SICServer and configuration files to
|
||||
# an instrument control computer.
|
||||
# It requires a MANIFEST.TXT file for each instrument
|
||||
|
||||
# INSTCFCOMMON.TXT file contains paths to the common configuration files
|
||||
# used by the instrument specific configurations, it should be placed in
|
||||
# the 'config' directory for each instrument. The paths are relative
|
||||
# to the instrument source directory. This file is optional.
|
||||
|
||||
usage()
|
||||
{
|
||||
cat <<EOF
|
||||
deploySICS.sh copies SICS and the files listed
|
||||
in the MANIFEST.TXT files to the IC host.
|
||||
Usage:
|
||||
./deploySICS.sh [-n] INSTRUMENT [TARGET_HOST [TARGET_DIR]]
|
||||
where
|
||||
-n if present inhibits the actual deployment (for testing the script)
|
||||
INSTRUMENT can be hrpd, echidna, hipd, wombat, lyrebird ... (not "./xxx")
|
||||
or test/INSTRUMENT or INSTRUMENT/test for test deployment
|
||||
TARGET_HOST can be a remote host or 'localhost'
|
||||
defaults to ics1-<instrument>.nbi... or ics1-test.nbi... for test
|
||||
TARGET_DIR is the top part of the directory tree
|
||||
defaults to /usr/local or /usr/local/TEST_SICS/<instrument> for test
|
||||
tail directories in TARGET_DIR will be created on TARGET_HOST if necessary.
|
||||
Examples:
|
||||
./deploySICS.sh -n echidna
|
||||
prepares deployment of echidna (./hrpd)
|
||||
to directory /usr/local/sics on isc1-echidna.nbi.ansto.gov.au
|
||||
./deploySICS.sh -n reflectometer/test
|
||||
prepares deployment of platypus (./reflectometer)
|
||||
to directory usr/local/TEST_SICS/platypus on isc1-test.nbi.ansto.gov.au
|
||||
./deploySICS.sh -n test/echidna localhost $HOME
|
||||
prepares deployment of echidna (./hrpd)
|
||||
to directory $HOME/TEST_SICS/echidna on localhost
|
||||
EOF
|
||||
}
|
||||
|
||||
# Copy sics server configuration files to a given destination
|
||||
# Usage: copy_server_config SERVER_DIRECTORY
|
||||
copy_server_config() {
|
||||
sicserver_path=$1
|
||||
cp -a --preserve=timestamps $COMMON $INSTSPEC $TEMPDIR/$DESTDIR/$sicserver_path
|
||||
if [ -e $INSTCFDIR/INSTCFCOMMON.TXT ]; then
|
||||
for f in $(cat $INSTCFDIR/INSTCFCOMMON.TXT); do
|
||||
cp --parents --preserve=timestamps $f $TEMPDIR/$DESTDIR/$sicserver_path
|
||||
done
|
||||
fi
|
||||
}
|
||||
|
||||
shopt -s nocasematch
|
||||
|
||||
if [[ "$1" = "-n" ]]
|
||||
then
|
||||
DEPLOY="NO"
|
||||
shift
|
||||
else
|
||||
DEPLOY="YES"
|
||||
fi
|
||||
|
||||
if [ $# -eq 0 -o $# -gt 3 ]
|
||||
then
|
||||
usage
|
||||
exit 1
|
||||
fi
|
||||
|
||||
TESTING=$(dirname "$1")
|
||||
INSTRUMENT=$(basename "$1")
|
||||
if [[ "$INSTRUMENT" = "test" ]]
|
||||
then
|
||||
TESTING=$(basename "$1")
|
||||
INSTRUMENT=$(dirname "$1")
|
||||
fi
|
||||
|
||||
SRCDIR="."
|
||||
TEMPDIR=$HOME/tmp
|
||||
|
||||
|
||||
|
||||
# Set the destination host
|
||||
# instrument name and the
|
||||
# instrument src directory
|
||||
|
||||
SICSDIR=sics
|
||||
case $INSTRUMENT in
|
||||
echidna|hrpd)
|
||||
INSTRUMENT=echidna
|
||||
DESTHOST=${2:-ics1-echidna.nbi.ansto.gov.au}
|
||||
INSTSRC=$SRCDIR/hrpd;;
|
||||
wombat|hipd)
|
||||
INSTRUMENT=wombat
|
||||
DESTHOST=${2:-ics1-wombat.nbi.ansto.gov.au}
|
||||
INSTSRC=$SRCDIR/hipd;;
|
||||
koala|qld)
|
||||
INSTRUMENT=koala
|
||||
DESTHOST=${2:-ics1-koala.nbi.ansto.gov.au}
|
||||
INSTSRC=$SRCDIR/qld;;
|
||||
platypus|reflectometer)
|
||||
INSTRUMENT=platypus
|
||||
DESTHOST=${2:-ics1-platypus.nbi.ansto.gov.au}
|
||||
INSTSRC=$SRCDIR/reflectometer;;
|
||||
kowari|rsd)
|
||||
INSTRUMENT=kowari
|
||||
DESTHOST=${2:-ics1-kowari.nbi.ansto.gov.au}
|
||||
INSTSRC=$SRCDIR/rsd;;
|
||||
quokka|sans)
|
||||
INSTRUMENT=quokka
|
||||
DESTHOST=${2:-ics1-quokka.nbi.ansto.gov.au}
|
||||
INSTSRC=$SRCDIR/sans;;
|
||||
pelican|pas)
|
||||
INSTRUMENT=pelican
|
||||
DESTHOST=${2:-ics1-pelican.nbi.ansto.gov.au}
|
||||
INSTSRC=$SRCDIR/pas;;
|
||||
lyrebird|lyrebird)
|
||||
INSTRUMENT=lyrebird
|
||||
DESTHOST=${2:-ics1-lyrebird.nbi.ansto.gov.au}
|
||||
SICSDIR=nbi/lyrebird
|
||||
INSTSRC=$SRCDIR/lyrebird;;
|
||||
taipan|tas)
|
||||
INSTRUMENT=taipan
|
||||
DESTHOST=${2:-ics1-taipan.nbi.ansto.gov.au}
|
||||
SICSDIR=nbi/taipan
|
||||
INSTSRC=$SRCDIR/tas;;
|
||||
esac
|
||||
INSTCFDIR=$INSTSRC/config
|
||||
|
||||
make -C ../ $INSTRUMENT || exit $?
|
||||
|
||||
if [[ "$TESTING" = "test" ]]
|
||||
then
|
||||
DESTHOST=${2:-ics1-test.nbi.ansto.gov.au}
|
||||
DESTDIR=${3:-/usr/local}/TEST_SICS/$INSTRUMENT
|
||||
TARDIR=${DESTDIR:1}
|
||||
# remove and recreate the temporary directory
|
||||
rm -fr $TEMPDIR/$DESTDIR
|
||||
mkdir -p $TEMPDIR/$DESTDIR
|
||||
#copy TEST_SICS/fakeDMC and remove .svn any directories
|
||||
cp -a $SRCDIR/TEST_SICS/* $TEMPDIR/$DESTDIR
|
||||
rm -fr $(find $TEMPDIR/$DESTDIR -name .svn)
|
||||
# step down to the sics directory
|
||||
DESTDIR=$DESTDIR/$SICSDIR
|
||||
mkdir -p $TEMPDIR/$DESTDIR
|
||||
else
|
||||
DESTDIR=${3:-/usr/local}/$SICSDIR
|
||||
TARDIR=${DESTDIR:1}
|
||||
# remove and recreate the temporary directory
|
||||
rm -fr $TEMPDIR/$DESTDIR
|
||||
mkdir -p $TEMPDIR/$DESTDIR
|
||||
fi
|
||||
|
||||
echo "Deploying $INSTRUMENT to $DESTHOST:$DESTDIR"
|
||||
|
||||
|
||||
EXTRACT_CMDS="tar vxzp -C /; touch /$DESTDIR/newserver/{DataNumber,extraconfig.tcl,config/nexus/nexus.dic} "
|
||||
if [[ "$DESTHOST" = "localhost" ]]
|
||||
then
|
||||
EXTRACT=$EXTRACT_CMDS
|
||||
EXTRACT_NODEPLOY=$EXTRACT_CMDS
|
||||
elif [[ "$TESTING" != "test" ]]
|
||||
then
|
||||
EXTRACT="ssh $DESTHOST $EXTRACT_CMDS; chown -R root:root /$DESTDIR; chown ${INSTRUMENT}_sics. /$DESTDIR/newserver/{DataNumber,config/nexus/nexus.dic}; chown ${INSTRUMENT}. /$DESTDIR/newserver/extraconfig.tcl"
|
||||
EXTRACT_NODEPLOY="ssh $DESTHOST "$EXTRACT_CMDS; chown -R root:root /$DESTDIR; chown ${INSTRUMENT}_sics. /$DESTDIR/newserver/{DataNumber,config/nexus/nexus.dic}; chown ${INSTRUMENT}. /$DESTDIR/newserver/extraconfig.tcl""
|
||||
else
|
||||
EXTRACT="ssh $DESTHOST $EXTRACT_CMDS"
|
||||
EXTRACT_NODEPLOY="ssh $DESTHOST "$EXTRACT_CMDS""
|
||||
fi
|
||||
|
||||
if [ ! -e $SRCDIR/MANIFEST.TXT ]
|
||||
then
|
||||
echo "$SRCDIR/MANIFEST.TXT not found"
|
||||
exit 1
|
||||
fi
|
||||
if [ ! -e $SRCDIR/$INSTSRC/MANIFEST.TXT ]
|
||||
then
|
||||
echo "$SRCDIR/$INSTSRC/MANIFEST.TXT not found"
|
||||
echo "You must list the files required for $INSTRUMENT in the manifest"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Get list of files to copy and prepend directory name
|
||||
COMMON=$(for f in $(cat $SRCDIR/MANIFEST.TXT); do echo -n "$SRCDIR/$f "; done)
|
||||
INSTSPEC=$(for f in $(cat $INSTSRC/MANIFEST.TXT); do echo -n "$INSTSRC/$f "; done)
|
||||
|
||||
# Create Instrument Control Server directories and copy SICS configs to the 'server' directory
|
||||
mkdir -p $TEMPDIR/$DESTDIR/{batch,newserver,log,tmp}
|
||||
copy_server_config newserver
|
||||
cp -a --preserve=timestamps ../SICServer $TEMPDIR/$DESTDIR/newserver
|
||||
|
||||
# Create Script Validator directories
|
||||
mkdir -p $TEMPDIR/$DESTDIR/script_validator/{data,log,tmp}
|
||||
|
||||
# Create a manifest of the files installed on the IC host
|
||||
echo "Date: $(date -Iminutes)" > $TEMPDIR/$DESTDIR/newserver/MANIFEST.TXT
|
||||
echo -e "The following files were installed by $USER\n" >> $TEMPDIR/$DESTDIR/newserver/MANIFEST.TXT
|
||||
cat $SRCDIR/MANIFEST.TXT $SRCDIR/$INSTSRC/MANIFEST.TXT >> $TEMPDIR/$DESTDIR/newserver/MANIFEST.TXT
|
||||
|
||||
cd $TEMPDIR
|
||||
# remove any .svn directories
|
||||
rm -rf $(find $TARDIR -type d -name .svn)
|
||||
# remove any temporary editor files
|
||||
find $TARDIR -type f -name .\*.sw\? -exec rm {} \;
|
||||
# remove any editor backup files directories
|
||||
find $TARDIR -type f -name \*~ -exec rm {} \;
|
||||
# set modes for files
|
||||
find $TARDIR -type f -exec chmod u-s,g-x+wr,o-wx+r {} \;
|
||||
find $TARDIR -type f -perm -100 -exec chmod go+x {} \;
|
||||
# set modes for directories
|
||||
find $TARDIR -type d -exec chmod u+rwx,g+rwxs,o-w+rx {} \;
|
||||
|
||||
# Strip leading / from DESTDIR and extract to destination
|
||||
if [[ "$DEPLOY" = "YES" ]]
|
||||
then
|
||||
tar -cz ${TARDIR} | $EXTRACT
|
||||
else
|
||||
echo "tar -cz -C $TEMPDIR $TARDIR | $EXTRACT_NODEPLOY"
|
||||
fi
|
||||
@@ -2,7 +2,6 @@ config/source/source_common.tcl
|
||||
config/anticollider/anticollider_common.tcl
|
||||
config/plc/plc_common_1.tcl
|
||||
config/counter/counter_common_1.tcl
|
||||
config/environment/temperature/sct_lakeshore_3xx.tcl
|
||||
config/environment/magneticField/sct_bruker_BEC1.tcl
|
||||
config/hipadaba/hipadaba_configuration_common.tcl
|
||||
config/hipadaba/common_instrument_dictionary.tcl
|
||||
@@ -15,4 +14,7 @@ config/scan/scan_common_1.tcl
|
||||
config/nexus/nxscripts_common_1.tcl
|
||||
config/commands/commands_common.tcl
|
||||
config/motors/sct_positmotor_common.tcl
|
||||
config/environment/sct_protek_common.tcl
|
||||
config/environment/temperature/sct_lakeshore_340.tcl
|
||||
config/environment/temperature/sct_lakeshore_336.tcl
|
||||
config/motors/sct_jogmotor_common.tcl
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
fileeval $cfPath(beamline)/sct_RFGen.tcl
|
||||
|
||||
# NOTE: opCurr is 10 * your operating current, ie if the current is 7.1 then opCurr = 71
|
||||
::scobj::rfgen::mkRFGen {
|
||||
name "polarizer_flipper"
|
||||
address 1
|
||||
opCurr 71
|
||||
opFreq 407
|
||||
IP 137.157.202.149
|
||||
PORT 4001
|
||||
tuning 1
|
||||
interval 2
|
||||
currtol 1
|
||||
compCurr 1
|
||||
guideCurr 1
|
||||
thickness 1
|
||||
}
|
||||
|
||||
::scobj::rfgen::mkRFGen {
|
||||
name "analyzer_flipper"
|
||||
address 9
|
||||
opCurr 71
|
||||
opFreq 407
|
||||
IP 137.157.202.149
|
||||
PORT 4002
|
||||
tuning 1
|
||||
interval 2
|
||||
currtol 1
|
||||
compCurr 1
|
||||
guideCurr 1
|
||||
thickness 1
|
||||
}
|
||||
@@ -0,0 +1,419 @@
|
||||
##
|
||||
# @file Mirrotron RF Generator control
|
||||
#
|
||||
# Author: Ferdi Franceschini (ffr@ansto.gov.au) May 2010
|
||||
#
|
||||
# The controller can be installed with the following command,
|
||||
# ::scobj::rfgen::mkRFGen {
|
||||
# name "anal"
|
||||
# address 1
|
||||
# opCurr 68
|
||||
# opFreq 241
|
||||
# IP localhost
|
||||
# PORT 65123
|
||||
# tuning 1
|
||||
# currtol 1
|
||||
# interval 2
|
||||
# }
|
||||
#
|
||||
# NOTE:
|
||||
# If tuning=1 this will generate xxx/set_current and xxx/set_frequency
|
||||
# nodes for the instrument scientists.
|
||||
# The tuning parameter should be set to 0 for the users.
|
||||
#
|
||||
# The operation_manual_Platypus_polarization_system.doc:Sec 3.1 states the following
|
||||
# Attention
|
||||
# a) Do not switch on the RF output with non-zero current setting (the current
|
||||
# control becomes unstable)! If unsure, rotate the current setting
|
||||
# potentiometer 10 turns counter-clockwise.
|
||||
# b) In case of RF vacuum discharge (harmful for the system)
|
||||
# " the main symptom is that the RF power source turns into CV mode, the
|
||||
# voltage increases to 34 Vem and the current decreases;
|
||||
# " switch off the RF output;
|
||||
# " decrease current setting by rotating the potentiometer 10 turns counter-clockwise;
|
||||
# " verify the vacuum level in the tank and restart the flipper operation only if it is below 0.01 mbar.
|
||||
|
||||
namespace eval ::scobj::rfgen {
|
||||
# Control states
|
||||
variable RAMPIDLE 0
|
||||
variable RAMPSTOP 1
|
||||
variable RAMPSTART 2
|
||||
variable RAMPBUSY 3
|
||||
variable RAMPTOZERO 4
|
||||
variable FLIPOFF 5
|
||||
variable MAXVOLTAGE 34
|
||||
}
|
||||
|
||||
##
|
||||
# @brief Utility for trimming zero padding from current and frequency readings.
|
||||
# We do this to avoid misinterpreting numbers as octal
|
||||
proc ::scobj::rfgen::mkStatArr {stateArrName stateReport} {
|
||||
upvar $stateArrName stateArr
|
||||
array set stateArr $stateReport
|
||||
|
||||
if {$stateArr(curr) != 0} {
|
||||
set val [string trimleft $stateArr(curr) 0]
|
||||
if {[string is integer $val]} {
|
||||
set stateArr(curr) $val
|
||||
} else {
|
||||
set stateArr(curr) -1
|
||||
}
|
||||
}
|
||||
if {$stateArr(freq) != 0} {
|
||||
set val [string trimleft $stateArr(freq) 0]
|
||||
if {[string is integer $val]} {
|
||||
set stateArr(freq) $val
|
||||
} else {
|
||||
set stateArr(freq) -1
|
||||
}
|
||||
}
|
||||
if {$stateArr(voltage) != 0} {
|
||||
set val [string trimleft $stateArr(voltage) 0]
|
||||
if {[string is integer $val]} {
|
||||
set stateArr(voltage) $val
|
||||
} else {
|
||||
set stateArr(voltage) -1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
##
|
||||
# @brief Switch the generator on or off
|
||||
proc ::scobj::rfgen::switch_on {basePath} {
|
||||
variable RAMPSTART
|
||||
variable RAMPTOZERO
|
||||
|
||||
set genState [sct target]
|
||||
switch $genState {
|
||||
"0" {
|
||||
hsetprop $basePath targetCurr 0
|
||||
hsetprop $basePath OutputState 0
|
||||
hsetprop $basePath ramping $RAMPSTART
|
||||
sct update 0
|
||||
sct utime updatetime
|
||||
}
|
||||
"1" {
|
||||
hsetprop $basePath targetCurr [hgetpropval $basePath opCurr]
|
||||
hsetprop $basePath targetFreq [hgetpropval $basePath opFreq]
|
||||
hsetprop $basePath OutputState 1
|
||||
hsetprop $basePath ramping $RAMPSTART
|
||||
sct update 1
|
||||
sct utime updatetime
|
||||
}
|
||||
default {
|
||||
set ErrMsg "[sct] invalid input $genState, Valid states for [sct] are 1 or 0"
|
||||
sct seterror "ERROR: $ErrMsg"
|
||||
return -code error $ErrMsg
|
||||
}
|
||||
}
|
||||
return idle
|
||||
}
|
||||
|
||||
##
|
||||
# @brief Get the target current and scale it for the RF generator.
|
||||
# Also updates the operating current for this session.
|
||||
#
|
||||
# @param basePath, The object base-path, this is where we keep our state variables.
|
||||
proc ::scobj::rfgen::set_current {basePath} {
|
||||
variable RAMPSTART
|
||||
|
||||
set newCurr [sct target]
|
||||
|
||||
set current [expr {round(10.0 * $newCurr)}]
|
||||
hsetprop $basePath targetCurr $current
|
||||
hsetprop $basePath opCurr $current
|
||||
hsetprop $basePath ramping $RAMPSTART
|
||||
hsetprop $basePath OutputState 1
|
||||
return idle
|
||||
}
|
||||
|
||||
##
|
||||
# @brief Get the target frequency. Also updates the operating frequency for this session.
|
||||
#
|
||||
# @param basePath, The object base-path, this is where we keep our state variables.
|
||||
proc ::scobj::rfgen::set_frequency {basePath} {
|
||||
variable RAMPSTART
|
||||
|
||||
set newFreq [sct target]
|
||||
|
||||
hsetprop $basePath targetFreq $newFreq
|
||||
hsetprop $basePath opFreq $newFreq
|
||||
hsetprop $basePath ramping $RAMPSTART
|
||||
hsetprop $basePath OutputState 1
|
||||
return idle
|
||||
}
|
||||
|
||||
##
|
||||
# @brief Request a state report from the RF generator
|
||||
proc ::scobj::rfgen::rqStatFunc {} {
|
||||
sct send "L:[sct address]"
|
||||
return rdState
|
||||
}
|
||||
|
||||
##
|
||||
# @brief Read and record the state report from the RF generator
|
||||
proc ::scobj::rfgen::rdStatFunc {} {
|
||||
variable RAMPBUSY
|
||||
variable RAMPSTART
|
||||
variable RAMPTOZERO
|
||||
variable RAMPIDLE
|
||||
variable FLIPOFF
|
||||
variable MAXVOLTAGE
|
||||
|
||||
set basePath [sct]
|
||||
|
||||
set currSuperState [sct ramping]
|
||||
set updateFlipper 0
|
||||
set statStr [sct result]
|
||||
if {[string match "ASCERR:*" $statStr]} {
|
||||
sct geterror $statStr
|
||||
sct ramping $RAMPIDLE
|
||||
return stateChange
|
||||
}
|
||||
set statList [split $statStr "|="]
|
||||
foreach {k v} $statList {
|
||||
if {$k == "type"} {
|
||||
lappend temp "$k $v"
|
||||
continue
|
||||
}
|
||||
if {[string is integer $v]} {
|
||||
lappend temp "$k $v"
|
||||
} else {
|
||||
lappend temp "$k -1"
|
||||
}
|
||||
}
|
||||
set statList [join $temp]
|
||||
mkStatArr stateArr $statList
|
||||
|
||||
if {$statList != [sct oldStateRep]} {
|
||||
hset $basePath/flip_current [expr {$stateArr(curr) / 10.0}]
|
||||
hset $basePath/flip_frequency $stateArr(freq)
|
||||
hset $basePath/flip_voltage $stateArr(voltage)
|
||||
hset $basePath/flip_on $stateArr(O)
|
||||
hset $basePath/state_report $statList
|
||||
sct update $statList
|
||||
sct utime updatetime
|
||||
sct oldStateRep $statList
|
||||
}
|
||||
if {$currSuperState != $FLIPOFF && $stateArr(curr) > [sct currTol] && $stateArr(O) && $stateArr(CV)} {
|
||||
broadcast "WARNING: RF generator has switched to voltage control, voltage = $stateArr(voltage)"
|
||||
if {$stateArr(voltage) >= $MAXVOLTAGE} {
|
||||
sct ramping $FLIPOFF
|
||||
}
|
||||
}
|
||||
|
||||
return stateChange
|
||||
}
|
||||
|
||||
##
|
||||
# @brief State transition function
|
||||
proc ::scobj::rfgen::stateFunc {} {
|
||||
variable RAMPIDLE
|
||||
variable RAMPSTOP
|
||||
variable RAMPSTART
|
||||
variable RAMPBUSY
|
||||
variable RAMPTOZERO
|
||||
variable FLIPOFF
|
||||
variable MAXVOLTAGE
|
||||
|
||||
set basePath [sct]
|
||||
|
||||
set currSuperState [sct ramping]
|
||||
mkStatArr stateArr [hval $basePath/state_report]
|
||||
set currControlStatus [sct status]
|
||||
|
||||
|
||||
switch $currSuperState [ subst -nocommands {
|
||||
$RAMPSTART {
|
||||
# broadcast RAMPSTART
|
||||
if [string match $currControlStatus "IDLE"] {
|
||||
statemon start flipper
|
||||
sct status "BUSY"
|
||||
sct ramping $RAMPBUSY
|
||||
return ramp
|
||||
} else {
|
||||
# Flipper is off, set current to zero before switching on
|
||||
sct origTargetCurr [sct targetCurr]
|
||||
sct targetCurr 0
|
||||
sct OutputState 0
|
||||
sct ramping $RAMPTOZERO
|
||||
return ramp
|
||||
}
|
||||
}
|
||||
$RAMPTOZERO {
|
||||
# broadcast RAMPTOZERO
|
||||
if {$stateArr(curr) <= [sct currTol]} {
|
||||
# We've reached a safe state so switch on and ramp to target current
|
||||
sct targetCurr [sct origTargetCurr]
|
||||
sct OutputState 1
|
||||
sct ramping $RAMPBUSY
|
||||
} else {
|
||||
sct targetCurr 0
|
||||
sct OutputState 0
|
||||
}
|
||||
return ramp
|
||||
}
|
||||
$RAMPBUSY {
|
||||
# broadcast RAMPBUSY
|
||||
if { [expr {abs($stateArr(curr) - [sct targetCurr])}] <= [sct currTol] } {
|
||||
sct ramping $RAMPSTOP
|
||||
return idle
|
||||
}
|
||||
return ramp
|
||||
}
|
||||
$FLIPOFF {
|
||||
sct targetCurr 0
|
||||
sct OutputState 0
|
||||
if { $stateArr(curr) <= [sct currTol] } {
|
||||
sct ramping $RAMPSTOP
|
||||
broadcast "ERROR: Spin flipper switched off voltage exceeds $MAXVOLTAGE in voltage control state, check vacuum"
|
||||
return idle
|
||||
} else {
|
||||
return ramp
|
||||
}
|
||||
}
|
||||
$RAMPSTOP {
|
||||
# broadcast RAMPSTOP
|
||||
if [string match $currControlStatus "BUSY"] {
|
||||
statemon stop flipper
|
||||
sct status "IDLE"
|
||||
}
|
||||
sct ramping $RAMPIDLE
|
||||
return idle
|
||||
}
|
||||
$RAMPIDLE {
|
||||
# broadcast RAMPIDLE
|
||||
return idle
|
||||
}
|
||||
}]
|
||||
}
|
||||
|
||||
##
|
||||
# @brief Ramps the current up or down in steps of 0.5A and/or sets the frequency
|
||||
proc ::scobj::rfgen::rampFunc {} {
|
||||
set basePath [sct]
|
||||
set currSuperState [sct ramping]
|
||||
mkStatArr stateArr [hval $basePath/state_report]
|
||||
|
||||
set targetCurr [sct targetCurr]
|
||||
set targetFreq [sct targetFreq]
|
||||
set output [sct OutputState]
|
||||
|
||||
if { [expr {abs($stateArr(curr) - [sct targetCurr])}] <= [sct currTol] } {
|
||||
set curr $stateArr(curr)
|
||||
} elseif {$targetCurr < $stateArr(curr)} {
|
||||
set curr [expr $stateArr(curr)-5]
|
||||
if {$curr < $targetCurr} {
|
||||
set curr $targetCurr
|
||||
}
|
||||
} elseif {$targetCurr > $stateArr(curr)} {
|
||||
set curr [expr $stateArr(curr)+5]
|
||||
if {$curr > $targetCurr} {
|
||||
set curr $targetCurr
|
||||
}
|
||||
}
|
||||
set reply [$SCT_RFGEN send "S:[sct address]:I=$curr:F=$targetFreq:K3=$stateArr(K3):K2=$stateArr(K2):K1=$stateArr(K1):O=$output"]
|
||||
|
||||
return idle
|
||||
}
|
||||
|
||||
|
||||
##
|
||||
# @brief Make an RF generator control object
|
||||
#
|
||||
# @param argList, {name "analyser" address "1" opCurr 68 opFreq 241 IP localhost PORT 65123 tuning 0 interval 1}
|
||||
#
|
||||
# name: name of RF generator object
|
||||
# address: address assigned to RF generator 1-9
|
||||
# opCurr: the operating current, when you switch it on it will ramp to this current
|
||||
# opFreq: the operating frequency, when you switch it on it will set this frequency
|
||||
# IP: IP address of RF generator moxa box
|
||||
# PORT: Port number assigned to the generator on the moxa-box
|
||||
# tuning: boolean, set tuning=1 to allow instrument scientists to set the current and frequency
|
||||
# interval: polling and ramping interval in seconds. One sets the ramp rate to 0.5A/s
|
||||
proc ::scobj::rfgen::mkRFGen {argList} {
|
||||
variable RAMPIDLE
|
||||
|
||||
# Generate parameter array from the argument list
|
||||
foreach {k v} $argList {
|
||||
set KEY [string toupper $k]
|
||||
set pa($KEY) $v
|
||||
}
|
||||
|
||||
MakeSICSObj $pa(NAME) SCT_OBJECT
|
||||
sicslist setatt $pa(NAME) klass instrument
|
||||
sicslist setatt $pa(NAME) long_name $pa(NAME)
|
||||
|
||||
# hfactory /sics/$pa(NAME)/status plain spy text
|
||||
hsetprop /sics/$pa(NAME) status "IDLE"
|
||||
hfactory /sics/$pa(NAME)/state_report plain internal text
|
||||
hfactory /sics/$pa(NAME)/flip_current plain internal float
|
||||
hfactory /sics/$pa(NAME)/flip_frequency plain internal int
|
||||
hfactory /sics/$pa(NAME)/flip_voltage plain internal int
|
||||
hfactory /sics/$pa(NAME)/flip_on plain internal int
|
||||
|
||||
hsetprop /sics/$pa(NAME) read ::scobj::rfgen::rqStatFunc
|
||||
hsetprop /sics/$pa(NAME) rdState ::scobj::rfgen::rdStatFunc
|
||||
hsetprop /sics/$pa(NAME) stateChange ::scobj::rfgen::stateFunc
|
||||
hsetprop /sics/$pa(NAME) ramp ::scobj::rfgen::rampFunc
|
||||
|
||||
hsetprop /sics/$pa(NAME) address $pa(ADDRESS)
|
||||
hsetprop /sics/$pa(NAME) tuning $pa(TUNING)
|
||||
hsetprop /sics/$pa(NAME) ramping $RAMPIDLE
|
||||
hsetprop /sics/$pa(NAME) opCurr $pa(OPCURR)
|
||||
hsetprop /sics/$pa(NAME) opFreq $pa(OPFREQ)
|
||||
hsetprop /sics/$pa(NAME) targetCurr 0
|
||||
hsetprop /sics/$pa(NAME) origTargetCurr 0
|
||||
hsetprop /sics/$pa(NAME) oldStateRep ""
|
||||
|
||||
hsetprop /sics/$pa(NAME) currTol $pa(CURRTOL)
|
||||
|
||||
hfactory /sics/$pa(NAME)/comp_current plain internal float
|
||||
hsetprop /sics/$pa(NAME)/comp_current units "A"
|
||||
hset /sics/$pa(NAME)/comp_current $pa(COMPCURR)
|
||||
hfactory /sics/$pa(NAME)/guide_current plain internal float
|
||||
hsetprop /sics/$pa(NAME)/guide_current units "A"
|
||||
hset /sics/$pa(NAME)/guide_current $pa(GUIDECURR)
|
||||
hfactory /sics/$pa(NAME)/thickness plain internal float
|
||||
hsetprop /sics/$pa(NAME)/thickness units "mm"
|
||||
hset /sics/$pa(NAME)/thickness $pa(THICKNESS)
|
||||
|
||||
hfactory /sics/$pa(NAME)/switch_on plain user int
|
||||
hsetprop /sics/$pa(NAME)/switch_on write ::scobj::rfgen::switch_on /sics/$pa(NAME)
|
||||
# Only create the set current and frequency nodes when commissioning
|
||||
|
||||
# Initialise properties required for generating the API for GumTree and to save data
|
||||
::scobj::hinitprops $pa(NAME) flip_current flip_frequency flip_voltage flip_on comp_current guide_current thickness
|
||||
hsetprop /sics/$pa(NAME)/comp_current mutable false
|
||||
hsetprop /sics/$pa(NAME)/guide_current mutable false
|
||||
hsetprop /sics/$pa(NAME)/thickness mutable false
|
||||
|
||||
if {[SplitReply [rfgen_simulation]] == "false"} {
|
||||
set SCT_RFGEN sct_rfgen_$pa(NAME)
|
||||
makesctcontroller $SCT_RFGEN rfamp $pa(IP):$pa(PORT)
|
||||
mkStatArr stateArr [split [$SCT_RFGEN transact "L:$pa(ADDRESS)"] "|="]
|
||||
|
||||
hset /sics/$pa(NAME)/flip_current [expr {$stateArr(curr) / 10.0}]
|
||||
hset /sics/$pa(NAME)/flip_frequency $stateArr(freq)
|
||||
hset /sics/$pa(NAME)/flip_voltage $stateArr(voltage)
|
||||
hset /sics/$pa(NAME)/flip_on $stateArr(O)
|
||||
hsetprop /sics/$pa(NAME) targetFreq $stateArr(freq)
|
||||
hsetprop /sics/$pa(NAME) targetCurr [expr {$stateArr(curr) / 10.0}]
|
||||
|
||||
$SCT_RFGEN poll /sics/$pa(NAME) $pa(INTERVAL)
|
||||
$SCT_RFGEN write /sics/$pa(NAME)/switch_on
|
||||
}
|
||||
|
||||
if {$pa(TUNING)} {
|
||||
hfactory /sics/$pa(NAME)/set_current plain user float
|
||||
hfactory /sics/$pa(NAME)/set_frequency plain user int
|
||||
|
||||
hsetprop /sics/$pa(NAME)/set_current write ::scobj::rfgen::set_current /sics/$pa(NAME)
|
||||
hsetprop /sics/$pa(NAME)/set_frequency write ::scobj::rfgen::set_frequency /sics/$pa(NAME)
|
||||
|
||||
if {[SplitReply [rfgen_simulation]] == "false"} {
|
||||
$SCT_RFGEN write /sics/$pa(NAME)/set_current
|
||||
$SCT_RFGEN write /sics/$pa(NAME)/set_frequency
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
fileeval $cfPath(beamline)/sct_RFGen.tcl
|
||||
|
||||
# NOTE: opCurr is 10 * your operating current, ie if the current is 7.1 then opCurr = 71
|
||||
::scobj::rfgen::mkRFGen {
|
||||
name "polarizer_flipper"
|
||||
address 1
|
||||
opCurr 0
|
||||
opFreq 198
|
||||
K1 0
|
||||
K2 1
|
||||
K3 1
|
||||
IP 137.157.202.149
|
||||
PORT 4001
|
||||
tuning 1
|
||||
interval 2
|
||||
currtol 1
|
||||
compCurr 1
|
||||
guideCurr 1
|
||||
thickness 1
|
||||
}
|
||||
|
||||
::scobj::rfgen::mkRFGen {
|
||||
name "analyzer_flipper"
|
||||
address 9
|
||||
opCurr 0
|
||||
opFreq 198
|
||||
K1 0
|
||||
K2 0
|
||||
K3 0
|
||||
IP 137.157.202.149
|
||||
PORT 4002
|
||||
tuning 1
|
||||
interval 2
|
||||
currtol 1
|
||||
compCurr 1
|
||||
guideCurr 1
|
||||
thickness 1
|
||||
}
|
||||
@@ -0,0 +1,427 @@
|
||||
##
|
||||
# @file Mirrotron RF Generator control
|
||||
#
|
||||
# Author: Ferdi Franceschini (ffr@ansto.gov.au) May 2010
|
||||
#
|
||||
# The controller can be installed with the following command,
|
||||
# ::scobj::rfgen::mkRFGen {
|
||||
# name "anal"
|
||||
# address 1
|
||||
# opCurr 68
|
||||
# opFreq 241
|
||||
# IP localhost
|
||||
# PORT 65123
|
||||
# tuning 1
|
||||
# currtol 1
|
||||
# interval 2
|
||||
# }
|
||||
#
|
||||
# NOTE:
|
||||
# If tuning=1 this will generate xxx/set_current and xxx/set_frequency
|
||||
# nodes for the instrument scientists.
|
||||
# The tuning parameter should be set to 0 for the users.
|
||||
#
|
||||
# The operation_manual_Platypus_polarization_system.doc:Sec 3.1 states the following
|
||||
# Attention
|
||||
# a) Do not switch on the RF output with non-zero current setting (the current
|
||||
# control becomes unstable)! If unsure, rotate the current setting
|
||||
# potentiometer 10 turns counter-clockwise.
|
||||
# b) In case of RF vacuum discharge (harmful for the system)
|
||||
# " the main symptom is that the RF power source turns into CV mode, the
|
||||
# voltage increases to 34 Vem and the current decreases;
|
||||
# " switch off the RF output;
|
||||
# " decrease current setting by rotating the potentiometer 10 turns counter-clockwise;
|
||||
# " verify the vacuum level in the tank and restart the flipper operation only if it is below 0.01 mbar.
|
||||
|
||||
namespace eval ::scobj::rfgen {
|
||||
# Control states
|
||||
variable RAMPIDLE 0
|
||||
variable RAMPSTOP 1
|
||||
variable RAMPSTART 2
|
||||
variable RAMPBUSY 3
|
||||
variable RAMPTOZERO 4
|
||||
variable FLIPOFF 5
|
||||
variable MAXVOLTAGE 34
|
||||
}
|
||||
|
||||
##
|
||||
# @brief Utility for trimming zero padding from current and frequency readings.
|
||||
# We do this to avoid misinterpreting numbers as octal
|
||||
proc ::scobj::rfgen::mkStatArr {stateArrName stateReport} {
|
||||
upvar $stateArrName stateArr
|
||||
array set stateArr $stateReport
|
||||
|
||||
if {$stateArr(curr) != 0} {
|
||||
set val [string trimleft $stateArr(curr) 0]
|
||||
if {[string is integer $val]} {
|
||||
set stateArr(curr) $val
|
||||
} else {
|
||||
set stateArr(curr) -1
|
||||
}
|
||||
}
|
||||
if {$stateArr(freq) != 0} {
|
||||
set val [string trimleft $stateArr(freq) 0]
|
||||
if {[string is integer $val]} {
|
||||
set stateArr(freq) $val
|
||||
} else {
|
||||
set stateArr(freq) -1
|
||||
}
|
||||
}
|
||||
if {$stateArr(voltage) != 0} {
|
||||
set val [string trimleft $stateArr(voltage) 0]
|
||||
if {[string is integer $val]} {
|
||||
set stateArr(voltage) $val
|
||||
} else {
|
||||
set stateArr(voltage) -1
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
##
|
||||
# @brief Switch the generator on or off
|
||||
proc ::scobj::rfgen::switch_on {basePath} {
|
||||
variable RAMPSTART
|
||||
variable RAMPTOZERO
|
||||
|
||||
set genState [sct target]
|
||||
switch $genState {
|
||||
"0" {
|
||||
hsetprop $basePath targetCurr 0
|
||||
hsetprop $basePath OutputState 0
|
||||
hsetprop $basePath ramping $RAMPSTART
|
||||
sct update 0
|
||||
sct utime updatetime
|
||||
}
|
||||
"1" {
|
||||
hsetprop $basePath targetCurr [hgetpropval $basePath opCurr]
|
||||
hsetprop $basePath targetFreq [hgetpropval $basePath opFreq]
|
||||
hsetprop $basePath OutputState 1
|
||||
hsetprop $basePath ramping $RAMPSTART
|
||||
sct update 1
|
||||
sct utime updatetime
|
||||
}
|
||||
default {
|
||||
set ErrMsg "[sct] invalid input $genState, Valid states for [sct] are 1 or 0"
|
||||
sct seterror "ERROR: $ErrMsg"
|
||||
return -code error $ErrMsg
|
||||
}
|
||||
}
|
||||
return idle
|
||||
}
|
||||
|
||||
##
|
||||
# @brief Get the target current and scale it for the RF generator.
|
||||
# Also updates the operating current for this session.
|
||||
#
|
||||
# @param basePath, The object base-path, this is where we keep our state variables.
|
||||
proc ::scobj::rfgen::set_current {basePath} {
|
||||
variable RAMPSTART
|
||||
|
||||
set newCurr [sct target]
|
||||
|
||||
set current [expr {round(10.0 * $newCurr)}]
|
||||
hsetprop $basePath targetCurr $current
|
||||
hsetprop $basePath opCurr $current
|
||||
hsetprop $basePath ramping $RAMPSTART
|
||||
hsetprop $basePath OutputState 1
|
||||
return idle
|
||||
}
|
||||
|
||||
##
|
||||
# @brief Get the target frequency. Also updates the operating frequency for this session.
|
||||
#
|
||||
# @param basePath, The object base-path, this is where we keep our state variables.
|
||||
proc ::scobj::rfgen::set_frequency {basePath} {
|
||||
variable RAMPSTART
|
||||
|
||||
set newFreq [sct target]
|
||||
|
||||
hsetprop $basePath targetFreq $newFreq
|
||||
hsetprop $basePath opFreq $newFreq
|
||||
hsetprop $basePath ramping $RAMPSTART
|
||||
hsetprop $basePath OutputState 1
|
||||
return idle
|
||||
}
|
||||
|
||||
##
|
||||
# @brief Request a state report from the RF generator
|
||||
proc ::scobj::rfgen::rqStatFunc {} {
|
||||
sct send "L:[sct address]"
|
||||
return rdState
|
||||
}
|
||||
|
||||
##
|
||||
# @brief Read and record the state report from the RF generator
|
||||
proc ::scobj::rfgen::rdStatFunc {} {
|
||||
variable RAMPBUSY
|
||||
variable RAMPSTART
|
||||
variable RAMPTOZERO
|
||||
variable RAMPIDLE
|
||||
variable FLIPOFF
|
||||
variable MAXVOLTAGE
|
||||
|
||||
set basePath [sct]
|
||||
|
||||
set currSuperState [sct ramping]
|
||||
set updateFlipper 0
|
||||
set statStr [sct result]
|
||||
if {[string match "ASCERR:*" $statStr]} {
|
||||
sct geterror $statStr
|
||||
sct ramping $RAMPIDLE
|
||||
return stateChange
|
||||
}
|
||||
set statList [split $statStr "|="]
|
||||
foreach {k v} $statList {
|
||||
if {$k == "type"} {
|
||||
lappend temp "$k $v"
|
||||
continue
|
||||
}
|
||||
if {[string is integer $v]} {
|
||||
lappend temp "$k $v"
|
||||
} else {
|
||||
lappend temp "$k -1"
|
||||
}
|
||||
}
|
||||
set statList [join $temp]
|
||||
mkStatArr stateArr $statList
|
||||
|
||||
if {$statList != [sct oldStateRep]} {
|
||||
hset $basePath/flip_current [expr {$stateArr(curr) / 10.0}]
|
||||
hset $basePath/flip_frequency $stateArr(freq)
|
||||
hset $basePath/flip_voltage $stateArr(voltage)
|
||||
hset $basePath/flip_on $stateArr(O)
|
||||
hset $basePath/state_report $statList
|
||||
sct update $statList
|
||||
sct utime updatetime
|
||||
sct oldStateRep $statList
|
||||
}
|
||||
if {$currSuperState != $FLIPOFF && $stateArr(curr) > [sct currTol] && $stateArr(O) && $stateArr(CV)} {
|
||||
broadcast "WARNING: RF generator has switched to voltage control, voltage = $stateArr(voltage)"
|
||||
if {$stateArr(voltage) >= $MAXVOLTAGE} {
|
||||
sct ramping $FLIPOFF
|
||||
}
|
||||
}
|
||||
|
||||
return stateChange
|
||||
}
|
||||
|
||||
##
|
||||
# @brief State transition function
|
||||
proc ::scobj::rfgen::stateFunc {} {
|
||||
variable RAMPIDLE
|
||||
variable RAMPSTOP
|
||||
variable RAMPSTART
|
||||
variable RAMPBUSY
|
||||
variable RAMPTOZERO
|
||||
variable FLIPOFF
|
||||
variable MAXVOLTAGE
|
||||
|
||||
set basePath [sct]
|
||||
|
||||
set currSuperState [sct ramping]
|
||||
mkStatArr stateArr [hval $basePath/state_report]
|
||||
set currControlStatus [sct status]
|
||||
|
||||
|
||||
switch $currSuperState [ subst -nocommands {
|
||||
$RAMPSTART {
|
||||
# broadcast RAMPSTART
|
||||
if [string match $currControlStatus "IDLE"] {
|
||||
statemon start flipper
|
||||
sct status "BUSY"
|
||||
sct ramping $RAMPBUSY
|
||||
return ramp
|
||||
} else {
|
||||
# Flipper is off, set current to zero before switching on
|
||||
sct origTargetCurr [sct targetCurr]
|
||||
sct targetCurr 0
|
||||
sct OutputState 0
|
||||
sct ramping $RAMPTOZERO
|
||||
return ramp
|
||||
}
|
||||
}
|
||||
$RAMPTOZERO {
|
||||
# broadcast RAMPTOZERO
|
||||
if {$stateArr(curr) <= [sct currTol]} {
|
||||
# We've reached a safe state so switch on and ramp to target current
|
||||
sct targetCurr [sct origTargetCurr]
|
||||
sct OutputState 1
|
||||
sct ramping $RAMPBUSY
|
||||
} else {
|
||||
sct targetCurr 0
|
||||
sct OutputState 0
|
||||
}
|
||||
return ramp
|
||||
}
|
||||
$RAMPBUSY {
|
||||
# broadcast RAMPBUSY
|
||||
if { [expr {abs($stateArr(curr) - [sct targetCurr])}] <= [sct currTol] } {
|
||||
sct ramping $RAMPSTOP
|
||||
return idle
|
||||
}
|
||||
return ramp
|
||||
}
|
||||
$FLIPOFF {
|
||||
sct targetCurr 0
|
||||
sct OutputState 0
|
||||
if { $stateArr(curr) <= [sct currTol] } {
|
||||
sct ramping $RAMPSTOP
|
||||
broadcast "ERROR: Spin flipper switched off voltage exceeds $MAXVOLTAGE in voltage control state, check vacuum"
|
||||
return idle
|
||||
} else {
|
||||
return ramp
|
||||
}
|
||||
}
|
||||
$RAMPSTOP {
|
||||
# broadcast RAMPSTOP
|
||||
if [string match $currControlStatus "BUSY"] {
|
||||
statemon stop flipper
|
||||
sct status "IDLE"
|
||||
}
|
||||
sct ramping $RAMPIDLE
|
||||
return idle
|
||||
}
|
||||
$RAMPIDLE {
|
||||
# broadcast RAMPIDLE
|
||||
return idle
|
||||
}
|
||||
}]
|
||||
}
|
||||
|
||||
##
|
||||
# @brief Ramps the current up or down in steps of 0.5A and/or sets the frequency
|
||||
proc ::scobj::rfgen::rampFunc {} {
|
||||
set basePath [sct]
|
||||
set currSuperState [sct ramping]
|
||||
mkStatArr stateArr [hval $basePath/state_report]
|
||||
|
||||
set targetCurr [sct targetCurr]
|
||||
set SCT_RFGEN [sct contname]
|
||||
set K1 [sct K1]
|
||||
set K2 [sct K2]
|
||||
set K3 [sct K3]
|
||||
set targetFreq [sct targetFreq]
|
||||
set output [sct OutputState]
|
||||
|
||||
if { [expr {abs($stateArr(curr) - $targetCurr)}] <= [sct currTol] } {
|
||||
set curr $targetCurr
|
||||
} elseif {$targetCurr < $stateArr(curr)} {
|
||||
set curr [expr $stateArr(curr)-5]
|
||||
if {$curr < $targetCurr} {
|
||||
set curr $targetCurr
|
||||
}
|
||||
} elseif {$targetCurr > $stateArr(curr)} {
|
||||
set curr [expr $stateArr(curr)+5]
|
||||
if {$curr > $targetCurr} {
|
||||
set curr $targetCurr
|
||||
}
|
||||
}
|
||||
set reply [$SCT_RFGEN send "S:[sct address]:I=$curr:F=$targetFreq:K3=$K3:K2=$K2:K1=$K1:O=$output"]
|
||||
|
||||
return idle
|
||||
}
|
||||
|
||||
|
||||
##
|
||||
# @brief Make an RF generator control object
|
||||
#
|
||||
# @param argList, {name "analyser" address "1" opCurr 68 opFreq 241 IP localhost PORT 65123 tuning 0 interval 1}
|
||||
#
|
||||
# name: name of RF generator object
|
||||
# address: address assigned to RF generator 1-9
|
||||
# opCurr: the operating current, when you switch it on it will ramp to this current
|
||||
# opFreq: the operating frequency, when you switch it on it will set this frequency
|
||||
# IP: IP address of RF generator moxa box
|
||||
# PORT: Port number assigned to the generator on the moxa-box
|
||||
# tuning: boolean, set tuning=1 to allow instrument scientists to set the current and frequency
|
||||
# interval: polling and ramping interval in seconds. One sets the ramp rate to 0.5A/s
|
||||
proc ::scobj::rfgen::mkRFGen {argList} {
|
||||
variable RAMPIDLE
|
||||
|
||||
# Generate parameter array from the argument list
|
||||
foreach {k v} $argList {
|
||||
set KEY [string toupper $k]
|
||||
set pa($KEY) $v
|
||||
}
|
||||
|
||||
MakeSICSObj $pa(NAME) SCT_OBJECT
|
||||
sicslist setatt $pa(NAME) klass instrument
|
||||
sicslist setatt $pa(NAME) long_name $pa(NAME)
|
||||
|
||||
# hfactory /sics/$pa(NAME)/status plain spy text
|
||||
hsetprop /sics/$pa(NAME) status "IDLE"
|
||||
hfactory /sics/$pa(NAME)/state_report plain internal text
|
||||
hfactory /sics/$pa(NAME)/flip_current plain internal float
|
||||
hfactory /sics/$pa(NAME)/flip_frequency plain internal int
|
||||
hfactory /sics/$pa(NAME)/flip_voltage plain internal int
|
||||
hfactory /sics/$pa(NAME)/flip_on plain internal int
|
||||
|
||||
hsetprop /sics/$pa(NAME) read ::scobj::rfgen::rqStatFunc
|
||||
hsetprop /sics/$pa(NAME) rdState ::scobj::rfgen::rdStatFunc
|
||||
hsetprop /sics/$pa(NAME) stateChange ::scobj::rfgen::stateFunc
|
||||
hsetprop /sics/$pa(NAME) ramp ::scobj::rfgen::rampFunc
|
||||
|
||||
hsetprop /sics/$pa(NAME) address $pa(ADDRESS)
|
||||
hsetprop /sics/$pa(NAME) tuning $pa(TUNING)
|
||||
hsetprop /sics/$pa(NAME) ramping $RAMPIDLE
|
||||
hsetprop /sics/$pa(NAME) opCurr $pa(OPCURR)
|
||||
hsetprop /sics/$pa(NAME) opFreq $pa(OPFREQ)
|
||||
hsetprop /sics/$pa(NAME) targetCurr 0
|
||||
hsetprop /sics/$pa(NAME) origTargetCurr 0
|
||||
hsetprop /sics/$pa(NAME) oldStateRep ""
|
||||
|
||||
hsetprop /sics/$pa(NAME) K1 $pa(K1)
|
||||
hsetprop /sics/$pa(NAME) K2 $pa(K2)
|
||||
hsetprop /sics/$pa(NAME) K3 $pa(K3)
|
||||
hsetprop /sics/$pa(NAME) currTol $pa(CURRTOL)
|
||||
|
||||
hfactory /sics/$pa(NAME)/comp_current plain internal float
|
||||
hsetprop /sics/$pa(NAME)/comp_current units "A"
|
||||
hset /sics/$pa(NAME)/comp_current $pa(COMPCURR)
|
||||
hfactory /sics/$pa(NAME)/guide_current plain internal float
|
||||
hsetprop /sics/$pa(NAME)/guide_current units "A"
|
||||
hset /sics/$pa(NAME)/guide_current $pa(GUIDECURR)
|
||||
hfactory /sics/$pa(NAME)/thickness plain internal float
|
||||
hsetprop /sics/$pa(NAME)/thickness units "mm"
|
||||
hset /sics/$pa(NAME)/thickness $pa(THICKNESS)
|
||||
|
||||
hfactory /sics/$pa(NAME)/switch_on plain user int
|
||||
hsetprop /sics/$pa(NAME)/switch_on write ::scobj::rfgen::switch_on /sics/$pa(NAME)
|
||||
# Only create the set current and frequency nodes when commissioning
|
||||
|
||||
# Initialise properties required for generating the API for GumTree and to save data
|
||||
::scobj::hinitprops $pa(NAME) flip_current flip_frequency flip_voltage flip_on comp_current guide_current thickness
|
||||
hsetprop /sics/$pa(NAME)/comp_current mutable false
|
||||
hsetprop /sics/$pa(NAME)/guide_current mutable false
|
||||
hsetprop /sics/$pa(NAME)/thickness mutable false
|
||||
|
||||
if {[SplitReply [rfgen_simulation]] == "false"} {
|
||||
set SCT_RFGEN sct_rfgen_$pa(NAME)
|
||||
makesctcontroller $SCT_RFGEN rfamp $pa(IP):$pa(PORT)
|
||||
hsetprop /sics/$pa(NAME) contname $SCT_RFGEN
|
||||
mkStatArr stateArr [split [$SCT_RFGEN transact "L:$pa(ADDRESS)"] "|="]
|
||||
|
||||
hset /sics/$pa(NAME)/flip_current [expr {$stateArr(curr) / 10.0}]
|
||||
hset /sics/$pa(NAME)/flip_frequency $stateArr(freq)
|
||||
hset /sics/$pa(NAME)/flip_voltage $stateArr(voltage)
|
||||
hset /sics/$pa(NAME)/flip_on $stateArr(O)
|
||||
hsetprop /sics/$pa(NAME) targetFreq $stateArr(freq)
|
||||
hsetprop /sics/$pa(NAME) targetCurr $stateArr(curr)
|
||||
|
||||
$SCT_RFGEN poll /sics/$pa(NAME) $pa(INTERVAL)
|
||||
$SCT_RFGEN write /sics/$pa(NAME)/switch_on
|
||||
}
|
||||
|
||||
if {$pa(TUNING)} {
|
||||
hfactory /sics/$pa(NAME)/set_current plain user float
|
||||
hfactory /sics/$pa(NAME)/set_frequency plain user int
|
||||
|
||||
hsetprop /sics/$pa(NAME)/set_current write ::scobj::rfgen::set_current /sics/$pa(NAME)
|
||||
hsetprop /sics/$pa(NAME)/set_frequency write ::scobj::rfgen::set_frequency /sics/$pa(NAME)
|
||||
|
||||
if {[SplitReply [rfgen_simulation]] == "false"} {
|
||||
$SCT_RFGEN write /sics/$pa(NAME)/set_current
|
||||
$SCT_RFGEN write /sics/$pa(NAME)/set_frequency
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -35,14 +35,14 @@ namespace eval exp_mode {
|
||||
#3=DB
|
||||
#4=Single
|
||||
variable c1ht_pos
|
||||
set valid_modes [list SB DB FOC MT POL]
|
||||
set c1ht_pos [list 1057 806.7 557.1 320 68.9]
|
||||
set valid_modes [list SB DB FOC MT POL POLANAL]
|
||||
set c1ht_pos [list 1057 806.7 557.1 320 68.9 68.9]
|
||||
|
||||
command set_mode "text=[join $valid_modes ,] arg " { ;#need to change all softzero's
|
||||
global ::exp_mode::valid_modes
|
||||
if {[lsearch $::exp_mode::valid_modes $arg] == -1} {
|
||||
Clientput "Mode is: $::exp_mode::valid_modes - (POL, MT, FOC, DB, SB)"
|
||||
return -code error "Mode is: $::exp_mode::valid_modes - (polarisation,mt,focussing,DB,single)"
|
||||
Clientput "Mode is: $::exp_mode::valid_modes - (POL, POLANAL, MT, FOC, DB, SB)"
|
||||
return -code error "Mode is: $::exp_mode::valid_modes - (polarisation, polarisation and analysis, mt,focussing,DB,single)"
|
||||
} else {
|
||||
if { [catch {::exp_mode::set_guide_element $arg} errMsg] } {
|
||||
Clientput $errMsg
|
||||
@@ -81,7 +81,6 @@ namespace eval exp_mode {
|
||||
|
||||
return -code ok
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
##
|
||||
@@ -94,8 +93,8 @@ proc ::exp_mode::set_guide_element { arg } {
|
||||
|
||||
drive ss1u 0 ss1d 0 ss2u 0 ss2d 0 ss3u 0 ss3d 0 ss4u 0 ss4d 0
|
||||
if {[lsearch $::exp_mode::valid_modes $arg] == -1} {
|
||||
Clientput "Mode is: $::exp_mode::valid_modes - (polarisation,mt,focussing,DB,single)"
|
||||
return -code error "Mode is: $::exp_mode::valid_modes - (polarisation,mt,focussing,DB,single)"
|
||||
Clientput "Mode is: $::exp_mode::valid_modes - (polarisation, polarisation and analysis, mt, focussing, DB, single)"
|
||||
return -code error "Mode is: $::exp_mode::valid_modes - (polarisation,polarisation and analysis, mt, focussing, DB, single)"
|
||||
}
|
||||
|
||||
if {[catch {::exp_mode::checkMotionAndDrive c1ht [lindex $c1ht_pos [lsearch $::exp_mode::valid_modes $arg]]} errMsg]} {
|
||||
@@ -113,9 +112,9 @@ proc ::exp_mode::set_omega { arg } {
|
||||
return -code error "Please set the mode first"
|
||||
}
|
||||
|
||||
if {$arg<0} {
|
||||
return -code error "omega must be greater than 0"
|
||||
}
|
||||
# if {$arg<0} {
|
||||
# return -code error "omega must be greater than 0"
|
||||
# }
|
||||
#the modes is set to ensure that the right guide element is in place
|
||||
#someone may have changed it by hand. DO NOT REMOVE THIS FUNCTIONALITY
|
||||
#as it also has the effect of closing all the ssXvg gaps for safety.
|
||||
@@ -188,6 +187,15 @@ proc ::exp_mode::set_omega { arg } {
|
||||
}
|
||||
run sth $arg st3vt 0
|
||||
}
|
||||
POLANAL {
|
||||
if { [catch {
|
||||
checkMotion sth $arg
|
||||
checkMotion st3vt 0
|
||||
} errMsg ] } {
|
||||
return -code error $errMsg
|
||||
}
|
||||
run sth $arg st3vt 0
|
||||
}
|
||||
default {
|
||||
return -code error "omega driving not specified for that mode"
|
||||
}
|
||||
@@ -207,9 +215,9 @@ proc ::exp_mode::set_two_theta { arg } {
|
||||
if {$expomega == "NaN"} {
|
||||
return -code error "please set omega first"
|
||||
}
|
||||
if {$arg<0} {
|
||||
return -code error "two_theta is less than 0"
|
||||
}
|
||||
# if {$arg<0} {
|
||||
# return -code error "two_theta is less than 0"
|
||||
# }
|
||||
|
||||
set argrad [deg2rad $arg] ;#2theta position in radians
|
||||
set omegarad [deg2rad $expomega]
|
||||
@@ -287,23 +295,37 @@ proc ::exp_mode::set_two_theta { arg } {
|
||||
run st4vt $h2 dz $h1
|
||||
}
|
||||
POL {
|
||||
set d1 [SplitReply [dy]]
|
||||
set d2 [expr [SplitReply [slit4_distance]] - [SplitReply [sample_distance]]]
|
||||
set h1 [expr $d1 * tan($argrad)]
|
||||
set h2 [expr $d2 * tan($argrad)]
|
||||
if { [catch {isszst4vtsafe st4vt $h2} errMsg]} {return -code error $errMsg}
|
||||
if { [catch {
|
||||
checkMotion st4vt $h2
|
||||
checkMotion dz $h1
|
||||
} errMsg ] } {
|
||||
return -code error $errMsg
|
||||
}
|
||||
run st4vt $h2 dz $h1 analz -200 analtilt 0
|
||||
}
|
||||
POLANAL {
|
||||
set d1 [SplitReply [dy]]
|
||||
set d2 [expr [SplitReply [slit4_distance]] - [SplitReply [sample_distance]]]
|
||||
set d3 [expr [SplitReply [anal_distance]] - [SplitReply [sample_distance]]]
|
||||
set h1 [expr $d1 * tan($argrad)]
|
||||
set h2 [expr $d2 * tan($argrad)]
|
||||
set h3 [expr $d3 * tan($argrad)]
|
||||
set ang1 [expr $arg + 0.8]
|
||||
set ang1 [expr $arg]
|
||||
if { [catch {isszst4vtsafe st4vt $h2} errMsg]} {return -code error $errMsg}
|
||||
if { [catch {
|
||||
checkMotion st4vt $h2
|
||||
checkMotion dz $h1
|
||||
checkMotion analz $h3
|
||||
checkMotion analtilit $ang1
|
||||
checkMotion analtilt $ang1
|
||||
} errMsg ] } {
|
||||
return -code error $errMsg
|
||||
}
|
||||
run st4vt $h2 dz $h1 analz $h3 analtilit $ang1
|
||||
run st4vt $h2 dz $h1 analz $h3 analtilt $ang1
|
||||
}
|
||||
default {
|
||||
return -code error "two_theta not defined for that mode: $expmode"
|
||||
|
||||
@@ -53,6 +53,8 @@ proc ::histogram_memory::isc_initialize {} {
|
||||
|
||||
set ::histogram_memory::histmem_axes(HOR) /instrument/detector/x_bin
|
||||
set ::histogram_memory::histmem_axes(VER) /instrument/detector/y_bin
|
||||
set ::histogram_memory::histmem_axes(TOF) /instrument/detector/time_of_flight
|
||||
|
||||
} message ] {
|
||||
if {$::errorCode=="NONE"} {return $message}
|
||||
return -code error $message
|
||||
|
||||
@@ -40,6 +40,14 @@ foreach {vn klass units} {
|
||||
sicslist setatt $vn units $units
|
||||
}
|
||||
|
||||
foreach vn {
|
||||
slave
|
||||
master
|
||||
} {
|
||||
::utility::mkVar $vn int manager $vn true parameter false true
|
||||
sicslist setatt $vn mutable true
|
||||
}
|
||||
|
||||
foreach vn {
|
||||
mode
|
||||
guide_element
|
||||
@@ -50,7 +58,7 @@ foreach vn {
|
||||
|
||||
detector_distance 10000
|
||||
detector_base 300
|
||||
anal_distance 1808
|
||||
anal_distance 6894.94
|
||||
anal_base 20
|
||||
slit4_distance 5331.15
|
||||
slit4_base 20
|
||||
@@ -66,19 +74,21 @@ slit2_distance 1909.9
|
||||
slit2_base 20
|
||||
chopper4_distance 808
|
||||
chopper4_base 20
|
||||
chopper4_phase_offset 0.3246
|
||||
chopper4_phase_offset 14.465
|
||||
chopper3_distance 359
|
||||
chopper3_base 20
|
||||
chopper3_phase_offset 0.38500
|
||||
chopper3_phase_offset 14.59
|
||||
chopper2_distance 103
|
||||
chopper2_base 20
|
||||
chopper2_phase_offset -0.02
|
||||
chopper2_phase_offset 14.301
|
||||
chopper1_distance 0
|
||||
chopper1_base 20
|
||||
chopper1_phase_offset -1.857
|
||||
chopper1_phase_offset -29.801
|
||||
slit1_distance -256.1
|
||||
slit1_base 20
|
||||
mode NONE
|
||||
omega -1
|
||||
twotheta -1
|
||||
guide_element NONE
|
||||
master 1
|
||||
slave 3
|
||||
|
||||
@@ -25,7 +25,8 @@ fileeval $cfPath(parameters)/parameters.tcl
|
||||
fileeval $cfPath(plc)/plc.tcl
|
||||
fileeval $cfPath(counter)/counter.tcl
|
||||
fileeval $cfPath(environment)/magneticField/sct_bruker_BEC1.tcl
|
||||
fileeval $cfPath(environment)/temperature/sct_lakeshore_3xx.tcl
|
||||
fileeval $cfPath(environment)/temperature/sct_lakeshore_336.tcl
|
||||
fileeval $cfPath(environment)/temperature/sct_lakeshore_340.tcl
|
||||
fileeval $cfPath(hmm)/hmm_configuration.tcl
|
||||
fileeval $cfPath(nexus)/nxscripts.tcl
|
||||
fileeval $cfPath(hmm)/detector.tcl
|
||||
@@ -33,6 +34,7 @@ fileeval $cfPath(scan)/scan.tcl
|
||||
fileeval $cfPath(chopper)/chopper.tcl
|
||||
fileeval $cfPath(commands)/commands.tcl
|
||||
fileeval $cfPath(anticollider)/anticollider.tcl
|
||||
fileeval $cfPath(beamline)/polanal.tcl
|
||||
source gumxml.tcl
|
||||
|
||||
::utility::mkVar ::anticollider::protect_detector text manager protect_detector false detector true false
|
||||
@@ -40,7 +42,8 @@ source gumxml.tcl
|
||||
|
||||
# Driver for Bruker BEC1 power supply (1-Tesla Magnet)
|
||||
# driver short-name IP-address MoxaPort Tolerance(Amps)
|
||||
#add_bruker_BEC1 ma1 137.157.202.152 4444 0.1
|
||||
add_bruker_BEC1 ma1 137.157.202.152 4444 0.1
|
||||
#add_sct_ls340 tc1 137.157.202.150 4001 "\r" 5.0 5.0
|
||||
|
||||
server_init
|
||||
###########################################
|
||||
|
||||
@@ -15,7 +15,6 @@ config/nexus/nxscripts_common_1.tcl
|
||||
config/commands/commands_common.tcl
|
||||
config/motors/sct_positmotor_common.tcl
|
||||
config/environment/sct_protek_common.tcl
|
||||
config/environment/sct_mcr500_rheometer.tcl
|
||||
config/environment/temperature/sct_julabo_lh45.tcl
|
||||
config/environment/temperature/sct_lakeshore_340.tcl
|
||||
config/environment/temperature/sct_lakeshore_336.tcl
|
||||
|
||||
81
site_ansto/instrument/sans/config/counter/sct_rheometer.tcl
Normal file
81
site_ansto/instrument/sans/config/counter/sct_rheometer.tcl
Normal file
@@ -0,0 +1,81 @@
|
||||
## RHEOMETER CONTROL
|
||||
|
||||
proc rhCallBack {rootPath} {
|
||||
# if rhSpeed >= trigger then start histmem and pop trigger and time
|
||||
if {[hval $rootPath/runexp] != 1} {
|
||||
return idle
|
||||
}
|
||||
set trigList [hval $rootPath/triggerList]
|
||||
if {$trigList == "EMPTY"} {
|
||||
hset $rootPath/acqTime "EMPTY"
|
||||
hset $rootPath/runexp 0
|
||||
return idle
|
||||
}
|
||||
set acqTime [hval /sics/rhSpeed/acqTime]
|
||||
if {$acqTime == "EMPTY"} {
|
||||
broadcast "You must set acquisition time"
|
||||
return idle
|
||||
}
|
||||
set rhSpeed [hval $rootPath]
|
||||
set trigLevel [lindex $trigList 0]
|
||||
if {$rhSpeed >= $trigLevel } {
|
||||
set listLen [llength $trigList]
|
||||
if {$listLen > 1} {
|
||||
# If the rhSpeed has jumped over a number of trigger values then skip over those elements in the list
|
||||
for {set tlIndex 1} {$tlIndex < $listLen} {incr tlIndex} {
|
||||
set trigLevel [lindex $trigList $tlIndex]
|
||||
if {$rhSpeed < $trigLevel } {
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
histmem pause
|
||||
broadcast [info level 0] [hval $rootPath] trigger a [lindex $acqTime 0] second acquisition, sicstime [sicstime]
|
||||
histmem mode time
|
||||
histmem preset [lindex $acqTime 0]
|
||||
histmem start
|
||||
if {$listLen > 1} {
|
||||
# Pop trigger
|
||||
hset $rootPath/triggerList [lrange $trigList $tlIndex end]
|
||||
} else {
|
||||
hset $rootPath/triggerList "EMPTY"
|
||||
hset $rootPath/acqTime "EMPTY"
|
||||
hset $rootPath/runexp 0
|
||||
}
|
||||
if { $acqTime != "EMPTY" && [llength $acqTime] > 1} {
|
||||
hset $rootPath/acqTime [lrange $acqTime 1 end]
|
||||
}
|
||||
}
|
||||
return idle
|
||||
}
|
||||
|
||||
##
|
||||
# @brief Pop trigger and acquisition time
|
||||
proc rheometer_savehmmdata {rootPath} {
|
||||
set si [hval $rootPath/saveIndex]
|
||||
broadcast [info level 0]: save data index = $si, sicstime [sicstime]
|
||||
save $si
|
||||
if {[hval $rootPath/runexp] == 0} {
|
||||
hset $rootPath/saveIndex 0
|
||||
newfile clear
|
||||
} else {
|
||||
incr si
|
||||
hset $rootPath/saveIndex $si
|
||||
}
|
||||
}
|
||||
publish rheometer_savehmmdata user
|
||||
|
||||
|
||||
proc add_rheo {IP} {
|
||||
MakeProtek rhTorque $IP 4002
|
||||
MakeProtek rhSpeed $IP 4001 1.0 0.0 0.5 "rhCallBack /sics/rhSpeed"
|
||||
hfactory /sics/rhSpeed/saveIndex plain user int
|
||||
hset /sics/rhSpeed/saveIndex 0
|
||||
hfactory /sics/rhSpeed/triggerList plain user text
|
||||
hset /sics/rhSpeed/triggerList "EMPTY"
|
||||
hfactory /sics/rhSpeed/acqTime plain user text
|
||||
hset /sics/rhSpeed/acqTime "EMPTY"
|
||||
hfactory /sics/rhSpeed/runexp plain user float
|
||||
hset /sics/rhSpeed/runexp 0
|
||||
scriptcallback connect hmm COUNTEND "rheometer_savehmmdata /sics/rhSpeed"
|
||||
}
|
||||
@@ -251,11 +251,6 @@ proc rdPwdAck {} {
|
||||
hset $vs_root/status "busy"
|
||||
statemon start nvs_speed
|
||||
statemon start nvs_lambda
|
||||
if {[sct writestatus] == "start"} {
|
||||
# Called by drive adapter
|
||||
hsetprop $vs_root/setspeed driving 1
|
||||
hsetprop $vs_root/setLambda driving 1
|
||||
}
|
||||
return $nextState
|
||||
}
|
||||
|
||||
@@ -305,6 +300,7 @@ proc rdPwdAck {} {
|
||||
set state [lindex [hval $statuspath] $paramindex(state) end]
|
||||
set aspeed [lindex [hval $statuspath] $paramindex(aspeed) end]
|
||||
if {[string match {*CONTROL*} $state] || $aspeed != 0} {
|
||||
sct driving 0
|
||||
error "Not allowed while the velocity selector is running"
|
||||
}
|
||||
return OK
|
||||
@@ -314,6 +310,7 @@ proc is_Speed_in_blocked_range {speed} {
|
||||
variable blocked_speeds
|
||||
foreach {min max} $blocked_speeds {
|
||||
if {$min <= $speed && $speed <= $max} {
|
||||
sct driving 0
|
||||
error "Speed of $speed rpm is within the blocked range of $min to $max rpm"
|
||||
}
|
||||
}
|
||||
@@ -358,6 +355,7 @@ proc get_nearest_allowed_speed {speed} {
|
||||
set speed [sct target]
|
||||
set ttang [lindex [hval $statuspath] $paramindex(ttang) end]
|
||||
if {$ttang > 90} {
|
||||
sct driving 0
|
||||
error "ERROR: You must first initialise the turntable"
|
||||
}
|
||||
|
||||
@@ -372,6 +370,7 @@ proc checkBlockedWavelengths {statuspath} {
|
||||
set lambda [sct target]
|
||||
set ttang [lindex [hval $statuspath] $paramindex(ttang) end]
|
||||
if {$ttang > 90} {
|
||||
sct driving 0
|
||||
error "ERROR: You must first initialise the turntable"
|
||||
}
|
||||
set angle [lindex [hval $statuspath] $paramindex(ttang) end]
|
||||
@@ -424,11 +423,6 @@ proc halt {root} {
|
||||
hset $vs_root/status "busy"
|
||||
statemon start nvs_speed
|
||||
statemon start nvs_lambda
|
||||
if {[sct writestatus] == "start"} {
|
||||
# Called by drive adapter
|
||||
hsetprop $vs_root/setLambda driving 1
|
||||
hsetprop $vs_root/setspeed driving 1
|
||||
}
|
||||
return $nextState
|
||||
}
|
||||
|
||||
|
||||
@@ -37,7 +37,7 @@ fileeval $cfPath(environment)/temperature/sct_julabo_lh45.tcl
|
||||
fileeval $cfPath(environment)/temperature/sct_qlink.tcl
|
||||
fileeval $cfPath(environment)/magneticField/sct_oxford_ips.tcl
|
||||
fileeval $cfPath(environment)/environment.tcl
|
||||
fileeval $cfPath(environment)/sct_mcr500_rheometer.tcl
|
||||
fileeval $cfPath(environment)/sct_rheometer.tcl
|
||||
fileeval $cfPath(environment)/sct_protek_common.tcl
|
||||
fileeval $cfPath(beamline)/spin_flipper.tcl
|
||||
source gumxml.tcl
|
||||
|
||||
Reference in New Issue
Block a user