diff --git a/eigera2.c b/eigera2.c index e59fbc5..395247c 100644 --- a/eigera2.c +++ b/eigera2.c @@ -148,11 +148,12 @@ static int eigera2CheckLimits(void *data, float val, static long eigera2SetValue(void *data, SConnection *pCon, float val){ eigera2 self = NULL; float d2r, d2l; + int status; self = (eigera2)data; if(self->state != IDLE){ - SCWrite(pCon,"ERROR: Eiger A2 still busy...", eError); + SCWrite(pCon,"ERROR: Eiger A2 still busy...", eLogError); return HWFault; } self->a2Target = val; @@ -161,7 +162,12 @@ static long eigera2SetValue(void *data, SConnection *pCon, float val){ setNewMotorTarget(self->motorList,A2R,d2r); setNewMotorTarget(self->motorList,A2L,d2l); self->state = RUNNING; - return self->listDriv->SetValue(&self->motorList, pCon, 27.); + status = self->listDriv->SetValue(&self->motorList, pCon, 27.); + if(status != OKOK){ + self->listDriv->Halt(&self->motorList); + self->state = WAITSTOP; + } + return status; } /*---------------------------------------------------------------- GetValue is supposed to read a motor position @@ -211,7 +217,7 @@ static int eigera2CheckStatus(void *data, SConnection *pCon){ * position after a stop. */ status = self->listDriv->CheckStatus(&self->motorList,pCon); - if(status == HWFault || status == HWIdle){ + if(status == HWIdle){ SCWrite(pCon,"WARNING: driving slits into position after stop", eWarning); self->state = WAITSLIT; self->a2Target = eigera2GetValue(data,pCon); @@ -222,10 +228,12 @@ static int eigera2CheckStatus(void *data, SConnection *pCon){ self->listDriv->SetValue(&self->motorList, pCon, 27.); return HWBusy; } - return status; + return HWBusy; } return 1; } +extern int MOLIEigerStatus(void *data, SConnection * pCon); /* motorlist.c */ + /*---------------------------------------------------------------- returns NULL on failure, a new datastructure else ------------------------------------------------------------------*/ @@ -246,6 +254,7 @@ static eigera2 eigera2MakeObject(){ } self->motorList = LLDcreate(sizeof(MotControl)); self->listDriv = makeMotListInterface(); + self->listDriv->CheckStatus = MOLIEigerStatus; pDriv = FindDrivable(pServ->pSics,A2); assert(pDriv != NULL); @@ -451,6 +460,12 @@ int DrivableAction(SConnection * pCon, SicsInterp * pSics, void *pData, return 1; } } + if(strcmp(argv[1],"reset") == 0){ + selfe = (eigera2)pData; + selfe->state = IDLE; + SCSendOK(pCon); + return 1; + } } pDum = (pDummy)pData; pDriv = (pIDrivable) pDum->pDescriptor->GetInterface(pDum,DRIVEID); diff --git a/polterwrite.c b/polterwrite.c index d0509ec..81ac028 100644 --- a/polterwrite.c +++ b/polterwrite.c @@ -140,7 +140,7 @@ static void writeChopper(NXhandle hfil, NXdict hdict, SConnection * pCon) node = FindHdbNode(NULL,"/sics/choco/chopper/nspee", NULL); if(node != NULL){ - fVal = (float)node->value.v.doubleValue; + fVal = atof(node->value.v.text); NXDputalias(hfil,hdict,"crottarget",&fVal); } }