- Added a sinq module for monitoring the Accelerator broadcast

- Added automatic notification via SMS


SKIPPED:
	psi/dgrambroadcast.c
	psi/dgrambroadcast.h
	psi/make_gen
	psi/psi.c
	psi/sinq.c
	psi/sinq.h
This commit is contained in:
koennecke
2005-07-08 12:32:38 +00:00
parent 96e8cdb2d5
commit 054e2133ee
20 changed files with 163 additions and 46 deletions

View File

@ -41,6 +41,7 @@
-----------------------------------------------------------------------------*/
#include <stdlib.h>
#include <assert.h>
#include <time.h>
#include <string.h>
#include "fortify.h"
#include "sics.h"
@ -106,6 +107,7 @@
pTaskMan pTask;
int iLock;
pICallBack pCall;
time_t lastRun;
} ExeList;
static pExeList pExecutor = NULL;
@ -141,6 +143,7 @@
pRes->lTask = -1;
pRes->iLock = 0;
pRes->pCall = CreateCallBackInterface();
pRes->lastRun = time(NULL);
return pRes;
}
/*-------------------------------------------------------------------------*/
@ -868,6 +871,21 @@
SCWrite(pCon, "ERROR: illegal arguments for ListExe", eError);
return 0;
}
/*-------------------------------------------------------------------------*/
int SicsIdle(SConnection *pCon, SicsInterp *pSics, void *pData,
int argc, char *argv[])
{
pExeList self = NULL;
int idle;
char pBueffel[80];
self = (pExeList)pData;
assert(self);
idle = time(NULL) - self->lastRun;
snprintf(pBueffel,79,"sicsidle = %d",idle);
SCWrite(pCon,pBueffel,eValue);
return 1;
}
/*--------------------------------------------------------------------------
Usage:
Success
@ -985,6 +1003,7 @@
return 0;
}
self->lastRun = time(NULL);
iRet = CheckExeList(self);
switch(iRet)
{

View File

@ -126,10 +126,15 @@
int ListExe(SConnection *pCon, SicsInterp *pSics, void *pData,
int argc, char *argv[]);
/*
lists all currently executing objects
*/
int SicsIdle(SConnection *pCon, SicsInterp *pSics, void *pData,
int argc, char *argv[]);
/*
prints the seconds since the device executor was running the last time
*/
int Success(SConnection *pCon, SicsInterp *pSics, void *pData,
int argc, char *argv[]);
/*
@ -156,7 +161,7 @@
void UnlockDeviceExecutor(pExeList self);
#line 292 "devexec.w"
#line 297 "devexec.w"
/* -------------------------- Executor management -------------------------*/

View File

@ -320,10 +320,15 @@ to the global SICS device executor.
\mbox{}\verb@ @\\
\mbox{}\verb@ int ListExe(SConnection *pCon, SicsInterp *pSics, void *pData,@\\
\mbox{}\verb@ int argc, char *argv[]);@\\
\mbox{}\verb@@\\
\mbox{}\verb@ /*@\\
\mbox{}\verb@ lists all currently executing objects@\\
\mbox{}\verb@ */@\\
\mbox{}\verb@ int SicsIdle(SConnection *pCon, SicsInterp *pSics, void *pData,@\\
\mbox{}\verb@ int argc, char *argv[]);@\\
\mbox{}\verb@ /*@\\
\mbox{}\verb@ prints the seconds since the device executor was running the last time@\\
\mbox{}\verb@ */@\\
\mbox{}\verb@@\\
\mbox{}\verb@ int Success(SConnection *pCon, SicsInterp *pSics, void *pData,@\\
\mbox{}\verb@ int argc, char *argv[]);@\\
\mbox{}\verb@ /*@\\

View File

@ -266,10 +266,15 @@ to the global SICS device executor.
int ListExe(SConnection *pCon, SicsInterp *pSics, void *pData,
int argc, char *argv[]);
/*
lists all currently executing objects
*/
int SicsIdle(SConnection *pCon, SicsInterp *pSics, void *pData,
int argc, char *argv[]);
/*
prints the seconds since the device executor was running the last time
*/
int Success(SConnection *pCon, SicsInterp *pSics, void *pData,
int argc, char *argv[]);
/*

View File

@ -21,6 +21,7 @@ typedef struct {
char scanVar[30];
double step;
int np;
float preset;
}FourTableEntry, *pFourTableEntry;
/*==================== functions =======================================*/
int MakeFourCircleTable(){
@ -52,8 +53,8 @@ static void printList(int handle, SConnection *pCon){
status = LLDnodePtr2First(handle);
while(status == 1) {
LLDnodeDataTo(handle,&entry);
snprintf(pBueffel,131,"%8.3f %s %8.3f %d\n", entry.twoThetaEnd,
entry.scanVar,entry.step, entry.np);
snprintf(pBueffel,131,"%8.3f %10s %8.3f %d %8.3f\n", entry.twoThetaEnd,
entry.scanVar,entry.step, entry.np,entry.preset);
Tcl_DStringAppend(&list,pBueffel,-1);
printed = 1;
status = LLDnodePtr2Next(handle);
@ -153,6 +154,12 @@ static int addToList(int handle, SConnection *pCon, int argc, char *argv[]){
SCWrite(pCon,pBueffel,eError);
return 0;
}
entry.preset = -1.0;
if(argc > 7){
if(isNumeric(argv[7])){
entry.preset = atof(argv[7]);
}
}
insertEntry(handle,entry);
return 1;
}
@ -273,6 +280,17 @@ double GetFourCircleStep(int handle, double two_theta){
}
}
/*------------------------------------------------------------------------*/
float GetFourCirclePreset(int handle, double two_theta){
FourTableEntry entry;
entry = findEntry(handle,two_theta);
if(strcmp(entry.scanVar,"NOT FOUND") == 0){
return -999.99;
} else {
return entry.preset;
}
}
/*------------------------------------------------------------------------*/
int GetFourCircleScanNP(int handle, double two_theta){
FourTableEntry entry;
@ -292,9 +310,9 @@ int SaveFourCircleTable(int handle, char *objName, FILE *fd){
status = LLDnodePtr2Last(handle);
while(status != 0) {
LLDnodeDataTo(handle,&entry);
fprintf(fd,"%s table add %f %s %f %d\n",objName,
fprintf(fd,"%s table add %f %s %f %d %f\n",objName,
entry.twoThetaEnd,entry.scanVar,
entry.step,entry.np);
entry.step,entry.np,entry.preset);
status = LLDnodePtr2Prev(handle);
}
return 1;

View File

@ -18,6 +18,7 @@
char *GetFourCircleScanVar(int handle, double two_theta);
int GetFourCircleScanNP(int handle, double two_theta);
double GetFourCircleStep(int handle, double two_theta);
float GetFourCirclePreset(int handle, double two_theta);
int SaveFourCircleTable(int handle, char *objName, FILE *fd);
#endif

21
macro.c
View File

@ -829,7 +829,7 @@ static int ProtectedExec(ClientData clientData, Tcl_Interp *interp,
{
char pBueffel[1024];
pPubTcl self = NULL;
int iRet;
int iRet, length;
char *pPtr;
Tcl_Interp *pTcl = NULL;
@ -853,9 +853,22 @@ static int ProtectedExec(ClientData clientData, Tcl_Interp *interp,
iRet = Tcl_Eval(pTcl,pBueffel);
if(iRet == TCL_OK)
{
strncpy(pBueffel,pTcl->result,1023);
SCWrite(pCon,pBueffel,eStatus);
{ length = strlen(pTcl->result);
if(length < 1024){
strncpy(pBueffel,pTcl->result,1023);
SCWrite(pCon,pBueffel,eStatus);
} else {
length += 10;
pPtr = (char *)malloc(length*sizeof(char));
if(pPtr == NULL){
SCWrite(pCon,"ERROR: out of memory in TclAction",eError);
return 0;
}
memset(pPtr,0,length*sizeof(char));
strncpy(pPtr,pTcl->result,length-1);
SCWrite(pCon,pPtr,eStatus);
free(pPtr);
}
return 1;
}
else

View File

@ -12,6 +12,7 @@
#include <assert.h>
#include <tcl.h>
#include <time.h>
#include <fcntl.h>
#include "stringdict.h"
#include "mccontrol.h"
/*========================= life and death ==================================*/
@ -294,14 +295,25 @@ int McStasStart(pMcStasController self, CounterMode mode, float fPreset){
static long readMonFile(pMcStasController self){
char pResult[256];
FILE *fd = NULL;
struct flock fl;
long monValue = -1;
int i;
if(!StringDictGet(self->scripts,"mcmonfile",pResult,255)){
return -1;
}
fl.l_type = F_RDLCK;
fl.l_whence = SEEK_SET;
fl.l_start = 0;
fl.l_len = 0;
fl.l_pid = getpid();
fd = fopen(pResult,"r");
if(fd != NULL){
fcntl(fileno(fd),F_SETLKW,&fl);
fscanf(fd,"%ld", &monValue);
fl.l_type = F_UNLCK;
fcntl(fileno(fd),F_SETLK,&fl);
fclose(fd);
}
return monValue;
@ -313,11 +325,10 @@ int McStasStatus(pMcStasController self, float *fControl){
int status, i;
/*
* check at max any second, else we keep the system busy and
* check at max any second, else SICS keeps the system busy and
* there is no CPU left for McStas
*/
SicsWait(1);
status = invokeScript(self,"mcisrunning",pServ->pSics,pResult, 255);
if(status == 0){
strncpy(self->errorText,pResult,255);
@ -342,6 +353,7 @@ int McStasStatus(pMcStasController self, float *fControl){
* check only any three seconds, else SICS uses up all the CPU time
* and the simulation has no chance.
*/
*fControl = self->lastMon;
if(time(NULL) < self->lastMonitorRead + 3) {
return HWBusy;
}
@ -362,6 +374,7 @@ int McStasStatus(pMcStasController self, float *fControl){
self->lastMonitorRead = time(NULL);
monValue *= self->monitorScale;
*fControl = monValue;
self->lastMon = monValue;
if(monValue >= self->fPreset){
McStasStop(self);
}

View File

@ -28,6 +28,7 @@
time_t startTime;
time_t stopTime;
time_t lastMonitorRead;
float lastMon;
}McStasController, *pMcStasController;
/*---------------------- function prototypes -------------------------------------------*/

View File

@ -82,6 +82,7 @@ $\langle$mcconint {\footnotesize ?}$\rangle\equiv$
\mbox{}\verb@ time_t startTime;@\\
\mbox{}\verb@ time_t stopTime;@\\
\mbox{}\verb@ time_t lastMonitorRead;@\\
\mbox{}\verb@ float lastMon;@\\
\mbox{}\verb@ }McStasController, *pMcStasController;@\\
\mbox{}\verb@ @$\diamond$
\end{list}

View File

@ -77,6 +77,7 @@ deemed advisable to separate this logic into a separate module. The McStas contr
time_t startTime;
time_t stopTime;
time_t lastMonitorRead;
float lastMon;
}McStasController, *pMcStasController;
@}
The fields are:

View File

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

View File

@ -47,12 +47,23 @@ OUTPUT PARAMETERS (Nsum, psum, p2sum,currentCount)
STATE PARAMETERS (x,y,z,vx,vy,vz,t,s1,s2,p)
SHARE
%{
#include <fcntl.h>
void dumpTotal(char *ffilename, long totalCounts){
FILE *fd = NULL;
struct flock fl;
fl.l_type = F_WRLCK;
fl.l_whence = 0;
fl.l_start = 0;
fl.l_len = 0;
fl.l_pid = getpid();
fd = fopen(ffilename,"w");
if(fd != NULL){
fcntl(fileno(fd),F_SETLKW,&fl);
fprintf(fd,"%ld\n",totalCounts);
fl.l_type = F_UNLCK;
fcntl(fileno(fd),F_SETLK,&fl);
fclose(fd);
}
}

View File

@ -107,7 +107,7 @@ COMPONENT Bmoin_slit = Slit(
AT (0,0,0.525) RELATIVE msa ROTATED (0,0,0) RELATIVE msa
COMPONENT out = Virtual_output(file=lambdafile)
COMPONENT out = Virtual_output(file=lambdafile,bufsize=100000)
AT(0,0,0.64) RELATIVE msa ROTATED (0,0,0) RELATIVE msa
END

View File

@ -163,7 +163,7 @@ proc copydmcdata { } {
mcreader open $home/dmc.xml
mcreader insertmon \
"/$mcversion/DMC_diff/dmc.xml/PSD_sample/values" \
counter 1 [expr 1./10000]
counter 1 [expr 1./1000]
mcreader insertmon \
"/$mcversion/DMC_diff/dmc.xml/Det9/det9.dat/values" \
counter 5
@ -171,7 +171,7 @@ proc copydmcdata { } {
if { $hmScale <= 0} {
set hmScale 1e9
} else {
set hmScale [expr $hmScale * 1e9]
set hmScale [expr $hmScale * 1e7]
}
clientput "HM scale = $hmScale"
mcreader inserthm \
@ -188,7 +188,7 @@ mccontrol configure mcstart rundmcoptsim
mccontrol configure mccopydata copydmcdata
mccontrol configure update 60
mccontrol configure mcmonfile $home/monfile
mccontrol configure monitorscale [expr 1. /10000]
mccontrol configure monitorscale [expr 1. /1000]
mccontrol configure mcdump mcstasdump
#--------------------------------------------------------------------------
# A count command for VDMC

View File

@ -14,7 +14,7 @@ sicsdatapostfix .hdf
sicsdatapostfix setAccess 0
sicsdataprefix powder
sicsdataprefix setAccess 0
starttime 2005-07-01 16:19:39
starttime 2005-07-08 10:41:56
starttime setAccess 2
comment3 UNKNOWN
comment3 setAccess 2
@ -121,9 +121,9 @@ a1 precision 0.010000
a1 AccessCode 2.000000
a1 movecount 10.000000
banana CountMode monitor
banana preset 5.000000
banana preset 2.000000
# Counter counter
counter SetPreset 5000.000000
counter SetPreset 2000.000000
counter SetMode Monitor
# Motor twothetad
twothetad sign 1.000000

View File

@ -371,6 +371,9 @@ static void ListMesure(pMesure self, char *name, SConnection *pCon)
/* loop over all scan variables */
status = 1;
memset(pHead,0,512*sizeof(char));
memset(pStatus,0,512*sizeof(char));
memset(pItem,0,20*sizeof(char));
for(i = 0; i < self->iScanVar; i++)
{
DynarGet(self->pScanVar,i,&pDings);
@ -378,7 +381,7 @@ static void ListMesure(pMesure self, char *name, SConnection *pCon)
if(pVar)
{
fVal = pVar->pInter->GetValue(pVar->pObject,self->pCon);
AppendScanVar(pVar,fVal);
AppendScanVar(pVar,fVal);
sprintf(pItem,"%-10.10s",pVar->Name);
strcat(pHead,pItem);
sprintf(pItem,"%-10.3f",fVal);
@ -551,12 +554,14 @@ int weakScan(pMesure self, double twoTheta)
}
}
/*-----------------------------------------------------------------------*/
static int PerformPSDScan(pMesure self, char *scanVar, float fStart, float step, int np)
static int PerformPSDScan(pMesure self, char *scanVar, float fStart,
float step, int np, float two_theta)
{
int status;
char pCommand[1024];
char countMode[20];
Tcl_Interp *pTcl;
float fPreset;
/*
PSD scans are done by calling the routine Tcl procedure tricsscan with the
@ -570,7 +575,12 @@ static int PerformPSDScan(pMesure self, char *scanVar, float fStart, float step,
{
strcpy(countMode,"monitor");
}
snprintf(pCommand,1023,"tricsscan %f %f %d %s %f", fStart, step, np,countMode,self->fPreset);
fPreset = GetFourCirclePreset(self->stepTable,(double)two_theta);
if(fPreset < .0){
fPreset = self->fPreset;
}
snprintf(pCommand,1023,"tricsscan %f %f %d %s %f", fStart, step, np,
countMode,fPreset);
pTcl = InterpGetTcl(pServ->pSics);
status = Tcl_Eval(pTcl,pCommand);
if(status != TCL_OK)
@ -585,7 +595,7 @@ static int PerformPSDScan(pMesure self, char *scanVar, float fStart, float step,
/*------------------------------------------------------------------------*/
static int ScanReflection(pMesure self, float twoTheta, SConnection *pCon)
{
float fStart, stepWidth;
float fStart, stepWidth, fPreset;
int iRet, np;
char pBueffel[132];
char *scanVar = NULL;
@ -619,7 +629,7 @@ static int ScanReflection(pMesure self, float twoTheta, SConnection *pCon)
*/
if(self->psd == 1)
{
iRet = PerformPSDScan(self,scanVar,fStart, stepWidth, np);
iRet = PerformPSDScan(self,scanVar,fStart, stepWidth, np,twoTheta);
free(scanVar);
return iRet;
}
@ -668,6 +678,14 @@ static int ScanReflection(pMesure self, float twoTheta, SConnection *pCon)
memset(self->lCounts,0,np*sizeof(long));
}
/*
* determine preset
*/
fPreset = GetFourCirclePreset(self->stepTable,(double)twoTheta);
if(fPreset < .0){
fPreset = self->fPreset;
}
/* do the scan */
free(scanVar);
if(self->iCompact)
@ -679,7 +697,7 @@ static int ScanReflection(pMesure self, float twoTheta, SConnection *pCon)
self->pScanner->ScanDrive = ScanFastDrive;
}
iRet = SilentScan(self->pScanner,np,self->CountMode,
self->fPreset,pServ->pSics,pCon);
fPreset,pServ->pSics,pCon);
if(weakScan(self,twoTheta))
{
/*
@ -701,7 +719,7 @@ static int ScanReflection(pMesure self, float twoTheta, SConnection *pCon)
*/
SCWrite(pCon,"Remeasuring weak reflection",eWarning);
iRet = SilentScan(self->pScanner,np,self->CountMode,
self->fPreset*5.,pServ->pSics,pCon);
fPreset*5.,pServ->pSics,pCon);
}
ResetScanFunctions(self->pScanner);
@ -941,6 +959,7 @@ static int ScanReflection(pMesure self, float twoTheta, SConnection *pCon)
assert(self);
assert(pCon);
memset(pTime,0,132*sizeof(char));
#ifdef MESSDEBUG
self->np = 90;

View File

@ -327,7 +327,11 @@ static int evaluateStatus(pMotor self, SConnection *pCon)
}
if(newStatus == HWIdle || newStatus == OKOK)
{
finishDriving(self,pCon);
newStatus = checkPosition(self,pCon);
if(newStatus != HWBusy)
{
finishDriving(self,pCon);
}
}
break;
case HWBusy:

1
ofac.c
View File

@ -243,6 +243,7 @@
*/
AddCommand(pInter,"StopExe",StopCommand,DeleteExeList, pExe);
AddCommand(pInter,"ListExe",ListExe,NULL,pExe);
AddCommand(pInter,"sicsidle",SicsIdle,NULL,pExe);
AddCommand(pInter,"Success",Success,NULL,pExe);
AddCommand(pInter,"pause",PauseAction,NULL,pExe);
AddCommand(pInter,"continue",ContinueAction,NULL,pExe);

28
scan.c
View File

@ -305,20 +305,20 @@ static void ConfigureScanDict(pStringDict dict)
pCount = (pCountEntry)pData;
if(pCount != NULL)
{
fprintf(fd,"%s storecounts %ld %f %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld\n",
self->objectName,
pCount->lCount,
pCount->fTime,
pCount->Monitors[0],
pCount->Monitors[1],
pCount->Monitors[2],
pCount->Monitors[3],
pCount->Monitors[4],
pCount->Monitors[5],
pCount->Monitors[6],
pCount->Monitors[7],
pCount->Monitors[8],
pCount->Monitors[9]);
fprintf(fd,"%s storecounts %ld %f %ld %ld %ld %ld %ld %ld %ld %ld %ld %ld\n",
self->objectName,
pCount->lCount,
pCount->fTime,
pCount->Monitors[0],
pCount->Monitors[1],
pCount->Monitors[2],
pCount->Monitors[3],
pCount->Monitors[4],
pCount->Monitors[5],
pCount->Monitors[6],
pCount->Monitors[7],
pCount->Monitors[8],
pCount->Monitors[9]);
}
}
if(self->iMode == eTimer){