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

Add scalers and monitoring. Change the syntax of registerObserver. Add the...

Add scalers and monitoring. Change the syntax of registerObserver. Add the number of event in detector.
parent 334d4002
......@@ -42,7 +42,7 @@ PerfectStereoElecDriver::~PerfectStereoElecDriver() {
* init
*/
void PerfectStereoElecDriver::init() {
owner()->isconfigured=true;
}
/*
......
......@@ -87,10 +87,15 @@ void RealStereoElecDriver::qtLoop() {
daq->InitAMCProto(owner()->nfeboard());
daq->DoConfig(owner()->DAQParams);
cout << "DoConfig ok" << endl;
cout << "DAQ_Param elecMapping "<< owner()->DAQParams.elecMapping_v.size() << endl;
owner()->isconfigured=true;
} else if (*command == START_COMMAND) {
if(!owner()->started){
cout << "Before start " << owner()->DAQParams.FEParams_v.at(0).threshold_v[0] << endl;
daq->DoStart(owner()->DAQParams);
cout << "DoStart ok" << endl;
daq->preQtAcqLoop();
......@@ -104,6 +109,11 @@ void RealStereoElecDriver::qtLoop() {
try {
daq->QtAcqLoop();
owner()->nbevent=daq->getNbEvent();
int32* data = owner()->data();
if (owner()->dataSize() > 0) {
data[0] = owner()->nbevent;
owner()->data.sendEvent();
}
}
catch (const std::exception& ex)
{
......@@ -116,9 +126,45 @@ void RealStereoElecDriver::qtLoop() {
}
}else if (*command == READINFO_COMMAND) {
unsigned int accepted_cnt,rejected_cnt;
long elapsedtime;
if(owner()->started and !owner()->m_StopActivated){
daq->QtAcqLoopCounter(accepted_cnt,rejected_cnt,false);
cout << dec << "Trig accepted " << accepted_cnt << " rejected " << rejected_cnt << endl;
daq->QtAcqLoopCounter(accepted_cnt,rejected_cnt,false,scalers,elapsedtime);
cout << dec << "T1 accepted " << accepted_cnt << " T1 rejected " << rejected_cnt << " T2 accepted " << owner()->nbevent << endl;
if(scalers_prev.size()!=scalers.size()) scalers_prev=scalers;
if(elapsedtime==0) elapsedtime=1000; // should be useless
int index=0;
for (int j = 0; j < NBFEMAX; j++) {
if (owner()->boardtype(j) == FEBOARD) {
if(index+7>=scalers.size()){
cout << "Error while reading the scalers : the scalers vector is too small. Inte;pting to read index "
<< index+7 << " whereas the scalers vector size is: " << scalers.size() << endl;
break;
}
owner()->rate0.set(j,(float64)(scalers.at(index)-scalers_prev.at(index))/elapsedtime*1000);
owner()->rate1.set(j,(float64)(scalers.at(index+1)-scalers_prev.at(index+1))/elapsedtime*1000);
owner()->rate2.set(j,(float64)(scalers.at(index+2)-scalers_prev.at(index+2))/elapsedtime*1000);
owner()->rate3.set(j,(float64)(scalers.at(index+3)-scalers_prev.at(index+3))/elapsedtime*1000);
owner()->rate4.set(j,(float64)(scalers.at(index+4)-scalers_prev.at(index+4))/elapsedtime*1000);
owner()->rate5.set(j,(float64)(scalers.at(index+5)-scalers_prev.at(index+5))/elapsedtime*1000);
owner()->rate6.set(j,(float64)(scalers.at(index+6)-scalers_prev.at(index+6))/elapsedtime*1000);
owner()->rate7.set(j,(float64)(scalers.at(index+7)-scalers_prev.at(index+7))/elapsedtime*1000);
index+=11;
}
else{
owner()->rate0.set(j,-1);
owner()->rate1.set(j,-1);
owner()->rate2.set(j,-1);
owner()->rate3.set(j,-1);
owner()->rate4.set(j,-1);
owner()->rate5.set(j,-1);
owner()->rate6.set(j,-1);
owner()->rate7.set(j,-1);
}
}
scalers_prev=scalers;
}
}else if (*command == STOP_COMMAND) {
//owner()->startActivated =false;
......@@ -142,7 +188,6 @@ void RealStereoElecDriver::qtLoop() {
void RealStereoElecDriver::init() {
readConfig();
readMonitoring();
int32 index = 0;
owner()->DAQParams.triggerIPAdd = owner()->triggeripaddress();
......@@ -238,7 +283,7 @@ void RealStereoElecDriver::synchroniseRead() {
* readStatus
*/
void RealStereoElecDriver::readStatus() {
//cout << "readStatus() : startActivated = " << owner()->startActivated() << " started " << owner()->started << endl;
//cout << "readStatus() : startActivated = " << owner()->startActivated() << " started " << owner()->started << " Progression "<< owner()->commandProgression << endl;
if (owner()->started == true) {
bool finished = false;
int32 mode = owner()->mode();
......@@ -247,7 +292,7 @@ void RealStereoElecDriver::readStatus() {
owner()->time.update(actual);
if (mode == acquisition::GateCommon::TIME_MODE) {
float64 target = owner()->time.setpoint();
// cout << "Actual time " << actual << " target time " << target << endl;
cout << "Actual time " << actual << " target time " << target << endl;
if (actual >= target) {
finished = true;
actual = target;
......@@ -256,7 +301,7 @@ void RealStereoElecDriver::readStatus() {
} else if (mode == acquisition::GateCommon::COUNTER1_MODE) {
int32 target = owner()->counts.setpoint();
int32 actual = owner()->nbevent;
// cout << "Actual nb event " << actual << " target nb event " << target << endl;
cout << "Actual nb event " << actual << " target nb event " << target << endl;
if (actual >= target) {
finished = true;
}
......@@ -266,23 +311,16 @@ void RealStereoElecDriver::readStatus() {
// cout << "Actual nb event " << actual << " target nb event " << target << endl;
if (actual >= target) {
finished = true;
cout << "Acquisition finished" << endl ;
}
}
if (finished) {
//m_Status = COUNT_END;
//owner()->status.update(m_Status);
//owner()->computeGateStatus(m_Status);
//owner()->computeAcquisitionStatus(0);
owner()->computeDetectorStatus(0);
//owner()->m_StopActivated = true;
//owner()->startActivated = false;
owner()->commandProgression = PROGRESSION_END_DEVICE_CONTAINER;
cout << "Progression 100 because finished " << endl;
stop();
} else {
//owner()->status.update(m_Status);
//owner()->computeGateStatus(m_Status);
//owner()->computeAcquisitionStatus(0);
owner()->computeDetectorStatus(0);
owner()->calculateProgression();
}
......@@ -295,9 +333,11 @@ void RealStereoElecDriver::readStatus() {
owner()->m_SynchroniseReadActivated = false;
owner()->m_SynchroniseReadTerminated = false;
owner()->commandProgression = PROGRESSION_END_DEVICE_CONTAINER;
cout << "Progression 100 After SynchroniseRead " << endl;
}
} else {
owner()->commandProgression = PROGRESSION_END_DEVICE_CONTAINER;
cout << "Progression 100 because started=false" << endl;
}
//m_Status = COUNT_END;
//owner()->status.update(m_Status);
......
......@@ -123,6 +123,9 @@ private:
TmonFE8 monFE8[NBFEMAX];
TmonLED monLED[NBLEDMAX];
vector<unsigned int> scalers;
vector<unsigned int> scalers_prev;
};
}
......
......@@ -38,6 +38,7 @@ StereoElecController::StereoElecController(const string& name) :ExperimentContro
// Init property
nbfemax.init(this, NOSAVE, "nbfemax");
nbledmax.init(this, NOSAVE, "nbledmax");
slotindex.init(this, NOSAVE, "slotindex");
fe_pos5v.init(this, NOSAVE, "fe_pos5v");
fe_neg5v.init(this, NOSAVE, "fe_neg5v");
fe_adc3v3a.init(this, NOSAVE, "fe_adc3v3a");
......@@ -47,6 +48,15 @@ StereoElecController::StereoElecController(const string& name) :ExperimentContro
led_dac3v3.init(this, NOSAVE, "led_dac3v3");
led_amp24v.init(this, NOSAVE, "led_amp24v");
rate0.init(this, NOSAVE, "rate0");
rate1.init(this, NOSAVE, "rate1");
rate2.init(this, NOSAVE, "rate2");
rate3.init(this, NOSAVE, "rate3");
rate4.init(this, NOSAVE, "rate4");
rate5.init(this, NOSAVE, "rate5");
rate6.init(this, NOSAVE, "rate6");
rate7.init(this, NOSAVE, "rate7");
m_Driver.init(this, "driver");
registerFunction(TYPE);
......@@ -61,6 +71,7 @@ StereoElecController::StereoElecController(const StereoElecController& controlle
ExperimentController(controller){
nbfemax.copy(this, controller.nbfemax);
nbledmax.copy(this, controller.nbledmax);
slotindex.copy(this, controller.slotindex);
fe_pos5v.copy(this, controller.fe_pos5v);
fe_neg5v.copy(this, controller.fe_neg5v);
fe_adc3v3a.copy(this, controller.fe_adc3v3a);
......@@ -70,6 +81,15 @@ StereoElecController::StereoElecController(const StereoElecController& controlle
led_dac3v3.copy(this, controller.led_dac3v3);
led_amp24v.copy(this, controller.led_amp24v);
rate0.copy(this, controller.rate0);
rate1.copy(this, controller.rate1);
rate2.copy(this, controller.rate2);
rate3.copy(this, controller.rate3);
rate4.copy(this, controller.rate4);
rate5.copy(this, controller.rate5);
rate6.copy(this, controller.rate6);
rate7.copy(this, controller.rate7);
m_Driver.copy(controller.m_Driver);
}
......@@ -93,15 +113,37 @@ void StereoElecController::postConfiguration() {
registerUpdater(m_Driver->led_dac3v3, &StereoElecController::updateLED_DAC3V3, this);
registerUpdater(m_Driver->led_amp24v, &StereoElecController::updateLED_Amp24V, this);
registerUpdater(m_Driver->rate0, &StereoElecController::updateRate0, this);
registerUpdater(m_Driver->rate1, &StereoElecController::updateRate1, this);
registerUpdater(m_Driver->rate2, &StereoElecController::updateRate2, this);
registerUpdater(m_Driver->rate3, &StereoElecController::updateRate3, this);
registerUpdater(m_Driver->rate4, &StereoElecController::updateRate4, this);
registerUpdater(m_Driver->rate5, &StereoElecController::updateRate5, this);
registerUpdater(m_Driver->rate6, &StereoElecController::updateRate6, this);
registerUpdater(m_Driver->rate7, &StereoElecController::updateRate7, this);
m_Driver->execute("readMonitoring");
}
void StereoElecController::refreshNbFEMaxProperty(int32 value) throw (CannotSetValue){
slotindex.resize(value);
for(int i=0;i<value;i++) slotindex.set(i,i);
fe_pos5v.resize(value);
fe_neg5v.resize(value);
fe_adc3v3a.resize(value);
fe_adc1v8a.resize(value);
fe_tadc03.resize(value);
fe_tadc47.resize(value);
rate0.resize(value);
rate1.resize(value);
rate2.resize(value);
rate3.resize(value);
rate4.resize(value);
rate5.resize(value);
rate6.resize(value);
rate7.resize(value);
}
void StereoElecController::refreshNbLEDMaxProperty(int32 value) throw (CannotSetValue){
......@@ -134,5 +176,31 @@ void StereoElecController::updateLED_DAC3V3(int32 index){
void StereoElecController::updateLED_Amp24V(int32 index){
led_amp24v.set(index,m_Driver->led_amp24v(index));
}
void StereoElecController::updateRate0(int32 index){
rate0.set(index,m_Driver->rate0(index));
}
void StereoElecController::updateRate1(int32 index){
rate1.set(index,m_Driver->rate1(index));
}
void StereoElecController::updateRate2(int32 index){
rate2.set(index,m_Driver->rate2(index));
}
void StereoElecController::updateRate3(int32 index){
rate3.set(index,m_Driver->rate3(index));
}
void StereoElecController::updateRate4(int32 index){
rate4.set(index,m_Driver->rate4(index));
}
void StereoElecController::updateRate5(int32 index){
rate5.set(index,m_Driver->rate5(index));
}
void StereoElecController::updateRate6(int32 index){
rate6.set(index,m_Driver->rate6(index));
}
void StereoElecController::updateRate7(int32 index){
rate7.set(index,m_Driver->rate7(index));
}
}
......@@ -75,6 +75,7 @@ protected:
Property<int32> nbfemax;
Property<int32> nbledmax;
// FE, size NBFEMAX
DynamicProperty<int32> slotindex;
DynamicProperty<float64> fe_pos5v; /**< Front-end positive power supply. */
DynamicProperty<float64> fe_neg5v; /**< Front-end negative power supply. */
DynamicProperty<float64> fe_adc3v3a; /**< ADC power supply. */
......@@ -85,6 +86,15 @@ protected:
DynamicProperty<float64> led_dac3v3; /**< DAC setting power supply */
DynamicProperty<float64> led_amp24v; /**< Amplifier supply. */
// Properties for rates
DynamicProperty<float64> rate0;
DynamicProperty<float64> rate1;
DynamicProperty<float64> rate2;
DynamicProperty<float64> rate3;
DynamicProperty<float64> rate4;
DynamicProperty<float64> rate5;
DynamicProperty<float64> rate6;
DynamicProperty<float64> rate7;
DriverPtr<StereoElecDriver> m_Driver; //! The driver linked to the controller
......@@ -103,8 +113,15 @@ private:
virtual void updateLED_DAC3V3(int32 index);
virtual void updateLED_Amp24V(int32 index);
/*!
virtual void updateRate0(int32 index);
virtual void updateRate1(int32 index);
virtual void updateRate2(int32 index);
virtual void updateRate3(int32 index);
virtual void updateRate4(int32 index);
virtual void updateRate5(int32 index);
virtual void updateRate6(int32 index);
virtual void updateRate7(int32 index);
/*!
* \brief update the progression property from driver one
*/
void updateProgression();
......
......@@ -68,6 +68,15 @@ StereoElecDriver::StereoElecDriver(const string& name) :
led_dac3v3.init(this, NOSAVE, "led_dac3v3");
led_amp24v.init(this, NOSAVE, "led_amp24v");
rate0.init(this, NOSAVE, "rate0");
rate1.init(this, NOSAVE, "rate1");
rate2.init(this, NOSAVE, "rate2");
rate3.init(this, NOSAVE, "rate3");
rate4.init(this, NOSAVE, "rate4");
rate5.init(this, NOSAVE, "rate5");
rate6.init(this, NOSAVE, "rate6");
rate7.init(this, NOSAVE, "rate7");
/*
* Init the device command list
*/
......@@ -88,10 +97,10 @@ StereoElecDriver::StereoElecDriver(const string& name) :
registerRefresher(boardtype, &StereoElecDriver::refreshBoardTypeProperty, this);
registerRefresher(nfeboard, &StereoElecDriver::refreshNFEBoardProperty, this);
registerRefresher(nledboard, &StereoElecDriver::refreshNLEDBoardProperty, this);
registerObserverCommand(driver::READ_COMMAND,2); //multiple de 2 ms
registerObserverCommand(driver::READ_INFOS_COMMAND,500); //multiple de 2 ms
registerObserverCommand(driver::STATUS_COMMAND,100); //multiple de 2 ms
registerSpyCommand(READ_MONITORING_COMMAND, 12);//5 sec
registerObserverCommandMs(driver::READ_COMMAND,4); //in millisecond
registerObserverCommand(driver::READ_INFOS_COMMAND,50); //multiple de 20 ms (quel que soit la valeur de observerCycleDuration-us)
registerObserverCommand(driver::STATUS_COMMAND,10); //multiple de 20 ms (quel que soit la valeur de observerCycleDuration-us)
registerSpyCommand(READ_MONITORING_COMMAND, 12);//multiple de 5 sec
deviceType = ROOT_DEVICE_TYPE_DEVICE_CONTAINER;
......@@ -110,6 +119,7 @@ StereoElecDriver::StereoElecDriver(const string& name) :
namechannel6.resize(nslot());
namechannel7.resize(nslot());
slotnumber.resize(nslot());
feindex.resize(nslot());
ledindex.resize(nslot());
......@@ -122,6 +132,15 @@ StereoElecDriver::StereoElecDriver(const string& name) :
led_dac3v3.resize(NBLEDMAX);
led_amp24v.resize(NBLEDMAX);
rate0.resize(NBFEMAX);
rate1.resize(NBFEMAX);
rate2.resize(NBFEMAX);
rate3.resize(NBFEMAX);
rate4.resize(NBFEMAX);
rate5.resize(NBFEMAX);
rate6.resize(NBFEMAX);
rate7.resize(NBFEMAX);
nfeboard.update(0);
nledboard.update(0);
......@@ -297,10 +316,10 @@ void StereoElecDriver::calculateProgression() {
actual = time();
} else if (mode() == GateCommon::COUNTER1_MODE) {
setpoint = (float64) counts.setpoint();
actual = (float64) counts();
actual = (float64) nbevent;
} else if (mode() == GateCommon::COUNTER2_MODE) {
setpoint = (float64) counts2.setpoint();
actual = (float64) counts2();
actual = (float64) nbevent;
} else if (mode() == GateCommon::COUNTER3_MODE) {
setpoint = (float64) counts3.setpoint();
actual = (float64) counts3();
......
......@@ -103,6 +103,16 @@ public:
DynamicProperty<float64> led_dac3v3; /**< DAC setting power supply */
DynamicProperty<float64> led_amp24v; /**< Amplifier supply. */
// Properties for rates
DynamicProperty<float64> rate0;
DynamicProperty<float64> rate1;
DynamicProperty<float64> rate2;
DynamicProperty<float64> rate3;
DynamicProperty<float64> rate4;
DynamicProperty<float64> rate5;
DynamicProperty<float64> rate6;
DynamicProperty<float64> rate7;
STDAQParams DAQParams;
vector<int32> feslots; // size nfeboard
......
......@@ -10,3 +10,13 @@ StereoElec.fe_tadc47pPrefix=Temp. ADC 4-7 (C)
StereoElec.led_dac3v3Prefix=DAC 3.3V
StereoElec.led_amp24vPrefix=Amplifier 24V
StereoElecScalers.Title=Trigger rates (Hz)
StereoElec.rate0Prefix=Channel 0
StereoElec.rate1Prefix=Channel 1
StereoElec.rate2Prefix=Channel 2
StereoElec.rate3Prefix=Channel 3
StereoElec.rate4Prefix=Channel 4
StereoElec.rate5Prefix=Channel 5
StereoElec.rate6Prefix=Channel 6
StereoElec.rate7Prefix=Channel 7
\ No newline at end of file
......@@ -5,6 +5,8 @@
</property>
<property name="nbledmax" type="int32" max_length="3">
</property>
<dynamic_property name="slotindex" size_property="nbfemax" type="int32" max_length="2">
</dynamic_property>
<dynamic_property name="fe_pos5v" size_property="nbfemax" type="float64" max_length="5">
</dynamic_property>
<dynamic_property name="fe_neg5v" size_property="nbfemax" type="float64" max_length="5">
......@@ -21,5 +23,21 @@
</dynamic_property>
<dynamic_property name="led_amp24v" size_property="nbledmax" type="float64" max_length="5">
</dynamic_property>
<dynamic_property name="rate0" size_property="nbfemax" type="float64" max_length="8">
</dynamic_property>
<dynamic_property name="rate1" size_property="nbfemax" type="float64" max_length="8">
</dynamic_property>
<dynamic_property name="rate2" size_property="nbfemax" type="float64" max_length="8">
</dynamic_property>
<dynamic_property name="rate3" size_property="nbfemax" type="float64" max_length="8">
</dynamic_property>
<dynamic_property name="rate4" size_property="nbfemax" type="float64" max_length="8">
</dynamic_property>
<dynamic_property name="rate5" size_property="nbfemax" type="float64" max_length="8">
</dynamic_property>
<dynamic_property name="rate6" size_property="nbfemax" type="float64" max_length="8">
</dynamic_property>
<dynamic_property name="rate7" size_property="nbfemax" type="float64" max_length="8">
</dynamic_property>
</controller>
......@@ -2,14 +2,16 @@
<controller type="stereo_elec_controller" role="stereo_elec_controller1"/>
<group title="StereoElec.Title">
<group title="StereoElecFE.Title">
<table_composite nbColumns="6">
<table_composite nbColumns="7">
<simple_label prefix="StereoElec.slotnumberPrefix" font_style="BOLD" hAlignment="center"/>
<simple_label prefix="StereoElec.fe_pos5vPrefix" font_style="BOLD" hAlignment="center"/>
<simple_label prefix="StereoElec.fe_neg5vPrefix" font_style="BOLD" hAlignment="center"/>
<simple_label prefix="StereoElec.fe_adc3v3aPrefix" font_style="BOLD" hAlignment="center"/>
<simple_label prefix="StereoElec.fe_adc1v8aPrefix" font_style="BOLD" hAlignment="center"/>
<simple_label prefix="StereoElec.fe_tadc03pPrefix" font_style="BOLD" hAlignment="center"/>
<simple_label prefix="StereoElec.fe_tadc47pPrefix" font_style="BOLD" hAlignment="center"/>
<dynamic_composite role="stereo_elec_controller1" properties="fe_pos5v,fe_neg5v,fe_adc3v3a,fe_adc1v8a,fe_tadc03,fe_tadc47">
<dynamic_composite role="stereo_elec_controller1" properties="slotindex,fe_pos5v,fe_neg5v,fe_adc3v3a,fe_adc1v8a,fe_tadc03,fe_tadc47">
<label role="stereo_elec_controller1" property="slotindex" hAlignment="center"/>
<label role="stereo_elec_controller1" property="fe_pos5v" hAlignment="center"/>
<label role="stereo_elec_controller1" property="fe_neg5v" hAlignment="center"/>
<label role="stereo_elec_controller1" property="fe_adc3v3a" hAlignment="center"/>
......@@ -18,8 +20,35 @@
<label role="stereo_elec_controller1" property="fe_tadc47" hAlignment="center"/>
</dynamic_composite>
</table_composite>
<newLine/>
<simple_label prefix="StereoElecScalers.Title" font_style="BOLD" hAlignment="center"/>
<newLine/>
<table_composite nbColumns="9">
<simple_label prefix="StereoElec.slotnumberPrefix" font_style="BOLD" hAlignment="center"/>
<simple_label prefix="StereoElec.rate0Prefix" font_style="BOLD" hAlignment="center"/>
<simple_label prefix="StereoElec.rate1Prefix" font_style="BOLD" hAlignment="center"/>
<simple_label prefix="StereoElec.rate2Prefix" font_style="BOLD" hAlignment="center"/>
<simple_label prefix="StereoElec.rate3Prefix" font_style="BOLD" hAlignment="center"/>
<simple_label prefix="StereoElec.rate4Prefix" font_style="BOLD" hAlignment="center"/>
<simple_label prefix="StereoElec.rate5Prefix" font_style="BOLD" hAlignment="center"/>
<simple_label prefix="StereoElec.rate6Prefix" font_style="BOLD" hAlignment="center"/>
<simple_label prefix="StereoElec.rate7Prefix" font_style="BOLD" hAlignment="center"/>
<dynamic_composite role="stereo_elec_controller1" properties="slotindex,rate0,rate1,rate2,rate3,rate4,rate5,rate6,rate7">
<label role="stereo_elec_controller1" property="slotindex" hAlignment="center"/>
<label role="stereo_elec_controller1" property="rate0" hAlignment="center"/>
<label role="stereo_elec_controller1" property="rate1" hAlignment="center"/>
<label role="stereo_elec_controller1" property="rate2" hAlignment="center"/>
<label role="stereo_elec_controller1" property="rate3" hAlignment="center"/>
<label role="stereo_elec_controller1" property="rate4" hAlignment="center"/>
<label role="stereo_elec_controller1" property="rate5" hAlignment="center"/>
<label role="stereo_elec_controller1" property="rate6" hAlignment="center"/>
<label role="stereo_elec_controller1" property="rate7" hAlignment="center"/>
</dynamic_composite>
</table_composite>
</group>
<newLine/>
<group title="StereoElecLED.Title">
<table_composite nbColumns="2">
<simple_label prefix="StereoElec.led_dac3v3Prefix" font_style="BOLD" hAlignment="center"/>
......@@ -30,5 +59,8 @@
</dynamic_composite>
</table_composite>
</group>
</group>
</plugin>
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment