Commit 9f93f92f authored by Locatelli's avatar Locatelli
Browse files

Add cyclops Dat Header controller:

This controller prepare a data header for the cyclops camera server
parent 6183e08f
/*
* 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 "controllers/common/family/Families.h"
#include "CyclopsDataHeader.h"
#include <InstrumentManager/InstrumentManager.h>
namespace cyclops {
const string CyclopsDataHeader::TYPE = "cyclops_dataheader";
const string CyclopsDataHeader::SEP_VALUE = ":";
const string CyclopsDataHeader::SEP_PARAM = ",";
const string CyclopsDataHeader::END = "*";
/*
* Constructor
*/
CyclopsDataHeader::CyclopsDataHeader(const string& name) :
utilities::CountSpy(name) {
setFamily(family::HIDDEN);
registerFunction(TYPE);
m_CamDriver.init(this, "cammeraDriver");
m_Title.init(this, "title");
m_SampleSettings.init(this, "sample_settings");
m_ScanInfo.init(this, "scan_info");
m_CyclopsSetting.init(this, "cyclops_setting");
map<string, ExperimentController*> experimentControllersMap =
InstrumentManager::getInstance()->getAllInstalledExperimentControllersMap();
map<string, ExperimentController*>::iterator it;
for (it = experimentControllersMap.begin(); it != experimentControllersMap.end(); it++) {
if (dynamic_cast<axis::AxisController*>(it->second) != 0) {
axis::AxisController* axis = dynamic_cast<axis::AxisController*>(it->second);
m_AxisControllers.push_back(axis);
}
}
}
/*
* Destructor
*/
CyclopsDataHeader::~CyclopsDataHeader() {
}
/*
* postConfiguration
*/
void CyclopsDataHeader::postConfiguration() {
utilities::CountSpy::postConfiguration();
}
/*
* updateProperty
*/
void CyclopsDataHeader::updateProperty(ChangeAspect* aChangeAspect) {
string propertyName = aChangeAspect->getStringParam();
string controllername = aChangeAspect->getControllerName();
int32 i;
for (i = 0; i < (int32) m_CountControllers.size(); ++i) {
if (m_CountControllers[i]->getName() == controllername) {
break;
}
}
if (i < (int32) m_CountControllers.size()) {
if (propertyName == statusMessage.getName()) {
boost::any propvalue = dynamic_cast<AbstractController*>(m_CountControllers[i])->getValue(propertyName);
if (any_cast<string>(propvalue) == "Writing parameters") {
createHeader();
}
}
}
utilities::CountSpy::updateProperty(aChangeAspect);
}
/*
* createHeader
*/
void CyclopsDataHeader::createHeader() {
ostringstream header;
header << " ";
create_a(header, "instrument", m_Title->instrumentName());
create_a(header, "dated", m_Title->startTime());
create_a(header, "user", m_Title->userName());
create_a(header, "l.c.", m_Title->localContactName());
create_a(header, "commentary", m_Title->title());
if (m_ScanInfo->running()) {
create_a(header, "scan_angle", m_ScanInfo->firstControllerName());
}
else {
create_a(header, "scan_angle", "none");
}
create_i(header, "kctrl", 4, 0);
create_i(header, "manip", m_ScanInfo->firstIndex(), 0);
create_i(header, "nbang", m_ScanInfo->nbController(), 0);
create_i(header, "nkmes", m_ScanInfo->nbStep(), 0);
create_i(header, "npmes", m_ScanInfo->actualStep(), 0);
create_i(header, "jcode", modeint(), 0);
create_i(header, "count", 0, 0);
create_i(header, "gain", m_CyclopsSetting->gain(), 0);
create_i(header, "mode", m_CyclopsSetting->mode(), 0);
create_i(header, "nacq", m_CyclopsSetting->nbKine(), 0);
vector<axis::AxisController*>::iterator iter = m_AxisControllers.begin();
while(iter != m_AxisControllers.end()) {
ostringstream name;
name << "angle_" << (*iter)->getName();
create_f(header, name.str(), (*iter)->position(), 8 ,2);
++iter;
}
create_f(header, "scan_start", m_ScanInfo->firstStartValue(), 8 ,2);
create_f(header, "scan_width", m_ScanInfo->firstWidthValue(), 8 ,2);
create_f(header, "scan_step", m_ScanInfo->firstStepValue(), 8 ,2);
if (m_SampleSettings->useMag() == true) {
create_f(header, "magf", m_SampleSettings->getMagController()->field(), 8 ,2);
}
if (m_SampleSettings->useTemp() == true) {
create_f(header, "temp", m_SampleSettings->getMainSampleTempController()->regulationTemperature(), 8 ,2);
create_f(header, "stpt", m_SampleSettings->getMainSampleTempController()->setpointTemperature(), 8 ,2);
create_f(header, "reqt", m_SampleSettings->getMainSampleTempController()->wantedTemperature(), 8 ,2);
create_f(header, "samp", m_SampleSettings->getMainSampleTempController()->sampleTemperature(), 8 ,2);
create_f(header, "heat", m_SampleSettings->getMainSampleTempController()->power(), 8 ,2);
if (m_SampleSettings->getSecSampleTempController()->isEnabled() == true) {
create_f(header, "temp2", m_SampleSettings->getSecSampleTempController()->regulationTemperature(), 8 ,2);
create_f(header, "stpt2", m_SampleSettings->getSecSampleTempController()->setpointTemperature(), 8 ,2);
create_f(header, "reqt2", m_SampleSettings->getSecSampleTempController()->wantedTemperature(), 8 ,2);
create_f(header, "samp2", m_SampleSettings->getSecSampleTempController()->sampleTemperature(), 8 ,2);
create_f(header, "heat2", m_SampleSettings->getSecSampleTempController()->power(), 8 ,2);
}
else {
create_f(header, "temp2", -1., 8 ,2);
}
}
header << END;
m_CamDriver->header = header.str();
}
/*
* create_a
*/
void CyclopsDataHeader::create_a(ostream& out, const string& name, const string& value) {
out << name << SEP_VALUE << value << SEP_PARAM;
}
/*
* create_i
*/
void CyclopsDataHeader::create_i(ostream& out, const string& name, int32 value, uint32 nbch) {
ostringstream buf;
if (nbch > 0) {
buf.width(nbch);
}
buf << value;
create_a(out, name, buf.str());
}
/*
* create_f
*/
void CyclopsDataHeader::create_f(ostream& out, const string& name, float64 value, uint32 nbch, uint32 nbdec) {
ostringstream buf;
if (nbch > 0) {
buf.width(nbch);
}
buf.precision(nbdec);
buf << value;
create_a(out, name, buf.str());
}
}
/*
* 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.
*/
/*!
* \brief class cyclops camera data settings
* \author J. Locatelli
* \date 21-11-2019
*/
#ifndef CYCLOPSDATAHEADER_H
#define CYCLOPSDATAHEADER_H
#include <Controller.h>
#include "CyclopsSetting.h"
#include "controllers/common/utilities/CountSpy.h"
#include "controllers/common/acquisition/ExperimentData.h"
#include "controllers/common/axis/AxisController.h"
#include "controllers/common/sample_environment/environment/SampleSettings.h"
#include "controllers/common/scanlegacy/ScanInfo.h"
#include "drivers/photonic/psl/PslDriver.h"
namespace cyclops {
/*!
* \class cyclops data server path setiing
* \brief Configure data path and name for cyclops data server
*/
class CyclopsDataHeader: public utilities::CountSpy {
public:
//! Type of controller
static const std::string TYPE;
/*!
* \brief Constructor
* \param[in] name the name of the experiment controller
*/
CyclopsDataHeader(const std::string& name);
/*!
* \brief Destructor
*/
virtual ~CyclopsDataHeader();
virtual void updateProperty(ChangeAspect* aChangeAspect);
/*!
* Properties
*/
private:
/*!
* \brief Method called before changing the property value
* This method is called after setting configuration during the creation of controller.
*/
virtual void postConfiguration();
DriverPtr<psl::PslDriver> m_CamDriver;
ControllerPtr<acquisition::ExperimentData> m_Title;
ControllerPtr<sample_environment::SampleSettings> m_SampleSettings;
ControllerPtr<scan::ScanInfo> m_ScanInfo;
ControllerPtr<CyclopsSetting> m_CyclopsSetting;
std::vector<axis::AxisController*> m_AxisControllers;
void createHeader();
void create_a(std::ostream& out, const std::string& name, const std::string& value);
void create_i(std::ostream& out, const std::string& name, int32 value, uint32 nbch);
void create_f(std::ostream& out, const std::string& name, float64 value, uint32 nbch, uint32 nbdec);
static const std::string SEP_VALUE;
static const std::string SEP_PARAM;
static const std::string END;
};
}
#endif //CYCLOPSDATAHEADER_H
......@@ -22,8 +22,8 @@
* \date 02-11-2016
*/
#ifndef CameraSETTING_H
#define CameraSETTING_H
#ifndef CAMERASETTING_H
#define CAMERASETTING_H
#include "controllers/common/acquisition/detector/DetectorElement.h"
#include "controllers/common/acquisition/detector/DetectorController.h"
......
<module name="cyclops">
<controller class="cyclops::CyclopsDataHeader"/>
<controller class="cyclops::CyclopsDataPath"/>
<controller class="cyclops::CyclopsSetting"/>
......
......@@ -62,6 +62,7 @@ PslDriver::PslDriver(const string& name):
fileDirectory.init(this, SAVE, "fileDirectory");
fileName.init(this, SAVE, "fileName");
numor.init(this, SAVE, "numor");
header.init(this, NOSAVE, "header");
initCommand(driver::INIT_COMMAND);
initCommand(driver::READ_COMMAND);
......
......@@ -91,6 +91,7 @@ public:
Property<string> fileName;
Property<int32> numor;
Property<std::string> header;
private:
......
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