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) static int HMCStatus_ANSTO(void *pData, SConnection *pCon)
// A very slightly modified version of the original HMCStatus(), // A slightly modified version of the original HMCStatus(),
// to support pause-on-count-terminate option for ANSTO HM. // to support pause-on-count-terminate option for ANSTO HM,
// and termination either by counter or by HM.
{ {
int status,i; int status,i;
pHMcontrol self = NULL; pHMcontrol self = NULL;
@@ -31,7 +32,9 @@ static int HMCStatus_ANSTO(void *pData, SConnection *pCon)
self = (pHMcontrol)pData; self = (pHMcontrol)pData;
assert(self); 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) if(status == HWIdle || status == HWFault)
{ {
/* /*
@@ -39,10 +42,10 @@ static int HMCStatus_ANSTO(void *pData, SConnection *pCon)
occurred. occurred.
*/ */
InvokeCallBack(self->pCall,COUNTEND,pCon); 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 // instead of stopping them. Use the existing interface
// functions to do this. // 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); self->pCount->Pause(self,pCon);
else else
self->pCount->Halt(self); self->pCount->Halt(self);
@@ -65,13 +68,40 @@ static int HMCStatus_ANSTO(void *pData, SConnection *pCon)
/*----------------------------------------------------------------------*/ /*----------------------------------------------------------------------*/
int HMControlAction_ANSTO(SConnection *pCon, SicsInterp *pSics, int HMControlAction_ANSTO(SConnection *pCon, SicsInterp *pSics,
void *pData, int argc, char *argv[]) void *pData, int argc, char *argv[])
// This function extends HMControlAction by looking for an optional // This function extends HMControlAction by looking for an optional fifth
// fifth command argument, which is stored to the expanded command data. // and sixth command argument, which are stored to the expanded command data.
// Thereafter the rest of the arguments are simply passed to the standard // Thereafter the rest of the arguments are simply passed to the standard
// HMControlAction function. // HMControlAction function.
{ {
((pHMcontrol_ANSTO)pData)->Pause_HM_After_Count ((pHMcontrol_ANSTO)pData)->Pause_HM_After_Count=0;
=(argc>=5&&strcmp(argv[4],"pause")==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); return HMControlAction(pCon, pSics, pData, argc, argv);
} }

View File

@@ -20,6 +20,7 @@ typedef struct
HMcontrol hmc; HMcontrol hmc;
/* Extra data for HMControl_ANSTO for extra functionality */ /* Extra data for HMControl_ANSTO for extra functionality */
int Pause_HM_After_Count; int Pause_HM_After_Count;
int Termination_Object;
} HMcontrol_ANSTO, *pHMcontrol_ANSTO; } HMcontrol_ANSTO, *pHMcontrol_ANSTO;
int MakeHMControl_ANSTO(SConnection *pCon, SicsInterp *pSics, int MakeHMControl_ANSTO(SConnection *pCon, SicsInterp *pSics,