Implements a protocol handler for the protek 608 multimeters which just allows us to read the display. It reports all elements of the display including the bar graph, it does not provide remote control of the multimeter. The protocol handler broadcasts a warning to all clients if the auto-off function is enabled. sct_rfamp.c This is a protocol handler for the Mirrortron 35V 7A AC Generator (ANSFR-83B). sinqhttpprot.c Copied the PSI script context http protocol handler. sct_orhvpsprot.c Ordela high voltage power supply protocol handler now catches unknown commands. sct_eurotherm_2000.tcl Eurotherm controller for the kowari load frame by Douglas Clowes. sct_lakeshore_3xx.tcl Latest update from Arndt. The two control loops are now independent, settletime and tolerance now work properly. common_instrument_dictionary.tcl Make instrument/status saveable. sct_orhvps_common.tcl Provides voltage ramping and implements the dhv1 command for the Ordela HVPS via the sct_orhpsprot.c protocol handler. hmm_configuration_common_1.tcl Adds new "histmem clockscale" subcommand to get and set the clock scale from the fat_clock_scale FAT parameter. You can now upload the FAT FRAME_BUFFER and FRAME_DUTYCYCLE parameters to the histogram memory. The veto commands are now "histmem veto on" and "histmem veto off". hmm_object.tcl The axis order for the histmem object has been restore to t,y,x sct_positmotor_common.tcl Code has been simplified. nxscripts_common_1.tcl Removed obsolete ::nexus::data function. TOF axis now correctly report time_of_flight instead of "time". plc_common_1.tcl Make PLC info saveable. scan_common_1.tcl SICS-385 The scan command should check the final scan variable value against he soft upper and lower limits, not against the hard limits. Make sure that the scan variable axis is saved. platypus, kowari, quokka hmm_configuration.tcl Use the HOR and VER entries in the new histmem_axes hash to select the horizontal and vertical axes for the histmem. kowari motor_configuration.tcl secondary_slit_configuration.tcl Flatten slits motor structure to match old layout in data files. quokka commands.tcl SICS-380 EApPosYmm -> EApPosY quokka detector.tcl Use new script context controller for Ordela HVPS quokka hmm_configuration.tcl Set detector height to 5.08*192 the same as the width quokka motor_configuration.tcl Code cleanup quokka positmotor_configuration.tcl Use new positmotor code. quokka aperture_configuration.tcl Added attenuation factor column to AttRotLookupTable quokka parameters.tcl SICS-380 Refactor nexus, remove redundant parameters. site_ansto.c Added the following protocols, Httpl, Protek608, aand RFAmp. scriptcontext.c SICS-386 SctActionHandler: set "send" string to NULL when a chain of scripts completes with state=idle. It turns out that if none of the scripts in the "read chain" call [sct send] each time the chain is executed, then SICS will hammer the device with calls to AsconWrite(). This can be avoided if SctActionHandler sets the 'send' string to NULL before "goto finish" in the idle state. This will be safer and still let you have chains with multiple [sct send] and read scripts. asyncprotocol.c Fix platypus memory leak. devser.c SICS-387 Started adding code to pass signals on to script context drivers. ascon.c AsconTask(): Make sure we return to the AsconIdle state when sending a command which expect no response, also only reconnect if there is a Timeout when there has been an error. r2888 | ffr | 2010-04-19 14:04:41 +1000 (Mon, 19 Apr 2010) | 90 lines
353 lines
11 KiB
C
353 lines
11 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 AddModbusProtocoll();
|
|
extern void AddOrdHVPSProtocoll();
|
|
extern void AddVelSelProtocol();
|
|
extern void AddUSBTMCProtocoll();
|
|
extern void AddAnsfrProtocol();
|
|
extern void AddHttpProtocoll();
|
|
extern void AddProtek608Protocol();
|
|
extern void AddRFAmpProtocol();
|
|
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();
|
|
AddModbusProtocoll();
|
|
AddOrdHVPSProtocoll();
|
|
AddVelSelProtocol();
|
|
AddUSBTMCProtocoll();
|
|
AddAnsfrProtocol();
|
|
AddHttpProtocoll();
|
|
AddProtek608Protocol();
|
|
AddRFAmpProtocol();
|
|
}
|
|
|
|
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;
|
|
}
|
|
|
|
void broadcastPrintf(int iOut, char *fmt, ...)
|
|
{
|
|
va_list ap;
|
|
char buf[256];
|
|
char *dyn;
|
|
unsigned int l;
|
|
int res;
|
|
|
|
va_start(ap, fmt);
|
|
l = vsnprintf(buf, sizeof buf, fmt, ap);
|
|
va_end(ap);
|
|
if (l >= sizeof buf) {
|
|
/* we have probably a C99 conforming snprintf and
|
|
need a larger buffer
|
|
*/
|
|
dyn = malloc(l+1);
|
|
if (dyn != NULL) {
|
|
va_start(ap, fmt);
|
|
vsnprintf(dyn, l+1, fmt, ap);
|
|
va_end(ap);
|
|
ServerWriteGlobal(dyn, iOut);
|
|
free(dyn);
|
|
}
|
|
}
|
|
ServerWriteGlobal(buf, iOut);
|
|
}
|