SICS-188 hdb_path is now a comma separated list of paths. NOTE: nodes listed as derived parameter dependencies aren't added to the path.

sans/config/hmm/detector.tcl
Use dns-name for voltage controller address.

sans/config/motors/motor_configuration.tcl
Set det home position.
SICS-122 Added FastShutter variable and configured det motor with an action object to set the FastShutter variable.
SICS-248 Replaced beamstop motor objects with beamstop action objects.

action.[ch]
The action object factory will eventuall be defined here.
SICS-122 Currently there is just a funcion which sets the FastShutter variable

beamstopaction.c
Added motion control enabled check.
Added "list" subcommand.

Makefile
Compile action.c

motor_dmc2280.c
The status check command now always checks the TI1 and TI0 interrupts.
Added action-object configuration parameter.  Call AO_istatus with TI1
if configured with an action object.

r2674 | ffr | 2008-08-13 14:16:30 +1000 (Wed, 13 Aug 2008) | 26 lines
This commit is contained in:
Ferdi Franceschini
2008-08-13 14:16:30 +10:00
committed by Douglas Clowes
parent 7c7ed6cbf9
commit 8a07f5eaf6
7 changed files with 124 additions and 24 deletions

View File

@@ -91,7 +91,7 @@ OBJ= site_ansto.o anstoutil.o\
anstohttp.o \
hmcontrol_ansto.o\
lssmonitor.o \
beamstopaction.o
beamstopaction.o action.o
all: ../matrix/libmatrix.a $(COREOBJ:%=../%) $(EXTRA:%=../%) libansto.a libhardsup
$(CC) -g -o SICServer $(COREOBJ:%=../%) $(EXTRA:%=../%) $(SUBLIBS) $(PSI_SLIBS:%=../%) $(PSI_LIBS) $(GHTTP_LIBS)

54
site_ansto/action.c Normal file
View File

@@ -0,0 +1,54 @@
/*-------------------------------------------------------------------------
* @file ACTION OBJECT
* Currently just provides methods to set SICSVariables on status update.
* Copyright: see file Copyright.txt
*/
#include "action.h"
#include "sics.h"
#include "asyncqueue.h"
#include "nwatch.h"
#include "fsm.h"
#include "anstoutil.h"
#include "sicsvar.h"
#include <stdlib.h>
#include <stdbool.h>
#include <assert.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
static char *SV_FastShutter = "FastShutter";
static void setTextSICSVar(char *VarName, char *value) {
int privilege = 1;
pSicsVariable svText=NULL;
svText = (pSicsVariable)FindCommandData(pServ->pSics,SV_FastShutter,"SicsVariable");
if (svText != NULL)
VarSetText(svText,value,privilege);
}
/**
* @brief Update a SICS variable with the current status
*
* @param input, status from device
* @param identifier, status query identifier
*/
void AO_istatus(int input, char *identifier) {
int testVal;
if (strcasecmp(identifier, "TI1") == 0) {
testVal = 48 & input;
if (testVal == 32) { // Fast shutter open
setTextSICSVar(SV_FastShutter, "OPEN");
} else if (testVal == 16) { // Fast shutter closed
setTextSICSVar(SV_FastShutter, "CLOSED");
} else if (testVal == 48) {
setTextSICSVar(SV_FastShutter, "INBETWEEN");
} else { // 0 ie both limits activated
setTextSICSVar(SV_FastShutter, "FAULT");
}
} else if (strcasecmp(identifier, "TS") == 0) {
}
}

4
site_ansto/action.h Normal file
View File

@@ -0,0 +1,4 @@
#ifndef ACTION_H
#define ACTION_H
void AO_istatus(int input, char *identifier);
#endif

View File

@@ -16,6 +16,8 @@
#define SEQLEN 16
#define ACTIONS 32
extern int DMC2280MotionControl;
typedef enum {
ActID,
Args,
@@ -23,7 +25,7 @@ typedef enum {
DEBUG
} submcd;
char *subcmdName[] = {"act", "args", "status", "debug"};
char *subcmdName[] = {"act", "args", "status", "debug", NULL};
char *validActions[LASTACTION+1] = {"up", "down"};
/* Each action takes two arguments, an axis label and the jogspeed */
char *dfltActionSequence[ACTIONS][SEQLEN] = { {"SH%c","JG%c=%d", "BG%c", NULL}, {"SH%c","JG%c=(-1.0)*(%d)", "BG%c", NULL} };
@@ -94,7 +96,7 @@ static void *AO_GetInterface(void *pData, int iID) {
int AO_Wrapper(SConnection *pCon, SicsInterp *pSics, void *pData, int argc, char *argv[]) {
char msg[128]="No message", output[256];
int actID, status;
int actID, status, i;
OutCode msgType;
pAction self = (pAction) pData;
@@ -102,7 +104,13 @@ int AO_Wrapper(SConnection *pCon, SicsInterp *pSics, void *pData, int argc, char
sprintf(msg, "%d", self->status);
msgType = eValue;
} else if (argc == 2) { /* GET */
if (strcasecmp(argv[1], subcmdName[ActID]) == 0) {
if (strcasecmp(argv[1], "list") == 0) {
for (i=0; subcmdName[i]; i++) {
sprintf(msg, "%s", subcmdName[i]);
SCWrite(pCon,msg,eValue);
}
return OKOK;
} else if (strcasecmp(argv[1], subcmdName[ActID]) == 0) {
sprintf(msg, "%s", validActions[self->actionID]);
msgType = eValue;
} else if (strcasecmp(argv[1], subcmdName[Args]) == 0) {
@@ -116,6 +124,7 @@ int AO_Wrapper(SConnection *pCon, SicsInterp *pSics, void *pData, int argc, char
msgType = eValue;
} else if (strcasecmp(argv[1], subcmdName[DEBUG]) == 0) {
sprintf(msg, "%d", self->debug);
msgType = eValue;
}
} else if (argc == 3) { /* SET */
if (strcasecmp(argv[1], subcmdName[ActID]) == 0) {
@@ -176,6 +185,16 @@ if fVal == start then
char cmd[AO_CMDLEN], reply[AO_CMDLEN];
int i, cmd_len, comStatus;
if (DMC2280MotionControl != 1) {
AO_Halt(pData);
if (DMC2280MotionControl == 0) {
SCWrite(pCon, "ERROR: Motion control is off", eError);
return 0;
} else {
SCWrite(pCon, "ERROR: Motion control state is unknown", eError);
return 0;
}
}
pAction self = (pAction) pData;
if (self->actionID < NOACTION || self->actionID > LASTACTION) {
sprintf(msg, "ERROR: Programmer error, invalid action ID %d for %s. Alert a SICS programmer", self->actionID, self->objname);

View File

@@ -5,7 +5,7 @@ set sim_mode [SplitReply [detector_simulation]]
if {$::sim_mode == "true"} {
EvFactory new dhv1 sim
} else {
makeasyncqueue acq ORHVPS 137.157.202.85 4001
makeasyncqueue acq ORHVPS ca1-quokka 4001
evfactory new dhv1 orhvps acq
dhv1 lowerlimit 0
dhv1 upperlimit 2400

View File

@@ -1,9 +1,10 @@
# $Revision: 1.22 $
# $Date: 2008-08-07 06:18:17 $
# $Revision: 1.23 $
# $Date: 2008-08-13 04:16:30 $
# Author: Ferdi Franceschini (ffr@ansto.gov.au)
# Last revision by: $Author: ffr $
# START MOTOR CONFIGURATION
::utility::mkVar FastShutter text manager FastShutter false instrument true false
set animal quokka
set sim_mode [SplitReply [motor_simulation]]
@@ -56,7 +57,7 @@ set samx_Home 7414223
set samy_Home 7101486
set samz_Home 9944901
set samthet_Home 22997883
set det_Home 7047593
set det_Home 7055209
set detoff_Home 6932100
set pent_Home 8123563
@@ -370,6 +371,7 @@ Motor det $motor_driver_type [params \
asyncqueue mc1\
host mc1-quokka\
port pmc1-quokka\
aoid MC1\
axis G\
units mm\
hardlowerlim 350\
@@ -385,7 +387,7 @@ det part detector
det long_name detector_y
det softlowerlim 400
det softupperlim 18900
det home 0
det home 350.5
det speed 20
# Detector translation across beam [-50,450] mm
@@ -804,7 +806,7 @@ Motor att $motor_driver_type [params \
cntsPerX [expr -($att_factor*8192.0)]]
att part collimator
att long_name att
setHomeandRange -motor att -home 0 -lowrange -30 -uprange 7230
setHomeandRange -motor att -home 0 -lowrange 0 -uprange 7230
att speed 5
############################
@@ -858,7 +860,17 @@ bsz softlowerlim -240
bsz softupperlim 100
bsz home 0
# beam stop disk 5 (largest)
if {1} {
# largest to smallest
# MakeActionObject obj aQ JG-speed upsw downsw axis
MakeActionObject bs1 mc4 [expr $bs124sign*$bs_steps_per_rev*$bs1gear/360.0] 8 4 C
MakeActionObject bs2 mc4 [expr $bs124sign*$bs_steps_per_rev*$bs2gear/360.0] 8 4 D
MakeActionObject bs3 mc4 [expr $bs35sign*$bs_steps_per_rev*$bs3gear/360.0] 4 8 E
MakeActionObject bs4 mc4 [expr $bs124sign*$bs_steps_per_rev*$bs4gear/360.0] 8 4 F
MakeActionObject bs5 mc4 [expr $bs35sign*$bs_steps_per_rev*$bs5gear/360.0] 4 8 G
} else {
# beam stop disk 5 (smallest)
Motor bs5 $motor_driver_type [params \
asyncqueue mc4\
host mc4-quokka\
@@ -938,7 +950,7 @@ bs2 softlowerlim 0
bs2 softupperlim 90
bs2 home 0
# beam stop disk 1 (smallest)
# beam stop disk 1 (largest)
Motor bs1 $motor_driver_type [params \
asyncqueue mc4\
host mc4-quokka\
@@ -957,6 +969,7 @@ bs1 long_name bs1
bs1 softlowerlim 0
bs1 softupperlim 90
bs1 home 0
}
# Polarizer Rotation
Motor pol $motor_driver_type [params \

View File

@@ -30,6 +30,7 @@
#include <dynstring.h>
#include <time.h>
#include "anstoutil.h"
#include "action.h"
#define UNITSLEN 256
#define TEXTPARLEN 1024
@@ -207,6 +208,7 @@ struct __MoDriv {
#endif
int bias_bits; /**< number of bits to mask */
int bias_bias; /**< bias to add to encoder value */
char ao_id[256];
};
int DMC2280MotionControl = 1; /* defaults to enabled */
@@ -1151,23 +1153,17 @@ static bool has_var_x(pDMC2280Driv self, const char* vars, const char* name) {
static int cmdStatus(pDMC2280Driv self) {
char cmd[CMDLEN];
char encoder = self->axisLabel;
int io_byte = 0;
if (self->encoderAxis && !(self->variables & VAR_ENC))
encoder = self->encoderAxis;
if (self->axisLabel >= 'A' && self->axisLabel <= 'D')
io_byte = 0;
else
io_byte = 1;
/* Use POSx, ENCx, RUNx, SWIx if it has these variables */
snprintf(cmd, CMDLEN, "MG {F10.0} %s%c,%s%c,%s%c,%s%c,%s%c,_TI%d,_XQ0",
snprintf(cmd, CMDLEN, "MG {F10.0} %s%c,%s%c,%s%c,%s%c,%s%c,_TI0,_TI1,_XQ0",
(self->variables & VAR_POS) ? "POS" : "_TD", self->axisLabel,
(self->variables & VAR_ENC) ? "ENC" : "_TP", encoder,
(self->variables & VAR_SWI) ? "SWI" : "_TS", self->axisLabel,
(self->variables & VAR_RUN) ? "RUN" : "_BG", self->axisLabel,
(self->variables & VAR_STP) ? "STP" : "_SC", self->axisLabel,
io_byte);
(self->variables & VAR_STP) ? "STP" : "_SC", self->axisLabel);
return DMC_SendReq(self, cmd);
}
@@ -1247,12 +1243,21 @@ static int cmdOff(pDMC2280Driv self) {
static int rspStatus(pDMC2280Driv self, const char* text) {
int iRet, iFlags;
int iSteps, iCounts;
int iIOByte, iStopCode, iXQ0, iBG;
iRet = sscanf(text, "%d %d %d %d %d %d %d",
int iTIzero, iTIone, iIOByte, iStopCode, iXQ0, iBG;
iRet = sscanf(text, "%d %d %d %d %d %d %d %d",
&iSteps, &iCounts, &iFlags, &iBG,
&iStopCode, &iIOByte, &iXQ0);
if (iRet != 7)
&iStopCode, &iTIzero, &iTIone, &iXQ0);
if (iRet != 8)
return 0;
/* TODO some kind of callback for builtin status would be better */
if (self->ao_id[0] != '\0') {
AO_istatus(iTIone, "TI1");
}
if (self->axisLabel >= 'A' && self->axisLabel <= 'D')
iIOByte = iTIzero;
else
iIOByte = iTIone;
if ((trace_switches || self->debug) && self->currFlags != iFlags) {
char line[CMDLEN];
char *sw;
@@ -3654,6 +3659,11 @@ MotorDriver *CreateDMC2280(SConnection *pCon, char *motor, char *params) {
sscanf(pPtr,"%d",&(pNew->debug));
}
pNew->ao_id[0] = '\0';
if ((pPtr=getParam(pCon, interp, params, "aoid", _OPTIONAL)) != NULL) {
strncpy(pNew->ao_id, pPtr, sizeof(pNew->ao_id));
pNew->ao_id[sizeof(pNew->ao_id) - 1] = '\0';
}
if ((pPtr=getParam(pCon, interp, params, LONG_NAME, _OPTIONAL)) != NULL) {
strncpy(pNew->long_name, pPtr, sizeof(pNew->long_name));
pNew->long_name[sizeof(pNew->long_name) - 1] = '\0';