This means that ASIM motor drivers can now be configured with the same configuration file as the DMC2280 driver. Also ensured that motors drive instantly to there target position, this streamlines testing and is useful for the script validation server. r1949 | ffr | 2007-05-10 13:15:21 +1000 (Thu, 10 May 2007) | 4 lines
247 lines
7.4 KiB
C
247 lines
7.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 <multichan.h>
|
|
#include <tcl.h>
|
|
#include <site.h>
|
|
#include <SCinter.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"
|
|
/* 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"
|
|
|
|
#include "safetyplc.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);
|
|
|
|
|
|
void SiteInit(void) {
|
|
int NetWatchInit(void);
|
|
NetWatchInit();
|
|
#define INIT(F) { void F(void); F(); }
|
|
/* insert here initialization routines ... */
|
|
|
|
}
|
|
|
|
static pSite /*@null@*/ siteANSTO = NULL;
|
|
|
|
/*----------------------------------------------------------------------*/
|
|
static void AddCommands(SicsInterp *pInter)
|
|
{
|
|
(void) AddCommand(pInter,"MakeTCPSelector",VelSelTcpFactory,NULL,NULL);
|
|
(void) AddCommand(pInter,"portnum",portNumCmd,NULL,NULL);
|
|
// (void) AddCommand(pInter,"MakePLC",MakePLC,NULL,NULL);
|
|
AddCommand(pInter,"MakeHMControl_ANSTO",MakeHMControl_ANSTO,NULL,NULL);
|
|
AddCommand(pInter,"MakeMultiChan",MultiChanFactory,NULL,NULL);
|
|
AddCommand(pInter,"MakeSafetyPLC",SafetyPLCFactory,NULL,NULL);
|
|
}
|
|
/*---------------------------------------------------------------------*/
|
|
static void RemoveCommands(SicsInterp *pSics){
|
|
// RemoveCommand(pInter,"MakePLC");
|
|
}
|
|
/*-------------------------------------------------------------------*/
|
|
/*@null@*/ static pMotor CreateMotorAnsto(SConnection *pCon, int argc, char *argv[])
|
|
{
|
|
MotorDriver *pDriver = NULL;
|
|
pMotor pNew = NULL;
|
|
Tcl_Interp *pTcl = 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 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){
|
|
AddCommand(pSics,argv[2],NHQ200Wrapper,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;
|
|
}
|
|
|