various changes
This commit is contained in:
94
statemon.c
94
statemon.c
@ -117,22 +117,26 @@ static int StateInterest(int iEvent, void *pEvent, void *pUser)
|
|||||||
printf("Bad StateInterest in statemon\n");
|
printf("Bad StateInterest in statemon\n");
|
||||||
return 0;
|
return 0;
|
||||||
} else if (pCon == pStateMonDummyCon) {
|
} else if (pCon == pStateMonDummyCon) {
|
||||||
if(iEvent == STSTART){
|
if (iEvent == STSTART) {
|
||||||
snprintf(buffer,255,"SUID MSG STARTED = %s", device);
|
snprintf(buffer, 255, "SUID MSG STARTED = %s", device);
|
||||||
SCWrite(pStateMonDummyCon,buffer,eError);
|
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 (iEvent == STEND) {
|
||||||
if (pVar == NULL) {
|
snprintf(buffer, 255, "SUID MSG FINISH = %s", device);
|
||||||
SCWrite(pStateMonDummyCon,"ERROR: StateMon.c: Could not find SUID SicsVariable",eError);
|
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;
|
return 0;
|
||||||
}
|
}
|
||||||
(pVar->iVal)++;
|
(pVar->iVal)++;
|
||||||
InvokeCallBack(pVar->pCall, VALUECHANGE, pVar);
|
InvokeCallBack(pVar->pCall, VALUECHANGE, pVar);
|
||||||
} else {
|
} else {
|
||||||
if (iEvent == STSTART) {
|
if (iEvent == STSTART) {
|
||||||
snprintf(buffer, 255, "STARTED = %s", device);
|
snprintf(buffer, 255, "STARTED = %s", device);
|
||||||
SCWrite(pCon, buffer, eWarning);
|
SCWrite(pCon, buffer, eWarning);
|
||||||
@ -141,6 +145,22 @@ static int StateInterest(int iEvent, void *pEvent, void *pUser)
|
|||||||
snprintf(buffer, 255, "FINISH = %s", device);
|
snprintf(buffer, 255, "FINISH = %s", device);
|
||||||
SCWrite(pCon, buffer, eWarning);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
@ -254,7 +274,7 @@ static void killStateMon(void *pData)
|
|||||||
if (self->pCall != NULL) {
|
if (self->pCall != NULL) {
|
||||||
DeleteCallBackInterface(self->pCall);
|
DeleteCallBackInterface(self->pCall);
|
||||||
}
|
}
|
||||||
if(pStateMonDummyCon != NULL) {
|
if (pStateMonDummyCon != NULL) {
|
||||||
SCDeleteConnection(pStateMonDummyCon);
|
SCDeleteConnection(pStateMonDummyCon);
|
||||||
}
|
}
|
||||||
free(self);
|
free(self);
|
||||||
@ -313,7 +333,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: failed 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);
|
||||||
@ -324,15 +344,17 @@ int StateMonFactory(SConnection * pCon, SicsInterp * pSics, void *pData,
|
|||||||
}
|
}
|
||||||
/* Make dummy connection for SUID (instrument state id) */
|
/* Make dummy connection for SUID (instrument state id) */
|
||||||
pStateMonDummyCon = SCCreateDummyConnection(pSics);
|
pStateMonDummyCon = SCCreateDummyConnection(pSics);
|
||||||
lID = RegisterCallback(pNew->pCall, STSTART, StateInterest, pStateMonDummyCon, NULL);
|
lID = RegisterCallback(pNew->pCall, STSTART, StateInterest,
|
||||||
SCRegister(pStateMonDummyCon,pSics, pNew->pCall,lID);
|
pStateMonDummyCon, NULL);
|
||||||
lID = RegisterCallback(pNew->pCall, STEND, StateInterest, pStateMonDummyCon, NULL);
|
SCRegister(pStateMonDummyCon, pSics, pNew->pCall, lID);
|
||||||
SCRegister(pStateMonDummyCon,pSics, pNew->pCall,lID);
|
lID = RegisterCallback(pNew->pCall, STEND, StateInterest,
|
||||||
pRes = VarCreate(usInternal,veInt,SICS_SUID);
|
pStateMonDummyCon, NULL);
|
||||||
AddCommand(pSics,SICS_SUID,VarWrapper,(KillFunc)VarKill,pRes);
|
SCRegister(pStateMonDummyCon, pSics, pNew->pCall, lID);
|
||||||
/*
|
pRes = VarCreate(usInternal, veInt, SICS_SUID);
|
||||||
* TODO: add kill functions
|
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;
|
||||||
}
|
}
|
||||||
@ -386,7 +408,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);
|
SCUnregisterID(pCon, lID);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
SCSendOK(pCon);
|
SCSendOK(pCon);
|
||||||
@ -419,30 +441,30 @@ int StateMonAction(SConnection * pCon, SicsInterp * pSics, void *pData,
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
} else if(strcmp(argv[1],"pause") == 0) {
|
} else if (strcmp(argv[1], "pause") == 0) {
|
||||||
if(argc > 2){
|
if (argc > 2) {
|
||||||
InvokeCallBack(self->pCall,STPAUSE,argv[2]);
|
InvokeCallBack(self->pCall, STPAUSE, argv[2]);
|
||||||
SCSendOK(pCon);
|
SCSendOK(pCon);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
} else if(strcmp(argv[1],"continue") == 0) {
|
} else if (strcmp(argv[1], "continue") == 0) {
|
||||||
if(argc > 2){
|
if (argc > 2) {
|
||||||
InvokeCallBack(self->pCall,STCONTINUE,argv[2]);
|
InvokeCallBack(self->pCall, STCONTINUE, argv[2]);
|
||||||
SCSendOK(pCon);
|
SCSendOK(pCon);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
} else if(strcmp(argv[1],"busy") == 0) {
|
} else if (strcmp(argv[1], "busy") == 0) {
|
||||||
if(argc > 2){
|
if (argc > 2) {
|
||||||
InvokeCallBack(self->pCall,STBUSY,argv[2]);
|
InvokeCallBack(self->pCall, STBUSY, argv[2]);
|
||||||
SCSendOK(pCon);
|
SCSendOK(pCon);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
} else if(strcmp(argv[1],"idle") == 0) {
|
} else if (strcmp(argv[1], "idle") == 0) {
|
||||||
if(argc > 2){
|
if (argc > 2) {
|
||||||
InvokeCallBack(self->pCall,STIDLE,argv[2]);
|
InvokeCallBack(self->pCall, STIDLE, argv[2]);
|
||||||
SCSendOK(pCon);
|
SCSendOK(pCon);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user