Commit 5e97000d authored by acq's avatar acq
Browse files

Add qdc driver and controller (Cadarache)

parent 5232bd05
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#include "CAENQdcController.h"
#include "drivers/global/DriversCommands.h"
#include "controllers/common/family/Families.h"
#include <boost/thread/thread.hpp>
#include <lstdpp128/lstdpp.h>
using namespace std;
using namespace boost;
namespace npp {
const string CAENQdcController::TYPE = "psd_controller";
/*
* Constructor
*/
CAENQdcController::CAENQdcController(const string& name) : CAENAdcController(name) {
setFamily(family::ACQUISITION, family::SETTING);
// Register properties
triggerHoldOff.init(this, NOSAVE, "trigger_holdoff");
triggerThreshold.init(this, NOSAVE, "trigger_threshold");
selfTrigger.init(this, NOSAVE, "self_trigger");
chargeSensitivity.init(this, NOSAVE, "charge_sensitivity");
gateWidth.init(this, NOSAVE, "long_gate");
preGate.init(this, NOSAVE, "pre_gate");
baselineMean.init(this, NOSAVE, "base_mean");
m_dgtzDriver.init(this, "qdc_driver");
registerFunction(TYPE);
}
/*
* Destructor
*/
CAENQdcController::~CAENQdcController() {
}
/*
* postConfiguration
*/
void CAENQdcController::postConfiguration() {
registerRefresher(recordLength, &CAENQdcController::refreshRecordLengthProperty, this);
registerRefresher(nbChannels, &CAENQdcController::refreshNbChannelsProperty, this);
registerRefresher(dppAcqMode, &CAENQdcController::refreshDppAcqModeProperty, this);
registerRefresher(displayChannel, &CAENQdcController::refreshDisplayChannelProperty, this);
registerRefresher(triggerHoldOff, &CAENQdcController::refreshTriggerHoldOffProperty, this);
registerRefresher(triggerThreshold, &CAENQdcController::refreshTriggerThresholdProperty, this);
registerRefresher(selfTrigger, &CAENQdcController::refreshSelfTriggerProperty, this);
registerRefresher(chargeSensitivity, &CAENQdcController::refreshChargeSensitivityProperty, this);
registerRefresher(gateWidth, &CAENQdcController::refreshGateWidthProperty, this);
registerRefresher(preGate, &CAENQdcController::refreshPreGateProperty, this);
registerRefresher(baselineMean, &CAENQdcController::refreshBaselineMean, this);
registerRefresher(channelActive, &CAENQdcController::refreshChannelActiveProperty, this);
registerRefresher(dcOffset, &CAENQdcController::refreshDcOffsetProperty, this);
registerRefresher(preTrigger, &CAENQdcController::refreshPreTriggerProperty, this);
registerRefresher(pulsePolarity, &CAENQdcController::refreshPulsePolarityProperty, this);
updateBoardProperties();
cardType = lstdpp128::C1751_PSD;
}
void CAENQdcController::refreshRecordLengthProperty(int32 aValue) throw (CannotSetValue) {
m_dgtzDriver->recordLength = aValue;
}
void CAENQdcController::refreshNbChannelsProperty(int32 aValue) throw (CannotSetValue) {
cout << "CAENQdcController::refreshNbChannelsProperty : " << aValue << endl;
minRange = 0;
maxRange = aValue - 1;
m_dgtzDriver->nbChannels = aValue;
if (displayChannel() >= aValue)
displayChannel = aValue - 1;
}
void CAENQdcController::refreshDppAcqModeProperty(int32 aValue) throw (CannotSetValue) {
CAENAdcController::refreshDppAcqModeProperty(aValue);
m_dgtzDriver->dppAcqMode = aValue;
boost::thread td(boost::bind(&CAENQdcController::initBoard, this));
}
void CAENQdcController::refreshDisplayChannelProperty(int32 aChannel) throw (CannotSetValue) {
cout << "CAENQdcController::refreshDisplayChannelProperty : " << aChannel << endl;
float64 holdOff = m_dgtzDriver->triggerHoldOff() / 1000.0;
if (holdOff == 0)
holdOff = 0.2;
triggerHoldOff.update(holdOff);
int32 trigTrsd = m_dgtzDriver->triggerThreshold.get(aChannel);
if (trigTrsd == 0)
trigTrsd = 20;
triggerThreshold.update(trigTrsd);
selfTrigger.update(m_dgtzDriver->selfTrigger.get(aChannel));
int32 chargeSens = m_dgtzDriver->chargeSensitivity.get(aChannel);
chargeSensitivity.update(chargeSens);
float64 gWidth = m_dgtzDriver->gateWidth.get(aChannel) / 1000.0;
if (gWidth == 0.0)
gWidth = 1.0;
gateWidth.update(gWidth);
float64 pGate = m_dgtzDriver->preGate.get(aChannel) / 1000.0;
if (pGate == 0)
pGate = 0.1;
preGate.update(pGate);
int32 baseAvrg = m_dgtzDriver->baselineMean.get(aChannel);
if (baseAvrg == 0)
baseAvrg = 4;
baselineMean.update(baseAvrg);
channelActive.update(m_dgtzDriver->channelActive.get(aChannel));
int32 offSet = m_dgtzDriver->dcOffset.get(aChannel);
if (offSet == 0)
offSet = 10;
dcOffset.update(offSet);
int32 preTrig = m_dgtzDriver->preTrigger.get(aChannel);
if (preTrig == 0)
preTrig = 500;
preTrigger.update(preTrig);
pulsePolarity.update(m_dgtzDriver->pulsePolarity.get(aChannel));
initChannel(aChannel);
}
void CAENQdcController::refreshTriggerHoldOffProperty(float64 aValue) throw (CannotSetValue) {
m_dgtzDriver->triggerHoldOff.update((int32)(aValue * 1000));
boost::thread td(boost::bind(&CAENQdcController::writeParam, this));
}
void CAENQdcController::refreshTriggerThresholdProperty(int32 aValue) throw (CannotSetValue) {
m_dgtzDriver->triggerThreshold.set(displayChannel(), aValue);
boost::thread td(boost::bind(&CAENQdcController::writeParam, this));
}
void CAENQdcController::refreshSelfTriggerProperty(int32 aValue) throw (CannotSetValue) {
m_dgtzDriver->selfTrigger.set(displayChannel(), aValue);
boost::thread td(boost::bind(&CAENQdcController::writeParam, this));
}
void CAENQdcController::refreshChargeSensitivityProperty(int32 aValue) throw (CannotSetValue) {
m_dgtzDriver->chargeSensitivity.set(displayChannel(), aValue);
boost::thread td(boost::bind(&CAENQdcController::writeParam, this));
}
void CAENQdcController::refreshGateWidthProperty(float64 aValue) throw (CannotSetValue) {
m_dgtzDriver->gateWidth.set(displayChannel(), (int32)(aValue * 1000));
boost::thread td(boost::bind(&CAENQdcController::writeParam, this));
}
void CAENQdcController::refreshPreGateProperty(float64 aValue) throw (CannotSetValue) {
m_dgtzDriver->preGate.set(displayChannel(), (int32)(aValue * 1000));
boost::thread td(boost::bind(&CAENQdcController::writeParam, this));
}
void CAENQdcController::refreshBaselineMean(int32 aValue) throw (CannotSetValue) {
m_dgtzDriver->baselineMean.set(displayChannel(), aValue);
boost::thread td(boost::bind(&CAENQdcController::writeParam, this));
}
void CAENQdcController::refreshChannelActiveProperty(int32 aValue) throw (CannotSetValue) {
m_dgtzDriver->channelActive.set(displayChannel(), aValue);
// Update channel mask
int32 mask = 0;
for (int32 i=0; i<m_dgtzDriver->nbChannels(); ++i) {
if (m_dgtzDriver->channelActive.get(i))
mask += (m_dgtzDriver->channelActive.get(i) << i);
}
m_dgtzDriver->channelMask = mask;
}
void CAENQdcController::refreshDcOffsetProperty(int32 aValue) throw (CannotSetValue) {
m_dgtzDriver->dcOffset.set(displayChannel(), aValue);
boost::thread td(boost::bind(&CAENQdcController::writeParam, this));
}
void CAENQdcController::refreshPreTriggerProperty(int32 aValue) throw (CannotSetValue) {
m_dgtzDriver->preTrigger.set(displayChannel(), aValue);
boost::thread td(boost::bind(&CAENQdcController::writeParam, this));
}
void CAENQdcController::refreshPulsePolarityProperty(int32 aValue) throw (CannotSetValue) {
m_dgtzDriver->pulsePolarity.set(displayChannel(), aValue);
boost::thread td(boost::bind(&CAENQdcController::writeParam, this));
}
void CAENQdcController::updateBoardProperties() {
modelName.update(m_dgtzDriver->modelName());
channels.update(m_dgtzDriver->channels());
nbChannels.update(m_dgtzDriver->nbChannels());
minRange = 0;
maxRange = m_dgtzDriver->nbChannels() - 1;
dppAcqMode.update(m_dgtzDriver->dppAcqMode());
}
void CAENQdcController::writeParam() {
m_dgtzDriver.execute(caen_qdc::CAENQdcDriver::WRITE_PARAMETERS_COMMAND, false);
}
void CAENQdcController::initBoard() {
m_dgtzDriver.execute(driver::INIT_COMMAND, false);
}
void CAENQdcController::initChannel(int32 aChannel) {
m_dgtzDriver->triggerHoldOff.update((int32)(triggerHoldOff() * 1000));
m_dgtzDriver->triggerThreshold.set(aChannel, triggerThreshold());
m_dgtzDriver->selfTrigger.set(aChannel,selfTrigger());
m_dgtzDriver->chargeSensitivity.set(aChannel, chargeSensitivity());
m_dgtzDriver->preGate.set(aChannel, (int32)(preGate() * 1000));
m_dgtzDriver->gateWidth.set(aChannel, (int32)(gateWidth() * 1000));
m_dgtzDriver->preGate.set(aChannel, (int32)(preGate() * 1000));
m_dgtzDriver->baselineMean.set(aChannel, baselineMean());
m_dgtzDriver->channelActive.set(aChannel, channelActive());
m_dgtzDriver->dcOffset.set(aChannel, dcOffset());
m_dgtzDriver->preTrigger.set(aChannel, preTrigger());
m_dgtzDriver->pulsePolarity.set(aChannel, pulsePolarity());
// Update channel mask
int32 mask = 0;
for (int32 i=0; i<m_dgtzDriver->nbChannels(); ++i) {
if (m_dgtzDriver->channelActive.get(i))
mask += (m_dgtzDriver->channelActive.get(i) << i);
}
m_dgtzDriver->channelMask = mask;
m_dgtzDriver->dcOffset.set(aChannel, dcOffset());
m_dgtzDriver->preTrigger.set(aChannel, preTrigger());
m_dgtzDriver->pulsePolarity.set(aChannel, pulsePolarity());
boost::thread td(boost::bind(&CAENQdcController::writeParam, this));
}
void CAENQdcController::clearData() {
commandProgression = 0;
m_dgtzDriver.execute(caen_qdc::CAENQdcDriver::CLEAR_COMMAND, true);
commandProgression = 100;
}
}
/*
* Nomad Instrument Control Software
*
* Copyright 2011 Institut Laue-Langevin
*
* Licensed under the EUPL, Version 1.1 only (the "License");
* You may not use this work except in compliance with the Licence.
* You may obtain a copy of the Licence at:
*
* http://joinup.ec.europa.eu/software/page/eupl
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the Licence is distributed on an "AS IS" basis,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the Licence for the specific language governing permissions and
* limitations under the Licence.
*/
#ifndef CAENQDCCONTROLLER_H
#define CAENQDCCONTROLLER_H
#include "CAENAdcController.h"
#include "drivers/caen_qdc/CAENQdcDriver.h"
namespace npp {
/*!
* \class CAENV1724Driver
* \brief Main class for the CAENV1724Driver device driver
*
* \par
* Class for CAENV1724Driver driver. Implements DeviceDriver methods.
* \par
* The CAENV1724Driver device manages the global functionality of the CAEN V1724 VME Digitiser.
*/
class CAENQdcController: public CAENAdcController {
public:
//! Driver type value
static const std::string TYPE;
/*!
* \brief Constructor
* \param[in] name the name of the device driver
*/
CAENQdcController(const std::string& name);
/*!
* \brief Destructor
*/
virtual ~CAENQdcController();
/**
* \brief Postconfiguration
*/
virtual void postConfiguration();
// Channels properties
Property<float64>triggerHoldOff;
Property<int32>triggerThreshold;
Property<int32>selfTrigger;
Property<int32>chargeSensitivity;
Property<float64>gateWidth;
Property<float64>preGate;
Property<int32>baselineMean;
void initBoard();
protected:
DriverPtr<caen_qdc::CAENQdcDriver> m_dgtzDriver;
virtual void refreshNbChannelsProperty(int32 aValue) throw (CannotSetValue);
virtual void refreshDisplayChannelProperty(int32 aValue) throw (CannotSetValue);
virtual void refreshDppAcqModeProperty(int32 aValue) throw (CannotSetValue);
virtual void refreshPulsePolarityProperty(int32 aValue) throw (CannotSetValue);
virtual void updateBoardProperties();
private:
virtual void refreshChannelActiveProperty(int32 aValue) throw (CannotSetValue);
virtual void refreshRecordLengthProperty(int32 aValue) throw (CannotSetValue);
void refreshTriggerHoldOffProperty(float64 aValue) throw (CannotSetValue);
void refreshTriggerThresholdProperty(int32 aValue) throw (CannotSetValue);
void refreshSelfTriggerProperty(int32 aValue) throw (CannotSetValue);
void refreshChargeSensitivityProperty(int32 aValue) throw (CannotSetValue);
void refreshGateWidthProperty(float64 aValue) throw (CannotSetValue);
void refreshPreGateProperty(float64 aValue) throw (CannotSetValue);
void refreshBaselineMean(int32 aValue) throw (CannotSetValue);
void refreshDcOffsetProperty(int32 aValue) throw (CannotSetValue);
void refreshPreTriggerProperty(int32 aValue) throw (CannotSetValue);
virtual void clearData();
virtual void writeParam();
virtual void initChannel(int32 aChannel);
};
}
#endif //CAENQDCCONTROLLER_H
......@@ -3,6 +3,7 @@
<controller class="npp::CAENCfdController"/>
<controller class="npp::CAENPksController"/>
<controller class="npp::CAENPsdController"/>
<controller class="npp::CAENQdcController"/>
<controller class="npp::DPPAcquisitionController"/>
<controller class="npp::DPPLiveProcessCountRelay"/>
<controller class="npp::BidimHistoDetectorElement"/>
......
# Board Params
qdc_controller.boardParamsTitle=Board Parameters
qdc_controller.nbChannels=Nb channels:
qdc_controller.acqMode=Acquisition mode:
# Channel General Settings
qdc_controller.generalSettingsTitle=General Settings
qdc_controller.recordLength=Record length
qdc_controller.displayChannel=Channel
qdc_controller.channelEnabled=Channel enabled
qdc_controller.pulsePolarity=Pulse polarity
qdc_controller.dcOffset=DC offset
qdc_controller.enabledCheckedValue=1
qdc_controller.enabledUncheckedValue=0
# Timing Filter
qdc_controller.selfTrigger=Self-trigger
qdc_controller.stenabledLabel=Enable
qdc_controller.stenabledValue=1
qdc_controller.stdisableLabel=Disable
qdc_controller.stdisableValue=0
qdc_controller.timingFilterTitle=Trigger and Timing Filter
qdc_controller.preTrigger=Pre-trigger
qdc_controller.threshold=Threshold
qdc_controller.triggerHoldOff=Trigger holdoff
qdc_controller.charge_sensitivity=Charge sens.
qdc_controller.fcversuslsb=fc/LSB
qdc_controller.20csValue=0
qdc_controller.20csLabel=20
qdc_controller.40csValue=1
qdc_controller.40csLabel=40
qdc_controller.80csValue=2
qdc_controller.80csLabel=80
qdc_controller.160csValue=3
qdc_controller.160csLabel=160
qdc_controller.320csValue=4
qdc_controller.320csLabel=320
qdc_controller.640csValue=5
qdc_controller.640csLabel=640
# Energy Filter
qdc_controller.energyFilterTitle=Energy Filter
qdc_controller.baselineMean=Baseline mean
qdc_controller.gateWidth=Gate width
qdc_controller.preGate=Pre gate
# Units
qdc_controller.lsbUnit=LSB
qdc_controller.uSecUnit=us
# Combo polarity
qdc_controller.positiveValue=0
qdc_controller.positiveLabel=Positive
qdc_controller.negativeValue=1
qdc_controller.negativeLabel=Negative
# Combo digital gain
qdc_controller.gain1Value=0
qdc_controller.gain1Label=1
qdc_controller.gain2Value=1
qdc_controller.gain2Label=2
qdc_controller.gain4Value=2
qdc_controller.gain4Label=4
qdc_controller.gain8Value=3
qdc_controller.gain8Label=8
# Combo decimation
qdc_controller.dec0Value=0
qdc_controller.dec0Label=0
qdc_controller.dec2Value=1
qdc_controller.dec2Label=2
qdc_controller.dec4Value=2
qdc_controller.dec4Label=4
qdc_controller.dec8Value=3
qdc_controller.dec8Label=8
# Combo trigger smoothing
qdc_controller.smooth1Value=1
qdc_controller.smooth1Label=1
qdc_controller.smooth2Value=2
qdc_controller.smooth2Label=2
qdc_controller.smooth4Value=4
qdc_controller.smooth4Label=4
qdc_controller.smooth8Value=8
qdc_controller.smooth8Label=8
qdc_controller.smooth16Value=16
qdc_controller.smooth16Label=16
qdc_controller.smooth32Value=32
qdc_controller.smooth32Label=32
# Combo base mean
qdc_controller.base0Value=0
qdc_controller.base0Label=Fixed
qdc_controller.base8Value=1
qdc_controller.base8Label=8
qdc_controller.base16Value=2
qdc_controller.base16Label=16
qdc_controller.base32Value=3
qdc_controller.base32Label=32
qdc_controller.base64Value=4
qdc_controller.base64Label=64
qdc_controller.base128Value=5
qdc_controller.base128Label=128
qdc_controller.base256Value=6
qdc_controller.base256Label=256
qdc_controller.base512Value=7
qdc_controller.base512Label=512
# Combo peak mean
qdc_controller.peak1Value=0
qdc_controller.peak1Label=1
qdc_controller.peak4Value=1
qdc_controller.peak4Label=4
qdc_controller.peak16Value=2
qdc_controller.peak16Label=16
qdc_controller.peak64Value=3
qdc_controller.peak64Label=64
# Combo acq mode
qdc_controller.oscilloscopeValue=0
qdc_controller.oscilloscopeLabel=Oscilloscope
qdc_controller.histogramValue=1
qdc_controller.histogramLabel=Histogram
qdc_controller.waveformValue=2
qdc_controller.waveformLabel=Wave Form
# Plot group
qdc_controller.histogranPlotTitle=Energy histogram
qdc_controller.inputPlotTitle=Signals
qdc_controller.histoPrefix=Histogram
qdc_controller.signalPrefix=Signals
qdc_controller.postTrigPrefix=Post trigger samples
qdc_controller.offsetPrefix=Input DC offset
qdc_controller.histogramLegend=Energy
qdc_controller.inputLegend=Input
qdc_controller.longGateLegend=Long Gate
qdc_controller.shortGateLegend=Short Gate
qdc_controller.triggerLegend=Trigger
qdc_controller.percentSuffix=%
<plotdatas>
<plotdata key="pha_histogram_plot" legend_key="qdc_controller.histogramLegend" color="FFFFFF" plugins="SETUP">
<dataY p_role="qdc_controller1" p_name="curve0_table"/>
</plotdata>
<plotdata key="pha_input_plot" legend_key="qdc_controller.inputLegend" color="F60B0B" plugins="SETUP">
<dataY p_role="qdc_controller1" p_name="curve1_table"/>
</plotdata>
<plotdata key="pha_trapezoid_plot" legend_key="qdc_controller.trapezoidLegend" color="0DC93D" plugins="SETUP">
<dataY p_role="qdc_controller1" p_name="curve2_table"/>
</plotdata>
<plotdata key="pha_trigger_plot" legend_key="qdc_controller.triggerLegend" color="FFFD18" plugins="SETUP">
<dataY p_role="qdc_controller1" p_name="curve3_table"/>
</plotdata>
<plotdata key="pha_peaking_plot" legend_key="qdc_controller.peakingLegend" color="18F0FF" plugins="SETUP">
<dataY p_role="qdc_controller1" p_name="curve4_table"/>
</plotdata>
</plotdatas>
\ No newline at end of file
<controller_plugin_config type="qdc_controller">
<image key="HARDWARE_VME_MODULE"/>
<settings view="qdc_controllerView.xml"/>
</controller_plugin_config>
<?xml version="1.0" encoding="ISO-8859-1" ?>
<controller type="qdc_controller">
<property name="nb_channels" type="int32" max_length="2">
<strictly_positive/>
</property>
<property name="display_channel" type="int32" max_length="3">
<property_range min_property="min_range" max_property="max_range"/>
</property>
<property name="record_length" type="int32" max_length="6">
</property>
<property name="trigger_holdoff" type="float64" max_length="6">
<decimal_format nb_decimal_places="3"/>
<strictly_positive/>
</property>
<property name="trigger_threshold" type="int32" max_length="3">
<strictly_positive/>
</property>