conman.c
Reduce log noise by setting iout = eInternal for macros. servlog.c Fixed timestamp in logfiles to get hours. hmm_configuration_common_1.tcl Added ML's mods to wombat config: ie BAT and FAT TABLE attributes and elements for multi-period acquisition and histo-streaming. Fixed "failed lsearch" bug. It's more robust to test for a non-successful lsearch instead of a failed lsearch. nxscripts_common_1.tcl SICS-297 Fixed Saving data series in a scratch file overwrites earlier entries. instdict_specification.tcl Added "scobj" kind and "sct_indexed_motor" sics object type for script context controllers and and objects. hipadaba_configuration_common.tcl Added sct_indexed_motor sics obj type to ::hdb::sobjadd and scobj kind to ::hdb::add_node sct_positmotor_common.tcl Update the index SICS variable when updating the current index value to make sure that the position is saved in the data file. You must now provide the hdb node_name when creating the sct posit motor. mk_sct_positmotor now sets the "param" and "long_name" attributes on the posit motor object util/utility.tcl Added ::utility::set_sct_indexed_motor_attributes to set SICS object attributes required for generating hdb info for an SCT_POSIT_MOTOR nxscript.c Merge the ansto mod to putslab (rev1.7) which adds support for saving unbuffered data from the histmem. sicshipadaba.c This incorporates the patch made to CommandSetCallback in rev1.10 so it can just be copied as is (ie no merge required). WARNING: There are changes to ListHdbNode to handle record separators which may affect us. Disabled sending hdb command start and stop messages because they break gumtree sicshdbfactory.c Disabled sending hdb command start and stop messages because they break gumtree hipadaba_configuration_common.tcl R2.4DEV The sct_posit_motor case of ::hdb::sobjadd is only needed to call add_node with kind=scobj. nxscripts_common_1.tcl R2.4DEV Added ::nexus::scobj::sdsinfo _gen_nxdict now skips nodes with data_type == "none" new util/script_context_util.tcl R2.4DEV Adds ::scobj::hinitprops command to initialise the hdb properties for script context object nodes. sct_positmotor_common.tcl R2.4DEV Use ::scobj::hinitprops utility command to initialise hdb properties on script context object parameter nodes. dynstring.c DynStringReplace should memcopy '\0', otherwise it can get the wrong length for iTextLen. Added DynStringReplaceWithLen to allow initialising a dynstring with char arrays which contain null chars and other non-ascii chars. Useful for read and write buffers in script context. ascon.c AsconRead return NULL for noResponse and AsconFailed otherwise the "result" node gets set with a spurious empty value. scriptcontext.c SctActionHandler only set the "result" node if there really is a reply. sicsobj.c Update from M.K. site_ansto.c Added galil and ordela hvps protocol handlers for scriptcontext. motor_dmc2280.c Allow home parameter to be outside of limits (for KOWARI) hardsup/makefile Added ordela HVPS protocol handler hardsup/sct_orhvpsprot.c New ordela HVPS protocol handler. Retries on NAKs and re-orders pot channels (ie toggles lower two bits). hardsup/sct_velselprot.c Start velocity selector protocol handler. hardsup/sct_galilprot.c Completed galil protocol handler. hipadaba_configuration_common.tcl Add new style SICS objects to hdb tree. instdict_specification.tcl Added scobj to kind list and sct_motor to sics object list. (and some housekeeping) hmm_configuration_common_1.tcl Added ratemaps to simulation. Fixe BAT_TABLE and added PERIOD_INDICES as per Mark Lesha's mods for multi-period acquisition. ratemaps now return float. sct_postimotor_common.tcl Now setting properties on the posit motor object so that it can be automatically added to the hdb tree. hrpd/config/motors/motor_configuration.tcl Fixed simulated msd motor so that it's handle properly in the hdb layer. sans/config/hmm/detector_ordela.tcl Updated the ordela calibration script to use the new sct_orhvpsprop.c script context controller. quokka_configuration.tcl Deleted lines which set the hdb properties for script context posit motors. This is now handled automatically as for other SICS objects. utility.tcl setpos now replaces the motor setpos subcommand. Added functions to set script context object attributes and sct_posit motor attributes. Created hparPath and hsibPath convenience commands for new-style SICS objects. script_context_util.tcl NEW! Adds hinitprops function to initialise the hdb properties for a script context object r2758 | ffr | 2008-12-12 17:53:53 +1100 (Fri, 12 Dec 2008) | 113 lines
This commit is contained in:
committed by
Douglas Clowes
parent
121aac2946
commit
e36e9f1146
4
ascon.c
4
ascon.c
@@ -519,11 +519,11 @@ int AsconWrite(Ascon *a, char *command, int noResponse) {
|
|||||||
char *AsconRead(Ascon *a) {
|
char *AsconRead(Ascon *a) {
|
||||||
if (a->noResponse) {
|
if (a->noResponse) {
|
||||||
a->noResponse=0;
|
a->noResponse=0;
|
||||||
return "";
|
return NULL;
|
||||||
}
|
}
|
||||||
if (a->state % 4 == AsconFailed) {
|
if (a->state % 4 == AsconFailed) {
|
||||||
a->state = AsconIdle;
|
a->state = AsconIdle;
|
||||||
return "";
|
return NULL;
|
||||||
}
|
}
|
||||||
if (a->responseValid) {
|
if (a->responseValid) {
|
||||||
a->responseValid = 0;
|
a->responseValid = 0;
|
||||||
|
|||||||
7
conman.c
7
conman.c
@@ -572,6 +572,9 @@ extern pServer pServ;
|
|||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
if (self->iMacro) {
|
||||||
|
iOut = eInternal;
|
||||||
|
}
|
||||||
return self->write(self,pBuffer,iOut);
|
return self->write(self,pBuffer,iOut);
|
||||||
}
|
}
|
||||||
/*-----------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------*/
|
||||||
@@ -710,8 +713,8 @@ static void writeToLogFiles(SConnection *self, char *buffer)
|
|||||||
iRet = 0;
|
iRet = 0;
|
||||||
}
|
}
|
||||||
if (/*iRet == 0 &&*/
|
if (/*iRet == 0 &&*/
|
||||||
buffer[0] == 'O' && buffer[1] == 'K' &&
|
iOut == eInternal || (buffer[0] == 'O' && buffer[1] == 'K' &&
|
||||||
(buffer[2] == '\0' || buffer[2] == '\r' || buffer[2] == '\n')) {
|
(buffer[2] == '\0' || buffer[2] == '\r' || buffer[2] == '\n'))) {
|
||||||
/* supress */ iRet = 0;
|
/* supress */ iRet = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|||||||
13
dynstring.c
13
dynstring.c
@@ -217,14 +217,13 @@
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
/*--------------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------------*/
|
||||||
int DynStringReplace(pDynString self, char *pText, int iPos)
|
int DynStringReplaceWithLen(pDynString self, char *pText, int iPos, int len) {
|
||||||
{
|
|
||||||
int iRequested, iRet;
|
int iRequested, iRet;
|
||||||
|
|
||||||
assert(self);
|
assert(self);
|
||||||
assert(self->iMAGIC == DYNMAGIC);
|
assert(self->iMAGIC == DYNMAGIC);
|
||||||
|
|
||||||
iRequested = strlen(pText) + iPos;
|
iRequested = len + iPos;
|
||||||
if(iRequested >= self->iBufferSize)
|
if(iRequested >= self->iBufferSize)
|
||||||
{
|
{
|
||||||
iRet = Resize(self,iRequested);
|
iRet = Resize(self,iRequested);
|
||||||
@@ -234,10 +233,14 @@
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
memcpy(&self->pBuffer[iPos],pText,strlen(pText)*sizeof(char));
|
memcpy(&self->pBuffer[iPos],pText,(1+len)*sizeof(char));
|
||||||
self->iTextLen = strlen(self->pBuffer);
|
self->iTextLen = len;
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
int DynStringReplace(pDynString self, char *pText, int iPos)
|
||||||
|
{
|
||||||
|
return DynStringReplaceWithLen(self, pText, iPos, strlen(pText));
|
||||||
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
char *GetCharArray(pDynString self)
|
char *GetCharArray(pDynString self)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -89,4 +89,9 @@
|
|||||||
/*
|
/*
|
||||||
removes all old dat from the dynstring
|
removes all old dat from the dynstring
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
int DynStringReplaceWithLen(pDynString self, char *pText, int iPos, int len);
|
||||||
|
/*
|
||||||
|
Useful for making dynstrings containing null chars and other non-Ascii chars
|
||||||
|
*/
|
||||||
#endif
|
#endif
|
||||||
|
|||||||
91
nxscript.c
91
nxscript.c
@@ -30,6 +30,7 @@
|
|||||||
#include "nxdict.h"
|
#include "nxdict.h"
|
||||||
#include "nxscript.h"
|
#include "nxscript.h"
|
||||||
#include "sicsdata.h"
|
#include "sicsdata.h"
|
||||||
|
#include "sicshipadaba.h"
|
||||||
|
|
||||||
extern char *trim(char *str);
|
extern char *trim(char *str);
|
||||||
|
|
||||||
@@ -399,6 +400,92 @@ static void putAttribute(SConnection *pCon, SicsInterp *pSics,
|
|||||||
NXopenpath(self->fileHandle,"/");
|
NXopenpath(self->fileHandle,"/");
|
||||||
}
|
}
|
||||||
/*----------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------*/
|
||||||
|
static void putHdb(SConnection *pCon, SicsInterp *pSics, pNXScript self,
|
||||||
|
int argc, char *argv[]){
|
||||||
|
pHdb node = NULL;
|
||||||
|
char alias[512];
|
||||||
|
hdbValue v;
|
||||||
|
float fVal, *floatAr = NULL;
|
||||||
|
int i;
|
||||||
|
int start[5],size[5];
|
||||||
|
|
||||||
|
if(argc < 3){
|
||||||
|
SCWrite(pCon,"ERROR: putHdb needs at least node name",
|
||||||
|
eError);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
node = FindHdbNode(NULL,argv[2], pCon);
|
||||||
|
if(node == NULL){
|
||||||
|
SCPrintf(pCon,eError,"ERROR: node %s not found", argv[2]);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
memset(alias,0,512*sizeof(char));
|
||||||
|
if(!GetHdbProperty(node,"nxalias", alias, 512)){
|
||||||
|
if(argc < 4) {
|
||||||
|
SCPrintf(pCon,eError,"ERROR: neither nxalias property nor alias on command line found for %s",
|
||||||
|
argv[2]);
|
||||||
|
return;
|
||||||
|
} else {
|
||||||
|
strncpy(alias, argv[3],512);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
GetHipadabaPar(node,&v,pCon);
|
||||||
|
if (strcmp(argv[3],"point")==0) {
|
||||||
|
NXDopenalias(self->fileHandle, self->dictHandle,alias);
|
||||||
|
start[0]=atoi(argv[4]); size[0]=1;
|
||||||
|
switch(v.dataType){
|
||||||
|
case HIPINT:
|
||||||
|
NXputslab(self->fileHandle,&v.v.intValue,start,size);
|
||||||
|
break;
|
||||||
|
case HIPFLOAT:
|
||||||
|
fVal = v.v.doubleValue;
|
||||||
|
NXputslab(self->fileHandle,&fVal,start,size);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
ReleaseHdbValue(&v);
|
||||||
|
NXopenpath(self->fileHandle,"/");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
switch(v.dataType){
|
||||||
|
case HIPNONE:
|
||||||
|
return;
|
||||||
|
break;
|
||||||
|
case HIPINT:
|
||||||
|
NXDputalias(self->fileHandle, self->dictHandle, alias,
|
||||||
|
&v.v.intValue);
|
||||||
|
break;
|
||||||
|
case HIPFLOAT:
|
||||||
|
fVal = v.v.doubleValue;
|
||||||
|
NXDputalias(self->fileHandle, self->dictHandle, alias,
|
||||||
|
&fVal);
|
||||||
|
break;
|
||||||
|
case HIPTEXT:
|
||||||
|
NXDputalias(self->fileHandle, self->dictHandle, alias,
|
||||||
|
v.v.text);
|
||||||
|
break;
|
||||||
|
case HIPINTAR:
|
||||||
|
case HIPINTVARAR:
|
||||||
|
NXDputalias(self->fileHandle, self->dictHandle, alias,
|
||||||
|
v.v.intArray);
|
||||||
|
break;
|
||||||
|
case HIPFLOATAR:
|
||||||
|
case HIPFLOATVARAR:
|
||||||
|
floatAr = malloc(v.arrayLength*sizeof(float));
|
||||||
|
if(floatAr == NULL){
|
||||||
|
SCPrintf(pCon,eError,"ERROR: out of memory writing %s", node->name);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
for(i = 0; i < v.arrayLength; i++){
|
||||||
|
floatAr[i] = v.v.floatArray[i];
|
||||||
|
}
|
||||||
|
NXDputalias(self->fileHandle, self->dictHandle, alias,
|
||||||
|
floatAr);
|
||||||
|
free(floatAr);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
ReleaseHdbValue(&v);
|
||||||
|
}
|
||||||
|
/*----------------------------------------------------------------------*/
|
||||||
static void updateHMDim(NXScript *self, pHistMem mem){
|
static void updateHMDim(NXScript *self, pHistMem mem){
|
||||||
int iDim[MAXDIM];
|
int iDim[MAXDIM];
|
||||||
int i, rank, timeLength, status;
|
int i, rank, timeLength, status;
|
||||||
@@ -1117,6 +1204,10 @@ static int handlePut(SConnection *pCon, SicsInterp *pSics, pNXScript self,
|
|||||||
/* ================*/
|
/* ================*/
|
||||||
putCounter(pCon,pSics,self, argc,argv);
|
putCounter(pCon,pSics,self, argc,argv);
|
||||||
return 1;
|
return 1;
|
||||||
|
} else if(strcmp(argv[1],"puthdb") == 0){
|
||||||
|
/* ================*/
|
||||||
|
putHdb(pCon,pSics,self, argc,argv);
|
||||||
|
return 1;
|
||||||
}else if(strcmp(argv[1],"puthm") == 0){
|
}else if(strcmp(argv[1],"puthm") == 0){
|
||||||
/*=================*/
|
/*=================*/
|
||||||
putHistogramMemory(pCon,pSics,self,argc, argv);
|
putHistogramMemory(pCon,pSics,self,argc, argv);
|
||||||
|
|||||||
@@ -275,7 +275,9 @@ static char *SctActionHandler(void *actionData, char *lastReply) {
|
|||||||
} else {
|
} else {
|
||||||
con = SCStorePush(controller->conn);
|
con = SCStorePush(controller->conn);
|
||||||
}
|
}
|
||||||
SetProp(node, controller->node, "result", lastReply);
|
if (lastReply != NULL) {
|
||||||
|
SetProp(node, controller->node, "result", lastReply);
|
||||||
|
}
|
||||||
if (controller->verbose && lastReply != NULL && *lastReply != '\0') {
|
if (controller->verbose && lastReply != NULL && *lastReply != '\0') {
|
||||||
SCPrintf(con, eWarning, "reply : %s", lastReply);
|
SCPrintf(con, eWarning, "reply : %s", lastReply);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -53,6 +53,7 @@
|
|||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
|
#include <time.h>
|
||||||
#include <sys/time.h>
|
#include <sys/time.h>
|
||||||
#include "ifile.h"
|
#include "ifile.h"
|
||||||
#include "conman.h"
|
#include "conman.h"
|
||||||
@@ -228,13 +229,15 @@ static const char* timestamp(struct timeval *tp) {
|
|||||||
static char ts[80];
|
static char ts[80];
|
||||||
int hh, mm, ss;
|
int hh, mm, ss;
|
||||||
struct timeval tv;
|
struct timeval tv;
|
||||||
|
struct tm *time;
|
||||||
if (tp)
|
if (tp)
|
||||||
tv = *tp;
|
tv = *tp;
|
||||||
else
|
else
|
||||||
gettimeofday(&tv, NULL);
|
gettimeofday(&tv, NULL);
|
||||||
hh = (tv.tv_sec / 3600) % 24;
|
time = localtime(&tv.tv_sec);
|
||||||
mm = (tv.tv_sec / 60) % 60;
|
hh = time->tm_hour;
|
||||||
ss = tv.tv_sec % 60;
|
mm = time->tm_min;
|
||||||
|
ss = time->tm_sec;
|
||||||
snprintf(ts, 80, "%02d:%02d:%02d.%06d", hh, mm, ss, (int) tv.tv_usec);
|
snprintf(ts, 80, "%02d:%02d:%02d.%06d", hh, mm, ss, (int) tv.tv_usec);
|
||||||
return ts;
|
return ts;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -245,7 +245,9 @@ static hdbCallbackReturn CommandSetCallback(pHdb node, void *userData,
|
|||||||
}
|
}
|
||||||
current = current->next;
|
current = current->next;
|
||||||
}
|
}
|
||||||
|
// SendHdbStatusMessage(node,"start");
|
||||||
status = HDBInvoke(pCon,pServ->pSics, GetCharArray(cmd));
|
status = HDBInvoke(pCon,pServ->pSics, GetCharArray(cmd));
|
||||||
|
// SendHdbStatusMessage(node,"stop");
|
||||||
DeleteDynString(cmd);
|
DeleteDynString(cmd);
|
||||||
if(status == 1){
|
if(status == 1){
|
||||||
return hdbContinue;
|
return hdbContinue;
|
||||||
|
|||||||
105
sicshipadaba.c
105
sicshipadaba.c
@@ -17,6 +17,8 @@
|
|||||||
* interpreter interface.
|
* interpreter interface.
|
||||||
*
|
*
|
||||||
* Refactored to new callback system, Markus Zolliker, Mark Koennecke, March 2008
|
* Refactored to new callback system, Markus Zolliker, Mark Koennecke, March 2008
|
||||||
|
*
|
||||||
|
* Added start and finished messages to commands. Mark Koennecke, November 2008
|
||||||
*/
|
*/
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
@@ -42,17 +44,13 @@ typedef enum {
|
|||||||
normal_protocol,
|
normal_protocol,
|
||||||
json_protocol,
|
json_protocol,
|
||||||
} Protocol;
|
} Protocol;
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
linefeed,
|
|
||||||
space,
|
|
||||||
} RecSep;
|
|
||||||
|
|
||||||
char *trim(char *str);
|
char *trim(char *str);
|
||||||
/*====================== Messages ==================================================*/
|
/*====================== Messages ==================================================*/
|
||||||
static char killID[] = {"killID"};
|
static char killID[] = {"killID"};
|
||||||
static char killInternalID[] = {"killInternalID"};
|
static char killInternalID[] = {"killInternalID"};
|
||||||
static char killPtr[] = {"killPtr"};
|
static char killPtr[] = {"killPtr"};
|
||||||
|
static char startID[] = {"start"};
|
||||||
|
static char stopID[] = {"stop"};
|
||||||
/*----------------------------------------------------------------------------------*/
|
/*----------------------------------------------------------------------------------*/
|
||||||
pHdbIDMessage GetKillIDMessage(pHdbMessage message){
|
pHdbIDMessage GetKillIDMessage(pHdbMessage message){
|
||||||
if(message->type == killID){
|
if(message->type == killID){
|
||||||
@@ -74,7 +72,38 @@ pHdbPtrMessage GetKillPtrMessage(pHdbMessage message){
|
|||||||
}
|
}
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
pHdbMessage GetHdbStartMessage(pHdbMessage message){
|
||||||
|
if(message->type == startID){
|
||||||
|
return (pHdbMessage)message;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
pHdbMessage GetHdbStopMessage(pHdbMessage message){
|
||||||
|
if(message->type == stopID){
|
||||||
|
return (pHdbMessage)message;
|
||||||
|
}
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
/*-----------------------------------------------------------------------------------*/
|
||||||
|
void SendHdbStatusMessage(pHdb node, char *status){
|
||||||
|
pHdbMessage pRes = NULL;
|
||||||
|
pRes = malloc(sizeof(hdbMessage));
|
||||||
|
if(pRes == NULL){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if(strcmp(status,"start") == 0){
|
||||||
|
pRes->type = startID;
|
||||||
|
} else if(strcmp(status,"stop") == 0){
|
||||||
|
pRes->type = stopID;
|
||||||
|
} else {
|
||||||
|
/* someone is trying to create an non existent message */
|
||||||
|
assert(0);
|
||||||
|
}
|
||||||
|
InvokeCallbackChain(node,pRes);
|
||||||
|
free(pRes);
|
||||||
|
}
|
||||||
/*=============== common callback functions used for SICS ===========================*/
|
/*=============== common callback functions used for SICS ===========================*/
|
||||||
static hdbCallbackReturn SICSCheckPermissionCallback(pHdb node, void *userData,
|
static hdbCallbackReturn SICSCheckPermissionCallback(pHdb node, void *userData,
|
||||||
pHdbMessage message){
|
pHdbMessage message){
|
||||||
@@ -197,13 +226,12 @@ static hdbCallbackReturn SICSDriveCallback(pHdb node, void *userData,
|
|||||||
|
|
||||||
dum = (pDummy)userData;
|
dum = (pDummy)userData;
|
||||||
assert(pCon != NULL && dum != NULL);
|
assert(pCon != NULL && dum != NULL);
|
||||||
GetHipadabaPath(node);
|
|
||||||
if(GetHdbProperty(node,"sicsdev",pSicsdev,79)){
|
if(GetHdbProperty(node,"sicsdev",pSicsdev,79)){
|
||||||
status = StartDevice(pServ->pExecutor,node->path,dum->pDescriptor,
|
status = StartDevice(pServ->pExecutor,pSicsdev,dum->pDescriptor,
|
||||||
userData, pCon, (float)v.v.doubleValue);
|
userData, pCon, (float)v.v.doubleValue);
|
||||||
} else {
|
} else {
|
||||||
status = StartDevice(pServ->pExecutor,node->path,dum->pDescriptor,
|
status = StartDevice(pServ->pExecutor,node->name,dum->pDescriptor,
|
||||||
userData, pCon, (float)v.v.doubleValue);
|
userData, pCon, (float)v.v.doubleValue);
|
||||||
}
|
}
|
||||||
if(status == 1){
|
if(status == 1){
|
||||||
return hdbContinue;
|
return hdbContinue;
|
||||||
@@ -281,8 +309,10 @@ static hdbCallbackReturn SICSFuncCallback(pHdb node, void *userData,
|
|||||||
}
|
}
|
||||||
func = (SICSOBJFunc)node->value.v.func;
|
func = (SICSOBJFunc)node->value.v.func;
|
||||||
if(func != NULL){
|
if(func != NULL){
|
||||||
|
SendHdbStatusMessage(node, "start");
|
||||||
status = func((pSICSOBJ)userData,(SConnection *)mm->callData,
|
status = func((pSICSOBJ)userData,(SConnection *)mm->callData,
|
||||||
node, par,nPar);
|
node, par,nPar);
|
||||||
|
SendHdbStatusMessage(node, "stop");
|
||||||
} else {
|
} else {
|
||||||
printf("Great Badness in calling SICSFuncCallback\n");
|
printf("Great Badness in calling SICSFuncCallback\n");
|
||||||
return hdbAbort;
|
return hdbAbort;
|
||||||
@@ -473,8 +503,33 @@ static hdbCallbackReturn SICSNotifyCallback(pHdb node, void *userData,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* handle start and stop messages
|
||||||
|
*/
|
||||||
|
if(GetHdbStartMessage(message) != NULL){
|
||||||
|
pPath = GetHipadabaPath(node);
|
||||||
|
result = CreateDynString(128,128);
|
||||||
|
DynStringConcat(result, pPath);
|
||||||
|
DynStringConcat(result," STARTED");
|
||||||
|
SCWriteInContext(cbInfo->pCon, GetCharArray(result), eEvent, cbInfo->context);
|
||||||
|
DeleteDynString(result);
|
||||||
|
free(pPath);
|
||||||
|
return hdbContinue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(GetHdbStopMessage(message) != NULL){
|
||||||
|
pPath = GetHipadabaPath(node);
|
||||||
|
result = CreateDynString(128,128);
|
||||||
|
DynStringConcat(result, pPath);
|
||||||
|
DynStringConcat(result," FINISHED");
|
||||||
|
SCWriteInContext(cbInfo->pCon, GetCharArray(result), eEvent, cbInfo->context);
|
||||||
|
DeleteDynString(result);
|
||||||
|
free(pPath);
|
||||||
|
return hdbContinue;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* react only on update messages
|
* Deal with update messages
|
||||||
*/
|
*/
|
||||||
if((mm = GetHdbUpdateMessage(message)) == NULL){
|
if((mm = GetHdbUpdateMessage(message)) == NULL){
|
||||||
return hdbContinue;
|
return hdbContinue;
|
||||||
@@ -1195,9 +1250,6 @@ static void SICSDeleteNodeData(pHdb node){
|
|||||||
if(node->name != NULL){
|
if(node->name != NULL){
|
||||||
free(node->name);
|
free(node->name);
|
||||||
}
|
}
|
||||||
if(node->path != NULL){
|
|
||||||
free(node->path);
|
|
||||||
}
|
|
||||||
ReleaseHdbValue(&node->value);
|
ReleaseHdbValue(&node->value);
|
||||||
node->magic = 000000;
|
node->magic = 000000;
|
||||||
|
|
||||||
@@ -1979,7 +2031,7 @@ static int MakeHdbNode(SConnection *pCon, SicsInterp *pSics, void *pData,
|
|||||||
eError);
|
eError);
|
||||||
return 0;
|
return 0;
|
||||||
} else {
|
} else {
|
||||||
length = atoi(argv[4]);
|
length = atoi(argv[3]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2425,7 +2477,7 @@ int isSICSHdbRO(pHdb node){
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static pDynString formatPlainList(pHdb node, RecSep recsep){
|
static pDynString formatPlainList(pHdb node){
|
||||||
pHdb current;
|
pHdb current;
|
||||||
pDynString result = NULL;
|
pDynString result = NULL;
|
||||||
|
|
||||||
@@ -2437,14 +2489,7 @@ static pDynString formatPlainList(pHdb node, RecSep recsep){
|
|||||||
current = node->child;
|
current = node->child;
|
||||||
while(current != NULL){
|
while(current != NULL){
|
||||||
DynStringConcat(result,current->name);
|
DynStringConcat(result,current->name);
|
||||||
switch (recsep) {
|
DynStringConcat(result,"\n");
|
||||||
case space:
|
|
||||||
DynStringConcat(result," ");
|
|
||||||
break;
|
|
||||||
case linefeed:
|
|
||||||
default:
|
|
||||||
DynStringConcat(result,"\n");
|
|
||||||
}
|
|
||||||
current = current->next;
|
current = current->next;
|
||||||
}
|
}
|
||||||
return result;
|
return result;
|
||||||
@@ -2621,16 +2666,12 @@ static int ListHdbNode(SConnection *pCon, SicsInterp *pSics, void *pData,
|
|||||||
listData = formatListWithVal(node);
|
listData = formatListWithVal(node);
|
||||||
} else if(strcmp(argv[1],"-cli") == 0){
|
} else if(strcmp(argv[1],"-cli") == 0){
|
||||||
listData = formatClientList(node);
|
listData = formatClientList(node);
|
||||||
} else if(strcmp(argv[1],"-space") == 0){
|
|
||||||
listData = formatPlainList(node, space);
|
|
||||||
} else if(strcmp(argv[1],"-linefeed") == 0){
|
|
||||||
listData = formatPlainList(node, linefeed);
|
|
||||||
} else {
|
} else {
|
||||||
if ((protocol = isJSON(pCon)) == 1) {
|
if ((protocol = isJSON(pCon)) == 1) {
|
||||||
listData = formatJSONList(node);
|
listData = formatJSONList(node);
|
||||||
outCode = eHdbEvent;
|
outCode = eHdbEvent;
|
||||||
} else {
|
} else {
|
||||||
listData = formatPlainList(node, linefeed);
|
listData = formatPlainList(node);
|
||||||
outCode = eEvent;
|
outCode = eEvent;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -2892,7 +2933,9 @@ static hdbCallbackReturn CommandSetCallback(pHdb node, void *userData,
|
|||||||
}
|
}
|
||||||
current = current->next;
|
current = current->next;
|
||||||
}
|
}
|
||||||
|
// SendHdbStatusMessage(node,"start");
|
||||||
status = HDBInvoke(pCon,pServ->pSics, GetCharArray(cmd));
|
status = HDBInvoke(pCon,pServ->pSics, GetCharArray(cmd));
|
||||||
|
// SendHdbStatusMessage(node,"stop");
|
||||||
DeleteDynString(cmd);
|
DeleteDynString(cmd);
|
||||||
if(status == 1){
|
if(status == 1){
|
||||||
return hdbContinue;
|
return hdbContinue;
|
||||||
|
|||||||
@@ -34,6 +34,9 @@ typedef struct {
|
|||||||
}hdbPtrMessage, *pHdbPtrMessage;
|
}hdbPtrMessage, *pHdbPtrMessage;
|
||||||
/*-----------------------------------------------------------------------------*/
|
/*-----------------------------------------------------------------------------*/
|
||||||
pHdbPtrMessage GetKillPtrMessage(pHdbMessage message);
|
pHdbPtrMessage GetKillPtrMessage(pHdbMessage message);
|
||||||
|
pHdbMessage GetHdbStartMessage(pHdbMessage message);
|
||||||
|
pHdbMessage GetHdbStopMessage(pHdbMessage message);
|
||||||
|
void SendHdbStatusMessage(pHdb node, char *status);
|
||||||
/*======================== data structure for automatic parameter update =======*/
|
/*======================== data structure for automatic parameter update =======*/
|
||||||
typedef struct {
|
typedef struct {
|
||||||
SConnection *pCon;
|
SConnection *pCon;
|
||||||
|
|||||||
66
sicsobj.c
66
sicsobj.c
@@ -5,6 +5,7 @@
|
|||||||
*
|
*
|
||||||
* Mark Koennecke, July 2007
|
* Mark Koennecke, July 2007
|
||||||
*/
|
*/
|
||||||
|
#include <stdio.h>
|
||||||
#include <sics.h>
|
#include <sics.h>
|
||||||
#include <tcl.h>
|
#include <tcl.h>
|
||||||
#include "assert.h"
|
#include "assert.h"
|
||||||
@@ -21,6 +22,50 @@ extern int decodeSICSPriv(char *txt); /* from access.c */
|
|||||||
void DefaultKill(void *data){
|
void DefaultKill(void *data){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
/*--------------------------------------------------------------------------*/
|
||||||
|
void DefaultFree(void *data){
|
||||||
|
if(data != NULL){
|
||||||
|
free(data);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
static void saveSICSNode(pHdb node, char *prefix, FILE *fd){
|
||||||
|
char newprefix[1024], val[20];
|
||||||
|
pHdb child;
|
||||||
|
hdbValue v;
|
||||||
|
pDynString data = NULL;
|
||||||
|
|
||||||
|
if(GetHdbProperty(node,"__save",val,20) == 1){
|
||||||
|
GetHipadabaPar(node,&v,NULL);
|
||||||
|
data = formatValue(v,node);
|
||||||
|
if(data != NULL){
|
||||||
|
fprintf(fd,"%s %s\n", prefix, GetCharArray(data));
|
||||||
|
DeleteDynString(data);
|
||||||
|
}
|
||||||
|
child = node->child;
|
||||||
|
while(child != NULL){
|
||||||
|
snprintf(newprefix,1024,"%s/%s", prefix,child->name);
|
||||||
|
saveSICSNode(node,newprefix,fd);
|
||||||
|
child = child->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
/*---------------------------------------------------------------------------*/
|
||||||
|
int SaveSICSOBJ(void *data, char *name, FILE *fd){
|
||||||
|
pSICSOBJ self = (pSICSOBJ)data;
|
||||||
|
char prefix[1024];
|
||||||
|
pHdb node;
|
||||||
|
|
||||||
|
if(self != NULL && self->objectNode != NULL){
|
||||||
|
node = self->objectNode->child;
|
||||||
|
while(node != NULL){
|
||||||
|
snprintf(prefix, 1024,"%s %s", name, node->name);
|
||||||
|
saveSICSNode(node, prefix, fd);
|
||||||
|
node = node->next;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
pSICSOBJ MakeSICSOBJv(char *name, char *class, int type, int priv){
|
pSICSOBJ MakeSICSOBJv(char *name, char *class, int type, int priv){
|
||||||
pSICSOBJ pNew = NULL;
|
pSICSOBJ pNew = NULL;
|
||||||
@@ -32,6 +77,7 @@ pSICSOBJ MakeSICSOBJv(char *name, char *class, int type, int priv){
|
|||||||
}
|
}
|
||||||
memset(pNew,0,sizeof(SICSOBJ));
|
memset(pNew,0,sizeof(SICSOBJ));
|
||||||
pNew->pDes = CreateDescriptor(class);
|
pNew->pDes = CreateDescriptor(class);
|
||||||
|
pNew->pDes->SaveStatus = SaveSICSOBJ;
|
||||||
if (type == HIPNONE) {
|
if (type == HIPNONE) {
|
||||||
pNew->objectNode = MakeHipadabaNode(name, HIPNONE, 1);
|
pNew->objectNode = MakeHipadabaNode(name, HIPNONE, 1);
|
||||||
} else {
|
} else {
|
||||||
@@ -87,7 +133,21 @@ static int invokeOBJFunction(pSICSOBJ object, pHdb commandNode, SConnection *pCo
|
|||||||
pHdb currentPar = NULL;
|
pHdb currentPar = NULL;
|
||||||
SICSOBJFunc pFunc = NULL;
|
SICSOBJFunc pFunc = NULL;
|
||||||
pHdb parArray[64];
|
pHdb parArray[64];
|
||||||
|
char buffer[1024];
|
||||||
|
|
||||||
|
/*
|
||||||
|
* If the first argument has the special name args, concatenate all arguments
|
||||||
|
* and put the result as text into this parameter. This allows for the
|
||||||
|
* object function to parse and interpret the arguments itself.
|
||||||
|
*/
|
||||||
|
if(commandNode->child != NULL && strcmp(commandNode->child->name,"args") == 0) {
|
||||||
|
Arg2Text(argc,argv,buffer,1024);
|
||||||
|
assignPar(commandNode->child,pCon,buffer);
|
||||||
|
parArray[0] = commandNode->child;
|
||||||
|
count = 1;
|
||||||
|
goto invoke;
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* assign parameters and fill parameter array for function at the same
|
* assign parameters and fill parameter array for function at the same
|
||||||
* time. Be lenient about missing parameters: Then the old values will
|
* time. Be lenient about missing parameters: Then the old values will
|
||||||
@@ -106,12 +166,14 @@ static int invokeOBJFunction(pSICSOBJ object, pHdb commandNode, SConnection *pCo
|
|||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
|
|
||||||
pFunc = (SICSOBJFunc)commandNode->value.v.func;
|
invoke: pFunc = (SICSOBJFunc)commandNode->value.v.func;
|
||||||
if(pFunc == NULL){
|
if(pFunc == NULL){
|
||||||
SCWrite(pCon,"ERROR: internal error, function not found",eError);
|
SCWrite(pCon,"ERROR: internal error, function not found",eError);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
SendHdbStatusMessage(commandNode,"start");
|
||||||
status = pFunc(object, pCon, commandNode, parArray,count);
|
status = pFunc(object, pCon, commandNode, parArray,count);
|
||||||
|
SendHdbStatusMessage(commandNode,"stop");
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
|
|||||||
@@ -29,7 +29,9 @@ pSICSOBJ MakeSICSOBJ(char *name, char *class);
|
|||||||
pSICSOBJ MakeSICSOBJv(char *name, char *class, int type, int priv);
|
pSICSOBJ MakeSICSOBJv(char *name, char *class, int type, int priv);
|
||||||
void KillSICSOBJ(void *data);
|
void KillSICSOBJ(void *data);
|
||||||
void DefaultKill(void *data);
|
void DefaultKill(void *data);
|
||||||
|
void DefaultFree(void *data);
|
||||||
|
|
||||||
|
int SaveSICSOBJ(void *data, char *name, FILE *fd);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This creates a new SICS object and installs it in the interpreter. It returns
|
* This creates a new SICS object and installs it in the interpreter. It returns
|
||||||
|
|||||||
@@ -8,9 +8,9 @@
|
|||||||
|
|
||||||
SRC = .
|
SRC = .
|
||||||
CC = gcc
|
CC = gcc
|
||||||
CFLAGS = -g -DLINUX $(DFORTIFY) -I$(SRC) -I../.. -Wall -Wno-unused
|
CFLAGS = -g -DLINUX $(DFORTIFY) -I$(SRC) -I../.. -Wall -Wno-unused -Wextra
|
||||||
|
|
||||||
HOBJ= nhq200util.o itc4util.o lh45util.o lakeshore340util.o west4100util.o asynsrv_utility.o geterrno.o strjoin.o chopper.o modbustcp.o sct_galilprot.o
|
HOBJ= nhq200util.o itc4util.o lh45util.o lakeshore340util.o west4100util.o asynsrv_utility.o geterrno.o strjoin.o chopper.o modbustcp.o sct_galilprot.o sct_orhvpsprot.o
|
||||||
|
|
||||||
libhlib.a: $(HOBJ)
|
libhlib.a: $(HOBJ)
|
||||||
rm -f libhlib.a
|
rm -f libhlib.a
|
||||||
|
|||||||
@@ -1,40 +1,102 @@
|
|||||||
|
/** @file Galil protocol handler for script-context based controllers.
|
||||||
|
*
|
||||||
|
* If you 'send' commands to a galil controller using this protocol you
|
||||||
|
* will get one of three possible responses,
|
||||||
|
* 1. A value
|
||||||
|
* eg
|
||||||
|
* 2. An acknowledgement (ie 'OK')
|
||||||
|
* eg
|
||||||
|
* sct_mc2 send "MOG"
|
||||||
|
* OK
|
||||||
|
* 3. An error message
|
||||||
|
* eg
|
||||||
|
* sct_mc2 send "BGG"
|
||||||
|
* ASCERR: 20 Begin not valid with motor off (during read finished)
|
||||||
|
*/
|
||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <ascon.h>
|
#include <ascon.h>
|
||||||
#include <ascon.i>
|
#include <ascon.i>
|
||||||
#include <dynstring.h>
|
#include <dynstring.h>
|
||||||
|
|
||||||
|
/** @brief Set line terminator before sending command
|
||||||
|
*/
|
||||||
|
int GalilWriteStart(Ascon *a) {
|
||||||
|
DynStringConcat(a->wrBuffer,"\r");
|
||||||
|
a->state = AsconWriting;
|
||||||
|
a->wrPos = 0;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** @brief Map galil replies to OK, ASCERR:..., value.
|
||||||
|
* You can use the first character to sort replies from a galil controller
|
||||||
|
* into four categories
|
||||||
|
* First character is,
|
||||||
|
* 'SPACE' This is followed by a value
|
||||||
|
* '?' Error, use 'TC 1' to get error code and message.
|
||||||
|
* ':' Command received, in response to commands which don't request data.
|
||||||
|
* '1-9' First digit of error-code followed by error message. (in response to 'TC 1')
|
||||||
|
*/
|
||||||
|
int GalilReading(Ascon *a) {
|
||||||
|
int ret;
|
||||||
|
char chr, ch[2];
|
||||||
|
|
||||||
|
ret = AsconReadChar(a->fd, &chr);
|
||||||
|
switch (chr) {
|
||||||
|
case ' ':
|
||||||
|
return AsconStdHandler(a);
|
||||||
|
break;
|
||||||
|
case '?':
|
||||||
|
DynStringClear(a->wrBuffer);
|
||||||
|
DynStringCopy(a->wrBuffer, "TC 1");
|
||||||
|
a->noResponse = 0;
|
||||||
|
a->state = AsconWriteStart;
|
||||||
|
a->responseValid=0;
|
||||||
|
a->wrPos = 0;
|
||||||
|
return 1;
|
||||||
|
break;
|
||||||
|
case ':':
|
||||||
|
DynStringReplace(a->rdBuffer, "OK",0);
|
||||||
|
a->state = AsconReadDone;
|
||||||
|
return 1;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
/* Check for first digit of errorcode followed by error message */
|
||||||
|
if ('1' <= chr && chr <= '9') {
|
||||||
|
ch[0] = chr;
|
||||||
|
ch[1] = '\0';
|
||||||
|
AsconStdHandler(a);
|
||||||
|
DynStringInsert(a->rdBuffer, ch, 0);
|
||||||
|
a->state = AsconReadDone;
|
||||||
|
AsconError(a, GetCharArray(a->rdBuffer), 0);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
/** brief Galil protocol handler.
|
||||||
|
* This handler formats commands (ie adds cr line terminator) and
|
||||||
|
* sorts replies into standard responses of
|
||||||
|
* <value>
|
||||||
|
* OK
|
||||||
|
* ASCERR:...
|
||||||
|
*/
|
||||||
int GalilProtHandler(Ascon *a) {
|
int GalilProtHandler(Ascon *a) {
|
||||||
int ret;
|
int ret;
|
||||||
char chr, *data;
|
|
||||||
|
switch(a->state){
|
||||||
switch(a->state){
|
case AsconWriteStart:
|
||||||
case AsconWriteStart:
|
ret = GalilWriteStart(a);
|
||||||
data = GetCharArray(a->wrBuffer);
|
return ret;
|
||||||
DynStringConcat(a->wrBuffer,"\r");
|
break;
|
||||||
a->state = AsconWriting;
|
case AsconReading:
|
||||||
a->wrPos = 0;
|
ret = GalilReading(a);
|
||||||
break;
|
return ret;
|
||||||
case AsconReading:
|
break;
|
||||||
ret = AsconReadChar(a->fd, &chr);
|
default:
|
||||||
switch (chr) {
|
return AsconStdHandler(a);
|
||||||
case ' ':
|
}
|
||||||
return AsconStdHandler(a);
|
return 1;
|
||||||
break;
|
|
||||||
case '?':
|
|
||||||
AsconError(a, "Galil Error", errno);
|
|
||||||
DynStringConcatChar(a->rdBuffer, '\0');
|
|
||||||
a->state = AsconReadDone;
|
|
||||||
break;
|
|
||||||
case ':':
|
|
||||||
DynStringConcatChar(a->rdBuffer, '\0');
|
|
||||||
a->state = AsconReadDone;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
return AsconStdHandler(a);
|
|
||||||
}
|
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void AddGalilProtocoll(){
|
void AddGalilProtocoll(){
|
||||||
|
|||||||
351
site_ansto/hardsup/sct_orhvpsprot.c
Normal file
351
site_ansto/hardsup/sct_orhvpsprot.c
Normal file
@@ -0,0 +1,351 @@
|
|||||||
|
/** @file OrdHVPS protocol handler for script-context based controllers.
|
||||||
|
* MJL 17/9/08 implement a special command mode to make life easier
|
||||||
|
*
|
||||||
|
TODO Make dhv1 object, refer to following cmd IO for scripting.
|
||||||
|
sct_dhv1 transact "P x4"
|
||||||
|
x4 6
|
||||||
|
sct_dhv1 transact v
|
||||||
|
ORDELA 2.10 07/24/00
|
||||||
|
sct_dhv1 transact H
|
||||||
|
56
|
||||||
|
set msg [sct_dhv1 transact {h 57}]
|
||||||
|
ACK
|
||||||
|
sct_dhv1 transact H
|
||||||
|
57
|
||||||
|
|
||||||
|
* TODO Remove globals and statics if we want to allow more controllers.
|
||||||
|
*/
|
||||||
|
#include <errno.h>
|
||||||
|
#include <ascon.h>
|
||||||
|
#include <ascon.i>
|
||||||
|
#include <dynstring.h>
|
||||||
|
#include <unistd.h>
|
||||||
|
|
||||||
|
#define ACK 6
|
||||||
|
#define NAK 21
|
||||||
|
#define MAXARGS 5
|
||||||
|
#define MAXARGLEN 32
|
||||||
|
#define ERRMSGLEN 127
|
||||||
|
#define MAXRETRY 3
|
||||||
|
static char cmdrspfmt[MAXARGLEN];
|
||||||
|
static char *pcmdrspfmt=cmdrspfmt;
|
||||||
|
static char cmdArgv[MAXARGS][MAXARGLEN];
|
||||||
|
/** @brief Format command before sending
|
||||||
|
*/
|
||||||
|
int OrdHVPSWriteStart(Ascon *a) {
|
||||||
|
char cmd[MAXARGLEN];
|
||||||
|
int cmd_len, ci,cj,bi;
|
||||||
|
char *wrBArray, ch;
|
||||||
|
|
||||||
|
// strcpy(wrBArray, GetCharArray(a->wrBuffer));
|
||||||
|
wrBArray = GetCharArray(a->wrBuffer);
|
||||||
|
cmd_len = GetDynStringLength(a->wrBuffer);
|
||||||
|
for (ci=2, cj=0, bi=0; ci<MAXARGS && bi<cmd_len && cj < MAXARGLEN; ci++) {
|
||||||
|
for (cj=0; (ch = wrBArray[bi]) != ' ' && bi<cmd_len; bi++, cj++)
|
||||||
|
cmdArgv[ci][cj] = ch;
|
||||||
|
cmdArgv[ci][cj] = '\0';
|
||||||
|
while (wrBArray[bi] == ' ' && bi < cmd_len)
|
||||||
|
bi++;
|
||||||
|
}
|
||||||
|
if (cj >= MAXARGLEN) {
|
||||||
|
a->state = AsconIdle;
|
||||||
|
AsconError(a, "Command or argument exceeds maximum length", 0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
pcmdrspfmt=cmdrspfmt;
|
||||||
|
// In command mode, the third argument is normally a single letter command
|
||||||
|
// and the remaining arguments are command parameters. For future expansion,
|
||||||
|
// we also allow the third argument to be an explicit command/response format.
|
||||||
|
// This is in format "<cmd>-<resp>" where the command and response fields
|
||||||
|
// are format specifiers containing the required/expected ASCII letters
|
||||||
|
// in the command, and the format specifiers '%s' (string),
|
||||||
|
// '%d' (integer 0-255), , '%B' (a board name e.g. x0-y15),
|
||||||
|
// '%P' (a pot name e.g. x0-y191), or '%A' (ack code as 'ACK'/'NAK').
|
||||||
|
// Formats '%c' (a character) and '%x' (char as 2 hex digits) could be
|
||||||
|
// added to the code if needed.
|
||||||
|
// Note '%P' translates to/from a two-byte board number plus pot number.
|
||||||
|
// Code '%A' only useable in response format.
|
||||||
|
if (strlen(cmdArgv[2])==1)
|
||||||
|
switch(*cmdArgv[2])
|
||||||
|
{
|
||||||
|
// All the known commands for the Ordela 21000N, at 9/08.
|
||||||
|
// If more become available, add them here, or alternately
|
||||||
|
// supply an appropriate command format string explicitly.
|
||||||
|
case 'v': pcmdrspfmt="vz-%sz"; break; // Get firmware version
|
||||||
|
case 'p': pcmdrspfmt="p%P%dz-%A"; break; // Set a pot value
|
||||||
|
case 'P': pcmdrspfmt="P%Pz-P%P%dz"; break; // Get a pot value
|
||||||
|
case 'h': pcmdrspfmt="h%dz-%A"; break; // Set HV voltage (also settable directly via the orhvps object)
|
||||||
|
case 'H': pcmdrspfmt="Hz-H%dz"; break; // Get HV setting
|
||||||
|
case 'd': pcmdrspfmt="dz-%A"; break; // Enter diagnostic mode (disables coincidence detection etc.)
|
||||||
|
case 'D': pcmdrspfmt="Dz-D%dz"; break; // Check if in diagnostic mode
|
||||||
|
case 'n': pcmdrspfmt="nz-%A"; break; // Exit diagnostic mode
|
||||||
|
case 'b': pcmdrspfmt="b%Bz-%A"; break; // Disable a board
|
||||||
|
case 'B': pcmdrspfmt="B%Bz-B%B%dz"; break; // Query if board disabled
|
||||||
|
case 'l': pcmdrspfmt="l%Bz-%A"; break; // Re-enable a board
|
||||||
|
case 'J': pcmdrspfmt="Jz-J%dz"; break; // Check jumper settings
|
||||||
|
}
|
||||||
|
// Prepare the command string
|
||||||
|
char *pcmd=cmd;
|
||||||
|
int nfmtspec=0;
|
||||||
|
while(*pcmdrspfmt!='-')
|
||||||
|
{
|
||||||
|
if (*pcmdrspfmt=='\0')
|
||||||
|
{
|
||||||
|
a->state = AsconIdle;
|
||||||
|
AsconError(a, "Missing '-' separator in format string", 0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (*pcmdrspfmt=='%') // format specifier
|
||||||
|
{
|
||||||
|
pcmdrspfmt++;
|
||||||
|
if (++nfmtspec>3)
|
||||||
|
{
|
||||||
|
a->state = AsconIdle;
|
||||||
|
AsconError(a, "Not enough arguments supplied for cmd", 0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int v1,v2;
|
||||||
|
switch(*pcmdrspfmt++)
|
||||||
|
{
|
||||||
|
case 's': // probably never used
|
||||||
|
pcmd+=sprintf(pcmd,"%s",cmdArgv[nfmtspec+2]);
|
||||||
|
break;
|
||||||
|
case 'd':
|
||||||
|
sscanf(cmdArgv[nfmtspec+2],"%d",&v1);
|
||||||
|
pcmd+=sprintf(pcmd,"%c",(char)v1);
|
||||||
|
break;
|
||||||
|
case 'B':
|
||||||
|
sscanf(cmdArgv[nfmtspec+2]+1,"%d",&v1);
|
||||||
|
v1+=(v1>=8)*8; // 0-15-> 0-7 and 16-23
|
||||||
|
v1+=(*cmdArgv[nfmtspec+2]=='y')*8; // y at 8-15 and 24-31
|
||||||
|
pcmd+=sprintf(pcmd,"%c",v1);
|
||||||
|
break;
|
||||||
|
case 'P':
|
||||||
|
sscanf(cmdArgv[nfmtspec+2]+1,"%d",&v1);
|
||||||
|
v1^=0x3;
|
||||||
|
v2=v1&0xF;
|
||||||
|
v1>>=4;
|
||||||
|
v1+=(v1>=8)*8;
|
||||||
|
v1+=(*cmdArgv[nfmtspec+2]=='y')*8;
|
||||||
|
pcmd+=sprintf(pcmd,"%c%c",v1,v2);
|
||||||
|
break;
|
||||||
|
// case 'A': is NOT supported - responses only!
|
||||||
|
default:
|
||||||
|
a->state = AsconIdle;
|
||||||
|
AsconError(a, "Unknown % specification in command format", 0);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
*pcmd++=*pcmdrspfmt++; // Simple ASCII character that is part of command
|
||||||
|
}
|
||||||
|
pcmdrspfmt++; // skip over the '-' separator into the response format
|
||||||
|
cmd_len=pcmd-cmd;
|
||||||
|
cmd[cmd_len] = '\0';
|
||||||
|
DynStringReplaceWithLen(a->wrBuffer,cmd,0,cmd_len);
|
||||||
|
a->state = AsconWriting;
|
||||||
|
a->wrPos = 0;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int OrdFmtReply(char *rdBArray, int rsp_len, char *response, char *errmsg) {
|
||||||
|
int ret, i, idx, bnum;
|
||||||
|
char chr, ch[2];
|
||||||
|
char *rsp;
|
||||||
|
int error_in_cmd_rsp_parse=0;
|
||||||
|
//int rsp_len;
|
||||||
|
// Start parsing the response according to the format string.
|
||||||
|
// If we don't get what we expect, set error_in_cmd_rsp_parse
|
||||||
|
// so that the response is output in 'send' format.
|
||||||
|
// Only output the parameters in the response format, not ASCII's
|
||||||
|
char *pcmd;
|
||||||
|
char *prsp;
|
||||||
|
int got_fmt_rsp=0;
|
||||||
|
#if 0
|
||||||
|
AsconStdHandler(a);
|
||||||
|
/*
|
||||||
|
ffr If AsconStdHandler doesn't see a '\r' or '\n' and there are no more
|
||||||
|
chars to read, it leaves state=AsconReading and the rdBuffer char array
|
||||||
|
without a null terminator. So we assume that higher level code can tell
|
||||||
|
if the response is OK and set the state and terminator.
|
||||||
|
*/
|
||||||
|
DynStringConcatChar(a->rdBuffer, '\0');
|
||||||
|
a->state = AsconReadDone;
|
||||||
|
#else
|
||||||
|
//if (0 == OrdReadChars(a)) return 0;
|
||||||
|
#endif
|
||||||
|
pcmd = response;
|
||||||
|
rsp=rdBArray;
|
||||||
|
//rsp_len = GetDynStringLength(a->rdBuffer);
|
||||||
|
prsp = rsp;
|
||||||
|
while (*pcmdrspfmt&&!error_in_cmd_rsp_parse)
|
||||||
|
{
|
||||||
|
if (prsp-rsp>=rsp_len)
|
||||||
|
error_in_cmd_rsp_parse=1; // response is too short - no bytes left to parse
|
||||||
|
else if (*pcmdrspfmt=='%') // Parse byte(s)
|
||||||
|
{
|
||||||
|
pcmdrspfmt++;
|
||||||
|
if (got_fmt_rsp)
|
||||||
|
*pcmd++=' '; // separate response fields with spaces (Tcl list can separate these)
|
||||||
|
int slen;
|
||||||
|
switch(*pcmdrspfmt++)
|
||||||
|
{
|
||||||
|
case 's':
|
||||||
|
pcmd+=(slen=sprintf(pcmd,"%s",prsp));
|
||||||
|
*--pcmd='\0'; // string should have been terminated (with a 'z') but that gets checked later
|
||||||
|
prsp+=slen-1;
|
||||||
|
break;
|
||||||
|
case 'd':
|
||||||
|
pcmd+=sprintf(pcmd,"%d",*prsp++);
|
||||||
|
break;
|
||||||
|
case 'B':
|
||||||
|
pcmd+=sprintf(pcmd,"%c%d",(prsp[0]&0x8)?'y':'x',(prsp[0]&0x7)+((prsp[0]&0x10)>>1));
|
||||||
|
prsp++;
|
||||||
|
break;
|
||||||
|
case 'P':
|
||||||
|
if (rsp_len-(prsp-rsp)<2)
|
||||||
|
error_in_cmd_rsp_parse=1;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
bnum =0x3^( (prsp[0]&0x7)*0x10+(prsp[0]&0x10)*0x8+prsp[1] );
|
||||||
|
pcmd+=sprintf(pcmd,"%c%d",(prsp[0]&0x8)?'y':'x',bnum);
|
||||||
|
prsp+=2;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 'A':
|
||||||
|
error_in_cmd_rsp_parse|=(prsp[0]!=0x06&&prsp[0]!=0x15);
|
||||||
|
pcmd+=sprintf(pcmd,"%s",(prsp[0]==0x06)?"ACK":"NAK");
|
||||||
|
prsp++;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
// a->state = AsconReadDone;
|
||||||
|
// AsconError(a, "Unknown % specification in response format", 0);
|
||||||
|
sprintf(errmsg, "Unknown specification for response format");
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
got_fmt_rsp=1;
|
||||||
|
}
|
||||||
|
else // expected ASCII characters in response have to match response format
|
||||||
|
error_in_cmd_rsp_parse|=(*prsp++!=*pcmdrspfmt++);
|
||||||
|
}
|
||||||
|
if (error_in_cmd_rsp_parse) {
|
||||||
|
idx=0;
|
||||||
|
idx=sprintf(errmsg,"Bad response format: ");
|
||||||
|
for (i = 0; i < rsp_len && idx < 31; ++i) {
|
||||||
|
if (response[i] < 32 || response[i] > 126)
|
||||||
|
idx+=sprintf(&errmsg[idx], "%02Xh", response[i]);
|
||||||
|
else
|
||||||
|
errmsg[idx++] = response[i];
|
||||||
|
}
|
||||||
|
// if (idx < 31)
|
||||||
|
errmsg[idx++] = '\0';
|
||||||
|
|
||||||
|
// a->state = AsconReadDone;
|
||||||
|
// AsconError(a, errmsg, 0);
|
||||||
|
return -1;
|
||||||
|
} else {
|
||||||
|
// a->state = AsconReadDone;
|
||||||
|
// DynStringReplace(a->rdBuffer,response,0);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
int OrdHVPSReading(Ascon *a) {
|
||||||
|
int ret, rsp_len;
|
||||||
|
static int retries = MAXRETRY;
|
||||||
|
char chr, errmsg[ERRMSGLEN], response[MAXARGLEN];
|
||||||
|
|
||||||
|
ret = AsconReadChar(a->fd, &chr);
|
||||||
|
if (ret > 0 && chr == NAK && retries > 0) {
|
||||||
|
AsconReadGarbage(a->fd);
|
||||||
|
a->state = AsconWriting;
|
||||||
|
a->wrPos = 0;
|
||||||
|
retries--;
|
||||||
|
return 0;
|
||||||
|
} else if (retries <= 0) {
|
||||||
|
a->state = AsconReadDone;
|
||||||
|
AsconError(a, "Received too many NAKs", 0);
|
||||||
|
retries = MAXRETRY;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
retries = MAXRETRY;
|
||||||
|
while (ret > 0) {
|
||||||
|
a->start = DoubleTime();
|
||||||
|
|
||||||
|
if (ACK == chr) {
|
||||||
|
a->state = AsconReadDone;
|
||||||
|
DynStringConcatChar(a->rdBuffer, chr);
|
||||||
|
} else if (chr == 'z') {
|
||||||
|
a->state = AsconReadDone;
|
||||||
|
DynStringConcatChar(a->rdBuffer, 'z');
|
||||||
|
break;
|
||||||
|
} else {
|
||||||
|
if (DynStringConcatChar(a->rdBuffer, chr) == 0) {
|
||||||
|
a->state = AsconReadDone;
|
||||||
|
AsconError(a, "DynStringConcatChar failed:", ENOMEM);
|
||||||
|
return 1;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
ret = AsconReadChar(a->fd, &chr);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (a->state != AsconReadDone) {
|
||||||
|
if (a->timeout > 0) {
|
||||||
|
if (DoubleTime() - a->start > a->timeout) {
|
||||||
|
AsconError(a, "read timeout", 0);
|
||||||
|
a->state = AsconTimeout;
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
rsp_len = GetDynStringLength(a->rdBuffer);
|
||||||
|
if (OrdFmtReply(GetCharArray(a->rdBuffer), rsp_len, response, errmsg) >= 0) {
|
||||||
|
DynStringReplace(a->rdBuffer,response,0);
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
AsconError(a, errmsg, 0);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/** brief OrdHVPS protocol handler.
|
||||||
|
* This handler formats commands (ie adds cr line terminator) and
|
||||||
|
* sorts replies into standard responses of
|
||||||
|
* <value>
|
||||||
|
* OK
|
||||||
|
* ASCERR:...
|
||||||
|
*/
|
||||||
|
int OrdHVPSProtHandler(Ascon *a) {
|
||||||
|
int ret;
|
||||||
|
|
||||||
|
switch(a->state){
|
||||||
|
case AsconWriteStart:
|
||||||
|
ret = OrdHVPSWriteStart(a);
|
||||||
|
return ret;
|
||||||
|
break;
|
||||||
|
case AsconReading:
|
||||||
|
ret = OrdHVPSReading(a);
|
||||||
|
return ret;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return AsconStdHandler(a);
|
||||||
|
}
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
void AddOrdHVPSProtocoll(){
|
||||||
|
AsconProtocol *prot = NULL;
|
||||||
|
|
||||||
|
pcmdrspfmt = (char *) malloc(128);
|
||||||
|
prot = calloc(sizeof(AsconProtocol), 1);
|
||||||
|
prot->name = strdup("ordhvps");
|
||||||
|
prot->init = AsconStdInit;
|
||||||
|
prot->handler = OrdHVPSProtHandler;
|
||||||
|
AsconInsertProtocol(prot);
|
||||||
|
}
|
||||||
204
site_ansto/hardsup/sct_velselprot.c
Normal file
204
site_ansto/hardsup/sct_velselprot.c
Normal file
@@ -0,0 +1,204 @@
|
|||||||
|
/**
|
||||||
|
* @file Astrium Velocity Selector protocol
|
||||||
|
* @Author Ferdi Franceschini
|
||||||
|
*/
|
||||||
|
#include <errno.h>
|
||||||
|
#include <ascon.h>
|
||||||
|
#include <ascon.i>
|
||||||
|
#include <dynstring.h>
|
||||||
|
|
||||||
|
#define MAXRETRIES 3
|
||||||
|
static char *UIDPROMPT="#SES#Fill in your user ID";
|
||||||
|
static char *PWDPROMPT="#SES#Fill in your password";
|
||||||
|
static char *CMDOK="#SOS#ACCEPT";
|
||||||
|
static char *CMDERR="#SOS#NCCEPT";
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
Unknown,
|
||||||
|
sendUID,
|
||||||
|
sendPWD,
|
||||||
|
Established
|
||||||
|
} VelSelState;
|
||||||
|
typedef struct {
|
||||||
|
VelSelState subState;
|
||||||
|
char *user;
|
||||||
|
char *password;
|
||||||
|
char *expect;
|
||||||
|
int retries;
|
||||||
|
} VelSelProt, *pVelSelProt;
|
||||||
|
|
||||||
|
void VelSelAuthUID(Ascon *a) {
|
||||||
|
char chr;
|
||||||
|
int ret;
|
||||||
|
}
|
||||||
|
void VelSelAuthPwd(Ascon *a) {
|
||||||
|
}
|
||||||
|
void VelSelAuthenticate(Ascon *a) {
|
||||||
|
char chr;
|
||||||
|
int ret;
|
||||||
|
pVelSelProt pVelSel = (pVelSelProt)a->private;
|
||||||
|
|
||||||
|
switch (pVelSel->authProg) {
|
||||||
|
case start:
|
||||||
|
break;
|
||||||
|
case readingUIDPrompt:
|
||||||
|
break;
|
||||||
|
case readingPWDPrompt:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
ret = AsconReadChar(a->fd, &chr);
|
||||||
|
if (ret > 0 && chr == '#') {
|
||||||
|
while (AsconReadChar(a->fd, &chr) > 0) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (a->state != AsconReadDone) {
|
||||||
|
if (a->timeout > 0) {
|
||||||
|
if (DoubleTime() - a->start > a->timeout) {
|
||||||
|
AsconError(a, "read timeout", 0);
|
||||||
|
a->state = AsconTimeout;
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
int VelSelWriteStart(Ascon *a) {
|
||||||
|
DynStringConcatChar(a->wrBuffer, '\r');
|
||||||
|
a->state = AsconWriting;
|
||||||
|
a->wrPos = 0;
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int VelSelReading(Ascon *a) {
|
||||||
|
int ret;
|
||||||
|
char chr;
|
||||||
|
pVelSelProt pVelSel = (pVelSelProt)a->private;
|
||||||
|
|
||||||
|
switch (pVelSel->subState) {
|
||||||
|
case sendUID:
|
||||||
|
ret = AsconReadChar(a->fd, &chr);
|
||||||
|
if (ret > 0) {
|
||||||
|
if (*pVelSel->expect == '\0') {
|
||||||
|
pVelSel->substate = sendPWD;
|
||||||
|
pVelSel->expect = PWDPROMPT;
|
||||||
|
} else if (chr == *pVelSel->expect) {
|
||||||
|
pVelSel->expect++;
|
||||||
|
} else if (pVelSel->retries-- > 0) {
|
||||||
|
a->state = AsconConnectStart;
|
||||||
|
pVelSel->retries = MAXRETRIES;
|
||||||
|
AsconError(a, "Did not get UID request", 0);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pVelSel->retries = MAXRETRIES;
|
||||||
|
break;
|
||||||
|
case sendPWD:
|
||||||
|
break;
|
||||||
|
case Established:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
}
|
||||||
|
switch(event) {
|
||||||
|
case UIDReq:
|
||||||
|
// wrBuffer = user:NVS
|
||||||
|
a->state = AsconWriteStart;
|
||||||
|
return 1;
|
||||||
|
break;
|
||||||
|
case PWDReq:
|
||||||
|
// wrBuffer = password:NVS
|
||||||
|
a->state = AsconWriteStart;
|
||||||
|
return 1;
|
||||||
|
break;
|
||||||
|
case
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
int VelSelProtHandler(Ascon *a) {
|
||||||
|
int ret;
|
||||||
|
pVelSelProt pVelSel = (pVelSelProt)a->private;
|
||||||
|
|
||||||
|
switch (a->state) {
|
||||||
|
case AsconConnecting:
|
||||||
|
ret = AsconConnectSuccess(a->fd);
|
||||||
|
if (ret == 0) {
|
||||||
|
/* in progress */
|
||||||
|
} else if (ret > 0) {
|
||||||
|
pVelSelProt->subState = sendUID;
|
||||||
|
a->state = AsconReading;
|
||||||
|
} else if (ret < 0) {
|
||||||
|
AsconError(a, "AsconConnectSuccess failed:", errno);
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case AsconWriteStart:
|
||||||
|
ret = VelSelWriteStart(a);
|
||||||
|
return ret;
|
||||||
|
break;
|
||||||
|
case AsconReading:
|
||||||
|
ret = VelSelReading(a);
|
||||||
|
return ret;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return AsconStdHandler(a);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
static void VelSelKill(void *data) {
|
||||||
|
pVelSelProt pVelSel = (pVelSelProt)data;
|
||||||
|
if (pVelSel == NULL)
|
||||||
|
return;
|
||||||
|
if (pVelSel->user != NULL)
|
||||||
|
free(pVelSel->user);
|
||||||
|
if (pVelSel->password != NULL)
|
||||||
|
free(pVelSel->password);
|
||||||
|
free(pVelSel);
|
||||||
|
}
|
||||||
|
|
||||||
|
static int VelSelProtInit(Ascon *a, SConnection *con, int argc, char *argv[]) {
|
||||||
|
pVelSelProt *pVelSel = NULL;
|
||||||
|
Tcl_Interp *tcl_interp;
|
||||||
|
|
||||||
|
pVelSel = (pVelSelProt) malloc(sizeof(VelSelProt));
|
||||||
|
if (VelSel == NULL) {
|
||||||
|
SCWrite(con, "ERROR: malloc for pVelSel failed in VelSelProtInit",eError);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
if (argc < 4) {
|
||||||
|
SCWrite(con, "ERROR: You must provide host, user, password parameters",eError);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
a->hostport = strdup(argv[1]);
|
||||||
|
pVelSel->user = strdup(argv[2]);
|
||||||
|
pVelSel->password = strdup(argv[3]);
|
||||||
|
if (argc == 5) {
|
||||||
|
tcl_interp = InterpGetTcl(pServ->pSics);
|
||||||
|
if (TCL_ERROR == Tcl_GetDobule(tcl_interp,argv[4],&a->timeout)) {
|
||||||
|
SCWrite(con, Tcl_GetStringResult(tcl_interp), eError);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
a->timeout = 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
pVelSel->subState = Unknown;
|
||||||
|
pVelSel->expect = UIDPROMPT;
|
||||||
|
pVelSel->retries = MAXRETRIES;
|
||||||
|
|
||||||
|
a->private = pVelSel;
|
||||||
|
a->killPrivate = VelSelKill;
|
||||||
|
a->state = AsconConnectStart;
|
||||||
|
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
void AddVelSelProtocol() {
|
||||||
|
AsconProtocol *prot = NULL;
|
||||||
|
|
||||||
|
prot = calloc(sizeof(AsconProtocol), 1);
|
||||||
|
prot->name = strdup("astvelsel");
|
||||||
|
prot->init = VelSelProtInit;
|
||||||
|
prot->handler = VelSelProtHandler;
|
||||||
|
AsconInsertProtocol(prot);
|
||||||
|
}
|
||||||
@@ -340,9 +340,9 @@ proc ::hdb::add_subtree {hpath subtree {object @none} {type @none} {makenode @no
|
|||||||
switch $makenode {
|
switch $makenode {
|
||||||
"@none" {
|
"@none" {
|
||||||
foreach {n v} $subtree {
|
foreach {n v} $subtree {
|
||||||
if {[lsearch -exact $::nexus_classes $n] != -1} {
|
if {[lsearch -exact $::nexus_classes $n] >= 0} {
|
||||||
add_subtree $hpath $v $object $n NXclass
|
add_subtree $hpath $v $object $n NXclass
|
||||||
} elseif {[lsearch -exact $SICStypes $n] != -1} {
|
} elseif {[lsearch -exact $SICStypes $n] >= 0} {
|
||||||
add_subtree $hpath $v $object $n sicsobject
|
add_subtree $hpath $v $object $n sicsobject
|
||||||
} elseif {$n=="link"} {
|
} elseif {$n=="link"} {
|
||||||
add_subtree $hpath $v $object $n link
|
add_subtree $hpath $v $object $n link
|
||||||
@@ -541,6 +541,10 @@ proc ::hdb::add_node {basePath args} {
|
|||||||
hsetprop $node_path/$child klass [getatt $node_name klass]
|
hsetprop $node_path/$child klass [getatt $node_name klass]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
scobj {
|
||||||
|
set node_path ${basePath}/$node_name
|
||||||
|
hfactory $node_path link $node_name
|
||||||
|
}
|
||||||
script - getset {
|
script - getset {
|
||||||
# A r/w pair of scripts, node = a node path
|
# A r/w pair of scripts, node = a node path
|
||||||
set node_path $basePath/[normalgetatt $node_name long_name]
|
set node_path $basePath/[normalgetatt $node_name long_name]
|
||||||
@@ -706,7 +710,7 @@ proc ::hdb::sobjadd {hpath sobj args} {
|
|||||||
set hpath [add_hpath $hpath $sobjatt(group)]
|
set hpath [add_hpath $hpath $sobjatt(group)]
|
||||||
if {[catch {hsetprop $hpath type part} err]} {clientput $err error}
|
if {[catch {hsetprop $hpath type part} err]} {clientput $err error}
|
||||||
}
|
}
|
||||||
if {[lsearch [hlist $hpath] $sobjatt(long_name)] != -1} {
|
if {[lsearch [hlist $hpath] $sobjatt(long_name)] >= 0} {
|
||||||
clientput "ERROR: $hpath/$sobjatt(long_name) for $sobj exists" error
|
clientput "ERROR: $hpath/$sobjatt(long_name) for $sobj exists" error
|
||||||
} elseif {$sobjatt(kind) == "hdb_subtree"} {
|
} elseif {$sobjatt(kind) == "hdb_subtree"} {
|
||||||
add_subtree $hpath [$sobj]
|
add_subtree $hpath [$sobj]
|
||||||
@@ -785,6 +789,11 @@ proc ::hdb::sobjadd {hpath sobj args} {
|
|||||||
# TODO
|
# TODO
|
||||||
todo_msg "$sobjatt(type) case, add $sobj to $hpath"
|
todo_msg "$sobjatt(type) case, add $sobj to $hpath"
|
||||||
}
|
}
|
||||||
|
# TODO Can this be replaced with a sct_* glob?
|
||||||
|
sct_posit_motor {
|
||||||
|
set sobjName [normalgetatt $sobj long_name]
|
||||||
|
add_node $hpath node $sobjName long_name $sobjName kind scobj
|
||||||
|
}
|
||||||
environment_controller {
|
environment_controller {
|
||||||
todo_msg "$sobjatt(type) case, add $sobj to $hpath"
|
todo_msg "$sobjatt(type) case, add $sobj to $hpath"
|
||||||
}
|
}
|
||||||
@@ -848,7 +857,7 @@ proc ::hdb::prune {instdict} {
|
|||||||
foreach name $candidates {
|
foreach name $candidates {
|
||||||
array unset dictval
|
array unset dictval
|
||||||
array set dictval $dictarr($name)
|
array set dictval $dictarr($name)
|
||||||
if {[lsearch $dictval(property) nxvgroup] != -1} {
|
if {[lsearch $dictval(property) nxvgroup] >= 0} {
|
||||||
# Link targets are not candidates for pruning
|
# Link targets are not candidates for pruning
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
@@ -862,7 +871,7 @@ proc ::hdb::prune {instdict} {
|
|||||||
if {[llength [array get dictarr $name/*]] == 0} {
|
if {[llength [array get dictarr $name/*]] == 0} {
|
||||||
array unset dictarr $name
|
array unset dictarr $name
|
||||||
} else {
|
} else {
|
||||||
if {[lsearch $candidates $name/*] != -1} {
|
if {[lsearch $candidates $name/*] >= 0} {
|
||||||
lappend new_candidates $name
|
lappend new_candidates $name
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,14 +12,14 @@ set boolean {true false}
|
|||||||
|
|
||||||
# SICS OBJECTS MUST PROVIDE THE FOLLOWING INFORMATION
|
# SICS OBJECTS MUST PROVIDE THE FOLLOWING INFORMATION
|
||||||
set sobj_klass_list {@none aperture attenuator collimator command crystal data detector disk_chopper entry environment experiment graphics instrument slits monitor monochromator parameter derived_parameter plc sample scan sensor source user}
|
set sobj_klass_list {@none aperture attenuator collimator command crystal data detector disk_chopper entry environment experiment graphics instrument slits monitor monochromator parameter derived_parameter plc sample scan sensor source user}
|
||||||
set sobj_sicstype_list {chopperadapter environment_controller sicsvariable macro motor configurablevirtualmotor singlecounter histmem nxscript sicsdata scanobject}
|
set sobj_sicstype_list {chopperadapter environment_controller sicsvariable macro motor configurablevirtualmotor singlecounter histmem nxscript sicsdata scanobject sct_posit_motor}
|
||||||
# Different kinds of things are added to the hdb in different ways.
|
# Different kinds of things are added to the hdb in different ways.
|
||||||
# command: This is something a client can run with hset /a/b/c start, it may have parameters and feedback.
|
# command: This is something a client can run with hset /a/b/c start, it may have parameters and feedback.
|
||||||
# Parameters and feedback should be made available in 'ilists' named after the command.
|
# Parameters and feedback should be made available in 'ilists' named after the command.
|
||||||
# script: Supplies an rscript and a wscript to attach to a node for hgets and hsets.
|
# script: Supplies an rscript and a wscript to attach to a node for hgets and hsets.
|
||||||
# hobj: Something that can be hattached to a node. {motor sicsvariable histmem}.
|
# hobj: Something that can be hattached to a node. {motor sicsvariable histmem}.
|
||||||
# hdb_subtree: Is a macro which returns a keyed list that describes a hdb subtree.
|
# hdb_subtree: Is a macro which returns a keyed list that describes a hdb subtree.
|
||||||
set sobj_kind_list {command hobj script getset hdb_subtree}
|
set sobj_kind_list {command hobj script getset hdb_subtree scobj}
|
||||||
set sobj_interfacelist [subst {drivable {$boolean} countable {$boolean} callback {$boolean} environment {$boolean} }]
|
set sobj_interfacelist [subst {drivable {$boolean} countable {$boolean} callback {$boolean} environment {$boolean} }]
|
||||||
|
|
||||||
set privilege_list {spy user manager readonly internal}
|
set privilege_list {spy user manager readonly internal}
|
||||||
@@ -43,6 +43,29 @@ set sobj_attlist [subst {
|
|||||||
}]
|
}]
|
||||||
|
|
||||||
# OBJECT SPECIFIC ATTRIBUTES
|
# OBJECT SPECIFIC ATTRIBUTES
|
||||||
|
set chopperadapter_attlist [subst {
|
||||||
|
$sobj_attlist
|
||||||
|
savecmd {print}
|
||||||
|
sdsinfo {print}
|
||||||
|
nxalias {text}
|
||||||
|
mutable [subst {{$boolean}}]
|
||||||
|
}]
|
||||||
|
|
||||||
|
set environment_controller_attlist [subst {
|
||||||
|
$sobj_attlist
|
||||||
|
mutable [subst {{$boolean}}]
|
||||||
|
}]
|
||||||
|
|
||||||
|
set histmem_attlist [subst {
|
||||||
|
$sobj_attlist
|
||||||
|
mutable [subst {{$boolean}}]
|
||||||
|
}]
|
||||||
|
|
||||||
|
# A macro can be attached to an hdb node as a command or a script
|
||||||
|
set macro_attlist [subst {
|
||||||
|
$sobj_attlist
|
||||||
|
}]
|
||||||
|
|
||||||
set motor_attlist [subst {
|
set motor_attlist [subst {
|
||||||
$sobj_attlist
|
$sobj_attlist
|
||||||
units alpha
|
units alpha
|
||||||
@@ -55,36 +78,15 @@ set configurablevirtualmotor_attlist [subst {
|
|||||||
$motor_attlist
|
$motor_attlist
|
||||||
}]
|
}]
|
||||||
|
|
||||||
set singlecounter_attlist [subst {
|
set nxscript_attlist [subst {
|
||||||
$sobj_attlist
|
$sobj_attlist
|
||||||
mutable [subst {{$boolean}}]
|
|
||||||
}]
|
|
||||||
|
|
||||||
set histmem_attlist [subst {
|
|
||||||
$sobj_attlist
|
|
||||||
mutable [subst {{$boolean}}]
|
|
||||||
}]
|
}]
|
||||||
|
|
||||||
set scanobject_attlist [subst {
|
set scanobject_attlist [subst {
|
||||||
$sobj_attlist
|
$sobj_attlist
|
||||||
}]
|
}]
|
||||||
|
|
||||||
set sicsvariable_attlist [subst {
|
set sct_posit_motor_attlist [subst {
|
||||||
$sobj_attlist
|
|
||||||
mutable [subst {{$boolean}}]
|
|
||||||
}]
|
|
||||||
|
|
||||||
set environment_controller_attlist [subst {
|
|
||||||
$sobj_attlist
|
|
||||||
mutable [subst {{$boolean}}]
|
|
||||||
}]
|
|
||||||
|
|
||||||
# A macro can be attached to an hdb node as a command or a script
|
|
||||||
set macro_attlist [subst {
|
|
||||||
$sobj_attlist
|
|
||||||
}]
|
|
||||||
|
|
||||||
set nxscript_attlist [subst {
|
|
||||||
$sobj_attlist
|
$sobj_attlist
|
||||||
}]
|
}]
|
||||||
|
|
||||||
@@ -93,11 +95,13 @@ set sicsdata_attlist [subst {
|
|||||||
mutable [subst {{$boolean}}]
|
mutable [subst {{$boolean}}]
|
||||||
}]
|
}]
|
||||||
|
|
||||||
set chopperadapter_attlist [subst {
|
set sicsvariable_attlist [subst {
|
||||||
|
$sobj_attlist
|
||||||
|
mutable [subst {{$boolean}}]
|
||||||
|
}]
|
||||||
|
|
||||||
|
set singlecounter_attlist [subst {
|
||||||
$sobj_attlist
|
$sobj_attlist
|
||||||
savecmd {print}
|
|
||||||
sdsinfo {print}
|
|
||||||
nxalias {text}
|
|
||||||
mutable [subst {{$boolean}}]
|
mutable [subst {{$boolean}}]
|
||||||
}]
|
}]
|
||||||
# INSTRUMENT DICTIONARIES MUST PROVIDE THE FOLLOWING INFORMATION
|
# INSTRUMENT DICTIONARIES MUST PROVIDE THE FOLLOWING INFORMATION
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# $Revision: 1.43 $
|
# $Revision: 1.44 $
|
||||||
# $Date: 2008-11-06 23:13:50 $
|
# $Date: 2008-12-12 06:53:49 $
|
||||||
# Author: Ferdi Franceschini
|
# Author: Ferdi Franceschini
|
||||||
# Based on the examples in the hs_test.tcl sample configuration by Mark Lesha.
|
# Based on the examples in the hs_test.tcl sample configuration by Mark Lesha.
|
||||||
# http://gumtree.ansto.gov.au:9080/nbicms/bragg-systems/histogram-server/hs_test.tcl/view
|
# http://gumtree.ansto.gov.au:9080/nbicms/bragg-systems/histogram-server/hs_test.tcl/view
|
||||||
@@ -52,6 +52,8 @@ namespace eval histogram_memory {
|
|||||||
hmm configure statuscheck false
|
hmm configure statuscheck false
|
||||||
hmm configure num_events_filled_to_histo 12345
|
hmm configure num_events_filled_to_histo 12345
|
||||||
hmm configure acq_dataset_active_sec 9.8
|
hmm configure acq_dataset_active_sec 9.8
|
||||||
|
hmm configure ratemap_xy_max_bin 123
|
||||||
|
hmm configure ratemap_xy_total 321
|
||||||
foreach bm $::counter::isc_beam_monitor_list {
|
foreach bm $::counter::isc_beam_monitor_list {
|
||||||
set bm_num [string index $bm end]
|
set bm_num [string index $bm end]
|
||||||
if [string is integer $bm_num] {
|
if [string is integer $bm_num] {
|
||||||
@@ -674,7 +676,7 @@ proc HISTMEM_TABLE {tpath args} {
|
|||||||
"-setel" {
|
"-setel" {
|
||||||
set element [lindex $arglist 0]
|
set element [lindex $arglist 0]
|
||||||
set value [lindex $arglist 1]
|
set value [lindex $arglist 1]
|
||||||
if {[lsearch [::utility::tabget hmm_xml $tpath/_ALLOWED_ELEMENTS_] $element] != -1} {
|
if {[lsearch [::utility::tabget hmm_xml $tpath/_ALLOWED_ELEMENTS_] $element] >= 0} {
|
||||||
::utility::tabset hmm_xml $tpath/$element/_CONTENT_ $value
|
::utility::tabset hmm_xml $tpath/$element/_CONTENT_ $value
|
||||||
} else {
|
} else {
|
||||||
error "ERROR: $element is not an allowed element in $tpath"
|
error "ERROR: $element is not an allowed element in $tpath"
|
||||||
@@ -683,7 +685,7 @@ proc HISTMEM_TABLE {tpath args} {
|
|||||||
"-setatt" {
|
"-setatt" {
|
||||||
set attname [lindex $arglist 0]
|
set attname [lindex $arglist 0]
|
||||||
set value [lindex $arglist 1]
|
set value [lindex $arglist 1]
|
||||||
if {[lsearch [::utility::tabget hmm_xml $tpath/_ALLOWED_ATTRIBUTES_] $attname] != -1} {
|
if {[lsearch [::utility::tabget hmm_xml $tpath/_ALLOWED_ATTRIBUTES_] $attname] >= 0} {
|
||||||
::utility::tabset hmm_xml $tpath/_ATTLIST_/$attname $value
|
::utility::tabset hmm_xml $tpath/_ATTLIST_/$attname $value
|
||||||
} else {
|
} else {
|
||||||
error "ERROR: $attname is not an allowed attribute in $tpath"
|
error "ERROR: $attname is not an allowed attribute in $tpath"
|
||||||
@@ -751,8 +753,8 @@ proc HISTMEM_TABLE {tpath args} {
|
|||||||
#
|
#
|
||||||
proc BAT_TABLE {args} {
|
proc BAT_TABLE {args} {
|
||||||
if [ catch {
|
if [ catch {
|
||||||
set attributes { FRAME_FREQUENCY SIZE_PERIOD COUNT_METHOD COUNT_SIZE READ_DATA_TYPE }
|
set attributes { NO_BAT_ENTRIES NO_BAT_PERIODS NO_REPEAT_ENTRY NO_REPEAT_TABLE NO_EXECUTE_TABLE }
|
||||||
set elements {{ }}
|
set elements {{ PERIOD_INDICES }}
|
||||||
|
|
||||||
set tag BAT
|
set tag BAT
|
||||||
foreach {opt arglist} [::utility::get_opt_arglist $args] {}
|
foreach {opt arglist} [::utility::get_opt_arglist $args] {}
|
||||||
@@ -806,11 +808,11 @@ proc BAT_TABLE {args} {
|
|||||||
"-del" {
|
"-del" {
|
||||||
foreach att [lindex $attributes 0] el [lindex $elements 0] {
|
foreach att [lindex $attributes 0] el [lindex $elements 0] {
|
||||||
set index [lsearch -exact $arglist $el]
|
set index [lsearch -exact $arglist $el]
|
||||||
if {$index != -1} {
|
if {$index >= 0} {
|
||||||
HISTMEM_TABLE $tag -delel $el
|
HISTMEM_TABLE $tag -delel $el
|
||||||
}
|
}
|
||||||
set index [lsearch -exact $arglist $att]
|
set index [lsearch -exact $arglist $att]
|
||||||
if {$index != -1} {
|
if {$index >= 0} {
|
||||||
HISTMEM_TABLE $tag -delatt $att
|
HISTMEM_TABLE $tag -delatt $att
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -894,11 +896,11 @@ proc CAT_TABLE {args} {
|
|||||||
"-del" {
|
"-del" {
|
||||||
foreach att [lindex $attributes 0] el [lindex $elements 0] {
|
foreach att [lindex $attributes 0] el [lindex $elements 0] {
|
||||||
set index [lsearch -exact $arglist $el]
|
set index [lsearch -exact $arglist $el]
|
||||||
if {$index != -1} {
|
if {$index >= 0} {
|
||||||
HISTMEM_TABLE $tag -delel $el
|
HISTMEM_TABLE $tag -delel $el
|
||||||
}
|
}
|
||||||
set index [lsearch -exact $arglist $att]
|
set index [lsearch -exact $arglist $att]
|
||||||
if {$index != -1} {
|
if {$index >= 0} {
|
||||||
HISTMEM_TABLE $tag -delatt $att
|
HISTMEM_TABLE $tag -delatt $att
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -927,7 +929,7 @@ proc CAT_TABLE {args} {
|
|||||||
#
|
#
|
||||||
proc FAT_TABLE {args} {
|
proc FAT_TABLE {args} {
|
||||||
if [ catch {
|
if [ catch {
|
||||||
set attributes { FRAME_FREQUENCY SIZE_PERIOD COUNT_METHOD COUNT_SIZE READ_DATA_TYPE VIEW_MAG_X VIEW_MAG_Y}
|
set attributes { FRAME_FREQUENCY SIZE_PERIOD NOS_PERIODS COUNT_METHOD COUNT_SIZE READ_DATA_TYPE VIEW_MAG_X VIEW_MAG_Y HISTO_STREAMING }
|
||||||
set elements {{ }}
|
set elements {{ }}
|
||||||
|
|
||||||
set tag FAT
|
set tag FAT
|
||||||
@@ -982,11 +984,11 @@ proc FAT_TABLE {args} {
|
|||||||
"-del" {
|
"-del" {
|
||||||
foreach att [lindex $attributes 0] el [lindex $elements 0] {
|
foreach att [lindex $attributes 0] el [lindex $elements 0] {
|
||||||
set index [lsearch -exact $arglist $el]
|
set index [lsearch -exact $arglist $el]
|
||||||
if {$index != -1} {
|
if {$index >= 0} {
|
||||||
HISTMEM_TABLE $tag -delel $el
|
HISTMEM_TABLE $tag -delel $el
|
||||||
}
|
}
|
||||||
set index [lsearch -exact $arglist $att]
|
set index [lsearch -exact $arglist $att]
|
||||||
if {$index != -1} {
|
if {$index >= 0} {
|
||||||
HISTMEM_TABLE $tag -delatt $att
|
HISTMEM_TABLE $tag -delatt $att
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1112,11 +1114,11 @@ proc OAT_TABLE {args} {
|
|||||||
"-del" {
|
"-del" {
|
||||||
foreach att [array names attlookup] el [lindex $elements 0] {
|
foreach att [array names attlookup] el [lindex $elements 0] {
|
||||||
set index [lsearch -exact $arglist $el]
|
set index [lsearch -exact $arglist $el]
|
||||||
if {$index != -1} {
|
if {$index >= 0} {
|
||||||
HISTMEM_TABLE $tag -delel $el
|
HISTMEM_TABLE $tag -delel $el
|
||||||
}
|
}
|
||||||
set index [lsearch -exact $arglist $att]
|
set index [lsearch -exact $arglist $att]
|
||||||
if {$index != -1} {
|
if {$index >= 0} {
|
||||||
HISTMEM_TABLE $tag -delatt $attlookup($att)
|
HISTMEM_TABLE $tag -delatt $attlookup($att)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1201,7 +1203,7 @@ proc SAT_TABLE {args} {
|
|||||||
"-del" {
|
"-del" {
|
||||||
foreach att $attributes {
|
foreach att $attributes {
|
||||||
set index [lsearch -exact $arglist $att]
|
set index [lsearch -exact $arglist $att]
|
||||||
if {$index != -1} {
|
if {$index >= 0} {
|
||||||
HISTMEM_TABLE $attpath -delatt $att
|
HISTMEM_TABLE $attpath -delatt $att
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1576,14 +1578,14 @@ sicslist setatt ::histogram_memory::time long_name time
|
|||||||
sicslist setatt ::histogram_memory::time mutable true
|
sicslist setatt ::histogram_memory::time mutable true
|
||||||
sicslist setatt ::histogram_memory::time units seconds
|
sicslist setatt ::histogram_memory::time units seconds
|
||||||
|
|
||||||
::utility::macro::getset int ::histogram_memory::ratemap_xy_max_bin {} {
|
::utility::macro::getset float ::histogram_memory::ratemap_xy_max_bin {} {
|
||||||
return "ratemap_xy_max_bin = [lindex [hmm configure ratemap_xy_max_bin] 2]"
|
return "ratemap_xy_max_bin = [lindex [hmm configure ratemap_xy_max_bin] 2]"
|
||||||
}
|
}
|
||||||
sicslist setatt ::histogram_memory::ratemap_xy_max_bin klass detector
|
sicslist setatt ::histogram_memory::ratemap_xy_max_bin klass detector
|
||||||
sicslist setatt ::histogram_memory::ratemap_xy_max_bin long_name max_binrate
|
sicslist setatt ::histogram_memory::ratemap_xy_max_bin long_name max_binrate
|
||||||
sicslist setatt ::histogram_memory::ratemap_xy_max_bin mutable true
|
sicslist setatt ::histogram_memory::ratemap_xy_max_bin mutable true
|
||||||
|
|
||||||
::utility::macro::getset int ::histogram_memory::ratemap_xy_total {} {
|
::utility::macro::getset float ::histogram_memory::ratemap_xy_total {} {
|
||||||
return "ratemap_xy_total = [lindex [hmm configure ratemap_xy_total] 2]"
|
return "ratemap_xy_total = [lindex [hmm configure ratemap_xy_total] 2]"
|
||||||
}
|
}
|
||||||
sicslist setatt ::histogram_memory::ratemap_xy_total klass detector
|
sicslist setatt ::histogram_memory::ratemap_xy_total klass detector
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
namespace eval ::sobj::positmotor {
|
namespace eval ::scobj::positmotor {
|
||||||
variable posit_table
|
variable posit_table
|
||||||
variable posit_indices
|
variable posit_indices
|
||||||
# TODO Add a script to edit the posit_table and attach it to indexed nodes with read and write actions.
|
# TODO Add a script to edit the posit_table and attach it to indexed nodes with read and write actions.
|
||||||
@@ -155,7 +155,7 @@ namespace eval ::sobj::positmotor {
|
|||||||
set posit_table($motor,$posindex) $val
|
set posit_table($motor,$posindex) $val
|
||||||
}
|
}
|
||||||
|
|
||||||
proc mk_sct_positmotor {sct_controller motor param table_ID posit_list} {
|
proc mk_sct_positmotor {sct_controller motor parnode param table_ID posit_list} {
|
||||||
variable posit_table
|
variable posit_table
|
||||||
variable posit_indices
|
variable posit_indices
|
||||||
|
|
||||||
@@ -171,14 +171,13 @@ namespace eval ::sobj::positmotor {
|
|||||||
|
|
||||||
|
|
||||||
if [ catch {
|
if [ catch {
|
||||||
set ns ::sobj::positmotor
|
set ns ::scobj::positmotor
|
||||||
set parnode ${motor}_motor
|
# set parnode ${motor}_motor
|
||||||
MakeSICSObj $parnode SCT_MOTOR
|
MakeSICSObj $parnode SCT_POSIT_MOTOR
|
||||||
# Make setable position parameter and poll it.
|
# Make setable position parameter and poll it.
|
||||||
VarMake $param float user
|
# hattach /sics/${parnode} $param $param
|
||||||
hattach /sics/${parnode} $param $param
|
|
||||||
set posindex_node /sics/${parnode}/${param}
|
set posindex_node /sics/${parnode}/${param}
|
||||||
# hfactory $posindex_node plain spy float
|
hfactory $posindex_node plain user float
|
||||||
hsetprop $posindex_node read ${ns}::rd_index $param $motor
|
hsetprop $posindex_node read ${ns}::rd_index $param $motor
|
||||||
hsetprop $posindex_node state_reading_index ${ns}::state_reading_index $posindex_node $param $motor
|
hsetprop $posindex_node state_reading_index ${ns}::state_reading_index $posindex_node $param $motor
|
||||||
hsetprop $posindex_node write ${ns}::w_index $sct_controller $posindex_node $param $motor
|
hsetprop $posindex_node write ${ns}::w_index $sct_controller $posindex_node $param $motor
|
||||||
@@ -213,6 +212,10 @@ namespace eval ::sobj::positmotor {
|
|||||||
$sct_controller poll $posindex_node
|
$sct_controller poll $posindex_node
|
||||||
$sct_controller write $posindex_node
|
$sct_controller write $posindex_node
|
||||||
|
|
||||||
|
sicslist setatt $parnode long_name $parnode
|
||||||
|
|
||||||
|
hinitprops $parnode
|
||||||
|
hinitprops $parnode $param
|
||||||
} message ] {
|
} message ] {
|
||||||
return -code error $message
|
return -code error $message
|
||||||
}
|
}
|
||||||
@@ -220,7 +223,7 @@ namespace eval ::sobj::positmotor {
|
|||||||
|
|
||||||
namespace export mk_sct_positmotor
|
namespace export mk_sct_positmotor
|
||||||
}
|
}
|
||||||
namespace import ::sobj::positmotor::*
|
namespace import ::scobj::positmotor::*
|
||||||
##
|
##
|
||||||
# Eg
|
# Eg
|
||||||
# hfactory /controllers plain spy none
|
# hfactory /controllers plain spy none
|
||||||
|
|||||||
@@ -298,8 +298,10 @@ proc ::nexus::newfile_collection {args} {
|
|||||||
set state(file,namestyle) $param(-savetype)
|
set state(file,namestyle) $param(-savetype)
|
||||||
file_set_list "UNKNOWN"
|
file_set_list "UNKNOWN"
|
||||||
if {$param(-savetype) == "scratch"} {
|
if {$param(-savetype) == "scratch"} {
|
||||||
|
set state(file,isNewScratchFile) true
|
||||||
set state(file,incr_datnum) false
|
set state(file,incr_datnum) false
|
||||||
} else {
|
} else {
|
||||||
|
set state(file,isNewScratchFile) false
|
||||||
set state(file,incr_datnum) true
|
set state(file,incr_datnum) true
|
||||||
}
|
}
|
||||||
set idNum [expr 1 + [SplitReply [sicsdatanumber]]]
|
set idNum [expr 1 + [SplitReply [sicsdatanumber]]]
|
||||||
@@ -445,12 +447,7 @@ proc ::nexus::save {{point 0}} {
|
|||||||
} else {
|
} else {
|
||||||
set isNewFile false
|
set isNewFile false
|
||||||
}
|
}
|
||||||
if [string match -nocase "*scratch*" $currFilename($data_label)] {
|
if {$isNewFile || $state(file,isNewScratchFile)} {
|
||||||
set isScratchFile true
|
|
||||||
} else {
|
|
||||||
set isScratchFile false
|
|
||||||
}
|
|
||||||
if {$isNewFile || $isScratchFile} {
|
|
||||||
::nexus::createfile $currFilename($data_label)
|
::nexus::createfile $currFilename($data_label)
|
||||||
dataFileName $currFilename($data_label)
|
dataFileName $currFilename($data_label)
|
||||||
estart [lindex [sicstime] 1]
|
estart [lindex [sicstime] 1]
|
||||||
@@ -464,6 +461,7 @@ proc ::nexus::save {{point 0}} {
|
|||||||
::nexus::makelinks
|
::nexus::makelinks
|
||||||
::nexus::set_plotdata_info
|
::nexus::set_plotdata_info
|
||||||
::nexus::nxclosefile $currFilename($data_label)
|
::nexus::nxclosefile $currFilename($data_label)
|
||||||
|
set state(file,isNewScratchFile) false
|
||||||
} else {
|
} else {
|
||||||
eend [lindex [sicstime] 1]
|
eend [lindex [sicstime] 1]
|
||||||
# timestamp [expr {[clock seconds] - $start_seconds_array($data_label)}]
|
# timestamp [expr {[clock seconds] - $start_seconds_array($data_label)}]
|
||||||
@@ -728,8 +726,12 @@ proc ::nexus::save {{point 0}} {
|
|||||||
} else {
|
} else {
|
||||||
$p_arr(savecmd) $p_arr(sicsdev) $p_arr(nxalias) $data_type
|
$p_arr(savecmd) $p_arr(sicsdev) $p_arr(nxalias) $data_type
|
||||||
}
|
}
|
||||||
} elseif {[info exists p_arr(savecmd)] || [info exists p_arr(nxalias)]} {
|
} elseif {[info exists p_arr(nxalias)]} {
|
||||||
error_msg "/$hpath/$child must have both 'savecmd' and 'nxalias' properties\nThe actual property list for /$hpath/$child is [array get p_arr]"
|
if {[info exists p_arr(mutable)] && $p_arr(mutable) == "true" } {
|
||||||
|
nxscript puthdb /$hpath/$child point $pt
|
||||||
|
} else {
|
||||||
|
nxscript puthdb /$hpath/$child
|
||||||
|
}
|
||||||
}
|
}
|
||||||
::nexus::savetree $hpath/$child $pt
|
::nexus::savetree $hpath/$child $pt
|
||||||
}
|
}
|
||||||
@@ -774,6 +776,9 @@ proc ::nexus::save {{point 0}} {
|
|||||||
}
|
}
|
||||||
array set p_arr [::utility::hlistplainprop /$hpath]
|
array set p_arr [::utility::hlistplainprop /$hpath]
|
||||||
set data_type [lindex [split [hinfo /$hpath] , ] 0]
|
set data_type [lindex [split [hinfo /$hpath] , ] 0]
|
||||||
|
if {$data_type == "none"} {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if {$p_arr(data) == "true" && $p_arr(nxsave) == "true" && [info exists p_arr(nxalias)]} {
|
if {$p_arr(data) == "true" && $p_arr(nxsave) == "true" && [info exists p_arr(nxalias)]} {
|
||||||
set alias $p_arr(nxalias)
|
set alias $p_arr(nxalias)
|
||||||
if {[info exists p_arr(sdsinfo)]} {
|
if {[info exists p_arr(sdsinfo)]} {
|
||||||
@@ -1007,7 +1012,7 @@ proc ::nexus::macro::getset_save {sobj nxalias data_type args} {
|
|||||||
}
|
}
|
||||||
} message ] {
|
} message ] {
|
||||||
if {$::errorCode=="NONE"} {return $message}
|
if {$::errorCode=="NONE"} {return $message}
|
||||||
return -code error $message
|
return -code error "::nexus::macro::getset_save, $message"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1061,7 +1066,8 @@ namespace eval ::nexus {
|
|||||||
}
|
}
|
||||||
|
|
||||||
proc ::nexus::sicsvariable::save {svar nxalias data_type args} {
|
proc ::nexus::sicsvariable::save {svar nxalias data_type args} {
|
||||||
array set attribute [attlist $svar]
|
if [ catch {
|
||||||
|
array set attribute [attlist $svar]
|
||||||
set val [SplitReply [$svar]]
|
set val [SplitReply [$svar]]
|
||||||
if {[lindex $args 0] == "point"} {
|
if {[lindex $args 0] == "point"} {
|
||||||
set index [lindex $args 1]
|
set index [lindex $args 1]
|
||||||
@@ -1080,8 +1086,12 @@ proc ::nexus::sicsvariable::save {svar nxalias data_type args} {
|
|||||||
default {error "ERROR: [info level -1]->::nexus::sicsvariable::save, unknown type $data_type"}
|
default {error "ERROR: [info level -1]->::nexus::sicsvariable::save, unknown type $data_type"}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if {[info exists attribute(units)]} {
|
if {[info exists attribute(units)]} {
|
||||||
nxscript putattribute $nxalias units $attribute(units)
|
nxscript putattribute $nxalias units $attribute(units)
|
||||||
|
}
|
||||||
|
} message ] {
|
||||||
|
if {$::errorCode=="NONE"} {return $message}
|
||||||
|
return -code error "::nexus::sicsvariable::save, $message"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1096,6 +1106,17 @@ proc ::nexus::sicsvariable::sdsinfo {svar data_type args} {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
namespace eval ::nexus::scobj {}
|
||||||
|
proc ::nexus::scobj::sdsinfo {svar data_type args} {
|
||||||
|
array set param $args
|
||||||
|
set dtype [::nexus::hdb2nx_type $data_type]
|
||||||
|
if {$param(mutable) == true} {
|
||||||
|
return " -type $dtype -rank 1 -dim {-1}"
|
||||||
|
} else {
|
||||||
|
return " -type $dtype"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
namespace eval ::nexus::chopperadapter { }
|
namespace eval ::nexus::chopperadapter { }
|
||||||
proc ::nexus::chopperadapter::save {sobj nxalias data_type args} {
|
proc ::nexus::chopperadapter::save {sobj nxalias data_type args} {
|
||||||
array set attribute [attlist $sobj]
|
array set attribute [attlist $sobj]
|
||||||
@@ -1216,7 +1237,7 @@ foreach expt $::nexus::exports {
|
|||||||
|
|
||||||
set tmpstr [string map {"$" ""} {$Name: not supported by cvs2svn $}]
|
set tmpstr [string map {"$" ""} {$Name: not supported by cvs2svn $}]
|
||||||
set nx_content_release_tag [lindex $tmpstr [expr [llength $tmpstr] - 1]]
|
set nx_content_release_tag [lindex $tmpstr [expr [llength $tmpstr] - 1]]
|
||||||
set tmpstr [string map {"$" ""} {$Revision: 1.45 $}]
|
set tmpstr [string map {"$" ""} {$Revision: 1.46 $}]
|
||||||
set nx_content_revision_num [lindex $tmpstr [expr [llength $tmpstr] - 1]]
|
set nx_content_revision_num [lindex $tmpstr [expr [llength $tmpstr] - 1]]
|
||||||
|
|
||||||
#namespace eval data {
|
#namespace eval data {
|
||||||
@@ -1239,3 +1260,4 @@ set nx_content_revision_num [lindex $tmpstr [expr [llength $tmpstr] - 1]]
|
|||||||
#}
|
#}
|
||||||
|
|
||||||
::nexus::init
|
::nexus::init
|
||||||
|
publish ::nexus::data user
|
||||||
|
|||||||
@@ -14,3 +14,4 @@ config/scan/scan_common_1.tcl
|
|||||||
config/nexus/nxscripts_common_1.tcl
|
config/nexus/nxscripts_common_1.tcl
|
||||||
config/commands/commands_common.tcl
|
config/commands/commands_common.tcl
|
||||||
config/motors/sct_positmotor_common.tcl
|
config/motors/sct_positmotor_common.tcl
|
||||||
|
config/motors/sct_jogmotor_common.tcl
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# $Revision: 1.32 $
|
# $Revision: 1.33 $
|
||||||
# $Date: 2008-10-20 00:08:30 $
|
# $Date: 2008-12-12 06:53:51 $
|
||||||
# Author: Ferdi Franceschini (ffr@ansto.gov.au)
|
# Author: Ferdi Franceschini (ffr@ansto.gov.au)
|
||||||
# Last revision by: $Author: ffr $
|
# Last revision by: $Author: ffr $
|
||||||
|
|
||||||
@@ -685,12 +685,17 @@ ss2d long_name bottom
|
|||||||
|
|
||||||
# Virtual and Simulated Motors
|
# Virtual and Simulated Motors
|
||||||
# ----------------------------
|
# ----------------------------
|
||||||
|
|
||||||
Motor msd ASIM [params\
|
Motor msd ASIM [params\
|
||||||
units mm\
|
asyncqueue mc4\
|
||||||
hardlowerlim 2500\
|
axis I\
|
||||||
hardupperlim 3500\
|
units mm\
|
||||||
]
|
stepsPerX $slitStepRate\
|
||||||
|
maxSpeed 1\
|
||||||
|
maxAccel 1\
|
||||||
|
maxDecel 1\
|
||||||
|
hardlowerlim 2500\
|
||||||
|
hardupperlim 3500\
|
||||||
|
]
|
||||||
msd part sample
|
msd part sample
|
||||||
msd long_name mono_sample_mm
|
msd long_name mono_sample_mm
|
||||||
|
|
||||||
|
|||||||
@@ -1,10 +1,9 @@
|
|||||||
# Ordela 21000N detector calibration
|
# Ordela 21000N detector calibration
|
||||||
|
|
||||||
proc ord_get_pot { potxy potnumber } {
|
proc ord_get_pot { potxy potnumber } {
|
||||||
# NOTE: Contains reordering of lower 2 bits. Remove when device driver is fixed!!! (?)
|
|
||||||
for { set rsp "Bad" } { $rsp == "Bad" } { } {
|
for { set rsp "Bad" } { $rsp == "Bad" } { } {
|
||||||
set potname [ format "%s%d" $potxy [ expr $potnumber ^ 3 ] ]
|
set potname [ format "%s%d" $potxy $potnumber ]
|
||||||
set rspall [ dhv1 cmd P $potname ]
|
set rspall [ sct_dhv1 transact "P $potname" ]
|
||||||
set rsp [lindex [split $rspall " "] 1]
|
set rsp [lindex [split $rspall " "] 1]
|
||||||
}
|
}
|
||||||
return $rsp
|
return $rsp
|
||||||
@@ -12,9 +11,8 @@ proc ord_get_pot { potxy potnumber } {
|
|||||||
Publish ord_get_pot User
|
Publish ord_get_pot User
|
||||||
|
|
||||||
proc ord_set_pot { potxy potnumber potvalue } {
|
proc ord_set_pot { potxy potnumber potvalue } {
|
||||||
# NOTE: Contains reordering of lower 2 bits. Remove when device driver is fixed!!! (?)
|
set potname [ format "%s%d" $potxy $potnumber ]
|
||||||
set potname [ format "%s%d" $potxy [ expr $potnumber ^ 3 ] ]
|
set rsp [ sct_dhv1 transact "p $potname $potvalue" ]
|
||||||
set rsp [ dhv1 cmd p $potname $potvalue ]
|
|
||||||
return $rsp
|
return $rsp
|
||||||
}
|
}
|
||||||
Publish ord_set_pot User
|
Publish ord_set_pot User
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ set 20sample_table {
|
|||||||
20 -464.3
|
20 -464.3
|
||||||
}
|
}
|
||||||
|
|
||||||
mk_sct_positmotor sct_mc1 samx samplenum 20SAMPLES $20sample_table
|
mk_sct_positmotor sct_mc1 samx changer_position samplenum 20SAMPLES $20sample_table
|
||||||
|
|
||||||
set auto_ap_table {
|
set auto_ap_table {
|
||||||
2.5 0
|
2.5 0
|
||||||
@@ -47,24 +47,5 @@ set auto_ap_table {
|
|||||||
25.0 215
|
25.0 215
|
||||||
30.0 250
|
30.0 250
|
||||||
}
|
}
|
||||||
mk_sct_positmotor sct_mc3 apx aperture auto_ap $auto_ap_table
|
mk_sct_positmotor sct_mc3 apx autoSampleAp aperture auto_ap $auto_ap_table
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# $Revision: 1.18 $
|
# $Revision: 1.19 $
|
||||||
# $Date: 2008-11-03 23:23:25 $
|
# $Date: 2008-12-12 06:53:52 $
|
||||||
# Author: Ferdi Franceschini (ffr@ansto.gov.au)
|
# Author: Ferdi Franceschini (ffr@ansto.gov.au)
|
||||||
# Last revision by: $Author: ffr $
|
# Last revision by: $Author: ffr $
|
||||||
|
|
||||||
@@ -55,38 +55,3 @@ server_init
|
|||||||
hsetprop /instrument/parameters/derived_parameters/$pname/feedback/status data false
|
hsetprop /instrument/parameters/derived_parameters/$pname/feedback/status data false
|
||||||
hsetprop /instrument/parameters/derived_parameters/$pname/feedback/status nxsave false
|
hsetprop /instrument/parameters/derived_parameters/$pname/feedback/status nxsave false
|
||||||
}
|
}
|
||||||
hsetprop /sct_mc1 control false
|
|
||||||
hsetprop /sct_mc1 data false
|
|
||||||
hsetprop /sct_mc2 control false
|
|
||||||
hsetprop /sct_mc2 data false
|
|
||||||
hsetprop /sct_mc3 control false
|
|
||||||
hsetprop /sct_mc3 data false
|
|
||||||
hsetprop /sct_mc4 control false
|
|
||||||
hsetprop /sct_mc4 data false
|
|
||||||
|
|
||||||
hfactory /instrument/parameters/changer_position link samx_motor
|
|
||||||
hsetprop /instrument/parameters/changer_position data true
|
|
||||||
set param samplenum
|
|
||||||
hsetprop /instrument/parameters/changer_position/${param} savecmd ::nexus::sicsvariable::save
|
|
||||||
hsetprop /instrument/parameters/changer_position/${param} sdsinfo ::nexus::sicsvariable::sdsinfo
|
|
||||||
hsetprop /instrument/parameters/changer_position/${param} control true
|
|
||||||
hsetprop /instrument/parameters/changer_position/${param} data true
|
|
||||||
hsetprop /instrument/parameters/changer_position/${param} nxsave true
|
|
||||||
hsetprop /instrument/parameters/changer_position/${param} mutable true
|
|
||||||
hsetprop /instrument/parameters/changer_position/${param} sicsdev $param
|
|
||||||
hsetprop /instrument/parameters/changer_position/${param} nxalias $param
|
|
||||||
hsetprop /instrument/parameters/changer_position/${param} klass parameter
|
|
||||||
|
|
||||||
hfactory /instrument/parameters/autoSampleAp link apx_motor
|
|
||||||
hsetprop /instrument/parameters/autoSampleAp data true
|
|
||||||
set param aperture
|
|
||||||
hsetprop /instrument/parameters/autoSampleAp/${param} savecmd ::nexus::sicsvariable::save
|
|
||||||
hsetprop /instrument/parameters/autoSampleAp/${param} sdsinfo ::nexus::sicsvariable::sdsinfo
|
|
||||||
hsetprop /instrument/parameters/autoSampleAp/${param} control true
|
|
||||||
hsetprop /instrument/parameters/autoSampleAp/${param} data true
|
|
||||||
hsetprop /instrument/parameters/autoSampleAp/${param} nxsave true
|
|
||||||
hsetprop /instrument/parameters/autoSampleAp/${param} mutable true
|
|
||||||
hsetprop /instrument/parameters/autoSampleAp/${param} sicsdev $param
|
|
||||||
hsetprop /instrument/parameters/autoSampleAp/${param} nxalias $param
|
|
||||||
hsetprop /instrument/parameters/autoSampleAp/${param} klass parameter
|
|
||||||
|
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
# SICS common configuration
|
# SICS common configuration
|
||||||
|
|
||||||
# $Revision: 1.45 $
|
# $Revision: 1.46 $
|
||||||
# $Date: 2008-10-27 04:55:40 $
|
# $Date: 2008-12-12 06:53:47 $
|
||||||
# Author: Ferdi Franceschini (ffr@ansto.gov.au)
|
# Author: Ferdi Franceschini (ffr@ansto.gov.au)
|
||||||
# Last revision by $Author: ffr $
|
# Last revision by $Author: ffr $
|
||||||
# RELEASE_NUMBER: $Name: not supported by cvs2svn $
|
# RELEASE_NUMBER: $Name: not supported by cvs2svn $
|
||||||
@@ -34,6 +34,8 @@ plc_simulation false
|
|||||||
VarMake sics_fullsimulation Text internal
|
VarMake sics_fullsimulation Text internal
|
||||||
|
|
||||||
source util/utility.tcl
|
source util/utility.tcl
|
||||||
|
source util/script_context_util.tcl
|
||||||
|
|
||||||
proc syncbackup {file} {
|
proc syncbackup {file} {
|
||||||
backup motorSave
|
backup motorSave
|
||||||
backup $file
|
backup $file
|
||||||
@@ -139,7 +141,7 @@ sics_release [lindex $tmpstr [expr [llength $tmpstr] - 1]]
|
|||||||
sics_release lock
|
sics_release lock
|
||||||
|
|
||||||
::utility::mkVar sics_revision_num Text internal
|
::utility::mkVar sics_revision_num Text internal
|
||||||
set tmpstr [string map {"$" ""} {$Revision: 1.45 $}]
|
set tmpstr [string map {"$" ""} {$Revision: 1.46 $}]
|
||||||
sics_revision_num [lindex $tmpstr [expr [llength $tmpstr] - 1]]
|
sics_revision_num [lindex $tmpstr [expr [llength $tmpstr] - 1]]
|
||||||
sics_revision_num lock
|
sics_revision_num lock
|
||||||
|
|
||||||
@@ -216,6 +218,8 @@ proc server_set_sobj_attributes {} {
|
|||||||
::nexus::set_sobj_attributes
|
::nexus::set_sobj_attributes
|
||||||
::histogram_memory::set_sobj_attributes
|
::histogram_memory::set_sobj_attributes
|
||||||
::utility::set_chopper_attributes
|
::utility::set_chopper_attributes
|
||||||
|
::utility::set_sctobj_attributes
|
||||||
|
::utility::set_sct_posit_motor_attributes
|
||||||
## TODO move the following to the new ansto gumxml.tcl
|
## TODO move the following to the new ansto gumxml.tcl
|
||||||
sicslist setatt getgumtreexml privilege internal
|
sicslist setatt getgumtreexml privilege internal
|
||||||
clientput "serverport [get_portnum $::serverport]"
|
clientput "serverport [get_portnum $::serverport]"
|
||||||
@@ -250,6 +254,7 @@ proc server_init {} {
|
|||||||
sicslist setatt sics_suid long_name sics_suid
|
sicslist setatt sics_suid long_name sics_suid
|
||||||
|
|
||||||
server_set_sobj_attributes
|
server_set_sobj_attributes
|
||||||
|
|
||||||
} message ] {
|
} message ] {
|
||||||
clientput $errorContext
|
clientput $errorContext
|
||||||
clientput $callStack
|
clientput $callStack
|
||||||
|
|||||||
@@ -103,7 +103,7 @@ proc setdiff {A B} {
|
|||||||
proc _intersection {lista listb} {
|
proc _intersection {lista listb} {
|
||||||
set result {}
|
set result {}
|
||||||
foreach elem [join $listb] {
|
foreach elem [join $listb] {
|
||||||
if { [lsearch -exact $lista $elem] != -1 } {
|
if { [lsearch -exact $lista $elem] >= 0} {
|
||||||
lappend result $elem
|
lappend result $elem
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
20
site_ansto/instrument/util/script_context_util.tcl
Normal file
20
site_ansto/instrument/util/script_context_util.tcl
Normal file
@@ -0,0 +1,20 @@
|
|||||||
|
namespace eval ::scobj { }
|
||||||
|
##
|
||||||
|
# @brief Initialise the hdb properties required for generating the GumTree interface and
|
||||||
|
# saving data for script context objects
|
||||||
|
proc ::scobj::hinitprops {sobj args} {
|
||||||
|
if {$args == ""} {
|
||||||
|
set hpath /sics/$sobj
|
||||||
|
hsetprop $hpath nxalias $sobj
|
||||||
|
} else {
|
||||||
|
set hpath /sics/$sobj/$args
|
||||||
|
hsetprop $hpath nxalias ${sobj}_$args
|
||||||
|
}
|
||||||
|
hsetprop $hpath control true
|
||||||
|
hsetprop $hpath data true
|
||||||
|
hsetprop $hpath nxsave true
|
||||||
|
hsetprop $hpath mutable true
|
||||||
|
hsetprop $hpath klass parameter
|
||||||
|
hsetprop $hpath sicsdev $sobj
|
||||||
|
hsetprop $hpath sdsinfo ::nexus::scobj::sdsinfo
|
||||||
|
}
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
# Some useful functions for SICS configuration.
|
# Some useful functions for SICS configuration.
|
||||||
|
|
||||||
# $Revision: 1.19 $
|
# $Revision: 1.20 $
|
||||||
# $Date: 2008-10-13 04:40:06 $
|
# $Date: 2008-12-12 06:53:53 $
|
||||||
# Author: Ferdi Franceschini (ffr@ansto.gov.au)
|
# Author: Ferdi Franceschini (ffr@ansto.gov.au)
|
||||||
# Last revision by $Author: ffr $
|
# Last revision by $Author: ffr $
|
||||||
|
|
||||||
@@ -366,10 +366,16 @@ proc SplitReply { text } {
|
|||||||
}
|
}
|
||||||
|
|
||||||
# Sets motor position reading to pos by adjusting the softzero
|
# Sets motor position reading to pos by adjusting the softzero
|
||||||
proc setpos {motor pos} {
|
proc setpos {motor pos args} {
|
||||||
set currPos [SplitReply [$motor]]
|
if {$args == ""} {
|
||||||
|
set currPos [SplitReply [$motor]]
|
||||||
|
set newPos $pos
|
||||||
|
} else {
|
||||||
|
set currPos $pos
|
||||||
|
set newPos [lindex $args 0]
|
||||||
|
}
|
||||||
set oldZero [SplitReply [$motor softzero]]
|
set oldZero [SplitReply [$motor softzero]]
|
||||||
set newZero [expr $currPos - $pos + $oldZero]
|
set newZero [expr $currPos - $newPos + $oldZero]
|
||||||
uplevel #0 "$motor softzero $newZero"
|
uplevel #0 "$motor softzero $newZero"
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -429,6 +435,22 @@ proc ::utility::set_histomem_attributes {} {
|
|||||||
sicslist setatt $hm mutable true
|
sicslist setatt $hm mutable true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
proc ::utility::set_sctobj_attributes {} {
|
||||||
|
foreach sobj [sicslist type SctController] {
|
||||||
|
hsetprop /$sobj control false
|
||||||
|
hsetprop /$sobj data false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
proc ::utility::set_sct_posit_motor_attributes {} {
|
||||||
|
foreach sobj [sicslist type SCT_POSIT_MOTOR] {
|
||||||
|
sicslist setatt $sobj klass parameter
|
||||||
|
sicslist setatt $sobj data true
|
||||||
|
sicslist setatt $sobj control true
|
||||||
|
sicslist setatt $sobj nxsave true
|
||||||
|
sicslist setatt $sobj mutable true
|
||||||
|
sicslist setatt $sobj privilege user
|
||||||
|
}
|
||||||
|
}
|
||||||
proc ::utility::set_motor_attributes {} {
|
proc ::utility::set_motor_attributes {} {
|
||||||
# Bug: SICS-57 on Jira
|
# Bug: SICS-57 on Jira
|
||||||
# The first entry in [sicslist type motor] is 'motor' when
|
# The first entry in [sicslist type motor] is 'motor' when
|
||||||
@@ -822,7 +844,7 @@ proc ::utility::macro::getset {type name arglist body} {
|
|||||||
$body
|
$body
|
||||||
}]
|
}]
|
||||||
|
|
||||||
publish $name user
|
publish $name spy
|
||||||
if {$arglist == ""} {
|
if {$arglist == ""} {
|
||||||
sicslist setatt $name access read_only
|
sicslist setatt $name access read_only
|
||||||
} else {
|
} else {
|
||||||
@@ -840,6 +862,14 @@ proc ::utility::macro::getset {type name arglist body} {
|
|||||||
sicslist setatt $name savecmd ::nexus::macro::getset_save
|
sicslist setatt $name savecmd ::nexus::macro::getset_save
|
||||||
sicslist setatt $name sdsinfo ::nexus::macro::getset_sdsinfo
|
sicslist setatt $name sdsinfo ::nexus::macro::getset_sdsinfo
|
||||||
}
|
}
|
||||||
|
proc hparPath {} {
|
||||||
|
set hpath [sct]
|
||||||
|
return [file dirname $hpath]
|
||||||
|
}
|
||||||
|
proc hsibPath {sibling} {
|
||||||
|
set hpath [sct]
|
||||||
|
return [file dirname $hpath]/$sibling
|
||||||
|
}
|
||||||
namespace import ::utility::*;
|
namespace import ::utility::*;
|
||||||
Publish getinfo spy
|
Publish getinfo spy
|
||||||
Publish setpos user
|
Publish setpos user
|
||||||
|
|||||||
@@ -1217,12 +1217,18 @@ static int cmdPoll(pDMC2280Driv self) {
|
|||||||
|
|
||||||
static void cmdHalt(pDMC2280Driv self) {
|
static void cmdHalt(pDMC2280Driv self) {
|
||||||
char cmd[CMDLEN];
|
char cmd[CMDLEN];
|
||||||
snprintf(cmd, CMDLEN, "ST%c", self->axisLabel);
|
if (self->protocol == 3) {
|
||||||
(void) DMC_Send(self, cmd);
|
|
||||||
if (self->variables & VAR_HLT) {
|
|
||||||
snprintf(cmd, CMDLEN, "HLT%c=1", self->axisLabel);
|
snprintf(cmd, CMDLEN, "HLT%c=1", self->axisLabel);
|
||||||
/* Note that this does not expect a reply or confirmation */
|
/* Note that this does not expect a reply or confirmation */
|
||||||
(void) DMC_Send(self, cmd);
|
(void) DMC_Send(self, cmd);
|
||||||
|
} else {
|
||||||
|
snprintf(cmd, CMDLEN, "ST%c", self->axisLabel);
|
||||||
|
(void) DMC_Send(self, cmd);
|
||||||
|
if (self->variables & VAR_HLT) {
|
||||||
|
snprintf(cmd, CMDLEN, "HLT%c=1", self->axisLabel);
|
||||||
|
/* Note that this does not expect a reply or confirmation */
|
||||||
|
(void) DMC_Send(self, cmd);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -3355,18 +3361,16 @@ static int DMC2280SetPar(void *pData, SConnection *pCon,
|
|||||||
/* Set home, managers only. Users should set softposition */
|
/* Set home, managers only. Users should set softposition */
|
||||||
if(strcasecmp(name, HOME) == 0) {
|
if(strcasecmp(name, HOME) == 0) {
|
||||||
/* Debug Managers only */
|
/* Debug Managers only */
|
||||||
if(!SCMatchRights(pCon,usMugger))
|
if(!SCMatchRights(pCon,usInternal))
|
||||||
return 1;
|
return 1;
|
||||||
else {
|
else {
|
||||||
if ( (self->fLower - newValue) > FLT_EPSILON) {
|
if ( (self->fLower - newValue) > FLT_EPSILON) {
|
||||||
snprintf(pError, ERRLEN,"ERROR:'%s %s' must be greater than or equal to %f", self->name, HOME, self->fLower);
|
snprintf(pError, ERRLEN,"WARNING:'%s %s' is lower than the lower limit %f", self->name, HOME, self->fLower);
|
||||||
SCWrite(pCon, pError, eError);
|
SCWrite(pCon, pError, eWarning);
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
if ( (newValue - self->fUpper) > FLT_EPSILON) {
|
if ( (newValue - self->fUpper) > FLT_EPSILON) {
|
||||||
snprintf(pError, ERRLEN,"ERROR:'%s %s' must be less than or equal to %f", self->name, HOME, self->fUpper);
|
snprintf(pError, ERRLEN,"WARNING:'%s %s' is greater than the upper limit %f", self->name, HOME, self->fUpper);
|
||||||
SCWrite(pCon, pError, eError);
|
SCWrite(pCon, pError, eWarning);
|
||||||
return 1;
|
|
||||||
}
|
}
|
||||||
self->fHome = newValue;
|
self->fHome = newValue;
|
||||||
return 1;
|
return 1;
|
||||||
|
|||||||
@@ -53,6 +53,8 @@
|
|||||||
*/
|
*/
|
||||||
extern int VelSelTcpFactory(SConnection *pCon, SicsInterp *pSics, void *pData, int argc, char *argv[]);
|
extern int VelSelTcpFactory(SConnection *pCon, SicsInterp *pSics, void *pData, int argc, char *argv[]);
|
||||||
extern pCodri MakeTcpDoChoDriver(char *tclArray, SConnection *pCon);
|
extern pCodri MakeTcpDoChoDriver(char *tclArray, SConnection *pCon);
|
||||||
|
extern void AddGalilProtocoll();
|
||||||
|
extern void AddOrdHVPSProtocoll();
|
||||||
|
|
||||||
|
|
||||||
void SiteInit(void) {
|
void SiteInit(void) {
|
||||||
@@ -60,7 +62,8 @@ void SiteInit(void) {
|
|||||||
NetWatchInit();
|
NetWatchInit();
|
||||||
#define INIT(F) { void F(void); F(); }
|
#define INIT(F) { void F(void); F(); }
|
||||||
/* insert here initialization routines ... */
|
/* insert here initialization routines ... */
|
||||||
|
AddGalilProtocoll();
|
||||||
|
AddOrdHVPSProtocoll();
|
||||||
}
|
}
|
||||||
|
|
||||||
static pSite /*@null@*/ siteANSTO = NULL;
|
static pSite /*@null@*/ siteANSTO = NULL;
|
||||||
|
|||||||
Reference in New Issue
Block a user