Files
sics/site_ansto/action.c
2014-05-16 17:23:44 +10:00

69 lines
1.8 KiB
C

/*-------------------------------------------------------------------------
* @file ACTION OBJECT
* Currently just provides methods to set SICSVariables on status update.
* Copyright: see file Copyright.txt
*/
#include "action.h"
#include "sics.h"
#include "asyncqueue.h"
#include "nwatch.h"
#include "fsm.h"
#include "anstoutil.h"
#include "sicsvar.h"
#include <stdlib.h>
#include <stdbool.h>
#include <assert.h>
#include <string.h>
#include <ctype.h>
#include <math.h>
static char *SV_FastShutter = "FastShutter";
static char *SV_BATPOS = "::beam::attenuator::_fb_BeamAttenuator";
static void setTextSICSVar(char *VarName, char *value) {
int privilege = 1;
pSicsVariable svText=NULL;
svText = (pSicsVariable)FindCommandData(pServ->pSics,SV_FastShutter,"SicsVariable");
if (svText != NULL)
VarSetText(svText,value,privilege);
}
/**
* @brief Update a SICS variable with the current status
*
* @param input, status from device
* @param identifier, status query identifier
*/
void AO_istatus(int input, char *identifier) {
int testVal;
if (strcasecmp(identifier, "QKK:TI1") == 0) {
testVal = 48 & input;
if (testVal == 32) { // Fast shutter open
setTextSICSVar(SV_FastShutter, "OPEN");
} else if (testVal == 16) { // Fast shutter closed
setTextSICSVar(SV_FastShutter, "CLOSED");
} else if (testVal == 48) {
setTextSICSVar(SV_FastShutter, "INBETWEEN");
} else { // 0 ie both limits activated
setTextSICSVar(SV_FastShutter, "FAULT");
}
} else if (strcasecmp(identifier, "PLP:BAT:POS") == 0) {
// Handle platypus:BAT POS
switch (input) {
case -1:
setTextSICSVar(SV_BATPOS, "OUT");
break;
case 0:
setTextSICSVar(SV_BATPOS, "IN");
break;
case 1:
setTextSICSVar(SV_BATPOS, "OSCILLATING");
default:
break;
}
}
}