From d3b8f38ced33f4ca4512701ab992ab5016b706f8 Mon Sep 17 00:00:00 2001 From: cvs Date: Thu, 21 Dec 2000 07:55:04 +0000 Subject: [PATCH] - fixed a bug in pause handling of environment controller. - added code to triple axis MAD emulation layer --- danu.dat | 2 +- devexec.c | 2 + evcontroller.c | 6 +- motor.c | 5 + nxsans.c | 6 +- sicsstat.tcl | 12 +- sicsstatus.tcl | 4 +- simcter.c | 2 +- sinqhmdriv.c | 13 ++ tas.h | 4 +- tas.w | 6 +- tascom.tcl | 313 ++++++++++++++++++++++++++++++++++++++++++++++++- tasinit.c | 5 +- task.c | 19 +++ tasscan.c | 24 +++- 15 files changed, 399 insertions(+), 24 deletions(-) diff --git a/danu.dat b/danu.dat index 4db577fa..992f0ca2 100644 --- a/danu.dat +++ b/danu.dat @@ -1,3 +1,3 @@ - 7476 + 7634 NEVER, EVER modify or delete this file You'll risk eternal damnation and a reincarnation as a cockroach!|n \ No newline at end of file diff --git a/devexec.c b/devexec.c index a5bcc2f9..d9165069 100644 --- a/devexec.c +++ b/devexec.c @@ -412,6 +412,7 @@ SetStatus(eOutOfBeam); if(SCGetInterrupt(self->pOwner) != eContinue) { + SetStatus(eEager); self->iStatus = DEVINT; return -1; } @@ -420,6 +421,7 @@ SetStatus(ePaused); if(SCGetInterrupt(self->pOwner) != eContinue) { + ContinueExecution(self); self->iStatus = DEVINT; return -1; } diff --git a/evcontroller.c b/evcontroller.c index 8b9b20f5..410e1f0a 100644 --- a/evcontroller.c +++ b/evcontroller.c @@ -62,6 +62,7 @@ #include "el755driv.h" #include "tecsdriv.h" #include "chadapter.h" +#include "status.h" /*--------------------- Functions needed to implement interfaces -----------*/ static long EVIDrive(void *pData, SConnection *pCon, float fVal) { @@ -339,7 +340,6 @@ self = (pEVControl)pData; assert(self); - self->pDriv->GetValue(self->pDriv,&fPos); sprintf(pBueffel,"WARNING: %s is out of range by %f",self->pName, self->fTarget - fPos); @@ -367,14 +367,14 @@ /* wait till OK */ iRet = 0; - while(iRet == 0) + while(iRet == 0 && IsCounting(pExe) ) { SicsWait(5); iRet = self->pEnvir->IsInTolerance(self); - } /* OK now, continue */ + SetStatus(eEager); ContinueExecution(pExe); return 1; } diff --git a/motor.c b/motor.c index 935c295b..98120d17 100644 --- a/motor.c +++ b/motor.c @@ -505,6 +505,11 @@ extern void KillPiPiezo(void *pData); *fVal = self->fPosition; return 1; } + else if(strcmp(name,"target") == 0) + { + *fVal = self->fTarget; + return 1; + } else { return 0; diff --git a/nxsans.c b/nxsans.c index e9a9b837..6c36d942 100644 --- a/nxsans.c +++ b/nxsans.c @@ -201,7 +201,7 @@ int32 iAxis[128]; int i, iRet; long lVal; - HistInt lData[16384]; + HistInt lData[65536]; CommandList *pCom = NULL; pHistMem self = NULL; CounterMode eMode; @@ -555,9 +555,9 @@ NXDputalias(Nfil,pDict,"ddmo",&iVal); fVal = GetHistCountTime(self,pCon); NXDputalias(Nfil,pDict,"ddtime",&fVal); - GetHistogram(self,pCon,0,0,16384,lData,16384*sizeof(HistInt)); + GetHistogram(self,pCon,0,0,65536,lData,65536*sizeof(HistInt)); NXDputalias(Nfil,pDict,"ddcounts",lData); - for(i = 0; i < 128; i++) + for(i = 0; i < 256; i++) { iAxis[i] = i; } diff --git a/sicsstat.tcl b/sicsstat.tcl index 64dc8b7b..66d44538 100644 --- a/sicsstat.tcl +++ b/sicsstat.tcl @@ -98,7 +98,7 @@ local Berty Chimney local setAccess 2 output a1,a2,a3,a4 output setAccess 2 -lastcommand sc a4 10 da4 .1 np 7 ti 8 +lastcommand sc qh 0 0 2 3 dqh 0.01 0.0 0.01 .1 lastcommand setAccess 2 user Billy Looser user setAccess 2 @@ -108,6 +108,8 @@ f2 0 f2 setAccess 2 f1 0 f1 setAccess 2 +swunit 0 +swunit setAccess 2 hz 0.000000 hz setAccess 2 hy 0.000000 @@ -124,11 +126,11 @@ if2v 0.000000 if2v setAccess 2 if1v 0.000000 if1v setAccess 2 -mn 2000 +mn 700 mn setAccess 2 -ti 8.000000 +ti 2.000000 ti setAccess 2 -np 7 +np 9 np setAccess 2 fx 2 fx setAccess 2 @@ -183,7 +185,7 @@ bs setAccess 2 as 5.000000 as setAccess 2 # Counter counter -counter SetPreset 8.000000 +counter SetPreset 2.000000 counter SetMode Timer # Motor agl agl SoftZero -0.490000 diff --git a/sicsstatus.tcl b/sicsstatus.tcl index 28dfae3e..550a0ef6 100644 --- a/sicsstatus.tcl +++ b/sicsstatus.tcl @@ -38,7 +38,7 @@ det1zerox 128. det1zerox setAccess 1 mono2theta 36.77 mono2theta setAccess 1 -monodescription unknownit crystal +monodescription unknownit crystal monodescription setAccess 1 # Motor om om SoftZero 0.000000 @@ -407,5 +407,5 @@ sample DanielOxid sample setAccess 2 title TopsiTupsiTapsi title setAccess 2 -starttime UNKNOWN +starttime 2000-12-15 15:44:22 starttime setAccess 2 diff --git a/simcter.c b/simcter.c index ffdcfc5d..6b7950a4 100644 --- a/simcter.c +++ b/simcter.c @@ -50,7 +50,7 @@ A SIMCOUNTER HAS a BUILT IN FAILURE RATE OF 10% FOR TESTING ERROR HANDLING CODE. A negative failure rate means absolute success. */ -#define FAILRATE -0.05 +#define FAILRATE 0.05 /*----------------------------------------------------------------------------*/ static float SimRandom(void) { diff --git a/sinqhmdriv.c b/sinqhmdriv.c index 8a6a8398..5afd4aaa 100644 --- a/sinqhmdriv.c +++ b/sinqhmdriv.c @@ -313,6 +313,19 @@ pInternal->iLastHMError = status; return HWFault; } + + /* + When SICS was interrupted while the measurement was paused + the inhibit flag may still be set. We clear this here in order to + fix this bug. + */ + status = SINQHMContinueDAQ(pInternal->pMaster); + if( (status < 0) && (status != DAQ_INHIBIT) ) + { + pInternal->iLastHMError = status; + return HWFault; + } + /* start the El737 counter */ pCountInt = pInternal->pCounter->pDes->GetInterface(pInternal->pCounter, diff --git a/tas.h b/tas.h index f7264c77..1e2a6efc 100644 --- a/tas.h +++ b/tas.h @@ -105,8 +105,9 @@ #define BET4 89 #define OUT 90 #define LOC 91 +#define SWUNIT 92 -#define MAXPAR 92 +#define MAXPAR 93 #define MAXADD 20 /* --------------------- data structure -------------------------------*/ @@ -121,6 +122,7 @@ typedef struct { int addType[MAXADD]; int addCount; int iFileNO; + int iFast; }TASdata, *pTASdata; diff --git a/tas.w b/tas.w index 518ce2fa..4590f6bd 100644 --- a/tas.w +++ b/tas.w @@ -44,6 +44,7 @@ typedef struct { int addType[MAXADD]; int addCount; int iFileNO; + int iFast; }TASdata, *pTASdata; @} \begin{description} @@ -61,6 +62,8 @@ such variables. variables. This can be 0 for simple variables or 1 for a motor. \item[addCount] is the number of additional output variables. \item[iFileNO] is the number of the current data file. +\item[iFast] is a flag denoting a fast scan. In a fast scan there is +no wait for the motors to finish driving. \end{description} The constants for the parameters are defined in the header file. @@ -185,8 +188,9 @@ These are mainly the interpreter interface functions: #define BET4 89 #define OUT 90 #define LOC 91 +#define SWUNIT 92 -#define MAXPAR 92 +#define MAXPAR 93 #define MAXADD 20 /* --------------------- data structure -------------------------------*/ diff --git a/tascom.tcl b/tascom.tcl index 8a1df256..99062d31 100644 --- a/tascom.tcl +++ b/tascom.tcl @@ -26,6 +26,13 @@ if { [info exists tasinit] == 0 } { Publish lz Spy Publish lm Spy Publish ls Spy + SicsAlias lz ll Spy + Publish le Spy + Publish lt Spy + Publish li Spy + Publish log User + Publish sz User + Publish sw User } #-------------------------------------------------------------------------- @@ -666,8 +673,310 @@ proc ls args { return $output } +#--------------------------------------------------------------------------- +# le --> list energy + +proc le args { + set un [swunit] + if { $un == 1} { + append output " Energy Units Thz\n" + } else { + append output " Energy Units Mev\n" + } + append output " ================\n" + append output [format " EI KI EF%s\n" \ + " KF QH QK QL"] + set v1 [tasSplit [ei]] + set v2 [tasSplit [ki]] + set v3 [tasSplit [ef]] + set v4 [tasSplit [kf]] + set v5 [tasSplit [qh]] + set v6 [tasSplit [qk]] + set v7 [tasSplit [ql]] + set val [format " %9.4f %9.4f %9.4f %9.4f %9.4f %9.4f %9.4f \n" \ + $v1 $v2 $v3 $v4 $v5 $v6 $v7] + append output [format "POSN: %s" $val] + append output [format "TARG: %s" $val] + append output [format " EN QM\n"] + set v1 [tasSplit [en]] + set v2 [tasSplit [qm]] + set val [format " %9.4f %9.4f\n" $v1 $v2] + append output [format "POSN: %s" $val] + append output [format "TARG: %s" $val] + + return $output +} + +#----------------------------------------------------------------------- +# fmtMot formats a motors parameters in order to fit the format for +# the list targets commands + +proc fmtMot mot { + set zero [tasSplit [madZero $mot]] + set pos [tasSplit [$mot]] + set target [expr [tasSplit [eval $mot target]] + $zero] + if { [tasSplit [eval $mot fixed]] < 0} { + set fix " " + } else { + set fix "f" + } + set txt [format "%-7s%1s %7.2f %7.2f %7.2f" $mot $fix $pos $target \ + $zero] + return $txt +} +#------------------------------------------------------------------------- +# lt --> list targets + +proc lt args { + append output " Positions and Targets \n" + append output " ===================== \n" + append output [format " Posn Targ Zero %s" \ + " Posn Targ Zero\n"] + append output [format "%s | %s\n" \ + [fmtMot A1] " "] + append output [format "%s | %s\n" \ + [fmtMot A2] [fmtMot ATL]] + append output [format "%s | %s\n" \ + [fmtMot A3] [fmtMot ATU] ] + append output [format "%s | %s\n" \ + [fmtMot A4] " " ] + append output [format "%s | %s\n" \ + [fmtMot A5] [fmtMot MGL] ] + append output [format "%s | %s\n" \ + [fmtMot A6] [fmtMot SGL] ] + append output [format "%s | %s\n" \ + [fmtMot MCV] [fmtMot SGU] ] + append output [format "%s | %s\n" \ + [fmtMot SRO] " " ] + append output [format "%s | %s\n" \ + [fmtMot ACH] [fmtMot AGL] ] + append output [format "%s | %s\n" \ + [fmtMot MTL] " " ] + append output [format "%s | %s\n" \ + [fmtMot MTU] " " ] + return $output +} + +#-------------------------------------------------------------------------- +# li --> list everything + +proc li args { + clientput [lm] + clientput [ls] + clientput [lz] + clientput [lt] + clientput [le] +} + +#----------------------------------------------------------------------- +# make a new log file name for log +proc makeLog args { + set tim [sicstime] + set l [split $tim] + set l2 [split [lindex $l 1] ":"] + set nam [format "madsics-%s@%s-%s-%s.log" [lindex $l 0] \ + [lindex $l2 0] [lindex $l2 1] [lindex $l2 2]] + return $nam +} +#------------------------------------------------------------------------- +# log the logging control command + +set madlog disabled + +proc log args { + global madlog +#------ no args, just print status + if { [ llength $args] == 0 } { + if { [string compare $madlog disabled] == 0 } { + return "Logging is disabled" + } else { + return [format "Logging to %s" $madlog] + } + } +#------args, action according to keyword + set key [string tolower [lindex $args 0]] + switch $key { + new { + set madlog [makeLog] + commandlog new $madlog + } + start { + set madlog [makeLog] + commandlog new $madlog + } + close { + commandlog close + set madlog disabled + } + default { + append output "Log understands: \n" + append output "\tLog new : new logfile\n" + append output "\tLog start : start logging\n" + append output "\tLog close : stop logging\n" + return $output + } + } +} + +#-------------------------------------------------------------------------- +# sz -->setzero + +proc sz args { + global tasmot + set usage "\n Usage: \n\t sz motor newzero\n" + set line [string tolower [join $args]] + set pos 0 + set mot [varToken $line $pos] + set val [varToken $line $pos] + if { [lsearch $tasmot $mot] < 0 } { + error [format "ERROR: %s is no motor %s" $mot $usage] + } + if { [string compare [SICStype $val] NUM ] != 0 } { + error [format "ERROR: expected number, got %s %s" $val $usage] + } +#-------- output, output, output......... + append output [format "Values : Lo(hard) Lo(soft) Posn%s" \ + " Target Hi(soft) Hi(hard) Zero\n"] + set zero [tasSplit [madZero $mot]] + set loh [tasSplit [eval $mot hardlowerlim]] + set loh [expr $loh + $zero] + set los [tasSplit [eval $mot softlowerlim]] + set pos [tasSplit [eval $mot]] + set his [tasSplit [eval $mot softupperlim]] + set hih [tasSplit [eval $mot hardupperlim]] + set hih [expr $hih + $zero] + set targ [expr [tasSplit [eval $mot target]] + $zero] + append output [format \ + "%-8sOld: %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f\n" \ + $mot $loh $los $pos $targ $his $hih $zero] +#-------action + madZero $mot $val +#-------- more output + set zero [tasSplit [madZero $mot]] + set loh [tasSplit [eval $mot hardlowerlim]] + set loh [expr $loh + $zero] + set los [tasSplit [eval $mot softlowerlim]] + set pos [tasSplit [eval $mot]] + set his [tasSplit [eval $mot softupperlim]] + set hih [tasSplit [eval $mot hardupperlim]] + set hih [expr $hih + $zero] + set targ [expr [tasSplit [eval $mot target]] + $zero] + append output [format \ + " New: %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f %8.2f\n" \ + $loh $los $pos $targ $his $hih $zero] + return $output +} + +#--------------------------------------------------------------------------- +# switches and the sw command + +#-------------------------------------------------------------------------- +# powdersw deals with the powder switch + +set powder 0 + +proc powdersw args { + global powder + if { [llength $args] > 0 } { + switch [lindex $args 0] { + on { + as 6.28 + cs 6.28 + bs 6.28 + aa 90. + bb 90. + cc 90. + a3 fixed 1 + set powder 1 + return "Q now in reverse Angstroem" + } + off { + set powder 0 + a3 fixed -1 + } + flip { + if {$powder == 1 } { + return [powdersw off] + } else { + return [powdersw on] + } + } + default { + error "ERROR: syntax error, only on, off, flip allowed" + } + } + } else { + if { $powder == 1} { + return [format " %-30s : %-5s" "Powder Mode" "on"] + } else { + return [format " %-30s : %-5s" "Powder Mode" "off"] + } + } +} +#----------------------------------------------------------------------- +# mapping switches to procedures handling them + +set switches(powder) powdersw + +#------------------------------------------------------------------------ +# prsw prints switches +proc prsw args { + global switches + set l [array names switches] + foreach e $l { + append output [eval $switches($e)] + } + return $output +} + +#-------------------------------------------------------------------------- +# sw --> the switches command - - +proc sw args { + global switches + set swlist [array names switches] + set maxsw [llength $swlist] +#------- no args + if { [llength $args] <= 0 } { + clientput [prsw] + set line [sicsprompt "Switch number? : "] + while { [string length $line] > 1 } { + set ret [catch {expr $line - 1} num] + if { $ret != 0 } { + error [format "ERROR: expected number, got %s" \ + $line] + } + if {$num >= $maxsw} { + error "ERROR: switch number out of bounds" + } + if { $num < 0} { + return [prsw] + } + clientput [eval $switches([lindex $swlist $num]) flip] + clientput [prsw] + set line [sicsprompt "Switch number? "] + } + } else { +#-------- direct on command line + set line [join $args] + set pos 0 + set sw [varToken $line $pos] + set op [varToken $line $pos] + while { [string compare $sw END] != 0 } { + set ret [catch {expr $sw - 1} num] + if { $ret != 0 } { + error [format "ERROR: expected number, got %s" \ + $sw] + } + if { $num >= $maxsw || $num < 0 } { + error "ERROR: switch number out of bounds" + } + clientput [eval $switches([lindex $swlist $num]) $op] + set sw [varToken $line $pos] + set op [varToken $line $pos] + } + clientput [prsw] + } +} diff --git a/tasinit.c b/tasinit.c index b6f8df66..78edfa2f 100644 --- a/tasinit.c +++ b/tasinit.c @@ -148,6 +148,7 @@ extern char *tasVariableOrder[] = { "bet4", "output", "local", + "swunit", NULL}; /*--------------------------------------------------------------------- There is a special feauture in MAD where the count mode is determined @@ -291,15 +292,13 @@ int TASFactory(SConnection *pCon, SicsInterp *pSics, void *pData, TASKill(pNew); return 0; } - /* - iError = AddCommand(pSics,"set",TASSet,NULL,pNew); + iError = AddCommand(pSics,"sf",TASScan,NULL,pNew); if(!iError) { SCWrite(pCon,"ERROR: duplicate set command not created",eError); TASKill(pNew); return 0; } - */ return 1; } diff --git a/task.c b/task.c index bc9b065a..de30fa3b 100644 --- a/task.c +++ b/task.c @@ -180,6 +180,20 @@ self->pCurrent = self->pHead; } } +/*-------------------------------------------------------------------------*/ + static int TaskExist(pTaskMan self, long lID) + { + pTaskHead pCur = self->pHead; + while(pCur != NULL) + { + if(pCur->lID == lID) + { + return 1; + } + pCur = pCur->pNext; + } + return 0; + } /*--------------------------------------------------------------------------*/ int TaskSchedule(pTaskMan self) { @@ -252,6 +266,11 @@ else { IncrTaskPointer(self); + } + if(self->pCurrent == self->pHead) + { + if(!TaskExist(self,lID)) + goto ente; } } diff --git a/tasscan.c b/tasscan.c index 7fa5f91a..cf7a62b2 100644 --- a/tasscan.c +++ b/tasscan.c @@ -587,9 +587,16 @@ static int TASScanDrive(pScanData self, int iPoint) /* now wait for our motors to arrive, thereby ignoring any error - returns. + returns. DO NOT WAIT if fast scan! */ - status = Wait4Success(GetExecutor()); + if(pTAS->iFast) + { + return 1; + } + else + { + status = Wait4Success(GetExecutor()); + } return 1; } @@ -1231,6 +1238,19 @@ int TASScan(SConnection *pCon, SicsInterp *pSics, void *pData, if(!SCMatchRights(pCon,usUser)) return 0; + /* + check if we are a fast scan or a normal scan + */ + strtolower(argv[0]); + if(strcmp(argv[0],"sf") == 0) + { + pTAS->iFast = 1; + } + else + { + pTAS->iFast = 0; + } + /* Initialize parsing*/ Arg2Text(argc, argv,pLine,1023); strtolower(pLine);