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

Clean up on state variables. Add the et server start.

parent 3b0a5823
......@@ -23,9 +23,10 @@
#include <iostream>
#include <boost/thread.hpp>
#include <boost/bind.hpp>
#include <cameo/cameo.h>
using namespace std;
using namespace cameo;
namespace stereo_elec {
......@@ -49,6 +50,21 @@ RealStereoElecDriver::RealStereoElecDriver(StereoElecDriver* owner) :
m_serverThread = new boost::thread(boost::bind(&RealStereoElecDriver::qtLoop, this));
m_serverThread2 = new boost::thread(boost::bind(&RealStereoElecDriver::mtcaLoop, this));
cameo::Server server(application::This::getServer().getEndpoint());
auto_ptr<cameo::application::Instance> etsApplication = server.connect("ets");
if (etsApplication->exists()) {
// The application exists from a previous server session
etsApplication->kill();
application::State state = etsApplication->waitFor();
cout << "Terminated ets application " << state << " before restarting" << endl;
}
etsApplication = server.start("ets");
if (!etsApplication->exists()) {
cout << "No ets application" << endl;
}
}
/*
......@@ -95,17 +111,18 @@ void RealStereoElecDriver::qtLoop() {
} else if (*command == START_COMMAND) {
if(!owner()->started){
cout << "Before start " << owner()->DAQParams.FEParams_v.at(0).threshold_v[0] << endl;
//owner()->DAQParams.subtitle=owner()->counts.subtitle();
daq->DoStart(owner()->DAQParams);
cout << "DoStart ok" << endl;
daq->preQtAcqLoop();
m_TimeCounter.clear();
owner()->nbevent=0;
owner()->started=true;
owner()->startActivated=false;
}
}
else if (*command == READ_COMMAND) {
if(owner()->started and !owner()->m_StopActivated){
if(owner()->started){
try {
daq->QtAcqLoop();
owner()->nbevent=daq->getNbEvent();
......@@ -128,7 +145,7 @@ void RealStereoElecDriver::qtLoop() {
unsigned int accepted_cnt,rejected_cnt;
long elapsedtime;
if(owner()->started and !owner()->m_StopActivated){
if(owner()->started){
daq->QtAcqLoopCounter(accepted_cnt,rejected_cnt,false,scalers,elapsedtime);
cout << dec << "T1 accepted " << accepted_cnt << " T1 rejected " << rejected_cnt << " T2 accepted " << owner()->nbevent << endl;
......@@ -138,10 +155,15 @@ void RealStereoElecDriver::qtLoop() {
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 "
cout << "Error while reading the scalers : the scalers vector is too small. Intempting to read index "
<< index+7 << " whereas the scalers vector size is: " << scalers.size() << endl;
break;
}
if(index+7>=scalers.size()){
cout << "Error while reading the scalers : the scalers-prev vector is too small. Intempting to read index "
<< index+7 << " whereas the scalers_prev 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);
......@@ -167,16 +189,10 @@ void RealStereoElecDriver::qtLoop() {
}
}else if (*command == STOP_COMMAND) {
//owner()->startActivated =false;
if(owner()->started){
owner()->started=false;
daq->DoStop();
cout << "DoStop ok" << endl;
daq->DoSave();
cout << "DoSave ok" << endl;
}
//owner()->m_StopActivated = false;
}
delete command;
......@@ -227,7 +243,7 @@ void RealStereoElecDriver::writeParam() {
* readInfos
*/
void RealStereoElecDriver::readInfos() {
if(owner()->started and !owner()->m_StopActivated) m_commandQueue->put(new int32(READINFO_COMMAND),0);
if(owner()->started) m_commandQueue->put(new int32(READINFO_COMMAND),0);
}
/*
* start
......@@ -239,7 +255,6 @@ void RealStereoElecDriver::start() {
cout << "Start command" << endl;
m_commandQueue->put(new int32(START_COMMAND),1);
owner()->startActivated=true;
owner()->m_StopActivated = false;
}else{
cout << "The number of FE board in DAQParam (" << owner()->DAQParams.FEParams_v.size() <<") does not correspond to the number of FE board in the crate (" <<owner()->nfeboard()<<")." << endl;
}
......@@ -255,12 +270,9 @@ void RealStereoElecDriver::start() {
*/
void RealStereoElecDriver::stop() {
if(owner()->started){
owner()->startActivated=false;
if(!owner()->m_StopActivated){
cout << "Stop command" << endl;
m_commandQueue->put(new int32(STOP_COMMAND),1);
}
owner()->m_StopActivated = true;
cout << "Stop command" << endl;
m_commandQueue->put(new int32(STOP_COMMAND),1);
owner()->started = false;
}
}
......@@ -268,7 +280,7 @@ void RealStereoElecDriver::stop() {
* read
*/
void RealStereoElecDriver::read() {
if(owner()->started and !owner()->m_StopActivated) m_commandQueue->put(new int32(READ_COMMAND),0);
if(owner()->started) m_commandQueue->put(new int32(READ_COMMAND),0);
}
/*
......
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