Histmem now only calls TaskYield after SICS has finished initalising, this stops the statusfile task from being called early and overwriting the status file. Created ANSTO_MakeHistMemory command to install ANSTO_HistAction Added veto functions. Mapped the HistDriver interface Pause() and Continue() commands to AnstoHttpVeto and AnstoHttpNoVeto. Implemented an ANSTO_Histaction to call AnstoHttpPause when sent a "pause" subcommand. hmcontrol_ansto.c Call AnstoHttpPause() directly when Pause_HM_After_Count is set to preserver current behaviour. counterdriv.c Now sends the correct "SICS RESUME" command to resume a paused count. ansto_sctdriveadapter.c NEW This lets you create driveable objects from script-context controllers which have one node for setting a parameter and another node for reading the parameter (eg temperature controllers, choppers, velocity selectors) sctemonadapter.c NEW This generates an environment monitor interface for script-context controllers so that the emon object in SICS will be able to pause counters if the controller goes out of tolerance. sct_usbtmcprot.c, usbtmc.h NEW First attempt at a protocol handler for USB Test and Measurement Class devices sct_julabo_lh45.tcl NEW Implements script-context controller for the Julabo LH45 temperature controller. Makefile Added ansto_sctdriveadapter and sctemonadapter hardsup/makefile Added velocity selector and usbtmc protocol handlers hardsup/sct_velselprot.c Simplified, don't worry about trying to implement a login handler for now, just implement a "Reading" handler. site_ansto.c Add the velocity selector and USBTMC protocol handlers. Added the ANSTO_MakeHM command instrument/config/hipadaba/common_instrument_dictionary.tcl Added support for auxiliary data, ie extra meta-data entries in the "data" group of the nexus file. Add new NXvelocity_selector object under /instrument. instrument/config/hipadaba/hipadaba_configuration_common.tcl Add the new "sct_object" script-context controller objects to the hdb tree. instrument/config/hipadaba/instdict_specification.tcl Define the new sct_object controllers. instrument/config/hmm/hmm_configuration_common_1.tcl Use the new ANSTO_MakeHM command to create histmem drivers which support veto. Define allowed attributes and elements for the BAT_TABLE and FAT_TABLE Stop between counts instead of pausing because setting pause now sends a veto. instrument/config/motors/sct_jogmotor_common.tcl You now need to specify klass when creating a jogmotor. instrument/config/motors/sct_positmotor_common.tcl You can now specify an optional function which calculates the instrument parameter (eg attenuation) from a posit table entry when defining a posit motor. instrument/config/nexus/nxscripts_common_1.tcl Report file status info in the /experiment section of the hdb tree. Add auxiliary data to data file. Handle saving data from script-context controller objects. instrument/util/script_context_util.tcl Added procedure to set required properties for saving script-context object data. instrument/util/utility.tcl Added set_sct_object_attributes proc to automatically set required attributes on SCT_OBJECTs Fixed hlistplainprop to deal with empty property fields on hdb nodes. instrument/server_config.tcl Call the new nexus initialisation command and set attributes on sct objects. hrpd/config/motors/motor_configuration.tcl New absenc home readings for mchi and mphi. New absenc home and range for mf1 hipd/config/commands/commands.tcl Exported and published the new ajscmds so that they can be used in batch files. hipd/config/motors/motor_configuration.tcl New mchi absenc home rsd/config/hmm/hmm_configuration.tcl Provide support for saving corrected hmm data rsd/config/motors/motor_configuration.tcl Use simple names for motors. SICS-329 sans/config/INSTCFCOMMON.TXT Added julabo and lakeshore configuration files to list. sans/config/optics/guide_configuration.tcl Added entrance aperture positions to the configuration table and the cn_maps which map the index to the component ID. sans/commands/commands.tcl The "guide" command now set EApPosYmm after driving the guides in place. The indexed position to component maps (cn_map) have been moved to the guide_configuration.tcl file. sans/motors/motor_configuration.tcl Set samy home to 56.1mm sans/config/velsel/sct_velsel.tc NEW Implements script-context controller object for the NVS40 velocity selector. TODO tilt-angle control, driveable interface. sans/config/hmm/hmm_configuration.tcl Set 5.08mm spacing on detector width. Use pixel-offset for vertical and horizontal detector axes. sans/config/motors/motor_configuration.tcl Swap directions of beamstops 4 and 5 (the two smallest) New config parameters for samx, samthet, apx, det, detoff, bsz, sans/config/motors/positmotor_configuration.tcl Added descriptive headers to positmotor configuration tables and new synstax for the make positmotor command. sans/config/nexus/nxscripts.tcl Implemented initialisation command. sans/config/parameters/parameters.tcl Added SampleThickness and TransmissionFlag. Calculate SamplePosYmm from samy and SamyOffsetmm. Added beamstops to hdb tree. reflectometer/config/nexus/nxscripts.tcl Implement the initialisation procedure. r2767 | ffr | 2009-03-31 10:16:54 +1100 (Tue, 31 Mar 2009) | 123 lines
317 lines
9.7 KiB
C
317 lines
9.7 KiB
C
/*------------------------------------------------------------------------
|
|
File: anstoSite.c
|
|
|
|
This is the site specific interface to SICS for ANSTO. This file implements
|
|
the interface defined in ../site.h
|
|
|
|
Copyright: see file Copyright.txt
|
|
|
|
Template: Mark Koennecke, June 2003
|
|
Nick Hauser, Paul Hathaway, May 2004
|
|
-----------------------------------------------------------------------*/
|
|
#include <stdlib.h>
|
|
#include <assert.h>
|
|
#include <fortify.h>
|
|
#include <sics.h>
|
|
#include <motor.h>
|
|
#include <asyncprotocol.h>
|
|
#include <asyncqueue.h>
|
|
#include <tcl.h>
|
|
#include <site.h>
|
|
#include <SCinter.h>
|
|
|
|
#include "protocol.h"
|
|
/* site-specific driver header files */
|
|
#include "motor_dmc2280.h"
|
|
#include "motor_asim.h"
|
|
#include "itc4.h"
|
|
/* Added code for new LH45 and Lakeshore 340 drivers */
|
|
#include "lh45.h"
|
|
#include "lakeshore340.h"
|
|
#include "west4100.h"
|
|
/* Added HTTP support for ANSTO OPAL NBI Histogram Server */
|
|
#include "anstohttp.h"
|
|
#include "anstoutil.h"
|
|
/* Added customized HMControl object to support ANSTO OPAL NBI Histogram Server */
|
|
#include "hmcontrol.h"
|
|
#include "hmcontrol_ansto.h" // extends hmcontrol.h
|
|
/* Added code for NHQ200 HV Power Supply */
|
|
#include "nhq200.h"
|
|
/* Added code for Oak Ridge High Voltage Power Supply */
|
|
#include "orhvps.h"
|
|
/* Added code for new LS340 LAKESORE 340 Temperature Controller */
|
|
#include "ls340.h"
|
|
|
|
#include "safetyplc.h"
|
|
#include "lssmonitor.h"
|
|
#include "beamstopaction.h"
|
|
|
|
/*@observer@*//*@null@*/ pCounterDriver CreateMonCounter(/*@observer@*/SConnection *pCon, /*@observer@*/char *name, char *params);
|
|
|
|
/*
|
|
from tcpdornier.c
|
|
*/
|
|
extern int VelSelTcpFactory(SConnection *pCon, SicsInterp *pSics, void *pData, int argc, char *argv[]);
|
|
extern pCodri MakeTcpDoChoDriver(char *tclArray, SConnection *pCon);
|
|
extern void AddGalilProtocoll();
|
|
extern void AddOrdHVPSProtocoll();
|
|
extern void AddVelSelProtocol();
|
|
extern void AddUSBTMCProtocoll();
|
|
extern int ANSTO_MakeHistMemory(SConnection *pCon, SicsInterp *pSics, void *pData, int argc, char *argv[]);
|
|
|
|
|
|
void SiteInit(void) {
|
|
int NetWatchInit(void);
|
|
NetWatchInit();
|
|
#define INIT(F) { void F(void); F(); }
|
|
/* insert here initialization routines ... */
|
|
INIT(SctEmonInit);
|
|
INIT(ANSTO_SctDriveInit);
|
|
AddGalilProtocoll();
|
|
AddOrdHVPSProtocoll();
|
|
AddVelSelProtocol();
|
|
AddUSBTMCProtocoll();
|
|
}
|
|
|
|
static pSite /*@null@*/ siteANSTO = NULL;
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
static void AddCommands(SicsInterp *pInter)
|
|
{
|
|
DMC2280InitProtocol(pInter);
|
|
SafetyPLCInitProtocol(pInter);
|
|
LSSInitProtocol(pInter);
|
|
NHQ200InitProtocol(pInter);
|
|
ORHVPSInitProtocol(pInter);
|
|
LS340InitProtocol(pInter);
|
|
AddCommand(pInter,"InstallProtocolHandler", InstallProtocol,NULL,NULL);
|
|
AddCommand(pInter,"MakeTCPSelector",VelSelTcpFactory,NULL,NULL);
|
|
AddCommand(pInter,"portnum",portNumCmd,NULL,NULL);
|
|
AddCommand(pInter,"abortbatch",AbortBatch,NULL,NULL);
|
|
AddCommand(pInter,"MakeHMControl_ANSTO",MakeHMControl_ANSTO,NULL,NULL);
|
|
// AddCommand(pInter,"MakeAsyncProtocol",AsyncProtocolFactory,NULL,NULL);
|
|
// AddCommand(pInter,"MakeAsyncQueue",AsyncQueueFactory,NULL,NULL);
|
|
AddCommand(pInter,"MakeMultiChan",AsyncQueueFactory,NULL,NULL);
|
|
AddCommand(pInter,"MakeSafetyPLC",SafetyPLCFactory,NULL,NULL);
|
|
AddCommand(pInter,"MakeLSSMonitor",LSSFactory,NULL,NULL);
|
|
AddCommand(pInter,"MakeActionObject",ActionObjectFactory,NULL,NULL);
|
|
AddCommand(pInter,"ANSTO_MakeHM",ANSTO_MakeHistMemory,NULL,NULL);
|
|
}
|
|
/*---------------------------------------------------------------------*/
|
|
static void RemoveCommands(SicsInterp *pSics){
|
|
}
|
|
/*-------------------------------------------------------------------*/
|
|
/*@null@*/ static pMotor CreateMotorAnsto(SConnection *pCon, int argc, char *argv[])
|
|
{
|
|
MotorDriver *pDriver = NULL;
|
|
pMotor pNew = NULL;
|
|
char pBueffel[132];
|
|
|
|
/* create the motor */
|
|
strtolower(argv[1]);
|
|
if(strcmp(argv[1],"dmc2280") == 0) {
|
|
pDriver = (MotorDriver *)CreateDMC2280(pCon,argv[0],argv[2]);
|
|
if(!pDriver){
|
|
return NULL;
|
|
}
|
|
pNew = MotorInit("DMC2280",argv[0],pDriver);
|
|
if(!pNew) {
|
|
sprintf(pBueffel,"ERROR:SITE: Failure to create motor %s",argv[1]);
|
|
SCWrite(pCon,pBueffel,eError);
|
|
return NULL;
|
|
}
|
|
pNew->pActionRoutine = DMC2280Action;
|
|
}
|
|
if(strcmp(argv[1],"asim") == 0) {
|
|
pDriver = (MotorDriver *)CreateASIM(pCon,argv[0],argv[2]);
|
|
if(!pDriver){
|
|
return NULL;
|
|
}
|
|
pNew = MotorInit("ASIM",argv[0],pDriver);
|
|
if(!pNew) {
|
|
sprintf(pBueffel,"ERROR:SITE: Failure to create motor %s",argv[1]);
|
|
SCWrite(pCon,pBueffel,eError);
|
|
return NULL;
|
|
}
|
|
pNew->pActionRoutine = SimAction;
|
|
}
|
|
|
|
|
|
|
|
return pNew;
|
|
}
|
|
/*-------------------------------------------------------------------*/
|
|
static pCounterDriver CreateCounterDriverAnsto(SConnection *pCon,
|
|
int argc,
|
|
char *argv[]){
|
|
pCounterDriver pDriver = NULL;
|
|
strtolower(argv[2]);
|
|
if(strcmp(argv[2],"anstomonitor") == 0) {
|
|
pDriver = CreateMonCounter(pCon, argv[1], argv[3]);
|
|
}
|
|
if(!pDriver){
|
|
return NULL;
|
|
}
|
|
return pDriver;
|
|
}
|
|
/*-------------------------------------------------------------------*/
|
|
static HistDriver *CreateAnstoHistMem(char *name, pStringDict pOptions){
|
|
HistDriver *pNew = NULL;
|
|
|
|
if(strcmp(name,"anstohttp") == 0){
|
|
pNew = CreateAnstoHttpDriver(pOptions);
|
|
}
|
|
return pNew;
|
|
}
|
|
/*-------------------------------------------------------------------*/
|
|
static pVelSelDriv CreateVelSelDriv(char *name, char *array,
|
|
Tcl_Interp *pTcl){
|
|
pVelSelDriv pNew = NULL;
|
|
return pNew;
|
|
}
|
|
/*-------------------------------------------------------------------*/
|
|
static pCodri CreateController(SConnection *pCon,int argc, char *argv[]){
|
|
pCodri pNew = NULL;
|
|
if(strcmp(argv[0],"tcpdocho") == 0){
|
|
if(argc < 2){
|
|
SCWrite(pCon,"ERROR: insufficient number of arguments for creating TcpDoCho",
|
|
eError);
|
|
return NULL;
|
|
}
|
|
return MakeTcpDoChoDriver(argv[1], pCon);
|
|
}
|
|
return pNew;
|
|
}
|
|
/*------------------------------------------------------------------*/
|
|
static pEVControl InstallEnvironmentController(SicsInterp *pSics,
|
|
SConnection *pCon,
|
|
int argc, char *argv[]){
|
|
int status;
|
|
pEVControl pNew = NULL;
|
|
pEVDriver pDriv = NULL;
|
|
strtolower(argv[3]);
|
|
|
|
|
|
/* Added code for new LH45 driver */
|
|
if(strcmp(argv[3],"lh45") == 0) {
|
|
pDriv = CreateLH45Driver(argc-4,&argv[4]);
|
|
if(pDriv){
|
|
pNew = CreateEVController(pDriv,argv[2],&status);
|
|
if(pNew != NULL){
|
|
AddCommand(pSics,argv[2],LH45Wrapper,DeleteEVController,
|
|
pNew);
|
|
}
|
|
}
|
|
}
|
|
|
|
/* Added code for new Lakeshore 340 driver */
|
|
if(strcmp(argv[3],"lakeshore340") == 0) {
|
|
pDriv = CreateLAKESHORE340Driver(argc-4,&argv[4]);
|
|
if(pDriv){
|
|
pNew = CreateEVController(pDriv,argv[2],&status);
|
|
if(pNew != NULL){
|
|
AddCommand(pSics,argv[2],LAKESHORE340Wrapper,DeleteEVController,
|
|
pNew);
|
|
}
|
|
}
|
|
}
|
|
|
|
/* Added code for new Lakeshore 340 driver */
|
|
if(strcmp(argv[3],"west4100") == 0) {
|
|
pDriv = CreateWEST4100Driver(argc-4,&argv[4]);
|
|
if(pDriv){
|
|
pNew = CreateEVController(pDriv,argv[2],&status);
|
|
if(pNew != NULL){
|
|
AddCommand(pSics,argv[2],WEST4100Wrapper,DeleteEVController,
|
|
pNew);
|
|
}
|
|
}
|
|
}
|
|
|
|
/* Added code for new NHQ 200 driver */
|
|
if(strcmp(argv[3],"nhq200") == 0) {
|
|
pDriv = CreateNHQ200Driver(argc-4,&argv[4]);
|
|
if(pDriv){
|
|
pNew = CreateEVController(pDriv,argv[2],&status);
|
|
if(pNew != NULL){
|
|
NHQ200Register(pNew, pDriv);
|
|
AddCommand(pSics,argv[2],NHQ200Wrapper,DeleteEVController,
|
|
pNew);
|
|
}
|
|
}
|
|
}
|
|
|
|
/* Added code for new Oak Ridge High Voltage Power Supply driver */
|
|
if(strcmp(argv[3],"orhvps") == 0) {
|
|
pDriv = CreateORHVPSDriver(argc-4,&argv[4]);
|
|
if(pDriv){
|
|
pNew = CreateEVController(pDriv,argv[2],&status);
|
|
if(pNew != NULL){
|
|
ORHVPSRegister(pNew, pDriv);
|
|
AddCommand(pSics,argv[2],ORHVPSWrapper,DeleteEVController,
|
|
pNew);
|
|
}
|
|
}
|
|
}
|
|
|
|
/* Added code for new LS340 LAKSHORE Temperature Controller 340 Driver */
|
|
if(strcmp(argv[3],"ls340") == 0) {
|
|
pDriv = CreateLS340Driver(argc,argv);
|
|
if(pDriv){
|
|
pNew = CreateEVController(pDriv,argv[2],&status);
|
|
if(pNew != NULL){
|
|
LS340Register(pNew, pDriv);
|
|
AddCommand(pSics,argv[2],LS340Wrapper,DeleteEVController,
|
|
pNew);
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
return pNew;
|
|
}
|
|
/*-----------------------------------------------------------------*/
|
|
static int ConfigureScan(pScanData self, char *option){
|
|
if(!self) {
|
|
return 0;
|
|
}
|
|
|
|
return 0;
|
|
}
|
|
/*--------------------------------------------------------------------*/
|
|
static void KillSite(void *site){
|
|
free(site);
|
|
siteANSTO = NULL;
|
|
}
|
|
/*---------------------------------------------------------------------
|
|
The scheme here goes along the lines of the singleton design pattern
|
|
---------------------------------------------------------------------*/
|
|
pSite getSite(void)
|
|
{
|
|
if(siteANSTO == NULL)
|
|
{
|
|
siteANSTO = (pSite)malloc(sizeof(Site));
|
|
/*
|
|
we cannot go on if we do not even have enough memory to allocate
|
|
the site data structure
|
|
*/
|
|
assert(siteANSTO);
|
|
/*
|
|
initializing function pointers
|
|
*/
|
|
siteANSTO->AddSiteCommands = AddCommands;
|
|
siteANSTO->RemoveSiteCommands = RemoveCommands;
|
|
siteANSTO->CreateMotor = CreateMotorAnsto;
|
|
siteANSTO->CreateCounterDriver = CreateCounterDriverAnsto;
|
|
siteANSTO->CreateHistogramMemoryDriver = CreateAnstoHistMem;
|
|
siteANSTO->CreateVelocitySelector = CreateVelSelDriv;
|
|
siteANSTO->CreateControllerDriver = CreateController;
|
|
siteANSTO->InstallEnvironmentController = InstallEnvironmentController;
|
|
siteANSTO->ConfigureScan = ConfigureScan;
|
|
siteANSTO->KillSite = KillSite;
|
|
}
|
|
return siteANSTO;
|
|
}
|
|
|