Files
sics/site_ansto/site_ansto.c
Ferdi Franceschini e36e9f1146 conman.c
Reduce log noise by setting iout = eInternal for macros.

servlog.c
Fixed timestamp in logfiles to get hours.

hmm_configuration_common_1.tcl
Added ML's mods to wombat config: ie BAT and FAT TABLE attributes and elements for multi-period acquisition and histo-streaming.
Fixed "failed lsearch" bug. It's more robust to test for a non-successful lsearch instead of a failed lsearch.

nxscripts_common_1.tcl
SICS-297 Fixed Saving data series in a scratch file overwrites earlier entries.

instdict_specification.tcl
Added "scobj" kind and "sct_indexed_motor" sics object type for script context controllers and and objects.

hipadaba_configuration_common.tcl
Added sct_indexed_motor sics obj type to ::hdb::sobjadd and scobj kind to ::hdb::add_node

sct_positmotor_common.tcl
Update the index SICS variable when updating the current index value to make sure that the position is saved in the data file.
You must now provide the hdb node_name when creating the sct posit motor.
mk_sct_positmotor now sets the "param" and "long_name" attributes on the posit motor object

util/utility.tcl
Added ::utility::set_sct_indexed_motor_attributes to set SICS object attributes required for generating hdb info for an SCT_POSIT_MOTOR

nxscript.c
Merge the ansto mod to putslab (rev1.7) which adds support for saving unbuffered data from the histmem.

sicshipadaba.c
This incorporates the patch made to CommandSetCallback in rev1.10 so it can just be copied as is (ie no merge required).
WARNING: There are changes to ListHdbNode to handle record separators which may affect us.
Disabled sending hdb command start and stop messages because they break gumtree

sicshdbfactory.c
Disabled sending hdb command start and stop messages because they break gumtree

hipadaba_configuration_common.tcl R2.4DEV
The sct_posit_motor case of ::hdb::sobjadd is only needed to call add_node with kind=scobj.

nxscripts_common_1.tcl R2.4DEV
Added ::nexus::scobj::sdsinfo
_gen_nxdict now skips nodes with data_type == "none"

new util/script_context_util.tcl R2.4DEV
Adds ::scobj::hinitprops command to initialise the hdb properties for script context object nodes.

sct_positmotor_common.tcl R2.4DEV
Use ::scobj::hinitprops utility command to initialise hdb properties on script context object parameter nodes.

dynstring.c
DynStringReplace should memcopy '\0', otherwise it can get the wrong length for iTextLen.
Added DynStringReplaceWithLen to allow initialising a dynstring with char arrays which contain null chars and
other non-ascii chars.  Useful for read and write buffers in script context.

ascon.c
AsconRead return NULL for noResponse and AsconFailed otherwise the "result" node gets set with a spurious empty value.

scriptcontext.c
SctActionHandler only set  the "result" node if there really is a reply.

sicsobj.c
Update from M.K.

site_ansto.c
Added galil and ordela hvps protocol handlers for scriptcontext.

motor_dmc2280.c
Allow home parameter to be outside of limits (for KOWARI)

hardsup/makefile
Added ordela HVPS protocol handler

hardsup/sct_orhvpsprot.c
New ordela HVPS protocol handler.  Retries on NAKs and re-orders pot channels (ie toggles lower two bits).

hardsup/sct_velselprot.c
Start velocity selector protocol handler.

hardsup/sct_galilprot.c
Completed galil protocol handler.

hipadaba_configuration_common.tcl
Add new style SICS objects to hdb tree.

instdict_specification.tcl
Added scobj to kind list and sct_motor to sics object list. (and some housekeeping)

hmm_configuration_common_1.tcl
Added ratemaps to simulation.  Fixe BAT_TABLE and added PERIOD_INDICES as per Mark Lesha's mods for multi-period acquisition.
ratemaps now return float.

sct_postimotor_common.tcl
Now setting properties on the posit motor object so that it can be automatically added to the hdb tree.

hrpd/config/motors/motor_configuration.tcl
Fixed simulated msd motor so that it's handle properly in the hdb layer.

sans/config/hmm/detector_ordela.tcl
Updated the ordela calibration script to use the new sct_orhvpsprop.c script context controller.

quokka_configuration.tcl
Deleted lines which set the hdb properties for script context posit motors.  This is now handled automatically as for other SICS objects.

utility.tcl
setpos now replaces the motor setpos subcommand.
Added functions to set script context object attributes and sct_posit motor attributes.
Created hparPath and hsibPath convenience commands for new-style SICS objects.

script_context_util.tcl
NEW! Adds hinitprops function to initialise the hdb properties for a script context object

r2758 | ffr | 2008-12-12 17:53:53 +1100 (Fri, 12 Dec 2008) | 113 lines
2012-11-15 16:56:43 +11:00

309 lines
9.4 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();
void SiteInit(void) {
int NetWatchInit(void);
NetWatchInit();
#define INIT(F) { void F(void); F(); }
/* insert here initialization routines ... */
AddGalilProtocoll();
AddOrdHVPSProtocoll();
}
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);
}
/*---------------------------------------------------------------------*/
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;
}