Commit dda6a36c authored by yannick legoc's avatar yannick legoc
Browse files

Merge branch 'windeta-update' into V3.2_191

parents bf15aa20 20160fd1
......@@ -25,6 +25,8 @@
#include "InstrumentManager/InstrumentManager.h"
#include "controllers/common/acquisition/Count.h"
#include "controllers/common/acquisition/ExperimentData.h"
#include "controllers/common/sample_environment/environment/SampleSettings.h"
#include "controllers/common/pressure/PressureController.h"
#include <boost/filesystem/operations.hpp>
#include <thread>
#include <fstream>
......@@ -83,6 +85,8 @@ RemoteWindeta::RemoteWindeta(const std::string& name) :
dataFilenameFormat.setEnumeratedValues(dataFilenameFormatValues);
dataFilenameFormat.setEnumeratedLabels(dataFilenameFormatLabels);
comment.init(this, SAVE, "comment");
presetsChanged.init(this, NOSAVE, "presets_changed");
presetsSize.init(this, NOSAVE, "presets_size");
presets.init(this, NOSAVE, "presets");
......@@ -280,6 +284,9 @@ void RemoteWindeta::start() {
m_stopped = false;
m_countNumor = 0;
// Set the data filename.
setDataFilename();
// Wait for the count to have changed the numor so that we can use it in case of sync.
if (dataFilenameFormat() == COUNT_SYNC_VALUE) {
......@@ -306,6 +313,8 @@ void RemoteWindeta::start() {
windeta::StartMeasure requestMessage;
requestMessage.set_preset(preset());
requestMessage.set_filename(m_dataFilename);
requestMessage.set_comment(comment());
// Send the message.
m_requester->sendTwoBinaryParts(requestType.SerializeAsString(), requestMessage.SerializeAsString());
......@@ -318,8 +327,8 @@ void RemoteWindeta::start() {
windeta::Response response;
response.ParseFromString(data);
// Set the data filename.
setDataFilename();
// Save the sample environment.
saveCurrentSampleEnvironment();
// The status must become running within a timeout.
i = 0;
......@@ -513,10 +522,30 @@ void RemoteWindeta::setDataFilename() {
}
}
void RemoteWindeta::saveCurrentSampleEnvironment() {
sample_environment::SampleSettings* environment = dynamic_cast<sample_environment::SampleSettings*>(InstrumentManager::getInstance()->getFirstExperimentControllerByType(sample_environment::SampleSettings::TYPE));
if (environment != nullptr) {
// Temperature.
m_startingEnvironment += "Temperature: ";
m_startingEnvironment += std::to_string(environment->sampleTemperatureKelvin()) + "K ";
// Pressure.
pressure::PressureController* pressure = dynamic_cast<pressure::PressureController*>(InstrumentManager::getInstance()->getExperimentController("HighPressureCell"));
if (pressure != nullptr && pressure->isEnabled()) {
m_startingEnvironment += "Pressure: ";
m_startingEnvironment += std::to_string(pressure->pressure()) + "Bar";
}
}
}
void RemoteWindeta::saveData(const std::string& data) {
ofstream dataFile(m_dataFilename.c_str());
if (dataFile.is_open()) {
dataFile << m_startingEnvironment << endl;
dataFile << data;
dataFile.close();
}
......
......@@ -80,6 +80,7 @@ public:
Property<int32> dataFilenameFormatSize;
DynamicProperty<std::string> dataFilenameFormatValues;
DynamicProperty<std::string> dataFilenameFormatLabels;
Property<std::string> comment;
Property<int32> presetsChanged;
Property<int32> presetsSize;
......@@ -95,6 +96,7 @@ private:
void initPresets();
void initIndependentDataFileId();
void setDataFilename();
void saveCurrentSampleEnvironment();
void saveData(const std::string& data);
static const std::string WINDETA_APPLICATION;
......@@ -120,6 +122,7 @@ private:
int m_countNumor;
bool m_stopped;
std::string m_dataFilename;
std::string m_startingEnvironment;
};
}
......
......@@ -17,6 +17,8 @@ message Request {
message StartMeasure {
required string preset = 1;
required string filename = 2;
required string comment = 3;
}
message StopServer {
......
......@@ -4,4 +4,5 @@ dielectrics_remote_windeta.remote_application=Remote application
dielectrics_remote_windeta.serverPrefix=Server endpoint
dielectrics_remote_windeta.presetPrefix=Preset
dielectrics_remote_windeta.startTimeoutPrefix=Start timeout
dielectrics_remote_windeta.dataFilenameFormatPrefix=Data Filename
\ No newline at end of file
dielectrics_remote_windeta.dataFilenameFormatPrefix=Data Filename
dielectrics_remote_windeta.commentPrefix=Comment
\ No newline at end of file
<plugin>
<controller type="dielectrics_remote_windeta" role="dielectrics_remote_windeta1"/>
<number_of_lines nb_lines="2"/>
<composite>
<combo role="dielectrics_remote_windeta1" property="preset" prefix="dielectrics_remote_windeta.presetPrefix" key="wantedPresetKey"/>
<property_combo role="dielectrics_remote_windeta1" property="data_filename_format" prefix="dielectrics_remote_windeta.dataFilenameFormatPrefix"/>
<newLine/>
<text role="dielectrics_remote_windeta1" property="comment" prefix="dielectrics_remote_windeta.commentPrefix"/>
</composite>
</plugin>
......@@ -4,6 +4,7 @@
<property name="cameo_server" type="string" max_length="30"/>
<property name="preset" type="string" max_length="30"/>
<property name="comment" type="string" max_length="60"/>
<property name="number_of_points" type="int32"/>
<property name="start_timeout" type="int32"/>
<property name="data_filename_format" type="string"/>
......
......@@ -16,6 +16,8 @@
<combo role="dielectrics_remote_windeta1" property="preset" key="wantedPresetKey"/>
<simple_label prefix="dielectrics_remote_windeta.dataFilenameFormatPrefix"/>
<property_combo role="dielectrics_remote_windeta1" property="data_filename_format"/>
<simple_label prefix="dielectrics_remote_windeta.commentPrefix"/>
<text role="dielectrics_remote_windeta1" property="comment"/>
</table_composite>
</plugin>
......@@ -562,14 +562,14 @@ void VEXPController::periodicUpdate() {
while (m_running.load()) {
std::this_thread::yield();
std::this_thread::sleep_for(std::chrono::seconds(spyPeriod()));
std::lock_guard<std::mutex> lock(m_publisherMutex);
// Send using the publisher.
string spyData = getSpyData();
m_spyPublisher->send(spyData);
std::this_thread::yield();
std::this_thread::sleep_for(std::chrono::seconds(spyPeriod()));
}
}
......
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