Commit 51d3f654 authored by yannick legoc's avatar yannick legoc
Browse files

removed the binary sending of data for dpp histogram and coincidence

parent 7aaf3691
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
<controller class="npp::RemoteDPPContext"/> <controller class="npp::RemoteDPPContext"/>
<controller class="npp::RemoteDPPHistogram"/> <controller class="npp::RemoteDPPHistogram"/>
<controller class="npp::RemoteDPPCoincidence"/> <controller class="npp::RemoteDPPCoincidence"/>
<controller class="npp::RemoteDPPTest"/>
<include path="$(NOMAD_HOME)/../NomadModules/src"/> <include path="$(NOMAD_HOME)/../NomadModules/src"/>
......
...@@ -95,12 +95,14 @@ void RemoteDPPCoincidence::setDetectorControllers(const std::vector<ControllerPt ...@@ -95,12 +95,14 @@ void RemoteDPPCoincidence::setDetectorControllers(const std::vector<ControllerPt
DPPLiveProcess::setDetectorControllers(detectorControllers); DPPLiveProcess::setDetectorControllers(detectorControllers);
/* Do not do it
// register the list mode data // register the list mode data
int32 index = 0; int32 index = 0;
for (vector<ControllerPtr<acquisition::DetectorController> >::const_iterator c = detectorControllers.begin(); c != detectorControllers.end(); ++c) { for (vector<ControllerPtr<acquisition::DetectorController> >::const_iterator c = detectorControllers.begin(); c != detectorControllers.end(); ++c) {
registerUpdater((*c)->listModeData, &RemoteDPPCoincidence::updateListModeData, this, index); registerUpdater((*c)->listModeData, &RemoteDPPCoincidence::updateListModeData, this, index);
index++; index++;
} }
*/
} }
void RemoteDPPCoincidence::start() { void RemoteDPPCoincidence::start() {
......
...@@ -77,6 +77,7 @@ void RemoteDPPHistogram::setDetectorControllers(const std::vector<ControllerPtr< ...@@ -77,6 +77,7 @@ void RemoteDPPHistogram::setDetectorControllers(const std::vector<ControllerPtr<
DPPLiveProcess::setDetectorControllers(detectorControllers); DPPLiveProcess::setDetectorControllers(detectorControllers);
/* Do not do it.
// Register the list mode data // Register the list mode data
int32 index = 0; int32 index = 0;
for (vector<ControllerPtr<acquisition::DetectorController> >::const_iterator c = detectorControllers.begin(); c != detectorControllers.end(); ++c) { for (vector<ControllerPtr<acquisition::DetectorController> >::const_iterator c = detectorControllers.begin(); c != detectorControllers.end(); ++c) {
...@@ -84,7 +85,7 @@ void RemoteDPPHistogram::setDetectorControllers(const std::vector<ControllerPtr< ...@@ -84,7 +85,7 @@ void RemoteDPPHistogram::setDetectorControllers(const std::vector<ControllerPtr<
(*c)->attach(this); (*c)->attach(this);
registerUpdater((*c)->listModeData, &RemoteDPPHistogram::updateListModeData, this, index); registerUpdater((*c)->listModeData, &RemoteDPPHistogram::updateListModeData, this, index);
index++; index++;
} }*/
} }
void RemoteDPPHistogram::start() { void RemoteDPPHistogram::start() {
......
/*
* 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 "RemoteDPPTest.h"
#include <common/base/ServerProperties.h>
#include <boost/thread.hpp>
#include <boost/bind.hpp>
#include <boost/lexical_cast.hpp>
#include <boost/property_tree/json_parser.hpp>
#include <cstdlib>
namespace npp {
using namespace std;
using namespace common;
using namespace boost;
using namespace cameo;
using namespace lstdpp128;
using boost::property_tree::ptree;
const std::string RemoteDPPTest::TYPE = "remote_dpp_test";
RemoteDPPTest::RemoteDPPTest(const std::string& name) :
RemoteDPPLiveProcess(name) {
maxBlock.init(this, SAVE, "max_block");
refreshTimeS.init(this, SAVE, "refresh_time_s");
}
RemoteDPPTest::RemoteDPPTest(const RemoteDPPTest& controller) :
RemoteDPPLiveProcess(controller) {
}
RemoteDPPTest::~RemoteDPPTest() {
}
void RemoteDPPTest::postConfiguration() {
RemoteDPPLiveProcess::postConfiguration();
resetData();
}
void RemoteDPPTest::setDetectorControllers(const std::vector<ControllerPtr<acquisition::DetectorController> > & detectorControllers) {
DPPLiveProcess::setDetectorControllers(detectorControllers);
// Register the list mode data
int32 index = 0;
for (vector<ControllerPtr<acquisition::DetectorController> >::const_iterator c = detectorControllers.begin(); c != detectorControllers.end(); ++c) {
// Force the attachment to receive updates
(*c)->attach(this);
registerUpdater((*c)->listModeData, &RemoteDPPTest::updateListModeData, this, index);
index++;
}
}
void RemoteDPPTest::start() {
cout << "RemoteDPPTest::start" << endl;
// Need a mutex to avoid having two start at the same time.
{
boost::mutex::scoped_lock lock(m_mutex);
resetData();
// Numor
string numor;
size_t size = fileName().size();
if (size < 6) {
string prefix(6 - size, '0');
numor = prefix + fileName();
} else {
numor = fileName();
}
string outputName = ServerProperties::getInstance()->getNomadDataPath() + "/" + numor + ".lst-test";
if (m_file.is_open()) {
m_file.close();
}
m_file.open(outputName.c_str(), ios::binary);
cout << getName() << " open " << outputName << endl;
}
}
void RemoteDPPTest::stop() {
if (m_file.is_open()) {
m_file.close();
cout << "File " << m_file << " is closed" << endl;
}
}
void RemoteDPPTest::raz() {
resetData();
}
void RemoteDPPTest::updateListModeData(int index) {
if (m_file.is_open()) {
int32 size = detectorControllers[index]->listModeData.getSize();
int32 * memoryBlock = detectorControllers[index]->listModeData();
// Put the array into a string
string data(reinterpret_cast<char *>(memoryBlock), sizeof(int32) * size);
// Send the data
m_file << data;
}
}
void RemoteDPPTest::resetData() {
}
}
/*
* 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 NPP_REMOTEDPPTEST_H
#define NPP_REMOTEDPPTEST_H
#include "RemoteDPPLiveProcess.h"
#include <boost/thread.hpp>
#include <stdint.h>
#include <memory>
#include <fstream>
namespace npp {
class RemoteDPPTest : public RemoteDPPLiveProcess {
public:
//! Type of controller
static const std::string TYPE;
RemoteDPPTest(const std::string& name);
RemoteDPPTest(const RemoteDPPTest& controller);
virtual ~RemoteDPPTest();
virtual void postConfiguration();
virtual void setDetectorControllers(const std::vector<ControllerPtr<acquisition::DetectorController> > & detectorControllers);
virtual void start();
virtual void stop();
virtual void raz();
void updateListModeData(int index);
private:
void resetData();
Property<int32> maxBlock;
Property<int32> refreshTimeS;
std::ofstream m_file;
};
}
#endif
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