You can now run the oscillating collimator for a specified number of cycles. A MOTEND event is now sent when the oscillator stops. Also temporarily set status to eEager to allow changing the motor accesscode parameter while something else is running, (eg a counter) motor.c finishDriving is no longer static so we can call it from the oscilator and generate a MOTEND event. west4100.c Return 'success' from wrapper on "controlsensor" and "sensorlist" queries so we can test and capture their values in scripts. Makefile Compile the quokka beamstopaction object site_ansto.c Add the MakeActionObject command. Currently only makes the hardcoded beamstopaction object obpar.c Report object name and parameter on an illegal attempt to set a parameter hmm_configuration_common_1.tcl Add oscillating collimator control flag for Wombat. If true we use hmm to start the histogram server instead of hmc. TODO remove hmc and always use hmm. hipd/config/motors/motor_configuration.tcl Don't load anticollider config twice. Fix oct limits wombat_configuration.tcl Environment configuration must be loaded before running server_init. hrpd/config/hmm/hmm_configuration.tcl Fix default time-bin to match 10Hz frame frequency hrpd/config/motors/motor_configuration.tcl Added dummy motor for testing. reflectometer/config/hmm/detector.tcl Fill in dhv1 configuration parameters. sans/config/hmm/detector.tcl Enable detector voltage control sans/config/hmm/hmm_configuration.tcl SICS-227 set default resolution to 192x192 sans/config/motors/motor_configuration.tcl Added dummy motor for testing quokka parameters.tcl Fix L2mm calculation, Fix SICS-228 users cannot set rotapdeg beamstopaction.[ch] NEW: Implements an action command to drive the quokka beamstops up and down. r2670 | ffr | 2008-08-07 13:17:29 +1000 (Thu, 07 Aug 2008) | 53 lines
358 lines
11 KiB
C
358 lines
11 KiB
C
/*---------------------------------------------------------------------------
|
|
W E S T 4 1 0 0 . C
|
|
|
|
This is the implementation for a WEST4100 object derived from a more general
|
|
environment controller.
|
|
|
|
Mark Koennecke, August 1997
|
|
Mark Lesha, January 2006 (based on ITC4 code)
|
|
Paul Barron, January 2008 (Note: This is based on the old LAKESHORE340 code and
|
|
not the new LS340 code written by Rodney Davies Feb 08)
|
|
|
|
Copyright:
|
|
|
|
Labor fuer Neutronenstreuung
|
|
Paul Scherrer Institut
|
|
CH-5423 Villigen-PSI
|
|
|
|
|
|
The authors hereby grant permission to use, copy, modify, distribute,
|
|
and license this software and its documentation for any purpose, provided
|
|
that existing copyright notices are retained in all copies and that this
|
|
notice is included verbatim in any distributions. No written agreement,
|
|
license, or royalty fee is required for any of the authorized uses.
|
|
Modifications to this software may be copyrighted by their authors
|
|
and need not follow the licensing terms described here, provided that
|
|
the new terms are clearly indicated on the first page of each file where
|
|
they apply.
|
|
|
|
IN NO EVENT SHALL THE AUTHORS OR DISTRIBUTORS BE LIABLE TO ANY PARTY
|
|
FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES
|
|
ARISING OUT OF THE USE OF THIS SOFTWARE, ITS DOCUMENTATION, OR ANY
|
|
DERIVATIVES THEREOF, EVEN IF THE AUTHORS HAVE BEEN ADVISED OF THE
|
|
POSSIBILITY OF SUCH DAMAGE.
|
|
|
|
THE AUTHORS AND DISTRIBUTORS SPECIFICALLY DISCLAIM ANY WARRANTIES,
|
|
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY,
|
|
FITNESS FOR A PARTICULAR PURPOSE, AND NON-INFRINGEMENT. THIS SOFTWARE
|
|
IS PROVIDED ON AN "AS IS" BASIS, AND THE AUTHORS AND DISTRIBUTORS HAVE
|
|
NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, ENHANCEMENTS, OR
|
|
MODIFICATIONS.
|
|
----------------------------------------------------------------------------*/
|
|
#include <string.h>
|
|
#include <stdlib.h>
|
|
#include <assert.h>
|
|
#include <tcl.h>
|
|
#include <fortify.h>
|
|
#include <sics.h>
|
|
#include <splitter.h>
|
|
#include <obpar.h>
|
|
#include <devexec.h>
|
|
#include <nserver.h>
|
|
#include <interrupt.h>
|
|
#include <emon.h>
|
|
#include <evcontroller.h>
|
|
#include <evcontroller.i>
|
|
#include "west4100.h"
|
|
|
|
int SetSetpointWEST4100(pEVDriver self, int Setpoint);
|
|
int SetAlarm1WEST4100(pEVDriver self, int Alarm1);
|
|
int SetAlarm2WEST4100(pEVDriver self, int Alarm2);
|
|
int SetPowerLimitWEST4100(pEVDriver self, int PowerLimit);
|
|
int SetRampRateWEST4100(pEVDriver self, int RampRate);
|
|
int GetSetpointWEST4100(pEVDriver self);
|
|
int GetAlarm1WEST4100(pEVDriver self);
|
|
int GetAlarm2WEST4100(pEVDriver self);
|
|
int GetPowerLimitWEST4100(pEVDriver self);
|
|
int GetRampRateWEST4100(pEVDriver self);
|
|
int GetProcessValueWEST4100(pEVDriver self);
|
|
int GetAddressWEST4100(pEVDriver self);
|
|
int GetTransactWEST4100(pEVDriver self);
|
|
int GetWorkingSetpointWEST4100(pEVDriver self);
|
|
|
|
/*---------------------------------------------------------------------------*/
|
|
int WEST4100SetPar(pEVControl self, char *name, float fNew, SConnection *pCon)
|
|
{
|
|
int iRet;
|
|
|
|
/* check authorisation */
|
|
if(!SCMatchRights(pCon,usUser))
|
|
{
|
|
SCWrite(pCon,"ERROR: you are not authorised to change this parameter",
|
|
eError);
|
|
return 0;
|
|
}
|
|
|
|
/* just catch those three names which we understand */
|
|
if(strcmp(name,"setpoint") == 0)
|
|
{
|
|
iRet = SetSetpointWEST4100(self->pDriv,(int)fNew);
|
|
if(!iRet)
|
|
{
|
|
SCWrite(pCon,"ERROR: value out of range",eError);
|
|
return 0;
|
|
}
|
|
iRet = ConfigWEST4100(self->pDriv);
|
|
if(iRet != 1)
|
|
{
|
|
SCWrite(pCon,"ERROR: WEST4100 configuration failed! ",eError);
|
|
SCWrite(pCon,"INFO: Probably comm problem, Retry!",eError);
|
|
return 0;
|
|
}
|
|
SCSendOK(pCon);
|
|
return 1;
|
|
}
|
|
|
|
if(strcmp(name,"alarm1") == 0)
|
|
{
|
|
iRet = SetAlarm1WEST4100(self->pDriv,(int)fNew);
|
|
if(!iRet)
|
|
{
|
|
SCWrite(pCon,"ERROR: value out of range",eError);
|
|
return 0;
|
|
}
|
|
iRet = ConfigWEST4100(self->pDriv);
|
|
if(iRet != 1)
|
|
{
|
|
SCWrite(pCon,"ERROR: WEST4100 configuration failed! ",eError);
|
|
SCWrite(pCon,"INFO: Probably comm problem, Retry!",eError);
|
|
return 0;
|
|
}
|
|
SCSendOK(pCon);
|
|
return 1;
|
|
}
|
|
|
|
if(strcmp(name,"alarm2") == 0)
|
|
{
|
|
iRet = SetAlarm2WEST4100(self->pDriv,(int)fNew);
|
|
if(!iRet)
|
|
{
|
|
SCWrite(pCon,"ERROR: value out of range",eError);
|
|
return 0;
|
|
}
|
|
iRet = ConfigWEST4100(self->pDriv);
|
|
if(iRet != 1)
|
|
{
|
|
SCWrite(pCon,"ERROR: WEST4100 configuration failed! ",eError);
|
|
SCWrite(pCon,"INFO: Probably comm problem, Retry!",eError);
|
|
return 0;
|
|
}
|
|
SCSendOK(pCon);
|
|
return 1;
|
|
}
|
|
|
|
if(strcmp(name,"powerlimit") == 0)
|
|
{
|
|
iRet = SetPowerLimitWEST4100(self->pDriv,(int)fNew);
|
|
if(!iRet)
|
|
{
|
|
SCWrite(pCon,"ERROR: value out of range",eError);
|
|
return 0;
|
|
}
|
|
iRet = ConfigWEST4100(self->pDriv);
|
|
if(iRet != 1)
|
|
{
|
|
SCWrite(pCon,"ERROR: WEST4100 configuration failed! ",eError);
|
|
SCWrite(pCon,"INFO: Probably comm problem, Retry!",eError);
|
|
return 0;
|
|
}
|
|
SCSendOK(pCon);
|
|
return 1;
|
|
}
|
|
|
|
if(strcmp(name,"ramprate") == 0)
|
|
{
|
|
iRet = SetRampRateWEST4100(self->pDriv,(int)fNew);
|
|
if(!iRet)
|
|
{
|
|
SCWrite(pCon,"ERROR: value out of range",eError);
|
|
return 0;
|
|
}
|
|
iRet = ConfigWEST4100(self->pDriv);
|
|
if(iRet != 1)
|
|
{
|
|
SCWrite(pCon,"ERROR: WEST4100 configuration failed! ",eError);
|
|
SCWrite(pCon,"INFO: Probably comm problem, Retry!",eError);
|
|
return 0;
|
|
}
|
|
SCSendOK(pCon);
|
|
return 1;
|
|
}
|
|
|
|
else
|
|
return EVCSetPar(self,name,fNew,pCon);
|
|
}
|
|
/*--------------------------------------------------------------------------*/
|
|
int WEST4100GetPar(pEVControl self, char *name, float *fNew)
|
|
{
|
|
int iRet;
|
|
|
|
/* just catch those two names which we understand */
|
|
if(strcmp(name,"setpoint") == 0)
|
|
{
|
|
iRet = GetSetpointWEST4100(self->pDriv);
|
|
*fNew = (float)iRet;
|
|
return 1;
|
|
}
|
|
else if(strcmp(name,"alarm1") == 0)
|
|
{
|
|
iRet = GetAlarm1WEST4100(self->pDriv);
|
|
*fNew = (float)iRet;
|
|
return 1;
|
|
}
|
|
else if(strcmp(name,"alarm2") == 0)
|
|
{
|
|
iRet = GetAlarm2WEST4100(self->pDriv);
|
|
*fNew = (float)iRet;
|
|
return 1;
|
|
}
|
|
else if(strcmp(name,"powerlimit") == 0)
|
|
{
|
|
iRet = GetPowerLimitWEST4100(self->pDriv);
|
|
*fNew = (float)iRet;
|
|
return 1;
|
|
}
|
|
else if(strcmp(name,"ramprate") == 0)
|
|
{
|
|
iRet = GetRampRateWEST4100(self->pDriv);
|
|
*fNew = (float)iRet;
|
|
return 1;
|
|
}
|
|
else if(strcmp(name,"numsensors") == 0)
|
|
{
|
|
iRet = 1; // Furnace only has 1 sensor
|
|
*fNew = (int)iRet;
|
|
return 1;
|
|
}
|
|
else if(strcmp(name,"sensora") == 0)
|
|
{
|
|
iRet = GetProcessValueWEST4100(self->pDriv); // Furnace only has 1 sensor
|
|
*fNew = (float)iRet;
|
|
return 1;
|
|
}
|
|
else
|
|
return EVCGetPar(self,name,fNew);
|
|
}
|
|
/*---------------------------------------------------------------------------*/
|
|
int WEST4100List(pEVControl self, SConnection *pCon)
|
|
{
|
|
char pBueffel[132];
|
|
int iRet;
|
|
|
|
iRet = EVCList(self,pCon);
|
|
|
|
sprintf(pBueffel,"%s.NumSensors = %d",self->pName,1);
|
|
SCWrite(pCon,pBueffel,eValue);
|
|
|
|
sprintf(pBueffel,"%s.ControlSensor = %s",self->pName,"SensorA");
|
|
SCWrite(pCon,pBueffel,eValue);
|
|
|
|
|
|
sprintf(pBueffel,"%s.ModbusAddress = %d",self->pName,GetAddressWEST4100(self->pDriv));
|
|
SCWrite(pCon,pBueffel,eValue);
|
|
|
|
sprintf(pBueffel,"%s.TransactionNumber = %d",self->pName,GetTransactWEST4100(self->pDriv));
|
|
SCWrite(pCon,pBueffel,eValue);
|
|
|
|
sprintf(pBueffel,"%s.ProcessValue = %d",self->pName,GetProcessValueWEST4100(self->pDriv));
|
|
SCWrite(pCon,pBueffel,eValue);
|
|
|
|
sprintf(pBueffel,"%s.Setpoint = %d",self->pName,GetSetpointWEST4100(self->pDriv));
|
|
SCWrite(pCon,pBueffel,eValue);
|
|
|
|
sprintf(pBueffel,"%s.WorkingSetpoint = %d",self->pName,GetWorkingSetpointWEST4100(self->pDriv));
|
|
SCWrite(pCon,pBueffel,eValue);
|
|
|
|
sprintf(pBueffel,"%s.Alarm1 = %d",self->pName,GetAlarm1WEST4100(self->pDriv));
|
|
SCWrite(pCon,pBueffel,eValue);
|
|
|
|
sprintf(pBueffel,"%s.Alarm2 = %d",self->pName,GetAlarm2WEST4100(self->pDriv));
|
|
SCWrite(pCon,pBueffel,eValue);
|
|
|
|
sprintf(pBueffel,"%s.PowerLimit = %d",self->pName,GetPowerLimitWEST4100(self->pDriv));
|
|
SCWrite(pCon,pBueffel,eValue);
|
|
|
|
sprintf(pBueffel,"%s.RampRate = %d",self->pName,GetRampRateWEST4100(self->pDriv));
|
|
SCWrite(pCon,pBueffel,eValue);
|
|
|
|
return iRet;
|
|
}
|
|
/*-------------------------------------------------------------------------*/
|
|
int WEST4100Wrapper(SConnection *pCon, SicsInterp *pSics, void *pData,
|
|
int argc, char *argv[])
|
|
{
|
|
pEVControl self = NULL;
|
|
char pBueffel[256];
|
|
int iRet;
|
|
double fNum;
|
|
float fVal;
|
|
int fValue;
|
|
|
|
self = (pEVControl)pData;
|
|
assert(self);
|
|
assert(pCon);
|
|
assert(pSics);
|
|
|
|
if(argc < 2)
|
|
{
|
|
return EVControlWrapper(pCon,pSics,pData,argc,argv);
|
|
}
|
|
// Set or Get
|
|
strtolower(argv[1]);
|
|
if( (strcmp(argv[1],"controlsensor") == 0) || (strcmp(argv[1],"sensorlist") == 0)){
|
|
sprintf(pBueffel,"%s.%s = %s",self->pName,argv[1],"sensorA");
|
|
SCWrite(pCon,pBueffel,eValue);
|
|
return 1;
|
|
}
|
|
else if((strcmp(argv[1],"setpoint") == 0) || (strcmp(argv[1],"alarm1") == 0)
|
|
|| (strcmp(argv[1],"powerlimit") == 0) || (strcmp(argv[1],"alarm2") == 0)
|
|
|| (strcmp(argv[1],"ramprate") == 0) || (strcmp(argv[1],"numsensors") == 0)
|
|
|| (strcmp(argv[1],"sensora") == 0))
|
|
{
|
|
if(argc > 2) /* set case */
|
|
{
|
|
iRet = Tcl_GetDouble(pSics->pTcl,argv[2],&fNum);
|
|
if(iRet != TCL_OK)
|
|
{
|
|
sprintf(pBueffel,"ERROR: expected number, got %s",argv[2]);
|
|
SCWrite(pCon,pBueffel,eError);
|
|
return 0;
|
|
}
|
|
return WEST4100SetPar(self,argv[1],(float)fNum,pCon);
|
|
}
|
|
else /* get case */
|
|
{
|
|
iRet = WEST4100GetPar(self,argv[1],&fVal);
|
|
sprintf(pBueffel,"%s.%s = %f",self->pName,argv[1],fVal);
|
|
SCWrite(pCon,pBueffel,eValue);
|
|
return 1;
|
|
}
|
|
}
|
|
// Write or Query
|
|
else if(strcmp(argv[1],"parameter") == 0)
|
|
{
|
|
if(argc > 3) /* set case */
|
|
{
|
|
return WEST4100Write(self->pDriv,atoi(argv[2]),atoi(argv[3]));
|
|
}
|
|
else /* get case */
|
|
{
|
|
iRet = WEST4100Query(self->pDriv,atoi(argv[2]),&fValue);
|
|
sprintf(pBueffel,"%s.%s %s = %d",self->pName,argv[1],argv[2],fValue);
|
|
SCWrite(pCon,pBueffel,eValue);
|
|
return 1;
|
|
}
|
|
}
|
|
// List
|
|
else if(strcmp(argv[1],"list") == 0)
|
|
{
|
|
return WEST4100List(self,pCon);
|
|
}
|
|
else
|
|
{
|
|
return EVControlWrapper(pCon,pSics,pData,argc,argv);
|
|
}
|
|
/* not reached */
|
|
return 0;
|
|
}
|