Cleaned up ANSTO code to merge with sinqdev.sics
This is our new RELEASE-4_0 branch which was taken from ansto/93d9a7c Conflicts: .gitignore SICSmain.c asynnet.c confvirtualmot.c counter.c devexec.c drive.c event.h exebuf.c exeman.c histmem.c interface.h motor.c motorlist.c motorsec.c multicounter.c napi.c napi.h napi4.c network.c nwatch.c nxscript.c nxxml.c nxxml.h ofac.c reflist.c scan.c sicshipadaba.c sicsobj.c site_ansto/docs/Copyright.txt site_ansto/instrument/lyrebird/config/tasmad/sicscommon/nxsupport.tcl site_ansto/instrument/lyrebird/config/tasmad/taspub_sics/tasscript.tcl statusfile.c tasdrive.c tasub.c tasub.h tasublib.c tasublib.h
This commit is contained in:
118
statemon.c
118
statemon.c
@ -16,16 +16,11 @@
|
||||
#include "stptok.h"
|
||||
#include "statemon.h"
|
||||
#include "sicshipadaba.h"
|
||||
#include "sicsvar.h"
|
||||
|
||||
#define SICS_SUID "sics_suid"
|
||||
pICallBack statemon_cbinterface = NULL;
|
||||
/*==========================================================================*/
|
||||
typedef struct __STATEMON {
|
||||
pObjectDescriptor pDes;
|
||||
pICallBack pCall;
|
||||
} StateMon;
|
||||
SConnection *pStateMonDummyCon = NULL;
|
||||
/*============================ Callbacks =================================*/
|
||||
static int DevexecCallback(int iEvent, void *text, void *pData)
|
||||
{
|
||||
@ -106,8 +101,7 @@ static int StateInterest(int iEvent, void *pEvent, void *pUser)
|
||||
SConnection *pCon = (SConnection *) pUser;
|
||||
char *device = (char *) pEvent;
|
||||
char buffer[256];
|
||||
pSicsVariable pVar = NULL;
|
||||
|
||||
|
||||
if (pCon == NULL || !SCisConnected(pCon)) {
|
||||
return -1;
|
||||
}
|
||||
@ -116,51 +110,14 @@ static int StateInterest(int iEvent, void *pEvent, void *pUser)
|
||||
if (pCon == NULL || device == NULL) {
|
||||
printf("Bad StateInterest in statemon\n");
|
||||
return 0;
|
||||
} else if (pCon == pStateMonDummyCon) {
|
||||
if (iEvent == STSTART) {
|
||||
snprintf(buffer, 255, "SUID MSG STARTED = %s", device);
|
||||
SCWrite(pStateMonDummyCon, buffer, eError);
|
||||
}
|
||||
if (iEvent == STEND) {
|
||||
snprintf(buffer, 255, "SUID MSG FINISH = %s", device);
|
||||
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);
|
||||
}
|
||||
if (iEvent == STPAUSE) {
|
||||
snprintf(buffer, 255, "PAUSE = %s", device);
|
||||
SCWrite(pCon, buffer, eWarning);
|
||||
}
|
||||
if (iEvent == STCONTINUE) {
|
||||
snprintf(buffer, 255, "CONTINUE = %s", device);
|
||||
SCWrite(pCon, buffer, eWarning);
|
||||
}
|
||||
if (iEvent == STBUSY) {
|
||||
snprintf(buffer, 255, "BUSY = %s", device);
|
||||
SCWrite(pCon, buffer, eWarning);
|
||||
}
|
||||
if (iEvent == STIDLE) {
|
||||
snprintf(buffer, 255, "IDLE = %s", device);
|
||||
SCWrite(pCon, buffer, eWarning);
|
||||
}
|
||||
}
|
||||
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;
|
||||
}
|
||||
@ -168,7 +125,7 @@ static int StateInterest(int iEvent, void *pEvent, void *pUser)
|
||||
/*--------------------------------------------------------------------------*/
|
||||
static pHdb recurseInterestNode(pHdb current, char *pDevice)
|
||||
{
|
||||
char pSicsdev[131], pAlias[132];
|
||||
char pSicsdev[132], pAlias[132];
|
||||
pHdb result = NULL;
|
||||
char *alias = NULL, *pPtr = NULL;
|
||||
|
||||
@ -274,9 +231,6 @@ static void killStateMon(void *pData)
|
||||
if (self->pCall != NULL) {
|
||||
DeleteCallBackInterface(self->pCall);
|
||||
}
|
||||
if (pStateMonDummyCon != NULL) {
|
||||
SCDeleteConnection(pStateMonDummyCon);
|
||||
}
|
||||
free(self);
|
||||
}
|
||||
}
|
||||
@ -285,12 +239,10 @@ static void killStateMon(void *pData)
|
||||
int StateMonFactory(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
int argc, char *argv[])
|
||||
{
|
||||
long lID;
|
||||
pStateMon pNew = NULL;
|
||||
commandContext cc;
|
||||
pICallBack target = NULL;
|
||||
void *pPtr = NULL, *exe = NULL, *pDevexec = NULL;
|
||||
pSicsVariable pRes = NULL;
|
||||
|
||||
exe = FindCommandData(pSics, "exe", "ExeManager");
|
||||
pDevexec = FindCommandData(pSics, "stopexe", "DeviceExecutor");
|
||||
@ -314,7 +266,6 @@ int StateMonFactory(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
memset(pNew, 0, sizeof(StateMon));
|
||||
pNew->pDes = CreateDescriptor("statemon");
|
||||
pNew->pCall = CreateCallBackInterface();
|
||||
statemon_cbinterface = pNew->pCall;
|
||||
if (pNew->pDes == NULL || pNew->pCall == NULL) {
|
||||
SCWrite(pCon, "ERROR: out of memory creating StateMon", eError);
|
||||
return 0;
|
||||
@ -342,17 +293,6 @@ int StateMonFactory(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
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);
|
||||
lID = RegisterCallback(pNew->pCall, STEND, StateInterest,
|
||||
pStateMonDummyCon, NULL);
|
||||
pRes = VarCreate(usInternal, veInt, SICS_SUID);
|
||||
AddCommand(pSics, SICS_SUID, VarWrapper, (KillFunc) VarKill, pRes);
|
||||
/*
|
||||
* TODO: add kill functions
|
||||
*/
|
||||
AddCommand(pSics, "statemon", StateMonAction, killStateMon, pNew);
|
||||
return 1;
|
||||
}
|
||||
@ -395,15 +335,9 @@ int StateMonAction(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
SCWrite(pCon, "ERROR: out of memory registering interest", eError);
|
||||
return 0;
|
||||
}
|
||||
|
||||
lID = RegisterCallback(self->pCall, STSTART, StateInterest,
|
||||
callCon, NULL);
|
||||
lID = RegisterCallback(self->pCall, STPAUSE, StateInterest,
|
||||
callCon, NULL);
|
||||
lID = RegisterCallback(self->pCall, STCONTINUE, StateInterest,
|
||||
callCon, NULL);
|
||||
lID = RegisterCallback(self->pCall, STBUSY, StateInterest,
|
||||
callCon, NULL);
|
||||
callCon, SCDeleteConnection);
|
||||
SCRegister(pCon, pSics, self->pCall, lID);
|
||||
lID = RegisterCallback(self->pCall, STEND, StateInterest,
|
||||
callCon, NULL);
|
||||
SCSendOK(pCon);
|
||||
@ -443,34 +377,6 @@ int StateMonAction(SConnection * pCon, SicsInterp * pSics, void *pData,
|
||||
return 1;
|
||||
}
|
||||
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);
|
||||
|
Reference in New Issue
Block a user