19 #define LOG(__msg__, __level__,__location__) l_Log(CInstrumentCatalog::sLogMessage(__level__, "MFCManager", __msg__, __location__))
21 #define NO_SEARCH_SPR 0 // No search is being performed
22 #define SEARCH_ENDED_SPR 100 // Search progress that is notified when search has ended
41 if (rNotifier.
Is(m_ADNotifier))
44 l_NewInstrumentCurrent(rCurrentInstr.
ReadCurrent());
50 if (rNotifier.
Is(m_ADNotifier))
53 l_NewMFC3045SerialSettings(rMFC3045SerialSett.
ReadCurrent());
59 if (rNotifier.
Is(m_ADNotifier))
68 if (rNotifier.
Is(m_ADNotifier))
77 if (rNotifier.
Is(m_ADNotifier))
80 l_NewNormalizationRequest(rNormalizationRequest.
ReadCurrent());
115 const U8 * l_pVal =
static_cast<const U8 *
>(l_pASNot->
DataCopy());
150 void CMFCManager::l_ClearInstrumentInfo()
172 if(
nullptr != m_pMFCDevice)
176 m_pMFCDevice =
nullptr;
181 l_ClearInstrumentInfo();
190 auto l_InstrIt = m_RsrcListMap.find(rNewInstr.
UniqueID);
191 if (l_InstrIt == m_RsrcListMap.end())
196 m_pMFCDevice =
new CMFC3045Device(m_MFCController, m_RsrcManager, l_InstrIt->second.ParsedResource.Name, m_MFC3045SerialSett);
201 m_pMFCDevice =
new CMFC2x46Device(m_MFCController, m_RsrcManager, l_InstrIt->second.ParsedResource.Name, m_DefaultPAConfScriptFilePath, m_CustomPAConfScriptDirectory);
205 l_RetError = m_pMFCDevice->
Connect(m_InstrInfo);
216 if(!l_UpdateRBBusyLedState(m_RBBusyLedState))
220 m_MFCController.
ScanPA(m_pMFCDevice);
228 l_ClearInstrumentInfo();
231 if(
nullptr != m_pMFCDevice)
234 m_pMFCDevice =
nullptr;
263 l_SendError(l_RetError);
264 if (CMFCDevice::sMFCDeviceError::eLevel::kError >= l_RetError.
Level)
266 throw CMFCManagerException(
"Serial settings change failed. Instrument serial settings might be corrupted. Set default instrument settings by pressing remote Start button untill end of led blinking while resetting the instrument.",
MTL__LOCATION__);
272 m_MFC3045SerialSett = rNewSerialSett;
274 l_NewInstrumentCurrent(l_CurrentInstr);
284 m_MFC3045SerialSett = rNewSerialSett;
296 m_InstrState = rNewInstrState;
304 if (
nullptr != m_pMFCDevice)
305 m_MFCController.
ScanPA(m_pMFCDevice);
326 if (
nullptr == m_pMFCDevice)
356 if (
nullptr != m_pMFCDevice)
357 m_MFCController.
ScanPA(m_pMFCDevice);
372 if(
nullptr != m_pMFCDevice)
374 if(!l_UpdateRBBusyLedState(rNewRBBusyLedState))
377 m_RBBusyLedState = rNewRBBusyLedState;
384 if (
nullptr != m_pMFCDevice)
385 m_MFCController.
ScanPA(m_pMFCDevice);
398 if (
nullptr == m_pMFCDevice)
403 switch (m_InstrInfo.
Type)
409 size_t l_Found = l_Desc.find(
"arm");
410 if(std::string::npos!=l_Found)
412 U32 l_ArmVerMaj = std::stoul(l_Desc.substr(l_Found +3, 1));
413 U32 l_ArmVerMin = std::stoul(l_Desc.substr(l_Found +5, 2));
414 if(l_ArmVerMaj >= 1 && l_ArmVerMin >= 22)
459 void CMFCManager::l_UpdateInstrumentStatus()
466 switch (m_MFCControllerState)
501 switch(rMFCDeviceError.
Level)
503 case CMFCDevice::sMFCDeviceError::eLevel::kFatal:
506 case CMFCDevice::sMFCDeviceError::eLevel::kError:
509 case CMFCDevice::sMFCDeviceError::eLevel::kWarning:
512 case CMFCDevice::sMFCDeviceError::eLevel::kNoError:
539 m_Cat.
cError.rRequestControl(Error);
547 void CMFCManager::l_UpdateSPR(uint8_t SearchProgress)
556 case eEventType::kExit:
558 case eEventType::kUserMsg:
562 l_CatalogNotificationHandler(pMsg->
pCatNot);
565 l_ControllerNotificationHandler(pMsg->
pContrNot);
597 switch (m_MFCControllerState)
606 m_MFCController.
ScanPA(m_pMFCDevice);
609 m_MFCController.
ScanPA(m_pMFCDevice);
615 m_MFCControllerState = State;
618 l_UpdateInstrumentStatus();
628 m_RsrcListMap = l_PrettyResourceNameList(NewResourceList);
631 m_PrettyInstrList.clear();
632 for (
auto & l_it : m_RsrcListMap)
635 l_InsCon.
Label = l_it.second.PrettyName;
637 switch (l_it.second.ParsedResource.Info.Type())
639 case eInterfaceType::TCPIP:
642 case eInterfaceType::USB:
645 case eInterfaceType::ASRL:
652 m_PrettyInstrList.push_back(l_InsCon);
661 if(
nullptr !=m_pMFCDevice)
666 l_UpdateInstrumentStatus();
694 l_UpdateSPR(Progress);
695 l_UpdateInstrumentStatus();
703 l_UpdateInstrumentStatus();
712 l_UpdateInstrumentStatus();
723 switch (m_MFCControllerState)
728 if (error.
Level <= CMFCDevice::sMFCDeviceError::eLevel::kFatal)
737 case CMFCDevice::sMFCDeviceError::eLevel::kFatal:
739 l_ClearInstrumentInfo();
742 case CMFCDevice::sMFCDeviceError::eLevel::kError:
746 case CMFCDevice::sMFCDeviceError::eLevel::kWarning:
755 m_MFCController.
ScanPA(m_pMFCDevice);
786 m_ContCat(m_ContCatInstance),
787 m_ADNotifier(&
CMFCManager::PostCatalogNotification, this),
788 m_ASControllerNotifier(&
CMFCManager::PostControllerNotification, this),
789 m_pMFCDevice(nullptr),
790 m_MFCController(m_ContCatInstance, rDefaultPAConfScriptFilePath, rCustomPAConfScriptDir),
791 m_RBController(m_RsrcManager, m_ContCatInstance),
792 m_DefaultPAConfScriptFilePath(rDefaultPAConfScriptFilePath),
793 m_CustomPAConfScriptDirectory(rCustomPAConfScriptDir)
845 m_ContCat.
oPAInfo.Subscribe(m_ASControllerNotifier);
849 m_ContCat.
oMeasResults.Subscribe(m_ASControllerNotifier);
850 m_ContCat.
oError.Subscribe(m_ASControllerNotifier);
851 m_ContCat.
oLogMessage.Subscribe(m_ASControllerNotifier);
872 CThreadedMailBox::ThreadStart();
881 CThreadedMailBox::ThreadStop();
888 m_pMFCDevice =
nullptr;
891 CMFCManager::tResourceMap CMFCManager::l_PrettyResourceNameList(
const CParsedResourceList & rRsrcList)
899 CMFCManager::tResourceMap l_ReturnedList;
901 std::regex l_reg(
"([^:]+)+");
902 std::sregex_token_iterator l_end;
903 for (
auto & l_RsrcIt : rRsrcList)
906 std::sregex_token_iterator l_TokIt(l_RsrcIt.Name.begin(), l_RsrcIt.Name.end(), l_reg);
907 std::vector<std::string> l_Tokens(l_TokIt, l_end);
909 if (l_Tokens.size() >= 2 && l_RsrcIt.Info.Class() ==
"INSTR" && l_Tokens.back() ==
"INSTR")
912 if (l_Tokens[0].find(
"USB") == 0 && l_Tokens.size() == 5 && l_Tokens[1] ==
"0x1BFA" && l_Tokens[2] ==
"0x07EA")
915 std::string l_InstrName =
"PT2026 " + l_Tokens[3];
916 l_ReturnedList.insert(std::pair<tUniqueID, sPrettyResource>(l_RsrcIt.Name, { l_InstrName, l_RsrcIt }));
919 else if (0 == l_Tokens[0].find(
"TCPIP") && 4 == l_Tokens.size())
921 if(std::string::npos != l_Tokens[1].find(
"PT2026") || std::string::npos != l_Tokens[1].find(
"pt2026"))
924 std::string l_InstrName = l_Tokens[1];
925 l_ReturnedList.insert(std::pair<tUniqueID, sPrettyResource>(l_RsrcIt.Name, { l_InstrName, l_RsrcIt }));
930 else if (l_Tokens[0].find(
"ASRL") == 0)
933 U8 l_COMnumber =
static_cast<U8
>(l_RsrcIt.Info.Number());
934 std::string l_InstrName =
"INSTR - COM" + std::to_string(l_COMnumber);
935 l_ReturnedList.insert(std::pair<tUniqueID, sPrettyResource>(l_RsrcIt.Name, { l_InstrName, l_RsrcIt }));
940 return l_ReturnedList;