Added to repository.
r986 | ffr | 2006-05-09 09:17:15 +1000 (Tue, 09 May 2006) | 2 lines
This commit is contained in:
committed by
Douglas Clowes
parent
a72513165b
commit
81359a740f
238
site_ansto/site_ansto.c
Normal file
238
site_ansto/site_ansto.c
Normal file
@@ -0,0 +1,238 @@
|
||||
/*------------------------------------------------------------------------
|
||||
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 <tcl.h>
|
||||
#include <site.h>
|
||||
#include <SCinter.h>
|
||||
|
||||
/* site-specific driver header files */
|
||||
#include "motor_asim.h"
|
||||
#include "itc4.h"
|
||||
/* Added code for new LH45 and Lakeshore 340 drivers */
|
||||
#include "lh45.h"
|
||||
#include "lakeshore340.h"
|
||||
/*
|
||||
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) {
|
||||
|
||||
#define INIT(F) { void F(void); F(); }
|
||||
/* insert here initialization routines ... */
|
||||
|
||||
}
|
||||
|
||||
static pSite /*@null@*/ siteANSTO = NULL;
|
||||
|
||||
/*----------------------------------------------------------------------*/
|
||||
static void AddCommands(SicsInterp *pInter)
|
||||
{
|
||||
// int iRet;
|
||||
// SConnection *pDummyConn;
|
||||
(void) AddCommand(pInter,"MakeTCPSelector",VelSelTcpFactory,NULL,NULL);
|
||||
/*
|
||||
* Initialisation: Force execution here or use config script
|
||||
*/
|
||||
// pDummyConn = SCCreateDummyConnection(pInter);
|
||||
// iRet = InterpExecute(pInter,pDummyConn,"config outcode warning");
|
||||
// iRet = InterpExecute(pInter,pDummyConn,"InstallSinfox");
|
||||
// iRet = InterpExecute(pInter,pDummyConn,"InstallProtocolHandler");
|
||||
// SCDeleteConnection(pDummyConn);
|
||||
}
|
||||
/*---------------------------------------------------------------------*/
|
||||
static void RemoveCommands(SicsInterp *pSics){
|
||||
// RemoveCommand(pInter,"InstallProtocolHandler"0);
|
||||
// RemoveCommand(pInter,"InstallSinfox");
|
||||
}
|
||||
/*-------------------------------------------------------------------*/
|
||||
/*@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;
|
||||
}
|
||||
}
|
||||
if(strcmp(argv[1],"asim") == 0) {
|
||||
pDriver = (MotorDriver *)CreateASIM(pCon,argc-2,&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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
return pNew;
|
||||
}
|
||||
/*extern pCounterDriver CreateCtrNitio10(SConnection *pCon,char *name,int argc,char *argv[]); */
|
||||
/*-------------------------------------------------------------------*/
|
||||
static pCounterDriver CreateCounterDriverAnsto(SConnection *pCon,
|
||||
int argc,
|
||||
char *argv[]){
|
||||
pCounterDriver pNew = NULL;
|
||||
if(strcmp(argv[2],"nitio10") == 0){
|
||||
if(argc < 4){
|
||||
SCWrite(pCon,
|
||||
"ERROR:SITE: Insufficient arguments for NITIO10 counter",
|
||||
eError);
|
||||
return NULL;
|
||||
}
|
||||
/* pNew = CreateCtrNitio10(pCon,argv[1],argc-3,&argv[3]);*/
|
||||
}
|
||||
return pNew;
|
||||
}
|
||||
/*-------------------------------------------------------------------*/
|
||||
static HistDriver *CreateHistMem(char *name, pStringDict pOptions){
|
||||
HistDriver *pNew = NULL;
|
||||
|
||||
if(strcmp(name,"anstohm") == 0){
|
||||
//#ifdef __cplusplus
|
||||
printf("try to CreateAnstoHM() ...\n");
|
||||
// pNew = CreateAnstoHM(pOptions);
|
||||
//#endif /* __cplusplus */
|
||||
}
|
||||
|
||||
if(strcmp(name,"hm_mrpd") == 0){
|
||||
printf("try to Create HM for MRPD ...\n");
|
||||
// pNew = CreateHmMrpd(pOptions);
|
||||
}
|
||||
|
||||
if(strcmp(name,"hm_asim") == 0){
|
||||
// pNew = CreateHmAsim(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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
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 = CreateHistMem;
|
||||
siteANSTO->CreateVelocitySelector = CreateVelSelDriv;
|
||||
siteANSTO->CreateControllerDriver = CreateController;
|
||||
siteANSTO->InstallEnvironmentController = InstallEnvironmentController;
|
||||
siteANSTO->ConfigureScan = ConfigureScan;
|
||||
siteANSTO->KillSite = KillSite;
|
||||
}
|
||||
return siteANSTO;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user