Files
sics/obpar.c
Ferdi Franceschini d7cea6914c oscillate.c SICS-232
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
2012-11-15 13:40:44 +11:00

216 lines
5.5 KiB
C

/*-----------------------------------------------------------------------
A helper class for Sics-objects internal parameter management
Mark Koennecke, November 1996
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 <stdlib.h>
#include <assert.h>
#include <string.h>
#include "Scommon.h"
#include "fortify.h"
#include "conman.h"
#include "status.h"
#include "obpar.h"
/*------------------------------------------------------------------------*/
int ObParLength(ObPar *self)
{
int i = 0;
assert(self);
while(self[i].iCode != -100)
{
i++;
}
return i;
}
/*-------------------------------------------------------------------------*/
ObPar *ObParCreate(int iArrayLong)
{
ObPar *pRes = NULL;
int i;
assert(iArrayLong > 0);
/* allocate memory */
pRes = (ObPar *)malloc((iArrayLong + 1)*sizeof(ObPar));
if(!pRes)
{
return NULL;
}
/* initialise all to 0 */
for(i = 0; i < iArrayLong; i++)
{
pRes[i].name = NULL;
pRes[i].fVal = .0;
pRes[i].iCode = usSpy;
}
/* have a sentinel at the end */
pRes[iArrayLong].iCode = -100;
return pRes;
}
/*--------------------------------------------------------------------------*/
void ObParDelete(ObPar *self)
{
int i;
int iLong;
assert(self);
/* free the names */
iLong = ObParLength(self);
for(i = 0; i < iLong; i++)
{
if(self[i].name)
free(self[i].name);
}
free(self);
}
/*---------------------------------------------------------------------------*/
ObPar *ObParFind(ObPar *self, char *name)
{
int i;
assert(self);
for(i = 0; self[i].iCode != -100; i++)
{
if(strcmp(name,self[i].name) == 0)
{
return &self[i];
}
}
return NULL;
}
/*---------------------------------------------------------------------------*/
int ObParIndex(ObPar *self, char *name)
{
int i;
assert(self);
for(i = 0; self[i].iCode != -100; i++)
{
if(strcmp(name,self[i].name) == 0)
{
return i;
}
}
return -1;
}
/*---------------------------------------------------------------------------*/
int ObParInit(ObPar *self, int i, char *name, float fVal, int iCode)
{
assert(self);
/* check i */
if( (i < 0) && ( i >= ObParLength(self) ))
{
return 0;
}
if(self[i].name)
{
free(self[i].name);
}
self[i].name = strdup(name);
self[i].fVal = fVal;
self[i].iCode = iCode;
return 1;
}
/*------------------------------------------------------------------------*/
int ObParSet(ObPar *self, char *obname, char *name, float fVal,
SConnection *pCon)
{
char pBueffel[512];
ObPar *pPar = NULL;
Status eStat;
assert(self);
/* find the parameter */
pPar = ObParFind(self,name);
if(pPar == NULL)
{
sprintf(pBueffel,"ERROR: %s.%s parameter not found",
obname,name);
SCWrite(pCon, pBueffel,eError);
return 0;
}
/* are we running? */
eStat = GetStatus();
if(!((eStat == eEager) || (eStat == eBatch)) )
{
sprintf(pBueffel,"ERROR: Cannot change %s.%s parameter while running", obname, name);
SCWrite(pCon, pBueffel,eError);
return 0;
}
/* check permission */
if(!SCMatchRights(pCon,pPar->iCode))
{
sprintf(pBueffel,"ERROR: Insufficient privilege to change %s.%s",
obname, name);
SCWrite(pCon, pBueffel,eError);
return 0;
}
/* passed all tests: do It! */
pPar->fVal = fVal;
return 1;
}
/*------------------------------------------------------------------------*/
float ObVal(ObPar *self, int i)
{
assert(self);
assert(i > -1);
assert( i < ObParLength(self));
return self[i].fVal;
}