Commit 736a7fc6 authored by Cristina Cocho's avatar Cristina Cocho

Modifications done in HPLC and UVDetector controller

parent 4d6877d1
......@@ -41,7 +41,7 @@ uv_usbdetectorcontroller.spectrumTitle=Spectrum
uv_usbdetectorcontroller.spectrumPlotPrefix=Spectrum
uv_usbdetectorcontroller.intensity0PlotTitle=Intensity0
uv_usbdetectorcontroller.intensity0PlotPrefix=Intensity0
uv_usbdetectorcontroller.wavelengthXAxisLegend=Wavelength
uv_usbdetectorcontroller.wavelengthXAxisLegend=Wavelength (nm)
uv_usbdetectorcontroller.chromatoXAxisLegend=Seconds
uv_usbdetectorcontroller.plotYAxisLegend=Intensity
uv_usbdetectorcontroller.plotXAxisLegend=Time (sec)
......
<?xml version="1.0" encoding="UTF-8"?>
<plugin>
<controller type="uv_usbdetectorcontroller" role="uv_usbdetectorcontroller1" />
<number_of_lines nb_lines="2" />
<text role="uv_usbdetectorcontroller1" property="time_of_measure" prefix="uv_usbdetectorcontroller.measureTimePrefix" suffix="uv_usbdetectorcontroller.sec"/>
<text role="uv_usbdetectorcontroller1" property="integration_time" prefix="uv_usbdetectorcontroller.integrationTimePrefix" suffix="uv_usbdetectorcontroller.microsec"/>
<text role="uv_usbdetectorcontroller1" property="scans_average" prefix="uv_usbdetectorcontroller.scansAveragePrefix"/>
<newLine/>
<text role="uv_usbdetectorcontroller1" property="lambda1" prefix="uv_usbdetectorcontroller.lambda1Prefix" suffix="uv_usbdetectorcontroller.nanometer"/>
<text role="uv_usbdetectorcontroller1" property="lambda2" prefix="uv_usbdetectorcontroller.lambda2Prefix" suffix="uv_usbdetectorcontroller.nanometer"/>
<text role="uv_usbdetectorcontroller1" property="lambda3" prefix="uv_usbdetectorcontroller.lambda3Prefix" suffix="uv_usbdetectorcontroller.nanometer"/>
<text role="uv_usbdetectorcontroller1" property="lambda4" prefix="uv_usbdetectorcontroller.lambda4Prefix" suffix="uv_usbdetectorcontroller.nanometer"/>
</plugin>
\ No newline at end of file
<controller_plugin_config type="uv_usbdetectorcontroller">
<image key="UV_SPECTRO"/>
<settings view="uv_usbdetectorcontrollerView.xml"/>
<command view="uv_usbdetectorcontrollerCommandView.xml" />
</controller_plugin_config>
\ No newline at end of file
......@@ -8,7 +8,7 @@
<text role="uv_usbdetectorcontroller1" property="lambda2" prefix="uv_usbdetectorcontroller.lambda2Prefix" suffix="uv_usbdetectorcontroller.nanometer"/>
<text role="uv_usbdetectorcontroller1" property="lambda3" prefix="uv_usbdetectorcontroller.lambda3Prefix" suffix="uv_usbdetectorcontroller.nanometer"/>
<text role="uv_usbdetectorcontroller1" property="lambda4" prefix="uv_usbdetectorcontroller.lambda4Prefix" suffix="uv_usbdetectorcontroller.nanometer"/>
<plot_launcher role="uv_usbdetectorcontroller1" data="spectrum" title="uv_usbdetectorcontroller.spectrumTitle" x_axis_title="uv_usbdetectorcontroller.plotXAxisLegend" y_axis_title="uv_usbdetectorcontroller.plotYAxisLegend" height="20"/>
<plot_launcher role="uv_usbdetectorcontroller1" data="spectrum" title="uv_usbdetectorcontroller.spectrumTitle" x_axis_title="uv_usbdetectorcontroller.wavelengthXAxisLegend" y_axis_title="uv_usbdetectorcontroller.plotYAxisLegend" height="20"/>
<simple_label prefix="uv_usbdetectorcontroller.spectrumPlotPrefix"/>
<newLine/>
<check role="uv_usbdetectorcontroller1" property="result_in_absorbance" prefix="uv_usbdetectorcontroller.inAbsorbanceSuffix" checkBoxValues="uv_usbdetectorcontroller.inAbsorbance" />
......
......@@ -194,8 +194,11 @@ void HplcController::postConfiguration() {
registerUpdater(m_pumpH->pressure, &HplcController::updatePressurePumpH, this);
registerUpdater(m_pumpD->pressure, &HplcController::updatePressurePumpD, this);
registerUpdater(m_pumpH->flowRate, &HplcController::updateFlowRatePumpH, this);
registerUpdater(m_pumpD->flowRate, &HplcController::updateFlowRatePumpD, this);
registerUpdater(m_collector->actualTube, &HplcController::updateActualTubePosition, this);
registerUpdater(m_detector->conditionIsReached, &HplcController::updateConditionIsReached, this);
registerUpdater(m_count->statusMessage, &HplcController::updateDetectorStatus, this);
// Initialize dynamic properties and enumerated labels&values
numberValvePositions = NUMBER_VALVE_POSITIONS;
......@@ -267,6 +270,18 @@ void HplcController::updatePressurePumpD() {
}
}
void HplcController::updateFlowRatePumpH() {
if (columnMeasured() == COLUMN_H) {
m_detector->flowRate = m_pumpH->flowRate.setpoint();
}
}
void HplcController::updateFlowRatePumpD() {
if (columnMeasured() == COLUMN_D) {
m_detector->flowRate = m_pumpD->flowRate.setpoint();
}
}
void HplcController::updateActualTubePosition() {
// Just pass the data to the UVDetector where the value is stored in a vector
m_detector->actualTubePosition = m_collector->actualTube();
......@@ -280,19 +295,36 @@ void HplcController::updateConditionIsReached() {
* NOTE: The start has to be done in PARALLEL because we are executing a command (start on the pump) inside a thread (the start of the UVDetector)
* If the start is not parallel we block the updater and hence everything is blocked!
*/
if (useThreshold() && m_detector->conditionIsReached()) {
if (useThreshold()) {
float64 flowRate;
if (m_detector->conditionIsReached()) {
// Change to DataCollect FlowRate
flowRate = dataCollectFlowRate();
} else {
// Change back to elutionFlowRate
flowRate = elutionFlowRate();
}
if (columnMeasured() == COLUMN_H) {
m_pumpH->flowRate.setpoint = dataCollectFlowRate();
m_pumpH->flowRate.setpoint = flowRate;
m_pumpH->startParallel();
} else if (columnMeasured() == COLUMN_D) {
m_pumpD->flowRate.setpoint = dataCollectFlowRate();
m_pumpD->flowRate.setpoint = flowRate;
m_pumpD->startParallel();
} else {
// ERROR
}
m_detector->flowRate = dataCollectFlowRate(); // IMPORTANT! Detector needs to know actual flowRate in order to have a proper x axis values in ml
std::cout << "Condition reached " << m_detector->conditionIsReached << std::endl;
m_detector->flowRate = flowRate; // IMPORTANT! Detector needs to know actual flowRate in order to have a proper x axis values in ml
}
}
void HplcController::updateDetectorStatus() {
// Detect when count controller has finished a repetition in order to empty the buffer in the UV Detector
if (m_count->statusMessage() == "Close data") {
cleanUVDetectorData();
}
}
......@@ -378,8 +410,7 @@ void HplcController::stop() {
void HplcController::cleanUVDetectorData() {
if (m_count->experimentData->isDataSaved()) {
// TO avoid having large data sets in memory CLEAN the yBlockData once it is saved in the data file
std::cout << "cleaning data " << std::endl;
m_detector->cleanData();
m_detector->cleanBlockData();
}
}
......@@ -468,12 +499,6 @@ void HplcController::configureControllers() {
m_detector->timeOutValue = timeOutValue; //in seconds!
m_detector->resultInAbsorbance = true; //Default value
// TODO
// m_detector->xScaleInMl = true;
// Former detector
// m_detector->init(); // do init here because it involves dummy reads that take time
// Set up Count
m_count->time.setpoint = exposureTime();
m_count->timeType = "s";
......@@ -540,6 +565,7 @@ void HplcController::doDataAcquisition() {
// Wait for the termination of the threads
group.join_all();
}
void HplcController::startCount() {
......
......@@ -128,8 +128,11 @@ private:
virtual void updatePressurePumpH();
virtual void updatePressurePumpD();
virtual void updateFlowRatePumpH();
virtual void updateFlowRatePumpD();
virtual void updateActualTubePosition();
virtual void updateConditionIsReached();
virtual void updateDetectorStatus();
static const int32 VALVE_LOAD_POS;
static const int32 VALVE_INJECT_POS;
......
......@@ -87,6 +87,7 @@ UVUsbDetectorController::UVUsbDetectorController(const std::string& controllerNa
// Initialize class members
m_hasBeenStopped = false;
m_conditionReached = false;
intensity0 = nullptr;
measuredYData = nullptr;
chromato1 = nullptr;
......@@ -105,6 +106,9 @@ UVUsbDetectorController::UVUsbDetectorController(const std::string& controllerNa
actualLambdaValue = 0;
actualVolume = 0;
previousVolume = 0;
// Create mutex dynamically
m_mutex = new std::mutex();
}
UVUsbDetectorController::~UVUsbDetectorController() {
......@@ -120,6 +124,8 @@ UVUsbDetectorController::~UVUsbDetectorController() {
delete[] xDataPtr;
delete[] slopeData;
delete m_mutex;
}
void UVUsbDetectorController::postConfiguration() {
......@@ -220,6 +226,8 @@ void UVUsbDetectorController::calculateI0() {
void UVUsbDetectorController::doAcqWithDataSaving() {
m_hasBeenStopped = false;
m_conditionReached = false;
commandProgression = 0;
// Retrieve size of data from detector (the cleanData method sets it up to zero)
size = m_detectorDriver->size();
......@@ -232,13 +240,13 @@ void UVUsbDetectorController::doAcqWithDataSaving() {
common::Date m_actualTime = common::Date();
m_totalDuration = m_actualTime - m_startTime;
while ((m_totalDuration.getSeconds() < timeOfMeasure()) && (!m_hasBeenStopped)) {
common::Duration iterationTime;
while ((m_totalDuration.getSeconds() < timeOfMeasure()) && (!m_hasBeenStopped)) {
common::Date startTime = common::Date();
getData();
common::Date endTime = common::Date();
getData();
processData();
......@@ -257,12 +265,15 @@ void UVUsbDetectorController::doAcqWithDataSaving() {
// Update local variables to keep track of the time and volume
m_actualTime = common::Date();
m_totalDuration = (m_actualTime - m_startTime);
actualVolume = (flowRate() / 60.0) * m_totalDuration.getSeconds();
float64 delta = (flowRate() / 60.0) * iterationTime.getSeconds();
actualVolume = actualVolume + delta;
common::Date endTime = common::Date();
iterationTime = endTime - startTime;
common::Duration duration = endTime - startTime;
sleep(1);
::sleep(1);
}
stop();
}
......@@ -296,16 +307,18 @@ void UVUsbDetectorController::getData() {
tempYData = nullptr;
}
void UVUsbDetectorController::cleanData() {
void UVUsbDetectorController::cleanBlockData() {
// Lock also the access
std::lock_guard<std::mutex> lock(*m_mutex);
// Clean vector that holds the data
vectorForYData.clear();
// Set size properties to zero
blockSize = 1;
size = 1;
// Clean property content associated to this vector
yDataBlock.setSize(1);
}
void UVUsbDetectorController::processData() {
......@@ -333,7 +346,11 @@ void UVUsbDetectorController::processData() {
int32 lastPosition = yDataSize - 1;
xDataPtr = m_detectorDriver->xData();
float64 slope = fabs((yDataSize - 1)/(xDataPtr[lastPosition] - xDataPtr[firstPosition]));
float64 slope = 0;;
if (xDataPtr[lastPosition] - xDataPtr[firstPosition] != 0) {
slope = fabs((yDataSize - 1)/(xDataPtr[lastPosition] - xDataPtr[firstPosition]));
}
int32 indexLambda1 = (lambda1() - xDataPtr[firstPosition]) * slope;
int32 indexLambda2 = (lambda2() - xDataPtr[firstPosition]) * slope;
int32 indexLambda3 = (lambda3() - xDataPtr[firstPosition]) * slope;
......@@ -456,16 +473,8 @@ void UVUsbDetectorController::processData() {
xDataInFractions.update(xDataToSaveInFractions);
xDataInFractions.setSize(chromatoSize);
// (5) Store spectrum data which will be used in data file
int32 vectorSize = vectorForYData.size();
float64* tempYBlockData = new float64[vectorSize];
memset(tempYBlockData, 0, vectorSize * sizeof(float64));
std::copy(vectorForYData.begin(), vectorForYData.end(), tempYBlockData);
yDataBlock.update(tempYBlockData);
yDataBlock.setSize(vectorSize);
blockSize = vectorSize / size();
// Mutex block
storeDataBlock();
//Free memory here
delete[] absorptionData;
......@@ -486,8 +495,6 @@ void UVUsbDetectorController::processData() {
delete[] slopeData;
slopeData = NULL;
// End of NEW stuff
}
void UVUsbDetectorController::resetData() {
......@@ -514,7 +521,7 @@ void UVUsbDetectorController::resetLocalValues() {
}
void UVUsbDetectorController::checkCondition() {
bool m_conditionReached = false;
//The condition can vary: it can be a time, a threshold (in absorbance) or a slope. If no condition just wait until stop or time out value.
if (useThreshold()) {
if ((m_totalDuration.getSeconds() > 8) && ((m_totalDuration.getSeconds()) < timeOutValue())) {
......@@ -581,6 +588,22 @@ void UVUsbDetectorController::getActualLambdaValueForSlope() {
}
}
void UVUsbDetectorController::storeDataBlock() {
std::lock_guard<std::mutex> lock(*m_mutex);
// Store spectrum data which will be used in data file
int32 vectorSize = vectorForYData.size();
float64* tempYBlockData = new float64[vectorSize];
memset(tempYBlockData, 0, vectorSize * sizeof(float64));
std::copy(vectorForYData.begin(), vectorForYData.end(), tempYBlockData);
yDataBlock.update(tempYBlockData);
yDataBlock.setSize(vectorSize);
blockSize = vectorSize / size();
}
}
......
......@@ -22,6 +22,7 @@
#include <Controller.h>
#include "UVDetectorCommon.h"
#include "UVDetectorController.h"
#include <mutex>
namespace d22 {
......@@ -55,7 +56,7 @@ public:
virtual void init();
virtual void calculateI0();
virtual void doAcqWithDataSaving();
virtual void cleanData();
virtual void cleanBlockData();
void refreshInAbsorbance(bool inAbsorbance);
void updateStatus();
......@@ -119,6 +120,8 @@ public:
private:
bool m_hasBeenStopped;
bool m_conditionReached;
float64* intensity0;
float64* measuredYData;
......@@ -155,6 +158,8 @@ private:
void getActualLambdaValueForSlope();
virtual void makeAutozero();
void storeDataBlock();
static const int32 ABSORBANCE_THRESHOLD_MODE;
static const int32 SLOPE_THRESHOLD_MODE;
static const int32 TIME_THRESHOLD_MODE;
......@@ -165,9 +170,11 @@ private:
float64 previousVolume;
float64* absorptionData;
float64* xDataPtr;
std::mutex* m_mutex;
};
......
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