mirror of
https://github.com/slsdetectorgroup/slsDetectorPackage.git
synced 2025-06-23 10:07:59 +02:00
Guidetector (#54)
* WIP * dacWidget * main WIP * advanced WIP * WIP * WIP * WIP * WIP * WIP * WIP * works * updated gui to chrono * review fixes * unitque ptrs in gui
This commit is contained in:
@ -2,7 +2,7 @@
|
||||
|
||||
#include "ui_form_dac.h"
|
||||
|
||||
class multiSlsDetector;
|
||||
#include "Detector.h"
|
||||
#include "sls_detector_defs.h"
|
||||
|
||||
#include <string>
|
||||
@ -11,7 +11,7 @@ class qDacWidget:public QWidget, private Ui::WidgetDacObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
qDacWidget(QWidget *parent, multiSlsDetector* detector, bool d, std::string n, slsDetectorDefs::dacIndex i, bool t);
|
||||
qDacWidget(QWidget *parent, sls::Detector* detector, bool d, std::string n, slsDetectorDefs::dacIndex i, bool t);
|
||||
~qDacWidget();
|
||||
void SetDetectorIndex(int id);
|
||||
|
||||
@ -25,7 +25,7 @@ private:
|
||||
void GetAdc();
|
||||
void Refresh();
|
||||
|
||||
multiSlsDetector *myDet;
|
||||
sls::Detector *det;
|
||||
bool isDac{true};
|
||||
slsDetectorDefs::dacIndex index;
|
||||
bool isMillideg{false};
|
||||
|
@ -1,6 +1,5 @@
|
||||
#pragma once
|
||||
|
||||
#include "multiSlsDetector.h"
|
||||
#include "sls_detector_defs.h"
|
||||
|
||||
#include <QAbstractButton>
|
||||
@ -10,6 +9,15 @@
|
||||
#include <ostream>
|
||||
#include <stdint.h>
|
||||
#include <string>
|
||||
#include <chrono>
|
||||
using std::chrono::duration;
|
||||
using std::chrono::duration_cast;
|
||||
using std::chrono::nanoseconds;
|
||||
using std::chrono::microseconds;
|
||||
using std::chrono::milliseconds;
|
||||
using std::chrono::seconds;
|
||||
using std::chrono::minutes;
|
||||
using std::chrono::hours;
|
||||
|
||||
#define CATCH_DISPLAY(m, s) catch(...) { qDefs::DisplayExceptions(m, s); }
|
||||
#define CATCH_HANDLE(...) catch(...) { qDefs::HandleExceptions(__VA_ARGS__); }
|
||||
@ -145,98 +153,81 @@ class qDefs : public QWidget {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* returns the value in ns to send to server as the
|
||||
* server class slsdetector accepts in ns.
|
||||
* @param unit unit of time
|
||||
* @param value time
|
||||
* returns time value in ns
|
||||
*/
|
||||
static double getNSTime(timeUnit unit, double value) {
|
||||
double valueNS = value;
|
||||
switch (unit) {
|
||||
/** returns the time in a user friendly time unit */
|
||||
static std::pair<double, timeUnit> getUserFriendlyTime(nanoseconds tns) {
|
||||
if (tns < microseconds(1)) {
|
||||
return std::make_pair(tns.count(), NANOSECONDS);
|
||||
}
|
||||
if (tns < milliseconds(1)) {
|
||||
return std::make_pair(
|
||||
duration_cast<duration<double, std::micro>>(tns).count(),
|
||||
MICROSECONDS);
|
||||
}
|
||||
if (tns < seconds(1)) {
|
||||
return std::make_pair(
|
||||
duration_cast<duration<double, std::milli>>(tns).count(),
|
||||
MILLISECONDS);
|
||||
}
|
||||
if (tns < minutes(1)) {
|
||||
return std::make_pair(duration_cast<duration<double>>(tns).count(),
|
||||
SECONDS);
|
||||
}
|
||||
if (tns < hours(1)) {
|
||||
return std::make_pair(
|
||||
duration_cast<duration<double, std::ratio<60>>>(tns).count(),
|
||||
MINUTES);
|
||||
}
|
||||
return std::make_pair(
|
||||
duration_cast<duration<double, std::ratio<3600>>>(tns).count(), HOURS);
|
||||
}
|
||||
|
||||
/** returns the value in ns */
|
||||
static nanoseconds getNSTime(std::pair<double, timeUnit> time) {
|
||||
switch (time.second) {
|
||||
case HOURS:
|
||||
valueNS *= 60;
|
||||
return std::chrono::duration_cast<std::chrono::nanoseconds>(
|
||||
std::chrono::duration<double, std::ratio<3600>>(time.first));
|
||||
case MINUTES:
|
||||
valueNS *= 60;
|
||||
return std::chrono::duration_cast<std::chrono::nanoseconds>(
|
||||
std::chrono::duration<double, std::ratio<60>>(time.first));
|
||||
case SECONDS:
|
||||
valueNS *= 1000;
|
||||
return std::chrono::duration_cast<std::chrono::nanoseconds>(
|
||||
std::chrono::duration<double>(time.first));
|
||||
case MILLISECONDS:
|
||||
valueNS *= 1000;
|
||||
return std::chrono::duration_cast<std::chrono::nanoseconds>(
|
||||
std::chrono::duration<double, std::milli>(time.first));
|
||||
case MICROSECONDS:
|
||||
valueNS *= 1000;
|
||||
case NANOSECONDS:
|
||||
return std::chrono::duration_cast<std::chrono::nanoseconds>(
|
||||
std::chrono::duration<double, std::micro>(time.first));
|
||||
default:
|
||||
break;
|
||||
return std::chrono::duration_cast<std::chrono::nanoseconds>(
|
||||
std::chrono::duration<double, std::nano>(time.first));
|
||||
}
|
||||
return valueNS;
|
||||
};
|
||||
|
||||
/**
|
||||
* returns the value in ms
|
||||
* @param unit unit of time
|
||||
* @param value time
|
||||
* returns time value in ms
|
||||
*/
|
||||
static double getMSTime(timeUnit unit, double value) {
|
||||
double valueMS = value;
|
||||
switch (unit) {
|
||||
case NANOSECONDS:
|
||||
valueMS /= 1000;
|
||||
case MICROSECONDS:
|
||||
valueMS /= 1000;
|
||||
return valueMS;
|
||||
}
|
||||
|
||||
/** returns the value in ms */
|
||||
static milliseconds getMSTime(std::pair<double, timeUnit> time) {
|
||||
switch (time.second) {
|
||||
case HOURS:
|
||||
valueMS *= 60;
|
||||
return std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
std::chrono::duration<double, std::ratio<3600>>(time.first));
|
||||
case MINUTES:
|
||||
valueMS *= 60;
|
||||
return std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
std::chrono::duration<double, std::ratio<60>>(time.first));
|
||||
case SECONDS:
|
||||
valueMS *= 1000;
|
||||
return std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
std::chrono::duration<double>(time.first));
|
||||
case MILLISECONDS:
|
||||
return std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
std::chrono::duration<double, std::milli>(time.first));
|
||||
case MICROSECONDS:
|
||||
return std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
std::chrono::duration<double, std::micro>(time.first));
|
||||
default:
|
||||
break;
|
||||
return std::chrono::duration_cast<std::chrono::milliseconds>(
|
||||
std::chrono::duration<double, std::nano>(time.first));
|
||||
}
|
||||
return valueMS;
|
||||
};
|
||||
|
||||
/**
|
||||
* returns the time in the appropriate time unit
|
||||
* @param value time in seconds
|
||||
* returns the time in an appropriate time and unit
|
||||
*/
|
||||
static std::pair<double, timeUnit> getCorrectTime(double value) {
|
||||
timeUnit unit;
|
||||
int intUnit = (int)SECONDS;
|
||||
|
||||
/**0 ms*/
|
||||
if (!value) {
|
||||
unit = MILLISECONDS;
|
||||
return std::make_pair(value, unit);
|
||||
}
|
||||
|
||||
/** hr, min, sec */
|
||||
if (value >= 1) {
|
||||
double newVal = value;
|
||||
while ((newVal >= 1) && (intUnit >= (int)HOURS)) {
|
||||
/** value retains the old value */
|
||||
value = newVal;
|
||||
newVal = value / (double)60;
|
||||
intUnit--;
|
||||
}
|
||||
/** returning the previous value*/
|
||||
unit = (timeUnit)(intUnit + 1);
|
||||
return std::make_pair(value, unit);
|
||||
}
|
||||
/** ms, us, ns */
|
||||
else {
|
||||
while ((value < 1) && (intUnit < (int)NANOSECONDS)) {
|
||||
value = value * (double)1000;
|
||||
intUnit++;
|
||||
}
|
||||
unit = (timeUnit)(intUnit);
|
||||
return std::make_pair(value, unit);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
/**
|
||||
* displays an warning,error,info message
|
||||
|
@ -13,7 +13,7 @@ class qTabDebugging;
|
||||
class qTabDeveloper;
|
||||
class qTabMessages;
|
||||
|
||||
class multiSlsDetector;
|
||||
#include "Detector.h"
|
||||
|
||||
#include <QTabWidget>
|
||||
class QResizeEvent;
|
||||
@ -70,17 +70,17 @@ class qDetectorMain : public QMainWindow, private Ui::DetectorMainObject {
|
||||
NumberOfTabs
|
||||
};
|
||||
slsDetectorDefs::detectorType detType;
|
||||
multiSlsDetector* myDet;
|
||||
qDrawPlot* myPlot;
|
||||
MyTabWidget* tabs;
|
||||
qTabMeasurement* tabMeasurement;
|
||||
qTabDataOutput* tabDataOutput;
|
||||
qTabPlot* tabPlot;
|
||||
qTabSettings* tabSettings;
|
||||
qTabAdvanced* tabAdvanced;
|
||||
qTabDebugging* tabDebugging;
|
||||
qTabDeveloper* tabDeveloper;
|
||||
qTabMessages* tabMessages;
|
||||
std::unique_ptr<sls::Detector> det;
|
||||
std::unique_ptr<qDrawPlot> plot;
|
||||
std::unique_ptr<MyTabWidget> tabs;
|
||||
std::unique_ptr<qTabMeasurement> tabMeasurement;
|
||||
std::unique_ptr<qTabDataOutput> tabDataOutput;
|
||||
std::unique_ptr<qTabPlot> tabPlot;
|
||||
std::unique_ptr<qTabSettings> tabSettings;
|
||||
std::unique_ptr<qTabAdvanced> tabAdvanced;
|
||||
std::unique_ptr<qTabDebugging> tabDebugging;
|
||||
std::unique_ptr<qTabDeveloper> tabDeveloper;
|
||||
std::unique_ptr<qTabMessages> tabMessages;
|
||||
int isDeveloper;
|
||||
int heightPlotWindow;
|
||||
int heightCentralWidget;
|
||||
|
@ -3,20 +3,24 @@
|
||||
#include "ui_form_plot.h"
|
||||
|
||||
#include "qDefs.h"
|
||||
class detectorData;
|
||||
class SlsQt1DPlot;
|
||||
class SlsQtH1D;
|
||||
class SlsQt2DPlot;
|
||||
class qCloneWidget;
|
||||
class QResizeEvent;
|
||||
|
||||
class detectorData;
|
||||
#include "Detector.h"
|
||||
|
||||
class QResizeEvent;
|
||||
#include <QFutureWatcher>
|
||||
|
||||
#include <mutex>
|
||||
|
||||
class qDrawPlot : public QWidget, private Ui::PlotObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
qDrawPlot(QWidget *parent, multiSlsDetector *detector);
|
||||
qDrawPlot(QWidget *parent, sls::Detector *detector);
|
||||
~qDrawPlot();
|
||||
bool GetIsRunning();
|
||||
void SetRunning(bool enable);
|
||||
@ -88,7 +92,7 @@ class qDrawPlot : public QWidget, private Ui::PlotObject {
|
||||
void Update2dXYRange();
|
||||
|
||||
static const int NUM_PEDESTAL_FRAMES = 20;
|
||||
multiSlsDetector *myDet;
|
||||
sls::Detector *det;
|
||||
slsDetectorDefs::detectorType detType;
|
||||
|
||||
SlsQt1DPlot *plot1d{nullptr};
|
||||
|
@ -2,20 +2,20 @@
|
||||
|
||||
#include "ui_form_tab_advanced.h"
|
||||
|
||||
class multiSlsDetector;
|
||||
#include "Detector.h"
|
||||
|
||||
class qTabAdvanced:public QWidget, private Ui::TabAdvancedObject{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
qTabAdvanced(QWidget *parent, multiSlsDetector* detector);
|
||||
qTabAdvanced(QWidget *parent, sls::Detector* detector);
|
||||
~qTabAdvanced();
|
||||
|
||||
public slots:
|
||||
void Refresh();
|
||||
|
||||
private slots:
|
||||
void SetDetector(int index);
|
||||
void SetDetector();
|
||||
void SetControlPort(int port);
|
||||
void SetStopPort(int port);
|
||||
void SetDetectorUDPIP();
|
||||
@ -60,7 +60,7 @@ private:
|
||||
void GetSubExposureTime();
|
||||
void GetSubDeadTime();
|
||||
|
||||
multiSlsDetector *myDet;
|
||||
sls::Detector *det;
|
||||
};
|
||||
|
||||
|
||||
|
@ -2,13 +2,13 @@
|
||||
|
||||
#include "ui_form_tab_dataoutput.h"
|
||||
|
||||
class multiSlsDetector;
|
||||
#include "Detector.h"
|
||||
|
||||
class qTabDataOutput:public QWidget, private Ui::TabDataOutputObject{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
qTabDataOutput(QWidget *parent, multiSlsDetector* detector);
|
||||
qTabDataOutput(QWidget *parent, sls::Detector* detector);
|
||||
~qTabDataOutput();
|
||||
void Refresh();
|
||||
|
||||
@ -38,7 +38,7 @@ public:
|
||||
void GetSpeed();
|
||||
void GetFlags();
|
||||
|
||||
multiSlsDetector *myDet;
|
||||
sls::Detector *det;
|
||||
// Button group for radiobuttons for rate
|
||||
QButtonGroup *btnGroupRate;
|
||||
// enum for the Eiger clock divider
|
||||
@ -48,12 +48,7 @@ public:
|
||||
QUARTERSPEED,
|
||||
NUMBEROFSPEEDS
|
||||
};
|
||||
// enum for the Eiger readout flags1
|
||||
enum {
|
||||
CONTINUOUS,
|
||||
STOREINRAM
|
||||
};
|
||||
// enum for the Eiger readout flags2
|
||||
// enum for the Eiger Parallel flag
|
||||
enum {
|
||||
PARALLEL,
|
||||
NONPARALLEL
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include "ui_form_tab_debugging.h"
|
||||
|
||||
class multiSlsDetector;
|
||||
#include "Detector.h"
|
||||
|
||||
class QTreeWidget;
|
||||
class QTreeWidgetItem;
|
||||
@ -11,7 +11,7 @@ class qTabDebugging:public QWidget, private Ui::TabDebuggingObject{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
qTabDebugging(QWidget *parent, multiSlsDetector* detector);
|
||||
qTabDebugging(QWidget *parent, sls::Detector* detector);
|
||||
~qTabDebugging();
|
||||
void Refresh();
|
||||
|
||||
@ -26,7 +26,7 @@ private:
|
||||
void Initialization();
|
||||
void PopulateDetectors();
|
||||
|
||||
multiSlsDetector *myDet;
|
||||
sls::Detector *det;
|
||||
/** Tree Widget displaying the detectors, modules */
|
||||
QTreeWidget *treeDet;
|
||||
QLabel *lblDetectorHostname;
|
||||
|
@ -3,7 +3,7 @@
|
||||
#include "ui_form_tab_developer.h"
|
||||
class qDacWidget;
|
||||
|
||||
class multiSlsDetector;
|
||||
#include "Detector.h"
|
||||
#include "sls_detector_defs.h"
|
||||
|
||||
#include <string>
|
||||
@ -13,7 +13,7 @@ class qTabDeveloper:public QWidget, private Ui::TabDeveloperObject {
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
qTabDeveloper(QWidget *parent, multiSlsDetector* detector);
|
||||
qTabDeveloper(QWidget *parent, sls::Detector* detector);
|
||||
~qTabDeveloper();
|
||||
|
||||
public slots:
|
||||
@ -29,7 +29,7 @@ private:
|
||||
void GetHighVoltage();
|
||||
slsDetectorDefs::dacIndex getSLSIndex(slsDetectorDefs::detectorType detType, int index);
|
||||
|
||||
multiSlsDetector *myDet;
|
||||
sls::Detector *det;
|
||||
std::vector<qDacWidget*> dacWidgets;
|
||||
std::vector<qDacWidget*> adcWidgets;
|
||||
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
class qDrawPlot;
|
||||
|
||||
class multiSlsDetector;
|
||||
#include "Detector.h"
|
||||
|
||||
class QStandardItemModel;
|
||||
|
||||
@ -12,7 +12,7 @@ class qTabMeasurement:public QWidget, private Ui::TabMeasurementObject{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
qTabMeasurement(QWidget *parent, multiSlsDetector* detector, qDrawPlot* plot);
|
||||
qTabMeasurement(QWidget *parent, sls::Detector* detector, qDrawPlot* p);
|
||||
~qTabMeasurement();
|
||||
|
||||
void Refresh();
|
||||
@ -66,8 +66,8 @@ signals:
|
||||
void EnableTabsSignal(bool);
|
||||
void FileNameChangedSignal(QString);
|
||||
private:
|
||||
multiSlsDetector *myDet;
|
||||
qDrawPlot *myPlot;
|
||||
sls::Detector *det;
|
||||
qDrawPlot *plot;
|
||||
// enum for the timing mode
|
||||
enum{
|
||||
AUTO,
|
||||
|
@ -4,7 +4,7 @@
|
||||
|
||||
class qDrawPlot;
|
||||
|
||||
class multiSlsDetector;
|
||||
#include "Detector.h"
|
||||
|
||||
class QButtonGroup;
|
||||
|
||||
@ -12,7 +12,7 @@ class qTabPlot:public QWidget, private Ui::TabPlotObject{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
qTabPlot(QWidget *parent,multiSlsDetector* detector, qDrawPlot* plot);
|
||||
qTabPlot(QWidget *parent, sls::Detector* detector, qDrawPlot* p);
|
||||
~qTabPlot();
|
||||
void SetScanArgument();
|
||||
void Refresh();
|
||||
@ -45,8 +45,8 @@ private:
|
||||
void SetXYRange();
|
||||
void MaintainAspectRatio(int dimension);
|
||||
|
||||
multiSlsDetector *myDet;
|
||||
qDrawPlot *myPlot;
|
||||
sls::Detector *det;
|
||||
qDrawPlot *plot;
|
||||
bool is1d;
|
||||
|
||||
QButtonGroup *btnGroupPlotType{nullptr};
|
||||
|
@ -2,13 +2,13 @@
|
||||
|
||||
#include "ui_form_tab_settings.h"
|
||||
|
||||
class multiSlsDetector;
|
||||
#include "Detector.h"
|
||||
|
||||
class qTabSettings: public QWidget, private Ui::TabSettingsObject{
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
qTabSettings(QWidget *parent, multiSlsDetector* detector);
|
||||
qTabSettings(QWidget *parent, sls::Detector* detector);
|
||||
~qTabSettings();
|
||||
void Refresh();
|
||||
|
||||
@ -26,7 +26,7 @@ private:
|
||||
void GetDynamicRange();
|
||||
void GetThresholdEnergy();
|
||||
|
||||
multiSlsDetector *myDet;
|
||||
sls::Detector *det;
|
||||
enum {
|
||||
STANDARD,
|
||||
FAST,
|
||||
|
Reference in New Issue
Block a user