C++ Instrument Catalog
USBRemoteBoxController.h
Go to the documentation of this file.
1 
6 #pragma once
7 
8 // Personal includes
9 #include "USBRemoteBox.h"
10 #include "Exception.h"
11 #include "Helpers.h"
12 #include "Synchronization.h"
13 #include "ThreadedMailbox.h"
14 #include "MFCManagerCatalog.h"
15 
16 using namespace MTL;
17 using namespace MTL::Instrument;
18 using namespace MTL::ThreadedMailbox;
19 
20 namespace MTL {
21 
22  //--------------------------------------------------------------------------//
23  // Remote Box
24  //--------------------------------------------------------------------------//
26  enum eMsgType { kTimerEvent, kCatalogNotification } MsgType;
29  : pCatNot(nullptr) {}
31  : MsgType(MT), pCatNot(pNot) {}
32  };
33  class CUSBRemoteBoxController : private CThreadedMailBox<sUSBRemoteBoxControllerMailBoxMsg>
34  {
35  //----------------------------------------------------------------------//
36  // Constants
37  private:
38  static const std::string RSRC_FILTER;
39  static const int REFRESH_RATE_MS;
40 
41  //----------------------------------------------------------------------//
42  // Attributes
43  private:
44  CVISAResourceManager & m_rRsrcMan;
45  CUSBRemoteBoxInterface m_RBCat;
46  CAsyncSnaphsotNotifier m_ASManagerNotifier;
47  CUSBRemoteBox * m_pRemoteBox;
48  CTimer m_Timer;
49  CUSBRemoteBox::uLEDs m_LEDs;
50  CUSBRemoteBox::uButtons m_Buttons;
51 
52  //----------------------------------------------------------------------//
53  // Methods
54  public:
55  //----------------------------------------------------------------------//
56  // Constructors / Destructors
58  virtual ~CUSBRemoteBoxController();
59 
60  //----------------------------------------------------------------------//
61  // Start and stop control
62  void Operate();
63  void Terminate();
64 
65  // Lives in the timer thread
66  private:
67  void l_PostTimerEvent(); // Called when timer elapses. Adds timer event to queue.
68  // Lives in the Manager thread
69  private:
70  void l_PostManagerNotification(CAsyncNotification * pASNot); // Called when a subscribed observer is touched. Adds notification to queue.
71 
72  private:
73  //----------------------------------------------------------------------//
74  // Internal
75  void l_ThreadTask(CThreadedMailBox::eEventType EvtType, sUSBRemoteBoxControllerMailBoxMsg * pMsg);
76  void l_AsyncManagerNotificationHandler(CAsyncNotification * pASNot);
77  void l_Refresh();
78  void l_SetBusyState(bool Busy);
79  };
80 
81 } // namespace MTL
MFCManagerCatalog.h
Synchronization.h
Synchronization primitives.
MTL::Instrument::CUSBRemoteBox::uLEDs
Definition: USBRemoteBox.h:19
MTL::InstrumentCatalogInterface::CAsyncSnaphsotNotifier
Definition: CatalogInterface.h:299
USBRemoteBox.h
MTL::sUSBRemoteBoxControllerMailBoxMsg::eMsgType
eMsgType
Definition: USBRemoteBoxController.h:26
MTL::Instrument::CUSBRemoteBox
Definition: USBRemoteBox.h:15
MTL::ThreadedMailbox::CThreadedMailBox
Definition: ThreadedMailbox.h:222
MTL::Instrument::CUSBRemoteBox::uButtons
Definition: USBRemoteBox.h:27
MTL::sUSBRemoteBoxControllerMailBoxMsg::kTimerEvent
@ kTimerEvent
Definition: USBRemoteBoxController.h:26
MTL::sUSBRemoteBoxControllerMailBoxMsg
Definition: USBRemoteBoxController.h:25
MTL::ThreadedMailbox::CThreadedMailBox::eEventType
eEventType
Definition: ThreadedMailbox.h:228
ThreadedMailbox.h
Helpers.h
Collection of utility macros for error messages.
MTL::CUSBRemoteBoxController
Definition: USBRemoteBoxController.h:33
MTL::CUSBRemoteBoxInterface
Definition: MFCManagerCatalog.h:131
MTL
Definition: CPT2026PeripheralROM.h:19
MTL::Instrument
Definition: MFC3045.h:25
MTL::sUSBRemoteBoxControllerMailBoxMsg::sUSBRemoteBoxControllerMailBoxMsg
sUSBRemoteBoxControllerMailBoxMsg()
Definition: USBRemoteBoxController.h:28
MTL::sUSBRemoteBoxControllerMailBoxMsg::pCatNot
CAsyncNotification * pCatNot
Definition: USBRemoteBoxController.h:27
MTL::ThreadedMailbox
Definition: ThreadedMailbox.h:17
MTL::InstrumentCatalogInterface::CAsyncNotification
Definition: CatalogInterface.h:144
MTL::ThreadedMailbox::CTimer
Definition: ThreadedMailbox.h:126
MTL::CMFCManagerCatalog
Definition: MFCManagerCatalog.h:19
Exception.h
Exception handling utilities.
MTL::sUSBRemoteBoxControllerMailBoxMsg::sUSBRemoteBoxControllerMailBoxMsg
sUSBRemoteBoxControllerMailBoxMsg(eMsgType MT, CAsyncNotification *pNot)
Definition: USBRemoteBoxController.h:30
MTL::Instrument::CVISAResourceManager
VISA Resource Manager class.
Definition: VISAInstrument.h:35