C++Instrument Catalog MFC 1.2
Metrolab C++InstrumentCatalog for MFC
Loading...
Searching...
No Matches
MFCManager.h
Go to the documentation of this file.
1
5
6#pragma once
7
8// Standard includes
9#include <iostream>
10#include <atomic>
11#include <exception>
12#include <unordered_map>
13
14// Personnal includes
15#include "InstrumentCatalog.h"
16#include "MFCController.h"
17#include "MFC3045Device.h"
18#include "MFC2x46Device.h"
20#include "Helpers.h"
21#include "MFCManagerCatalog.h"
22
23using namespace MTL;
24using namespace MTL::Instrument;
25using namespace MTL::ThreadedMailbox;
26
27namespace MTL {
28 //--------------------------------------------------------------------------//
29 // MFC MANAGER
30 //--------------------------------------------------------------------------//
32 CAsyncNotification * pCatNot; // Global catalog notification
33 CAsyncNotification * pContrNot; // Controller notification
35 : pCatNot(nullptr), pContrNot(nullptr) {}
38 };
39 class CMFCManager : private CThreadedMailBox<sMFCManagerMailBoxMsg>
40 {
41 //--------------------------------------------------------------------------//
42 // Utilities
43 //--------------------------------------------------------------------------//
44 private:
45 typedef std::string tUniqueID;
46 struct sPrettyResource {
47 std::string PrettyName;
48 sParsedResource ParsedResource;
49 };
50 typedef std::unordered_map<tUniqueID, sPrettyResource> tResourceMap;
51 tResourceMap l_PrettyResourceNameList(const CParsedResourceList & rRsrcList);
52
53 private:
54 //--------------------------------------------------------------------------//
55 // Class attributes
56 //--------------------------------------------------------------------------//
58 CMFCManagerCatalog m_ContCatInstance;
59 CMFCManagerInterface m_ContCat;
60 CAsyncDynamicNotifier m_ADNotifier;
61 CAsyncSnaphsotNotifier m_ASControllerNotifier;
62 CVISAResourceManager m_RsrcManager;
63 tResourceMap m_RsrcListMap;
64 CMFCDevice * m_pMFCDevice = nullptr;
65 CMFCController m_MFCController;
66 CMFCManagerCatalog::eControllerState m_MFCControllerState;
67 CUSBRemoteBoxController m_RBController;
69 bool m_PADisconnected = true; // Used for MFC3048 disconnection that break the remote led busy state functionnality.
70
71 std::string m_CustomPAConfScriptDirectory; // Directory containing PA specific configuration scripts
72
73 // Local versions of controls
76 //CInstrumentCatalog::sProbeArrayInformation m_PAInfo; // no need to keep in Manager
77 //CInstrumentCatalog::sProbeArrayAngle m_PAAngle;
79 // Normalization is ephemeral
80 // Search result is ephemeral
81 // Measurement results are ephemeral
82 // Error is ephemeral
83 // Local versions of observers
87 // Instrument calibration date is ephemeral
88 // Normalization returned is ephemeral
90
91 //--------------------------------------------------------------------------//
92 // Local private methods
93 //--------------------------------------------------------------------------//
94 // Handlers for new values of catalog observers
95 void l_ClearInstrumentInfo();
96 void l_NewInstrumentCurrent(const CInstrumentCatalog::sInstrumentConnection & rNewInstr);
97 void l_NewMFC3045SerialSettings(const CInstrumentCatalog::sMFC3045SerialPortSettings & rNewSerialSett);
98 void l_NewInstrumentState(const CInstrumentCatalog::sInstrumentState & rNewInstrState);
99 void l_NewNormalizationRequest(const CInstrumentCatalog::sNormalization & rNewNormalizationRequest);
100 void l_GetDongleLicenseInfo();
101 void l_DongleLicenseUpdateRequest(const CInstrumentCatalog::sLicenseUpdate & rLicenseUpdateRequest);
102 void l_NewRBBusyLedState(const CInstrumentCatalog::eRemoteBoxBusyLedState & rNewRBBusyLedState);
103
104 // Private operations
105 bool l_UpdateRBBusyLedState(const CInstrumentCatalog::eRemoteBoxBusyLedState & rNewRBBusyLedState);
106 void l_UpdateInstrumentStatus();
107 void l_SendError(const CMFCDevice::sMFCDeviceError & rMFCDeviceError);
108 void l_SendError(CInstrumentCatalog::eErrorLevel Level, std::string Descr, std::string Source);
109 void l_SendError(CInstrumentCatalog::sError Error);
110 void l_Log(const CInstrumentCatalog::sLogMessage & rMessage);
111 void l_UpdateSPR(uint8_t SearchProgress);
112
113 // Local Thread
114 void l_ThreadTask(CThreadedMailBox::eEventType EvtType, sMFCManagerMailBoxMsg * pMsg);
115 // Lives in the main thread (outside of this class)
116 void l_CatalogNotificationHandler(CAsyncNotification * pANot);
117 void l_ControllerNotificationHandler(CAsyncNotification * pASNot);
118
119 //--------------------------------------------------------------------------//
120 // Catalog Notification handling
121 //--------------------------------------------------------------------------//
122 public :
123 void PostCatalogNotification(CAsyncNotification * pANot); // Receives asynchronous notifications from global catalog
124 //--------------------------------------------------------------------------//
125 // MFCManager Catalog Notification handling
126 //--------------------------------------------------------------------------//
127 void PostControllerNotification(CAsyncNotification * pASNot); // Receives asyncrhonous notifications from MFCController
128
129 //--------------------------------------------------------------------------//
130 // MFC Controller Interface
131 //--------------------------------------------------------------------------//
132 public:
134
141 void SlotSearchProgress(U8 Progress);
146
147 //--------------------------------------------------------------------------//
148 // Remote Box Controller Interface
149 //--------------------------------------------------------------------------//
150 public :
151 void SlotRBReset();
152 void SlotRBStart();
153
154 public:
155 //--------------------------------------------------------------------------//
156 // Constructor / Destructor
157 //--------------------------------------------------------------------------//
158 CMFCManager(CInstrumentCatalog & rCatalog, const std::string & rCustomPAConfScriptDir);
159 virtual ~CMFCManager();
160
161 //--------------------------------------------------------------------------//
162 // Class control
163 //--------------------------------------------------------------------------//
164 void SyncControls();
165 void SyncObservers();
166 void Subscribe();
167 void Operate();
168
169 public:
170 void Terminate();
171 }; // class CMFCManager
172
173} // namespace MTL
Collection of utility macros for error messages.
std::vector< sInstrumentConnection > tInstrumentList
CAsyncNotification * pCatNot
Definition MFCManager.h:32
CAsyncNotification * pContrNot
Definition MFCManager.h:33
sMFCManagerMailBoxMsg(CAsyncNotification *pCat, CAsyncNotification *pContr)
Definition MFCManager.h:36
void SlotPAInfo(CInstrumentCatalog::sProbeArrayInformation PAInfo)
void PostCatalogNotification(CAsyncNotification *pANot)
void SlotControllerState(CMFCManagerCatalog::eControllerState State)
void SlotControllerError(CMFCDevice::sMFCDeviceError error)
void SlotSearchResult(CInstrumentCatalog::sSearchResult SearRes)
void SlotMeasResult(CInstrumentCatalog::sMeasurementResults MeasRes)
void SlotInstrumentList(CParsedResourceList List)
CMFCManager(CInstrumentCatalog &rCatalog, const std::string &rCustomPAConfScriptDir)
void SlotControllerThreadIsReady()
void SlotProbeArrayAngle(CInstrumentCatalog::sProbeArrayAngle Angle)
void SlotInstrConfig(CInstrumentCatalog::sInstrumentConfiguration InstrConfig)
void PostControllerNotification(CAsyncNotification *pASNot)
void SlotRemoteBoxTriggerEvent()
void SlotControllerLogMessage(CInstrumentCatalog::sLogMessage Message)
void SlotSearchProgress(U8 Progress)
virtual ~CMFCManager()
VISA Resource Manager class.