Add instrument readiness and use defined bits
r1607 | dcl | 2007-03-06 09:40:27 +1100 (Tue, 06 Mar 2007) | 2 lines
This commit is contained in:
@@ -186,16 +186,15 @@ static void PLC_Notify(void* context, int event)
|
|||||||
static int GetCallback(void* ctx, const char* resp, int resp_len)
|
static int GetCallback(void* ctx, const char* resp, int resp_len)
|
||||||
{
|
{
|
||||||
int iRet;
|
int iRet;
|
||||||
int iRead;
|
unsigned int iRead;
|
||||||
pSafetyPLCController self = (pSafetyPLCController) ctx;
|
pSafetyPLCController self = (pSafetyPLCController) ctx;
|
||||||
iRet = sscanf(resp,"READ %x", &iRead);
|
iRet = sscanf(resp,"READ %ux", &iRead);
|
||||||
if(iRet != 1) { // Not a number, probably an error response
|
if(iRet != 1) { // Not a number, probably an error response
|
||||||
self->iValue = 0;
|
self->iValue = 0;
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
if (iRead < 0)
|
if ((iRead & LAMP_TEST_BIT) == 0)
|
||||||
iRead = -iRead;
|
self->iValue = iRead;
|
||||||
self->iValue = iRead;
|
|
||||||
}
|
}
|
||||||
if ((self->iValue & MOTOR_BOTH_BITS) == 0) /* neither */
|
if ((self->iValue & MOTOR_BOTH_BITS) == 0) /* neither */
|
||||||
DMC2280MotionControl = -1;
|
DMC2280MotionControl = -1;
|
||||||
@@ -241,9 +240,11 @@ static int PLC_Action(SConnection *pCon, SicsInterp *pSics,
|
|||||||
}
|
}
|
||||||
if (strcmp(argv[1], "motioncontrol") == 0) {
|
if (strcmp(argv[1], "motioncontrol") == 0) {
|
||||||
char* state = "unknown";
|
char* state = "unknown";
|
||||||
if (self->iValue & (1 << 6))
|
if ((self->iValue & MOTOR_BOTH_BITS) == MOTOR_BOTH_BITS)
|
||||||
|
state = "invalid";
|
||||||
|
else if (self->iValue & MOTOR_ENABLED_BIT)
|
||||||
state = "enabled";
|
state = "enabled";
|
||||||
else if (self->iValue & (1 << 7))
|
else if (self->iValue & MOTOR_DISABLED_BIT)
|
||||||
state = "disabled";
|
state = "disabled";
|
||||||
snprintf(line, 132, "%s.MotionControl = %s", argv[0], state);
|
snprintf(line, 132, "%s.MotionControl = %s", argv[0], state);
|
||||||
SCWrite(pCon, line, eStatus);
|
SCWrite(pCon, line, eStatus);
|
||||||
@@ -251,9 +252,11 @@ static int PLC_Action(SConnection *pCon, SicsInterp *pSics,
|
|||||||
}
|
}
|
||||||
else if (strcmp(argv[1], "secondary") == 0) {
|
else if (strcmp(argv[1], "secondary") == 0) {
|
||||||
char* state = "unknown";
|
char* state = "unknown";
|
||||||
if (self->iValue & (1 << 2))
|
if ((self->iValue & SEC_BOTH_BITS) == SEC_BOTH_BITS)
|
||||||
|
state = "invalid";
|
||||||
|
if (self->iValue & SEC_OPENED_BIT)
|
||||||
state = "opened";
|
state = "opened";
|
||||||
else if (self->iValue & (1 << 3))
|
else if (self->iValue & SEC_CLOSED_BIT)
|
||||||
state = "closed";
|
state = "closed";
|
||||||
snprintf(line, 132, "%s.Secondary = %s", argv[0], state);
|
snprintf(line, 132, "%s.Secondary = %s", argv[0], state);
|
||||||
SCWrite(pCon, line, eStatus);
|
SCWrite(pCon, line, eStatus);
|
||||||
@@ -261,14 +264,24 @@ static int PLC_Action(SConnection *pCon, SicsInterp *pSics,
|
|||||||
}
|
}
|
||||||
else if (strcmp(argv[1], "tertiary") == 0) {
|
else if (strcmp(argv[1], "tertiary") == 0) {
|
||||||
char* state = "unknown";
|
char* state = "unknown";
|
||||||
if (self->iValue & (1 << 4))
|
if ((self->iValue & TER_BOTH_BITS) == TER_BOTH_BITS)
|
||||||
|
state = "invalid";
|
||||||
|
if (self->iValue & TER_OPENED_BIT)
|
||||||
state = "opened";
|
state = "opened";
|
||||||
else if (self->iValue & (1 << 5))
|
else if (self->iValue & TER_CLOSED_BIT)
|
||||||
state = "closed";
|
state = "closed";
|
||||||
snprintf(line, 132, "%s.Tertiary = %s", argv[0], state);
|
snprintf(line, 132, "%s.Tertiary = %s", argv[0], state);
|
||||||
SCWrite(pCon, line, eStatus);
|
SCWrite(pCon, line, eStatus);
|
||||||
return OKOK;
|
return OKOK;
|
||||||
}
|
}
|
||||||
|
else if (strcmp(argv[1], "instrument") == 0) {
|
||||||
|
char* state = "unready";
|
||||||
|
if (self->iValue & INST_READY_BIT)
|
||||||
|
state = "ready";
|
||||||
|
snprintf(line, 132, "%s.Instrument = %s", argv[0], state);
|
||||||
|
SCWrite(pCon, line, eStatus);
|
||||||
|
return OKOK;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
/* TODO: handle private stuff */
|
/* TODO: handle private stuff */
|
||||||
return MultiChanAction(pCon, pSics, self->mcc, argc, argv);
|
return MultiChanAction(pCon, pSics, self->mcc, argc, argv);
|
||||||
|
|||||||
Reference in New Issue
Block a user