Commit bdfe8f28 authored by Jacob Lamblin's avatar Jacob Lamblin
Browse files

Add CalibParamController. Add Spy for StereoelecController. Correct small bugs.

parent ccc7b268
/*
* 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 <cmath>
#include <bitset>
#include "drivers/stereo_elec/StereoElecDef.h"
#include "CalibParamController.h"
#include "controllers/common/family/Families.h"
using namespace std;
namespace stereo_daq {
const string CalibParamController::TYPE = "calibparam_controller";
/*
* Constructor
*/
CalibParamController::CalibParamController(const string& name) : ExperimentController(name),controller::Stoppable(this),Select(this),Set(this) {
setFamily(family::ACQUISITION,family::SETTING);
sourcetype.init(this, NOSAVE, "sourcetype");
x.init(this, NOSAVE, "x");
y.init(this, NOSAVE, "y");
z.init(this, NOSAVE, "z");
m_ELECDriver.init(this, "driver");
registerFunction(TYPE);
}
CalibParamController::CalibParamController(const CalibParamController& controller) : ExperimentController(controller),controller::Stoppable(this), Select(this),Set(this) {
m_ELECDriver.copy(controller.m_ELECDriver);
sourcetype.copy(this, controller.sourcetype);
x.copy(this, controller.x);
y.copy(this, controller.y);
z.copy(this, controller.z);
}
/*
* Destructor
*/
CalibParamController::~CalibParamController() {
// Empty
}
void CalibParamController::postConfiguration() {
registerRefresher(sourcetype, &CalibParamController::refreshSourceTypeProperty, this);
registerRefresher(x, &CalibParamController::refreshXProperty, this);
registerRefresher(y, &CalibParamController::refreshYProperty, this);
registerRefresher(z, &CalibParamController::refreshZProperty, this);
sourcetype="none";
x=0;
y=0;
z=0;
}
void CalibParamController::refreshSourceTypeProperty(const std::string& value) throw (CannotSetValue) {
m_ELECDriver->DAQParams.sourceType = (string) value;
}
void CalibParamController::refreshXProperty(float64 value) throw (CannotSetValue) {
m_ELECDriver->DAQParams.sourcePosX = (float) value;
}
void CalibParamController::refreshYProperty(float64 value) throw (CannotSetValue) {
m_ELECDriver->DAQParams.sourcePosY = (float) value;
}
void CalibParamController::refreshZProperty(float64 value) throw (CannotSetValue) {
m_ELECDriver->DAQParams.sourcePosZ = (float) value;
}
void CalibParamController::select() {
}
void CalibParamController::set() {
}
void CalibParamController::start() {
}
void CalibParamController::stop() {
}
}
/*
* 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 CALIBPARAMCONTROLLER_H
#define CALIBPARAMCONTROLLER_H
#include <Controller.h>
#include "drivers/stereo_elec/StereoElecDriver.h"
#include "DAQParamController.h"
namespace stereo_daq {
/*!
* \class CalibParamController
*/
class CalibParamController: public ExperimentController,
public controller::Stoppable,
public Select,
public Set {
public:
//! Type of controller
static const std::string TYPE;
/*!
* \brief Constructor
*
* It is the default constructor called by the creator class ExperimentControllerCreator.
*
* \param[in] name the name of the controller
*/
CalibParamController(const std::string& name);
/*!
* \brief Copy constructor
*
* \param[in] controller the controller to copy
*/
CalibParamController(const CalibParamController& controller);
/*!
* \brief Destructor
*/
virtual ~CalibParamController();
/*!
* \brief Method called before changing the property value
*
* This method is called after setting configuration during the creation of controller.
*/
virtual void postConfiguration();
/*!
* Properties
*/
Property<string> sourcetype;
Property<float64> x;
Property<float64> y;
Property<float64> z;
protected:
DriverPtr<stereo_elec::StereoElecDriver> m_ELECDriver; //! The driver linked to the controller
/*!
* \brief select command
*/
virtual void select();
/*!
* \brief select command
*/
virtual void set();
/*!
* \brief start
*
*/
virtual void start();
/*!
* \brief Stop command
*/
virtual void stop();
private:
void refreshSourceTypeProperty(const std::string& value) throw (CannotSetValue);
void refreshXProperty(float64 value) throw (CannotSetValue);
void refreshYProperty(float64 value) throw (CannotSetValue);
void refreshZProperty(float64 value) throw (CannotSetValue);
};
}
#endif // CALIBPARAMCONTROLLER_H
......@@ -83,6 +83,26 @@ acquisition::TimeAcquisitionController(name), Select(this),Set(this) {
trigthresall.init(this, NOSAVE, "trigthresall");
ntotall.init(this, NOSAVE, "ntotall");
ntailall.init(this, NOSAVE, "ntailall");
t2tgon.init(this, NOSAVE, "t2tgon");
t2gcon.init(this, NOSAVE, "t2gcon");
t2vton.init(this, NOSAVE, "t2vton");
t2tgor.init(this, NOSAVE, "t2tgor");
t2gcor.init(this, NOSAVE, "t2gcor");
t2vtor.init(this, NOSAVE, "t2vtor");
t2tgmode.init(this, NOSAVE, "t2tgmode");
t2gcmode.init(this, NOSAVE, "t2gcmode");
t2vtmode.init(this, NOSAVE, "t2vtmode");
t2tgmin.init(this, NOSAVE, "t2tgmin");
t2gcmin.init(this, NOSAVE, "t2gcmin");
t2vtmin.init(this, NOSAVE, "t2vtmin");
t2tgmax.init(this, NOSAVE, "t2tgmax");
t2gcmax.init(this, NOSAVE, "t2gcmax");
t2vtmax.init(this, NOSAVE, "t2vtmax");
t2timeresetthres.init(this, NOSAVE, "t2timeresetthres");
m_HVDriver.init(this, "hvdriver");
experimentData.init(this, "experimentinfo");
......@@ -119,6 +139,26 @@ acquisition::TimeAcquisitionController(name), Select(this),Set(this) {
registerRefresher(t1timereset, &DAQParamController::refreshT1TimeResetProperty, this);
registerRefresher(namechannel, &DAQParamController::refreshNameChannelProperty, this);
registerRefresher(trigthresall, &DAQParamController::refreshTrigThresAllProperty, this);
registerRefresher(ntotall, &DAQParamController::refreshNTotAllProperty, this);
registerRefresher(ntailall, &DAQParamController::refreshNTailAllProperty, this);
registerRefresher(t2tgon, &DAQParamController::refreshT2TGOnProperty, this);
registerRefresher(t2gcon, &DAQParamController::refreshT2GCOnProperty, this);
registerRefresher(t2vton, &DAQParamController::refreshT2VTOnProperty, this);
registerRefresher(t2tgor, &DAQParamController::refreshT2TGOrProperty, this);
registerRefresher(t2gcor, &DAQParamController::refreshT2GCOrProperty, this);
registerRefresher(t2vtor, &DAQParamController::refreshT2VTOrProperty, this);
registerRefresher(t2tgmode, &DAQParamController::refreshT2TGModeProperty, this);
registerRefresher(t2gcmode, &DAQParamController::refreshT2GCModeProperty, this);
registerRefresher(t2vtmode, &DAQParamController::refreshT2VTModeProperty, this);
registerRefresher(t2tgmin, &DAQParamController::refreshT2TGMinProperty, this);
registerRefresher(t2gcmin, &DAQParamController::refreshT2GCMinProperty, this);
registerRefresher(t2vtmin, &DAQParamController::refreshT2VTMinProperty, this);
registerRefresher(t2tgmax, &DAQParamController::refreshT2TGMaxProperty, this);
registerRefresher(t2gcmax, &DAQParamController::refreshT2GCMaxProperty, this);
registerRefresher(t2vtmax, &DAQParamController::refreshT2VTMaxProperty, this);
registerRefresher(t2timeresetthres, &DAQParamController::refreshT2TimeResetThresProperty, this);
// registerRefresher(enabledfe, &DAQParamController::refreshEnabledFEProperty, this);
......@@ -170,6 +210,25 @@ DAQParamController::DAQParamController(const DAQParamController& controller) :
setvalue.copy(this, controller.setvalue);
trigthresall.copy(this, controller.trigthresall);
ntotall.copy(this, controller.ntotall);
ntailall.copy(this, controller.ntailall);
t2tgon.copy(this, controller.t2tgon);
t2gcon.copy(this, controller.t2gcon);
t2vton.copy(this, controller.t2vton);
t2tgor.copy(this, controller.t2tgor);
t2gcor.copy(this, controller.t2gcor);
t2vtor.copy(this, controller.t2vtor);
t2tgmode.copy(this, controller.t2tgmode);
t2gcmode.copy(this, controller.t2gcmode);
t2vtmode.copy(this, controller.t2vtmode);
t2tgmin.copy(this, controller.t2tgmin);
t2gcmin.copy(this, controller.t2gcmin);
t2vtmin.copy(this, controller.t2vtmin);
t2tgmax.copy(this, controller.t2tgmax);
t2gcmax.copy(this, controller.t2gcmax);
t2vtmax.copy(this, controller.t2vtmax);
t2timeresetthres.copy(this, controller.t2timeresetthres);
m_HVDriver.copy(controller.m_HVDriver);
experimentData.copy(controller.experimentData);
......@@ -178,7 +237,8 @@ DAQParamController::DAQParamController(const DAQParamController& controller) :
registerRefresher(nfeboard,&DAQParamController::refreshNFEBoardCloneProperty,this);
registerRefresher(nfeboardmax,&DAQParamController::refreshNFEBoardMaxProperty,this);
registerRefresher(ntotall, &DAQParamController::refreshNTotAllProperty, this);
registerRefresher(ntailall, &DAQParamController::refreshNTailAllProperty, this);
}
/*
......@@ -225,10 +285,23 @@ void DAQParamController::postConfiguration() {
ledused=0;
m_ELECDriver->DAQParams.ledUsed=false;
trigthresall=0;
ntotall=0;
ntailall=0;
setparam="";
setvalue="0";
m_ELECDriver->DAQParams.sourceType="none";
m_ELECDriver->DAQParams.sourcePosX=0.;
m_ELECDriver->DAQParams.sourcePosY=0.;
m_ELECDriver->DAQParams.sourcePosZ=0.;
t2tgon=false;
t2gcon=false;
t2vton=false;
t2timeresetthres=0;
experimentData->title="";
experimentData->subtitle="";
}
void DAQParamController::refreshNFEBoardMaxProperty(int32 value) throw (CannotSetValue) {\
// Resize properties and vector
ntot.resize(value);
......@@ -262,7 +335,7 @@ void DAQParamController::refreshNFEBoardMaxProperty(int32 value) throw (CannotSe
void DAQParamController::refreshNFEBoardProperty(int32 value) throw (CannotSetValue) {
cout << std::showbase<<dec;
cout << dec << "nfeboard ancienne puis nouvelle " << nfeboard() <<" " << value << endl;
cout << dec << "nfeboard ancienne " << nfeboard() <<" nouvelle " << value << endl;
if(nfeboard()==value){
cout << "nfeboard inchanged, skip the refresher" << endl ;
return;
......@@ -480,7 +553,7 @@ void DAQParamController::refreshNFEBoardCloneProperty(int32 value) throw (Cannot
void DAQParamController::refreshDAQModeProperty(int32 value) throw (CannotSetValue) {
m_ELECDriver->DAQParams.DAQMode = (short unsigned) value;
cout << "DAQMode " << m_ELECDriver->DAQParams.DAQMode << endl;
//cout << "DAQMode " << m_ELECDriver->DAQParams.DAQMode << endl;
}
void DAQParamController::refreshTrigModeProperty(int32 value) throw (CannotSetValue) {
m_ELECDriver->DAQParams.trigMode = (short unsigned) value;
......@@ -505,12 +578,17 @@ void DAQParamController::refreshLedUsedProperty(int value) throw (CannotSetValue
m_ELECDriver->DAQParams.ledUsed = value;
}
void DAQParamController::refreshNTotProperty(int32 index, int32 value) throw (CannotSetValue) {
cout << "NTOT refresher index " << index << " nfeboard() " << nfeboard() << " value " << value << endl;
if(index<nfeboard()) m_ELECDriver->DAQParams.FEParams_v.at(index).nTot = (short unsigned) value;
if(index<nfeboard()&&ntotall()==0){
m_ELECDriver->DAQParams.FEParams_v.at(index).nTot = (short unsigned) value;
//cout << "NTot(" << index << ") = " << value << endl;
}
}
void DAQParamController::refreshNTailProperty(int32 index, int32 value) throw (CannotSetValue) {
if(index<nfeboard()) m_ELECDriver->DAQParams.FEParams_v.at(index).nTail = (short unsigned) value;
if(index<nfeboard()&&ntailall()==0){
m_ELECDriver->DAQParams.FEParams_v.at(index).nTail = (short unsigned) value;
//cout << "NTail(" << index << ") = " << value << endl;
}
}
void DAQParamController::refreshPretrigProperty(int32 index, int32 value) throw (CannotSetValue) {
......@@ -528,7 +606,7 @@ void DAQParamController::refreshTrigChannelProperty(int32 index, bool value) thr
if(index<nfeboard()){
if (value) m_ELECDriver->DAQParams.FEParams_v.at(index).trigMask |= 0x00FF; // mise à 1 des 8 premiers bits
else m_ELECDriver->DAQParams.FEParams_v.at(index).trigMask &= 0xFF00; // mise à 0 des 8 premiers bits
cout << "trigMask " << (bitset<16> ) m_ELECDriver->DAQParams.FEParams_v.at(index).trigMask << endl;
//cout << "trigMask " << (bitset<16> ) m_ELECDriver->DAQParams.FEParams_v.at(index).trigMask << endl;
}
}
......@@ -536,7 +614,7 @@ void DAQParamController::refreshTrigSum03Property(int32 index, bool value) throw
if(index<nfeboard()){
if (value) m_ELECDriver->DAQParams.FEParams_v.at(index).trigMask |= (short unsigned) (1u << 8); // mise à 1 du bit 8
else m_ELECDriver->DAQParams.FEParams_v.at(index).trigMask &= (short unsigned) ~(1u << 8); // mise à 0 du bit 8
cout << "trigMask " << (bitset<16> ) m_ELECDriver->DAQParams.FEParams_v.at(index).trigMask << endl;
//cout << "trigMask " << (bitset<16> ) m_ELECDriver->DAQParams.FEParams_v.at(index).trigMask << endl;
}
}
......@@ -544,7 +622,7 @@ void DAQParamController::refreshTrigSum47Property(int32 index, bool value) throw
if(index<nfeboard()){
if (value) m_ELECDriver->DAQParams.FEParams_v.at(index).trigMask |= (short unsigned) (1u << 9); // mise à 1 du bit 9
else m_ELECDriver->DAQParams.FEParams_v.at(index).trigMask &= (short unsigned) ~(1u << 9); // mise à 0 du bit 9
cout << "trigMask " << (bitset<16> ) m_ELECDriver->DAQParams.FEParams_v.at(index).trigMask << endl;
//cout << "trigMask " << (bitset<16> ) m_ELECDriver->DAQParams.FEParams_v.at(index).trigMask << endl;
}
}
......@@ -553,7 +631,7 @@ void DAQParamController::refreshTrigSum07Property(int32 index, bool value) throw
if(index<nfeboard()){
if (value) m_ELECDriver->DAQParams.FEParams_v.at(index).trigMask |= (short unsigned) (1u << 10); // mise à 1 du bit 10
else m_ELECDriver->DAQParams.FEParams_v.at(index).trigMask &= (short unsigned) ~(1u << 10); // mise à 0 du bit 10
cout << "trigMask " << (bitset<16> ) m_ELECDriver->DAQParams.FEParams_v.at(index).trigMask << endl;
//cout << "trigMask " << (bitset<16> ) m_ELECDriver->DAQParams.FEParams_v.at(index).trigMask << endl;
}
}
......@@ -580,14 +658,14 @@ void DAQParamController::refreshT1AcceptedProperty(int32 index, bool value) thro
if(index<nfeboard()){
if(value) m_ELECDriver->DAQParams.fe_trigger_mask|= (1 << slotindex(index));
else m_ELECDriver->DAQParams.fe_trigger_mask &= ~(1<< slotindex(index));
cout << "fe_trigger_mask "<< m_ELECDriver->DAQParams.fe_trigger_mask << " value=" << value << endl;
//cout << "fe_trigger_mask "<< m_ELECDriver->DAQParams.fe_trigger_mask << " value=" << value << endl;
}
}
void DAQParamController::refreshT1TimeResetProperty(int32 index, bool value) throw (CannotSetValue) {
if(index<nfeboard()){
if(value) m_ELECDriver->DAQParams.fe_reset_mask|= (1 << slotindex(index));
else m_ELECDriver->DAQParams.fe_reset_mask &= ~(1<< slotindex(index));
cout << "fe_reset_mask "<< m_ELECDriver->DAQParams.fe_reset_mask << " value=" << value << endl;
//cout << "fe_reset_mask "<< m_ELECDriver->DAQParams.fe_reset_mask << " value=" << value << endl;
}
}
//void DAQParamController::refreshEnabledFEProperty(int32 index, bool value) throw (CannotSetValue) {
......@@ -603,7 +681,7 @@ void DAQParamController::refreshGain20Property(int32 index, bool value) throw (C
void DAQParamController::refreshTrigThresProperty(int32 index, int32 value) throw (CannotSetValue) {
if(index<ntotchannel()&&trigthresall()==0){
m_ELECDriver->DAQParams.FEParams_v.at(index / stereo_elec::NBFECHANNEL).threshold_v[ichannel(index)] = (short unsigned) value;
cout << "refreshTrigThresProperty " <<m_ELECDriver->DAQParams.FEParams_v.at(index / stereo_elec::NBFECHANNEL).threshold_v[ichannel(index)] << endl;
//cout << "refreshTrigThresProperty " <<m_ELECDriver->DAQParams.FEParams_v.at(index / stereo_elec::NBFECHANNEL).threshold_v[ichannel(index)] << endl;
}
}
......@@ -632,20 +710,95 @@ void DAQParamController::refreshNameChannelProperty(int32 index, const std::stri
}
void DAQParamController::refreshTrigThresAllProperty(int32 value) throw (CannotSetValue) {
if(value>0){
cout << "DAQParamController " << endl;
for(int i=0;i<nfeboard();i++){
for(int j=0;j< stereo_elec::NBFECHANNEL; j++){
m_ELECDriver->DAQParams.FEParams_v.at(i).threshold_v[j] = (short unsigned) value;
}
m_ELECDriver->DAQParams.FEParams_v.at(i).sumThreshold= (short unsigned) value;
//sumthres.set(i,value);
}
//for(int i=0;i<ntotchannel();i++) trigthres.set(i,value);
log(Level::s_Info) << "Trigger threshold have been set to " << value << " for all channels" << endlog;
}
}
void DAQParamController::refreshNTotAllProperty(int32 value) throw (CannotSetValue) {
if(value>0){
for(int i=0;i<nfeboard();i++){
//m_ELECDriver->DAQParams.FEParams_v.at(i).nTot = (short unsigned) value;
ntot.set(i,value);
}
log(Level::s_Info) << "Ntot have been set to " << value << " for all channels" << endlog;
cout << dec << "Trigger threshold for all channels have been set to " << value << endl;
}
}
void DAQParamController::refreshNTailAllProperty(int32 value) throw (CannotSetValue) {
if(value>0){
for(int i=0;i<nfeboard();i++){
//m_ELECDriver->DAQParams.FEParams_v.at(i).nTail = (short unsigned) value;
ntail.set(i,value);
}
log(Level::s_Info) << "Ntail have been set to " << value << " for all channels" << endlog;
}
}
void DAQParamController::refreshT2TGOnProperty(bool value) throw (CannotSetValue){
if(value==false){
t2tgmode=false;
t2tgmin=0x80000000;
t2tgmax=0x7FFFFFFF;
}
}
void DAQParamController::refreshT2GCOnProperty(bool value) throw (CannotSetValue){
if(value==false){
t2gcmode=false;
t2gcmin=0x80000000;
t2gcmax=0x7FFFFFFF;
}
}
void DAQParamController::refreshT2VTOnProperty(bool value) throw (CannotSetValue){
if(value==false){
t2vtmode=false;
t2vtmin=0x80000000;
t2vtmax=0x7FFFFFFF;
}
}void DAQParamController::refreshT2TGOrProperty(bool value) throw (CannotSetValue){
m_ELECDriver->DAQParams.OR_TG=value;
}
void DAQParamController::refreshT2GCOrProperty(bool value) throw (CannotSetValue){
m_ELECDriver->DAQParams.OR_GC=value;
}
void DAQParamController::refreshT2VTOrProperty(bool value) throw (CannotSetValue){
m_ELECDriver->DAQParams.OR_VT=value;
}
void DAQParamController::refreshT2TGModeProperty(bool value) throw (CannotSetValue){
m_ELECDriver->DAQParams.TGmode=value;
}
void DAQParamController::refreshT2GCModeProperty(bool value) throw (CannotSetValue){
m_ELECDriver->DAQParams.GCmode=value;
}
void DAQParamController::refreshT2VTModeProperty(bool value) throw (CannotSetValue){
m_ELECDriver->DAQParams.VTmode=value;
}
void DAQParamController::refreshT2TGMinProperty(int32 value) throw (CannotSetValue){
m_ELECDriver->DAQParams.QtotThreshold[0] = value;
}
void DAQParamController::refreshT2GCMinProperty(int32 value) throw (CannotSetValue){
m_ELECDriver->DAQParams.QtotThreshold[2] = value;
}
void DAQParamController::refreshT2VTMinProperty(int32 value) throw (CannotSetValue){
m_ELECDriver->DAQParams.QtotThreshold[4] = value;
}
void DAQParamController::refreshT2TGMaxProperty(int32 value) throw (CannotSetValue){
m_ELECDriver->DAQParams.QtotThreshold[1] = value;
}
void DAQParamController::refreshT2GCMaxProperty(int32 value) throw (CannotSetValue){
m_ELECDriver->DAQParams.QtotThreshold[3] = value;
}
void DAQParamController::refreshT2VTMaxProperty(int32 value) throw (CannotSetValue){
m_ELECDriver->DAQParams.QtotThreshold[5] = value;
}
void DAQParamController::refreshT2TimeResetThresProperty(int32 value) throw (CannotSetValue){
m_ELECDriver->DAQParams.QtotThreshold[6] = value;
}
void DAQParamController::updateTriggerIPAddress() {
m_ELECDriver->DAQParams.triggerIPAdd = m_ELECDriver->triggeripaddress();
......@@ -717,14 +870,19 @@ void DAQParamController::updateLogString() {
void DAQParamController::updateTitle() {
//if(experimentData->title()!=""){
cout << "Title " << experimentData->title() << endl;
log(Level::s_Info) << experimentData->title() << endlog;
m_ELECDriver->DAQParams.title=experimentData->title();
//}
}
void DAQParamController::updateSubtitle() {
//if(experimentData->subtitle()!=""){
cout << "subtitle " << experimentData->subtitle() << endl;
log(Level::s_Info) << experimentData->subtitle() << endlog;
m_ELECDriver->DAQParams.subtitle=experimentData->subtitle();
//}
}
......
......@@ -150,6 +150,27 @@ public:
Property<int32> trigthresall;
Property<int32> ntotall;
Property<int32> ntailall;
Property<bool> t2tgon;
Property<bool> t2gcon;
Property<bool> t2vton;
Property<bool> t2tgor;
Property<bool> t2gcor;
Property<bool> t2vtor;
Property<bool> t2tgmode;
Property<bool> t2gcmode;
Property<bool> t2vtmode;