23void CTHM1176InstrumentScanner::HandleError (QString Description,
30 l_Error.
Context = Context.toStdString();
33 CErrorList l_ErrorList;
34 l_ErrorList.push_back(l_Error);
41 m_pResourceManager = pResourceManager;
42 m_TimerID = startTimer(THM1176_SCAN_INTERVAL);
49 m_pResourceManager =
nullptr;
52 QThread::currentThread()->quit();
56void CTHM1176InstrumentScanner::timerEvent (QTimerEvent * Event)
61 if (
nullptr != m_pResourceManager)
64 m_pResourceManager->FindResources(l_InstrumentList, THM1176_RSRC_FILTER);
66 if (m_InstrumentList != l_InstrumentList)
68 m_InstrumentList = l_InstrumentList;
75 HandleError(
"Resource Manager not running", __func__);
85void CTHM1176InstrumentController::HandleError (QString Description,
89 CErrorList l_ErrorList;
90 if (
nullptr != m_pTHM1176)
92 l_ErrorList = m_pTHM1176->CurrentErrorList();
93 m_pTHM1176->ClearErrorList();
100 l_Error.
Context = Context.toStdString();
103 l_ErrorList.insert(l_ErrorList.begin(), l_Error);
115 m_pResourceManager = pResourceManager;
122 if (
nullptr != m_pTHM1176)
124 m_pTHM1176->Disconnect();
129 m_pResourceManager =
nullptr;
130 m_pTHM1176 =
nullptr;
133 QThread::currentThread()->quit();
140void CTHM1176InstrumentController::ClearInstrumentInfo (
void)
142 m_CurrentInstrument.clear();
144 m_Identification.
clear();
147 m_DivisorList.clear();
148 m_AveragingParmBounds.
clear();
149 m_TriggerParmBounds.
clear();
150 m_RangeParmBounds.
clear();
152 m_AveragingParms.
clear();
153 m_TriggerParms.
clear();
154 m_OutputSelect.
clear();
157 m_RangeParms.
clear();
162void CTHM1176InstrumentController::GetInstrumentInfo (std::string Context)
173 MakeUnitsList(Context);
196 m_OutputSelect.
clear();
204 GetCurrentUnits(Context);
207 m_RangeParms.
Auto = m_RangeParmBounds.
Auto;
211 if (!m_pTHM1176->
GetFormat(m_CommFormat))
216void CTHM1176InstrumentController::GetInstrumentParameters (std::string Context)
219 if (!m_pTHM1176->ParmAveragingGet(m_AveragingParms))
220 throw CException<CTHM1176InstrumentManager>(
"Cannot get Averaging parameters", Context);
223 if (!m_pTHM1176->ParmTriggerInputGet(m_TriggerParms))
224 throw CException<CTHM1176InstrumentManager>(
"Cannot get Trigger parameters", Context);
227 m_OutputSelect.clear();
228 m_OutputSelect.NoMeasurements = m_TriggerParmBounds.Count.Val;
231 if (!m_pTHM1176->ParmSleepGet(m_SleepParm))
232 throw CException<CTHM1176InstrumentManager>(
"Cannot get Sleep parameter", Context);
235 GetCurrentUnits(Context);
238 if (!m_pTHM1176->ParmRangeGet(m_RangeParms))
239 throw CException<CTHM1176InstrumentManager>(
"Cannot get Range parameters", Context);
242 if (!m_pTHM1176->GetFormat(m_CommFormat))
243 throw CException<CTHM1176InstrumentManager>(
"Cannot get Communication Format", Context);
247void CTHM1176InstrumentController::PublishInstrumentInfo (
void)
266void CTHM1176InstrumentController::PublishInstrumentParameters (
void)
281 m_InstrumentList = InstrumentList;
284 if (m_CurrentInstrument.empty() && m_pTHM1176 ==
nullptr)
return;
286 for (
auto l_pTHM1176ResourceID = InstrumentList.begin(); l_pTHM1176ResourceID < InstrumentList.end(); l_pTHM1176ResourceID++)
287 if (m_CurrentInstrument == *l_pTHM1176ResourceID)
return;
291 killTimer(m_TimerID);
295 if (m_pTHM1176 !=
nullptr)
296 m_pTHM1176->Disconnect();
297 m_pTHM1176 =
nullptr;
306 ClearInstrumentInfo();
307 PublishInstrumentInfo();
317 auto l_pResource = m_InstrumentList.begin();
318 for (; l_pResource < m_InstrumentList.end(); l_pResource++)
319 if (*l_pResource == CurrentInstrument)
break;
320 if (l_pResource >= m_InstrumentList.end())
324 if (CurrentInstrument == m_CurrentInstrument)
328 if (
nullptr != m_pTHM1176)
330 m_pTHM1176->Disconnect();
332 m_pTHM1176 =
nullptr;
341 ClearInstrumentInfo();
342 PublishInstrumentInfo();
346 if (
nullptr == m_pResourceManager)
351 if (
nullptr == m_pTHM1176)
369 std::string ErrorMessage;
370 if (!m_pTHM1176->Connect(THM1176_CONNECT_TIMEOUT,
true, &ErrorMessage))
374 GetInstrumentInfo(__func__);
375 m_CurrentInstrument = CurrentInstrument;
379 PublishInstrumentInfo();
388 m_pTHM1176 =
nullptr;
391 ClearInstrumentInfo();
397 }
catch (
const std::exception& ex) {
399 HandleError(ex.what(), __func__);
402 HandleError(
"Unknown error occurred during THM1176 connection", __func__);
415 if (m_pTHM1176 ==
nullptr)
417 else if (m_OperatingMode == OperatingMode)
425 killTimer(m_TimerID);
429 if (!m_pTHM1176->Abort())
434 m_OperatingMode = OperatingMode;
435 switch (m_OperatingMode)
438 if (
nullptr != m_pTHM1176)
441 if (!m_pTHM1176->Abort())
445 m_pTHM1176->Disconnect();
447 m_pTHM1176 =
nullptr;
456 ClearInstrumentInfo();
457 PublishInstrumentInfo();
463 if (!m_pTHM1176->Abort())
471 if (!m_pTHM1176->Reset())
475 GetInstrumentParameters(__func__);
476 PublishInstrumentParameters();
485 if (!m_pTHM1176->Abort())
495 if (!m_pTHM1176->Abort())
503 if (!m_pTHM1176->Initiate(
false))
507 switch (m_TriggerParms.Source)
520 if (!m_pTHM1176->MeasurementsGet(m_OutputSelect,
521 l_Measurement.
Bx, l_Measurement.
By, l_Measurement.
Bz,
523 &l_MeasurementConditions))
526 TranslateUnits(l_Measurement, l_Units);
536 l_Measurement.
Warnings = m_pTHM1176->CurrentErrorList();
550 if (!m_pTHM1176->Abort())
558 switch (m_TriggerParms.Source)
562 m_TimerID = startTimer(0);
568 if (!m_pTHM1176->Initiate(
true))
570 m_TimerID = startTimer(0);
576 if (!m_pTHM1176->Initiate(
false))
584 if (!m_pTHM1176->Abort())
592 if (!m_pTHM1176->CalibrateZeroOffset(m_CalibrationOverride))
602 if (!m_pTHM1176->Abort())
610 if (!m_pTHM1176->RestoreZeroOffset())
625 killTimer(m_TimerID);
641 if (m_pTHM1176 ==
nullptr ||
644 m_TriggerCount >= m_TriggerParms.Count)
648 if (!m_pTHM1176->SendBusTrigger())
652 if (++m_TriggerCount >= m_TriggerParms.Count)
658 if (!m_pTHM1176->MeasurementsGet(m_OutputSelect,
659 l_Measurement.
Bx, l_Measurement.
By, l_Measurement.
Bz,
661 &l_MeasurementConditions))
664 TranslateUnits(l_Measurement, l_Units);
674 l_Measurement.
Warnings = m_pTHM1176->CurrentErrorList();
682 if (!m_pTHM1176->Initiate(
false))
702void CTHM1176InstrumentController::timerEvent (QTimerEvent * Event)
719 l_Measurement.
Bx, l_Measurement.
By, l_Measurement.
Bz,
721 &l_MeasurementConditions))
724 TranslateUnits(l_Measurement, l_Units);
747void CTHM1176InstrumentController::MakeUnitsList (std::string Context)
750 CUnitsList l_UnitsList;
751 if (!m_pTHM1176->GetAllUnits(l_UnitsList))
752 throw CException<CTHM1176InstrumentManager>(
"Cannot get units list", Context);
755 for (
auto l_pUnits = l_UnitsList.begin(); l_pUnits < l_UnitsList.end(); l_pUnits++)
757 m_UnitsList.push_back(
static_cast<eTHM1176Units>(*l_pUnits));
760 if (!m_pTHM1176->GetDivisor(*l_pUnits, l_Divisor))
761 throw CException<CTHM1176InstrumentManager>(
"Cannot get units list", Context);
762 m_DivisorList.push_back(l_Divisor);
766 F32 l_FloatDivisor = m_DivisorList[0] * MU0;
767 if (l_FloatDivisor >= 1. && l_FloatDivisor <= 65535.)
769 m_UnitsList.push_back(
kApm);
770 m_DivisorList.push_back(
static_cast<U32>(l_FloatDivisor + 0.5));
772 l_FloatDivisor = m_DivisorList[0] * MU0 * 1000.;
773 if (l_FloatDivisor >= 1. && l_FloatDivisor <= 65535.)
775 m_UnitsList.push_back(
kkApm);
776 m_DivisorList.push_back(
static_cast<U32>(l_FloatDivisor + 0.5));
778 l_FloatDivisor = m_DivisorList[0] * MU0 / 1000;
779 if (l_FloatDivisor >= 1. && l_FloatDivisor <= 65535.)
781 m_UnitsList.push_back(
kmApm);
782 m_DivisorList.push_back(
static_cast<U32>(l_FloatDivisor + 0.5));
786 m_UnitsList.push_back(
kADC);
787 m_DivisorList.push_back(1);
791void CTHM1176InstrumentController::GetCurrentUnits (std::string Context)
794 bool l_UseCalibration;
795 if (!m_pTHM1176->ParmUnitsGet(l_Units) ||
796 !m_pTHM1176->ParmUseCalibrationGet(l_UseCalibration))
797 throw CException<CTHM1176InstrumentManager>(
"Cannot get Units", Context);
799 if (!l_UseCalibration)
804void CTHM1176InstrumentController::TranslateUnits (
CMeasurement & Measurement,
815 l_Multiplier = 1.f / MU0;
818 l_Multiplier = 0.001f / MU0;
821 l_Multiplier = 1000.f / MU0;
825 for (
size_t i = 0; i < Measurement.
Bx.size(); i++)
826 Measurement.
Bx[i] *= l_Multiplier;
827 for (
size_t i = 0; i < Measurement.
By.size(); i++)
828 Measurement.
By[i] *= l_Multiplier;
829 for (
size_t i = 0; i < Measurement.
Bz.size(); i++)
830 Measurement.
Bz[i] *= l_Multiplier;
831 Measurement.
Units = m_Units;
849 if (m_AveragingParms != AveragingParms)
851 if (m_pTHM1176 ==
nullptr ||
852 !m_pTHM1176->ParmAveragingSet(AveragingParms))
854 HandleError(
"Cannot change averaging parameters", __func__);
855 if(m_pTHM1176 ==
nullptr ||
856 !m_pTHM1176->ParmAveragingGet(m_AveragingParms))
857 HandleError(
"Cannot retrieve averaging parameters", __func__);
861 m_AveragingParms = AveragingParms;
867 if (0 == m_TimerID ||
868 !m_pTHM1176->Initiate(
true))
870 HandleError(
"Error restarting continous measurements", __func__);
883 if (m_TriggerParms != TriggerParms)
885 if (m_pTHM1176 ==
nullptr ||
886 !m_pTHM1176->ParmTriggerInputSet(TriggerParms))
888 HandleError(
"Cannot change trigger parameters", __func__);
889 if (m_pTHM1176 ==
nullptr ||
890 !m_pTHM1176->ParmTriggerInputGet(m_TriggerParms))
891 HandleError(
"Cannot retrieve trigger parameters", __func__);
895 m_TriggerParms = TriggerParms;
901 if (0 == m_TimerID ||
902 !m_pTHM1176->Initiate(
true))
904 HandleError(
"Error restarting continous measurements", __func__);
917 if (m_OutputSelect != OutputSelect)
919 if (m_pTHM1176 ==
nullptr)
920 HandleError(
"Cannot change output selection", __func__);
922 m_OutputSelect = OutputSelect;
930 if (m_SleepParm != SleepParm)
932 if (m_pTHM1176 ==
nullptr ||
933 !m_pTHM1176->ParmSleepSet(SleepParm))
935 HandleError(
"Cannot change sleep parameter", __func__);
936 if (m_pTHM1176 ==
nullptr ||
937 !m_pTHM1176->ParmSleepGet(m_SleepParm))
938 HandleError(
"Cannot retrieve sleep parameter", __func__);
941 m_SleepParm = SleepParm;
949 if (m_Units != Units)
953 if (m_pTHM1176 ==
nullptr)
961 if (!m_pTHM1176->ParmUseCalibrationSet(
true) ||
966 if (!m_pTHM1176->ParmUseCalibrationSet(
false))
971 if (!m_pTHM1176->ParmUseCalibrationSet(
true) ||
972 !m_pTHM1176->ParmUnitsSet(l_Units))
981 HandleError(
"Cannot change units", __func__);
990 if (m_RangeParms != RangeParms)
992 if (m_pTHM1176 ==
nullptr ||
993 !m_pTHM1176->ParmRangeSet(RangeParms))
995 HandleError(
"Cannot change range parameters", __func__);
996 if (m_pTHM1176 ==
nullptr ||
997 !m_pTHM1176->ParmRangeGet(m_RangeParms))
998 HandleError(
"Cannot retrieve range parameters", __func__);
1001 m_RangeParms = RangeParms;
1009 if (m_CommFormat != CommFormat)
1011 if (m_pTHM1176 ==
nullptr ||
1012 !m_pTHM1176->SetFormat(CommFormat))
1014 HandleError(
"Cannot change communication format", __func__);
1015 if (m_pTHM1176 ==
nullptr ||
1016 !m_pTHM1176->GetFormat(m_CommFormat))
1017 HandleError(
"Cannot retrieve communication format", __func__);
1020 m_CommFormat = CommFormat;
1028 m_CalibrationOverride = Override;
1037void CTHM1176InstrumentManager::HandleError (QString Description,
1044 l_Error.
Context = Context.toStdString();
1048 l_ErrorList.push_back(l_Error);
1049 emit UpdateErrorList(l_ErrorList);
1070 this, &CTHM1176InstrumentManager::UpdateInstrumentList);
1072 this, &CTHM1176InstrumentManager::UpdateErrorList);
1090 Qt::BlockingQueuedConnection);
1112 this, &CTHM1176InstrumentManager::UpdateCurrentInstrument);
1114 this, &CTHM1176InstrumentManager::UpdateInstrumentPointer);
1116 this, &CTHM1176InstrumentManager::UpdateOperatingMode);
1118 this, &CTHM1176InstrumentManager::UpdateMeasurement);
1120 this, &CTHM1176InstrumentManager::UpdateErrorList);
1123 this, &CTHM1176InstrumentManager::UpdateIdentification);
1125 this, &CTHM1176InstrumentManager::UpdateRangeList);
1127 this, &CTHM1176InstrumentManager::UpdateUnitsList);
1129 this, &CTHM1176InstrumentManager::UpdateDivisorList);
1131 this, &CTHM1176InstrumentManager::UpdateAveragingParmBounds);
1133 this, &CTHM1176InstrumentManager::UpdateTriggerParmBounds);
1135 this, &CTHM1176InstrumentManager::UpdateRangeParmBounds);
1138 this, &CTHM1176InstrumentManager::UpdateAveragingParms);
1140 this, &CTHM1176InstrumentManager::UpdateTriggerParms);
1142 this, &CTHM1176InstrumentManager::UpdateOutputSelect);
1144 this, &CTHM1176InstrumentManager::UpdateSleepParm);
1146 this, &CTHM1176InstrumentManager::UpdateUnits);
1148 this, &CTHM1176InstrumentManager::UpdateRangeParms);
1150 this, &CTHM1176InstrumentManager::UpdateCommFormat);
1153 m_pResourceManager =
new THM1176_RSRC_MGR_CLS;
1154 if (
nullptr == m_pResourceManager || !m_pResourceManager->Initialize())
1155 HandleError(
"Cannot initialize Resource Manager", __func__);
1158 m_pInstrumentScanner->moveToThread(&m_InstrumentScanThread);
1159 m_InstrumentScanThread.start();
1165 m_pInstrumentController->moveToThread(&m_InstrumentControlThread);
1166 m_InstrumentControlThread.start();
1169 connect(&m_InstrumentControlThread, &QThread::finished,
1170 m_pInstrumentController, &CTHM1176InstrumentController::deleteLater);
1171 connect(&m_InstrumentControlThread, &QThread::finished,
1173 connect(&m_InstrumentScanThread, &QThread::finished,
1174 m_pInstrumentScanner, &CTHM1176InstrumentScanner::deleteLater);
1188 if (!m_InstrumentControlThread.wait())
1189 HandleError(
"Cannot quit Instrument Controller thread", __func__);
1192 m_InstrumentScanThread.quit();
1193 if (!m_InstrumentScanThread.wait())
1194 HandleError(
"Cannot quit Instrument Scanner thread", __func__);
1197 delete m_pResourceManager;
1200 m_pResourceManager =
nullptr;
1201 m_pTHM1176 =
nullptr;
1202 m_pInstrumentScanner =
nullptr;
1203 m_pInstrumentController =
nullptr;
1210void CTHM1176InstrumentManager::UpdateInstrumentList (
CResourceList InstrumentList)
1224void CTHM1176InstrumentManager::UpdateCurrentInstrument (
tResourceName CurrentInstrument)
1235void CTHM1176InstrumentManager::UpdateInstrumentPointer (CTHM1176Instrument<THM1176_INSTR_CLS, THM1176_RSRC_MGR_CLS> * pTHM1176)
1238 m_pTHM1176 = pTHM1176;
1253void CTHM1176InstrumentManager::UpdateMeasurement (
CMeasurement Measurement)
1261void CTHM1176InstrumentManager::UpdateErrorList (CErrorList ErrorList)
1270void CTHM1176InstrumentManager::UpdateIdentification (sIdentifier Identification)
1278void CTHM1176InstrumentManager::UpdateRangeList (CFluxList RangeList)
1294void CTHM1176InstrumentManager::UpdateDivisorList (CDivisorList DivisorList)
1302void CTHM1176InstrumentManager::UpdateAveragingParmBounds (sAveraging<sBoundedParm> AveragingParmBounds)
1309 m_AveragingParms.NoPoints = m_AveragingParmBounds.NoPoints.Val;
1314void CTHM1176InstrumentManager::UpdateTriggerParmBounds (sInputTrigger<sBoundedParm> TriggerParmBounds)
1328void CTHM1176InstrumentManager::UpdateRangeParmBounds (sRange<sBoundedParm> RangeParmBounds)
1335 m_RangeParms.Auto = m_RangeParmBounds.Auto;
1336 m_RangeParms.Range = m_RangeParmBounds.Range.Val;
1342void CTHM1176InstrumentManager::UpdateAveragingParms (sAveraging<uParm> AveragingParms)
1354void CTHM1176InstrumentManager::UpdateTriggerParms (sInputTrigger<uParm> TriggerParms)
1366void CTHM1176InstrumentManager::UpdateOutputSelect (sArbitraryMeasurements OutputSelect)
1377void CTHM1176InstrumentManager::UpdateSleepParm (
bool SleepParm)
1388void CTHM1176InstrumentManager::UpdateUnits (
eTHM1176Units Units)
1399void CTHM1176InstrumentManager::UpdateRangeParms (sRange<uParm> RangeParms)
1429 return m_InstrumentList;
1435 return m_CurrentInstrument;
1441 return m_OperatingMode;
1447 if (m_pTHM1176 ==
nullptr)
1455 if (m_pTHM1176 ==
nullptr)
1456 HandleError(
"Instrument not connected", __func__);
1457 return m_Measurement;
1471 if (m_pTHM1176 ==
nullptr)
1472 HandleError(
"Instrument not connected", __func__);
1473 return m_Identification;
1479 if (m_pTHM1176 ==
nullptr)
1480 HandleError(
"Instrument not connected", __func__);
1487 if (m_pTHM1176 ==
nullptr)
1488 HandleError(
"Instrument not connected", __func__);
1495 if (m_pTHM1176 ==
nullptr)
1496 HandleError(
"Instrument not connected", __func__);
1497 return m_DivisorList;
1503 if (m_pTHM1176 ==
nullptr)
1504 HandleError(
"Instrument not connected", __func__);
1505 return m_AveragingParmBounds;
1511 if (m_pTHM1176 ==
nullptr)
1512 HandleError(
"Instrument not connected", __func__);
1513 return m_TriggerParmBounds;
1519 if (m_pTHM1176 ==
nullptr)
1520 HandleError(
"Instrument not connected", __func__);
1521 return m_RangeParmBounds;
1529 if (m_pTHM1176 ==
nullptr)
1530 HandleError(
"Instrument not connected", __func__);
1531 return m_AveragingParms;
1537 if (m_pTHM1176 ==
nullptr)
1538 HandleError(
"Instrument not connected", __func__);
1539 return m_TriggerParms;
1545 if (m_pTHM1176 ==
nullptr)
1546 HandleError(
"Instrument not connected", __func__);
1547 return m_OutputSelect;
1553 if (m_pTHM1176 ==
nullptr)
1554 HandleError(
"Instrument not connected", __func__);
1561 if (m_pTHM1176 ==
nullptr)
1562 HandleError(
"Instrument not connected", __func__);
1569 if (m_pTHM1176 ==
nullptr)
1570 HandleError(
"Instrument not connected", __func__);
1571 return m_RangeParms;
1577 if (m_pTHM1176 ==
nullptr)
1578 HandleError(
"Instrument not connected", __func__);
1579 return m_CommFormat;
1585 if (m_pTHM1176 ==
nullptr)
1587 HandleError(
"Instrument not connected", __func__);
1592 return m_pTHM1176->GetImmediateMeasurementPeriod(rAvg,
GetIdentification().ModelRevision, rPeriod);
1598 if (m_pTHM1176 ==
nullptr)
1600 HandleError(
"Instrument not connected", __func__);
1605 std::string l_SManufacturingDate;
1606 std::time_t l_ManufacturingDate;
1607 std::string l_SCalibrationDate;
1608 std::time_t l_CalibrationDate;
1609 bool l_Success = m_pTHM1176->ReadInformationDates(l_SManufacturingDate, l_ManufacturingDate, l_SCalibrationDate, l_CalibrationDate);
1613 rManufacturingDate = QDateTime::fromSecsSinceEpoch(l_ManufacturingDate);
1614 rCalibrationDate = QDateTime::fromSecsSinceEpoch(l_CalibrationDate);
1632 auto l_pResource = m_InstrumentList.begin();
1633 for (; l_pResource < m_InstrumentList.end(); l_pResource++)
1635 if (l_pResource >= m_InstrumentList.end())
1637 HandleError(
"Resource name not in resource list", __func__);
1641 if (m_pTHM1176 !=
nullptr &&
1643 m_Identification.FirmwareVersion.Major >= THM1176_MIN_VERSION_WITH_ABORTREAD &&
1644 !m_pTHM1176->AbortRead())
1645 HandleError(
"Cannot abort read", __func__);
1653 if (m_pTHM1176 ==
nullptr)
1655 HandleError(
"Instrument not connected", __func__);
1662 m_Identification.FirmwareVersion.Major >= THM1176_MIN_VERSION_WITH_ABORTREAD &&
1663 !m_pTHM1176->AbortRead())
1664 HandleError(
"Cannot abort read", __func__);
1673 if (m_pTHM1176 ==
nullptr)
1675 HandleError(
"Instrument not connected", __func__);
1681 if (
AveragingParms.NoPoints < m_AveragingParmBounds.NoPoints.Min ||
1684 HandleError(
"Averaging parameter out of range", __func__);
1689 m_Identification.FirmwareVersion.Major >= THM1176_MIN_VERSION_WITH_ABORTREAD &&
1690 !m_pTHM1176->AbortRead())
1691 HandleError(
"Cannot abort read", __func__);
1699 if (m_pTHM1176 ==
nullptr)
1701 HandleError(
"Instrument not connected", __func__);
1707 if (
TriggerParms.Count < m_TriggerParmBounds.Count.Min ||
1710 (
TriggerParms.Period_s < m_TriggerParmBounds.Period_s.Min ||
1711 TriggerParms.Period_s > m_TriggerParmBounds.Period_s.Max)))
1713 HandleError(
"Trigger parameter out of bounds", __func__);
1718 m_Identification.FirmwareVersion.Major >= THM1176_MIN_VERSION_WITH_ABORTREAD &&
1719 !m_pTHM1176->AbortRead())
1720 HandleError(
"Cannot abort read", __func__);
1728 if (m_pTHM1176 ==
nullptr)
1730 HandleError(
"Instrument not connected", __func__);
1739 HandleError(
"Invalid measurement count", __func__);
1744 m_Identification.FirmwareVersion.Major >= THM1176_MIN_VERSION_WITH_ABORTREAD &&
1745 !m_pTHM1176->AbortRead())
1746 HandleError(
"Cannot abort read", __func__);
1754 if (m_pTHM1176 ==
nullptr)
1756 HandleError(
"Instrument not connected", __func__);
1763 m_Identification.FirmwareVersion.Major >= THM1176_MIN_VERSION_WITH_ABORTREAD &&
1764 !m_pTHM1176->AbortRead())
1765 HandleError(
"Cannot abort read", __func__);
1773 if (m_pTHM1176 ==
nullptr)
1775 HandleError(
"Instrument not connected", __func__);
1779 if (
Units == m_Units)
return;
1781 auto l_pUnits = m_UnitsList.begin();
1782 for (; l_pUnits < m_UnitsList.end(); l_pUnits++)
1783 if (*l_pUnits ==
Units)
break;
1784 if (l_pUnits >= m_UnitsList.end())
1786 HandleError(
"Invalid Units", __func__);
1791 m_Identification.FirmwareVersion.Major >= THM1176_MIN_VERSION_WITH_ABORTREAD &&
1792 !m_pTHM1176->AbortRead())
1793 HandleError(
"Cannot abort read", __func__);
1801 if (m_pTHM1176 ==
nullptr)
1803 HandleError(
"Instrument not connected", __func__);
1812 auto l_pRange = m_RangeList.begin();
1813 for (; l_pRange < m_RangeList.end(); l_pRange++)
1814 if (abs(*l_pRange -
RangeParms.Range) < l_Tolerance)
break;
1815 if (l_pRange >= m_RangeList.end())
1817 HandleError(
"Invalid range selection", __func__);
1823 m_Identification.FirmwareVersion.Major >= THM1176_MIN_VERSION_WITH_ABORTREAD &&
1824 !m_pTHM1176->AbortRead())
1825 HandleError(
"Cannot abort read", __func__);
1833 if (m_pTHM1176 ==
nullptr)
1835 HandleError(
"Instrument not connected", __func__);
1842 m_Identification.FirmwareVersion.Major >= THM1176_MIN_VERSION_WITH_ABORTREAD &&
1843 !m_pTHM1176->AbortRead())
1844 HandleError(
"Cannot abort read", __func__);
Interface definition for Metrolab THM1176/TFM1186 Instrument Manager.
Exception handling utilities.
Collection of utility macros for error messages.
Platform Dependent Definitions.
float F32
32-bit floating-point number.
unsigned int U32
32-bit unsigned integer.
double F64
64-bit floating-point number.
const char * message() const noexcept
Return the message.
const char * context() const noexcept
Return the context.
Data returned for one measurement.
CErrorList Warnings
Any warnings returned during the measurement.
CFluxList Bx
Bx value for each measurement.
eTHM1176Units Units
Measurement units for Bx, By, Bz.
sInputTrigger< uParm > TriggerParms
Trigger parameters used for measurement.
CTimestampList TimestampList
Timestamp for each measurement.
sRange< uParm > RangeParms
Range parameters used for measurement.
sAveraging< uParm > AveragingParms
Averaging parameters used for measurement.
sArbitraryMeasurements OutputSelect
Output selection parameters used for measurement.
bool SleepParm
Sleep parameters used for measurement.
CFluxList By
By value for each measurement.
ushort Temp
Temperature, in arbitrary units.
CFluxList Bz
Bz value for each measurement.
eCommunicationFormat CommFormat
Communication parameters used for measurement.
THM1176 Instrument Controller class: communicate with instrument.
void UpdateOutputSelect(sArbitraryMeasurements OutputSelect)
Signal a change of the output selection parameters.
void SendTrigger(void)
Send a bus trigger.
void UpdateIdentification(sIdentifier Identification)
Signal to report identifier information for newly connected instrument.
void UpdateCurrentInstrument(tResourceName CurrentInstrument)
Signal that current instrument selection has changed.
void UpdateAveragingParms(sAveraging< uParm > AveragingParms)
Signal a change of the averaging parameters.
void UpdateErrorList(CErrorList LatestErrors)
Signal that new errors have been reported.
void UpdateRangeParms(sRange< uParm > RangeParms)
Signal a change of the range parameters.
void UpdateUnitsList(CTHM1176UnitsList UnitsList)
Signal to report list of valid measurement units for newly connected instrument.
void UpdateRangeList(CFluxList RangeList)
Signal to report list of valid ranges for newly connected instrument.
void SetCommFormat(eCommunicationFormat CommFormat)
Set communication format.
void UpdateRangeParmBounds(sRange< sBoundedParm > RangeParmBounds)
Signal to report bounds of range parameters for newly connected instrument.
void UpdateInstrumentList(CResourceList InstrumentList)
Update the Instrument Controller's copy of the list of detected instruments.
void UpdateUnits(eTHM1176Units Units)
Signal a change of the measurement units.
void SetAveragingParms(sAveraging< uParm > AveragingParms)
Set the averaging parameters.
void SetUnits(eTHM1176Units Units)
Select the measurement units.
void SetOutputSelect(sArbitraryMeasurements OutputSelect)
Select what data is returned.
void UpdateTriggerParms(sInputTrigger< uParm > TriggerParms)
Signal a change of the trigger parameters.
void UpdateDivisorList(CDivisorList DivisorList)
Signal to report divisors associated with valid measurement units for newly connected instrument.
void UpdateAveragingParmBounds(sAveraging< sBoundedParm > AveragingParmBounds)
Signal to report bounds of averaging parameters for newly connected instrument.
void Stop(void)
Shut down the Instrument Controller.
void UpdateMeasurement(CMeasurement Measurement)
Signal that a new measurement is available.
void Start(THM1176_RSRC_MGR_CLS *pResourceManager)
Initialize the Instrument Controller.
void SetOperatingMode(eTHM1176OperatingMode OperatingMode)
Set operating mode.
void UpdateSleepParm(bool SleepParm)
Signal a change of the sleep parameter.
void UpdateOperatingMode(eTHM1176OperatingMode OperatingMode)
Signal that the operating mode has changed.
void UpdateTriggerParmBounds(sInputTrigger< sBoundedParm > TriggerParmBounds)
Signal to report bounds of trigger parameters for newly connected instrument.
void SetCurrentInstrument(tResourceName CurrentInstrument)
Select the instrument to connect to.
void UpdateCommFormat(eCommunicationFormat CommFormat)
Signal a change of the communication format.
void SetTriggerParms(sInputTrigger< uParm > TriggerParms)
Set the trigger parameters.
void UpdateInstrumentPointer(CTHM1176Instrument< THM1176_INSTR_CLS, THM1176_RSRC_MGR_CLS > *pTHM1176)
Signal to broadcast updated pointer to THM1176 Instrument object.
void SetRangeParms(sRange< uParm > RangeParms)
Set range parameters.
void SetCalibrationOverride(bool Override)
Set whether or not to override the check for instruments whose zero offset should not be calibrated.
void SetSleepParm(bool SleepParm)
Set whether or not the instrument sleeps after each measurement.
void SetAveragingParms(sAveraging< uParm > AveragingParms)
Set the averaging parameters.
CErrorList GetErrorList(void)
Get the current error list.
void RelayOperatingMode(eTHM1176OperatingMode OperatingMode)
Internal signal to relay the operating mode selection to the Instrument Controller.
sArbitraryMeasurements GetOutputSelect(void)
Get the output selection parameters.
sAveraging< sBoundedParm > AveragingParmBounds
Bounds on averaging parameter.
bool ReadInformationDates(QDateTime &rManufacturingDate, QDateTime &rCalibrationDate)
Fetch the intrument's date information.
static const I32 THM1176_INST_MGR_ERROR
Additional error code: Instrument Manager Error.
eTHM1176Units Units
Current measurement units.
void SetSleepParm(bool SleepParm)
Set the sleep parameter.
eTHM1176Units GetUnits(void)
Get the measurement units.
eTHM1176OperatingMode GetOperatingMode(void)
Get the current operating mode.
sInputTrigger< sBoundedParm > GetTriggerParmBounds(void)
Get the bounds on trigger parameters.
void RelayTriggerParms(sInputTrigger< uParm > TriggerParms)
Internal signal to relay the trigger parameters to the Instrument Controller.
void SetOutputSelect(sArbitraryMeasurements OutputSelect)
Set the output selection parameters.
bool SleepParm
Sleep parameter: true if instrument should sleep after each measurement.
sRange< uParm > RangeParms
Current range parameters.
CTHM1176UnitsList GetUnitsList(void)
Get the list of valid measurement units for this instrument model.
CMeasurement GetMeasurement(void)
Get the last set of measurements.
sInputTrigger< uParm > GetTriggerParms(void)
Get the trigger parameters.
void NotifyTriggerParmBounds(sInputTrigger< sBoundedParm > TriggerParmBounds)
Notify that the bounds on trigger parameters have changed.
static const I32 THM1176_INST_CTLR_ERROR
Additional error code: Instrument Controller Error.
CFluxList RangeList
List of valid ranges for this instrument model.
eCommunicationFormat GetCommFormat(void)
Get the communication format parameters.
void RelayCurrentInstrument(tResourceName CurrentInstrument)
Internal signal to relay the instrument selection to the Instrument Controller.
void NotifyAveragingParmBounds(sAveraging< sBoundedParm > AveragingParmBounds)
Notify that the bounds on averaging parameters have changed.
CDivisorList DivisorList
List of divisors for each measurement unit for this instrument model, to convert "base" units to the ...
void NotifyAveragingParms(sAveraging< uParm > AveragingParms)
Notify that the averaging parameters have changed.
sInputTrigger< sBoundedParm > TriggerParmBounds
Bounds on trigger parameters.
bool GetIsTHMNullptr(void)
Get the test result of m_pTHM1176 pointer is Nullptr.
void NotifyUnits(eTHM1176Units Units)
Notify that the measurement units have changed.
sAveraging< uParm > GetAveragingParms(void)
Get the averaging parameters.
void NotifyCurrentInstrument(tResourceName CurrentInstrument)
Notify that the currently connected instrument has changed.
void NotifySleepParm(bool SleepParm)
Notify that the sleep parameter has changed.
void NotifyUnitsList(CTHM1176UnitsList UnitsList)
Notify that the list of valid measurement units has changed.
void NotifyRangeParms(sRange< uParm > RangeParms)
Notify that the range parameters have changed.
bool GetImmediateMeasurementPeriod(const sAveraging< uParm > &rAvg, F64 &rPeriod)
Get measurement interval for Immediate Trigger, for a given averaging parameter.
void SetCalibrationOverride(bool Override)
Set whether or not to override the check for instruments whose zero offset should not be calibrated.
sIdentifier GetIdentification(void)
Get the current instrument's identification information.
void NotifyDivisorList(CDivisorList DivisorList)
Notify that the list of divisors associated with each measurement unit for this instrument model has ...
void SendTrigger(void)
Send a bus trigger to the instrument (both slot and signal).
void RelayAveragingParms(sAveraging< uParm > AveragingParms)
Internal signal to relay the averaging parameters to the Instrument Controller.
void RelayUnits(eTHM1176Units Units)
Internal signal to relay the measurement units to the Instrument Controller.
void RelayOutputSelect(sArbitraryMeasurements OutputSelect)
Internal signal to relay the output selection parameters to the Instrument Controller.
void NotifyCommFormat(eCommunicationFormat CommFormat)
Notify that the communication format parameters have changed.
sArbitraryMeasurements OutputSelect
Output selection parameters: select what data elements are returned.
CMeasurement Measurement
Last measurement set returned.
sRange< sBoundedParm > RangeParmBounds
Bounds on range parameters.
static const I32 THM1176_INST_SCANNER_ERROR
Additional error code: Instrument Scanner Error.
void SetRangeParms(sRange< uParm > RangeParms)
Set the range parameters.
void NotifyMeasurement(CMeasurement Measurement)
Notify that a new set of measurements is available.
bool GetSleepParm(void)
Get the sleep parameter.
void SetOperatingMode(eTHM1176OperatingMode OperatingMode)
Set a new operating mode, for example to start measuring.
void NotifyTriggerParms(sInputTrigger< uParm > TriggerParms)
Notify that the trigger parameters have changed.
void StopInstrumentController(void)
Internal signal to stop the Instrument Controller.
void StopInstrumentScanner(void)
Internal signal to stop the Instrument Scanner.
void NotifyInstrumentList(CResourceList InstrumentList)
Notify that the list of detected instruments has changed.
CResourceList GetInstrumentList(void)
Get the list of connected instruments.
void RelayCommFormat(eCommunicationFormat CommFormat)
Internal signal to relay the communications format to the Instrument Controller.
void SetTriggerParms(sInputTrigger< uParm > TriggerParms)
Set the trigger parameters.
tResourceName CurrentInstrument
Currently connected instrument.
sIdentifier Identification
Identification information of currently connected instrument.
CResourceList InstrumentList
List of detected instruments.
CErrorList ErrorList
Current error list.
void StartInstrumentScanner(THM1176_RSRC_MGR_CLS *pResourceManager)
Internal signal to start the Instrument Scanner.
void SetCommFormat(eCommunicationFormat CommFormat)
Set the communication format parameters.
void StartInstrumentController(THM1176_RSRC_MGR_CLS *pResourceManager)
Internal signal to start to Instrument Controller.
void NotifyRangeParmBounds(sRange< sBoundedParm > RangeParmBounds)
Notify that the bounds on range parameters have changed.
tResourceName GetCurrentInstrument(void)
Get VISA resource name of currently connected instrument.
void NotifyOperatingMode(eTHM1176OperatingMode OperatingMode)
Notify that the operating mode has changed.
void NotifyErrorList(CErrorList ErrorList)
Notify that new errors are present.
void Start(void)
Initialize the THM1176 Instrument Manager.
void RelaySleepParm(bool SleepParm)
Internal signal to relay the sleep parameter to the Instrument Controller.
void NotifyRangeList(CFluxList RangeList)
Notify that the list of valid ranges has changed.
void Stop(void)
Shut down the THM1176 Instrument Manager.
eCommunicationFormat CommFormat
Current communication format parameter.
void RelayRangeParms(sRange< uParm > RangeParms)
Internal signal to relay the range parameters to the Instrument Controller.
sRange< uParm > GetRangeParms(void)
Get the range parameters.
sAveraging< uParm > AveragingParms
Current averaging parameters.
sRange< sBoundedParm > GetRangeParmBounds(void)
Get the bounds on range parameters.
void SetCurrentInstrument(tResourceName CurrentInstrument)
Connect a new instrument.
sAveraging< sBoundedParm > GetAveragingParmBounds(void)
Get the bounds on averaging parameters.
CDivisorList GetDivisorList(void)
Get the list of divisors associated with each measurement unit for this instrument model.
CFluxList GetRangeList(void)
Get list of valid ranges for this instrument model.
void NotifyIdentification(sIdentifier Identification)
Notify that the instrument identification information has changed.
void NotifyOutputSelect(sArbitraryMeasurements OutputSelect)
Notify that the output selection parameters have changed.
sInputTrigger< uParm > TriggerParms
Current trigger parameters.
eTHM1176OperatingMode OperatingMode
Current operating mode.
CTHM1176UnitsList UnitsList
List of valid measurement units for this instrument model.
void SetUnits(eTHM1176Units Units)
Set the measurement units.
THM1176 Instrument Scanner class: scan for connected instruments.
void UpdateErrorList(CErrorList ErrorList)
An update to the error list is available.
void Stop(void)
Shut down THM1176 Instrument Scanner.
void Start(THM1176_RSRC_MGR_CLS *pResourceManager)
Initialize THM1176 Instrument Scanner.
void UpdateInstrumentList(CResourceList InstrumentList)
An update to the instrument list is available.
List of measurement units.
List of VISA resource names.
THM1176 instrument class.
bool ParmAveragingGet(sAveraging< uParm > &rAvg)
Fetch the currently selected averaging parameter.
bool GetIdentification(std::string &rIdentification)
Fetch the intrument's identification string.
bool Initiate(bool Continuous=false)
Initiate measurements.
bool GetAllRanges(CFluxList &rRanges)
Fetch all the intrument's ranges.
bool ParmSleepGet(bool &rSleep)
Fetch parameter whether to sleep after each acquisition.
bool ParmRangeGet(sRange< uParm > &rRange)
Fetch currently selected measurement range.
bool ParmTriggerInputGet(sInputTrigger< uParm > &rInputTrig)
Fetch current trigger input parameters.
bool GetFormat(eCommunicationFormat &Format)
Retrieve whether data is returned as text or binary.
const CErrorList & CurrentErrorList()
Fetch current error list.
bool MeasurementsGet(U32 NoMeasurements, CFluxList &rBx, CFluxList &rBy, CFluxList &rBz, eUnits &rUnits, U16 &rTemp, CTimestampList &rTimestampList, sMeasurementConditions *pMeasurementConditions=NULL)
Retrieve measurements: short form.
List of divisors, one per measurement unit.
List of errors returned by the instrument.
List of flux density values.
F32 tFlux
Flux density value, as 32-bit floating-point number.
eCommunicationFormat
Enumeration of possible formats for returned data.
@ kComFormatAscii
Human-legible text.
@ kInputTrigSrcTimer
Timed trigger: start measurement at regular intervals.
@ kInputTrigSrcImmediate
Immediate trigger: start measurement immediately after previous one completes.
@ kInputTrigSrcBus
Bus trigger: start measurement upon USB trigger message.
eUnits
Enumeration of possible measurement units.
std::string tResourceName
IEEE488 resource name.
eTHM1176OperatingMode
Operating modes used to initiate actions or provide status.
@ kTHM1176RestoreZeroOffset
Restore the factory zero-offset setting.
@ kTHM1176CalibrateZeroOffset
Initiate the zero-offset calibration procedure.
@ kTHM1176Reset
Reset instrument.
@ kTHM1176NotConnected
Disconnect instrument.
@ kTHM1176Measure
Start a single measurement.
@ kTHM1176MeasureContinuously
Start a continuous measurement.
@ kTHM1176Idle
Place the instrument in idle mode.
eTHM1176Units
Enumeration of possible measurement units, including "ADC".
@ kmApm
Equivalent H in a vacuum, in mA/m.
@ kkApm
Equivalent H in a vacuum, in kA/m.
@ kApm
Equivalent H in a vacuum, in A/m.
Specify the measurement data to be returned.
void clear()
Clear to default values.
U32 NoMeasurements
Return this number of measurements.
ParmType< U16 > NoPoints
Number of points in block average.
void clear(void)
Clear to default (zero).
DataType Val
Current value.
Error returned by the instrument.
std::string Context
SCPI commands being executed at time of error.
std::string Description
Error description.
Instrument's identification string - parsed version.
void clear(void)
Clear to default.
Summary of the parameters used to make a measurement.
tFlux Range
Current range setting.
sAveraging< uParm > AveragingParms
Averaging parameters.
sInputTrigger< uParm > TriggerParms
Trigger parameters.
Measurement range parameter.
void clear(void)
Clear to default values.
bool Auto
Auto-ranging enabled.
ParmType< tFlux > Range
Measurement range, if auto-ranging is not enabled.