- Rearranged directory structure for forking out ANSTO

- Refactored site specific stuff into a site module
- PSI specific stuff is now in the PSI directory.
- The old version has been tagged with pre-ansto
This commit is contained in:
cvs
2003-06-20 10:18:47 +00:00
commit 064ec37e9a
271 changed files with 115513 additions and 0 deletions

72
utils/Makefile Normal file
View File

@ -0,0 +1,72 @@
#---------------------------------------------------------------------------
# Makefile for the Utilities in the utils directory,
#
# e.g. SerPortServer asynsrv_test
#
# David Maden, Sep-2000
#--------------------------------------------------------------------------
#------------ for DigitalUnix (add -DFORTIFY to CFLAGS for fortified version)
#CC = cc
#CFLAGS = -std -g -warnprotos -I. -I../hardsup
#BIN = ../bin
#LFLAGS = -L../hardsup
#------------ for Linux
CC = gcc
CFLAGS = -g -I. -I../hardsup -DLinux
BIN = ../bin
LFLAGS = -L../hardsup -L/usr/X11R6/lib
#------------
#----------------------------------------------------------
all: $(BIN)/asynsrv_test \
$(BIN)/el734 \
$(BIN)/el734_test \
$(BIN)/el737 \
$(BIN)/SerPortServer
#----------------------------------------------------------
$(BIN)/SerPortServer: SerPortServer.c
rm -f $(BIN)/SerPortServer
$(CC) $(CFLAGS) -o $(BIN)/SerPortServer \
SerPortServer.c $(LFLAGS) -lhlib -lX11
$(BIN)/asynsrv_test: asynsrv_test.c
rm -f $(BIN)/asynsrv_test
$(CC) $(CFLAGS) -o $(BIN)/asynsrv_test \
asynsrv_test.c $(LFLAGS) -lhlib -lX11
$(BIN)/el734: el734.c
@ echo "el734 needs Motif library. Not yet found on linux"
rm -f $(BIN)/el734
$(CC) $(CFLAGS) -o $(BIN)/el734 \
el734.c $(LFLAGS) -lhlib -lX11 -lXt -lXm
$(BIN)/el734_test: el734_test.c
rm -f $(BIN)/el734_test
$(CC) $(CFLAGS) -o $(BIN)/el734_test \
el734_test.c $(LFLAGS) -lhlib -lX11
$(BIN)/el737: el737.c
@ echo "el737 needs Motif library. Not yet found on linux"
rm -f $(BIN)/el737
$(CC) $(CFLAGS) -I/usr/X11R6/include -o $(BIN)/el737 \
el737.c $(LFLAGS) -lhlib -lXm -lXt -lX11 -lm
#----------------------------------------------------------
clean:
- rm -f *.o
- rm -f $(BIN)/SerPortServer \
$(BIN)/asynsrv_test \
$(BIN)/el734 \
$(BIN)/el734_test \
$(BIN)/el737
#----------------------------------------------------------
.c.o:
$(CC) $(CFLAGS) -c $*.c
#----------------------------------------------------------

2588
utils/SerPortServer.c Executable file

File diff suppressed because it is too large Load Diff

861
utils/asynsrv_test.c Executable file
View File

@ -0,0 +1,861 @@
#define ident "1A09"
#ifdef __DECC
#pragma module asynsrv_test ident
#endif
/*
** +--------------------------------------------------------------+
** | Paul Scherrer Institute |
** | SINQ Project |
** | |
** | This software may be used freely by non-profit organizations.|
** | It may be copied provided that the name of P.S.I. and of the |
** | author is included. Neither P.S.I. nor the author assume any |
** | responsibility for the use of this software outside of P.S.I.|
** +--------------------------------------------------------------+
**
** Link_options - Here is the Linker Option File
**!$ if p1 .eqs. "DEBUG" then dbg1 := /debug
**!$ if p1 .eqs. "DEBUG" then dbg2 := _dbg
**!$ link 'dbg1'/exe=asynsrv_test'dbg2'.exe sys$input/options
**! asynsrv_test
**! sinq_olb/lib
**! sys$share:decw$xmlibshr12/share
**! sys$share:decw$xtlibshrr5/share
**! sys$share:decw$xlibshr/share
**!$ purge/nolog asynsrv_test'dbg2'.exe
**!$ write sys$output "Exec file is asynsrv_test''DBG2'.exe
**!$ exit
**!!
**!! To build on LNSA01 ...
**!! $ build_cc_select :== decc
**!! $ import tasmad
**!! $ define/job deltat_c_tlb sinq_c_tlb
**!! $ set default ud0:[maden.scratch]
**!! $ bui tasmad_disk:[mad.tests]asynsrv_test debug
**!!
** Link_options_end
**
** Building on Alpha Digital Unix:
**
** setenv TAS_BASE ~maden/tasmad
** source $TAS_BASE/tasmad.setup
** rcp -p "lnsa09:tas_src:[utils]asynsrv_test.c" \
** $TAS_SRC/utils/asynsrv_test.c
** cc -std -g -o $TAS_BIN/asynsrv_test \
** -I$TAS_INC \
** $TAS_SRC/utils/asynsrv_test.c \
** -L$TAS_LIB -lsinq -lXm -lXt -lX11
**
** Resources and Flags File: decw$user_defaults:SinQ_rc.dat
** ------------------- or $HOME/SinQ_rc
**
** Resource Flag Default Description
** -------- ---- ------- -----------
** - -name asynsrv_test Name to use when looking up the
** resources. The default is the
** image file name.
** *AsynSrvHelp -help - Generates help info.
** *AsynSrvHost -host none The name of the host to which the
** program wishes to connect.
** *AsynSrvPort -port 4000 The TCP/IP port of the RS232C server.
** *AsynSrvChan -chan none The number of the RS232C channel to
** which the device is attached.
** *AsynSrvTmo -tmo 2 Time-out in secs for responses to
** *AsynSrvTmoConn -tmoC 5 Time-out in secs for connect.
** commands.
** *AsynSrvDebug -debug If specified, selects debug mode (not
** yet implemented).
** *AsynSrvLower -lc - If specified, causes conversion of
** input to lowercase before sending.
** *AsynSrvUpper -uc - If specified, causes conversion of
** input to uppercase before sending.
** This is the default.
** *AsynSrvNoCase -ncc - If specified, causes no case
** conversion of input before sending.
** *AsynSrvTermOut -termout "\r" Specifies a string to be appended to
** anything sent to the server.
** *AsynSrvTermIn -termin "\r" Specifies a string of up to 3 chars
** which will be recognised as
** input response terminators.
** A value given via -name will be converted to lowercase before being used.
**+
**---------------------------------------------------------------------------
** Module Name . . . . . . . . : [...tests]asynsrv_test.c
**
** Author . . . . . . . . . . : D. Maden
** Date of creation . . . . . . : Jan 1997
**
** Purpose
** =======
** asynsrv_test is a TCP/IP server client which should make a TCP/IP
** connection to an RS-232-C server and allow the user to transmit
** commands from the keyboard to a device attached to an RS-232-C channel
** on the server.
** Use:
** ===
** 1) Set up the host name, TCP/IP port number and RS-232-C channel of the
** device in the resources file (see above). These can also
** be supplied as options on the command line.
**
** 2) Run the program
**
** $ run cpt:[exe]asynsrv_test
**
** or, to specify options on the command line, use a DCL foreign
** command:
**
** $ asynsrv_test :== $cpt:[exe]asynsrv_test
** $ asynsrv_test -host <host> -port <port-number> -chan <chan>
**
** Updates:
** 1A01 20-Jan-1997 DM. Initial version.
** 1A07 3-Apr-2000 DM. Add fortify.h
**-
**====================================================================
*/
#include <stdlib.h>
#include <stdio.h>
#include <signal.h>
#include <ctype.h>
#include <time.h>
#ifdef __VMS
#include <sys/unixio.h>
#else
#include <unistd.h>
#ifdef FORTIFY
#include <fortify/fortify.h>
#endif
#endif
#include <X11/Intrinsic.h>
/*
**====================================================================
*/
#include <sinq_prototypes.h>
#include <asynsrv_def.h>
#include <rs232c_def.h>
/*
**--------------------------------------------------------------------------
** Define global structures and constants.
*/
/*-------------------------------------------------------------
** Global Variables
*/
static int C_gbl_status; /* Return status from C_... routines */
static int Ctrl_C_has_happened;
void *Hndl = NULL;
static XrmOptionDescRec OpTable[] = {
{"-name", ".name", XrmoptionSepArg, (XPointer) NULL},
{"-help", ".AsynSrvHelp", XrmoptionNoArg, (XPointer) "1"},
{"-host", ".AsynSrvHost", XrmoptionSepArg, (XPointer) NULL},
{"-port", ".AsynSrvPort", XrmoptionSepArg, (XPointer) NULL},
{"-chan", ".AsynSrvChan", XrmoptionSepArg, (XPointer) NULL},
{"-tmoC", ".AsynSrvTmoConn", XrmoptionSepArg, (XPointer) NULL},
{"-tmoc", ".AsynSrvTmoConn", XrmoptionSepArg, (XPointer) NULL},
{"-tmo", ".AsynSrvTmo", XrmoptionSepArg, (XPointer) NULL},
{"-debug", ".AsynSrvDebug", XrmoptionNoArg, (XPointer) "1"},
{"-lc", ".AsynSrvLower", XrmoptionNoArg, (XPointer) "1"},
{"-uc", ".AsynSrvUpper", XrmoptionNoArg, (XPointer) "1"},
{"-ncc", ".AsynSrvNoCase", XrmoptionNoArg, (XPointer) "1"},
{"-termout", ".AsynSrvTermOut", XrmoptionSepArg, (XPointer) NULL},
{"-termin", ".AsynSrvTermIn", XrmoptionSepArg, (XPointer) NULL},
};
struct AsynSrv__info AsynSrv_info;
int Debug;
float TmoC;
float Tmo;
int DoLower, DoUpper;
char TermOut[16];
char TermIn[16];
int Do_help;
char *Errstack;
int Errcode, Errno, Vaxc_errno;
/*
**--------------------------------------------------------------------------
** PrintErrInfo: print out error information.
*/
void PrintErrInfo (char *text) {
/* ============
*/
AsynSrv_ErrInfo (&Errstack, &Errcode, &Errno, &Vaxc_errno);
fprintf (stderr, "\n"
" Error return from %s.\n"
" Errstack = \"%s\".\n"
" Errcode = %d. Errno = %d. Vaxc$errno = %d.\n",
text, Errstack, Errcode, Errno, Vaxc_errno);
switch (Errcode) {
case ASYNSRV__BAD_BIND:
fprintf (stderr, "ASYNSRV__BAD_BIND\n");
break;
case ASYNSRV__BAD_CONNECT:
fprintf (stderr, "ASYNSRV__BAD_CONNECT\n");
break;
case ASYNSRV__BAD_HOST:
fprintf (stderr, "ASYNSRV__BAD_HOST\n");
break;
case ASYNSRV__BAD_PAR:
fprintf (stderr, "ASYNSRV__BAD_PAR\n");
break;
case ASYNSRV__BAD_SOCKET:
fprintf (stderr, "ASYNSRV__BAD_SOCKET\n");
break;
case ASYNSRV__NO_ROOM:
fprintf (stderr, "ASYNSRV__NO_ROOM\n");
break;
default:
fprintf (stderr, "Unrecognised error code!\n");
if ((Errno != 0) || (Vaxc_errno != 0)) perror (text);
}
return;
}
/*
**--------------------------------------------------------------------------
** ShowUsage: A simple print-out routine.
*/
void ShowUsage (int full) {
/* =========
*/
if (!full) {
if (Do_help) return;
printf ("\n"
"To get help on running the program issue the command:\n"
"\n"
" asynsrv_test -help\n"
"\n");
return;
}
printf ("\n"
"Usage: asynsrv_test [options ...]\n"
" \n"
" Valid options are: Equivalent resource name:\n"
" -help *AsynSrvHelp\n"
" -host <host-name> *AsynSrvHost\n"
" -port <port-number> *AsynSrvPort Dflt=4000\n"
" -chan <channel-number> *AsynSrvChan\n"
" -debug *AsynSrvDebug\n"
" -tmo <secs> *AsynSrvTmo Dflt=2\n"
" -tmoC <secs> *AsynSrvTmoConn Dflt=5\n"
" -lc *AsynSrvLower\n"
" -uc *AsynSrvUpper\n"
" -ncc *AsynSrvNoCase\n"
" -termout <term-out-string> *AsynSrvTermOut Dflt=\"\\r\"\n"
" -termin <term-in-string> *AsynSrvTermIn Dflt=\"\\r\"\n"
" -termin\n"
"\n"
" No default is allowed for -host or -chan,"
" i.e. values for\n"
" these parameters must be supplied either via a resource file or"
" on the\n"
" command line.\n"
"\n"
" -tmo is the time-out for responses to commands.\n"
" -tmoC is the time-out for the initial connection to the server.\n"
"\n"
"To quit the program, issue the command \"#q\".\n"
"To send a null command, issue the command \"\\0\".\n"
"Other special commands are:\n"
" #help\n"
" #close - gets SerPortServer to close its serial ports.\n"
" #flush - gets SerPortServer to flush its output.\n"
" #trace off - turn off SerPortServer tracing.\n"
" #trace on - turn on SerPortServer tracing.\n"
" #trace write - gets SerPortServer to write its trace buffer.\n"
"To send a command starting with \"#\", start it with \"##\".\n"
"\n");
return;
}
/*
**--------------------------------------------------------------------------
** DoInteract: Interact with the RS-232-C Device
*/
int DoInteract () {
/* ==========
*/
int status, go_on, no_errors, no_restore, i, j, len, act_len, tok_len;
FILE *lun;
char recd[132], buff[132], cmnd[132], cmnd_prnt[512];
char eot_save[4], tmo_save[4], term;
char *rptr, *tok;
struct RS__MsgStruct send_buff;
struct RS__RespStruct rcve_buff;
lun = stdin; /* Use standard input */
go_on = True;
no_errors = True;
if (lun == stdin) {
printf ("Issue the command \"#h\" for help and \"#q\" to quit.\n> ");
fflush (NULL);
}
while (go_on && (fgets (recd, sizeof (recd), lun) != NULL)) {
len = strlen (recd);
if (len <= 1) {
if (lun == stdin) {printf ("> "); fflush (NULL);}
continue;
}
if (recd[len-1] != '\n') {
recd[20] = '\0';
printf (" Record not terminated by \"\\n\". "
"It is probably too long!\n"
" The record starts thus: %s ...\n"
" It has been skipped.\n", recd);
if (lun == stdin) {printf ("> "); fflush (NULL);}
continue;
}
recd[len-1] = '\0'; /* Remove the terminating "\n" */
/*
** Strip off any trailing stuff (but keep it around so that we
** can print it out). "Trailing stuff" is anything after a "!".
*/
act_len = strcspn (recd, "!");
len = sizeof (buff);
if (DoLower) {
StrEdit (buff, recd, "trim uncomment lowercase", &len);
}else if (DoUpper) {
StrEdit (buff, recd, "trim uncomment upcase", &len);
}else {
StrEdit (buff, recd, "trim uncomment", &len);
}
len = sizeof (cmnd);
StrEdit (cmnd, buff, "lowercase", &len);
if (strncmp (buff, "##", 2) == 0) { /* "##" at start gets compressed
** to "#" */
len = sizeof (buff);
StrEdit (buff, &buff[1], "trim", &len);
}
tok = strtok (cmnd, " ");
tok_len = (tok != NULL) ? strlen (tok) : 0;
if ((tok_len >= 2) &&
(strncmp (tok, "#exit", tok_len) == 0)) {
go_on = False;
}else if ((tok_len >= 2) &&
(strncmp (tok, "#quit", tok_len) == 0)) {
go_on = False;
}else if ((tok_len >= 2) &&
(strncmp (tok, "#trace", tok_len) == 0)) {
tok = strtok (NULL, " ");
tok_len = (tok != NULL) ? strlen (tok) : 0;
if ((tok_len >= 2) &&
(strncmp (tok, "on", tok_len) == 0)) {
printf ("Requesting server to turn tracing on ..."); fflush (NULL);
status = AsynSrv_Trace (&AsynSrv_info, True);
if (status) {
printf (" done.\n");
}else {
printf ("\nError detected!\n");
}
}else if ((tok_len >= 2) &&
(strncmp (tok, "off", tok_len) == 0)) {
printf ("Requesting server to turn tracing off ..."); fflush (NULL);
status = AsynSrv_Trace (&AsynSrv_info, False);
if (status) {
printf (" done.\n");
}else {
printf ("\nError detected!\n");
}
}else if ((tok_len >= 1) &&
(strncmp (tok, "write", tok_len) == 0)) {
printf ("Requesting server to write trace ..."); fflush (NULL);
status = AsynSrv_Trace_Write (&AsynSrv_info);
if (status) {
printf (" done.\n");
}else {
printf ("\nError detected!\n");
}
}else {
printf ("Illegal \"#trace\" command! You must "
"specify \"on\" or \"off\" or \"write\".\n");
}
}else if ((tok_len >= 2) &&
(strncmp (tok, "#flush", tok_len) == 0)) {
printf ("Requesting server to flush ..."); fflush (NULL);
status = AsynSrv_Flush (&AsynSrv_info);
if (status) {
printf (" done.\n");
}else {
printf ("\nError detected!\n");
}
}else if ((tok_len >= 2) &&
(strncmp (tok, "#close", tok_len) == 0)) {
printf ("Requesting server to close its serial channels ..."); fflush (NULL);
status = AsynSrv_ChanClose (&AsynSrv_info);
if (status) {
printf (" done.\n");
}else {
printf ("\nError detected!\n");
}
}else if ((tok_len >= 2) &&
(strncmp (tok, "#help", tok_len) == 0)) {
ShowUsage (True);
}else if ((cmnd[0] == '#') && (cmnd[1] != '#')) {
printf ("Illegal command! If you really want to start a command\n"
" with a \"#\" character, you should use\n"
" \"##\" instead!\n");
}else {
if (strlen (buff) > 0) {
StrJoin (buff, sizeof (buff), buff, TermOut); /* Append terminator */
}
/*
** Show user what's getting sent
*/
MakePrintable (cmnd_prnt, sizeof (cmnd_prnt), buff);
printf ("Sending \"%s\" ... ", cmnd_prnt); fflush (NULL);
status = AsynSrv_SendCmnds (&AsynSrv_info, &send_buff, &rcve_buff,
buff, NULL);
if (!status) {
go_on = no_errors = False;
continue;
}else {
rptr = AsynSrv_GetReply (&AsynSrv_info, &rcve_buff, NULL);
if (rptr == NULL) {
printf ("No response from server!\n");
go_on = no_errors = False;
continue;
}else {
AsynSrv_GetLenTerm (&AsynSrv_info, &rcve_buff, rptr, &len, &term);
MakeMemPrintable (cmnd_prnt, sizeof (cmnd_prnt), rptr, len);
MakeMemPrintable (recd, sizeof (recd), &term, 1);
j = strlen (cmnd_prnt);
printf ("\nResponse length = %d. Terminator = \"%s\".\n", len, recd);
for (i = 0; i < (j/70); i++)
printf (" \"%.70s\"\\...\n", &cmnd_prnt[i*70]);
printf (" \"%s\"\n", &cmnd_prnt[i*70]);
}
}
}
if (lun == stdin) {printf ("> "); fflush (NULL);}
}
if (no_errors) {
printf ("\"Interaction\" completed.\n");
}else {
printf ("Interaction failed.\n");
}
return no_errors;
}
/*
**---------------------------------------------------------------------------
** SetupXrmDatabase - setup Resource Manager Database
*/
int SetupXrmDatabase (
/* ================
*/ XrmDatabase *db,
char *name[],
int *argc,
char *argv[]) {
static char our_name[80] = "Unknown"; /* This holds the program name */
static char lkup_name[80] = "Unknown"; /* Name for looking in database */
int status, i, first = True;
char text[80];
char full_nm0[80];
char full_nm1[80];
char *p_fil[] = {0,0,0,0,0,0,0,0,0,0};
char *my_name;
char *my_name_last;
char *name_type;
XrmValue name_value;
XrmDatabase cmnd_line_db = NULL;
XrmDatabase lcl_db = NULL;
/*-----------------------------------------------------
** This routine merges some resource databases with options specified on
** the command line. Resources can then be looked up using XrmGetResource.
** This is a bit like the X-toolkit routine XtAppInitialize does for the
** extraction of resources by XtGetApplicationResources.
**
** I can't help but think that there's a simpler way of doing this but I
** can't find it in the X manuals. Basically, the problem arises with wanting
** to avoid the calling program being associated with an X-display, i.e. it
** is intended for use by "command-line oriented" programs. All the nice,
** easy-to-use resource/command-line setup routines in Xlib or Xtlib seem to
** assume one is going to use a display -- not surprising, I suppose,
** since the concept of Xlib is for writing window based applications!
**
** Anyway, the point is that the following way turn out to be lacking
** when it gets tested in anger.
*/
status = True; /* Assume success */
our_name[0] = '\0';
/*
** Make a list of the databases to be merged, highest priority first.
*/
#ifdef __VMS
p_fil[0] = "decw$user_defaults:SinQ_rc.dat";
p_fil[1] = "decw$group_defaults:SinQ_rc.dat";
p_fil[2] = "decw$system_defaults:SinQ_rc.dat";
p_fil[3] = "decw$user_defaults:decw$xdefaults.dat";
p_fil[4] = "decw$group_defaults:decw$xdefaults.dat";
p_fil[5] = "decw$system_defaults:decw$xdefaults.dat";
p_fil[6] = NULL;
if (*argc > 0) { /* Find out what we are called - parse file nm */
my_name = strstr (argv[0], "]"); /* Find end of directory, i.e. "]" */
my_name++; /* Skip over "]" */
if (my_name[0] == '[') { /* Handle possible concealed device */
my_name = strstr (my_name, "]");
my_name++;
}
i = sizeof (our_name);
StrEdit (our_name, my_name, "lowercase", &i); /* Copy the rest */
strtok (our_name, "."); /* Close it off at "." */
}
#else
p_fil[0] = StrJoin (full_nm0, sizeof (full_nm0),
getenv ("HOME"), "/SinQ_rc");
p_fil[1] = "/usr/lib/X11/app-defaults/SinQ_rc";
p_fil[2] = StrJoin (full_nm1, sizeof (full_nm1),
getenv ("HOME"), "/.Xdefaults");
p_fil[3] = "/usr/lib/X11/app-defaults/Xdefaults";
p_fil[4] = NULL;
if (*argc > 0) { /* Find out what we are called - parse file nm */
/* Find end of directories */
my_name = argv[0] - 1;
while (my_name != NULL) {
my_name_last = my_name;
my_name_last++;
my_name = strstr (my_name_last, "/");
}
StrJoin (our_name, sizeof (our_name), my_name_last, "");
}
#endif
printf ("My name is \"%s\"\n", our_name);
/*
** Initialise and combine all databases
*/
XrmInitialize ();
for (i = 0; i < XtNumber (p_fil); i++) {
if (p_fil[i] == NULL) break;
status = XrmCombineFileDatabase (p_fil[i], &lcl_db, False);
if (status != 0) {
if (first) {
printf ("Resource database created from file %s.\n", p_fil[i]);
}else {
printf ("File %s merged into resource database.\n", p_fil[i]);
}
first = False;
}
}
/*
** See if there's anything specified on cmnd line, incl "name".
*/
XrmParseCommand (&cmnd_line_db,
OpTable, XtNumber(OpTable), our_name, argc, argv);
if (cmnd_line_db != NULL) {
/*
** There was at least 1 item on cmnd line. Process the line.
** If -name was specified, adopt it.
*/
status = XrmGetResource (cmnd_line_db, /* See if a name was specified */
StrJoin (text, sizeof (text), our_name, ".name"),
"ProgramName.Values",
&name_type, &name_value);
if (status) {
i = sizeof (lkup_name);
StrEdit (lkup_name, name_value.addr, "lowercase", &i);
printf ("Option list name is \"%s\"\n", lkup_name);
}else {
strcpy (lkup_name, our_name);
}
/*
** Loop over all items in OpTable and merge them into database,
** taking care of any possible name changes.
*/
for (i = 0; i < XtNumber (OpTable); i++) {
if (strcmp (OpTable[i].option, "-name") == 0) continue;
status = XrmGetResource (cmnd_line_db,
StrJoin (text, sizeof (text),
our_name, OpTable[i].specifier),
"ProgramName.Values",
&name_type, &name_value);
if (status) {
StrJoin (text, sizeof (text), lkup_name, OpTable[i].specifier);
XrmPutResource (&lcl_db, text, "String", &name_value);
}
}
}
*name = lkup_name;
*db = lcl_db;
if (lcl_db == NULL) printf ("Warning -- no resource database found.\n");
XrmDestroyDatabase (cmnd_line_db);
/*
** XrmPutFileDatabase (lcl_db, "asynsrv_test.db");
*/
return status;
}
/*
**---------------------------------------------------------------------------
** GetCheckResources - get and check our resources
*/
int GetCheckResources (
/* =================
*/ XrmDatabase *db,
char *appName) {
int i, status;
char buff[80];
char *type;
XrmValue value;
time_t time_now;
float tmp_secs;
status = XrmGetResource (*db,
StrJoin (buff, sizeof (buff),
appName, ".AsynSrvHelp"),
"ProgramName.Values",
&type, &value);
Do_help = (status) ? True : False;
if (Do_help) {
ShowUsage (True);
exit (EXIT_SUCCESS);
}
status = XrmGetResource (*db,
StrJoin (buff, sizeof (buff),
appName, ".AsynSrvDebug"),
"ProgramName.Values",
&type, &value);
Debug = (status) ? True : False;
status = XrmGetResource (*db,
StrJoin (buff, sizeof (buff),
appName, ".AsynSrvNoCase"),
"ProgramName.Values",
&type, &value);
if (status) {
DoLower = False; DoUpper = False;
}else {
DoLower = False; DoUpper = True;
}
status = XrmGetResource (*db,
StrJoin (buff, sizeof (buff),
appName, ".AsynSrvLower"),
"ProgramName.Values",
&type, &value);
if (status) DoLower = True;
if (DoLower) DoUpper = False;
status = XrmGetResource (*db,
StrJoin (buff, sizeof (buff),
appName, ".AsynSrvUpper"),
"ProgramName.Values",
&type, &value);
if (status) DoUpper = True;
if (DoUpper) DoLower = False;
status = XrmGetResource (*db,
StrJoin (buff, sizeof (buff),
appName, ".AsynSrvHost"),
"ProgramName.Values",
&type, &value);
if (!status) {
printf ("No server specified via the -host option. "
"No default allowed!\n");
ShowUsage (False);
return False;
}else {
StrJoin (AsynSrv_info.host, sizeof (AsynSrv_info.host), value.addr, "");
printf ("Using Internet host \"%s\".\n", AsynSrv_info.host);
}
status = XrmGetResource (*db,
StrJoin (buff, sizeof (buff),
appName, ".AsynSrvPort"),
"ProgramName.Values",
&type, &value);
if (!status || (sscanf (value.addr, "%d", &AsynSrv_info.port) != 1)) {
AsynSrv_info.port = 4000;
printf ("Using the default TCP/IP port number of %d.\n",
AsynSrv_info.port);
}else {
printf ("TCP/IP port number = %d\n", AsynSrv_info.port);
}
status = XrmGetResource (*db,
StrJoin (buff, sizeof (buff),
appName, ".AsynSrvChan"),
"ProgramName.Values",
&type, &value);
if (!status || (sscanf (value.addr, "%d", &AsynSrv_info.chan) != 1)) {
printf ("No RS-232-C channel specified via the -chan option. "
"No default allowed!\n");
ShowUsage (False);
return False;
}else {
printf ("RS-232-C channel number = %d\n", AsynSrv_info.chan);
}
status = XrmGetResource (*db,
StrJoin (buff, sizeof (buff),
appName, ".AsynSrvTmo"),
"ProgramName.Values",
&type, &value);
if (!status || (sscanf (value.addr, "%f", &Tmo) != 1)) {
Tmo = 2.0;
}else {
printf ("Response time-out = %d msec.\n", (int) ((Tmo + 0.0001) * 1000));
}
status = XrmGetResource (*db,
StrJoin (buff, sizeof (buff),
appName, ".AsynSrvTmoConn"),
"ProgramName.Values",
&type, &value);
if (!status || (sscanf (value.addr, "%f", &TmoC) != 1)) {
TmoC = 5.0;
}else {
printf ("Connection time-out = %d secs.\n", (int) (TmoC + 0.0001));
}
status = XrmGetResource (*db,
StrJoin (buff, sizeof (buff),
appName, ".AsynSrvTermOut"),
"ProgramName.Values",
&type, &value);
if (!status) {
printf ("Output terminator is \"\\r\"\n");
strcpy (TermOut, "\r");
}else {
printf ("Output terminator is \"%s\"\n", value.addr);
i = sizeof (TermOut);
if (StrEdit (TermOut, value.addr, "trim", &i) == NULL) {
printf ("Bad output terminator!\n");
ShowUsage (False);
return False;
}
}
status = XrmGetResource (*db,
StrJoin (buff, sizeof (buff),
appName, ".AsynSrvTermIn"),
"ProgramName.Values",
&type, &value);
if (!status) {
printf ("Input terminator is \"\\r\"\n");
memcpy (TermIn, "1\r\0\0", 4);
}else {
printf ("Input terminator is \"%s\"\n", value.addr);
i = sizeof (TermIn) - 1;
if (StrEdit (&TermIn[1], value.addr, "trim", &i) == NULL) {
printf ("Bad input terminator!\n");
ShowUsage (False);
return False;
}
switch (strlen (&TermIn[1])) {
case 0: strcpy (TermIn, "0\0\0\0"); break;
case 1: TermIn[0] = '1'; TermIn[2] = TermIn[3] = '\0'; break;
case 2: TermIn[0] = '2'; TermIn[3] = '\0'; break;
case 3: TermIn[0] = '3'; break;
default:
printf ("Input terminator string is too long!\n");
return False;
}
}
return True;
}
/*
**--------------------------------------------------------------------------
** CtrlC_Handler: Signal handler to detect <Ctrl-C> on keyboard.
*/
void CtrlC_Handler (int sigint) {
/* =============
*/
Ctrl_C_has_happened = True;
}
/*
**==========================================================================
** Main line program
** ------------------
*/
int main (int argc, char **argv) {
/* ============================
*/
char buff[80], text0[80], text1[80];
int buff_len;
int status, errcode, errno, vaxc_errno, i;
char *errName;
time_t time_now;
int sec_tmoC, msec_tmo;
XrmDatabase my_db;
char *appName;
/*-----------------------------------------------------------------------*/
time_now = time (NULL);
printf ("RS-232-C Device Test Program, Ident %s.\n", ident);
printf ("Started at %s", asctime (localtime (&time_now)));
/*-------------------------------------------------------------
** Setup the resource database and look up the resources.
*/
SetupXrmDatabase (&my_db, &appName, &argc, argv);
if (argc > 1) {
if (argc > 2) {
printf ("\nThe following arguments were not used:\n\n ");
for (i = 1; i < argc; i++) {
printf ("\"%s\" ", argv[i]);
}
}else {
printf ("\nArgument \"%s\" was not used.", argv[1]);
}
printf ("\n");
ShowUsage (False);
return False;
}
status = GetCheckResources (&my_db, appName);
if (!status) return False;
/*
** Declare a signal handler to catch <Ctrl-C> so that we
** can exit cleanly.
*/
Ctrl_C_has_happened = False;
signal (SIGINT, CtrlC_Handler);
sec_tmoC = (int) (TmoC + 0.0001);
msec_tmo = (int) ((Tmo + 0.0001) * 1000);
status = AsynSrv_ConfigDflt (
"tmoC", sec_tmoC, /* Specify the connection time-out */
"msecTmo", msec_tmo, /* Specify the response time-out */
"eot", TermIn, /* Specify the terminators */
NULL);
if (!status) {
printf ("Error setting default configuration of server connection.\n");
PrintErrInfo ("AsynSrv_ConfigDflt");
return False;
}
status = AsynSrv_Open (&AsynSrv_info);
if (!status) {
printf ("Error opening connection to server.\n");
PrintErrInfo ("AsynSrv_Open");
return False;
}else {
status = DoInteract ();
if (!status) {
PrintErrInfo ("DoInteract");
AsynSrv_Close (&AsynSrv_info, 0);
return False;
}
status = AsynSrv_Close (&AsynSrv_info, 0);
}
return True;
}
/*------------------------------------------------- End of asynsrv_test.c */

97
utils/check/amorcheck Executable file
View File

@ -0,0 +1,97 @@
#! /bin/sh
#next line is executed by sh, not by Tcl \
exec tclsh $0 ${1+"$@"}
#--------------------------------------------------------------------------
# This is the SICS syntax checker for the AMOR reflectometer
#
# Mark Koennecke, March 2003
#--------------------------------------------------------------------------
source /data/koenneck/src/sics/utils/check/sicssyntaxlib.tcl
#------------ define AMOR motors and aliases
sicsSyntaxMap ftz syntaxMotor
sicsSyntaxMap fom syntaxMotor
sicsSyntaxMap d1l syntaxMotor
sicsSyntaxMap d1r syntaxMotor
sicsSyntaxMap d1t syntaxMotor
sicsSyntaxMap d1b syntaxMotor
sicsSyntaxMap moz syntaxMotor
sicsSyntaxMap mty syntaxMotor
sicsSyntaxMap mom syntaxMotor
sicsSyntaxMap mtz syntaxMotor
sicsSyntaxMap d2l syntaxMotor
sicsSyntaxMap d2r syntaxMotor
sicsSyntaxMap d2t syntaxMotor
sicsSyntaxMap d2b syntaxMotor
sicsSyntaxMap d3l syntaxMotor
sicsSyntaxMap d3r syntaxMotor
sicsSyntaxMap d3t syntaxMotor
sicsSyntaxMap d3b syntaxMotor
sicsSyntaxMap stz syntaxMotor
sicsSyntaxMap som syntaxMotor
sicsSyntaxMap sch syntaxMotor
sicsSyntaxMap soz syntaxMotor
sicsSyntaxMap stb syntaxMotor
sicsSyntaxMap d4l syntaxMotor
sicsSyntaxMap d4r syntaxMotor
sicsSyntaxMap d4t syntaxMotor
sicsSyntaxMap d4b syntaxMotor
sicsSyntaxMap aoz syntaxMotor
sicsSyntaxMap aom syntaxMotor
sicsSyntaxMap atz syntaxMotor
sicsSyntaxMap d5l syntaxMotor
sicsSyntaxMap d5r syntaxMotor
sicsSyntaxMap d5t syntaxMotor
sicsSyntaxMap d5b syntaxMotor
sicsSyntaxMap coz syntaxMotor
sicsSyntaxMap c3z syntaxMotor
sicsSyntaxMap com syntaxMotor
sicsSyntaxMap cox syntaxMotor
#------------ define AMOR counters
sicsSyntaxMap counter syntaxCounter
sicsSyntaxMap hm syntaxHM
#------------ define AMOR variables
sicsSyntaxMap title syntaxTextPar
sicsSyntaxMap user syntaxTextPar
sicsSyntaxMap adres syntaxTextPar
sicsSyntaxMap collimation syntaxTextPar
sicsSyntaxMap sample syntaxTextPar
sicsSyntaxMap comment1 syntaxTextPar
sicsSyntaxMap comment2 syntaxTextPar
sicsSyntaxMap comment3 syntaxTextPar
sicsSyntaxMap fax syntaxTextPar
sicsSyntaxMap email syntaxTextPar
sicsSyntaxMap sample syntaxTextPar
#----------- define AMOR environment
sicsSyntaxMap temperature evSyntax
sicsSyntaxMap tt evSyntax
sicsSyntaxMap pby evSyntax
sicsSyntaxMap aby evSyntax
sicsSyntaxMap magnet evSyntax
#---------- define AMOR auxiliary
sicsSyntaxMap dr syntaxDrive
sicsSyntaxMap s2t syntaxNumPar
sicsSyntaxMap o2t syntaxNumPar
sicsSyntaxMap td syntaxNumPar
sicsSyntaxMap aw syntaxNumPar
sicsSyntaxMap shutter syntaxTextPar
#syntaxLoadSICS amorstatus.tcl
#puts stdout [array names sicsPar]
if { $argc < 1} {
puts stdout "Usage: \n\tamorcheck filename"
exit 0
}
set filename [lindex $argv 0]
lappend fileList [file tail $filename]
puts stdout "Syntax checking --> $filename <-- ........."
source $filename
puts stdout "If this completed without errors the likelihoof of your script"
puts stdout "executing properly on the instrument has increased significantly"
exit 1

68
utils/check/dmccheck Executable file
View File

@ -0,0 +1,68 @@
#! /bin/sh
#next line is executed by sh, not by Tcl \
exec tclsh $0 ${1+"$@"}
#--------------------------------------------------------------------------
# This is the SICS syntax checker for the DMC powder diffractometer
#
# Mark Koennecke, March 2003
#--------------------------------------------------------------------------
source /data/koenneck/src/sics/utils/check/sicssyntaxlib.tcl
#------------------------- define DMC motors and aliases
sicsSyntaxMap omegam syntaxMotor
sicsSyntaxMap twothetam syntaxMotor
sicsSyntaxMap monox syntaxMotor
sicsSyntaxMap monoy syntaxMotor
sicsSyntaxMap curvem syntaxMotor
sicsSyntaxMap monophi syntaxMotor
sicsSyntaxMap monochi syntaxMotor
sicsSyntaxMap table syntaxMotor
sicsSyntaxMap twothetad syntaxMotor
sicsSyntaxMap a1 syntaxMotor
sicsSyntaxMap a2 syntaxMotor
sicsSyntaxMap a3 syntaxMotor
sicsSyntaxMap a4 syntaxMotor
sicsSyntaxMap a5 syntaxMotor
sicsSyntaxMap a6 syntaxMotor
sicsSyntaxMap a7 syntaxMotor
sicsSyntaxMap a8 syntaxMotor
sicsSyntaxMap a9 syntaxMotor
#------------ define DMC counters
sicsSyntaxMap counter syntaxCounter
sicsSyntaxMap banana syntaxHM
#------------ define DMC variables
sicsSyntaxMap title syntaxTextPar
sicsSyntaxMap user syntaxTextPar
sicsSyntaxMap collimation syntaxTextPar
sicsSyntaxMap sample syntaxTextPar
sicsSyntaxMap comment1 syntaxTextPar
sicsSyntaxMap comment2 syntaxTextPar
sicsSyntaxMap comment3 syntaxTextPar
sicsSyntaxMap fax syntaxTextPar
sicsSyntaxMap email syntaxTextPar
sicsSyntaxMap sample syntaxTextPar
sicsSyntaxMap lambda syntaxNumPar
#----------- define DMC environment
sicsSyntaxMap temperature evSyntax
sicsSyntaxMap tt evSyntax
#---------- define DMC auxiliary
sicsSyntaxMap beam syntaxDummy
#--------- Main checking stuff
if { $argc < 1} {
puts stdout "Usage: \n\tdmccheck filename"
exit 0
}
set filename [lindex $argv 0]
lappend fileList [file tail $filename]
puts stdout "Syntax checking --> $filename <-- ........."
source $filename
puts stdout "If this completed without errors the likelihoof of your script"
puts stdout "executing properly on the instrument has increased significantly"
exit 1

82
utils/check/focuscheck Executable file
View File

@ -0,0 +1,82 @@
#! /bin/sh
#next line is executed by sh, not by Tcl \
exec tclsh $0 ${1+"$@"}
#--------------------------------------------------------------------------
# This is the SICS syntax checker for the FOCUS TOF diffractometer
#
# Mark Koennecke, March 2003
#--------------------------------------------------------------------------
source /data/koenneck/src/sics/utils/check/sicssyntaxlib.tcl
#------------ define FOCUS motors and aliases
sicsSyntaxMap mtt syntaxMotor
sicsSyntaxMap msl syntaxMotor
sicsSyntaxMap mth syntaxMotor
sicsSyntaxMap mtx syntaxMotor
sicsSyntaxMap mty syntaxMotor
sicsSyntaxMap mgo syntaxMotor
sicsSyntaxMap m1ch syntaxMotor
sicsSyntaxMap m1cv syntaxMotor
sicsSyntaxMap m2ch syntaxMotor
sicsSyntaxMap m2cv syntaxMotor
sicsSyntaxMap mex syntaxMotor
sicsSyntaxMap som syntaxMotor
sicsSyntaxMap sth syntaxMotor
sicsSyntaxMap sph syntaxMotor
sicsSyntaxMap theta syntaxMotor
sicsSyntaxMap a1 syntaxMotor
sicsSyntaxMap a2 syntaxMotor
#------------ define FOCUS counters
sicsSyntaxMap counter syntaxCounter
sicsSyntaxMap hm syntaxHM
#------------ define FOCUS variables
sicsSyntaxMap title syntaxTextPar
sicsSyntaxMap user syntaxTextPar
sicsSyntaxMap adres syntaxTextPar
sicsSyntaxMap collimation syntaxTextPar
sicsSyntaxMap sample syntaxTextPar
sicsSyntaxMap comment1 syntaxTextPar
sicsSyntaxMap comment2 syntaxTextPar
sicsSyntaxMap comment3 syntaxTextPar
sicsSyntaxMap fax syntaxTextPar
sicsSyntaxMap email syntaxTextPar
sicsSyntaxMap sample syntaxTextPar
sicsSyntaxMap lambda syntaxNumPar
#----------- define FOCUS environment
sicsSyntaxMap temperature evSyntax
sicsSyntaxMap tt evSyntax
#---------- define FOCUS auxiliary
sicsSyntaxMap fermispeed syntaxNumPar
sicsSyntaxMap diskspeed syntaxNumPar
sicsSyntaxMap ratio syntaxNumPar
sicsSyntaxMap phase syntaxNumPar
sicsSyntaxMap shutter syntaxTextPar
sicsSyntaxMap colli syntaxTextPar
sicsSyntaxMap td syntaxNumPar
sicsSyntaxMap aw syntaxNumPar
sicsSyntaxMap helium syntaxDummy
sicsSyntaxMap mono syntaxDummy
#--------- Main checking stuff
#syntaxLoadSICS focusstatus.tcl
#puts stdout [array names sicsPar]
if { $argc < 1} {
puts stdout "Usage: \n\tfocuscheck filename"
exit 0
}
set filename [lindex $argv 0]
lappend fileList [file tail $filename]
puts stdout "Syntax checking --> $filename <-- ........."
source $filename
puts stdout "If this completed without errors the likelihoof of your script"
puts stdout "executing properly on the instrument has increased significantly"
exit 1

149
utils/check/focusstatus.tcl Normal file
View File

@ -0,0 +1,149 @@
sampleangle 0.000000
sampleangle setAccess 2
delay 155.800003
delay setAccess 2
environment Void
environment setAccess 2
fermidist 3000.000000
fermidist setAccess 1
flightpathlength 3000.000000
flightpathlength setAccess 1
flightpath Standard
flightpath setAccess 1
bestatus 0
bestatus setAccess 2
# Motor a2
a2 sign 1.000000
a2 SoftZero 0.000000
a2 SoftLowerLim -184.000000
a2 SoftUpperLim 356.000000
a2 Fixed -1.000000
a2 InterruptMode 0.000000
a2 AccessCode 2.000000
# Motor a1
a1 sign 1.000000
a1 SoftZero 0.000000
a1 SoftLowerLim 17.500000
a1 SoftUpperLim 70.000000
a1 Fixed -1.000000
a1 InterruptMode 0.000000
a1 AccessCode 2.000000
batchroot /home/FOCUS/batch
batchroot setAccess 2
email fanni.juranyi@psi.ch
email setAccess 2
fax 2939
fax setAccess 2
phone 3176
phone setAccess 2
adress LNS
adress setAccess 2
comment3 UNKNOWN
comment3 setAccess 2
comment2 UNKNOWN
comment2 setAccess 2
comment1 UNKNOWN
comment1 setAccess 2
sample Zr95Al5 (42)
sample setAccess 2
user F. Juranyi
user setAccess 2
title I/02 B-9
title setAccess 2
lastscancommand cscan mth 33.94 0.05 25 10000
lastscancommand setAccess 2
hm CountMode monitor
hm preset 1000000.000000
hm genbin 9000.000000 50.000000 648
hm init
# Counter counter
counter SetPreset 1000000.000000
counter SetMode Monitor
# Motor mex
mex sign 1.000000
mex SoftZero 0.000000
mex SoftLowerLim -0.500000
mex SoftUpperLim 180.399994
mex Fixed -1.000000
mex InterruptMode 0.000000
mex AccessCode 2.000000
# Motor m2cv
m2cv sign 1.000000
m2cv SoftZero 0.000000
m2cv SoftLowerLim -0.700000
m2cv SoftUpperLim 14.300000
m2cv Fixed -1.000000
m2cv InterruptMode 0.000000
m2cv AccessCode 2.000000
# Motor m2ch
m2ch sign 1.000000
m2ch SoftZero 0.000000
m2ch SoftLowerLim -0.070000
m2ch SoftUpperLim 6.800000
m2ch Fixed -1.000000
m2ch InterruptMode 0.000000
m2ch AccessCode 2.000000
# Motor m1cv
m1cv sign 1.000000
m1cv SoftZero 0.000000
m1cv SoftLowerLim -5.000000
m1cv SoftUpperLim 10.800000
m1cv Fixed -1.000000
m1cv InterruptMode 0.000000
m1cv AccessCode 2.000000
# Motor m1ch
m1ch sign 1.000000
m1ch SoftZero 0.000000
m1ch SoftLowerLim -1.100000
m1ch SoftUpperLim 6.800000
m1ch Fixed -1.000000
m1ch InterruptMode 0.000000
m1ch AccessCode 2.000000
# Motor mgo
mgo sign 1.000000
mgo SoftZero 0.000000
mgo SoftLowerLim -0.600000
mgo SoftUpperLim 0.600000
mgo Fixed -1.000000
mgo InterruptMode 0.000000
mgo AccessCode 2.000000
# Motor mty
mty sign 1.000000
mty SoftZero 0.000000
mty SoftLowerLim -12.000000
mty SoftUpperLim 12.000000
mty Fixed -1.000000
mty InterruptMode 0.000000
mty AccessCode 2.000000
# Motor mtx
mtx sign 1.000000
mtx SoftZero 0.000000
mtx SoftLowerLim -12.000000
mtx SoftUpperLim 14.000000
mtx Fixed -1.000000
mtx InterruptMode 0.000000
mtx AccessCode 2.000000
# Motor mth
mth sign 1.000000
mth SoftZero 0.000000
mth SoftLowerLim 17.500000
mth SoftUpperLim 70.000000
mth Fixed -1.000000
mth InterruptMode 0.000000
mth AccessCode 2.000000
# Motor msl
msl sign 1.000000
msl SoftZero 0.000000
msl SoftLowerLim 0.000000
msl SoftUpperLim 218.000000
msl Fixed -1.000000
msl InterruptMode 0.000000
msl AccessCode 2.000000
# Motor mtt
mtt sign 1.000000
mtt SoftZero 0.000000
mtt SoftLowerLim -184.000000
mtt SoftUpperLim 356.000000
mtt Fixed -1.000000
mtt InterruptMode 0.000000
mtt AccessCode 2.000000

85
utils/check/hrptcheck Executable file
View File

@ -0,0 +1,85 @@
#! /bin/sh
#next line is executed by sh, not by Tcl \
exec tclsh $0 ${1+"$@"}
#--------------------------------------------------------------------------
# This is the SICS syntax checker for the HRPT powder diffractometer
#
# Mark Koennecke, March 2003
#--------------------------------------------------------------------------
source /data/koenneck/src/sics/utils/check/sicssyntaxlib.tcl
#------------------------- define HRPT motors and aliases
sicsSyntaxMap momu syntaxMotor
sicsSyntaxMap mtvu syntaxMotor
sicsSyntaxMap mtpu syntaxMotor
sicsSyntaxMap mgvu syntaxMotor
sicsSyntaxMap mgpu syntaxMotor
sicsSyntaxMap mcvu syntaxMotor
sicsSyntaxMap moml syntaxMotor
sicsSyntaxMap mtvl syntaxMotor
sicsSyntaxMap mtpl syntaxMotor
sicsSyntaxMap mgvl syntaxMotor
sicsSyntaxMap mcvl syntaxMotor
sicsSyntaxMap mexz syntaxMotor
sicsSyntaxMap som syntaxMotor
sicsSyntaxMap stt syntaxMotor
sicsSyntaxMap cex1 syntaxMotor
sicsSyntaxMap cex2 syntaxMotor
sicsSyntaxMap a1 syntaxMotor
sicsSyntaxMap a3 syntaxMotor
sicsSyntaxMap om syntaxMotor
sicsSyntaxMap omega syntaxMotor
sicsSyntaxMap a4 syntaxMotor
sicsSyntaxMap th syntaxMotor
sicsSyntaxMap b1 syntaxMotor
sicsSyntaxMap a17 syntaxMotor
sicsSyntaxMap a18 syntaxMotor
sicsSyntaxMap a12 syntaxMotor
sicsSyntaxMap a13 syntaxMotor
sicsSyntaxMap a14 syntaxMotor
sicsSyntaxMap a15 syntaxMotor
sicsSyntaxMap a16 syntaxMotor
sicsSyntaxMap a37 syntaxMotor
sicsSyntaxMap a22 syntaxMotor
sicsSyntaxMap a24 syntaxMotor
sicsSyntaxMap a25 syntaxMotor
sicsSyntaxMap a26 syntaxMotor
#------------ define HRPT counters
sicsSyntaxMap counter syntaxCounter
sicsSyntaxMap banana syntaxHM
#------------ define HRPT variables
sicsSyntaxMap title syntaxTextPar
sicsSyntaxMap user syntaxTextPar
sicsSyntaxMap collimation syntaxTextPar
sicsSyntaxMap sample syntaxTextPar
sicsSyntaxMap comment1 syntaxTextPar
sicsSyntaxMap comment2 syntaxTextPar
sicsSyntaxMap comment3 syntaxTextPar
sicsSyntaxMap fax syntaxTextPar
sicsSyntaxMap email syntaxTextPar
sicsSyntaxMap sample syntaxTextPar
sicsSyntaxMap lambda syntaxNumPar
sicsSyntaxMap mtt syntaxNumPar
#----------- define HRPT environment
sicsSyntaxMap temperature evSyntax
sicsSyntaxMap tt evSyntax
#---------- define HRPT auxiliary
sicsSyntaxMap beam syntaxDummy
sicsSyntaxMap graphit syntaxTextPar
#--------- Main checking stuff
if { $argc < 1} {
puts stdout "Usage: \n\thrptcheck filename"
exit 0
}
set filename [lindex $argv 0]
lappend fileList [file tail $filename]
puts stdout "Syntax checking --> $filename <-- ........."
source $filename
puts stdout "If this completed without errors the likelihoof of your script"
puts stdout "executing properly on the instrument has increased significantly"
exit 1

144
utils/check/sanscheck Executable file
View File

@ -0,0 +1,144 @@
#! /bin/sh
#next line is executed by sh, not by Tcl \
exec tclsh $0 ${1+"$@"}
#--------------------------------------------------------------------------
# This is the SICS syntax checker for the SANS small angle machine
#
# Mark Koennecke, March 2003
#--------------------------------------------------------------------------
source /data/koenneck/src/sics/utils/check/sicssyntaxlib.tcl
#------------------------- define SANS motors and aliases
sicsSyntaxMap som syntaxMotor
sicsSyntaxMap sax syntaxMotor
sicsSyntaxMap say syntaxMotor
sicsSyntaxMap saz syntaxMotor
sicsSyntaxMap spos syntaxMotor
sicsSyntaxMap mz syntaxMotor
sicsSyntaxMap mom syntaxMotor
sicsSyntaxMap gphi syntaxMotor
sicsSyntaxMap gtheta syntaxMotor
sicsSyntaxMap gomega syntaxMotor
sicsSyntaxMap detectorx syntaxMotor
sicsSyntaxMap detectory syntaxMotor
sicsSyntaxMap detectorrotation syntaxMotor
sicsSyntaxMap beamstopy syntaxMotor
sicsSyntaxMap beamstopx syntaxMotor
#------------ multimotors and their aliases
sicsSyntaxMap emagnetsampleholder mumoSyntax
set sicsPar(emagnetsampleholder.alias) [list z om]
set sicsPar(emagnetsampleholder.nampos) [list back]
sicsSyntaxMap msh mumoSyntax
set sicsPar(msh.alias) [list z om]
set sicsPar(msh.nampos) [list back]
sicsSyntaxMap cryomagnetsampleholder mumoSyntax
set sicsPar(cryomagnetsampleholder.alias) [list phi theta omega]
set sicsPar(cryomagnetsampleholder.nampos) [list back]
sicsSyntaxMap cryo mumoSyntax
set sicsPar(cryo.alias) [list phi theta omega]
set sicsPar(cryo.nampos) [list back]
sicsSyntaxMap sampletable mumoSyntax
set sicsPar(sampletable.alias) [list omega x y z posi]
set sicsPar(sampletable.nampos) [list back]
sicsSyntaxMap st mumoSyntax
set sicsPar(st.alias) [list omega x y z posi]
set sicsPar(st.nampos) [list back]
sicsSyntaxMap detector mumoSyntax
set sicsPar(detector.alias) [list x y phi]
set sicsPar(detector.nampos) [list back]
sicsSyntaxMap dt mumoSyntax
set sicsPar(dt.alias) [list x y phi]
set sicsPar(dt.nampos) [list back]
sicsSyntaxMap beamstop mumoSyntax
set sicsPar(beamstop.alias) [list x y]
set sicsPar(beamstop.nampos) [list back]
sicsSyntaxMap bs mumoSyntax
set sicsPar(bs.alias) [list x y]
set sicsPar(bs.nampos) [list back]
#------------ define SANS counters
sicsSyntaxMap counter syntaxCounter
sicsSyntaxMap banana syntaxHM
#------------ define SANS variables
sicsSyntaxMap title syntaxTextPar
sicsSyntaxMap user syntaxTextPar
sicsSyntaxMap collimation syntaxTextPar
sicsSyntaxMap sample syntaxTextPar
sicsSyntaxMap comment1 syntaxTextPar
sicsSyntaxMap comment2 syntaxTextPar
sicsSyntaxMap comment3 syntaxTextPar
sicsSyntaxMap fax syntaxTextPar
sicsSyntaxMap email syntaxTextPar
sicsSyntaxMap sample syntaxTextPar
sicsSyntaxMap lambda syntaxNumPar
sicsSyntaxMap nvs syntaxNumPar
#----------- define SANS environment
sicsSyntaxMap temperature evSyntax
sicsSyntaxMap tt evSyntax
#---------- define SANS auxiliary
sicsSyntaxMap beam syntaxDummy
sicsSyntaxMap detemp syntaxDummy
sicsSyntaxMap temp2 syntaxDummy
sicsSyntaxMap temp3 syntaxDummy
sicsSyntaxMap temp4 syntaxDummy
sicsSyntaxMap coll syntaxNumPar
sicsSyntaxMap att syntaxNumPar
sicsSyntaxMap shutter syntaxTextPar
sicsSyntaxMap bschange syntaxNumPar
sicsSyntaxMap qrange syntaxNumPar
sicsSyntaxMap bsin syntaxDummy
sicsSyntaxMap bsout syntaxDummy
#------------- SANS xy-tables
sicsSyntaxMap xydata0 syntaxXY
sicsSyntaxMap xydata1 syntaxXY
sicsSyntaxMap xydata2 syntaxXY
sicsSyntaxMap xydata3 syntaxXY
sicsSyntaxMap xydata4 syntaxXY
sicsSyntaxMap xydata5 syntaxXY
sicsSyntaxMap xydata6 syntaxXY
sicsSyntaxMap xydata7 syntaxXY
sicsSyntaxMap xydata8 syntaxXY
sicsSyntaxMap xydata9 syntaxXY
sicsSyntaxMap xydata syntaxXY
#--------- do we need this?
sicsSyntaxMap save syntaxDummy
sicsSyntaxMap SplitReply syntaxDummy
sicsSyntaxMap Publish syntaxDummy
#--------- Main checking stuff
if { $argc < 1} {
puts stdout "Usage: \n\tsanscheck filename"
exit 0
}
set filename [lindex $argv 0]
lappend fileList [file tail $filename]
puts stdout "Syntax checking --> $filename <-- ........."
source $filename
puts stdout "If this completed without errors the likelihoof of your script"
puts stdout "executing properly on the instrument has increased significantly"
exit 1

View File

@ -0,0 +1,86 @@
\documentclass[12pt,a4paper]{article}
%%\usepackage[dvips]{graphics}
%%\usepackage{epsf}
\setlength{\textheight}{24cm}
\setlength{\textwidth}{16cm}
\setlength{\headheight}{0cm}
\setlength{\headsep}{0cm}
\setlength{\topmargin}{0cm}
\setlength{\oddsidemargin}{0cm}
\setlength{\evensidemargin}{0cm}
\setlength{\hoffset}{0cm}
\setlength{\marginparwidth}{0cm}
\begin{document}
\begin{center}
\begin{Large}
SICS Syntax Checker\\
Implementation Notes\\
\end{Large}
Mark K\"onnecke\\
Mark.Koennecke@psi.ch\\
March/April 2003\\
Laboratory for Neutron Scattering\\
Paul Scherrer Institute\\
CH--5232 Villigen--PSI
Switzerland
\end{center}
Users wish to check their batch files for syntax errors before
submitting them to SICS for the weekend or the night. Unfortunately
checking SICS syntax is not so easy as it consists of Tcl syntax plus
SICS commands. In order to implement a syntax checker various
possibilities exist:\begin{itemize}
\item Implement the syntax checker as a calculation mode within
SICS. This has the disadvantage that the syntax check can only be run
by one person and only when the SICS server is not performing an
experiment. This is due to the fact, that SICS has only one set of
variables which may be changed dureing the syntax check. In order to
prevent corruption the security measures stated above are necessary.
\item Use a SICServer with simulated hardware. This would
work. Problems are that this is very time consuming to set up and the
synchronisation of parameter values with the main SICServer. This has
been solved through the sync command and thus this option is available
for complex scripts.
\item Use a Tcl interpreter with dummy SICS commands as a syntax
checker. In many cases batch files are fairly simple and a complete
simulation is not needed. The such a option would be sufficient.
\end{itemize}
\end{document}
\section{The Tcl Syntax Checker}
This section describes the syntax checker built from a Tcl interpreter
with dummy routines testing SICS syntax. The dummy procedures only
have to test the syntax and else do nothing. Not many such proecdures
have to be implemented but a means is needed for mapping names, for
instance motor names, to a suitable procedure for checking the syntax.
This syntax checker can be used in a variety of situations:
\begin{itemize}
\item Standalone: the preferred mode of operation
\item Within SICS: SICS would need to have a second Tcl interpreter
for this purpose in order to prevent corruption of the main
interpreter. Even then a rogue script could go into an endless loop
and thus hang the SICS server. Thus this second interpreter would have
to run as a separate process or thread.
\item This syntax checker could also help debugging SICS scripts.
\end{itemize}
For each instrument two files are needed for this syntax checker. The
first is a common library file which implements the syntax checking
procedures and the sics_alias procedure which maps names to
procedures. The second is a mapping file which defines the instrument
and enables those names the instrument provides. This is much like the
instrument initialization file for the main SICS program.
In order to help in script debugging, a global array with parameter
values defined through the user script will be maintained.
In a latter stage a connection to the main SICS could be added to the
system. Through this connection the actual configuration of the
instrument could be queried. Also parameter values can be updated in
order to help in debugging sophisticated scripts. Moreover this
connection could be used to check limit violations.

File diff suppressed because it is too large Load Diff

2
utils/check/test.tcl Normal file
View File

@ -0,0 +1,2 @@
drive mex -190

142
utils/check/topsicheck Executable file
View File

@ -0,0 +1,142 @@
#! /bin/sh
#next line is executed by sh, not by Tcl \
exec tclsh $0 ${1+"$@"}
#--------------------------------------------------------------------------
# This is the SICS syntax checker for the TOPSI diffractometer
#
# Mark Koennecke, March 2003
#--------------------------------------------------------------------------
source /data/koenneck/src/sics/utils/check/sicssyntaxlib.tcl
#------------------------- define TOPSI motors and aliases
sicsSyntaxMap d1r syntaxMotor
sicsSyntaxMap d1l syntaxMotor
sicsSyntaxMap d2r syntaxMotor
sicsSyntaxMap d2l syntaxMotor
sicsSyntaxMap d3r syntaxMotor
sicsSyntaxMap d3l syntaxMotor
sicsSyntaxMap dxt syntaxMotor
sicsSyntaxMap dxb syntaxMotor
sicsSyntaxMap utz syntaxMotor
sicsSyntaxMap uty syntaxMotor
sicsSyntaxMap sth syntaxMotor
sicsSyntaxMap stt syntaxMotor
sicsSyntaxMap stx syntaxMotor
sicsSyntaxMap sty syntaxMotor
sicsSyntaxMap sgx syntaxMotor
sicsSyntaxMap sgy syntaxMotor
sicsSyntaxMap utt syntaxMotor
sicsSyntaxMap scx syntaxMotor
sicsSyntaxMap scy syntaxMotor
sicsSyntaxMap po1 syntaxMotor
sicsSyntaxMap po2 syntaxMotor
sicsSyntaxMap mth syntaxMotor
sicsSyntaxMap mtt syntaxMotor
sicsSyntaxMap mtx syntaxMotor
sicsSyntaxMap mty syntaxMotor
sicsSyntaxMap mgx syntaxMotor
sicsSyntaxMap mfv syntaxMotor
sicsSyntaxMap d1b syntaxMotor
sicsSyntaxMap d2b syntaxMotor
sicsSyntaxMap d3b syntaxMotor
sicsSyntaxMap d1t syntaxMotor
sicsSyntaxMap d2t syntaxMotor
sicsSyntaxMap d3t syntaxMotor
#------------ aliases
sicsSyntaxMap s1r syntaxMotor
sicsSyntaxMap s1l syntaxMotor
sicsSyntaxMap s2r syntaxMotor
sicsSyntaxMap s2l syntaxMotor
sicsSyntaxMap s3r syntaxMotor
sicsSyntaxMap s3l syntaxMotor
sicsSyntaxMap a6 syntaxMotor
sicsSyntaxMap a5 syntaxMotor
sicsSyntaxMap a3 syntaxMotor
sicsSyntaxMap som syntaxMotor
sicsSyntaxMap th syntaxMotor
sicsSyntaxMap om syntaxMotor
sicsSyntaxMap a4 syntaxMotor
sicsSyntaxMap s2t syntaxMotor
sicsSyntaxMap tth syntaxMotor
sicsSyntaxMap 2t syntaxMotor
sicsSyntaxMap stu syntaxMotor
sicsSyntaxMap stl syntaxMotor
sicsSyntaxMap sgu syntaxMotor
sicsSyntaxMap sgl syntaxMotor
sicsSyntaxMap mgu syntaxMotor
sicsSyntaxMap sch syntaxMotor
sicsSyntaxMap sph syntaxMotor
sicsSyntaxMap pol syntaxMotor
sicsSyntaxMap ana syntaxMotor
sicsSyntaxMap a1 syntaxMotor
sicsSyntaxMap mom syntaxMotor
sicsSyntaxMap a2 syntaxMotor
sicsSyntaxMap m2t syntaxMotor
sicsSyntaxMap mtu syntaxMotor
sicsSyntaxMap mtl syntaxMotor
sicsSyntaxMap mcv syntaxMotor
sicsSyntaxMap sttl syntaxMotor
sicsSyntaxMap u2t syntaxMotor
#------------ define TOPSI counters
sicsSyntaxMap counter syntaxCounter
#------------ define TOPSI variables
sicsSyntaxMap title syntaxTextPar
sicsSyntaxMap user syntaxTextPar
sicsSyntaxMap collimation syntaxTextPar
sicsSyntaxMap sample syntaxTextPar
sicsSyntaxMap comment1 syntaxTextPar
sicsSyntaxMap comment2 syntaxTextPar
sicsSyntaxMap comment3 syntaxTextPar
sicsSyntaxMap fax syntaxTextPar
sicsSyntaxMap email syntaxTextPar
sicsSyntaxMap sample syntaxTextPar
sicsSyntaxMap lambda syntaxNumPar
#----------- define TOPSI environment
sicsSyntaxMap temperature evSyntax
sicsSyntaxMap tt evSyntax
#---------- define TOPSI auxiliary
sicsSyntaxMap beam syntaxDummy
sicsSyntaxMap o2t syntaxNumPar
sicsSyntaxMap o2tl syntaxNumPar
sicsSyntaxMap o2u syntaxNumPar
sicsSyntaxMap ttc syntaxTextPar
sicsSyntaxMap sttc syntaxTextPar
sicsSyntaxMap sef syntaxTextPar
sicsSyntaxMap remote syntaxTextPar
#------------------------------------------------------------------------
# some strange TOPSI commands with 3 numeric parameters
#-----------------------------------------------------------------------
proc dah {w1 w2 w3} {
if { [syntaxNumeric $w1] != 1 } {
error "ERROR: expected numeric w1, got $w1"
}
if { [syntaxNumeric $w2] != 1 } {
error "ERROR: expected numeric w2, got $w2"
}
if { [syntaxNumeric $w3] != 1 } {
error "ERROR: expected numeric w3, got $w3"
}
}
proc dav {w1 w2 w3} {
dah $w1 $w2 $w3
}
#--------- Main checking stuff
if { $argc < 1} {
puts stdout "Usage: \n\ttopsicheck filename"
exit 0
}
set filename [lindex $argv 0]
lappend fileList [file tail $filename]
puts stdout "Syntax checking --> $filename <-- ........."
source $filename
puts stdout "If this completed without errors the likelihoof of your script"
puts stdout "executing properly on the instrument has increased significantly"
exit 1

288
utils/check/tricscheck Executable file
View File

@ -0,0 +1,288 @@
#! /bin/sh
#next line is executed by sh, not by Tcl \
exec tclsh $0 ${1+"$@"}
#--------------------------------------------------------------------------
# This is the SICS syntax checker for the TRICS
#
# Mark Koennecke, March 2003
#--------------------------------------------------------------------------
source /data/koenneck/src/sics/utils/check/sicssyntaxlib.tcl
#------------ define TRICS motors and aliases
sicsSyntaxMap momu syntaxMotor
sicsSyntaxMap mtvu syntaxMotor
sicsSyntaxMap mtpu syntaxMotor
sicsSyntaxMap mgvu syntaxMotor
sicsSyntaxMap mgpu syntaxMotor
sicsSyntaxMap mcvu syntaxMotor
sicsSyntaxMap moml syntaxMotor
sicsSyntaxMap mtvl syntaxMotor
sicsSyntaxMap mtpl syntaxMotor
sicsSyntaxMap mgvl syntaxMotor
sicsSyntaxMap mcvl syntaxMotor
sicsSyntaxMap mexz syntaxMotor
sicsSyntaxMap cex1 syntaxMotor
sicsSyntaxMap som syntaxMotor
sicsSyntaxMap stt syntaxMotor
sicsSyntaxMap sch syntaxMotor
sicsSyntaxMap sph syntaxMotor
sicsSyntaxMap dg1 syntaxMotor
sicsSyntaxMap dg2 syntaxMotor
sicsSyntaxMap dg3 syntaxMotor
sicsSyntaxMap a17 syntaxMotor
sicsSyntaxMap a18 syntaxMotor
sicsSyntaxMap a1 syntaxMotor
sicsSyntaxMap a12 syntaxMotor
sicsSyntaxMap a13 syntaxMotor
sicsSyntaxMap a14 syntaxMotor
sicsSyntaxMap a15 syntaxMotor
sicsSyntaxMap a16 syntaxMotor
sicsSyntaxMap b1 syntaxMotor
sicsSyntaxMap a22 syntaxMotor
sicsSyntaxMap a23 syntaxMotor
sicsSyntaxMap a24 syntaxMotor
sicsSyntaxMap a25 syntaxMotor
sicsSyntaxMap a26 syntaxMotor
sicsSyntaxMap a37 syntaxMotor
sicsSyntaxMap a3 syntaxMotor
sicsSyntaxMap om syntaxMotor
sicsSyntaxMap a4 syntaxMotor
sicsSyntaxMap th syntaxMotor
sicsSyntaxMap a10 syntaxMotor
sicsSyntaxMap a20 syntaxMotor
sicsSyntaxMap ch syntaxMotor
sicsSyntaxMap chi syntaxMotor
sicsSyntaxMap ph syntaxMotor
sicsSyntaxMap a31 syntaxMotor
sicsSyntaxMap a32 syntaxMotor
sicsSyntaxMap a33 syntaxMotor
sicsSyntaxMap phi syntaxMotor
sicsSyntaxMap muca syntaxMotor
#------------ define TRICS counters
sicsSyntaxMap counter syntaxCounter
sicsSyntaxMap hm1 syntaxHM
sicsSyntaxMap hm2 syntaxHM
sicsSyntaxMap hm3 syntaxHM
#------------ define TRICS variables
sicsSyntaxMap title syntaxTextPar
sicsSyntaxMap user syntaxTextPar
sicsSyntaxMap adres syntaxTextPar
sicsSyntaxMap collimation syntaxTextPar
sicsSyntaxMap sample syntaxTextPar
sicsSyntaxMap comment1 syntaxTextPar
sicsSyntaxMap comment2 syntaxTextPar
sicsSyntaxMap comment3 syntaxTextPar
sicsSyntaxMap fax syntaxTextPar
sicsSyntaxMap email syntaxTextPar
sicsSyntaxMap sample syntaxTextPar
#----------- define TRICS environment
sicsSyntaxMap temperature evSyntax
sicsSyntaxMap tt evSyntax
#---------- define TRICS auxiliary
proc xbu {fname} {
fileeval $fname
}
proc exe {fname} {
fileeval $fname
}
proc do {fname} {
fileeval $fname
}
sicsSyntaxMap o2t syntaxNumPar
sicsSyntaxMap four syntaxTextPar
sicsSyntaxMap hmc hmcSyntax
sicsSyntaxMap hkl syntaxHKL
sicsSyntaxMap opti optiSyntax
sicsSyntaxMap rliste syntaxWarn
#-------------------------------------------------------------------------
# TRICS uses a couple of special scan commands with a special common
# syntax. This is defined here.
#-----------------------------------------------------------------------
proc tttscan { var start delta np {mode NULL} {preset NULL} } {
if { [syntaxNumeric $start] != 1} {
error "ERROR: $start is no number, expected scan start"
}
if { [syntaxNumeric $delta] != 1} {
error "ERROR: $delta is no number, expected scan step"
}
if { [syntaxNumeric $np] != 1} {
error "ERROR: $np is no number, expected scan noPoints"
}
if { [string compare $preset NULL] != 0 } {
if { [syntaxNumeric $preset] != 1} {
error "ERROR: $preset is no number, expected scan preset"
}
}
if { [string compare $mode NULL] != 0 } {
set mode [string trim [string tolower $mode]]
if { [syntaxCounterMode $mode] != 1} {
error "ERROR: $mode is no valid count mode!"
}
}
syntaxLimit $var $start
syntaxLimit $var [expr $start + $np*$delta]
}
proc tricsscan {start step np {mode NULL} {preset NULL} } {
tttscan om $start $step $np $mode $preset
}
proc detscan {start step np {mode NULL} {preset NULL} } {
tttscan stt $start $step $np $mode $preset
}
proc phscan {start step np {mode NULL} {preset NULL} } {
tttscan ph $start $step $np $mode $preset
}
#----------------------------------------------------------------------
# psdrefscan syntax. I wonder if anyone is using this........
#-----------------------------------------------------------------------
proc psdrefscan {filename step {mode NULL} {preset NULL}} {
if { [syntaxNumeric $step] != 1} {
error "ERROR: $step is no number, expected scan step"
}
if { [syntaxNumeric $np] != 1} {
error "ERROR: $np is no number, expected scan noPoints"
}
if { [string compare $preset NULL] != 0 } {
if { [syntaxNumeric $preset] != 1} {
error "ERROR: $preset is no number, expected scan preset"
}
}
if { [string compare $mode NULL] != 0 } {
set mode [string trim [string tolower $mode]]
if { [syntaxCountMode $mode] != 1} {
error "ERROR: $mode is no valid count mode!"
}
}
}
#----------------------------------------------------------------------
# mess measures a whole file with reflections
#----------------------------------------------------------------------
lappend messKey start file nb bi close writereflection
proc mess args {
global messKey sicsPar
if { [llength $args] < 1} {
error "ERROR: need subcommand to mess"
}
set subcommand [string trim [string tolower [lindex $args 0]]]
if { [lsearch $messKey $subcommand] >= 0} {
return
}
switch $subcommand {
preset -
np -
step -
compact {
if { [llength $args] > 1} {
set val [lindex $args 1]
if { [syntaxNumeric $val] != 1} {
error \
"ERROR: expected numeric par to $subcommand, got $val"
}
set sicsPar(mess.$subcommand) $val
} else {
return [syntaxGet mess.$subcommand]
}
}
mode -
countmode {
if { [llength $args] > 1} {
set val [lindex $args 1]
if { [syntaxCounterMode $val] != 1} {
error ERROR: expected counter mode, got $val
}
set sicsPar(mess.mode) $val
} else {
return [syntaxGet mess.mode]
}
}
reopen -
genlist -
measure {
if { [llength $args] < 2} {
error "ERROR: no filename to process for $subcommand"
}
}
default {
error "ERROR: subcommand $subcommand to mess not known"
}
}
}
#-------------------------------------------------------------------------
# The local maximum search command
#------------------------------------------------------------------------
lappend lomaPar window threshold steepness cogwindow cogcontour
proc lomax args {
global lomaPar sicsPar
if { [llength $args] < 1} {
error "ERROR: need subcommand to lomax"
}
set subcommand [string trim [string tolower [lindex $args 0]]]
if { [lsearch $lomaPar $subcommand] >= 0} {
if { [llength $args] > 1} {
set val [lindex $args 1]
if { [syntaxNumeric $val] != 1} {
error "ERROR: expected numeric arg to $subcommand, got $val"
}
set sicsPar(lomax.$subcommand) $val
} else {
return [syntaxGet lomax.$subcommand]
}
}
switch $subcommand {
stat -
search {
if { [llength $args] < 2} {
error "ERROR: need a hm to $subcommand"
}
set p [string trim [string tolower [lindex $args 1]]]
set ret [catch {info body $p} msg]
if { $ret != 0 } {
error [format "ERROR: no %s to $subcommand found" $p]
}
}
cog {
if { [llength $args] < 4} {
error "ERROR: not enough arguments to lomax cog"
}
set p [string trim [string tolower [lindex $args 1]]]
set ret [catch {info body $p} msg]
if { $ret != 0 } {
error [format "ERROR: no %s to calc COG fromfound" $p]
}
for {set i 2} {$i < [llength $args]} {incr i} {
set val [lindex $args $i]
if { [syntaxNumeric $val] != 1} {
error "ERROR: expected numeric par to cog, got $val"
}
}
}
default {
error "ERROR: subcommand $subcommand to lomax not known"
}
}
}
#--------------------------- main program --------------------------------
#syntaxLoadSICS amorstatus.tcl
#puts stdout [array names sicsPar]
if { $argc < 1} {
puts stdout "Usage: \n\ttricscheck filename"
exit 0
}
set filename [lindex $argv 0]
lappend fileList [file tail $filename]
puts stdout "Syntax checking --> $filename <-- ........."
source $filename
puts stdout "If this completed without errors the likelihoof of your script"
puts stdout "executing properly on the instrument has increased significantly"
exit 1

0
utils/check/tst Normal file
View File

242
utils/ecb-load.c Normal file
View File

@ -0,0 +1,242 @@
/***************************************************************************
* This file contains the download program the ECB system.
* It reads a Tek-hex formated file and downloads it to the ECB-system.
* The lowest address is used as the start address of the program.
*
* Project: ECB-C
* Filename: ecb_load.c
*
* Author: L. S. Jensen 18. Feb 1993
*
* Heavily reworked by code transfusions from tascom in order to
* support new ECB file format.
*
* Mark Koennecke, May 2003
*
* Copyright (C) Risoe National Laboratory, 1993, All rights reserved
****************************************************************************/
#include <stdio.h>
#include <string.h>
#include "ecb-drv.h" /* The ecb driver interface. */
#define MAX_BUFFER_SIZE 32767 /* Max. RAM in ECB system */
#define LINE_SIZE 128
#define LAST_LINE -125
#define CHECKSUM_ERR -100
#define FORMAT_ERR -101
#define FILE_ERR -102
#define CSTART_CODE 171 /* The number of ECB function cstart */
#define FOREVER 1 /* Used in a loop */
#define ECB_BYTES 65536L
#define ECB_DOWN_LOAD 178
#define LOAD_NEXT 1
/*****************************************************************************
* Local variables in this file.
*****************************************************************************/
static char buffer[MAX_BUFFER_SIZE];
static int debug = 0;
/*******************************************************************************
* Convert HEX to bin
*******************************************************************************/
static int look_up[] = {10, 11, 12, 13, 14 ,15};
static unsigned long
Hex_to_bin(char c)
{
if(isdigit((int) c))
return (c - '0');
else
return look_up[c - 'A'];
}
/*******************************************************************************
* Convert Bin to HEX
*******************************************************************************/
static char
Bin_to_hex (int i)
{
if(i <= 9)
return ( (char)(i + (int)('0')) );
else
return ( (char)( (i - 10) + (int)('A')) );
}
/***************************************************************************
* This function creates blocks as large as possible of consecutive data
* bytes from the hex file in order to speed up the data transfer by
* sending blocks of data to the ECB system rather than single lines.
****************************************************************************/
static Z80_reg x_outreg, x_inreg;
static long
Send_blocks(FILE *fp, Gpib_dev dev)
{
char line[LINE_SIZE];
char *point;
int line_not_output, byte_count, line_no,type, no_bytes,total_bytes;
int load_count = -1, function;
unsigned char x_ecb_data[ECB_BYTES]; /* Array to hold data blocks for ECB */
unsigned long adrs, old_adrs, total0, total1, total2;
void *line9 = &line[9];
unsigned short address;
for (;;)
{
if (line_not_output == 1)
line_not_output = 0; /* Start with old line */
else
{ /* Read a line from file */
point = fgets (line, LINE_SIZE, fp);
if (point != NULL)
{
byte_count = strlen(line);
byte_count -= 4; /* Remove checksum and \n in the */
line[byte_count+1] = '\0'; /* line, i.e. the four last characters */
line[0] = '0'; /* Replace : in line[0] with 0 */
}
else
{
if (!ferror(fp))
byte_count = 0;
else
{
fclose (fp);
fp = NULL;
return(FILE_ERR);
}
}
}
line_no += 1;
if (byte_count != 0)
{
if (line_no == 1)
strcpy (x_ecb_data, line);
type = (Hex_to_bin(line[7]) << 4) + Hex_to_bin(line[8]);
if (type != 0)
{
if (line_no > 1) /* Output buffer and mark that */
line_not_output = 1; /* last input line has not been output */
}
else
{
no_bytes = (Hex_to_bin(line[1]) << 4) + Hex_to_bin(line[2]);
adrs = (Hex_to_bin(line[3]) << 12) + (Hex_to_bin(line[4]) << 8) +
(Hex_to_bin(line[5]) << 4) + Hex_to_bin(line[6]);
if (line_no == 1)
{
total_bytes = no_bytes;
old_adrs = adrs;
continue; /* Get next input line */
}
else
{
if (old_adrs + no_bytes == adrs)
{ /* Contigious addresses */
total_bytes += no_bytes;
old_adrs = adrs;
strcat (x_ecb_data, line9); /* Add the new bytes to buffer */
total0 = total_bytes/256; /* and adjust number of bytes */
x_ecb_data[0] = Bin_to_hex(total0);
total1 = total_bytes - 256*total0;
total2 = total1/16;
x_ecb_data[1] = Bin_to_hex(total2);
x_ecb_data[2] = Bin_to_hex(total1 - 16*total2);
if (line_no < 20) /* Max 20 lines together */
continue; /* Get next input line */
}
}
line_not_output = 0; /* Output buffer, nothing waiting in line[] */
}
address = 1;
byte_count = strlen (x_ecb_data);
Ecb_write (dev, x_ecb_data,byte_count,1); /* Write a line to ECB */
line_no = 0;
if (load_count == -1) /* Type Loading followed by dots while */
{ /* down loading the file */
printf ("Loading");
load_count = 0;
}
load_count += 1;
if (load_count > 15)
{
printf (".");
load_count = 0;
}
function = ECB_DOWN_LOAD;
Ecb_func (dev, function,x_inreg); /* Call ECB download function */
if (x_outreg.b != LOAD_NEXT) /* Wait for reply from ECB */
break; /* If LOAD_NEXT, get next line, else finished */
}
}
printf("\nLoading completed\n");
}
/****************************************************************************
* Handles error in gpib driver.
****************************************************************************/
void
Exit_code(int status)
{
if(debug)
printf("exit status %d", status);
exit(status);
}
/****************************************************************************
*
****************************************************************************/
int
main(int argc, char *argv[])
{
Gpib_dev dev;
int dev_no;
FILE *record_fp;
long start_adr;
Z80_reg z80;
if (argc < 4|| argc > 5)
{
printf("used: %s Gpib-driver-name ECB-device-number ECB-hex-filename\n",
argv[0]);
exit(GPIB_ERR);
}
if (argc == 5)
{
if ((0 == strcasecmp(argv[4],"DEBUG"))||(0 == strcasecmp(argv[4],"VERBOSE")))
debug = 1;
}
record_fp = fopen(argv[3], "rb"); /* Open in read-only mode in binary mode */
if (record_fp == NULL)
{
printf("used: %s Gpib-driver-name ECB-device-number ECB-hex-filename\n",
argv[0]);
exit(FILE_ERR);
}
dev = Ecb_unit(argv[1], argv[2]); /* Open the ECB device */
start_adr = Send_blocks(record_fp, dev);
if (start_adr < 0) /* An error */
exit(start_adr);
z80.d = start_adr; /* Lsb part in Z80 reg. D */
z80.e = start_adr>>8; /* Msb part in Z80 reg. E */
Ecb_func(dev, CSTART_CODE, z80); /* And start the ecb-c program. */
return;
}

2087
utils/el734.c Executable file

File diff suppressed because it is too large Load Diff

4133
utils/el734_test.c Executable file

File diff suppressed because it is too large Load Diff

2848
utils/el737.c Executable file

File diff suppressed because it is too large Load Diff

26
utils/make.ecb Normal file
View File

@ -0,0 +1,26 @@
#
# Makefile for the ECB load program on Linux, PSI setup
CC =cc
CFLAGS = -g -I$(SINQDIR)/linux/include
OBJS = ecb-drv.o ecb-load.o gpib-drv.o
LIBS = $(SINQDIR)/linux/lib/libgpibenet.so
#########################################################################
ecb-load: $(OBJS)
$(CC) -g -o ecb-load $(OBJS) $(LIBS) -lfl
ecb-drv.o: ecb-drv.c ecb-drv.h gpib-drv.h
$(CC) $(CFLAGS) -c ecb-drv.c
ecb-load.o: ecb-load.c ecb-drv.h gpib-drv.h
$(CC) $(CFLAGS) -c ecb-load.c
gpib-drv.o: gpib-drv.c gpib-drv.h
$(CC) $(CFLAGS) -c gpib-drv.c
clean:
-rm *~
-rm $(OBJS)
-rm ecb-load
-rm core