From 661df3916658b199e4fa632e860321b2bb75e8ed Mon Sep 17 00:00:00 2001 From: zolliker Date: Fri, 18 Jan 2008 07:35:34 +0000 Subject: [PATCH] - various enhancements --- arrobj.c | 2 +- ease.c | 1 + ipsdriv.c | 8 +++ pardef.c | 49 ++++++++----- tasscan.c | 2 +- tecs/coc_client.c | 2 +- tecs/inp/g26550.inp | 2 + tecs/inp/x14667.inp | 2 + tecs/inp/x22644.inp | 171 ++++++++++++++++++++++---------------------- tecs/six.c | 3 +- tecs/tecs.c | 41 +++++++---- 11 files changed, 165 insertions(+), 118 deletions(-) diff --git a/arrobj.c b/arrobj.c index 9964f20..88a3960 100644 --- a/arrobj.c +++ b/arrobj.c @@ -201,7 +201,7 @@ static int ArrayMakeItem(void *object, void *delete, int argc, char *argv[]) { if (item->unit) item->unit = strdup(item->unit); if (item->value) item->value = strdup(item->value); ParInitPar(object, item->name); - SCparChange(SCLoad(&arr->p.conn)); + SCparChange(SCLoad(arr->p.conn)); return 1; Usage: diff --git a/ease.c b/ease.c index 414251b..367adfd 100644 --- a/ease.c +++ b/ease.c @@ -170,6 +170,7 @@ void EaseSavePars(void) { static int EaseRestart(EaseBase *eab) { int iRet; + eab->errCode = 0; if (eab->task) { FsmStop(eab->task, eab->idle); FsmRestartTask(eab->task, eab->idle); diff --git a/ipsdriv.c b/ipsdriv.c index df067d9..f0c19a0 100644 --- a/ipsdriv.c +++ b/ipsdriv.c @@ -42,6 +42,7 @@ typedef struct { int persmode; /* 0: leave switch on, 1: go to persistant mode */ int perswitch; /* state of switch */ int remote; /* 0: local, 1: remote, do not check, 2: remote, check */ + int nowait; /* 0: normal, 1: drive finishes immediately, ramp in background */ int heaterFault; char *fmt; /* fmt for field */ int force; /* force = 2: put heater switch even when stored field does not match */ @@ -125,6 +126,9 @@ void IpsParDef(void *object) { ParName("perswitch"); ParEnum(onOff); ParList(0); ParInt(&drv->perswitch, PAR_NAN); + ParName("nowait"); ParAccess(usUser); ParEnum(onOff); ParList(0); + ParInt(&drv->nowait, 0); + ParName("maxlimit"); ParSave(1); ParFloat(&drv->maxlimit, 0.0); ParName("limit"); ParAccess(usUser); ParFmt(drv->fmt); ParTail("Tesla"); @@ -302,6 +306,10 @@ static long IpsChangeField(long pc, void *object) { switch (pc) { default: /* FSM BEGIN *******************************/ EaseSetUpdate(eab, EASE_RUN, 0); + if (drv->nowait) { + drv->d.hwstate = HWIdle; + drv->d.eMode = EVMonitor; /* finish drive, continue in background */ + } EaseWrite(eab, "C3"); drv->remote = 1; return __LINE__; case __LINE__: /**********************************/ diff --git a/pardef.c b/pardef.c index cba9917..3e5a043 100644 --- a/pardef.c +++ b/pardef.c @@ -128,7 +128,7 @@ int ParPrintf(void *object, int iOut, const char *fmt, ...) { if (ctx && pobj == ctx->obj && ctx->con) { con = ctx->con; } else { - con = SCLoad(&pobj->conn); + con = SCLoad(pobj->conn); } } else if (ctx) { con = ctx->con; @@ -278,17 +278,27 @@ int ParLog(void *object) { ParData *o = ParCheck(&parClass, object); int next; + if (o->desc == NULL) { + free(o); + return 0; + } + if (o->logPending == 2) { + o->logPending = 0; + return 0; + } ParBegin(); ctx->now = time(NULL); next = ctx->now - (o->logTime / o->period + 1) * o->period; - if (next >= 0) { - showTime = 1; - ParDo(0, o, PAR_LOG, NULL); - o->logTime = ctx->now; - o->logPending = 0; + if (next < 0) { + ParEnd(); + return 1; } + showTime = 1; + ParDo(0, o, PAR_LOG, NULL); + o->logTime = ctx->now; + o->logPending = 0; ParEnd(); - return next; + return 0; } /*--------------------------------------------------------------------------*/ void ParLogForced(void *object) { @@ -300,7 +310,9 @@ void ParLogForced(void *object) { showTime = 1; ParDo(0, o, PAR_LOG, NULL); o->logTime = ctx->now; - o->logPending = 0; + if (o->logPending) { + o->logPending = 2; /* tell ParLog that we are done already, but task is still pending */ + } ParEnd(); } /*-------------------------------------------------------------------------*/ @@ -382,7 +394,7 @@ void ParSaveConn(void *object, SConnection *con) { rights = SCGetRights(con); if (rights >= usMugger && rights <= usUser && con->pSock != NULL) { - SCSave(&o->conn, con); + o->conn = SCSave(con, o->conn); } } /*----------------------------------------------------------------------------*/ @@ -457,6 +469,10 @@ static int ParExecute(SConnection *con, SicsInterp *sics, void *object, int argc ctx->enumText = 1; ParDo(con, o, PAR_SHOW, argv[2]); } + } else if (strcmp(argv[1],"endinit") == 0) { + initObj = NULL; + ParEnd(); + return 1; } else { if (strcmp(argv[1], "=") == 0) { ctx->argc = argc - 2; @@ -1198,13 +1214,7 @@ void *ParObject(void) { return ctx->obj; } /*----------------------------------------------------------------------------*/ -static int ParEndInit(void *object, void *arg, int argc, char *argv[]) { - initObj = NULL; - return 1; -} -/*----------------------------------------------------------------------------*/ void ParStdDef(void) { - ParName("endinit"); ParCmd(ParEndInit, NULL); ParName("verbose"); ParAccess(usUser); ParSave(0); ParLogAs(NULL); ParInt(&ctx->obj->verbose, 1); ParName("driver"); ParLogAs(NULL); ParStr(&ctx->obj->desc->name, NULL); ParName("creationCmd"); ParLogAs(NULL); ParStr(&ctx->obj->creationCmd, NULL); @@ -1238,6 +1248,7 @@ void ParKill(void *object) { if (o->creationCmd) free(o->creationCmd); if (o->pCall) DeleteCallBackInterface(o->pCall); if (o->desc) DeleteDescriptor(o->desc); + if (o->conn) SCStoreFree(o->conn); p = o->infoList; while (p) { q = p->next; @@ -1246,7 +1257,11 @@ void ParKill(void *object) { free(p); p = q; } - free(o); + if (o->logPending) { /* will be free in scheduled ParLog function */ + o->desc = NULL; + } else { + free(o); + } ParEnd(); if (ctx == NULL && pServ->pSics->iDeleting) { /* finish, no more contexts nested -> free all of them */ while (freeContexts) { @@ -1300,6 +1315,8 @@ void *ParMake(SConnection *con, char *name, ParClass *class, ParDef pardef, o->period = 5; o->infoList = NULL; o->verbose = 0; + o->logPending = 0; + o->conn = NULL; ParSaveConn(o, con); o->pardef = pardef; ParBegin(); diff --git a/tasscan.c b/tasscan.c index b539295..64953ab 100644 --- a/tasscan.c +++ b/tasscan.c @@ -428,7 +428,7 @@ static int TASHeader(pScanData self) fVal = pDrive->GetValue(pDum,self->pCon); pTem = (pEVControl)pCom->pData; EVCGetPar(pTem,"target",&fVal2); - fprintf(self->fd,"PARAM: TT=%8.4f, RT=%8.4f\n",fVal, fVal2); + fprintf(self->fd,"PARAM: TEM=%8.4f, RT=%8.4f\n",fVal, fVal2); } } diff --git a/tecs/coc_client.c b/tecs/coc_client.c index c819deb..ddf8a80 100644 --- a/tecs/coc_client.c +++ b/tecs/coc_client.c @@ -494,7 +494,7 @@ int CocShowLog(CocConn *conn, char *loglist, int start, int lines) { void CocCloseClient(CocConn *conn) { assert(conn!=NULL); - close(conn->fd); + if (conn->fd >= 0) close(conn->fd); conn->fd=-1; } diff --git a/tecs/inp/g26550.inp b/tecs/inp/g26550.inp index 901a4af..2816ab2 100644 --- a/tecs/inp/g26550.inp +++ b/tecs/inp/g26550.inp @@ -2,6 +2,8 @@ sens=g26550 unit=Ohm ! sensor format (mV,V,Ohm), log formats are choosen automatically !tlim=325 ! setpoint limit (automatic if omitted) type=Ge ! sensor type (Special,Si,GaAlAs,Pt250,Pt500,Pt2500,RhFe,C,Cernox,RuOx,Ge) (special if omitted) +range=60000 +form=loglog curv ! curve (sensor,temp/K) follows, must be ordered, but can be increasing or decreasing 51675.31367 1.26557 35429.70923 1.40134 diff --git a/tecs/inp/x14667.inp b/tecs/inp/x14667.inp index e349552..82854b7 100644 --- a/tecs/inp/x14667.inp +++ b/tecs/inp/x14667.inp @@ -5,6 +5,7 @@ type=cernox ! sensor type (Special,Si,GaAlAs,Pt250,Pt500,Pt2500,RhFe,C,Cerno !excit=300uA ! (off,30nA,100nA,300nA,1uA,3uA,10uA,30uA,100uA,300uA,1mA,10mV,1mV) (if omitted: default from sensor type) !range=0 ! range in sensor units (if rang=0: determine range from table, if omitted: default from sensor type) curv ! curve (sensor,temp/K) follows, must be ordered, but can be increasing or decreasing +27000 1.1 15213.49 1.407016 13018.43 1.5035 11293.78 1.601262 @@ -50,4 +51,5 @@ curv ! curve (sensor,temp/K) follows, must be ordered, but can be inc 57.69399 273.2733 57.65295 273.5096 53.45707 300.0828 +49 335 diff --git a/tecs/inp/x22644.inp b/tecs/inp/x22644.inp index c9649da..275db6d 100644 --- a/tecs/inp/x22644.inp +++ b/tecs/inp/x22644.inp @@ -1,92 +1,91 @@ -sens=x22644 +sens=x22644k unit=Ohm ! sensor format (mV,V,Ohm), log formats are choosen automatically !tlim=325 ! setpoint limit (automatic if omitted) type=cernox ! sensor type (Special,Si,GaAlAs,Pt250,Pt500,Pt2500,RhFe,C,Cernox,RuOx,Ge) (special if omitted) !excit=300uA ! (off,30nA,100nA,300nA,1uA,3uA,10uA,30uA,100uA,300uA,1mA,10mV,1mV) (if omitted: default from sensor type) !range=0 ! range in sensor units (if rang=0: determine range from table, if omitted: default from sensor type) curv ! curve (sensor,temp/K) follows, must be ordered, but can be increasing or decreasing -16007.79518 1.200721786 -13255.8808 1.298891069 -11205.15286 1.39943304 -8443.928222 1.599937175 -6702.327773 1.800442288 -5534.122213 2.00019607 -4704.584196 2.199969718 -4084.913232 2.400603038 -3610.312949 2.600633851 -3230.256645 2.802896079 -2936.389321 2.998094443 -2686.653219 3.198715722 -2478.1989 3.399484728 -2300.553298 3.602485184 -2151.36877 3.800490872 -2022.540635 3.998439887 -1908.79865 4.197156641 -1709.313903 4.621681363 -1557.368026 5.030523733 -1406.421873 5.540281439 -1243.706071 6.25898771 -1105.603956 7.076289652 -977.4489794 8.098257051 -880.4428612 9.126725378 -804.8003471 10.14989046 -743.7218062 11.1730348 -693.7309884 12.18383727 -651.4548886 13.19332605 -615.7657565 14.18572326 -584.5828244 15.17662749 -557.2403338 16.16073706 -532.9508371 17.14074973 -511.1072589 18.11815111 -491.3416812 19.09726974 -473.3439969 20.07459081 -455.2101691 21.15478955 -431.4309748 22.73367042 -410.1806618 24.3324661 -390.407091 26.00456745 -373.2423216 27.6242651 -357.4650865 29.26937996 -341.3901179 31.1270676 -324.8832171 33.25128091 -304.5451078 36.23921994 -287.1316191 39.19190152 -271.3027429 42.22413357 -257.4885798 45.23979471 -245.297921 48.23143543 -237.8548894 50.22289595 -221.3051609 55.19735291 -207.0981627 60.20938313 -194.8252865 65.20351886 -184.1071589 70.19674071 -174.6169591 75.18080073 -166.126924 80.17225392 -158.5229665 85.16939558 -151.626774 90.16147891 -145.4056367 95.15586553 -139.6765896 100.1540934 -129.6293513 110.1362537 -120.9858687 120.1370202 -113.5180198 130.13073 -106.9678656 140.1252385 -101.1878636 150.1234354 -96.03408894 160.1165839 -91.42205476 170.1168663 -87.26057763 180.1290119 -83.5052218 190.1274068 -80.09071577 200.1278156 -76.96422711 210.1345051 -74.10488591 220.1302898 -71.49685195 230.1260865 -69.07286887 240.1285934 -66.84323633 250.1146862 -64.77194872 260.1210378 -62.85425529 270.1122296 -61.06392683 280.1125128 -59.42108067 289.9881766 -57.86899725 299.992933 -56.40163103 310.0918565 -55.70314445 315.0849843 -55.03104128 320.106081 -54.25379641 326.0894698 -53.76781249 329.9611435 - +15490.92284 1.200721786 +12954.34936 1.298891069 +11076.20151 1.39943304 +8520.068684 1.599937175 +6861.930851 1.800442288 +5720.174664 2.00019607 +4893.450319 2.199969718 +4267.228514 2.400603038 +3782.811454 2.600633851 +3392.064692 2.802896079 +3088.314838 2.998094443 +2829.143213 3.198715722 +2612.128987 3.399484728 +2426.727308 3.602485184 +2270.720446 3.800490872 +2135.786463 3.998439887 +2016.497011 4.197156641 +1806.950796 4.621681363 +1647.078313 5.030523733 +1488.052584 5.540281439 +1316.419467 6.25898771 +1170.596974 7.076289652 +1035.166504 8.098257051 +932.58957 9.126725378 +852.5687804 10.14989046 +787.9348812 11.1730348 +735.021783 12.18383727 +690.2662946 13.19332605 +652.4786656 14.18572326 +619.4583612 15.17662749 +590.5019897 16.16073706 +564.7767246 17.14074973 +541.6403519 18.11815111 +520.7037071 19.09726974 +501.6387006 20.07459081 +482.4285499 21.15478955 +457.2366045 22.73367042 +434.7225473 24.3324661 +413.7720569 26.00456745 +395.5849007 27.6242651 +378.8673435 29.26937996 +361.8337601 31.1270676 +344.3419371 33.25128091 +322.7895815 36.23921994 +304.3358536 39.19190152 +287.5609455 42.22413357 +272.9208287 45.23979471 +260.0010408 48.23143543 +252.1127299 50.22289595 +234.5726345 55.19735291 +219.515172 60.20938313 +206.5074101 65.20351886 +195.1473491 70.19674071 +185.0886532 75.18080073 +176.0899553 80.17225392 +168.0303614 85.16939558 +160.7208948 90.16147891 +154.1269009 95.15586553 +148.0544602 100.1540934 +137.4049343 110.1362537 +128.24325 120.1370202 +120.3276383 130.13073 +113.3847137 140.1252385 +107.2580994 150.1234354 +101.7952486 160.1165839 +96.90661397 170.1168663 +92.49554787 180.1290119 +88.51495284 190.1274068 +84.89564499 200.1278156 +81.58162485 210.1345051 +78.55077213 220.1302898 +75.7862976 230.1260865 +73.21691146 240.1285934 +70.85353186 250.1146862 +68.6579939 260.1210378 +66.6252623 270.1122296 +64.72753475 280.1125128 +62.9861357 289.9881766 +61.34094329 299.992933 +59.78554947 310.0918565 +59.04516028 315.0849843 +58.33273711 320.106081 +57.5088645 326.0894698 +56.9937258 329.9611435 diff --git a/tecs/six.c b/tecs/six.c index 92d7e3a..133e0ba 100644 --- a/tecs/six.c +++ b/tecs/six.c @@ -99,7 +99,8 @@ void Usage(int cmds_only) { " -a or a ask always for username/password, forget passwords\n" " -c or c use background color instead of # and |\n" " -s or s simulation mode (on some instruments)\n" - " connect to a server on a different host\n" + " connect to the server for instr\n" + " -h connect to a server on a different host\n" " -p connect to a server on a different port\n" " -n do only a minimal login (no check of instrument)\n" " no option login with default privilege\n" diff --git a/tecs/tecs.c b/tecs/tecs.c index 8a68275..cf48b3f 100644 --- a/tecs/tecs.c +++ b/tecs/tecs.c @@ -58,18 +58,19 @@ typedef struct { char typ; } SensorT; -enum Sensors { A, B, C, D, A1, A2, A3, A4, N_SENSORS }; +enum Sensors { A, B, C, D, A0, A1, A2, A3, A4, N_SENSORS }; static SensorT sensA={"A"}, sensB={"B"}, sensC={"C"}, sensD={"D"}, + sensA0={"A0", DATA_UNDEF}, sensA1={"A1", DATA_UNDEF}, sensA2={"A2", DATA_UNDEF}, sensA3={"A3", DATA_UNDEF}, sensA4={"A4", DATA_UNDEF}, - *sensors[N_SENSORS]={&sensA, &sensB, &sensC, &sensD, &sensA1, &sensA2, &sensA3, &sensA4 }, + *sensors[N_SENSORS]={&sensA, &sensB, &sensC, &sensD, &sensA0, &sensA1, &sensA2, &sensA3, &sensA4 }, *ctlSens=NULL, /* control sensor */ *heliumSens=NULL, *auxSens=NULL, @@ -672,15 +673,15 @@ again: } if (sensA.type[0]>'0' && sensA.type[0]<='4') { nScan=sensA.type[0]-'0'; - for (i=4;i<4+nScan;i++) { + for (i=5;i<5+nScan;i++) { s=sensors[i]; s->present=-1; s->band=10; if (s->scale==0.0) s->scale=1.0; - s->typ='1'+i-4; + s->typ='1'+i-5; } sensA.type[0]='\0'; - for (i=4+nScan; it=DATA_UNDEF; sensors[i]->present=0; } @@ -879,7 +880,7 @@ void LogMinMax(int new) { } else if (nScan==0) { return; } - for (i=4; i<4+nScan; i++) { + for (i=5; i<5+nScan; i++) { s1=sensors[i]; if (s1->t!=DATA_UNDEF) { sprintf(buf1, " T%c %.5g", s1->ch[1], s1->t); @@ -1009,7 +1010,7 @@ int ReadTemp(void) { if (nScan>0) { while (1) { /* read until a non-selected channel found */ if (iScan>=nScan) iScan=0; - s=sensors[iScan+4]; + s=sensors[iScan+5]; if (s->present<1) break; str_copy(chan, s->ch); ERR_P(LscCmd(ser, "KRDG?[chan]>fbuf;DIOST?>,out1")); @@ -1615,7 +1616,7 @@ int ConfigAlarms(float genLimit) { ERR_P(LscCmd(ser, "RELAY 1:1;BEEP:0")); relay=0; k=0; - for (i=0;i<4+nScan;i++) { + for (i=0;i<5+nScan;i++) { s=sensors[i]; str_copy(buf1, s->ch); if (s->customAlarm==0 && genLimit>0.0) s->alarm=genLimit; @@ -1675,7 +1676,7 @@ void AssignTypes(void) { auxSens=NULL; testSens=NULL; test2Sens=NULL; - for (i=0; i<4+nScan; i++) { + for (i=0; i<5+nScan; i++) { s=sensors[i]; if (s->present==1) { typ=s->typ; @@ -1736,7 +1737,7 @@ int Settings(void) { } else { ERR_P(LscCmd(ser, "PID [loop],[prop],[integ],[deriv]")); } - for (i=0; i<4+nScan; i++) { + for (i=0; i<5+nScan; i++) { s=sensors[i]; if (i<4) { plug=plugs[i/2]; @@ -1796,7 +1797,7 @@ int Settings(void) { DisplayFmt(auxSens, fields, &k); if (nScan>0) { i=0; - while (i