Commit 8590093b authored by Locatelli's avatar Locatelli

Add first implementation of Type of measure

parent f5958624
......@@ -21,6 +21,8 @@
#include "controllers/common/family/Families.h"
#include "controllers/common/datafile/DataFileManager.h"
#include "Utilities/Simulated.h"
#include "TypeOfMeasure.h"
#include <InstrumentManager/InstrumentManager.h>
#include <boost/format.hpp>
#include <boost/lexical_cast.hpp>
......@@ -66,6 +68,7 @@ Count::Count(const string& name) :
m_TimeSetPointSecond = 0;
totalReps.update(1);
localReps.update(1);
m_TypeOfMeasure = NULL;
// Disable histogramming
setHistogramming(false);
......@@ -129,6 +132,14 @@ void Count::postConfiguration() {
registerUpdater(experimentData->numor, &Count::updateNumor, this);
registerUpdater(gate->gateStatus, &Count::updateStatus, this);
registerUpdater(gate->gateProgression, &Count::updateProgression, this);
// Get Type of measure controller
m_TypeOfMeasure = dynamic_cast<TypeOfMeasure*>(InstrumentManager::getInstance()->getFirstExperimentControllerByType(TypeOfMeasure::TYPE));
if (m_TypeOfMeasure != NULL) {
m_TypeOfMeasure->attach(this);
registerUpdater(m_TypeOfMeasure->typeOfMesure, &Count::updateMeasureType, this);
updateMeasureType();
}
}
void Count::init() {
......@@ -456,6 +467,15 @@ void Count::updateNumor() {
logNumor = logNumorValue.str();
}
/*
* updateMeasureType
*/
void Count::updateMeasureType() {
if (m_TypeOfMeasure != NULL) {
logMeasureType.update(m_TypeOfMeasure->typeOfMesure());
}
}
/*
* updateProgression
*/
......@@ -795,6 +815,13 @@ void Count::logCount() {
stringstream sstitle;
stringstream ssvalues;
// if (m_TypeOfMeasure == NULL) {
// cerr << "Type of measure is missing !!!!!!!" << endl;
// return;
// }
// LogStream logStream = log(Level::s_Info).property(logAcquisitionType).property(logNumor).property(logSubtitle).property(
// logMeasureType);
LogStream logStream = log(Level::s_Info)
.property(logAcquisitionType)
.property(logNumor)
......
......@@ -32,6 +32,8 @@
namespace acquisition {
class TypeOfMeasure;
class Count: public AbstractCount,
public CountProperties,
public ::CountLogProperties,
......@@ -118,6 +120,7 @@ protected:
void updateListModeData();
void updateNumor();
void updateProgression();
void updateMeasureType();
virtual void init();
virtual void stopAtEnd();
......@@ -152,7 +155,7 @@ protected:
bool m_UseMasterAcq;
bool m_UseMpda;
TypeOfMeasure* m_TypeOfMeasure;
static const std::string STANDARD_LOG_STYLE;
static const std::string TAS_LOG_STYLE;
......
......@@ -37,9 +37,10 @@
<controller class="acquisition::ExperimentData"/>
<controller class="acquisition::KineticCount"/>
<controller class="acquisition::MaskController"/>
<controller class="acquisition::TimeCount"/>
<controller class="acquisition::RocCount"/>
<controller class="acquisition::SampleDescription"/>
<controller class="acquisition::TimeCount"/>
<controller class="acquisition::TypeOfMeasure"/>
<parser class="command_line::GenericParser"/>
</module>
\ No newline at end of file
/*
* 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 "TypeOfMeasure.h"
namespace acquisition {
const string TypeOfMeasure::TYPE = "type_of_measure";
const string TypeOfMeasure::UNKNOWN = "Unknown";
const int32 TypeOfMeasure::UNKNOWN_INDEX = 0;
const string TypeOfMeasure::EMPTY_CELL = "Empty Cell";
const int32 TypeOfMeasure::EMPTY_CELL_INDEX = 1;
const string TypeOfMeasure::BACKGROUND = "Background";
const int32 TypeOfMeasure::BACKGROUND_INDEX = 2;
const string TypeOfMeasure::SAMPLE_REF = "Sample Reference";
const int32 TypeOfMeasure::SAMPLE_REF_INDEX = 3;
const string TypeOfMeasure::SAMPLE = "Sample";
const int32 TypeOfMeasure::SAMPLE_INDEX = 4;
const string TypeOfMeasure::D2O = "D2O";
const int32 TypeOfMeasure::D2O_INDEX = 5;
const string TypeOfMeasure::H2O = "H2O";
const int32 TypeOfMeasure::H2O_INDEX = 6;
/*
* Constructor
*/
TypeOfMeasure::TypeOfMeasure(const string& name) :
ExperimentController(name), controller::Start(this) {
setFamily(family::ACQUISITION, family::SETTING);
typeOfMesure.init(this, SPY | LOG_INFO | NOSAVE, "type", "MeasType");
typeOfMesureIndex.init(this, SAVE, "type_index");
nbTypes.init(this, NOSAVE, "nb_types");
types.init(this, NOSAVE, "types");
typesIndex.init(this, NOSAVE, "types_index");
nbHiddenTypes.init(this, SAVE, "nb_hidden_types");
hiddenTypes.init(this, SAVE, "hidden_types");
registerFunction(TYPE);
registerRefresher(nbHiddenTypes, &TypeOfMeasure::refreshNbHiddenTypesProperty, this);
}
/*
* Destructor
*/
TypeOfMeasure::~TypeOfMeasure() {
}
/*
* postConfiguration
*/
void TypeOfMeasure::postConfiguration() {
// construction of types list
addMeasureType(EMPTY_CELL_INDEX, EMPTY_CELL);
addMeasureType(BACKGROUND_INDEX, BACKGROUND);
addMeasureType(SAMPLE_REF_INDEX, SAMPLE_REF);
addMeasureType(SAMPLE_INDEX, SAMPLE);
addMeasureType(D2O_INDEX, D2O);
addMeasureType(H2O_INDEX, H2O);
//typeOfMesureIndex.setEnumeratedValues(typesIndex);
//typeOfMesureIndex.setEnumeratedLabels(types);
registerRefresher(typeOfMesureIndex, &TypeOfMeasure::refreshTypeIndexProperty, this);
}
/*
* refreshNbHiddenTypesProperty
*/
void TypeOfMeasure::refreshNbHiddenTypesProperty(int32 value) throw (CannotSetValue) {
hiddenTypes.resize(value);
}
/*
* refreshTypeIndexProperty
*/
void TypeOfMeasure::refreshTypeIndexProperty(int32 value) throw (CannotSetValue) {
bool found = false;
for (int32 i = 0; i < nbTypes(); ++i) {
if (value == typesIndex.get(i)) {
found = true;
break;
}
}
if (found == false) {
throw CannotSetValue();
}
switch(value) {
case EMPTY_CELL_INDEX:
typeOfMesure.update(EMPTY_CELL);
break;
case BACKGROUND_INDEX:
typeOfMesure.update(BACKGROUND);
break;
case SAMPLE_REF_INDEX:
typeOfMesure.update(SAMPLE_REF);
break;
case SAMPLE_INDEX:
typeOfMesure.update(SAMPLE);
break;
case D2O_INDEX:
typeOfMesure.update(D2O);
break;
case H2O_INDEX:
typeOfMesure.update(H2O);
break;
default:
typeOfMesure.update(UNKNOWN);
}
}
/*
* addMeasureType
*/
void TypeOfMeasure::addMeasureType(int32 index, const string& name) {
if (!isHiddenType(index)) {
nbTypes = nbTypes() + 1;
types.resize(nbTypes());
typesIndex.resize(nbTypes());
typesIndex.set(nbTypes() - 1, index);
types.set(nbTypes() - 1, name);
}
}
/*
* isHiddenType
*/
bool TypeOfMeasure::isHiddenType(int32 index) const {
bool found = false;
for (int32 i = 0; i < nbHiddenTypes(); ++i) {
if (index == hiddenTypes.get(i)) {
found = true;
break;
}
}
return found;
}
/*
* start
*/
void TypeOfMeasure::start() {
commandProgression = 0;
commandProgression = 100;
}
}
/*
* 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 TYPEOFMEASURE_H
#define TYPEOFMEASURE_H
#include <Controller.h>
namespace acquisition {
/*!
* \class TypeOfMeasure
* \brief Class described the type of measure controller
*
* \par
* This class is contains info of the type of measure needed for logs and data treatment
*/
class TypeOfMeasure: public ExperimentController, public controller::Start {
public:
//! Type of controller
static const std::string TYPE;
/*!
* \brief Constructor
* \param[in] name the name of the experiment controller
*/
TypeOfMeasure(const std::string& name);
/*!
* \brief Destructor
*/
virtual ~TypeOfMeasure();
/*!
* Properties
*/
Property<std::string> typeOfMesure; // Actual type
Property<int32> typeOfMesureIndex; // Actual type index
Property<int32> nbTypes; // Number of visible types
DynamicProperty<std::string> types; // Visible type names
DynamicProperty<int32> typesIndex; // Visible type index
Property<int32> nbHiddenTypes; // Number of hidden types
DynamicProperty<int32> hiddenTypes;
static const std::string UNKNOWN;
static const int32 UNKNOWN_INDEX;
static const std::string EMPTY_CELL;
static const int32 EMPTY_CELL_INDEX;
static const std::string BACKGROUND;
static const int32 BACKGROUND_INDEX;
static const std::string SAMPLE_REF;
static const int32 SAMPLE_REF_INDEX;
static const std::string SAMPLE;
static const int32 SAMPLE_INDEX;
static const std::string D2O;
static const int32 D2O_INDEX;
static const std::string H2O;
static const int32 H2O_INDEX;
private:
virtual void postConfiguration();
virtual void start();
/*!
* \brief Method called before changing the number of hidden types property value
* \throws CannotSetValue the value isn't corrected, or property couldn't be changed
*/
void refreshNbHiddenTypesProperty(int32 value) throw (CannotSetValue);
void refreshTypeIndexProperty(int32 value) throw (CannotSetValue);
void addMeasureType(int32 index, const std::string& name);
bool isHiddenType(int32 index) const;
};
}
#endif //TYPEOFMEASURE_H
<plugin>
<controller type="type_of_measure" role="type_of_measure1"/>
<number_of_lines nb_lines="1"/>
<property_combo role="type_of_measure1" property="type_index" prefix="type_of_measure.type_indexPrefix"/>
</plugin>
<controller_plugin_config type="type_of_measure">
<image key="SETTINGS"/>
<settings view="type_of_measureView.xml"/>
<command view="type_of_measureCommandView.xml"/>
<spy view="type_of_measureSpyView.xml"/>
</controller_plugin_config>
<?xml version="1.0" encoding="ISO-8859-1" ?>
<controller type="type_of_measure">
<property name="type_index" type="int32">
</property>
<property name="type" type="String" max_length="20">
</property>
<property name="nb_types" type="int32">
</property>
<dynamic_property name="types" size_property="nb_types" type="String">
</dynamic_property>
<dynamic_property name="types_index" size_property="nb_types" type="int32">
</dynamic_property>
</controller>
<plugin>
<controller type="type_of_measure" role="type_of_measure1"/>
<composite grabHorizontal="true">
<label role="type_of_measure1" property="type" font_size="12" font_style="BOLD" hAlignment="center"/>
</composite>
</plugin>
<plugin>
<controller type="type_of_measure" role="type_of_measure1"/>
<property_combo role="type_of_measure1" property="type_index" prefix="type_of_measure.type_indexPrefix"/>
</plugin>
......@@ -30,4 +30,5 @@ BaseLogProperties::BaseLogProperties(ExperimentController* controller) {
logNumor.init(controller, NOSAVE, "log_numor");
logSubtitle.init(controller, NOSAVE, "log_subtitle");
logTime.init(controller, NOSAVE, "log_time", "LogTime");
logMeasureType.init(controller, NOSAVE, "log_measure_type");
}
......@@ -37,6 +37,7 @@ public:
Property<std::string> logNumor;
Property<std::string> logSubtitle;
Property<std::string> logTime;
Property<std::string> logMeasureType;
static const std::string ACQTYPE;
};
......
......@@ -30,6 +30,7 @@
#include "../DiffMesureSetting.h"
#include "controllers/common/baselegacy/BaseCount.h"
#include "controllers/common/baselegacy/ExperimentControllerDef.h"
#include "controllers/common/acquisition/TypeOfMeasure.h"
#include <boost/any.hpp>
#include <boost/format.hpp>
#include <boost/algorithm/string.hpp>
......@@ -628,7 +629,6 @@ void DiffParCmd::parse(Items& items) throw (CannotSetValue, CommonCmdDef::BadInp
buf1 << "Simple scan width curve - theta vs. width:";
m_Parser->outputText(buf1.str());
m_Parser->outputEndl();
ostringstream buf2;
buf2 << "Theta values : ";
i = 0;
......@@ -1022,6 +1022,39 @@ void DiffParCmd::parse(Items& items) throw (CannotSetValue, CommonCmdDef::BadInp
}
}
/*
* Check For Measure type
*/
else if ((StringUtilities::cmp(*items, "mty", 3) == true)) {
++items;
acquisition::TypeOfMeasure* controller = dynamic_cast<acquisition::TypeOfMeasure*>(m_Parser->getControllerByFunction(
acquisition::TypeOfMeasure::TYPE));
if (controller != NULL) {
if (items.end() == false) {
controller->typeOfMesureIndex = m_Parser->cast<int32>(*items);
}
else {
ostringstream buf1;
buf1 << "actual: " << controller->typeOfMesureIndex() << "- " << controller->typeOfMesure();
m_Parser->outputText(buf1.str());
m_Parser->outputEndl();
ostringstream buf2;
buf2 << "Possibilities:";
m_Parser->outputText(buf2.str());
m_Parser->outputEndl();
for(int32 i=0;i<controller->nbTypes();++i) {
ostringstream buf3;
buf3 << "\t\t" << controller->typesIndex.get(i) << "- " << controller->types.get(i);
m_Parser->outputText(buf3.str());
m_Parser->outputEndl();
}
}
}
else {
throw CommonCmdDef::BadInput("Type of Measure object is missing");
}
return;
}
/*
* Error
*/
......
......@@ -28,6 +28,7 @@
#include <boost/any.hpp>
#include <boost/algorithm/string.hpp>
#include "controllers/common/sample_environment/environment/SampleSettings.h"
#include "controllers/common/acquisition/TypeOfMeasure.h"
namespace tas {
......@@ -294,6 +295,29 @@ void TasPrintCmd::parse(Items& items) throw (CannotSetValue, CommonCmdDef::BadIn
m_Parser->outputProperty(pcontroller, "VF", pcontroller->pressure.getName());
}
}
else if ((StringUtilities::cmp(*items, "mty") == true)) {
acquisition::TypeOfMeasure* controller = dynamic_cast<acquisition::TypeOfMeasure*>(m_Parser->getControllerByFunction(
acquisition::TypeOfMeasure::TYPE));
if (controller != NULL) {
ostringstream buf1;
buf1 << "actual: " << controller->typeOfMesureIndex() << "- " << controller->typeOfMesure();
m_Parser->outputText(buf1.str());
m_Parser->outputEndl();
ostringstream buf2;
buf2 << "Possibilities:";
m_Parser->outputText(buf2.str());
m_Parser->outputEndl();
for(int32 i=0;i<controller->nbTypes();++i) {
ostringstream buf3;
buf3 << "\t\t" << controller->typesIndex.get(i) << "- " << controller->types.get(i);
m_Parser->outputText(buf3.str());
m_Parser->outputEndl();
}
}
else {
throw CommonCmdDef::BadInput("Type of Measure object is missing");
}
}
/*
* Error
*/
......
......@@ -28,6 +28,7 @@
#include <boost/any.hpp>
#include <boost/algorithm/string.hpp>
#include "controllers/common/sample_environment/environment/SampleSettings.h"
#include "controllers/common/acquisition/TypeOfMeasure.h"
namespace tas {
......@@ -253,6 +254,22 @@ void TasSetCmd::parse(Items& items) throw (CannotSetValue, CommonCmdDef::BadInpu
CommandLineManager::getInstance()->output(buf.str());
}
}
else if ((StringUtilities::cmp(*items, "mty") == true)) {
++items;
acquisition::TypeOfMeasure* controller = dynamic_cast<acquisition::TypeOfMeasure*>(m_Parser->getControllerByFunction(
acquisition::TypeOfMeasure::TYPE));
if (controller != NULL) {
if (items.end() == false) {
controller->typeOfMesureIndex = m_Parser->cast<int32>(*items);
}
else {
throw CommonCmdDef::BadInput("Type of Measure value is missing");
}
}
else {
throw CommonCmdDef::BadInput("Type of Measure object is missing");
}
}
/*
* Error
......
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