Created anstoutil to share the getParam function.
Modified motor_dmc2280 and counterdiv to use anstoutil r1033 | ffr | 2006-07-25 16:48:14 +1000 (Tue, 25 Jul 2006) | 3 lines
This commit is contained in:

committed by
Douglas Clowes

parent
36f76e9486
commit
a7ebdff308
@ -62,10 +62,11 @@ TANGOLIBS = \
|
|||||||
# itc4.o itc4driv.o \
|
# itc4.o itc4driv.o \
|
||||||
# hm_mrpd.o scan_mrpd.o
|
# hm_mrpd.o scan_mrpd.o
|
||||||
|
|
||||||
OBJ= site_ansto.o \
|
OBJ= site_ansto.o anstoutil.o\
|
||||||
motor_asim.o motor_dmc2280.o\
|
motor_asim.o motor_dmc2280.o\
|
||||||
lh45.o lh45driv.o \
|
lh45.o lh45driv.o \
|
||||||
lakeshore340.o lakeshore340driv.o \
|
lakeshore340.o lakeshore340driv.o \
|
||||||
|
counterdriv.o\
|
||||||
../psi/tcpdocho.o ../psi/tcpdornier.o
|
../psi/tcpdocho.o ../psi/tcpdornier.o
|
||||||
|
|
||||||
all: ../matrix/libmatrix.a $(COREOBJ:%=../%) libansto.a libhardsup
|
all: ../matrix/libmatrix.a $(COREOBJ:%=../%) libansto.a libhardsup
|
||||||
@ -88,13 +89,15 @@ hm_mrpd.o : hm_mrpd.cpp
|
|||||||
hm_asim.o : hm_asim.cpp
|
hm_asim.o : hm_asim.cpp
|
||||||
$(CXX) -c hm_asim.cpp $(CFLAGS) $(CXXFLAGS) -Wno-all
|
$(CXX) -c hm_asim.cpp $(CFLAGS) $(CXXFLAGS) -Wno-all
|
||||||
|
|
||||||
clean:
|
anstoclean:
|
||||||
$(PSI_CLEAN_MATRIX)
|
|
||||||
$(MAKE) -C hardsup clean
|
$(MAKE) -C hardsup clean
|
||||||
rm -f SICServer
|
rm -f SICServer
|
||||||
rm -f *.a
|
rm -f *.a
|
||||||
rm -f *.o
|
rm -f *.o
|
||||||
|
|
||||||
|
clean: anstoclean
|
||||||
|
$(PSI_CLEAN_MATRIX)
|
||||||
|
|
||||||
MZOBJ=fsm.o logger.o sugar.o pardef.o ease.o strobj.o oxinst.o \
|
MZOBJ=fsm.o logger.o sugar.o pardef.o ease.o strobj.o oxinst.o \
|
||||||
ipsdriv.o ilmdriv.o itcdriv.o ighdriv.o euro2kdriv.o modbus.o
|
ipsdriv.o ilmdriv.o itcdriv.o ighdriv.o euro2kdriv.o modbus.o
|
||||||
|
|
||||||
|
25
site_ansto/anstoutil.c
Normal file
25
site_ansto/anstoutil.c
Normal file
@ -0,0 +1,25 @@
|
|||||||
|
#include <stdlib.h>
|
||||||
|
#include <sics.h>
|
||||||
|
#include "anstoutil.h"
|
||||||
|
|
||||||
|
/** \brief Get configuration parameter
|
||||||
|
* \param *pCon (r) connection object.
|
||||||
|
* \param *pTcl (r) Tcl interpreter
|
||||||
|
* \param *params Tcl array of configuration parameters
|
||||||
|
* \param *parName name of parameter to get from the array
|
||||||
|
* \param mustHave indicates optional or mandatory parameters\n
|
||||||
|
* possible values
|
||||||
|
* - _REQUIRED
|
||||||
|
* - _OPTIONAL
|
||||||
|
* \return (r) a reference to a string representation of the parameter value
|
||||||
|
*/
|
||||||
|
char *getParam(SConnection *pCon, Tcl_Interp *pTcl, char *params, char *parName, int mustHave ) {
|
||||||
|
char *pPtr=NULL;
|
||||||
|
char pError[ERRLEN];
|
||||||
|
pPtr = Tcl_GetVar2(pTcl,params,parName,TCL_GLOBAL_ONLY);
|
||||||
|
if((mustHave == _REQUIRED) && !pPtr){
|
||||||
|
snprintf(pError, ERRLEN,"ERROR: No '%s' parameter given for dmc2280 motor", parName);
|
||||||
|
SCWrite(pCon,pError, eError);
|
||||||
|
}
|
||||||
|
return pPtr;
|
||||||
|
}
|
7
site_ansto/anstoutil.h
Normal file
7
site_ansto/anstoutil.h
Normal file
@ -0,0 +1,7 @@
|
|||||||
|
#ifndef ANSTOUTIL_H
|
||||||
|
#define ANSTOUTIL_H
|
||||||
|
#define _REQUIRED 1
|
||||||
|
#define _OPTIONAL 0
|
||||||
|
#define ERRLEN 256
|
||||||
|
/*@observer@*/ char *getParam(/*@dependent@*/SConnection *pCon, Tcl_Interp *pTcl, char *params, char *parName, int mustHave );
|
||||||
|
#endif
|
@ -1,14 +1,31 @@
|
|||||||
|
/** \file motor_dmc2280.c
|
||||||
|
* \brief Driver for Galil DMC2280 motor controller.
|
||||||
|
*
|
||||||
|
* Implements a SICS motor object with a MotorDriver interface.
|
||||||
|
*
|
||||||
|
* Copyright: see file Copyright.txt
|
||||||
|
*
|
||||||
|
* Ferdi Franceschini July 2006
|
||||||
|
*
|
||||||
|
*/
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
#include <assert.h>
|
#include <assert.h>
|
||||||
#include <math.h>
|
#include <math.h>
|
||||||
#include <time.h>
|
#include <time.h>
|
||||||
#include "fortify.h"
|
#include "fortify.h"
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "sics.h"
|
#include <sics.h>
|
||||||
#include "countdriv.h"
|
#include <rs232controller.h>
|
||||||
|
#include <countdriv.h>
|
||||||
|
#include "anstoutil.h"
|
||||||
|
|
||||||
|
/*@-incondefs@*/
|
||||||
|
/*@observer@*//*@dependent@*/ Tcl_Interp *InterpGetTcl(SicsInterp *pSics);
|
||||||
|
/*@observer@*//*@dependent@*/ pCounterDriver CreateCounterDriver(char *name, char *type);
|
||||||
|
/*@+incondefs@*/
|
||||||
|
|
||||||
|
#if 0
|
||||||
typedef struct __COUNTDRIV {
|
typedef struct __COUNTDRIV {
|
||||||
/* variables */
|
|
||||||
char *name;
|
char *name;
|
||||||
char *type;
|
char *type;
|
||||||
CounterMode eMode;
|
CounterMode eMode;
|
||||||
@ -19,58 +36,136 @@ typedef struct __COUNTDRIV {
|
|||||||
long lCounts[MAXCOUNT];
|
long lCounts[MAXCOUNT];
|
||||||
int iPause;
|
int iPause;
|
||||||
int iErrorCode;
|
int iErrorCode;
|
||||||
/* functions */
|
|
||||||
int (*GetStatus)(CounterDriver *self, float *fControl);
|
|
||||||
int (*Start)(CounterDriver *self);
|
|
||||||
int (*Pause)(CounterDriver *self);
|
|
||||||
int (*Continue)(CounterDriver *self);
|
|
||||||
int (*Halt)(CounterDriver *self);
|
|
||||||
int (*ReadValues)(CounterDriver *self);
|
|
||||||
int (*GetError)(CounterDriver *self, int *iCode, char *error, int iErrLen);
|
|
||||||
int (*TryAndFixIt)(CounterDriver *self, int iCode);
|
|
||||||
int (*Set)(CounterDriver *self,char *name, int iCter, float fVal);
|
|
||||||
int (*Get)(CounterDriver *self,char *name, int iCter, float *fVal);
|
|
||||||
int (*Send)(CounterDriver *self, char *pText, char *pReply, int iReplyLen);
|
|
||||||
void (*KillPrivate)(CounterDriver *self);
|
|
||||||
void *pData; /* counter specific data goes here, ONLY for
|
|
||||||
internal driver use!
|
|
||||||
*/
|
|
||||||
} CountDriv, *pCountDriv;
|
|
||||||
|
|
||||||
|
int (*GetStatus)(CounterDriver *cntrData, float *fControl);
|
||||||
|
int (*Start)(CounterDriver *cntrData);
|
||||||
|
int (*Pause)(CounterDriver *cntrData);
|
||||||
|
int (*Continue)(CounterDriver *cntrData);
|
||||||
|
int (*Halt)(CounterDriver *cntrData);
|
||||||
|
int (*ReadValues)(CounterDriver *cntrData);
|
||||||
|
int (*GetError)(CounterDriver *cntrData, int *iCode, char *error, int iErrLen);
|
||||||
|
int (*TryAndFixIt)(CounterDriver *cntrData, int iCode);
|
||||||
|
int (*Set)(CounterDriver *cntrData,char *name, int iCter, float fVal);
|
||||||
|
int (*Get)(CounterDriver *cntrData,char *name, int iCter, float *fVal);
|
||||||
|
int (*Send)(CounterDriver *cntrData, char *pText, char *pReply, int iReplyLen);
|
||||||
|
void (*KillPrivate)(CounterDriver *cntrData);
|
||||||
|
void *pData; /* counter specific data */
|
||||||
|
|
||||||
|
/*@observer@*//*@dependent@*/SConnection *pCon;
|
||||||
|
prs232 controller;
|
||||||
|
|
||||||
|
} CountDriv, *BeamMon;
|
||||||
|
#endif
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
char *host;
|
||||||
|
int iPort;
|
||||||
|
int iChannel;
|
||||||
|
void *pData;
|
||||||
|
int finishCount;
|
||||||
|
} BeamMon;
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
static int MonGetStatus(CounterDriver *self, float *fControl) {
|
static int MonGetStatus(CounterDriver *cntrData, float *fControl) {
|
||||||
|
BeamMon *self = NULL;
|
||||||
|
|
||||||
|
self = (BeamMon *) cntrData;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int MonStart(CounterDriver *self) {
|
static int MonStart(CounterDriver *cntrData) {
|
||||||
|
BeamMon *self = NULL;
|
||||||
|
|
||||||
|
self = (BeamMon *) cntrData;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int MonPause(CounterDriver *self) {
|
static int MonPause(CounterDriver *cntrData) {
|
||||||
|
BeamMon *self = NULL;
|
||||||
|
|
||||||
|
self = (BeamMon *) cntrData;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int MonContinue(CounterDriver *self) {
|
static int MonContinue(CounterDriver *cntrData) {
|
||||||
|
BeamMon *self = NULL;
|
||||||
|
|
||||||
|
self = (BeamMon *) cntrData;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int MonHalt(CounterDriver *self) {
|
static int MonHalt(CounterDriver *cntrData) {
|
||||||
|
BeamMon *self = NULL;
|
||||||
|
|
||||||
|
self = (BeamMon *) cntrData;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int MonReadValues(CounterDriver *self) {
|
static int MonReadValues(CounterDriver *cntrData) {
|
||||||
|
BeamMon *self = NULL;
|
||||||
|
|
||||||
|
self = (BeamMon *) cntrData;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int MonGetError(CounterDriver *self, int *iCode, char *error, int iErrLen) {
|
static int MonGetError(CounterDriver *cntrData, int *iCode, char *error, int iErrLen) {
|
||||||
|
BeamMon *self = NULL;
|
||||||
|
|
||||||
|
self = (BeamMon *) cntrData;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int MonTryAndFixIt(CounterDriver *self, int iCode) {
|
static int MonTryAndFixIt(CounterDriver *cntrData, int iCode) {
|
||||||
|
BeamMon *self = NULL;
|
||||||
|
|
||||||
|
self = (BeamMon *) cntrData;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int MonSet(CounterDriver *self, char *name, int iCter, float FVal) {
|
static int MonSet(CounterDriver *cntrData, char *name, int iCter, float FVal) {
|
||||||
|
BeamMon *self = NULL;
|
||||||
|
|
||||||
|
self = (BeamMon *) cntrData;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int MonGet(CounterDriver *self, char *name, int iCter, float *fVal) {
|
static int MonGet(CounterDriver *cntrData, char *name, int iCter, float *fVal) {
|
||||||
|
BeamMon *self = NULL;
|
||||||
|
|
||||||
|
self = (BeamMon *) cntrData;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int MonSend(CounterDriver *self, char *pText, char *pReply, int iReplyLen) {
|
static int MonSend(CounterDriver *cntrData, char *pText, char *pReply, int iReplyLen) {
|
||||||
|
BeamMon *self = NULL;
|
||||||
|
|
||||||
|
self = (BeamMon *) cntrData;
|
||||||
}
|
}
|
||||||
|
|
||||||
pCountDriv CreateMonCounter(char *name, float fFail) {
|
static void KillMon(pCounterDriver self) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/*@observer@*//*@null@*/ pCounterDriver CreateMonCounter(/*@observer@*/SConnection *pCon, /*@observer@*/char *name, char *params) {
|
||||||
|
BeamMon *newCtr = NULL;
|
||||||
|
pCounterDriver pCntDriv = NULL;
|
||||||
|
char *pPtr = NULL;
|
||||||
|
char buffer[132];
|
||||||
|
int port;
|
||||||
|
Tcl_Interp *interp;
|
||||||
|
|
||||||
|
interp = InterpGetTcl(pServ->pSics);
|
||||||
|
|
||||||
|
newCtr = (BeamMon *)malloc(sizeof(BeamMon));
|
||||||
|
if(NULL == newCtr){
|
||||||
|
(void) SCWrite(pCon,"ERROR: no memory to allocate counter driver",
|
||||||
|
eError);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
pCntDriv = CreateCounterDriver(name, "MONITOR");
|
||||||
|
if(!pCntDriv) {
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
/* Get hostname and port from the list of named parameters */
|
||||||
|
if ((pPtr=getParam(pCon, interp, params,"port",1)) == NULL) {
|
||||||
|
KillMon(pCntDriv);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
sscanf(pPtr,"%d",&port);
|
||||||
|
if ((pPtr=getParam(pCon, interp, params,"host",1)) == NULL) {
|
||||||
|
KillMon(pCntDriv);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
strncpy(buffer,pPtr, 131);
|
||||||
|
|
||||||
|
return pCntDriv;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
#include <rs232controller.h>
|
#include <rs232controller.h>
|
||||||
#include <modriv.h>
|
#include <modriv.h>
|
||||||
#include <dynstring.h>
|
#include <dynstring.h>
|
||||||
|
#include "anstoutil.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
#include "splint/splint_fortify.h"
|
#include "splint/splint_fortify.h"
|
||||||
@ -124,12 +125,9 @@ typedef struct __MoDriv {
|
|||||||
#define INIT_STR_SIZE 256
|
#define INIT_STR_SIZE 256
|
||||||
#define STR_RESIZE_LENGTH 256
|
#define STR_RESIZE_LENGTH 256
|
||||||
#define CMDLEN 1024
|
#define CMDLEN 1024
|
||||||
#define ERRLEN 256
|
|
||||||
#define BUFFLEN 512
|
#define BUFFLEN 512
|
||||||
#define FAILURE 0
|
#define FAILURE 0
|
||||||
#define SUCCESS 1
|
#define SUCCESS 1
|
||||||
#define _REQUIRED 1
|
|
||||||
#define _OPTIONAL 0
|
|
||||||
#define _SAVEPOWER 0
|
#define _SAVEPOWER 0
|
||||||
|
|
||||||
#define HOME "home"
|
#define HOME "home"
|
||||||
@ -929,27 +927,6 @@ static void KillDMC2280(/*@only@*/void *pData){
|
|||||||
return controller;
|
return controller;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** \brief Get configuration parameter
|
|
||||||
* \param *pCon (r) connection object.
|
|
||||||
* \param *pTcl (r) Tcl interpreter
|
|
||||||
* \param *params Tcl array of configuration parameters
|
|
||||||
* \param *parName name of parameter to get from the array
|
|
||||||
* \param mustHave indicates optional or mandatory parameters\n
|
|
||||||
* possible values
|
|
||||||
* - _REQUIRED
|
|
||||||
* - _OPTIONAL
|
|
||||||
* \return (r) a reference to a string representation of the parameter value
|
|
||||||
*/
|
|
||||||
/*@observer@*/ static char *getParam(/*@dependent@*/SConnection *pCon, Tcl_Interp *pTcl, char *params, char *parName, int mustHave ) {
|
|
||||||
char *pPtr=NULL;
|
|
||||||
char pError[ERRLEN];
|
|
||||||
pPtr = Tcl_GetVar2(pTcl,params,parName,TCL_GLOBAL_ONLY);
|
|
||||||
if((mustHave == _REQUIRED) && !pPtr){
|
|
||||||
snprintf(pError, ERRLEN,"ERROR: No '%s' parameter given for dmc2280 motor", parName);
|
|
||||||
SCWrite(pCon,pError, eError);
|
|
||||||
}
|
|
||||||
return pPtr;
|
|
||||||
}
|
|
||||||
|
|
||||||
/** \brief Create a driver for the DMC2280 Galil controller.
|
/** \brief Create a driver for the DMC2280 Galil controller.
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user