SEPIA
Software documentation for the APEX SEPIA receivers
sepia.h
Go to the documentation of this file.
1 /* Copyright 2017 Michael Olberg <michael.olberg@chalmers.se> */
2 #ifndef SEPIA_H
3 #define SEPIA_H
4 
5 #include <QMainWindow>
6 #include <QAction>
7 #include <QActionGroup>
8 #include <QGroupBox>
9 #include <QTabWidget>
10 #include <QUdpSocket>
11 #include <QThreadPool>
12 #include <QMetaType>
13 #include <QLineEdit>
14 #include <QThread>
15 #include <QTableView>
16 #include <QPlainTextEdit>
17 #include <QStandardItemModel>
18 #include <QSortFilterProxyModel>
19 #include <QString>
20 #include <QStringList>
21 #include <QProgressBar>
22 #include <QLabel>
23 #include <QList>
24 #include <QVariant>
25 #include <QVector>
26 #include <QStateMachine>
27 
28 #include "sepia180.h"
29 #include "sepia345.h"
30 #include "sepia660.h"
31 
32 #include "device.h"
33 #include "property.h"
34 
35 #include "GUI/localoscillator.h"
36 #include "GUI/dualsidebandmixer.h"
37 #include "GUI/phaselockloop.h"
38 #include "GUI/environment.h"
39 #include "GUI/calunit.h"
40 #include "GUI/atmosphereplot.h"
41 
42 #include "SCPI/scpirequest.h"
43 
45 #include "GPIO/acromag.h"
47 #include "Synthesizer/agilent.h"
48 
49 #include "constants.h"
50 #include "logger_interface.h"
51 
60 class SEPIA : public QMainWindow, public Device {
61  Q_OBJECT
62  Q_PROPERTY(Device::State state READ status WRITE setStatus NOTIFY statusChanged)
63 
64  public:
65  explicit SEPIA(QMainWindow *parent = 0);
66  ~SEPIA();
67 
73 
74  QVariant &property(int which, bool cmd, int sub = 0);
75  bool inRange(double LOfreq);
76  bool isTuned() const;
77  bool tuningModified() const;
78 
79  double dewarPressure() const { return dewar_p; }
80  double dewarTemperature() const { return dewar_T; }
81 
82  int bandInUse() const;
83  CalUnit::MirrorPosition mirrorPosition(bool cmd) const;
84 
85  public slots:
86 
91  void setStatus(Device::State state);
92 
103  void updateProperty(int key, const QVariant &value, int sub = 0);
104 
113  void updateMonitorItem(const QString &name, DWORD addr, float value, char unit, int gain);
114 
119  void showProgress(int percent);
120 
126  void showStatus(const QString &msg, int timeout = 5000);
127 
128  void logScript(const QString &msg);
129  void scanMixer(Mixer::Polarization pol, Mixer::Element sis,
130  double from, double to, int steps);
131 
132  private slots:
133  void machineStarted();
134  void machineStopped();
135  void machineFinished();
142  void enterFreqDialog();
143 
149  void enterScanDialog();
150 
151  void enterDefluxDialog();
152  void demagnetize(Mixer::Polarization pol, Mixer::Element sis);
153  void demagnetized(Mixer::Polarization pol, Mixer::Element sis, bool ok);
154  void deflux(Mixer::Polarization pol);
155  void defluxed(Mixer::Polarization pol, bool ok);
156 
157  void enableExpert(bool flag);
158 
164  void setFrequency(double f, LocalOscillator::Sideband sb);
165  void tableDialog(QAction *action);
166 
167  void execMethod(ScpiRequest::Method method, QList<QVariant> params);
168  /* void clearModel(); */
169 
170  void dataReceived();
171  void sendUdpMessage(Sepia::Channel band, const QString &msg, const QHostAddress host, const quint16 port);
172  void cryostatUpdate(double Ta, double Tb, double Tc, double Td, double p, bool ups);
173  void cryoLoop(double T);
174 
175  void quit();
176  void runScript();
177  void cartridgeDlg();
178  void ifSwitchDlg();
179  void beSwitchDlg();
180  void agilentDlg();
181  void help();
182  void about();
183 
184  void initChannel();
185  void resetChannel();
186  void shutdownChannel();
187  void faultTriggered(Sepia::ErrorCode code);
188  void selectBand(QAction *action);
189  void unselectBand();
190  void startScanning(bool flag = true);
191 
192  void addChannel(Sepia::Channel channel);
193  void removeChannel(Sepia::Channel channel);
194 
195  void selectMirrorPosition(QAction *action);
196  void resetMirror();
197  void moveTo(int n);
198 
199  void enableGUIelements(bool enable);
200  void enableExpertMode(bool expert);
201 
202  void clearCurve(Mixer::Polarization pol, Mixer::Element sis);
203  void showCurve(Mixer::Polarization pol, Mixer::Element sis,
204  QVector<double> x, QVector<double> y, QVector<double> z,
205  const QString &xlab, const QString &ylab);
206  void tunedSystem(bool ok);
207  void tuneLO();
208  void tuneMixers();
209  void tunedLO(bool ok);
210  void tunedMixer(Mixer::Polarization pol, bool ok);
211  void newMixerBias(Mixer::Polarization pol, Mixer::Element sis, float mV);
212  void newCmdMixerBias(Mixer::Polarization pol, Mixer::Element sis, float mV);
213  void newMixerCurrent(Mixer::Polarization pol, Mixer::Element sis, float mV);
214  void newMixerPower(Mixer::Polarization pol, Mixer::Element sis, float mW);
215 
216  void newCoilCurrent(Mixer::Polarization pol, Mixer::Element sis, float mA);
217  void newCmdCoilCurrent(Mixer::Polarization pol, Mixer::Element sis, float mA);
218 
219  void newDrainVoltage(Mixer::Polarization pol, Mixer::Element sis, LNA::Stage lna, float mV);
220  void newDrainCurrent(Mixer::Polarization pol, Mixer::Element sis, LNA::Stage lna, float mA);
221  void newCmdDrainVoltage(Mixer::Polarization pol, Mixer::Element sis, LNA::Stage lna, float mV);
222  void newCmdDrainCurrent(Mixer::Polarization pol, Mixer::Element sis, LNA::Stage lna, float mA);
223  void newGateVoltage(Mixer::Polarization pol, Mixer::Element sis, LNA::Stage lna, float mV);
224 
225  void filterMonitor(const QString &expr);
226  void cartridgeStateChanged(Cartridge::InternalState s);
227 
228  signals:
229  void statusChanged(Device::State state);
230  void channelInitialize(bool withDeflux);
231  void tuningRequest(double Hz);
232  void triggerScript();
233  void performScan(Mixer::Polarization pol, Mixer::Element sis, double from, double to, int steps, bool withPower=false);
234  void demagnetizeMixer(Mixer::Polarization pol, Mixer::Element sis);
235  void defluxMixerPair(Mixer::Polarization pol);
236  void demagnetizeMixers(bool p0s1, bool p0s2, bool p1s1, bool p1s2);
237  void defluxMixerPairs(bool p0, bool p1);
238  void setCoilCurrents();
239  void channelAdded(Sepia::Channel channel);
240  void channelRemoved(Sepia::Channel channel);
241  void cryoUpdate(float, float, float, float, float);
242  void initBand();
243  void resetBand();
244  void shutdownBand();
245  void enableBand();
246  void disableBand();
247  void unselect();
248 
249  void initialize();
250  void reset();
251  void enable();
252  void disable();
253  void fault();
254  void shutdown();
255 
256  private:
257  org::apex::Sepia::LoggerInterface *logger;
258 
259  Sepia::Channel inUse;
260 
261  double dewar_T;
262  double dewar_p;
263 
264  uint m_backend;
265  uint m_IF;
266 
267  int m_steps;
268  double m_range[2];
269 
270  void registerTypes();
271  void createFileMenu();
272  void createBandMenu();
273  void createTuneMenu();
274  void createToolsMenu();
275  void createMirrorMenu();
276  void createHelpMenu();
277 
278  void setupStatusTab();
279  void setupMonitorTab();
280  void setupScpiTab();
281  void setupAtmosphereTab();
282 
283  void connectToHardware();
284 
285  void setupModel();
286  QStringList mcChannels;
287 
288  QList<QUdpSocket *> scpiSockets;
289  QUdpSocket b5Socket;
290  // QUdpSocket b7Socket;
291  QUdpSocket b9Socket;
292 
293  QActionGroup *bandSelection;
294  QActionGroup *mirrorSelection;
295  QActionGroup *tblSelection;
296 
297  QThreadPool *pool;
298 
299  Environment *env;
300  CalUnit *calunit;
301  QGroupBox *LObox;
302  LocalOscillator *LO;
303  PhaseLockLoop *PLL;
304  DualSidebandMixer *pol0;
305  DualSidebandMixer *pol1;
306 
307  QThread hardware;
308  Cartridge *cartridge;
309 
310  Sepia::ErrorCode lastError;
311 
312  SelectMirror *sm;
313  Acromag *gpio;
314  IFSwitch *ifSwitch;
315  BackendSwitch *backendSwitch;
316  Generator *agilent;
317 
318  QMenuBar *menubar;
319  QMenu *menuFile;
320  QMenu *menuBand;
321  QMenu *menuTune;
322  QMenu *menuTools;
323  QMenu *menuMirror;
324  QMenu *menuHelp;
325 
326  QAction *actionQuit;
327 
328  QAction *actionBand5;
329  QAction *actionBand7;
330  QAction *actionBand9;
331  QAction *actionNone;
332  QAction *actionInitialize;
333  QAction *actionReset;
334  QAction *actionShutdown;
335 
336  QAction *actionSetFrequency;
337  QAction *actionTuneLO;
338  QAction *actionTuneMixer;
339  QAction *actionTuningTable;
340  QAction *tableBand5;
341  QAction *tableBand7;
342  QAction *tableBand9;
343 
344  QAction *actionScan;
345  QAction *actionDeflux;
346  QAction *actionCartridge;
347  QAction *actionIFswitch;
348  QAction *actionBEswitch;
349  QAction *actionAgilent;
350  QAction *actionScript;
351  QAction *actionExpert;
352 
353  QAction *homeSelection;
354  QAction *band5Selection;
355  QAction *band7Selection;
356  QAction *band9Selection;
357  QAction *resetSelection;
358 
359  QAction *actionHelp;
360  QAction *actionAbout;
361 
362  QWidget *statusTab;
363  QWidget *monitorTab;
364  QWidget *scpiTab;
365  QWidget *atmosphereTab;
366 
367  QTabWidget *tabWidget;
368  QTableView *mcTableView;
369  QLineEdit *mcTableFilter;
370  QSortFilterProxyModel *proxyModel;
371  QStandardItemModel *mcModel;
372 
373  QPlainTextEdit *scpiLog;
374  QPlainTextEdit *scriptLog;
375  AtmospherePlot *atmosphere;
376 
377  QStatusBar *statusbar;
378  QProgressBar *progress;
379  QLabel *deviceLabel;
380 
381  QStateMachine machine;
382 };
383 
384 Q_DECLARE_METATYPE(Device::State);
385 
386 #endif // SEPIA_H
MirrorPosition
Possible positions for the selection mirror on the calibration unit.
Definition: calunit.h:31
The main class of the GUI application.
Definition: sepia.h:60
void updateProperty(int key, const QVariant &value, int sub=0)
Update a property.
Definition: sepia.cpp:703
Stage
An enumeration for the stages of a low noise amplifier.
Definition: constants.h:35
void showProgress(int percent)
Show progress via the status bar of the main window.
Definition: sepia.cpp:1579
A header file for commonly used constants.
A class to represent the local oscillator in the GUI.
Definition: localoscillator.h:26
Polarization
An enumeration for the two polarizations.
Definition: constants.h:9
Element
An enumeration for the two mixer elements in each polarization.
Definition: constants.h:17
A class to represent the phase lock loop in the GUI.
Definition: phaselockloop.h:19
A virtual class representing a device.
Definition: device.h:16
A virtual class representing a cartridge.
Definition: cartridge.h:267
A class to control the Acromag GP-I/O unit.
Definition: acromag.h:26
void showStatus(const QString &msg, int timeout=5000)
Show a message via the status bar of the main window.
Definition: sepia.cpp:1585
void updateMonitorItem(const QString &name, DWORD addr, float value, char unit, int gain)
Update the GUI with new data from the M&C unit (CANbus).
Definition: sepia.cpp:1521
A class to control the selection mirror of the calibration unit.
Definition: selectmirror.h:21
Sideband
This enum specifies the various sideband configurations.
Definition: localoscillator.h:42
A class for representing the state of the selection mirror via the GUI.
Definition: calunit.h:21
State
The State enum.
Definition: device.h:22
A class to represent a 2SB mixer in the GUI.
Definition: dualsidebandmixer.h:23
Channel
An enumeration for the three SEPIA channels (cartridges).
Definition: constants.h:66
A class to control the Agilent signal generator.
Definition: agilent.h:18
Device::State status()
Get current device status.
Definition: sepia.cpp:188
A virtual class representing a device.
void setStatus(Device::State state)
Set a new device status.
Definition: sepia.cpp:193