15#define LOG(__msg__, __level__,__location__) l_SendLogMessage(__msg__, __level__, "", __location__ )
27void CMFCController::l_SendLogMessage(
const std::string & rMessage,
const CInstrumentCatalog::eLogLevel & rLevel,
const std::string & rContext,
const std::string & rLocation)
36 m_ContCat.cError.RequestControl(rErrorMessage);
39void CMFCController::l_SendSearchProgress(
const U8 & rSearchProgress)
41 m_ContCat.cSearchProgress.RequestControl(rSearchProgress);
46 m_ContCat.cSearchResult.RequestControl(rSearchResult);
51 m_ContCat.cMeasResults.RequestControl(rMeasRes);
54bool CMFCController::l_IsAbortRequested()
61 rErrorOut = rOriginError;
64 if(!m_pMFCDevice->IsInstrumentConnected())
73void CMFCController::l_AbortInstrument()
79 if (
nullptr != m_pMFCDevice)
81 if (!m_pMFCDevice->AbortInstrument())
83 if (!m_pMFCDevice->AbortInstrument())
88 catch (CMFCDevice::sMFCDeviceError & rE)
91 l_SendErrorMessage(rE);
95void CMFCController::l_ScanResources()
103 if (
nullptr == m_pRsrcManager)
106 static CParsedResourceList l_RsrcList, l_NewRsrcList;
108 if (!m_pRsrcManager->FindResources(l_NewRsrcList,
"?*"))
110 if (l_RsrcList != l_NewRsrcList)
112 l_RsrcList = l_NewRsrcList;
113 m_ContCat.cInstrumentList.RequestControl(l_NewRsrcList);
116 catch (CMFCDevice::sMFCDeviceError & rE)
119 l_SendErrorMessage(rE);
121 m_ContCat.cInstrumentList.RequestControl(CParsedResourceList());
125void CMFCController::l_GetRemoteBoxButtonStatus()
129 CMFCDevice::sMFCDeviceError l_RetError;
130 bool l_RemoteBoxPressed(
false);
133 if (
nullptr == m_pMFCDevice)
135 l_RetError = m_pMFCDevice->RemoteBoxButtonStatus(l_RemoteBoxPressed);
140 if (l_RemoteBoxPressed)
143 m_ContCat.cRemoteBoxStart.RequestControl(
true);
146 catch (CMFCDevice::sMFCDeviceError & rE)
148 CMFCDevice::sMFCDeviceError l_Error;
149 l_CheckConnectionOnWarning(rE, l_Error);
151 l_SendErrorMessage(l_Error);
155bool CMFCController::l_ScanPA()
158 bool l_PAInfoChanged(
false);
159 bool l_PASucceeded(
true);
160 CInstrumentCatalog::sInstrumentConfiguration l_InsConf;
163 CMFCDevice::sMFCDeviceError l_RetError;
167 if (
nullptr == m_pMFCDevice)
169 if (!m_PAInfo.ProbeList.empty())
172 m_PAInfo = CInstrumentCatalog::sProbeArrayInformation();
173 l_InsConf = CInstrumentCatalog::sInstrumentConfiguration();
174 l_PAInfoChanged =
true;
178 l_RetError = m_pMFCDevice->ScanPA(m_PAInfo, l_InsConf, l_PAInfoChanged);
184 catch (CMFCDevice::sMFCDeviceError & rE)
186 CMFCDevice::sMFCDeviceError l_Error;
187 l_CheckConnectionOnWarning(rE, l_Error);
189 l_SendErrorMessage(l_Error);
190 l_PASucceeded =
false;
195 m_ContCat.cPAInfo.RequestControl(m_PAInfo);
196 m_ContCat.cInstrumentConfiguration.rRequestControl(l_InsConf);
198 return l_PASucceeded;
201void CMFCController::l_OperateWithInstrument()
206 CMFCDevice::sMFCDeviceError l_RetError;
208 switch (m_InstrState.OperatingMode)
224 if (
nullptr == m_pMFCDevice)
226 l_RetError = m_pMFCDevice->Search(m_InstrState);
241 if (
nullptr == m_pMFCDevice)
243 l_RetError = m_pMFCDevice->Measure(m_InstrState);
252 catch (CMFCDevice::sMFCDeviceError & rE)
255 l_SendErrorMessage(rE);
259void CMFCController::l_RequestSelfAbort()
264 m_ContCat.cState.RequestControl(m_ControllerState);
269 m_ContCat(rCatInstance),
272 m_pMFCDevice(nullptr),
273 m_CustomPAConfScriptDirectory(rCustomPAConfScriptDir)
285void CMFCController::l_TimerEventHandler()
289 switch (m_ControllerState)
294 m_Timer.
StartSingleShot(std::chrono::milliseconds(RSRC_POLLING_PERIOD_MS));
299 l_GetRemoteBoxButtonStatus();
301 m_Timer.
StartSingleShot(std::chrono::milliseconds(PA_POLLING_PERIOD_MS));
306 l_OperateWithInstrument();
324void CMFCController::l_PostTimerEvent()
333 case eEventType::kExit:
338 m_ContCat.cState.RequestControl(m_ControllerState);
340 case eEventType::kUserMsg:
346 l_TimerEventHandler();
374 m_pMFCDevice =
nullptr;
376 if (
nullptr == pRsrcManager)
381 m_pRsrcManager = pRsrcManager;
384 m_ContCat.cState.RequestControl(m_ControllerState);
386 m_Timer.StartSingleShot(std::chrono::milliseconds(0));
399 if (
nullptr == pMFCDevice)
404 if (pMFCDevice != m_pMFCDevice)
408 m_pMFCDevice = pMFCDevice;
411 m_ContCat.cState.RequestControl(m_ControllerState);
413 m_Timer.StartSingleShot(std::chrono::milliseconds(0));
427 if (
nullptr == pMFCDevice)
432 m_pMFCDevice = pMFCDevice;
433 m_InstrState = InsState;
435 switch (m_InstrState.OperatingMode)
439 m_ContCat.cState.RequestControl(m_ControllerState);
444 m_ContCat.cState.RequestControl(m_ControllerState);
446 m_Timer.StartSingleShot(std::chrono::milliseconds(0));
450 m_ContCat.cState.RequestControl(m_ControllerState);
452 m_Timer.StartSingleShot(std::chrono::milliseconds(0));
463 if (
nullptr == m_pMFCDevice)
468 l_RetError = m_pMFCDevice->GetNormalizationDate(l_NewNormDate);
473 if(l_NewNormDate != m_PAInfo.NormalizationDate)
475 m_PAInfo.NormalizationDate = l_NewNormDate;
476 m_ContCat.cPAInfo.RequestControl(m_PAInfo);
482 l_CheckConnectionOnWarning(rE, l_Error);
484 l_SendErrorMessage(l_Error);
#define LOG(__msg__, __level__, __location__)
Platform Dependent Definitions.
std::string StatusDescription(ViSession Session, ViStatus Status)
Return user-readable description of the given status code.
std::string tISO8601DateTime
enum MTL::sMFCControllerMailBoxMsg::eMsgType MsgType
CMFCController(CMFCManagerCatalog &rCatInstance, const std::string &rCustomPAConfScriptDir)
void ScanPA(CMFCDevice *pMFCDevice)
void ScanInstruments(CVISAResourceManager *pRsrcManager)
void SetInstrumentState(CMFCDevice *pMFCDevice, CInstrumentCatalog::sInstrumentState InsState)
virtual ~CMFCController()
void UpdateNormalizationDate()
enum MTL::CMFCDevice::sMFCDeviceError::eLevel Level
CControl< CInstrumentCatalog::sLogMessage > cLogMessage
bool StartSingleShot(std::chrono::milliseconds Delay_ms)
bool l_IsRequestedToStop()
void l_SendMsg(const UserMsgT &rMsg)
VISA Resource Manager class.