Commit 69a043bb authored by acq's avatar acq
Browse files

add cfd2 caen driver for fipps

parent 8245846b
......@@ -124,6 +124,7 @@ void CAENCfdController::postConfiguration() {
void CAENCfdController::refreshRecordLengthProperty(int32 aValue) throw (CannotSetValue) {
m_dgtzDriver->recordLength.update(aValue);
boost::thread td(boost::bind(&CAENCfdController::writeParam, this));
}
void CAENCfdController::refreshcfdTrapProperty(int32 aValue) throw (CannotSetValue) {
......@@ -447,12 +448,12 @@ void CAENCfdController::updateBoardProperties() {
void CAENCfdController::writeParam() {
m_dgtzDriver.execute(caen_cfd::CAENCfdDriver::WRITE_PARAMETERS_COMMAND, true);
m_dgtzDriver.execute(caen_cfd2::CAENCfd2Driver::WRITE_PARAMETERS_COMMAND, true);
}
void CAENCfdController::initBoard() {
m_dgtzDriver.execute(caen_cfd::CAENCfdDriver::SET_MODE_COMMAND, true);
m_dgtzDriver.execute(caen_cfd2::CAENCfd2Driver::SET_MODE_COMMAND, true);
}
void CAENCfdController::initChannel(int32 aChannel) {
......@@ -495,7 +496,7 @@ void CAENCfdController::initChannel(int32 aChannel) {
void CAENCfdController::clearData() {
commandProgression = 0;
m_dgtzDriver.execute(caen_cfd::CAENCfdDriver::CLEAR_COMMAND, true);
m_dgtzDriver.execute(caen_cfd2::CAENCfd2Driver::CLEAR_COMMAND, true);
commandProgression = 100;
}
......
......@@ -19,7 +19,7 @@
#ifndef CAENCFDCONTROLLER_H
#define CAENCFDCONTROLLER_H
#include "drivers/caen/caen_cfd/CAENCfdDriver.h"
#include "drivers/caen/caen_cfd2/CAENCfd2Driver.h"
#include "CAENAdcController.h"
//#include "drivers/ioxos/cfd/CfdDriver.h"
......@@ -89,7 +89,7 @@ public:
protected:
DriverPtr<caen_cfd::CAENCfdDriver> m_dgtzDriver;
DriverPtr<caen_cfd2::CAENCfd2Driver> m_dgtzDriver;
private:
......
......@@ -133,7 +133,7 @@ void RealCAENCfdDriver::init() {
if (ret)
cerr << "Error CAEN_DGTZ_SetDPP_VirtualProbe: " << ret << endl;
// Calibrate ADC channels at startup
// Calibrate ADC channels at startup and lock temperature correction
if (m_boardInit == 0) {
uint32_t d32 = 0;
cout << "INFO: Calibrating ADCs... " << endl;
......@@ -141,7 +141,7 @@ void RealCAENCfdDriver::init() {
if (ret)
cerr << "Error CAEN_DGTZ_Calibrate: " << ret << endl;
for (int32 i=0; i<owner()->channels(); ++i) {
LockTempCalibration_x730(i);
LockTempCalibration(i);
for (int32 i=0; i<owner()->channels(); ++i) {
CAEN_DGTZ_ReadRegister(m_boardHandle, 0x1088 + (i<<8), &d32);
if (!(d32 & 0x8))
......@@ -563,7 +563,7 @@ void RealCAENCfdDriver::registerSetBits(uint16_t addr, int32 startBit, int32 end
cerr << "Error registerSetBit" << endl;
}
int32 RealCAENCfdDriver::LockTempCalibration_x730(uint32_t ch) {
int32 RealCAENCfdDriver::LockTempCalibration(uint32_t ch) {
uint32_t lock, ctrl;
......
......@@ -108,7 +108,7 @@ private:
void open();
void close();
int32 LockTempCalibration_x730(uint32_t ch);
int32 LockTempCalibration(uint32_t ch);
int32 ReadSPIRegister(uint32_t ch, uint32_t address, uint32_t *value);
int32 WriteSPIRegister(uint32_t ch, uint32_t address, uint32_t value);
......
/*!
* \brief
* 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 CAENCFD2DEF_H
#define CAENCFD2DEF_H
#include <CAENDigitizer.h>
#include "common/base/BaseTypes.h"
namespace caen_cfd2 {
// Board parameters
typedef struct {
CAEN_DGTZ_ConnectionType LinkType; // Type of connection
int32 VMEBaseAddress; // VME address
CAEN_DGTZ_AcqMode_t AcqMode; // Start acquisition mode (SW, S_IN, First trigger)
CAEN_DGTZ_DPP_AcqMode_t DPPAcqMode; // Acquisition mode (Oscilloscope, List, Mixed)
CAEN_DGTZ_DPP_SaveParam_t SaveMode; // Save mode (Energy, Time, Energy&Time, None)
int32 RecordLength; // Nb of samples in oscilloscope mode
int32 cfdTrap; // Enable CFD plot or trapezoid
CAEN_DGTZ_IOLevel_t IOLevel; // I/O level (NIM, TTL)
CAEN_DGTZ_TriggerMode_t TriggerMode; // Trigger mode (disable, extout, acq_only, acq_extout)
int32 ChannelMask; // Channel enable mask
int32 EventAggr; // Nb of events per aggregate (0=automatic)
} DigitizerParams_t;
#define CFD_FAKEEVTS_ROLLOVER_REG 0X1080
#define DPP_ALG_CTRL2_REG 0X10A0
#define CFD_BASELINE_REG 0X10D0
#define CFD_DELAY_REG 0X1058
#define DYNAMIC_RANGE_REG 0X1028
}
#endif // CAENCFD2DEF_H
/*
* 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 "CAENCfd2Driver.h"
#include "drivers/global/DriversCommands.h"
#include "CAENCfd2Def.h"
#include "CAENCfd2State.h"
#include "PerfectCAENCfd2Driver.h"
#include "RealCAENCfd2Driver.h"
namespace caen_cfd2 {
const std::string CAENCfd2Driver::TYPE = "caen_cfd2";
const std::string CAENCfd2Driver::WRITE_PARAMETERS_COMMAND = "writeParam";
const std::string CAENCfd2Driver::SET_MODE_COMMAND = "setAcqMode";
const std::string CAENCfd2Driver::RESET_COMMAND = "reset";
const std::string CAENCfd2Driver::CLEAR_COMMAND = "clear";
/*
* Constructor
*/
CAENCfd2Driver::CAENCfd2Driver(const std::string& name) {
driver::Vme::init(name);
registerStates(new RealCAENCfd2Driver(this), new PerfectCAENCfd2Driver(this), new PerfectCAENCfd2Driver(this));
// Global properties
nbChannels.init(this, SAVE, "nb_channels");
nbBits.init(this, SAVE, "nb_bits");
model.init(this, NOSAVE, "model");
channels.init(this, NOSAVE, "channels");
serialNumber.init(this, NOSAVE, "serial_number");
modelName.init(this, NOSAVE, "model_name");
rocFirmware.init(this, NOSAVE, "roc_firmware");
amcFirmware.init(this, NOSAVE, "amc_firmware");
// Board properties
linkType.init(this, SAVE, "link_type");
acqMode.init(this, SAVE, "acq_mode");
dppAcqMode.init(this, SAVE, "dpp_acq_mode");
dppAcqModeStr.init(this, NOSAVE, "dpp_acq_mode_str");
saveMode.init(this, SAVE, "save_mode");
saveModeStr.init(this, NOSAVE, "save_mode_str");
recordLength.init(this, SAVE, "record_length");
cfdTrap.init(this, SAVE, "cfd_Trap");
ioLevel.init(this, SAVE, "io_level");
triggerMode.init(this, SAVE, "trigger_mode");
channelMask.init(this, SAVE, "channel_mask");
enableCoincidence.init(this, NOSAVE, "enable_coincidence");
coincidenceWindow.init(this, NOSAVE, "coincidence_window");
coincidenceMask.init(this, NOSAVE, "coincidence_mask");
usePn1Coincidence.init(this, SAVE, "use_Pn1_Coincidence");
// Channels properties
signalDecayTime.init(this, SAVE, "decay_time");
trapezoidFlatTop.init(this, SAVE, "trapezoid_flat");
trapezoidRiseTime.init(this, SAVE, "trapezoid_rise");
flatTopDelay.init(this, SAVE, "flat_top");
triggerSmoothing.init(this, SAVE, "trigger_smoothing");
signalRiseTime.init(this, SAVE, "rise_time");
triggerThreshold.init(this, SAVE, "trigger_threshold");
baselineMean.init(this, SAVE, "base_mean");
peakMean.init(this, SAVE, "peak_mean");
peakHoldOff.init(this, SAVE, "peak_holdoff");
baselineHoldOff.init(this, SAVE, "base_holdoff");
triggerHoldOff.init(this, SAVE, "trigger_holdoff");
triggerWindowSize.init(this, SAVE, "trigger_window_size");
triggerWindowEnable.init(this, SAVE, "trigger_window_enable");
digitalGain.init(this, SAVE, "digital_gain");
trapezoidGain.init(this, SAVE, "trapezoid_gain");
decimation.init(this, SAVE, "decimation");
channelActive.init(this, SAVE, "channel_active");
channelActiveStr.init(this, NOSAVE, "channel_active_str");
dynamicRange.init(this, SAVE, "dynamic_range");
dynamicRangeStr.init(this, NOSAVE, "dynamic_range_str");
dcOffset.init(this, SAVE, "dc_offset");
preTrigger.init(this, SAVE, "pre_trigger");
pulsePolarity.init(this, SAVE, "pulse_polarity");
pulsePolarityStr.init(this, NOSAVE, "pulse_polarity_str");
useFirstDerivative.init(this, SAVE, "use_first_derivative");
cfdActive.init(this, SAVE, "cfd_active");
cfdActiveStr.init(this, NOSAVE, "cfd_active_str");
cfdFraction.init(this, SAVE, "cfd_fraction");
cfdFractionStr.init(this, NOSAVE, "cfd_fraction_str");
cfdDelay.init(this, SAVE, "cfd_delay");
cfdSignalZero.init(this, SAVE, "signal_zero");
adcTemperature.init(this, NOSAVE, "adc_temperature");
// Init the device command list
initCommand(driver::INIT_COMMAND);
initCommand(driver::READ_INFOS_COMMAND);
initCommand(driver::STATUS_COMMAND);
initCommand(WRITE_PARAMETERS_COMMAND);
initCommand(SET_MODE_COMMAND);
initCommand(RESET_COMMAND);
initCommand(CLEAR_COMMAND);
// Init functions
registerFunction(NONE_FUNCTION);
addressType.update(driver::Vme::A32_ACCESS);
deviceType = LEAF_DEVICE_TYPE_DEVICE_CONTAINER;
registerRefresher(nbChannels, &CAENCfd2Driver::refreshNbChannelsProperty, this);
registerRefresher(dppAcqMode, &CAENCfd2Driver::refreshDppAcqModeProperty, this);
registerRefresher(saveMode, &CAENCfd2Driver::refreshSaveModeProperty, this);
registerRefresher(channelActive, &CAENCfd2Driver::refreshChannelActiveProperty, this);
registerRefresher(pulsePolarity, &CAENCfd2Driver::refreshPulsePolarityProperty, this);
registerRefresher(dynamicRange, &CAENCfd2Driver::refreshDynamicRangeProperty, this);
/*
* Register the Spy and Observer commands necessary to do the updates.
*/
registerSpyCommand(driver::STATUS_COMMAND, 20); // read temperature every 20 s
registerObserverCommand(driver::STATUS_COMMAND, 20);
}
/*
* Destructor
*/
CAENCfd2Driver::~CAENCfd2Driver() {
}
/*
* execute
*/
void CAENCfd2Driver::execute(const std::string& aCommand) {
if ((aCommand != driver::STOP_COMMAND) && (aCommand != driver::STATUS_COMMAND)
&& (aCommand != driver::READ_COMMAND)) {
commandProgression = PROGRESSION_UNKNOWNSTATE_DEVICE_CONTAINER;
}
CAENCfd2State* currentState = dynamic_cast<CAENCfd2State*>(getCurrentState());
// Check command
if (aCommand == driver::INIT_COMMAND) {
// Init command
currentState->init();
} else if (aCommand == WRITE_PARAMETERS_COMMAND) {
// writeParam command
currentState->writeParam();
commandProgression = PROGRESSION_END_DEVICE_CONTAINER;
} else if (aCommand == SET_MODE_COMMAND) {
// clear command
currentState->setAcqMode();
commandProgression = PROGRESSION_END_DEVICE_CONTAINER;
} else if (aCommand == CLEAR_COMMAND) {
// clear command
currentState->clear();
commandProgression = PROGRESSION_END_DEVICE_CONTAINER;
} else if (aCommand == RESET_COMMAND) {
// clear command
currentState->reset();
commandProgression = PROGRESSION_END_DEVICE_CONTAINER;
} else if (aCommand == driver::READ_INFOS_COMMAND) {
// Info command
currentState->readInfos();
commandProgression = PROGRESSION_END_DEVICE_CONTAINER;
} else if (aCommand == driver::STATUS_COMMAND) {
// Info command
currentState->readStatus();
commandProgression = PROGRESSION_END_DEVICE_CONTAINER;
} else {
//Error bad command
//Todo , normaly it will be detect it device action driver
}
}
void CAENCfd2Driver::refreshNbChannelsProperty(int32 aValue) throw (CannotSetValue){
signalDecayTime.resize(aValue);
trapezoidFlatTop.resize(aValue);
trapezoidRiseTime.resize(aValue);
flatTopDelay.resize(aValue);
triggerSmoothing.resize(aValue);
signalRiseTime.resize(aValue);
triggerThreshold.resize(aValue);
baselineMean.resize(aValue);
peakMean.resize(aValue);
peakHoldOff.resize(aValue);
baselineHoldOff.resize(aValue);
triggerHoldOff.resize(aValue);
triggerWindowSize.resize(aValue);
triggerWindowEnable.resize(aValue);
digitalGain.resize(aValue);
trapezoidGain.resize(aValue);
decimation.resize(aValue);
channelActive.resize(aValue);
channelActiveStr.resize(aValue);
dcOffset.resize(aValue);
preTrigger.resize(aValue);
pulsePolarity.resize(aValue);
pulsePolarityStr.resize(aValue);
useFirstDerivative.resize(aValue);
dynamicRange.resize(aValue);
dynamicRangeStr.resize(aValue);
cfdActive.resize(aValue);
cfdActiveStr.resize(aValue);
cfdFraction.resize(aValue);
cfdFractionStr.resize(aValue);
cfdDelay.resize(aValue);
cfdSignalZero.resize(aValue);
adcTemperature.resize(aValue);
}
void CAENCfd2Driver::refreshDppAcqModeProperty(int32 aValue) throw (CannotSetValue) {
switch (aValue) {
case 0:
dppAcqModeStr = "Oscilloscope";
break;
case 1:
dppAcqModeStr = "Histogram";
break;
}
}
void CAENCfd2Driver::refreshSaveModeProperty(int32 aValue) throw (CannotSetValue) {
switch (aValue) {
case 0:
saveModeStr = "Energy";
break;
case 1:
saveModeStr = "Time";
break;
case 2:
saveModeStr = "Energy&Time";
break;
}
}
void CAENCfd2Driver::refreshChannelActiveProperty(int32 index, int32 aValue) throw (CannotSetValue) {
switch (aValue) {
case 0:
channelActiveStr.set(index, "Inactive");
break;
case 1:
channelActiveStr.set(index, "Active");
break;
}
}
void CAENCfd2Driver::refreshPulsePolarityProperty(int32 index, int32 aValue) throw (CannotSetValue) {
switch (aValue) {
case 0:
pulsePolarityStr.set(index, "Positive");
break;
case 1:
pulsePolarityStr.set(index, "Negative");
break;
}
}
void CAENCfd2Driver::refreshDynamicRangeProperty(int32 index, int32 aValue) throw (CannotSetValue) {
switch (aValue) {
case 0:
dynamicRangeStr.set(index, "2V");
break;
case 1:
dynamicRangeStr.set(index, "0.5V");
break;
}
}
}
/*
* 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 CAENCFD2DRIVER_H
#define CAENCFD2DRIVER_H
#include <Driver.h>
#include "drivers/global/Vme.h"
namespace caen_cfd2 {
/*!
* \class CAENPhaDriver
* \brief Main class for the CAENPhaDriver device driver
*
* \par
* Class for caen_cfdDriver driver. Implements DeviceDriver methods.
* \par
* The CAENPhaDriver device manages the global functionality of the CAEN Pha VME Digitiser.
*/
class CAENCfd2Driver : public driver::Vme {
public:
//! Driver type value
static const std::string TYPE;
/*!
* \brief Constructor
* \param[in] name the name of the device driver
*/
CAENCfd2Driver(const std::string& name);
/*!
* \brief Destructor
*/
virtual ~CAENCfd2Driver();
/*!
* \brief Method called for executing a command
*
* \param[in] command the command to apply on the controller
*/
virtual void execute(const std::string& aCommand);
// Global properties
Property<int32> nbChannels;
Property<int32> nbBits;
Property<int32> model;
Property<int32> channels;
Property<int32> serialNumber;
Property<std::string> modelName;
Property<std::string> rocFirmware;
Property<std::string> amcFirmware;
// Board properties
Property<int32> linkType;
Property<int32> acqMode;
Property<int32> dppAcqMode;
Property<std::string> dppAcqModeStr;
Property<int32> saveMode;
Property<std::string> saveModeStr;
Property<int32> recordLength; // Nb samples for oscilloscope mode
Property<int32> cfdTrap;
Property<int32> ioLevel;
Property<int32> triggerMode;
Property<int32> channelMask;
// Coincidence properties
Property<int32> enableCoincidence;
Property<int32> coincidenceWindow;
Property<int32> coincidenceMask;
Property<int32> usePn1Coincidence;
// Channels properties in dppParams
DynamicProperty<int32> signalDecayTime; // M - range 0:65535
DynamicProperty<int32> trapezoidFlatTop; // m - range 0:1023
DynamicProperty<int32> trapezoidRiseTime; // k - range 0:1023
DynamicProperty<int32> flatTopDelay; // ftd (peaking)
DynamicProperty<int32> triggerSmoothing; // a - range 0:63
DynamicProperty<int32> signalRiseTime; // b - range 0:255
DynamicProperty<int32> triggerThreshold; // thr - range 0:16383
DynamicProperty<int32> baselineMean; // nsbl - range 0:6 (no baseline, 16, 64, 256, 1024, 4096, 16384)
DynamicProperty<int32> peakMean; // nspk - range 0:3 (1, 4, 16, 64 samples)
DynamicProperty<int32> peakHoldOff; // pkho - range 0:255
DynamicProperty<int32> baselineHoldOff; // blho - range 0:255
DynamicProperty<int32> triggerHoldOff; // trgho - range 0:63
DynamicProperty<int32> triggerWindowSize; // twwdt
DynamicProperty<int32> triggerWindowEnable; // trgwin - range 0:1
DynamicProperty<int32> digitalGain; // dgain - range 0:3 (1, 2, 4, 8)
DynamicProperty<float64> trapezoidGain; // enf
DynamicProperty<int32> decimation; // decimation - range 0:3 (disabled, 2, 4 8)
// Channels properties outside dppParam
DynamicProperty<int32> channelActive;
DynamicProperty<std::string> channelActiveStr;
DynamicProperty<int32> dynamicRange; // dynamic range 0=2V 1=0.5V - range 0:1
DynamicProperty<std::string> dynamicRangeStr;
DynamicProperty<int32> dcOffset; // range 0 - 100 of full scale
DynamicProperty<int32> preTrigger; // range 0:1023 (nSamples = pre_trig x 2)
DynamicProperty<int32> pulsePolarity; // invert input - range 0:1
DynamicProperty<std::string> pulsePolarityStr;
DynamicProperty<int32> useFirstDerivative; // use first derivative - range 0:1
// Channels properties for CFD mode
DynamicProperty<int32> cfdActive;
DynamicProperty<std::string> cfdActiveStr;
DynamicProperty<int32> cfdFraction; // 00= 25% - 01=50% - 11 = 100%
DynamicProperty<std::string> cfdFractionStr; // 00= 25% - 01=50% - 11 = 100%
DynamicProperty<int32> cfdDelay; // In step of 2ns
DynamicProperty<int32> cfdSignalZero; // In ADC channels
// Channels adc temperature
DynamicProperty<int32> adcTemperature;
// Commands
static const std::string WRITE_PARAMETERS_COMMAND;
static const std::string SET_MODE_COMMAND;
static const std::string RESET_COMMAND;
static const std::string CLEAR_COMMAND;
private:
void refreshNbChannelsProperty(int32 aValue) throw (CannotSetValue);
void refreshDppAcqModeProperty(int32 aValue) throw (CannotSetValue);
void refreshSaveModeProperty(int32 aValue) throw (CannotSetValue);
void refreshChannelActiveProperty(int32 index, int32 aValue) throw (CannotSetValue);
void refreshPulsePolarityProperty(int32 index, int32 aValue) throw (CannotSetValue);
void refreshDynamicRangeProperty(int32 index, int32 aValue) throw (CannotSetValue);
};
}
#endif //CAENCFD2DRIVER_H
/*
* 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
*