MJL 21/11/06 Added ability to select termination object (can now terminate all when a HM terminates, not just counter).

r1307 | mle | 2006-11-21 09:56:19 +1100 (Tue, 21 Nov 2006) | 2 lines
This commit is contained in:
Mark Lesha
2006-11-21 09:56:19 +11:00
committed by Douglas Clowes
parent 295eafefe8
commit ff576a4c68
2 changed files with 40 additions and 9 deletions

View File

@@ -22,8 +22,9 @@
/*----------------------------------------------------------------------*/
static int HMCStatus_ANSTO(void *pData, SConnection *pCon)
// A very slightly modified version of the original HMCStatus(),
// to support pause-on-count-terminate option for ANSTO HM.
// A slightly modified version of the original HMCStatus(),
// to support pause-on-count-terminate option for ANSTO HM,
// and termination either by counter or by HM.
{
int status,i;
pHMcontrol self = NULL;
@@ -31,7 +32,9 @@ static int HMCStatus_ANSTO(void *pData, SConnection *pCon)
self = (pHMcontrol)pData;
assert(self);
status = self->slaves[0]->CheckCountStatus(self->slaveData[0],pCon);
// Termination happens when the selected device (counter or HM) terminates.
status = self->slaves[((pHMcontrol_ANSTO)pData)->Termination_Object]
->CheckCountStatus(self->slaveData[((pHMcontrol_ANSTO)pData)->Termination_Object],pCon);
if(status == HWIdle || status == HWFault)
{
/*
@@ -39,10 +42,10 @@ static int HMCStatus_ANSTO(void *pData, SConnection *pCon)
occurred.
*/
InvokeCallBack(self->pCall,COUNTEND,pCon);
// If required, pause hm objects when count finishes
// If required, pause all objects when hm/count terminates
// instead of stopping them. Use the existing interface
// functions to do this.
if (((pHMcontrol_ANSTO)pData)->Pause_HM_After_Count)
if (((pHMcontrol_ANSTO)pData)->Pause_HM_After_Count==1)
self->pCount->Pause(self,pCon);
else
self->pCount->Halt(self);
@@ -65,13 +68,40 @@ static int HMCStatus_ANSTO(void *pData, SConnection *pCon)
/*----------------------------------------------------------------------*/
int HMControlAction_ANSTO(SConnection *pCon, SicsInterp *pSics,
void *pData, int argc, char *argv[])
// This function extends HMControlAction by looking for an optional
// fifth command argument, which is stored to the expanded command data.
// This function extends HMControlAction by looking for an optional fifth
// and sixth command argument, which are stored to the expanded command data.
// Thereafter the rest of the arguments are simply passed to the standard
// HMControlAction function.
{
((pHMcontrol_ANSTO)pData)->Pause_HM_After_Count
=(argc>=5&&strcmp(argv[4],"pause")==0);
((pHMcontrol_ANSTO)pData)->Pause_HM_After_Count=0;
((pHMcontrol_ANSTO)pData)->Termination_Object=0;
if (argc>=5)
{
if (strcmp(argv[4],"pause")==0)
((pHMcontrol_ANSTO)pData)->Pause_HM_After_Count=1;
else if (strcmp(argv[4],"stop")!=0) // default
{
SCWrite(pCon,"ERROR: Optional argument 5 must be 'stop' or 'pause'",eError);
return 0;
}
}
if (argc>=6)
{
if (sscanf(argv[5],"%d",&(((pHMcontrol_ANSTO)pData)->Termination_Object))!=1
|| ((pHMcontrol_ANSTO)pData)->Termination_Object>=((pHMcontrol_ANSTO)pData)->hmc.nSlaves)
{
char errstr[256];
sprintf(errstr,"ERROR: Optional argument 6 must be integer 0 to %d, specifies termination object.",
((pHMcontrol_ANSTO)pData)->hmc.nSlaves - 1);
SCWrite(pCon,errstr,eError);
return 0;
}
}
if (argc>=7) // too many args
{
SCWrite(pCon,"ERROR: Usage %s start preset mode",eError);
return 0;
}
return HMControlAction(pCon, pSics, pData, argc, argv);
}