SEPIA
Software documentation for the APEX SEPIA receivers
acromag.h
Go to the documentation of this file.
1 /* Copyright 2017 Michael Olberg <michael.olberg@chalmers.se> */
2 #ifndef ACROMAG_H
3 #define ACROMAG_H
4 
5 #include <QTcpSocket>
6 #include <QByteArray>
7 #include <QQueue>
8 
9 #include "../constants.h"
10 
26 class Acromag : public QTcpSocket
27 {
28  enum { MBAPLEN = 8 }; /* length of MODBUS application protocoll header */
29 
30  Q_OBJECT
31  public:
35  enum Cartridge {
36  OFF = 0,
37  A = 1,
38  B = 2,
39  C = 3
40  };
41 
45  static Acromag *instance()
46  {
47  if (gpio_instance == 0) gpio_instance = new Acromag();
48  return gpio_instance;
49  }
50  ~Acromag();
51 
57 
62  bool isConnected(Sepia::Channel channel) const;
63 
64  public slots:
68  void connectToServer();
69 
75  void cartridge(Sepia::Channel channel, bool on);
76 
81  void setLOswitch(Sepia::Channel channel);
82 
83  private:
84  static Acromag *gpio_instance;
85  Acromag();
86 
87  void sendAll();
88  void dumpBuffer(QByteArray) const;
89 
90  QQueue<quint16> words;
91  quint16 m_inuse;
92  Sepia::Channel m_lo;
93 
94  quint16 m_addr;
95  quint16 transaction;
96  quint16 protId;
97  quint8 unitId;
98 };
99 
100 #endif // ACROMAG_H
bool isConnected(Sepia::Channel channel) const
Check if we have a network connection to our Acromag instance.
Definition: acromag.cpp:90
Sepia::Channel connectedLO() const
Get the channel which is currently selected.
Definition: acromag.cpp:85
void cartridge(Sepia::Channel channel, bool on)
Select/unselect a cartridge.
Definition: acromag.cpp:58
void connectToServer()
Connect to Acromag GPIO device using Modbus tcp.
Definition: acromag.cpp:25
cartridge C (SEPIA band 7)
Definition: acromag.h:39
A virtual class representing a cartridge.
Definition: cartridge.h:267
cartridge A (SEPIA band 5)
Definition: acromag.h:37
cartridge B (SEPIA band 9)
Definition: acromag.h:38
A class to control the Acromag GP-I/O unit.
Definition: acromag.h:26
void setLOswitch(Sepia::Channel channel)
Set the LO switch for a given cartridge.
Definition: acromag.cpp:34
static Acromag * instance()
Get a pointer to a class Acromag instance.
Definition: acromag.h:45
Channel
An enumeration for the three SEPIA channels (cartridges).
Definition: constants.h:66
no connection
Definition: acromag.h:36