SEPIA
Software documentation for the APEX SEPIA receivers
minicircuit.h
Go to the documentation of this file.
1 /* Copyright 2017 Michael Olberg <michael.olberg@chalmers.se> */
2 #ifndef MINICIRCUITS_H
3 #define MINICIRCUITS_H
4 
5 #include <QTcpSocket>
6 #include "../network.h"
7 
17 class MiniCircuit : public QTcpSocket
18 {
19  Q_OBJECT
20  public:
24  enum SPDTswitch { A = 0x01, B = 0x02, C = 0x04, D = 0x08,
25  E = 0x10, F = 0x20, G = 0x40, H = 0x80 };
26 
27  explicit MiniCircuit(QObject *parent = 0);
28  ~MiniCircuit();
29 
30  public slots:
31  void connectTo(const char *addr);
32 
38  void setSwitch(MiniCircuit::SPDTswitch sw, bool flag);
39 
44  void setPattern(uint setting);
45  void getPattern();
46 
47  signals:
48  // void error();
49  void connectionStatus(bool ok);
50  void answerReady(const QString &ans);
51 
52  private slots:
53  void sendCommand(const QString &cmd);
54  void responseReady();
55 
56  private:
57  void dumpBuffer(QByteArray ba) const;
58 };
59 
60 class IFSwitch : public MiniCircuit
61 {
62  Q_OBJECT
63  public:
67  static IFSwitch *instance()
68  {
69  if (is_instance == 0) is_instance = new IFSwitch();
70  return is_instance;
71  }
72  ~IFSwitch() {}
73 
74  public slots:
75  void connectToServer();
76 
77  private:
78  static IFSwitch *is_instance;
79 };
80 
81 class BackendSwitch : public MiniCircuit
82 {
83  Q_OBJECT
84  public:
88  static BackendSwitch *instance()
89  {
90  if (bs_instance == 0) bs_instance = new BackendSwitch();
91  return bs_instance;
92  }
93  ~BackendSwitch() {}
94 
95  public slots:
96  void connectToServer();
97 
98  private:
99  static BackendSwitch *bs_instance;
100 };
101 
102 
103 #endif // MINICIRCUITS_H
void setPattern(uint setting)
Set the requested switches as a bit pattern.
Definition: minicircuit.cpp:37
void setSwitch(MiniCircuit::SPDTswitch sw, bool flag)
Set the requested switch.
Definition: minicircuit.cpp:51
SPDTswitch
Avaliable switches.
Definition: minicircuit.h:24
A class to control a MiniCircuit unit (IF and backend switch).
Definition: minicircuit.h:17