- Reworked the connection object and the IO system
- Reworked the support for TRICS - Added a second generation motor
This commit is contained in:
97
histmem.c
97
histmem.c
@ -167,6 +167,10 @@ extern pHistDriver MakeHMSlaveHM(pStringDict pOpt);
|
||||
self = (pHistMem)pData;
|
||||
assert(self);
|
||||
|
||||
if(!GetCountLock(self->pCountInt, pCon)){
|
||||
return HWFault;
|
||||
}
|
||||
|
||||
if(!self->iInit)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: histogram memory not initialised",eError);
|
||||
@ -195,6 +199,7 @@ extern pHistDriver MakeHMSlaveHM(pStringDict pOpt);
|
||||
SCWrite(pCon,"ERROR: failed to fix histogram memory problem",
|
||||
eError);
|
||||
SCSetInterrupt(pCon,eAbortBatch);
|
||||
ReleaseCountLock(self->pCountInt);
|
||||
return HWFault;
|
||||
}
|
||||
}
|
||||
@ -321,6 +326,7 @@ extern pHistDriver MakeHMSlaveHM(pStringDict pOpt);
|
||||
SCWrite(pCon,"ERROR: failed to fix histogram memory problem",eError);
|
||||
SCSetInterrupt(pCon,eAbortBatch);
|
||||
InvokeCallBack(self->pCall,COUNTEND,NULL);
|
||||
ReleaseCountLock(self->pCountInt);
|
||||
return eCt;
|
||||
}
|
||||
else
|
||||
@ -339,6 +345,7 @@ extern pHistDriver MakeHMSlaveHM(pStringDict pOpt);
|
||||
*/
|
||||
updateHMData(self->pDriv->data);
|
||||
InvokeCallBack(self->pCall,COUNTEND,NULL);
|
||||
ReleaseCountLock(self->pCountInt);
|
||||
}
|
||||
|
||||
return eCt;
|
||||
@ -595,6 +602,11 @@ extern pHistDriver MakeHMSlaveHM(pStringDict pOpt);
|
||||
assert(self);
|
||||
assert(pCon);
|
||||
|
||||
if(isRunning(self->pCountInt)){
|
||||
SCWrite(pCon,"ERROR: cannot configure histogram memory while counting", eError);
|
||||
return 0;
|
||||
}
|
||||
|
||||
iRet = HistDriverConfig(self->pDriv,self->pDriv->pOption,pCon);
|
||||
if(!iRet)
|
||||
{
|
||||
@ -766,16 +778,16 @@ void HistDirty(pHistMem self)
|
||||
iRet = Wait4Success(GetExecutor());
|
||||
if(iRet == DEVINT)
|
||||
{
|
||||
SCWrite(pCon,"Counting aborted due to Interrupt",eStatus);
|
||||
SCWrite(pCon,"Counting aborted due to Interrupt",eError);
|
||||
}
|
||||
else if(iRet == DEVERROR)
|
||||
{
|
||||
SCWrite(pCon,"Counting finished with Problems",eStatus);
|
||||
SCWrite(pCon,"Counting finished with Problems",eValue);
|
||||
iRet = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
SCWrite(pCon,"Counting finished",eStatus);
|
||||
SCWrite(pCon,"Counting finished",eValue);
|
||||
iRet = 1;
|
||||
}
|
||||
|
||||
@ -791,7 +803,7 @@ void HistDirty(pHistMem self)
|
||||
char pBueffel[512], pError[80];
|
||||
|
||||
assert(self);
|
||||
|
||||
|
||||
if(!self->iInit)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: histogram memory not initialised",eError);
|
||||
@ -934,24 +946,29 @@ void HistDirty(pHistMem self)
|
||||
return 0;
|
||||
}
|
||||
/*----------------------------------------------------------------------*/
|
||||
static int HMCountInterest(int iEvent, void *pEvent, void *pUser,
|
||||
commandContext cc)
|
||||
static int HMCountInterest(int iEvent, void *pEvent, void *pUser)
|
||||
{
|
||||
SConnection *pCon = NULL;
|
||||
char pBueffel[512];
|
||||
|
||||
if(iEvent == COUNTSTART)
|
||||
pCon = (SConnection *)pUser;
|
||||
|
||||
if(pCon == NULL || !SCisConnected(pCon))
|
||||
{
|
||||
return -1;
|
||||
}
|
||||
|
||||
if(iEvent == COUNTSTART && pUser != NULL)
|
||||
{
|
||||
pCon = (SConnection *)pUser;
|
||||
assert(pCon);
|
||||
SCWriteInContext(pCon,"HMCOUNTSTART",eWarning,cc);
|
||||
SCWrite(pCon,"HMCOUNTSTART",eWarning);
|
||||
return 1;
|
||||
}
|
||||
else if(iEvent == COUNTEND)
|
||||
{
|
||||
pCon = (SConnection *)pUser;
|
||||
assert(pCon);
|
||||
SCWriteInContext(pCon,"HMCOUNTEND",eWarning,cc);
|
||||
SCWrite(pCon,"HMCOUNTEND",eWarning);
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
@ -982,11 +999,13 @@ static int checkHMEnd(pHistMem self, char *text){
|
||||
int i,iRet,iLen,iRank,iDiscard,tofMode;
|
||||
float fVal;
|
||||
char *pMode[] = {"timer","monitor",NULL};
|
||||
pDynString buf = NULL;
|
||||
|
||||
memset(pBuffer, 0, sizeof(pBuffer));
|
||||
memset(pValue, 0, sizeof(pValue));
|
||||
memset(name, 0, sizeof(name));
|
||||
|
||||
|
||||
SCStartBuffering(pCon);
|
||||
iRet = StringDictGet(self->pDriv->pOption,"name",name,19);
|
||||
if(0==iRet) {
|
||||
strcpy(name,"*");
|
||||
@ -994,7 +1013,7 @@ static int checkHMEnd(pHistMem self, char *text){
|
||||
iRet = StringDictGet(self->pDriv->pOption,"driver",pValue,sizeof(pValue)-1);
|
||||
if(0<iRet) {
|
||||
sprintf(pBuffer,"%s.driver = %s",name,pValue);
|
||||
SCWrite(pCon,pBuffer,eStatus);
|
||||
SCWrite(pCon,pBuffer,eValue);
|
||||
}
|
||||
|
||||
iRet = StringDictGetAsNumber(self->pDriv->pOption,"update",&fVal);
|
||||
@ -1003,13 +1022,13 @@ static int checkHMEnd(pHistMem self, char *text){
|
||||
} else {
|
||||
sprintf(pBuffer,"%s.update = 0 (no buffering)",name);
|
||||
}
|
||||
SCWrite(pCon,pBuffer,eStatus);
|
||||
SCWrite(pCon,pBuffer,eValue);
|
||||
|
||||
iRet = StringDictGetAsNumber(self->pDriv->pOption,"rank",&fVal);
|
||||
if(0<iRet) {
|
||||
iRank = (int)rint(fVal);
|
||||
sprintf(pBuffer,"%s.rank = %d",name,iRank);
|
||||
SCWrite(pCon,pBuffer,eStatus);
|
||||
SCWrite(pCon,pBuffer,eValue);
|
||||
} else {
|
||||
iRank = 0;
|
||||
}
|
||||
@ -1018,7 +1037,7 @@ static int checkHMEnd(pHistMem self, char *text){
|
||||
iRet = StringDictGetAsNumber(self->pDriv->pOption,pValue,&fVal);
|
||||
if(0<iRet){
|
||||
sprintf(pBuffer,"%s.dim%1.1d = %d",name,i,(int)rint(fVal));
|
||||
SCWrite(pCon,pBuffer,eStatus);
|
||||
SCWrite(pCon,pBuffer,eValue);
|
||||
}
|
||||
}
|
||||
|
||||
@ -1032,18 +1051,18 @@ static int checkHMEnd(pHistMem self, char *text){
|
||||
if(NULL!=strstr(pKey,"dim")) iDiscard=1;
|
||||
if(0==iDiscard) {
|
||||
snprintf(pBuffer,511,"%s.%s = %s",name,pKey,pValue);
|
||||
SCWrite(pCon,pBuffer,eStatus);
|
||||
SCWrite(pCon,pBuffer,eValue);
|
||||
}
|
||||
pKey = StringDictGetNext(self->pDriv->pOption,pValue,sizeof(pValue)-1);
|
||||
}
|
||||
|
||||
/* Display Count Mode */
|
||||
sprintf(pBuffer,"%s.CountMode = %s",name,pMode[self->pDriv->eCount]);
|
||||
SCWrite(pCon,pBuffer,eStatus);
|
||||
SCWrite(pCon,pBuffer,eValue);
|
||||
|
||||
/* Display Preset */
|
||||
sprintf(pBuffer,"%s.preset = %f",name,self->pDriv->fCountPreset);
|
||||
SCWrite(pCon,pBuffer,eStatus);
|
||||
SCWrite(pCon,pBuffer,eValue);
|
||||
|
||||
if(self->pDriv->data->nTimeChan > 2) {
|
||||
tofMode = 1;
|
||||
@ -1051,7 +1070,11 @@ static int checkHMEnd(pHistMem self, char *text){
|
||||
tofMode = 0;
|
||||
}
|
||||
sprintf(pBuffer,"%s.tofMode = %d",name,tofMode);
|
||||
SCWrite(pCon,pBuffer,eStatus);
|
||||
SCWrite(pCon,pBuffer,eValue);
|
||||
buf = SCEndBuffering(pCon);
|
||||
if(buf != NULL){
|
||||
SCWrite(pCon,GetCharArray(buf), eValue);
|
||||
}
|
||||
}
|
||||
/*--------------------------------------------------------------------------*/
|
||||
|
||||
@ -1098,14 +1121,12 @@ static int checkHMEnd(pHistMem self, char *text){
|
||||
strtolower(argv[1]);
|
||||
if(strcmp(argv[1],"interest") == 0)
|
||||
{
|
||||
lID = RegisterCallback(self->pCall, SCGetContext(pCon),
|
||||
lID = RegisterCallback(self->pCall,
|
||||
COUNTSTART, HMCountInterest,
|
||||
pCon, NULL);
|
||||
SCRegister(pCon,pSics, self->pCall,lID);
|
||||
lID = RegisterCallback(self->pCall, SCGetContext(pCon),
|
||||
SCCopyConnection(pCon), SCDeleteConnection);
|
||||
lID = RegisterCallback(self->pCall,
|
||||
COUNTEND, HMCountInterest,
|
||||
pCon, NULL);
|
||||
SCRegister(pCon,pSics, self->pCall,lID);
|
||||
SCCopyConnection(pCon), SCDeleteConnection);
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
}
|
||||
@ -1178,6 +1199,10 @@ static int checkHMEnd(pHistMem self, char *text){
|
||||
}
|
||||
else /* set case */
|
||||
{
|
||||
if(isRunning(self->pCountInt)){
|
||||
SCWrite(pCon,"ERROR: cannot change preset while counting", eError);
|
||||
return 0;
|
||||
}
|
||||
fVal = atof(argv[2]);
|
||||
if(!SCMatchRights(pCon,self->iAccess))
|
||||
{
|
||||
@ -1221,6 +1246,10 @@ static int checkHMEnd(pHistMem self, char *text){
|
||||
else /* set case */
|
||||
{
|
||||
strtolower(argv[2]);
|
||||
if(isRunning(self->pCountInt)){
|
||||
SCWrite(pCon,"ERROR: cannot change countmode while counting", eError);
|
||||
return 0;
|
||||
}
|
||||
if(!SCMatchRights(pCon,self->iAccess))
|
||||
{
|
||||
return 0;
|
||||
@ -1638,16 +1667,14 @@ static int checkHMEnd(pHistMem self, char *text){
|
||||
/* generate time binning */
|
||||
else if(strcmp(argv[1],"genbin") == 0)
|
||||
{
|
||||
if(isRunning(self->pCountInt)){
|
||||
SCWrite(pCon,"ERROR: cannot change time binning while counting", eError);
|
||||
return 0;
|
||||
}
|
||||
if(!SCMatchRights(pCon,usMugger))
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
if(GetStatus() == eCounting)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: cannot modify timebinning while counting",
|
||||
eError);
|
||||
return 0;
|
||||
}
|
||||
if(argc < 5)
|
||||
{
|
||||
SCWrite(pCon,"ERROR: not enough aguments to genbin",eError);
|
||||
@ -1695,6 +1722,10 @@ static int checkHMEnd(pHistMem self, char *text){
|
||||
/* set a time bin */
|
||||
else if(strcmp(argv[1],"setbin") == 0)
|
||||
{
|
||||
if(isRunning(self->pCountInt)){
|
||||
SCWrite(pCon,"ERROR: cannot change time binning while counting", eError);
|
||||
return 0;
|
||||
}
|
||||
if(!SCMatchRights(pCon,usMugger))
|
||||
{
|
||||
return 0;
|
||||
@ -1732,6 +1763,10 @@ static int checkHMEnd(pHistMem self, char *text){
|
||||
/* clear time bin info */
|
||||
else if(strcmp(argv[1],"clearbin") == 0)
|
||||
{
|
||||
if(isRunning(self->pCountInt)){
|
||||
SCWrite(pCon,"ERROR: cannot change time binning while counting", eError);
|
||||
return 0;
|
||||
}
|
||||
clearTimeBinning(self->pDriv->data);
|
||||
SCSendOK(pCon);
|
||||
return 1;
|
||||
|
Reference in New Issue
Block a user