merge work in progress
This commit is contained in:
4
event.h
4
event.h
@ -49,6 +49,10 @@
|
|||||||
#define STEND 22
|
#define STEND 22
|
||||||
#define NEWTARGET 23
|
#define NEWTARGET 23
|
||||||
#define DIMCHANGE 24
|
#define DIMCHANGE 24
|
||||||
|
#define STPAUSE 25
|
||||||
|
#define STCONTINUE 26
|
||||||
|
#define STBUSY 27
|
||||||
|
#define STIDLE 28
|
||||||
|
|
||||||
#line 118 "event.w"
|
#line 118 "event.w"
|
||||||
|
|
||||||
|
@ -138,7 +138,6 @@ GHTTP_LIBS = \
|
|||||||
|
|
||||||
OBJ= site_ansto.o anstoutil.o\
|
OBJ= site_ansto.o anstoutil.o\
|
||||||
ansto_sctdriveadapter.o\
|
ansto_sctdriveadapter.o\
|
||||||
ansto_tclmotdriv.o\
|
|
||||||
sctemonadapter.o\
|
sctemonadapter.o\
|
||||||
motor_asim.o motor_dmc2280.o\
|
motor_asim.o motor_dmc2280.o\
|
||||||
lh45.o lh45driv.o \
|
lh45.o lh45driv.o \
|
||||||
|
110
statemon.c
110
statemon.c
@ -3,7 +3,7 @@
|
|||||||
* from the device executor and from scan and batch commands. Clients can
|
* from the device executor and from scan and batch commands. Clients can
|
||||||
* listen to this in order to figure out what is actually going on in a
|
* listen to this in order to figure out what is actually going on in a
|
||||||
* given SICS installation. This might in the end supersede the status code
|
* given SICS installation. This might in the end supersede the status code
|
||||||
* managment in status.c
|
* management in status.c
|
||||||
*
|
*
|
||||||
* copyright: see file COPYRIGHT
|
* copyright: see file COPYRIGHT
|
||||||
*
|
*
|
||||||
@ -16,11 +16,16 @@
|
|||||||
#include "stptok.h"
|
#include "stptok.h"
|
||||||
#include "statemon.h"
|
#include "statemon.h"
|
||||||
#include "sicshipadaba.h"
|
#include "sicshipadaba.h"
|
||||||
|
#include "sicsvar.h"
|
||||||
|
|
||||||
|
#define SICS_SUID "sics_suid"
|
||||||
|
pICallBack statemon_cbinterface = NULL;
|
||||||
/*==========================================================================*/
|
/*==========================================================================*/
|
||||||
typedef struct __STATEMON {
|
typedef struct __STATEMON {
|
||||||
pObjectDescriptor pDes;
|
pObjectDescriptor pDes;
|
||||||
pICallBack pCall;
|
pICallBack pCall;
|
||||||
} StateMon;
|
} StateMon;
|
||||||
|
SConnection *pStateMonDummyCon = NULL;
|
||||||
/*============================ Callbacks =================================*/
|
/*============================ Callbacks =================================*/
|
||||||
static int DevexecCallback(int iEvent, void *text, void *pData)
|
static int DevexecCallback(int iEvent, void *text, void *pData)
|
||||||
{
|
{
|
||||||
@ -101,22 +106,41 @@ static int StateInterest(int iEvent, void *pEvent, void *pUser)
|
|||||||
SConnection *pCon = (SConnection *) pUser;
|
SConnection *pCon = (SConnection *) pUser;
|
||||||
char *device = (char *) pEvent;
|
char *device = (char *) pEvent;
|
||||||
char buffer[256];
|
char buffer[256];
|
||||||
|
pSicsVariable pVar = NULL;
|
||||||
|
|
||||||
if (pCon == NULL || !SCisConnected(pCon)) {
|
if (pCon == NULL || !SCisConnected(pCon)) {
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (pCon == NULL || device == NULL) {
|
if (pCon == NULL || device == NULL) {
|
||||||
printf("Bad StateInterest in statemon\n");
|
printf("Bad StateInterest in statemon\n");
|
||||||
return 0;
|
return 0;
|
||||||
}
|
} else if (pCon == pStateMonDummyCon) {
|
||||||
if (iEvent == STSTART) {
|
if(iEvent == STSTART){
|
||||||
snprintf(buffer, 255, "STARTED = %s", device);
|
snprintf(buffer,255,"SUID MSG STARTED = %s", device);
|
||||||
SCWrite(pCon, buffer, eWarning);
|
SCWrite(pStateMonDummyCon,buffer,eError);
|
||||||
}
|
}
|
||||||
if (iEvent == STEND) {
|
if(iEvent == STEND){
|
||||||
snprintf(buffer, 255, "FINISH = %s", device);
|
snprintf(buffer,255,"SUID MSG FINISH = %s", device);
|
||||||
SCWrite(pCon, buffer, eWarning);
|
SCWrite(pStateMonDummyCon,buffer,eError);
|
||||||
|
}
|
||||||
|
pVar = (pSicsVariable)FindCommandData(pServ->pSics,SICS_SUID,"SicsVariable");
|
||||||
|
if (pVar == NULL) {
|
||||||
|
SCWrite(pStateMonDummyCon,"ERROR: StateMon.c: Could not find SUID SicsVariable",eError);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
(pVar->iVal)++;
|
||||||
|
InvokeCallBack(pVar->pCall, VALUECHANGE, pVar);
|
||||||
|
} else {
|
||||||
|
if (iEvent == STSTART) {
|
||||||
|
snprintf(buffer, 255, "STARTED = %s", device);
|
||||||
|
SCWrite(pCon, buffer, eWarning);
|
||||||
|
}
|
||||||
|
if (iEvent == STEND) {
|
||||||
|
snprintf(buffer, 255, "FINISH = %s", device);
|
||||||
|
SCWrite(pCon, buffer, eWarning);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -230,6 +254,9 @@ static void killStateMon(void *pData)
|
|||||||
if (self->pCall != NULL) {
|
if (self->pCall != NULL) {
|
||||||
DeleteCallBackInterface(self->pCall);
|
DeleteCallBackInterface(self->pCall);
|
||||||
}
|
}
|
||||||
|
if(pStateMonDummyCon != NULL) {
|
||||||
|
SCDeleteConnection(pStateMonDummyCon);
|
||||||
|
}
|
||||||
free(self);
|
free(self);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -238,10 +265,12 @@ static void killStateMon(void *pData)
|
|||||||
int StateMonFactory(SConnection * pCon, SicsInterp * pSics, void *pData,
|
int StateMonFactory(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||||
int argc, char *argv[])
|
int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
long lID;
|
||||||
pStateMon pNew = NULL;
|
pStateMon pNew = NULL;
|
||||||
commandContext cc;
|
commandContext cc;
|
||||||
pICallBack target = NULL;
|
pICallBack target = NULL;
|
||||||
void *pPtr = NULL, *exe = NULL, *pDevexec = NULL;
|
void *pPtr = NULL, *exe = NULL, *pDevexec = NULL;
|
||||||
|
pSicsVariable pRes = NULL;
|
||||||
|
|
||||||
exe = FindCommandData(pSics, "exe", "ExeManager");
|
exe = FindCommandData(pSics, "exe", "ExeManager");
|
||||||
pDevexec = FindCommandData(pSics, "stopexe", "DeviceExecutor");
|
pDevexec = FindCommandData(pSics, "stopexe", "DeviceExecutor");
|
||||||
@ -265,6 +294,7 @@ int StateMonFactory(SConnection * pCon, SicsInterp * pSics, void *pData,
|
|||||||
memset(pNew, 0, sizeof(StateMon));
|
memset(pNew, 0, sizeof(StateMon));
|
||||||
pNew->pDes = CreateDescriptor("statemon");
|
pNew->pDes = CreateDescriptor("statemon");
|
||||||
pNew->pCall = CreateCallBackInterface();
|
pNew->pCall = CreateCallBackInterface();
|
||||||
|
statemon_cbinterface = pNew->pCall;
|
||||||
if (pNew->pDes == NULL || pNew->pCall == NULL) {
|
if (pNew->pDes == NULL || pNew->pCall == NULL) {
|
||||||
SCWrite(pCon, "ERROR: out of memory creating StateMon", eError);
|
SCWrite(pCon, "ERROR: out of memory creating StateMon", eError);
|
||||||
return 0;
|
return 0;
|
||||||
@ -283,7 +313,7 @@ int StateMonFactory(SConnection * pCon, SicsInterp * pSics, void *pData,
|
|||||||
if (argc > 1) {
|
if (argc > 1) {
|
||||||
pPtr = FindCommandData(pSics, argv[1], "ScanObject");
|
pPtr = FindCommandData(pSics, argv[1], "ScanObject");
|
||||||
if (pPtr == NULL) {
|
if (pPtr == NULL) {
|
||||||
SCWrite(pCon, "ERROR: failked to locate scan object", eError);
|
SCWrite(pCon,"ERROR: failed to locate scan object",eError);
|
||||||
} else {
|
} else {
|
||||||
target = GetCallbackInterface(pPtr);
|
target = GetCallbackInterface(pPtr);
|
||||||
assert(target != NULL);
|
assert(target != NULL);
|
||||||
@ -292,6 +322,17 @@ int StateMonFactory(SConnection * pCon, SicsInterp * pSics, void *pData,
|
|||||||
RegisterCallback(target, SCANEND, StateMonScanInterest, pNew, NULL);
|
RegisterCallback(target, SCANEND, StateMonScanInterest, pNew, NULL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
/* Make dummy connection for SUID (instrument state id) */
|
||||||
|
pStateMonDummyCon = SCCreateDummyConnection(pSics);
|
||||||
|
lID = RegisterCallback(pNew->pCall, STSTART, StateInterest, pStateMonDummyCon, NULL);
|
||||||
|
SCRegister(pStateMonDummyCon,pSics, pNew->pCall,lID);
|
||||||
|
lID = RegisterCallback(pNew->pCall, STEND, StateInterest, pStateMonDummyCon, NULL);
|
||||||
|
SCRegister(pStateMonDummyCon,pSics, pNew->pCall,lID);
|
||||||
|
pRes = VarCreate(usInternal,veInt,SICS_SUID);
|
||||||
|
AddCommand(pSics,SICS_SUID,VarWrapper,(KillFunc)VarKill,pRes);
|
||||||
|
/*
|
||||||
|
* TODO: add kill functions
|
||||||
|
*/
|
||||||
AddCommand(pSics, "statemon", StateMonAction, killStateMon, pNew);
|
AddCommand(pSics, "statemon", StateMonAction, killStateMon, pNew);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -319,8 +360,21 @@ int StateMonAction(SConnection * pCon, SicsInterp * pSics, void *pData,
|
|||||||
SCWrite(pCon, "ERROR: out of memory registering interest", eError);
|
SCWrite(pCon, "ERROR: out of memory registering interest", eError);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
lID = RegisterCallback(self->pCall, STSTART, StateInterest,
|
lID = RegisterCallback(self->pCall, STSTART, StateInterest,
|
||||||
callCon, SCDeleteConnection);
|
callCon, NULL);
|
||||||
|
SCRegister(pCon, pSics, self->pCall, lID);
|
||||||
|
lID = RegisterCallback(self->pCall, STEND, StateInterest,
|
||||||
|
callCon, NULL);
|
||||||
|
SCRegister(pCon, pSics, self->pCall, lID);
|
||||||
|
lID = RegisterCallback(self->pCall, STPAUSE, StateInterest,
|
||||||
|
callCon, NULL);
|
||||||
|
SCRegister(pCon, pSics, self->pCall, lID);
|
||||||
|
lID = RegisterCallback(self->pCall, STCONTINUE, StateInterest,
|
||||||
|
callCon, NULL);
|
||||||
|
SCRegister(pCon, pSics, self->pCall, lID);
|
||||||
|
lID = RegisterCallback(self->pCall, STBUSY, StateInterest,
|
||||||
|
callCon, NULL);
|
||||||
SCRegister(pCon, pSics, self->pCall, lID);
|
SCRegister(pCon, pSics, self->pCall, lID);
|
||||||
lID = RegisterCallback(self->pCall, STEND, StateInterest,
|
lID = RegisterCallback(self->pCall, STEND, StateInterest,
|
||||||
callCon, NULL);
|
callCon, NULL);
|
||||||
@ -332,6 +386,7 @@ int StateMonAction(SConnection * pCon, SicsInterp * pSics, void *pData,
|
|||||||
lID = SCgetCallbackID(pCon, self->pCall);
|
lID = SCgetCallbackID(pCon, self->pCall);
|
||||||
if (lID >= 0) {
|
if (lID >= 0) {
|
||||||
RemoveCallback(self->pCall, lID);
|
RemoveCallback(self->pCall, lID);
|
||||||
|
SCUnregisterID(pCon,lID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SCSendOK(pCon);
|
SCSendOK(pCon);
|
||||||
@ -344,8 +399,10 @@ int StateMonAction(SConnection * pCon, SicsInterp * pSics, void *pData,
|
|||||||
}
|
}
|
||||||
lID = RegisterCallback(self->pCall, STSTART, StateHdbInterest,
|
lID = RegisterCallback(self->pCall, STSTART, StateHdbInterest,
|
||||||
callCon, SCDeleteConnection);
|
callCon, SCDeleteConnection);
|
||||||
|
/* TODO: why not SCRegister(pCon, pSics, self->pCall, lID); */
|
||||||
lID = RegisterCallback(self->pCall, STEND, StateHdbInterest,
|
lID = RegisterCallback(self->pCall, STEND, StateHdbInterest,
|
||||||
callCon, NULL);
|
callCon, NULL);
|
||||||
|
/* TODO: why not SCRegister(pCon, pSics, self->pCall, lID); */
|
||||||
SCSendOK(pCon);
|
SCSendOK(pCon);
|
||||||
return 1;
|
return 1;
|
||||||
} else if (strcmp(argv[1], "start") == 0) {
|
} else if (strcmp(argv[1], "start") == 0) {
|
||||||
@ -362,7 +419,36 @@ int StateMonAction(SConnection * pCon, SicsInterp * pSics, void *pData,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
} else if(strcmp(argv[1],"pause") == 0) {
|
||||||
|
if(argc > 2){
|
||||||
|
InvokeCallBack(self->pCall,STPAUSE,argv[2]);
|
||||||
|
SCSendOK(pCon);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
} else if(strcmp(argv[1],"continue") == 0) {
|
||||||
|
if(argc > 2){
|
||||||
|
InvokeCallBack(self->pCall,STCONTINUE,argv[2]);
|
||||||
|
SCSendOK(pCon);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
} else if(strcmp(argv[1],"busy") == 0) {
|
||||||
|
if(argc > 2){
|
||||||
|
InvokeCallBack(self->pCall,STBUSY,argv[2]);
|
||||||
|
SCSendOK(pCon);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
} else if(strcmp(argv[1],"idle") == 0) {
|
||||||
|
if(argc > 2){
|
||||||
|
InvokeCallBack(self->pCall,STIDLE,argv[2]);
|
||||||
|
SCSendOK(pCon);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SCWrite(pCon, "ERROR: keyword not recognized", eError);
|
SCWrite(pCon, "ERROR: keyword not recognized", eError);
|
||||||
return 0;
|
return 0;
|
||||||
|
Reference in New Issue
Block a user