bugfixes in drivers
This commit is contained in:
85
ipsdriv.c
85
ipsdriv.c
@ -46,6 +46,9 @@ typedef struct {
|
||||
float perslimit; /* field limit for activating persistent mode workaround (Tesla) */
|
||||
float voltage; /* voltage */
|
||||
float measured; /* measured current */
|
||||
float inductance; /* induction (read only on startup) */
|
||||
float ampRamp; /* ramp in amps (read only on startup) */
|
||||
char *startScript; /* script to be called on startup */
|
||||
int persmode; /* 0: delayed persistant mode, 1: go to persistant mode, 2: leave switch on */
|
||||
int persdelay; /* wait time for delayed persistant mode */
|
||||
int perswitch; /* state of switch */
|
||||
@ -234,6 +237,24 @@ void IpsParDef(void *object)
|
||||
ParSave(1);
|
||||
ParFloat(&drv->lastfield, PAR_NAN);
|
||||
|
||||
ParName("ampRamp");
|
||||
ParFmt("%g");
|
||||
ParTail("A");
|
||||
ParList("");
|
||||
ParFloat(&drv->ampRamp, 0.0);
|
||||
|
||||
ParName("inductance");
|
||||
ParFmt("%g");
|
||||
ParTail("Henry");
|
||||
ParList("");
|
||||
ParFloat(&drv->inductance, 0.0);
|
||||
|
||||
ParName("startScript");
|
||||
ParAccess(usUser);
|
||||
ParList("");
|
||||
ParSave(1);
|
||||
ParStr(&drv->startScript, "0");
|
||||
|
||||
ParName("confirm");
|
||||
ParCmd(IpsConfirm, NULL);
|
||||
|
||||
@ -519,7 +540,10 @@ static long IpsStart(long pc, void *object)
|
||||
{
|
||||
Ips *drv = ParCast(&ipsClass, object);
|
||||
EaseBase *eab = object;
|
||||
|
||||
float value;
|
||||
Tcl_Interp *pTcl = NULL;
|
||||
int iRet;
|
||||
|
||||
switch (pc) {
|
||||
default: /* FSM BEGIN ****************************** */
|
||||
EaseWrite(eab, "V");
|
||||
@ -532,7 +556,7 @@ static long IpsStart(long pc, void *object)
|
||||
} else {
|
||||
snprintf(eab->msg, sizeof eab->msg,
|
||||
"unknown power supply version: %s", eab->version);
|
||||
ParPrintf(drv, eError, "ERROR: %s", eab->msg);
|
||||
ParPrintf(drv, eLogError, "ERROR: %s", eab->msg);
|
||||
EaseStop(eab);
|
||||
goto quit;
|
||||
}
|
||||
@ -547,7 +571,64 @@ static long IpsStart(long pc, void *object)
|
||||
return __LINE__;
|
||||
case __LINE__: /**********************************/
|
||||
drv->d.targetValue = drv->persfield;
|
||||
|
||||
if (eab->syntax == 0) goto quit;
|
||||
|
||||
EaseWrite(eab, "R24");
|
||||
return __LINE__;
|
||||
case __LINE__:
|
||||
drv->inductance = OxiGet(eab, 1, NULL, 0.0);
|
||||
|
||||
if (drv->ramp == 0) {
|
||||
goto ramp_read;
|
||||
}
|
||||
|
||||
EaseWrite(eab, "R9");
|
||||
return __LINE__;
|
||||
case __LINE__:
|
||||
value = OxiGet(eab, 3, NULL, drv->ramp);
|
||||
if (fabs(value - drv->ramp) == 0) goto ramp_ok;
|
||||
|
||||
EaseWrite(eab, "C3");
|
||||
drv->remote = 1; /* remote state */
|
||||
return __LINE__;
|
||||
case __LINE__: /**********************************/
|
||||
|
||||
OxiSet(eab, "T", drv->ramp, 3);
|
||||
return __LINE__;
|
||||
case __LINE__: /**********************************/
|
||||
|
||||
EaseWrite(eab, "C0");
|
||||
drv->remote = 0; /* local state */
|
||||
return __LINE__;
|
||||
case __LINE__: /**********************************/
|
||||
|
||||
ramp_read:
|
||||
EaseWrite(eab, "R9");
|
||||
return __LINE__;
|
||||
case __LINE__:
|
||||
drv->ramp = OxiGet(eab, 3, NULL, drv->ramp);
|
||||
|
||||
ramp_ok:
|
||||
|
||||
EaseWrite(eab, "R6");
|
||||
return __LINE__;
|
||||
case __LINE__:
|
||||
drv->ampRamp = OxiGet(eab, 1, NULL, 0.0);
|
||||
|
||||
if (drv->startScript && drv->startScript[0] != '\0'
|
||||
&& 0 != strcmp(drv->startScript, "0")) {
|
||||
pTcl = InterpGetTcl(pServ->pSics);
|
||||
iRet = Tcl_Eval(pTcl, drv->startScript);
|
||||
if (iRet != TCL_OK) {
|
||||
snprintf(eab->msg, sizeof eab->msg, "%s", pTcl->result);
|
||||
ParPrintf(drv, eLogError, "ERROR: %s", eab->msg);
|
||||
EaseStop(eab);
|
||||
goto quit;
|
||||
}
|
||||
eab->msg[0]='\0';
|
||||
}
|
||||
|
||||
quit:
|
||||
return 0;
|
||||
} /* FSM END ******************************************* */
|
||||
|
Reference in New Issue
Block a user