- added external mode (for wiggle script)

This commit is contained in:
zolliker
2013-06-07 06:43:10 +00:00
parent d2fdcd8819
commit 0217b1d14c

View File

@ -58,6 +58,10 @@ typedef struct {
int perswait; /* wait time for persistent mode workaround (sec) */
int heaterFault;
int trainMode; /* 0/1 read back for train mode, 2/3 command for trainMode */
int external; /* 0: normal,
1: go to external (script controlled) mode
2: external mode
3: go back to internal mode */
DoThis dothis;
char *fmt; /* fmt for field */
int force; /* force = 2: put heater switch even when stored field does not match */
@ -264,6 +268,12 @@ void IpsParDef(void *object)
ParList(0);
ParInt(&drv->trainMode, PAR_NAN);
ParName("external");
ParAccess(usUser);
ParEnum(onOff);
ParList(0);
ParInt(&drv->external, 0);
ParName("startScript");
ParAccess(usUser);
ParList("");
@ -407,6 +417,19 @@ static long IpsRead(long pc, void *object)
eab->state = EASE_idle;
}
EasePchk(drv);
if (drv->external == 2) return 0; /* external mode */
if (drv->external == 3) { /* switch back to internal */
drv->external = 0;
goto localLocked;
}
if (drv->external != 1) goto getstatus;
EaseWrite(eab, "C3");
return __LINE__;
case __LINE__: /**********************************/
drv->external = 2;
return 0;
getstatus:
EaseWrite(eab, "X");
return __LINE__;
case __LINE__: /**********************************/
@ -733,7 +756,7 @@ static long IpsChangeField(long pc, void *object)
if (drv->lastfield == PAR_NAN) {
drv->lastfield = drv->persfield;
}
if (fabs(drv->d.targetValue - drv->lastfield) < 1e-5) {
if (fabs(drv->d.targetValue - drv->lastfield) < 0.5e-5) {
ParPrintf(drv, -1, "IPS: we are already at field %f",
drv->lastfield);
if (drv->persmode == 1) {
@ -745,9 +768,26 @@ static long IpsChangeField(long pc, void *object)
goto finish;
}
}
if (fabs(drv->current - drv->lastfield) < 1e-5) {
goto switch_on;
if (fabs(drv->current - drv->lastfield) >= 1.0e-5) {
goto ramp2setp;
}
if (drv->perswitch)
goto wait_open;
if (drv->force == 2) {
EaseWrite(eab, "H2");
} else {
EaseWrite(eab, "H1");
}
drv->force = 0;
return __LINE__;
case __LINE__: /**********************************/
if (strcmp(drv->d.b.ans, "H") == 0) {
goto switched_on;
}
ParPrintf(drv, -1, "IPS: switching heater on failed, try again");
ramp2setp:
OxiSet(eab, "J", drv->lastfield, 3); /* set point */
return __LINE__;
case __LINE__: /**********************************/
@ -794,6 +834,12 @@ static long IpsChangeField(long pc, void *object)
drv->force = 0;
return __LINE__;
case __LINE__: /**********************************/
if (strcmp(drv->d.b.ans, "?H1") == 0) {
ParPrintf(drv, eError, "IPS: switching heater on failed");
eab->errCode = EASE_FAULT;
goto off_finish;
}
switched_on:
drv->perswitch = 1;
drv->dothis = NOTHING;
drv->swtim = time(NULL);