Skip to content
Snippets Groups Projects
Commit 071627df authored by Hinko Kocevar's avatar Hinko Kocevar
Browse files

Merge branch 'jira_pbibcm_228_aux' into 'master'

PBIBCM-228 Add auxiliary Upper/Lower/Hysteresis Threshold PVs

See merge request beam-diagnostics/bde/modules/adsis8300bcm!38
parents c154ed5c 8e40b8b0
No related branches found
No related tags found
No related merge requests found
Pipeline #121300 failed
......@@ -1173,6 +1173,66 @@ record(ai, "$(P)$(R)CalibrationSample4R")
field(SCAN, "I/O Intr")
}
record(ao, "$(P)$(R)AuxUpperThreshold")
{
field(DTYP, "asynFloat64")
field(OUT, "@asyn($(PORT),$(ADDR=0),$(TIMEOUT=1))BCM.ACCT.AUX_UPPER_THRESHOLD")
field(EGU, "V")
field(PREC, "4")
field(DRVH, "1.0")
field(DRVL, "-1.0")
field(ASG, "critical")
info(autosaveFields, "VAL")
}
record(ai, "$(P)$(R)AuxUpperThresholdR")
{
field(DTYP, "asynFloat64")
field(INP, "@asyn($(PORT),$(ADDR=0),$(TIMEOUT=1))BCM.ACCT.AUX_UPPER_THRESHOLD")
field(EGU, "V")
field(PREC, "4")
field(SCAN, "I/O Intr")
}
record(ao, "$(P)$(R)AuxLowerThreshold")
{
field(DTYP, "asynFloat64")
field(OUT, "@asyn($(PORT),$(ADDR=0),$(TIMEOUT=1))BCM.ACCT.AUX_LOWER_THRESHOLD")
field(EGU, "V")
field(PREC, "4")
field(DRVH, "1.0")
field(DRVL, "-1.0")
field(ASG, "critical")
info(autosaveFields, "VAL")
}
record(ai, "$(P)$(R)AuxLowerThresholdR")
{
field(DTYP, "asynFloat64")
field(INP, "@asyn($(PORT),$(ADDR=0),$(TIMEOUT=1))BCM.ACCT.AUX_LOWER_THRESHOLD")
field(EGU, "V")
field(PREC, "4")
field(SCAN, "I/O Intr")
}
record(ao, "$(P)$(R)AuxHysteresisThreshold")
{
field(DTYP, "asynFloat64")
field(OUT, "@asyn($(PORT),$(ADDR=0),$(TIMEOUT=1))BCM.ACCT.AUX_HYSTERESIS_THRESHOLD")
field(EGU, "V")
field(PREC, "4")
field(DRVH, "1.0")
field(DRVL, "-1.0")
field(ASG, "critical")
info(autosaveFields, "VAL")
}
record(ai, "$(P)$(R)AuxHysteresisThresholdR")
{
field(DTYP, "asynFloat64")
field(INP, "@asyn($(PORT),$(ADDR=0),$(TIMEOUT=1))BCM.ACCT.AUX_HYSTERESIS_THRESHOLD")
field(EGU, "V")
field(PREC, "4")
field(SCAN, "I/O Intr")
}
record(ao, "$(P)$(R)BeamOverThreshold")
{
field(DTYP, "asynFloat64")
......
......@@ -267,6 +267,9 @@ sis8300bcm::sis8300bcm(const char *portName, const char *devicePath,
createParam(BCMAcctCalibrationSample2String, asynParamFloat64, &BCMAcctCalibrationSample2);
createParam(BCMAcctCalibrationSample3String, asynParamFloat64, &BCMAcctCalibrationSample3);
createParam(BCMAcctCalibrationSample4String, asynParamFloat64, &BCMAcctCalibrationSample4);
createParam(BCMAcctAuxUpperThresholdString, asynParamFloat64, &BCMAcctAuxUpperThreshold);
createParam(BCMAcctAuxLowerThresholdString, asynParamFloat64, &BCMAcctAuxLowerThreshold);
createParam(BCMAcctAuxHysteresisThresholdString, asynParamFloat64, &BCMAcctAuxHysteresisThreshold);
createParam(BCMAcctBeamAboveThresholdString, asynParamFloat64, &BCMAcctBeamAboveThreshold);
createParam(BCMAcctLeakyCoefficientString, asynParamFloat64, &BCMAcctLeakyCoefficient);
createParam(BCMAcctLeakyThresholdString, asynParamFloat64, &BCMAcctLeakyThreshold);
......@@ -905,6 +908,27 @@ int sis8300bcm::readbackParameters()
}
setDoubleParam(addr, BCMAcctCalibrationSample4, doubleValue);
ret = sis8300drvbcm_get_channel_aux_upper_threshold(mDeviceHandle, addr, &doubleValue);
if (ret) {
asynPrintError(pasynUserSelf, "sis8300drvbcm_get_channel_aux_upper_threshold returned %d", ret);
return ret;
}
setDoubleParam(addr, BCMAcctAuxUpperThreshold, doubleValue);
ret = sis8300drvbcm_get_channel_aux_lower_threshold(mDeviceHandle, addr, &doubleValue);
if (ret) {
asynPrintError(pasynUserSelf, "sis8300drvbcm_get_channel_aux_lower_threshold returned %d", ret);
return ret;
}
setDoubleParam(addr, BCMAcctAuxLowerThreshold, doubleValue);
ret = sis8300drvbcm_get_channel_aux_hysteresis_threshold(mDeviceHandle, addr, &doubleValue);
if (ret) {
asynPrintError(pasynUserSelf, "sis8300drvbcm_get_channel_aux_hysteresis_threshold returned %d", ret);
return ret;
}
setDoubleParam(addr, BCMAcctAuxHysteresisThreshold, doubleValue);
ret = sis8300drvbcm_get_channel_beam_above_threshold(mDeviceHandle, addr, &doubleValue);
if (ret) {
asynPrintError(pasynUserSelf, "sis8300drvbcm_get_channel_beam_above_threshold returned %d", ret);
......@@ -2111,6 +2135,21 @@ asynStatus sis8300bcm::writeFloat64(asynUser *pasynUser, epicsFloat64 value)
if (ret) {
asynPrintError(pasynUser, "sis8300drvbcm_set_channel_errant_window_end returned %d", ret);
}
} else if (function == BCMAcctAuxUpperThreshold) {
ret = sis8300drvbcm_set_channel_aux_upper_threshold(mDeviceHandle, addr, value);
if (ret) {
asynPrintError(pasynUser, "sis8300drvbcm_set_channel_aux_upper_threshold returned %d", ret);
}
} else if (function == BCMAcctAuxLowerThreshold) {
ret = sis8300drvbcm_set_channel_aux_lower_threshold(mDeviceHandle, addr, value);
if (ret) {
asynPrintError(pasynUser, "sis8300drvbcm_set_channel_aux_lower_threshold returned %d", ret);
}
} else if (function == BCMAcctAuxHysteresisThreshold) {
ret = sis8300drvbcm_set_channel_aux_hysteresis_threshold(mDeviceHandle, addr, value);
if (ret) {
asynPrintError(pasynUser, "sis8300drvbcm_set_channel_aux_hysteresis_threshold returned %d", ret);
}
} else if (function == BCMAcctBeamAboveThreshold) {
asynPrintDeviceInfo(pasynUserSelf, "set_channel_beam_above_threshold: addr %d, value %f", addr, value);
ret = sis8300drvbcm_set_channel_beam_above_threshold(mDeviceHandle, addr, value);
......
......@@ -163,6 +163,9 @@
#define BCMAcctCalibrationSample2String "BCM.ACCT.CALIBRATION_SAMPLE2"
#define BCMAcctCalibrationSample3String "BCM.ACCT.CALIBRATION_SAMPLE3"
#define BCMAcctCalibrationSample4String "BCM.ACCT.CALIBRATION_SAMPLE4"
#define BCMAcctAuxUpperThresholdString "BCM.ACCT.AUX_UPPER_THRESHOLD"
#define BCMAcctAuxLowerThresholdString "BCM.ACCT.AUX_LOWER_THRESHOLD"
#define BCMAcctAuxHysteresisThresholdString "BCM.ACCT.AUX_HYSTERESIS_THRESHOLD"
#define BCMAcctBeamAboveThresholdString "BCM.ACCT.BEAM_ABOVE_THRESHOLD"
#define BCMAcctLeakyCoefficientString "BCM.ACCT.LEAKY_INTEGRATOR_COEFFICIENT"
#define BCMAcctLeakyThresholdString "BCM.ACCT.LEAKY_INTEGRATOR_THRESHOLD"
......@@ -387,6 +390,9 @@ protected:
int BCMAcctCalibrationSample2;
int BCMAcctCalibrationSample3;
int BCMAcctCalibrationSample4;
int BCMAcctAuxUpperThreshold;
int BCMAcctAuxLowerThreshold;
int BCMAcctAuxHysteresisThreshold;
int BCMAcctBeamAboveThreshold;
int BCMAcctLeakyCoefficient;
int BCMAcctLeakyThreshold;
......
......@@ -146,6 +146,9 @@ extern "C" {
#define SIS8300BCM_ACCT_X_LEAKY_THR_REG 0x02E
#define SIS8300BCM_ACCT_X_FLATTOP_RISING_OFF 0x02F
#define SIS8300BCM_ACCT_X_FLATTOP_FALLING_OFF 0x030
#define SIS8300BCM_ACCT_X_AUX_UPPER_THRESHOLD_OFF 0x031
#define SIS8300BCM_ACCT_X_AUX_LOWER_THRESHOLD_OFF 0x032
#define SIS8300BCM_ACCT_X_AUX_HYSTERESIS_THRESHOLD_OFF 0x033
#define SIS8300BCM_ACCT_X_BEAM_ABOVE_THRESHOLD_REG 0x034
#define SIS8300BCM_ACCT_X_TRIGGER_WIDTH_OFF 0x035
#define SIS8300BCM_ACCT_X_AUTO_FLATTOP_RISING_OFF 0x036
......
......@@ -2762,6 +2762,96 @@ int sis8300drvbcm_set_enable_calibration_pulse(sis8300drv_usr *sisuser, unsigned
return ret;
}
// used to control aux upper threshold
int sis8300drvbcm_set_channel_aux_upper_threshold(sis8300drv_usr *sisuser, unsigned int channel, double threshold)
{
unsigned int reg = SIS8300BCM_CHANNEL_BLOCK_BASE + \
(SIS8300BCM_CHANNEL_BLOCK_SIZE * channel) + \
SIS8300BCM_ACCT_BANK_OFF + \
SIS8300BCM_ACCT_X_AUX_UPPER_THRESHOLD_OFF;
// register takes a signed value
int value = (int)(threshold * 32768);
// printf("%s: channel %d, reg 0x%x, value: %d\n", __func__, channel, reg, value);
return sis8300drv_reg_write(sisuser, reg, value);
}
int sis8300drvbcm_get_channel_aux_upper_threshold(sis8300drv_usr *sisuser, unsigned int channel, double *threshold)
{
unsigned int reg = SIS8300BCM_CHANNEL_BLOCK_BASE + \
(SIS8300BCM_CHANNEL_BLOCK_SIZE * channel) + \
SIS8300BCM_ACCT_BANK_OFF + \
SIS8300BCM_ACCT_X_AUX_UPPER_THRESHOLD_OFF;
// register holds a signed value
int value;
int ret = sis8300drv_reg_read(sisuser, reg, (unsigned *)&value);
if (ret) {
return ret;
}
*threshold = (value / 32768.0);
// printf("%s: channel %d, reg 0x%x, value: %d\n", __func__, channel, reg, value);
return ret;
}
// used to control aux lower threshold
int sis8300drvbcm_set_channel_aux_lower_threshold(sis8300drv_usr *sisuser, unsigned int channel, double threshold)
{
unsigned int reg = SIS8300BCM_CHANNEL_BLOCK_BASE + \
(SIS8300BCM_CHANNEL_BLOCK_SIZE * channel) + \
SIS8300BCM_ACCT_BANK_OFF + \
SIS8300BCM_ACCT_X_AUX_LOWER_THRESHOLD_OFF;
// register takes a signed value
int value = (int)(threshold * 32768);
// printf("%s: channel %d, reg 0x%x, value: %d\n", __func__, channel, reg, value);
return sis8300drv_reg_write(sisuser, reg, value);
}
int sis8300drvbcm_get_channel_aux_lower_threshold(sis8300drv_usr *sisuser, unsigned int channel, double *threshold)
{
unsigned int reg = SIS8300BCM_CHANNEL_BLOCK_BASE + \
(SIS8300BCM_CHANNEL_BLOCK_SIZE * channel) + \
SIS8300BCM_ACCT_BANK_OFF + \
SIS8300BCM_ACCT_X_AUX_LOWER_THRESHOLD_OFF;
// register holds a signed value
int value;
int ret = sis8300drv_reg_read(sisuser, reg, (unsigned *)&value);
if (ret) {
return ret;
}
*threshold = (value / 32768.0);
// printf("%s: channel %d, reg 0x%x, value: %d\n", __func__, channel, reg, value);
return ret;
}
// used to control aux hysteresis threshold
int sis8300drvbcm_set_channel_aux_hysteresis_threshold(sis8300drv_usr *sisuser, unsigned int channel, double threshold)
{
unsigned int reg = SIS8300BCM_CHANNEL_BLOCK_BASE + \
(SIS8300BCM_CHANNEL_BLOCK_SIZE * channel) + \
SIS8300BCM_ACCT_BANK_OFF + \
SIS8300BCM_ACCT_X_AUX_HYSTERESIS_THRESHOLD_OFF;
// register takes a signed value
int value = (int)(threshold * 32768);
// printf("%s: channel %d, reg 0x%x, value: %d\n", __func__, channel, reg, value);
return sis8300drv_reg_write(sisuser, reg, value);
}
int sis8300drvbcm_get_channel_aux_hysteresis_threshold(sis8300drv_usr *sisuser, unsigned int channel, double *threshold)
{
unsigned int reg = SIS8300BCM_CHANNEL_BLOCK_BASE + \
(SIS8300BCM_CHANNEL_BLOCK_SIZE * channel) + \
SIS8300BCM_ACCT_BANK_OFF + \
SIS8300BCM_ACCT_X_AUX_HYSTERESIS_THRESHOLD_OFF;
// register holds a signed value
int value;
int ret = sis8300drv_reg_read(sisuser, reg, (unsigned *)&value);
if (ret) {
return ret;
}
*threshold = (value / 32768.0);
// printf("%s: channel %d, reg 0x%x, value: %d\n", __func__, channel, reg, value);
return ret;
}
// used to control beam above threshold
int sis8300drvbcm_set_channel_beam_above_threshold(sis8300drv_usr *sisuser, unsigned int channel, double threshold)
{
......
......@@ -211,6 +211,12 @@ int sis8300drvbcm_set_channel_errant_window_start(sis8300drv_usr *sisuser, unsig
int sis8300drvbcm_get_channel_errant_window_start(sis8300drv_usr *sisuser, unsigned int channel, double *start);
int sis8300drvbcm_set_channel_errant_window_end(sis8300drv_usr *sisuser, unsigned int channel, double end);
int sis8300drvbcm_get_channel_errant_window_end(sis8300drv_usr *sisuser, unsigned int channel, double *end);
int sis8300drvbcm_set_channel_aux_upper_threshold(sis8300drv_usr *sisuser, unsigned int channel, double threshold);
int sis8300drvbcm_get_channel_aux_upper_threshold(sis8300drv_usr *sisuser, unsigned int channel, double *threshold);
int sis8300drvbcm_set_channel_aux_lower_threshold(sis8300drv_usr *sisuser, unsigned int channel, double threshold);
int sis8300drvbcm_get_channel_aux_lower_threshold(sis8300drv_usr *sisuser, unsigned int channel, double *threshold);
int sis8300drvbcm_set_channel_aux_hysteresis_threshold(sis8300drv_usr *sisuser, unsigned int channel, double threshold);
int sis8300drvbcm_get_channel_aux_hysteresis_threshold(sis8300drv_usr *sisuser, unsigned int channel, double *threshold);
int sis8300drvbcm_set_channel_beam_above_threshold(sis8300drv_usr *sisuser, unsigned int channel, double threshold);
int sis8300drvbcm_get_channel_beam_above_threshold(sis8300drv_usr *sisuser, unsigned int channel, double *threshold);
int sis8300drvbcm_get_channel_trigger_width(sis8300drv_usr *sisuser, unsigned int channel, double *width);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment