MJL 8/11/06 Initial version.
r1255 | mle | 2006-11-08 16:59:44 +1100 (Wed, 08 Nov 2006) | 2 lines
This commit is contained in:
committed by
Douglas Clowes
parent
3c7c269705
commit
d29d5d867c
104
site_ansto/hmcontrol_ansto.c
Normal file
104
site_ansto/hmcontrol_ansto.c
Normal file
@@ -0,0 +1,104 @@
|
||||
/*------------------------------------------------------------------------
|
||||
H M C O N T R O L _ A N S T O
|
||||
|
||||
A module creating a slightly modified HMControl object suitable for the
|
||||
ANSTO HM. This works exactly the same as the existing HMControl, but
|
||||
has extra options (e.g. pausing HM's at the end of a count instead of
|
||||
stopping them).
|
||||
|
||||
copyright: see copyright.h
|
||||
|
||||
Mark Lesha, October 2006
|
||||
-------------------------------------------------------------------------*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <tcl.h>
|
||||
#include "fortify.h"
|
||||
#include "hmcontrol.h"
|
||||
#include "hmcontrol_ansto.h" // extends hmcontrol.h
|
||||
#include "HistMem.h"
|
||||
#include "devexec.h"
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
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.
|
||||
{
|
||||
int status,i;
|
||||
pHMcontrol self = NULL;
|
||||
|
||||
self = (pHMcontrol)pData;
|
||||
assert(self);
|
||||
|
||||
status = self->slaves[0]->CheckCountStatus(self->slaveData[0],pCon);
|
||||
if(status == HWIdle || status == HWFault)
|
||||
{
|
||||
/*
|
||||
stop counting on slaves when finished or when an error
|
||||
occurred.
|
||||
*/
|
||||
InvokeCallBack(self->pCall,COUNTEND,pCon);
|
||||
// If required, pause hm objects when count finishes
|
||||
// instead of stopping them. Use the existing interface
|
||||
// functions to do this.
|
||||
if (((pHMcontrol_ANSTO)pData)->Pause_HM_After_Count)
|
||||
self->pCount->Pause(self,pCon);
|
||||
else
|
||||
self->pCount->Halt(self);
|
||||
}
|
||||
/*
|
||||
Warning: this assumes that slaves 1 - MAXSLAVE are histogram memories.
|
||||
If this assumption does not hold, change this code to check if this
|
||||
is really a histogram memory.
|
||||
*/
|
||||
for(i = 1; i < MAXSLAVE; i++)
|
||||
{
|
||||
if(self->slaves[i] != NULL)
|
||||
{
|
||||
HistDirty((pHistMem)self->slaveData[i]);
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
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.
|
||||
// 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);
|
||||
return HMControlAction(pCon, pSics, pData, argc, argv);
|
||||
}
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
int MakeHMControl_ANSTO(SConnection *pCon, SicsInterp *pSics,
|
||||
void *pData, int argc, char *argv[])
|
||||
{
|
||||
/* Start by making a plain vanilla HMControl object, */
|
||||
/* which gets installed in the command list. */
|
||||
if (!MakeHMControl(pCon, pSics, pData, argc, argv))
|
||||
return 0;
|
||||
/* Find the new object in the command list. */
|
||||
CommandList *pCommand;
|
||||
if (!(pCommand=FindCommand(pSics,argv[1])))
|
||||
return 0;
|
||||
/* Get the original command's data, and add the extended command's data */
|
||||
/* to it. The altered size of the object does not make any side effects. */
|
||||
HMcontrol_ANSTO *newpData;
|
||||
if (!(newpData=(HMcontrol_ANSTO *)malloc(sizeof(HMcontrol_ANSTO))))
|
||||
return 0;
|
||||
memcpy(newpData,pCommand->pData,sizeof(HMcontrol));
|
||||
memset(((char *)newpData)+sizeof(HMcontrol),0,sizeof(HMcontrol_ANSTO)-sizeof(HMcontrol));
|
||||
free(pCommand->pData);
|
||||
pCommand->pData=(void *)newpData;
|
||||
/* Customize the command handler and status reporting routine. */
|
||||
pCommand->OFunc = HMControlAction_ANSTO;
|
||||
newpData->hmc.pCount->CheckCountStatus = HMCStatus_ANSTO;
|
||||
/* All done, return success. */
|
||||
return 1;
|
||||
}
|
||||
28
site_ansto/hmcontrol_ansto.h
Normal file
28
site_ansto/hmcontrol_ansto.h
Normal file
@@ -0,0 +1,28 @@
|
||||
/*------------------------------------------------------------------------
|
||||
H M C O N T R O L _ A N S T O
|
||||
|
||||
A module creating a slightly modified HMControl object suitable for the
|
||||
ANSTO HM. This works exactly the same as the existing HMControl, but
|
||||
has extra options (e.g. pausing HM's at the end of a count instead of
|
||||
stopping them).
|
||||
|
||||
copyright: see copyright.h
|
||||
|
||||
Mark Lesha, October 2006
|
||||
-------------------------------------------------------------------------*/
|
||||
|
||||
#ifndef HMCONTROL_ANSTO_H_
|
||||
#define HMCONTROL_ANSTO_H_
|
||||
|
||||
typedef struct
|
||||
{
|
||||
/* Data of the original HMControl object */
|
||||
HMcontrol hmc;
|
||||
/* Extra data for HMControl_ANSTO for extra functionality */
|
||||
int Pause_HM_After_Count;
|
||||
} HMcontrol_ANSTO, *pHMcontrol_ANSTO;
|
||||
|
||||
int MakeHMControl_ANSTO(SConnection *pCon, SicsInterp *pSics,
|
||||
void *pData, int argc, char *argv[]);
|
||||
|
||||
#endif /*HMCONTROL_ANSTO_H_*/
|
||||
Reference in New Issue
Block a user