- fixed a bug in pause handling of environment controller.

- added code to triple axis MAD emulation layer
This commit is contained in:
cvs
2000-12-21 07:55:04 +00:00
parent 513e2701f0
commit d3b8f38ced
15 changed files with 399 additions and 24 deletions

View File

@ -1,3 +1,3 @@
7476 7634
NEVER, EVER modify or delete this file NEVER, EVER modify or delete this file
You'll risk eternal damnation and a reincarnation as a cockroach!|n You'll risk eternal damnation and a reincarnation as a cockroach!|n

View File

@ -412,6 +412,7 @@
SetStatus(eOutOfBeam); SetStatus(eOutOfBeam);
if(SCGetInterrupt(self->pOwner) != eContinue) if(SCGetInterrupt(self->pOwner) != eContinue)
{ {
SetStatus(eEager);
self->iStatus = DEVINT; self->iStatus = DEVINT;
return -1; return -1;
} }
@ -420,6 +421,7 @@
SetStatus(ePaused); SetStatus(ePaused);
if(SCGetInterrupt(self->pOwner) != eContinue) if(SCGetInterrupt(self->pOwner) != eContinue)
{ {
ContinueExecution(self);
self->iStatus = DEVINT; self->iStatus = DEVINT;
return -1; return -1;
} }

View File

@ -62,6 +62,7 @@
#include "el755driv.h" #include "el755driv.h"
#include "tecsdriv.h" #include "tecsdriv.h"
#include "chadapter.h" #include "chadapter.h"
#include "status.h"
/*--------------------- Functions needed to implement interfaces -----------*/ /*--------------------- Functions needed to implement interfaces -----------*/
static long EVIDrive(void *pData, SConnection *pCon, float fVal) static long EVIDrive(void *pData, SConnection *pCon, float fVal)
{ {
@ -339,7 +340,6 @@
self = (pEVControl)pData; self = (pEVControl)pData;
assert(self); assert(self);
self->pDriv->GetValue(self->pDriv,&fPos); self->pDriv->GetValue(self->pDriv,&fPos);
sprintf(pBueffel,"WARNING: %s is out of range by %f",self->pName, sprintf(pBueffel,"WARNING: %s is out of range by %f",self->pName,
self->fTarget - fPos); self->fTarget - fPos);
@ -367,14 +367,14 @@
/* wait till OK */ /* wait till OK */
iRet = 0; iRet = 0;
while(iRet == 0) while(iRet == 0 && IsCounting(pExe) )
{ {
SicsWait(5); SicsWait(5);
iRet = self->pEnvir->IsInTolerance(self); iRet = self->pEnvir->IsInTolerance(self);
} }
/* OK now, continue */ /* OK now, continue */
SetStatus(eEager);
ContinueExecution(pExe); ContinueExecution(pExe);
return 1; return 1;
} }

View File

@ -505,6 +505,11 @@ extern void KillPiPiezo(void *pData);
*fVal = self->fPosition; *fVal = self->fPosition;
return 1; return 1;
} }
else if(strcmp(name,"target") == 0)
{
*fVal = self->fTarget;
return 1;
}
else else
{ {
return 0; return 0;

View File

@ -201,7 +201,7 @@
int32 iAxis[128]; int32 iAxis[128];
int i, iRet; int i, iRet;
long lVal; long lVal;
HistInt lData[16384]; HistInt lData[65536];
CommandList *pCom = NULL; CommandList *pCom = NULL;
pHistMem self = NULL; pHistMem self = NULL;
CounterMode eMode; CounterMode eMode;
@ -555,9 +555,9 @@
NXDputalias(Nfil,pDict,"ddmo",&iVal); NXDputalias(Nfil,pDict,"ddmo",&iVal);
fVal = GetHistCountTime(self,pCon); fVal = GetHistCountTime(self,pCon);
NXDputalias(Nfil,pDict,"ddtime",&fVal); 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); NXDputalias(Nfil,pDict,"ddcounts",lData);
for(i = 0; i < 128; i++) for(i = 0; i < 256; i++)
{ {
iAxis[i] = i; iAxis[i] = i;
} }

View File

@ -98,7 +98,7 @@ local Berty Chimney
local setAccess 2 local setAccess 2
output a1,a2,a3,a4 output a1,a2,a3,a4
output setAccess 2 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 lastcommand setAccess 2
user Billy Looser user Billy Looser
user setAccess 2 user setAccess 2
@ -108,6 +108,8 @@ f2 0
f2 setAccess 2 f2 setAccess 2
f1 0 f1 0
f1 setAccess 2 f1 setAccess 2
swunit 0
swunit setAccess 2
hz 0.000000 hz 0.000000
hz setAccess 2 hz setAccess 2
hy 0.000000 hy 0.000000
@ -124,11 +126,11 @@ if2v 0.000000
if2v setAccess 2 if2v setAccess 2
if1v 0.000000 if1v 0.000000
if1v setAccess 2 if1v setAccess 2
mn 2000 mn 700
mn setAccess 2 mn setAccess 2
ti 8.000000 ti 2.000000
ti setAccess 2 ti setAccess 2
np 7 np 9
np setAccess 2 np setAccess 2
fx 2 fx 2
fx setAccess 2 fx setAccess 2
@ -183,7 +185,7 @@ bs setAccess 2
as 5.000000 as 5.000000
as setAccess 2 as setAccess 2
# Counter counter # Counter counter
counter SetPreset 8.000000 counter SetPreset 2.000000
counter SetMode Timer counter SetMode Timer
# Motor agl # Motor agl
agl SoftZero -0.490000 agl SoftZero -0.490000

View File

@ -38,7 +38,7 @@ det1zerox 128.
det1zerox setAccess 1 det1zerox setAccess 1
mono2theta 36.77 mono2theta 36.77
mono2theta setAccess 1 mono2theta setAccess 1
monodescription unknownit crystal monodescription unknownit crystal
monodescription setAccess 1 monodescription setAccess 1
# Motor om # Motor om
om SoftZero 0.000000 om SoftZero 0.000000
@ -407,5 +407,5 @@ sample DanielOxid
sample setAccess 2 sample setAccess 2
title TopsiTupsiTapsi title TopsiTupsiTapsi
title setAccess 2 title setAccess 2
starttime UNKNOWN starttime 2000-12-15 15:44:22
starttime setAccess 2 starttime setAccess 2

View File

@ -50,7 +50,7 @@
A SIMCOUNTER HAS a BUILT IN FAILURE RATE OF 10% FOR TESTING ERROR HANDLING A SIMCOUNTER HAS a BUILT IN FAILURE RATE OF 10% FOR TESTING ERROR HANDLING
CODE. A negative failure rate means absolute success. CODE. A negative failure rate means absolute success.
*/ */
#define FAILRATE -0.05 #define FAILRATE 0.05
/*----------------------------------------------------------------------------*/ /*----------------------------------------------------------------------------*/
static float SimRandom(void) static float SimRandom(void)
{ {

View File

@ -313,6 +313,19 @@
pInternal->iLastHMError = status; pInternal->iLastHMError = status;
return HWFault; 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 */ /* start the El737 counter */
pCountInt = pInternal->pCounter->pDes->GetInterface(pInternal->pCounter, pCountInt = pInternal->pCounter->pDes->GetInterface(pInternal->pCounter,

4
tas.h
View File

@ -105,8 +105,9 @@
#define BET4 89 #define BET4 89
#define OUT 90 #define OUT 90
#define LOC 91 #define LOC 91
#define SWUNIT 92
#define MAXPAR 92 #define MAXPAR 93
#define MAXADD 20 #define MAXADD 20
/* --------------------- data structure -------------------------------*/ /* --------------------- data structure -------------------------------*/
@ -121,6 +122,7 @@ typedef struct {
int addType[MAXADD]; int addType[MAXADD];
int addCount; int addCount;
int iFileNO; int iFileNO;
int iFast;
}TASdata, *pTASdata; }TASdata, *pTASdata;

6
tas.w
View File

@ -44,6 +44,7 @@ typedef struct {
int addType[MAXADD]; int addType[MAXADD];
int addCount; int addCount;
int iFileNO; int iFileNO;
int iFast;
}TASdata, *pTASdata; }TASdata, *pTASdata;
@} @}
\begin{description} \begin{description}
@ -61,6 +62,8 @@ such variables.
variables. This can be 0 for simple variables or 1 for a motor. variables. This can be 0 for simple variables or 1 for a motor.
\item[addCount] is the number of additional output variables. \item[addCount] is the number of additional output variables.
\item[iFileNO] is the number of the current data file. \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} \end{description}
The constants for the parameters are defined in the header file. 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 BET4 89
#define OUT 90 #define OUT 90
#define LOC 91 #define LOC 91
#define SWUNIT 92
#define MAXPAR 92 #define MAXPAR 93
#define MAXADD 20 #define MAXADD 20
/* --------------------- data structure -------------------------------*/ /* --------------------- data structure -------------------------------*/

View File

@ -26,6 +26,13 @@ if { [info exists tasinit] == 0 } {
Publish lz Spy Publish lz Spy
Publish lm Spy Publish lm Spy
Publish ls 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 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]
}
}

View File

@ -148,6 +148,7 @@ extern char *tasVariableOrder[] = {
"bet4", "bet4",
"output", "output",
"local", "local",
"swunit",
NULL}; NULL};
/*--------------------------------------------------------------------- /*---------------------------------------------------------------------
There is a special feauture in MAD where the count mode is determined 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); TASKill(pNew);
return 0; return 0;
} }
/* iError = AddCommand(pSics,"sf",TASScan,NULL,pNew);
iError = AddCommand(pSics,"set",TASSet,NULL,pNew);
if(!iError) if(!iError)
{ {
SCWrite(pCon,"ERROR: duplicate set command not created",eError); SCWrite(pCon,"ERROR: duplicate set command not created",eError);
TASKill(pNew); TASKill(pNew);
return 0; return 0;
} }
*/
return 1; return 1;
} }

19
task.c
View File

@ -180,6 +180,20 @@
self->pCurrent = self->pHead; 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) int TaskSchedule(pTaskMan self)
{ {
@ -252,6 +266,11 @@
else else
{ {
IncrTaskPointer(self); IncrTaskPointer(self);
}
if(self->pCurrent == self->pHead)
{
if(!TaskExist(self,lID))
goto ente;
} }
} }

View File

@ -587,9 +587,16 @@ static int TASScanDrive(pScanData self, int iPoint)
/* /*
now wait for our motors to arrive, thereby ignoring any error 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; return 1;
} }
@ -1231,6 +1238,19 @@ int TASScan(SConnection *pCon, SicsInterp *pSics, void *pData,
if(!SCMatchRights(pCon,usUser)) if(!SCMatchRights(pCon,usUser))
return 0; 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*/ /* Initialize parsing*/
Arg2Text(argc, argv,pLine,1023); Arg2Text(argc, argv,pLine,1023);
strtolower(pLine); strtolower(pLine);