C++Instrument Catalog MFC 1.2
Metrolab C++InstrumentCatalog for MFC
Loading...
Searching...
No Matches
InstrumentCatalog.h
Go to the documentation of this file.
1
5
6#pragma once
7
8#include "CatalogInterface.h"
9#include "OSDefines.h"
10
11#include <string>
12#include <vector>
13#include <iostream>
14#include <sstream>
15#include <iomanip>
16#include <ctime>
17
18using namespace MTL;
20
21namespace MTL {
23 public:
24 //----------------------------------------------------------------------//
25 // Types //
26 //----------------------------------------------------------------------//
27 typedef std::time_t tPosixTime; // Unix Time / Posix Time / Epoch time e.g. defined as the number of seconds that have elapsed since 00:00:00 Coordinated Universal Time (UTC), Thursday, 1 January 1970
28 typedef std::string tISO8601DateTime; // Date and Time in the ISO8601 YYYY-mm-ddTHH:MM:SSZ format (UTC Date and time)
29
30 typedef std::string tInstrumentLabel; // Instrument name to be presented to the customer (also called "pretty name")
31 typedef std::string tInstrumentUniqueID; // Unique instrument ID to identify the instrument (corresponds to the VISA resource name)
32 enum class eConnectionInterface { // Type of interface for a specific connection
33 kUnknown, // Unknown interface
34 kUSB, // USB interface
35 kEthernet, // Ethernet interface
36 kSerial // Serial interface
37 };
38 struct sInstrumentConnection { // Describes an available connection to an instrument
39 tInstrumentLabel Label; // Instrument label
40 tInstrumentUniqueID UniqueID; // Insturment unique ID
45 inline bool operator==(const sInstrumentConnection& other) const
46 {
47 return (UniqueID == other.UniqueID);
48 }
49 inline bool isEmpty() const
50 {
52 }
53 };
54 typedef std::vector<sInstrumentConnection> tInstrumentList; // List of instrument names
55 enum class eSerialBaudrate { // Serial baudrate
56 k2400 = 2400,
57 k4800 = 4800,
58 k9600 = 9600,
59 k19200 = 19200,
60 k28800 = 28800,
61 k38400 = 38400,
62 k57600 = 57600,
63 k115200 = 115200
64 };
65 enum class eSerialDataBits { // Number of data bits for the serial communication
66 k7 = 7,
67 k8 = 8
68 };
69 enum class eSerialParity { // Parity configuration for the serial communication
71 };
72 enum class eSerialStopBits { // Stop bit configuration for the serial communication
75 };
76 enum class eSerialHandshake { // Handshake configuration for the serial communication
78 kXonXoff, // Software Xon/Xoff Handshake
79 kHardware // Hardware CTS RTS Handshake
80 };
81 struct sMFC3045SerialPortSettings { // Sets serial port settings
82 eSerialBaudrate Baudrate; // [bd] Speed of the serial communication
83 eSerialDataBits DataBits; // [-] Number of transmitted bits per packet
84 eSerialParity Parity; // [-] Parity configuration of the serial communication
85 eSerialStopBits StopBits; // [-] Stop bit configuration of the serial communication
86 eSerialHandshake Handshake; // [-] Handshake configuration of the serial communication
87 U32 DelayWrRd; // [ms] Delay for Write/Read serial communication. Default = 10ms, Minimum = 0ms, Maximum = 100ms
96 bool operator==(const sMFC3045SerialPortSettings & other) const
97 { return ( Baudrate == other.Baudrate &&
98 DataBits == other.DataBits && Parity == other.Parity &&
99 StopBits == other.StopBits && Handshake == other.Handshake &&
100 DelayWrRd == other.DelayWrRd);}
101 bool operator!=(const sMFC3045SerialPortSettings & other) const
102 { return !operator==(other); }
103 };
104 enum class eInstrumentType { // Type of the instrument
108 };
109 struct sInstrumentInformation { // Returns information about the current instrument
110 sInstrumentConnection InstrumentConnection; // [-] Connection used for this instrument
111 eInstrumentType Type; // [-] Type of the instrument
112 std::string SerialNumber; // [-] Serial Number of the instrument
113 std::string Description; // [-] Description of the instrument (can contain firmware versions, options, etc...)
114 tISO8601DateTime CalibrationDate; // [-] Date of the last calibration in the ISO8601 YYYY-mm-dd format (UTC Date)
118 };
119 struct sInstrumentConfiguration { // Returns information about the current configuration of the instrument
120 F64 AcquisitionPeriod; // [s] - NMR signal acquisition period
124 };
125 struct sFCAInformation { // FCA peripheral information
126 std::string SerialNumber; // [-] Serial Number of the peripheral
127 std::string Description; // [-] Description of the peripheral
128 U16 FCAFwVersion; // [-] Firmware version of the peripheral, if exists. If none => 0
132 };
133
134 struct sProbeInformation { // Returns information about the current selected probe
135 U8 ProbeNumber; // [-] Number of the probe
136 F64 FreqMin; // [MHz] Minimal frequency of the probe
137 F64 FreqMax; // [MHz] Maximum frequency of the probe
139 : ProbeNumber(0), FreqMin(DPqNaN), FreqMax(DPqNaN)
140 {}
141 };
142 enum class eProbeArrayType { // Type of the Probe-Array
147 };
148 struct sProbeArrayInformation { // Returns information about the current probe-array
149 eProbeArrayType Type; // [-] Type of the Probe-Array
150 std::string SerialNumber; // [-] Serial Number of the Probe-Array
151 std::string Description; // [-] Description of the Probe-Array
152 tISO8601DateTime NormalizationDate; // [-] Date of the last normalization in the ISO8601 YYYY-mm-dd format (UTC Date)
153 F64 FreqMin; // [MHz] Minimal frequency of the probe-array
154 F64 FreqMax; // [MHz] Maximum frequency of the probe-array
155 F64 FreqCentral; // [MHz] Central frequency of the probe-array
156 F64 GyroRatio; // [MHz/T] Gyromagnetic ratio. Should be proton gyro ratio. Results are normalized with this value
157 std::vector<sProbeInformation> ProbeList; // List of the contained probes
158 sFCAInformation FCAInfo; // FCA peripheral information if exists
161 SerialNumber(""),
162 Description(""),
164 FreqMin(DPqNaN),
165 FreqMax(DPqNaN),
166 FreqCentral(DPqNaN),
167 GyroRatio(DPqNaN),
168 ProbeList(),
169 FCAInfo()
170 {}
171 size_t NbProbes() const
172 { return ProbeList.size(); }
173 void clear()
174 {
176 SerialNumber.clear();
177 Description.clear();
178 NormalizationDate.clear();
179 FreqMin = DPqNaN;
180 FreqMax = DPqNaN;
181 FreqCentral = DPqNaN;
182 GyroRatio = DPqNaN;
183 ProbeList.clear();
185 }
186 };
187 enum class eOperatingMode {
188 kIdle, // Instrument is not operating
189 kSearch, // Instrument performs a unique "coarse" search operation over a limited set of probes to determine the global field value.
190 kMeasure // Instrument performs measurement (including per probe small range search) according to probe selection
191 };
192 enum class eRepeatMode {
193 kSingle, // Operates a single time
194 kContinuous // Operates continuously until requested to stop
195 };
197 kProbeArray, // Probe-array is selected. Multiple probes are used
198 kSingleProbe // A single probe in the probe-array is selected
199 };
201 {
202 eMeasureSelectionMode SelectionMode; // [-] Whether we use a single or multiple probes for the measure operation
203 U8 ProbeNumber; // [-] Number of the selected probe, when SelectionMode is kSingleProbe
208 : SelectionMode(SelMode), ProbeNumber(PrbNb)
209 {}
210 bool operator==(const sMeasureProbeSelection & other) const
211 { return (SelectionMode == other.SelectionMode && ProbeNumber == other.ProbeNumber); }
212 bool operator!=(const sMeasureProbeSelection & other) const
213 { return !operator==(other); }
214 };
215 struct sInstrumentState { // Controls the state of the instrument, with associated operating parameters
216 eOperatingMode OperatingMode; // [-] Requested operating mode
217 eRepeatMode RepeatMode; // [-] Requested repeat mode
218 sMeasureProbeSelection ProbeSelection; // [-] Probe selection (relevant only for measurement operations)
219 F64 FreqMin; // [MHz] Minimal frequency used for the specified mode
220 F64 FreqMax; // [MHz] Maximum frequency used for the specified mode
221 U32 NbAveragedMeasurements; // [-] Number of repeated measurements used for the average. Limited value from 1 to 1500 for MFC2046 and from 2 to 1500 for MFC3045.
225 };
226 enum class eInstrumentState {
227 kWaitingForPA, // There is currently no connected probe-array
228 kReady, // There is a connected probe-array which is currently not operating
229 kSearching, // The instrument is currently searching
230 kMeasuring // The instrument is currently measuring
231 };
232 struct sInstrumentStatus { // Reflects the current instrument status
233 eInstrumentState State; // [-] Current instrument state
234 U8 SearchProgress; // [%] Progress of the search (if any) from 0 to 100%
239 : State(St), SearchProgress(SPR)
240 {}
241 };
242 enum class eRemoteBoxTrigger {
243 kRemoteBoxTrigger // Informs that Remote box start button has been pressed
244 };
246 kRemoteBusyLedOff, // Remote Led is turned OFF
247 kRemoteBusyLedMeasuring, // Remote Led is turned ON when measuring and turned OFF otherwise
248 kRemoteBusyLedOffEndMeas, // Remote Led is turned ON immediately and turned OFF automatically with the end of measurement
249 kRemoteBusyLedOn, // Remote Led is turned ON
250 kRemoteBusyLedBlinkSlow, // Remote Led is blinking slowly (about 1Hz)
251 kRemoteBusyLedBlinkFast // Remote Led is blinking quickly (about 2Hz)
252 };
254 F64 Freq; // [MHz] Frequency returned by the search operation
255 F32 StdDev; // [ppm] Standard deviation, relatively to Freq
257 : Freq(DPqNaN), StdDev(SPqNaN)
258 {}
259 };
261 U8 ProbeNumber; // [-] Number of the probe for this measurement
262 F64 Freq; // [MHz] Measured frequency
263 U32 NbValidMeasurements; // [-] Number of valid measurements (among the requested number of averaged measurements)
264 F32 StdDev; // [ppm] Standard deviation, relatively to Freq
266 : ProbeNumber(0), Freq(DPqNaN), NbValidMeasurements(0), StdDev(SPqNaN)
267 {}
268 };
269 typedef std::vector<sMeasurement> tMeasurementList;
271 U64 Timestamp; // [ms] Measurement time, relative to startup of the instrument
272 tMeasurementList MeasurementList; // [-] List of the obtained measurements
276 };
278 kReadRAM, // Read the current Normalization table from the temporary memory
279 kReadROM, // Read the Normalization table from the PA EEPROM
280 kWriteRAM, // Write a new Normalization table to the temporary memory
281 kWriteROM // Write a new Normalization table to the PA EEPROM
282 };
283 typedef F32 tNormalizationCorrection; // [MHz] Frequency error correction to be applied for normalization of a probe. Fcorrected = Fmeasured + FCorrection
284 typedef std::vector<tNormalizationCorrection> tNormalizationTable; // [MHz] List of normalization correction values for each probe of the probe-array.
286 eNormalizationAccess Access; // Whether the normalization is accessed in read or write
287 tNormalizationTable Table; // Table of correction values according to the reference
288 bool Succeeded; // Whether the operation has succeeded or not
292 };
293 struct sLicenseInformation { // Returns information about the current Metrolab license
294 std::string Description; // [-] Description of the license (can contain versions, options, etc...)
295 std::string SerialNumber; // [-] Serial Number of the usb license dongle
296 U16 ActiveModules; // [-] License active Module number (with bit set from 0 to 15 for module 0 to 15 when active)
297 tISO8601DateTime ExpirationUtcDate; // [-] License expiration date and time in the ISO8601 UTC format (YYYY-MM-DDTHH:MM:SSZ)
298 bool LicenseIsExpired; // [-] License date is expired. ExpirationUtcDate value is not valid and undetermined
302 };
303 struct sLicenseUpdate { // Returns information about the current Metrolab license
304 std::string FilePath; // [-] File path of update file
305 std::string StatusMessage; // [-] Satus message on update operation
306 bool UpdateSucceeded; // [-] Update succeeded
308 : FilePath(""), StatusMessage(""), UpdateSucceeded(false)
309 {}
310 };
311 enum class eErrorLevel {
312 kFatal, // Fatal error. Should not occur, program may crash
313 kError, // Error. The requested operation cannot keep executing
314 kWarning // Warning. An error occured but requested operation will continue to execute
315 };
316 static constexpr I32 WARNING_ERROR_CODE = 1; // Instrument's main Warning error code
317 static constexpr I32 UNDEFINED_ERROR_CODE = 0;
318 static constexpr I32 ERROR_CODE = -2; // Instrument's main Error code
319 static constexpr I32 FATAL_ERROR_CODE = -1; // Instrument's main Fatal error code
320 struct sError {
321 eErrorLevel Level; // Error level
322 I32 Code; // Code ID of the error. Positive values are warnings, negative values are errors
323 std::string Description; // Description of the error
324 std::string Source; // Information about the source of the error
328 sError(eErrorLevel Lvl, I32 Cde, std::string Dsc, std::string Src)
329 : Level(Lvl), Code(Cde), Description(Dsc), Source(Src)
330 {}
331 };
333 bool AngleSensorAvailable; // [-] Whether an angle sensor is available or not
334 F32 Angle; // [deg] Current measured angular position of the probe-array
336 : AngleSensorAvailable(false), Angle(SPqNaN)
337 {}
338 };
339 enum class eLogLevel {
340 kCritical, // An error that causes the software to crash
341 kDebug, // Message for debug purpose
342 kInfo, // General information message that may remain logged in release program
343 kWarning // Something wrong happened but doesn't prevent the software to keep running
344 };
345 struct sLogMessage {
346 eLogLevel Level; // Message level
347 std::string Context; // Message context ("Module.Sub-module.sub-module...")
348 std::string Message; // Message
349 std::string Location; // Origin of the message (If any. e.g. "FileName:line")
353 sLogMessage(const eLogLevel & rLevel, const std::string & rContext, const std::string & rMessage, const std::string & rLocation)
354 : Level(rLevel), Context(rContext), Message(rMessage), Location(rLocation)
355 {}
356 };
357
358
359 //----------------------------------------------------------------------//
360 // Dump Utilities //
361 //----------------------------------------------------------------------//
362 static inline std::string l_Dump(const tInstrumentList & rInsList)
363 {
364 std::ostringstream l_ss;
365 for (auto l_i = rInsList.begin(); l_i != rInsList.end(); l_i++)
366 {
367 l_ss << l_Dump(*l_i);
368 }
369 return l_ss.str();
370 }
371 static inline std::string l_Dump(const sInstrumentConnection & rInsConnection)
372 {
373 std::ostringstream l_ss;
374 l_ss << rInsConnection.Label << "(" << rInsConnection.UniqueID << ")";
375 l_ss << ( rInsConnection.Interface == eConnectionInterface::kUSB ? " (USB)" :
376 rInsConnection.Interface == eConnectionInterface::kEthernet ? " (Eth)" :
377 rInsConnection.Interface == eConnectionInterface::kSerial ? " (Serial)" : "(Unkn)") << std::endl;
378 return l_ss.str();
379 }
380 static inline std::string l_Dump(const sMFC3045SerialPortSettings & rSerialSett)
381 {
382 std::ostringstream l_ss;
383 l_ss << "Baudrate: " << (unsigned long)rSerialSett.Baudrate << " | ";
384 l_ss << "DataBits: " << (unsigned long)rSerialSett.DataBits << " | ";
385 l_ss << "Parity: " << ((rSerialSett.Parity == eSerialParity::kNone) ? "None" :
386 (rSerialSett.Parity == eSerialParity::kOdd) ? "Odd" :
387 (rSerialSett.Parity == eSerialParity::kEven) ? "Even" : "") << " | ";
388 l_ss << "StopBits: " << ((rSerialSett.StopBits == eSerialStopBits::k1) ? "1" :
389 (rSerialSett.StopBits == eSerialStopBits::k2) ? "2" : "") << " | ";
390 l_ss << "Handshake: " << ((rSerialSett.Handshake == eSerialHandshake::kNone) ? "None" :
391 (rSerialSett.Handshake == eSerialHandshake::kXonXoff) ? "XonXoff" :
392 (rSerialSett.Handshake == eSerialHandshake::kHardware) ? "Hardware" : "") << " | ";
393 l_ss << "WrRdDelay ms: " << (unsigned long)rSerialSett.DelayWrRd << std::endl;
394 return l_ss.str();
395 }
396 static inline std::string l_Dump(const sInstrumentInformation & rInsInfo)
397 {
398 std::ostringstream l_ss;
399 l_ss << "Instrument Information: Type: " << ((rInsInfo.Type == eInstrumentType::kMFC3045) ? "MFC3045" :
400 (rInsInfo.Type == eInstrumentType::kPT2026) ? "PT2026" : " ") << " | ";
401 l_ss << "Serial Number: " << rInsInfo.SerialNumber << " | ";
402 l_ss << "Calibration Date: " << rInsInfo.CalibrationDate << " | ";
403 l_ss << "Connection: " << ((rInsInfo.InstrumentConnection.Interface == eConnectionInterface::kUSB) ? "USB" :
405 (rInsInfo.InstrumentConnection.Interface == eConnectionInterface::kEthernet) ? "Ethernet" : "Unknown") << std::endl;
406 l_ss << "Description: " << rInsInfo.Description << std::endl;
407 return l_ss.str();
408 }
409 static inline std::string l_Dump(const sInstrumentConfiguration & rInsConf)
410 {
411 std::ostringstream l_ss;
412 l_ss << "Acquisition Period: " << rInsConf.AcquisitionPeriod << std::endl;
413 return l_ss.str();
414 }
415 static inline std::string l_Dump(const sProbeArrayInformation & rPAInfo)
416 {
417 std::ostringstream l_ss;
418 l_ss << "Serial Number: " << rPAInfo.SerialNumber << std::endl;
419 l_ss << "Description: " << rPAInfo.Description << std::endl;
420 l_ss << "Normalization Date: " << rPAInfo.NormalizationDate << std::endl;
421 l_ss << "FreqMin: " << rPAInfo.FreqMin << std::endl;
422 l_ss << "FreqMax: " << rPAInfo.FreqMax << std::endl;
423 l_ss << "FreqCentral: " << rPAInfo.FreqCentral << std::endl;
424 l_ss << "GyroRatio: " << rPAInfo.GyroRatio << std::endl;
425 l_ss << "ProbeList: (No. probes = " << rPAInfo.NbProbes() << ")" << std::endl;
426 for (auto l_it = rPAInfo.ProbeList.begin(); l_it != rPAInfo.ProbeList.end(); l_it++)
427 {
428 l_ss << " " << (unsigned int)l_it->ProbeNumber << " | " << l_it->FreqMin << " -> " << l_it->FreqMax << std::endl;
429 }
430 return l_ss.str();
431 }
432 static inline std::string l_Dump(const sProbeArrayAngle & rPAAngle)
433 {
434 std::ostringstream l_ss;
435 if (rPAAngle.AngleSensorAvailable)
436 l_ss << "Angle: " << rPAAngle.Angle << std::endl;
437 else
438 l_ss << "No PA angle sensor" << std::endl;
439 return l_ss.str();
440 }
441 static inline std::string l_Dump(const sInstrumentState & rInsState)
442 {
443 std::ostringstream l_ss;
444 l_ss << "OperatingMode: " << ( rInsState.OperatingMode == eOperatingMode::kIdle ? "Idle" :
445 rInsState.OperatingMode == eOperatingMode::kSearch ? "Search" :
446 rInsState.OperatingMode == eOperatingMode::kMeasure ? "Measure" : "") << std::endl;
447 l_ss << "RepeatMode: " << ( rInsState.RepeatMode == eRepeatMode::kSingle ? "Single" :
448 rInsState.RepeatMode == eRepeatMode::kContinuous ? "Continuous" : "") << std::endl;
450 l_ss << "Probe Array selected" << std::endl;
451 else
452 l_ss << "Selected probe: " << (unsigned int)rInsState.ProbeSelection.ProbeNumber << std::endl;
453 l_ss << "FreqMin: " << rInsState.FreqMin << std::endl;
454 l_ss << "FreqMax: " << rInsState.FreqMax << std::endl;
455 l_ss << "NbAveragedMeasurements: " << (unsigned int)rInsState.NbAveragedMeasurements << std::endl;
456 return l_ss.str();
457 }
458 static inline std::string l_Dump(const sInstrumentStatus & rInsStatus)
459 {
460 std::ostringstream l_ss;
461 l_ss << "State: " << ( rInsStatus.State == eInstrumentState::kWaitingForPA ? "WaitingForPA" :
462 rInsStatus.State == eInstrumentState::kReady ? "Ready" :
463 rInsStatus.State == eInstrumentState::kSearching ? "Searching" :
464 rInsStatus.State == eInstrumentState::kMeasuring ? "Measuring" : "") << " | ";
465 l_ss << "SearchProgress: " << (unsigned int)rInsStatus.SearchProgress << std::endl;
466 return l_ss.str();
467 }
468 static inline std::string l_Dump(const sSearchResult & rSearchResult)
469 {
470 std::ostringstream l_ss;
471 l_ss << "Frequency: " << rSearchResult.Freq << " | ";
472 l_ss << "StdDev: " << rSearchResult.StdDev << std::endl;
473 return l_ss.str();
474 }
475 static inline std::string l_Dump(const sMeasurementResults & rMeasResult)
476 {
477 std::ostringstream l_ss;
478 l_ss << "Timestamp: " << rMeasResult.Timestamp << std::endl;
479 for (auto l_it = rMeasResult.MeasurementList.begin(); l_it != rMeasResult.MeasurementList.end(); l_it++)
480 l_ss << " ProbeNo.: " << (unsigned int)l_it->ProbeNumber << " Freq: " << l_it->Freq << " Nb.Valid: " << (unsigned int)l_it->NbValidMeasurements << " SDev: " << l_it->StdDev << std::endl;
481 return l_ss.str();
482 }
483 static inline std::string l_Dump(const tISO8601DateTime & rDateTime)
484 {
485 std::ostringstream l_ss;
486 l_ss << "Date: " << rDateTime << std::endl;
487 return l_ss.str();
488 }
489 static inline std::string l_Dump(const sNormalization & rNormalization)
490 {
491 std::ostringstream l_ss;
492 l_ss << ( rNormalization.Access == eNormalizationAccess::kReadRAM ? "ReadRAM Access" :
493 rNormalization.Access == eNormalizationAccess::kReadROM ? "ReadROM Access" :
494 rNormalization.Access == eNormalizationAccess::kWriteRAM ? "WriteRAM Access" :
495 rNormalization.Access == eNormalizationAccess::kWriteROM ? "WriteROM Access" : "") << std::endl;
496 for (auto l_it = rNormalization.Table.begin(); l_it != rNormalization.Table.end(); l_it++)
497 l_ss << *l_it << std::endl;
498 l_ss << std::endl;
499 return l_ss.str();
500 }
501 static inline std::string l_Dump(const sLicenseInformation & rLicenseInfo)
502 {
503 std::ostringstream l_ss;
504 l_ss << "Description: " << rLicenseInfo.Description << " | ";
505 l_ss << "Serial Number: " << rLicenseInfo.SerialNumber << " | ";
506 l_ss << "Expiration Date: " << rLicenseInfo.ExpirationUtcDate << std::endl;
507 return l_ss.str();
508 }
509 static inline std::string l_Dump(const sLicenseUpdate & rLicenseUpdate)
510 {
511 std::ostringstream l_ss;
512 l_ss << "FilePath: " << rLicenseUpdate.FilePath << " | ";
513 l_ss << "Update status: " << rLicenseUpdate.StatusMessage << std::endl;
514 return l_ss.str();
515 }
516 static inline std::string l_Dump(const eRemoteBoxBusyLedState & rRBBusyLedState)
517 {
518 std::ostringstream l_ss;
519 l_ss << ( rRBBusyLedState == eRemoteBoxBusyLedState::kRemoteBusyLedOff ? "Remote busy led off" :
520 rRBBusyLedState == eRemoteBoxBusyLedState::kRemoteBusyLedMeasuring ? "Remote busy led on when measuring" :
521 rRBBusyLedState == eRemoteBoxBusyLedState::kRemoteBusyLedOffEndMeas ? "Remote busy led clears after measuring" :
522 rRBBusyLedState == eRemoteBoxBusyLedState::kRemoteBusyLedOn ? "Remote busy led on" :
523 rRBBusyLedState == eRemoteBoxBusyLedState::kRemoteBusyLedBlinkSlow ? "Remote busy led blink slow" :
524 rRBBusyLedState == eRemoteBoxBusyLedState::kRemoteBusyLedBlinkFast ? "Remote busy led blink fast" : "") << std::endl;
525 return l_ss.str();
526 }
527 static inline std::string l_Dump(const sError & rError)
528 {
529 std::ostringstream l_ss;
530 l_ss << "Error : " << ( rError.Level == eErrorLevel::kFatal ? "Fatal " :
531 rError.Level == eErrorLevel::kError ? "Error " :
532 rError.Level == eErrorLevel::kWarning ? "Warning " : "");
533 l_ss << rError.Code << " : " << rError.Description << " | @ " << rError.Source << std::endl;
534 return l_ss.str();
535 }
536 static inline std::string l_Dump(const sLogMessage & rLogMessage)
537 {
538 std::ostringstream l_ss;
539 l_ss << "Level: " << ( rLogMessage.Level == eLogLevel::kCritical ? "Critical" :
540 rLogMessage.Level == eLogLevel::kDebug ? "Debug" :
541 rLogMessage.Level == eLogLevel::kInfo ? "Info" :
542 rLogMessage.Level == eLogLevel::kWarning ? "Warning" : "") << std::endl;
543 l_ss << "Context: " << rLogMessage.Context << std::endl;
544 l_ss << "Message: \"" << rLogMessage.Message << "\"" << std::endl;
545 l_ss << "@ " << rLogMessage.Location << std::endl;
546 return l_ss.str();
547 }
548
549
550
553
554 protected:
555 //----------------------------------------------------------------------//
556 // Variables //
557 //----------------------------------------------------------------------//
558 //------------------------------------------//
559 // Connection
563 //------------------------------------------//
564 // Instrument / Probe-Array information
569 //------------------------------------------//
570 // Instrument / Probe-Array control and status
575 //------------------------------------------//
576 // Results
579 //------------------------------------------//
580 // Others
589
590 public:
594
595 }; // class CInstrumentCatalog
596
598 {
599 public:
600 //----------------------------------------------------------------------//
601 // Controls and Observers //
602 //----------------------------------------------------------------------//
603 //------------------------------------------//
604 // Connection
605 // What? Signals changes of the list of available PT2026/MFC3045 instruments.
606 // When? On startup, then, every time a change is detected (new or lost instrument).
608 // What? Controls which instrument to connect to, among the list received in oInstrumentList.
609 // When? Before performing any operation.
611 // What? Configures the serial port settings for MFC3045 detection and communication.
612 // When? Before connecting to an MFC3045 instrument.
614 //------------------------------------------//
615 // Instrument / Probe-Array information
616 // What? Returns information about the instrument we are connected to.
617 // When? When a new instrument is connected through cInstrumentCurrent.
619 // What? Returns instrument configuration.
620 // When? When a new probe-array is detected.
622 // What? Returns probe-array information.
623 // When? Every time a new probe-array is detected, including after first detection following instrument
624 // connection with cInstrumentCurrent.
626 // What? Signals current probe-array angle. (Not supported for now)
627 // When? After detection of a new probe-array, and when probe-array angle changes.
629 //------------------------------------------//
630 // Instrument / Probe-Array control and status
631 // What? Controls the desired state of the instrument.
632 // When? When a new operation (search or measurement) is desired, or to abort current operation.
633 // In principle, a search is requested once to determine the global field value and its standard deviation.
634 // This results serves to determine the working range for the next measurement operations (min and max frequency bounds).
635 // Then, measurement operations are requested over the whole probe-array or on a single probe.
637 // What? Returns current status of the instrument.
638 // When? After connecting to an instrument through cInstrumentCurrent,
639 // - signals whether a PA is connected or not
640 // - signals current instrument operation after requesting one through cInstrumentState
642 // What? Returns remote box trigger events.
643 // When? When the remote box start button is pressed.
645 // What? Controls remote box busy led state.
646 // When? After connecting to a new instrument.
648 //------------------------------------------//
649 // Results
650 // What? Returns search results.
651 // When? When a search operation is initiated through cInstrumentState,
652 // - if an NMR signal is found on at least one probe over the ones configured for the search (see cInstrumentState ProbeSelection), the mean frequency and its standard deviation is returned.
653 // - if no NMR signal was found, NaNs (Not A Number) are returned
655 // What? Returns measurement results.
656 // When? When a measurement operation is initiated through cInstrumentState,
657 // measurement results are returned according to the probe selection in cInstrumentState ProbeSelection.
658 // Whatever an NMR signal if found or not, a valid frequency or a NaN will be returned for every expected probe result.
660 //------------------------------------------//
661 // Normalization
662 // /!\ /!\ /!\ For detailed normalization information and training, please contact Metrolab. /!\ /!\ /!\
663 // What? Requests a read or write access to a normalization table.
664 // When? During normalization process, tables are set in RAM and validated against measurements, then confirmed in ROM.
666 // What? Returns normalization table or write status according to last request in cNormalizationRequest.
667 // When? After requesting an access to a normalization table in cNormalizationRequest.
669 // What? Sets licence information.
671 // What? Returns licence information.
673 // What? Sets the update of the licence.
675 // What? Returns the licence update status.
677 //------------------------------------------//
678 // Others
679 // What? Signals a new error.
680 // When? Anytime during the program execution.
682 // What? Returns logging information. (for debug purposes)
683 // When? Anytime during the program execution.
685
687 : oInstrumentList(rCatalog.vInstrumentList),
688 cInstrumentCurrent(rCatalog.vInstrumentCurrent),
689 cMFC3045SerialPortSettings(rCatalog.vMFC3045SerialPortSettings),
690 oInstrumentInformation(rCatalog.vInstrumentInformation),
691 oInstrumentConfiguration(rCatalog.vInstrumentConfiguration),
692 oProbeArrayInformation(rCatalog.vProbeArrayInformation),
693 oProbeArrayAngle(rCatalog.vProbeArrayAngle),
694 cInstrumentState(rCatalog.vInstrumentState),
695 oInstrumentStatus(rCatalog.vInstrumentStatus),
696 oRemoteBoxTriggerEvent(rCatalog.vRemoteBoxTriggerEvent),
697 cRemoteBoxBusyLedState(rCatalog.vRemoteBoxBusyLedState),
698 oSearchResult(rCatalog.vSearchResult),
699 oMeasurementResults(rCatalog.vMeasurementResults),
700 cNormalizationRequest(rCatalog.vNormalizationRequest),
701 oNormalizationReturned(rCatalog.vNormalizationReturned),
702 cLicenseInfoRequest(rCatalog.vLicenseInfoRequest),
703 oLicenseInfoReturned(rCatalog.vLicenseInfoReturned),
704 cLicenseUpdateRequest(rCatalog.vLicenseUpdateRequest),
705 oLicenseUpdateReturned(rCatalog.vLicenseUpdateReturned),
706 oError(rCatalog.vError),
707 oLogMessage(rCatalog.vLogMessage)
708 {}
709 };
710
712 {
713 public:
714 //----------------------------------------------------------------------//
715 // Controls and Observers //
716 //----------------------------------------------------------------------//
717 //------------------------------------------//
718 // Connection
722 //------------------------------------------//
723 // Instrument / Probe-Array information
728 //------------------------------------------//
729 // Instrument / Probe-Array control and status
734 //------------------------------------------//
735 // Results
738 //------------------------------------------//
739 // Others
748
750 : cInstrumentList(rCatalog.vInstrumentList),
751 oInstrumentCurrent(rCatalog.vInstrumentCurrent),
752 oMFC3045SerialPortSettings(rCatalog.vMFC3045SerialPortSettings),
753 cInstrumentInformation(rCatalog.vInstrumentInformation),
754 cInstrumentConfiguration(rCatalog.vInstrumentConfiguration),
755 cProbeArrayInformation(rCatalog.vProbeArrayInformation),
756 cProbeArrayAngle(rCatalog.vProbeArrayAngle),
757 oInstrumentState(rCatalog.vInstrumentState),
758 cInstrumentStatus(rCatalog.vInstrumentStatus),
759 cRemoteBoxTriggerEvent(rCatalog.vRemoteBoxTriggerEvent),
760 oRemoteBoxBusyLedState(rCatalog.vRemoteBoxBusyLedState),
761 cSearchResult(rCatalog.vSearchResult),
762 cMeasurementResults(rCatalog.vMeasurementResults),
763 oNormalizationRequest(rCatalog.vNormalizationRequest),
764 cNormalizationReturned(rCatalog.vNormalizationReturned),
765 oLicenseInfoRequest(rCatalog.vLicenseInfoRequest),
766 cLicenseInfoReturned(rCatalog.vLicenseInfoReturned),
767 oLicenseUpdateRequest(rCatalog.vLicenseUpdateRequest),
768 cLicenseUpdateReturned(rCatalog.vLicenseUpdateReturned),
769 cError(rCatalog.vError),
770 cLogMessage(rCatalog.vLogMessage)
771 {}
772 };
773} // namespace MTL
Platform Dependent Definitions.
std::vector< tNormalizationCorrection > tNormalizationTable
static std::string l_Dump(const sError &rError)
friend class CInstrManCatalogInterface
CVariable< sLogMessage > vLogMessage
static std::string l_Dump(const sProbeArrayInformation &rPAInfo)
CVariable< sSearchResult > vSearchResult
static constexpr I32 FATAL_ERROR_CODE
static std::string l_Dump(const sInstrumentConnection &rInsConnection)
static std::string l_Dump(const tISO8601DateTime &rDateTime)
CVariable< sInstrumentConfiguration > vInstrumentConfiguration
static std::string l_Dump(const sMFC3045SerialPortSettings &rSerialSett)
static constexpr I32 UNDEFINED_ERROR_CODE
static constexpr I32 ERROR_CODE
CVariable< sMeasurementResults > vMeasurementResults
static std::string l_Dump(const tInstrumentList &rInsList)
CVariable< sInstrumentStatus > vInstrumentStatus
CVariable< sInstrumentState > vInstrumentState
static std::string l_Dump(const sProbeArrayAngle &rPAAngle)
static std::string l_Dump(const sInstrumentState &rInsState)
CVariable< sProbeArrayInformation > vProbeArrayInformation
CVariable< sInstrumentInformation > vInstrumentInformation
static std::string l_Dump(const sLicenseUpdate &rLicenseUpdate)
std::vector< sMeasurement > tMeasurementList
std::vector< sInstrumentConnection > tInstrumentList
static std::string l_Dump(const sInstrumentConfiguration &rInsConf)
static std::string l_Dump(const sLogMessage &rLogMessage)
CVariable< sProbeArrayAngle > vProbeArrayAngle
CVariable< sMFC3045SerialPortSettings > vMFC3045SerialPortSettings
static std::string l_Dump(const sNormalization &rNormalization)
CVariable< tInstrumentList > vInstrumentList
CVariable< sInstrumentConnection > vInstrumentCurrent
CVariable< sLicenseInformation > vLicenseInfoRequest
CVariable< sLicenseUpdate > vLicenseUpdateReturned
static std::string l_Dump(const sInstrumentInformation &rInsInfo)
CVariable< eRemoteBoxBusyLedState > vRemoteBoxBusyLedState
CVariable< eRemoteBoxTrigger > vRemoteBoxTriggerEvent
CVariable< sLicenseUpdate > vLicenseUpdateRequest
static std::string l_Dump(const sLicenseInformation &rLicenseInfo)
static std::string l_Dump(const sMeasurementResults &rMeasResult)
static std::string l_Dump(const sSearchResult &rSearchResult)
static std::string l_Dump(const eRemoteBoxBusyLedState &rRBBusyLedState)
CVariable< sNormalization > vNormalizationReturned
CVariable< sError > vError
static constexpr I32 WARNING_ERROR_CODE
CVariable< sLicenseInformation > vLicenseInfoReturned
static std::string l_Dump(const sInstrumentStatus &rInsStatus)
CVariable< sNormalization > vNormalizationRequest
bool operator==(const sInstrumentConnection &other) const
sInstrumentConnection(tInstrumentLabel lbl="", tInstrumentUniqueID id="", eConnectionInterface itf=eConnectionInterface::kUnknown)
bool operator==(const sMFC3045SerialPortSettings &other) const
bool operator!=(const sMFC3045SerialPortSettings &other) const
bool operator==(const sMeasureProbeSelection &other) const
bool operator!=(const sMeasureProbeSelection &other) const
sMeasureProbeSelection(eMeasureSelectionMode SelMode, U8 PrbNb)
sInstrumentStatus(eInstrumentState St, U8 SPR)
sError(eErrorLevel Lvl, I32 Cde, std::string Dsc, std::string Src)
sLogMessage(const eLogLevel &rLevel, const std::string &rContext, const std::string &rMessage, const std::string &rLocation)
CObserver< CInstrumentCatalog::sNormalization > oNormalizationReturned
CObserver< CInstrumentCatalog::sLicenseUpdate > oLicenseUpdateReturned
CObserver< CInstrumentCatalog::eRemoteBoxTrigger > oRemoteBoxTriggerEvent
CObserver< CInstrumentCatalog::sSearchResult > oSearchResult
CObserver< CInstrumentCatalog::sMeasurementResults > oMeasurementResults
CObserver< CInstrumentCatalog::sLogMessage > oLogMessage
CControl< CInstrumentCatalog::sLicenseUpdate > cLicenseUpdateRequest
CControl< CInstrumentCatalog::sMFC3045SerialPortSettings > cMFC3045SerialPortSettings
CObserver< CInstrumentCatalog::sLicenseInformation > oLicenseInfoReturned
CObserver< CInstrumentCatalog::tInstrumentList > oInstrumentList
CObserver< CInstrumentCatalog::sError > oError
CObserver< CInstrumentCatalog::sInstrumentConfiguration > oInstrumentConfiguration
CControl< CInstrumentCatalog::sLicenseInformation > cLicenseInfoRequest
CControl< CInstrumentCatalog::eRemoteBoxBusyLedState > cRemoteBoxBusyLedState
CControl< CInstrumentCatalog::sInstrumentConnection > cInstrumentCurrent
CObserver< CInstrumentCatalog::sProbeArrayAngle > oProbeArrayAngle
CObserver< CInstrumentCatalog::sInstrumentInformation > oInstrumentInformation
CObserver< CInstrumentCatalog::sInstrumentStatus > oInstrumentStatus
CControl< CInstrumentCatalog::sInstrumentState > cInstrumentState
CObserver< CInstrumentCatalog::sProbeArrayInformation > oProbeArrayInformation
CControl< CInstrumentCatalog::sNormalization > cNormalizationRequest
CGUICatalogInterface(CInstrumentCatalog &rCatalog)
CControl< CInstrumentCatalog::sProbeArrayAngle > cProbeArrayAngle
CControl< CInstrumentCatalog::sSearchResult > cSearchResult
CObserver< CInstrumentCatalog::sLicenseInformation > oLicenseInfoRequest
CControl< CInstrumentCatalog::sMeasurementResults > cMeasurementResults
CInstrManCatalogInterface(CInstrumentCatalog &rCatalog)
CControl< CInstrumentCatalog::sNormalization > cNormalizationReturned
CControl< CInstrumentCatalog::sLicenseUpdate > cLicenseUpdateReturned
CControl< CInstrumentCatalog::sLogMessage > cLogMessage
CObserver< CInstrumentCatalog::sLicenseUpdate > oLicenseUpdateRequest
CObserver< CInstrumentCatalog::sInstrumentConnection > oInstrumentCurrent
CControl< CInstrumentCatalog::sProbeArrayInformation > cProbeArrayInformation
CObserver< CInstrumentCatalog::eRemoteBoxBusyLedState > oRemoteBoxBusyLedState
CControl< CInstrumentCatalog::tInstrumentList > cInstrumentList
CControl< CInstrumentCatalog::eRemoteBoxTrigger > cRemoteBoxTriggerEvent
CControl< CInstrumentCatalog::sInstrumentInformation > cInstrumentInformation
CObserver< CInstrumentCatalog::sNormalization > oNormalizationRequest
CControl< CInstrumentCatalog::sInstrumentConfiguration > cInstrumentConfiguration
CControl< CInstrumentCatalog::sError > cError
CControl< CInstrumentCatalog::sLicenseInformation > cLicenseInfoReturned
CObserver< CInstrumentCatalog::sInstrumentState > oInstrumentState
CObserver< CInstrumentCatalog::sMFC3045SerialPortSettings > oMFC3045SerialPortSettings
CControl< CInstrumentCatalog::sInstrumentStatus > cInstrumentStatus