nfm_base.h 33 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740
  1. #ifndef NFM_BASE_H
  2. #define NFM_BASE_H
  3. #include <stdint.h>
  4. #include <stddef.h>
  5. #include <stdbool.h>
  6. #include "app/nfm/nfm_base_ECalUnit.h"
  7. typedef struct TEcalHeader sEcalHeader_t;
  8. typedef struct TEcalHeaderCRC sEcalHeaderCRC_t;
  9. typedef struct TEcalDataHeader sEcalDataHeader_t;
  10. typedef struct TEcalDataHeaderCRC sEcalDataHeaderCRC_t;
  11. typedef struct TEcalTCompHeader sEcalTCompHeader_t;
  12. typedef struct TEcalTCompHeaderCRC sEcalTCompHeaderCRC_t;
  13. typedef struct TEcalSegment sEcalSegmentUnaligned_t;
  14. typedef struct TableTHeader sTableHeader_t;
  15. typedef struct TableTHeaderCRC sTableHeaderCRC_t;
  16. typedef struct TablePoint sTableTablePoint_t;
  17. typedef struct // ==TEcalSegment
  18. {
  19. double Fstart; // aligned access for 'double'
  20. double Fstop; // aligned access for 'double'
  21. int16_t Points;
  22. }
  23. // sEcalSegmentAligned_t: contains the same fields as a 'TEcalSegment',
  24. // but with aligned access for 'double'-typed fields.
  25. // Note: is used to store data inside the application, must not be used
  26. // to cast the buffer with data that read from the memory, use
  27. // sEcalSegmentUnaligned_t instead
  28. sEcalSegmentAligned_t;
  29. typedef sEcalSegmentAligned_t sEcalSegment_t;
  30. typedef struct TEcalTableHeader sEcalChrzTableHeader_t;
  31. typedef struct TEcalPoint24 sEcalChrzTablePoint_t;
  32. typedef struct TEcalThermMagnHeader sEcalTCompTableMagnHeader_t;
  33. typedef struct TEcalThermMagnPoint sEcalTCompTableMagnPoint_t;
  34. typedef struct TEcalThermPhaseHeader sEcalTCompTablePhaseHeader_t;
  35. typedef struct TEcalThermPhasePoint sEcalTCompTablePhasePoint_t;
  36. // enum ôèçè÷åñêèõ ïîðòîâ ïðèáîðà
  37. typedef enum
  38. {
  39. eNFMPort_1 = 1,
  40. eNFMPort_2 = 2
  41. }
  42. eNFMPorts_t;
  43. typedef enum {
  44. ePort_1 = 0,
  45. ePort_2,
  46. ePort_3,
  47. ePort_4,
  48. ePort_5,
  49. ePort_6,
  50. ePort_7,
  51. ePort_8,
  52. ePort_9,
  53. ePort_10,
  54. ePort_11,
  55. ePort_12,
  56. ePort_Unknown = 255,
  57. }
  58. ePorts_t;
  59. typedef enum {
  60. eTerminatePortState = 0, // All ports are shutdown
  61. eUnknownPortState = 255,
  62. }
  63. sDefaultPortStates_t;
  64. typedef enum {
  65. eTrigState_Rising = 0, // Rising
  66. eTrigState_Falling, // Falling
  67. eKeyState_UnknownTrig = 255,
  68. }
  69. eSBTrigState_t;
  70. #ifndef DEVICE_FIRMWARE_VERSION
  71. #define DEVICE_FIRMWARE_VERSION "2.0/02"
  72. #endif
  73. // eCharacterization_t:
  74. // Type of characterization table
  75. // Related objects: @aChrzDesc
  76. typedef enum
  77. {
  78. /* DO NOT CHANGE VALUES ! */
  79. eChFactory = 0, // factory table, by default
  80. eChUser1 = 1, // user table #1
  81. eChUser2 = 2, // user table #2
  82. eChUser3 = 3, // user table #3
  83. eCh_MAX = 4
  84. }
  85. eChrz_t;
  86. typedef enum
  87. {
  88. eChValues = 0, // User table plan
  89. eChValues_MAX = 2 // User table max
  90. }
  91. eChunks_t;
  92. // Type of scale of characterization table
  93. typedef enum
  94. {
  95. eChScale_undefined,
  96. eChScaleLinear, // Linear frequency scale
  97. eChScaleSegment, // Segment frequency scale
  98. }
  99. eChrzScaleType_t;
  100. // Type of connector type
  101. typedef enum
  102. {
  103. eCon_N50_M, // "Type-N50 -M-"
  104. eCon_N50_F, // "Type-N50 -F-"
  105. eCon_3dot5mm_M, // "3.5mm -M-"
  106. eCon_3dot5mm_F, // "3.5mm -F-"
  107. eCon_2dot4mm_M, // "2.4mm -M-"
  108. eCon_2dot4mm_F, // "2.4mm -F-"
  109. eCon_N75_M, // "Type-N75 -M-"
  110. eCon_N75_F, // "Type-N75 -F-"
  111. eCon_F_M, // "Type-F -M-"
  112. eCon_F_F, // "Type-F -F-"
  113. eCon_7_16_M, // "7/16 -M-"
  114. eCon_7_16_F, // "7/16 -F-"
  115. eCon_APC_7 // "APC-7"
  116. }
  117. eConnectorType_t;
  118. typedef enum
  119. {
  120. ePortId_A,
  121. ePortId_B,
  122. ePortId_C,
  123. ePortId_D,
  124. ePortId_MAX
  125. }
  126. ePortId_t;
  127. typedef enum
  128. {
  129. ePortComb_UNDEFINED,
  130. ePortComb_A,
  131. ePortComb_B,
  132. ePortComb_C,
  133. ePortComb_D,
  134. ePortComb_AB,
  135. ePortComb_AC,
  136. ePortComb_AD,
  137. ePortComb_BC,
  138. ePortComb_BD,
  139. ePortComb_CD,
  140. ePortComb_CHECK,
  141. ePortComb_MAX,
  142. ePortComb_BA = ePortComb_AB,
  143. ePortComb_CA = ePortComb_AC,
  144. ePortComb_CB = ePortComb_BC,
  145. ePortComb_DA = ePortComb_AD,
  146. ePortComb_DB = ePortComb_BD,
  147. ePortComb_DC = ePortComb_CD,
  148. ePortComb_MIN_SINGLE_XPort = ePortComb_A,
  149. ePortComb_MAX_SINGLE_XPort = ePortComb_D, // maximum supported
  150. ePortComb_MIN_SINGLE_2Port = ePortComb_A,
  151. ePortComb_MAX_SINGLE_2Port = ePortComb_B,
  152. ePortComb_MIN_SINGLE_4Port = ePortComb_A,
  153. ePortComb_MAX_SINGLE_4Port = ePortComb_D,
  154. ePortComb_MIN_THRU_XPort = ePortComb_AB,
  155. ePortComb_MAX_THRU_XPort = ePortComb_CD, // maximum supported
  156. ePortComb_MIN_THRU_2Port = ePortComb_AB,
  157. ePortComb_MAX_THRU_2Port = ePortComb_AB,
  158. ePortComb_MIN_THRU_4Port = ePortComb_AB,
  159. ePortComb_MAX_THRU_4Port = ePortComb_CD,
  160. ePortComb_MIN = ePortComb_A,
  161. }
  162. ePortComb_t;
  163. typedef enum // Do not forget to update 'NFMCheckPortStateAvailable' and 'NFM_ROM_GetChrzTableIndex' routines
  164. {
  165. ePortStateId_UNDEFINED,
  166. // Port State:
  167. ePortStateId_Short, // shorted port: A, B, C, D
  168. ePortStateId_Open, // opened port: A, B, C, D
  169. ePortStateId_Load , // loaded port: A, B, C, D
  170. ePortStateId_Load2, // loaded (2) port: A, B, C, D
  171. ePortStateId_Open2, // opened (2) port: A, B, C, D
  172. //-------------------------------------------------
  173. ePortStateId_S11, // | Quard matrix of S-param ^ } available for CHECK and THRU
  174. ePortStateId_S21, // | S11, S12, S21, S22 ^ } available for CHECK and THRU
  175. ePortStateId_S12, // | for combination of ^ } available for CHECK and THRU
  176. ePortStateId_S22, // | two ports or four ports ^ } available for CHECK and THRU
  177. //-------------------------------------------------
  178. ePortStateId_S13, // | 16-matrix of S-param ^ } available for CHECK only
  179. ePortStateId_S14, // | S11 - S44 ^ } available for CHECK only
  180. ePortStateId_S23, // | for combination of ^ } available for CHECK only
  181. ePortStateId_S24, // | four ports only ^ } available for CHECK only
  182. ePortStateId_S31, // | available for CHECK only ^ } available for CHECK only
  183. ePortStateId_S32, // | ^ } available for CHECK only
  184. ePortStateId_S33, // | ^ } available for CHECK only
  185. ePortStateId_S34, // | ^ } available for CHECK only
  186. ePortStateId_S41, // | ^ } available for CHECK only
  187. ePortStateId_S42, // | ^ } available for CHECK only
  188. ePortStateId_S43, // | ^ } available for CHECK only
  189. ePortStateId_S44, // | ^ } available for CHECK only
  190. //-------------------------------------------------
  191. ePortStateId_MAX,
  192. // ePortStateId_MIN_SINGLE...ePortStateId_MAX_SINGLE
  193. // Available states for Single Port Combination (A,B,C,D)
  194. ePortStateId_MIN_SINGLE_XPort = ePortStateId_Short, //
  195. ePortStateId_MAX_SINGLE_XPort = ePortStateId_Open2, // maximum supported
  196. ePortStateId_MIN_SINGLE_2Port = ePortStateId_Short, //
  197. ePortStateId_MAX_SINGLE_2Port = ePortStateId_Open2, //
  198. ePortStateId_MIN_SINGLE_4Port = ePortStateId_Short, //
  199. ePortStateId_MAX_SINGLE_4Port = ePortStateId_Open2, //
  200. // ePortStateId_MIN_THRU...ePortStateId_MAX_THRU
  201. // Available states for Pair Port Combination (AB,AC,AD,BC,BD,CD)
  202. ePortStateId_MIN_THRU_XPort = ePortStateId_S11, //
  203. ePortStateId_MAX_THRU_XPort = ePortStateId_S22, // maximum supported
  204. ePortStateId_MIN_THRU_2Port = ePortStateId_S11, //
  205. ePortStateId_MAX_THRU_2Port = ePortStateId_S22, //
  206. ePortStateId_MIN_THRU_4Port = ePortStateId_S11, //
  207. ePortStateId_MAX_THRU_4Port = ePortStateId_S22, //
  208. // ePortStateId_MIN_CHECK...ePortStateId_MAX_CHECK
  209. // Available states for Quard Port Combination (CHECK)
  210. ePortStateId_MIN_CHECK_XPort = ePortStateId_S11, //
  211. ePortStateId_MAX_CHECK_XPort = ePortStateId_S44, // maximum supported
  212. ePortStateId_MIN_CHECK_2Port = ePortStateId_S11, //
  213. ePortStateId_MAX_CHECK_2Port = ePortStateId_S22, //
  214. ePortStateId_MIN_CHECK_4Port = ePortStateId_S11, //
  215. ePortStateId_MAX_CHECK_4Port = ePortStateId_S44, //
  216. ePortStateId_MIN = ePortStateId_Short,
  217. }
  218. ePortStateId_t;
  219. // sNFMChrzPoint_t:
  220. //
  221. typedef struct
  222. {
  223. double magn;
  224. double phase;
  225. }
  226. sNFMChrzPoint_t;
  227. // sNFMTCompMagnPoint_t:
  228. //
  229. typedef struct
  230. {
  231. double magn;
  232. }
  233. sNFMTCompMagnPoint_t;
  234. // sNFMTCompPhasePoint_t:
  235. //
  236. typedef struct
  237. {
  238. double phase;
  239. }
  240. sNFMTCompPhasePoint_t;
  241. typedef struct
  242. {
  243. uint8_t port1; // Device port1 switch state
  244. uint8_t port2; // Device port2 switch state
  245. }sSWTablePoint_t;
  246. // sNFMGetPoints_t
  247. // Control structure to retieve the data points of
  248. // characterization array or thermocompensation array
  249. typedef struct
  250. {
  251. struct
  252. {
  253. size_t nStartPoint; // Starting point
  254. size_t nCount; // Amount of points
  255. sNFMChrzPoint_t * pDataArray; // Pointer to the buffer to store chrz points
  256. }
  257. in;
  258. struct
  259. {
  260. size_t TableAddress; // memory address of the table
  261. size_t nPoints; // whole number of points in the table
  262. int16_t min; // "Minimum value": for scaling the values, see TEcalTableHeader
  263. int16_t max; // "Maximum value": for scaling the values, see TEcalTableHeader
  264. }
  265. out;
  266. struct
  267. {
  268. unsigned int errCode; // error code, see @ERR_NFMGETPOINTS_* macros
  269. }
  270. svc;
  271. }
  272. sNFMGetPoints_t;
  273. // xNFMGetFreqPoints_t
  274. // Control structure to retieve the frequency points
  275. typedef struct
  276. {
  277. const void * private[14];
  278. }
  279. xNFMGetFreqPoints_t;
  280. // sNFMGetPointsSimplified_t
  281. // Control structure to retieve the data points
  282. typedef struct
  283. {
  284. const void * private[9];
  285. }
  286. xNFMGetPointsSimplified_t;
  287. typedef struct
  288. {
  289. const void * private[9];
  290. }
  291. xSWGetTablePoints_t;
  292. // @eNFMGetPointError_t
  293. // Result code of following routines:
  294. // - @NFMGetScaleFreqs_Begin
  295. // - @NFMGetScaleFreqs_Continue
  296. typedef enum
  297. {
  298. eNFMGetPointError_DataError = -2, // can't get/process data (crc invalid?)
  299. eNFMGetPointError_InvalidValue = -1, // invalid input parameters
  300. eNFMGetPointError_Success = 0, // success code
  301. eNFMGetPointError_OutOfBuffer = 1, // warning code
  302. eNFMGetPointError_Limit = 2, // warning code
  303. }
  304. eNFMGetPointError_t;
  305. #define ERR_NFMGETPOINTS_NOERR 0 // no error
  306. #define ERR_NFMGETPOINTS_INVAL 1 // invalid parameter or argument
  307. #define ERR_NFMGETPOINTS_INVHDR 2 // invalid data header (chrz or tcomp)
  308. #define ERR_NFMGETPOINTS_INVTBL 3 // invalid data table (corrupted/invalid crc)
  309. #define ERR_NFMGETPOINTS_IO 4 // i/o error
  310. typedef enum
  311. {
  312. eNFM_IfaceUSBVendor,
  313. eNFM_IfaceUSBTMC
  314. }
  315. eNFMUSBInterface_t;
  316. typedef struct
  317. {
  318. uint16_t settingsVersion; // Device settings version (for compatible)
  319. uint8_t rawBytes[8]; // Device current USB protocol
  320. uint16_t tempCoeff; // Device temperature coefficient
  321. uint8_t reserved[48]; // Reserved bytes
  322. }
  323. sNFMSettingsBlock_t;
  324. typedef struct
  325. {
  326. sNFMSettingsBlock_t settings;
  327. uint32_t CRCValue;
  328. }sNFMSettingsBlockCrc_t;
  329. typedef struct
  330. {
  331. struct
  332. {
  333. const char * manufacturerId; // Device Manufacturer Id
  334. const char * firmwareId; // Firmware ID
  335. const char * modelName; // SWB Model name
  336. const char * serialNumber; // serial number
  337. uint16_t allowedInputPorts;
  338. uint16_t allowedOutputPorts;
  339. uint16_t defaultInputState;
  340. uint16_t * inputPortStates; // Current input port states
  341. uint16_t deviceId; // device id
  342. bool isServiceMode; // is device in service mode
  343. }
  344. properties;
  345. struct
  346. {
  347. struct
  348. {
  349. bool (* getInterface)( eNFMUSBInterface_t * pCurrentIface );
  350. bool (* setInterface)( eNFMUSBInterface_t activateInterface );
  351. }
  352. usbInterface;
  353. struct
  354. {
  355. uint16_t (* getPortState)( uint16_t portNumber );
  356. bool (* setPortState)( uint16_t portNumber, uint16_t portState );
  357. }portMethods;
  358. // Get device serial number in string format
  359. size_t (* getDeviceSerial)( char * buffer, size_t size );
  360. // Get device manufacturer ID in string format
  361. size_t (* getDeviceManufacturer)( char * buffer, size_t size );
  362. // Check if the specified port state is available for current configuration
  363. bool (* checkPortStateAvailable)( ePortStateId_t portState );
  364. // Check if the specified port combination is available for current configuration
  365. bool (* checkPortCombinationAvailable)( ePortComb_t portComb );
  366. // Get model name (description)
  367. size_t (* getModelName)( char * buffer, size_t size );
  368. // Checks the characterization table parameters for compatibility
  369. bool (* checkTableParams)( ePortComb_t portComb, ePortStateId_t portState );
  370. struct
  371. {
  372. // // MEM:TABL:DATA?
  373. // // Reads the data points of the characterization table
  374. // size_t (* getPoints)( eChrz_t tableId, ePortComb_t portComb, ePortStateId_t portState,
  375. // sNFMGetPoints_t * pCtl ); # replaced with @getPoints_Init/@getPoints_Next
  376. // MEM:TABL:DATA?
  377. // Prepares the context before reading the data points of the characterization table
  378. // Parameters:
  379. // @sectorId - bank id, characterization bank;
  380. // @portComb - port combination to request (NFM path);
  381. // @portState - port state to request (S-parameter);
  382. // @pDataBuffer - output data buffer;
  383. // @szDataBuffer - output data buffer capacity;
  384. // @xCtl - the control context to initialize;
  385. // Returns: 0 in case error, or number of points in case success.
  386. size_t (* getPoints_Init)( eChrz_t sectorId, ePortComb_t portComb, ePortStateId_t portState,
  387. sNFMChrzPoint_t * pDataBuffer, size_t szDataBuffer,
  388. xNFMGetPointsSimplified_t * xCtl );
  389. // MEM:TABL:DATA?
  390. // @getPoints_Next
  391. // Uses already prepared context and reads the data points of the characterization
  392. // table to the top of specified buffer (see @getPoints_Init).
  393. // This method is designed to replace the obsolete @NFMGetPoints.
  394. // Parameters:
  395. // @xCtl - control context prepared by previous NFMGetPoints_Begin call
  396. // @pnPointsRetrieve - IN/OUT; IN: specifies a number of points to retrieve; OUT: stores the value of actually read points;
  397. //
  398. // Returns:
  399. // - eNFMGetPointError_DataError: error, can not load data;
  400. // - eNFMGetPointError_InvalidValue: error, invalid parameters;
  401. // - eNFMGetPointError_Success: success, all the points from the table have been read;
  402. // - eNFMGetPointError_OutOfBuffer: warning, points have been read, but it is required to continue because user buffer ran out;
  403. // - eNFMGetPointError_Limit: warning, points have been read, but the caller specified less points to read than actually available;
  404. int32_t (* getPoints_Next)( xNFMGetPointsSimplified_t * xCtl, size_t * pnPointsRetrieve );
  405. // Reads amount of points in the characterization table
  406. size_t (* getPointsCount)( eChrz_t tableId );
  407. // MEM:TABL:POIN?
  408. // Reads amount of points in the characterization table
  409. bool (* getPointsCountSafe)( eChrz_t tableId, int16_t * count );
  410. // MEM:TABL:DATE?
  411. // Reads the date of characterization table
  412. bool (* getDate)( eChrz_t tableId, char * buffer, size_t size, size_t * bytes );
  413. // MEM:TABL:TIME?
  414. // Reads the time of characterization table
  415. bool (* getTime)( eChrz_t tableId, char * buffer, size_t size, size_t * bytes );
  416. // MEM:TABL:FREQ:TYPE?
  417. // Reads the type of the frequency scale of data characterization table
  418. bool (* getScaleType)( eChrz_t tableId, eChrzScaleType_t * pType );
  419. // MEM:TABL:FREQ:SEGM:DATA?
  420. // Reads the scale segment of data characterization table
  421. // Pass NULL in @pSegment to retrieve amount of segments in return value
  422. size_t (* getScaleSegment)( eChrz_t tableId, sEcalSegment_t * pSegment, size_t nSegmentId );
  423. // MEM:TABL:FREQ:DATA?
  424. // @getScaleFreqs_Init
  425. // Prepares a retrieving context for calling the @getScaleFreqs_Next routine.
  426. // Initializes such values as:
  427. // - a number of starting point to retrive
  428. // - a buffer to retrieve the values to
  429. // - characterization table (unit) identifier (@tableId)
  430. // Parameters:
  431. // @tableId - characterization table to operate with;
  432. // @nStartPoint - starting point to begin retrieving from (default = 0);
  433. // @nStartSegment - starting segment to begin retrieving from (default = 0);
  434. // @pFreqArray - a floating point values buffer to store data to;
  435. // @BufferCapacity - receiving buffer capacity [@pFreqArray]
  436. // @xCtl - a control structure to intialize; use this structure to call @getScaleFreqs_Next.
  437. //
  438. // Returns: integer result (see @eNFMGetPointError_t):
  439. // - eNFMGetPointError_DataError: error, can not load data;
  440. // - eNFMGetPointError_InvalidValue: error, invalid parameters;
  441. // - eNFMGetPointError_Success: success, all the points from all the segments have been read;
  442. int32_t (* getScaleFreqs_Init)( eChrz_t tableId, double * pFreqArray, size_t BufferCapacity, xNFMGetFreqPoints_t * xCtl );
  443. // MEM:TABL:FREQ:DATA?
  444. // @getScaleFreqs_Next
  445. // Related SCPI command: 'MEM:TABL:FREQ:DATA?'
  446. // Reads the frequencies of data characterization table's points (either for Linear and Segment scale)
  447. // and stores it into the buffer specified by calling @getScaleFreqs_Init
  448. // Note: the points are stored to the top of the specified buffer each call.
  449. //
  450. // Parameters:
  451. // @xCtl - retrieve context, must be initialized by @NFMGetScaleFreqs_Begin
  452. // @pnPointsRetrieve - IN/OUT; IN: specifies a number of points to retrieve; OUT: stores the value of actually read points;
  453. //
  454. // !!! Attention: user shall control the @pFreqArray buffer range itself when calling @getScaleFreqs_Init
  455. // !!! and guarantee, that it has enough room to recevie specified number of points [@nPointsRetrieve].
  456. //
  457. // Returns:
  458. // - eNFMGetPointError_DataError: error, can not load data;
  459. // - eNFMGetPointError_InvalidValue: error, invalid parameters;
  460. // - eNFMGetPointError_Success: success, all the points from all the segments have been read;
  461. // - eNFMGetPointError_OutOfBuffer: warning, points have been read, but it is required to continue because user buffer ran out;
  462. // - eNFMGetPointError_Limit: warning, points have been read, but the caller specified less points to read than actually available;
  463. int32_t (* getScaleFreqs_Next)( xNFMGetFreqPoints_t * xCtl, size_t * pnPointsRetrieve );
  464. // MEM:TABL:FREQ:STAR?
  465. // Reads the start frequency of the characterization table
  466. bool (* getStartFreq)( eChrz_t tableId, double * pStartFreq );
  467. // MEM:TABL:FREQ:STOP?
  468. // Reads the stop frequency of the characterization table
  469. bool (* getStopFreq)( eChrz_t tableId, double * pStopFreq );
  470. // MEM:TABL:TEMP?
  471. // Reads the characterization temperature of characterization table
  472. bool (* getChrzTemp)( eChrz_t tableId, double * pTemperature );
  473. // MEM:TABL:CONN?
  474. // Reads the connector type of the NFM
  475. bool (* getConnectorType)( ePortId_t portId, char * buffer, size_t size, size_t * bytes );
  476. // MEM:TABL:ADAP?
  477. // Reads the adapter description of the NFM connector
  478. bool (* getAdapterDesc)( eChrz_t tableId, ePortId_t portId, char * buffer, size_t size, size_t * bytes );
  479. // MEM:TABL:ANAL? ( =ANALyzer)
  480. // Reads the analyzer type
  481. bool (* getAnalyzer)( eChrz_t tableId, char * buffer, size_t size, size_t * bytes );
  482. // MEM:TABL:PLAC?
  483. // Reads the place where the characterization had been created
  484. bool (* getPlace)( eChrz_t tableId, char * buffer, size_t size, size_t * bytes );
  485. // MEM:TABL:OPER?
  486. // Reads the the characterization operator's name
  487. bool (* getOperator)( eChrz_t tableId, char * buffer, size_t size, size_t * bytes );
  488. }
  489. xCharacterization;
  490. struct
  491. {
  492. // TABLe:GET?
  493. // @getTablePoints_Init
  494. // Prepares a retrieving context for calling the @getTablePoints_Next routine.
  495. // Initializes such values as:
  496. // - a number of starting point to retrive
  497. // - a buffer to retrieve the values to
  498. // - points table (unit) identifier (@tableId)
  499. // Parameters:
  500. // @tableId - characterization table to operate with;
  501. // @nStartPoint - starting point to begin retrieving from (default = 0);
  502. // @nStartSegment - starting segment to begin retrieving from (default = 0);
  503. // @pValuesArray - a uint8_t point values buffer to store data to;
  504. // @BufferCapacity - receiving buffer capacity [@pFreqArray]
  505. // @xCtl - a control structure to intialize; use this structure to call @getTablePoints_Next.
  506. //
  507. // Returns: integer result (see @eNFMGetPointError_t):
  508. // - eNFMGetPointError_DataError: error, can not load data;
  509. // - eNFMGetPointError_InvalidValue: error, invalid parameters;
  510. // - eNFMGetPointError_Success: success, all the points from all the segments have been read;
  511. int32_t (* getTablePoints_Init)( eChrz_t tableId, sSWTablePoint_t * pPointsArray, size_t BufferCapacity, xSWGetTablePoints_t * xCtl );
  512. // TABLe:GET?
  513. // @getTablePoints_Next
  514. // Related SCPI command: 'TABLe:GET?'
  515. // Reads the switch plan points of data table's points (either for Linear and Segment scale)
  516. // and stores it into the buffer specified by calling @getTablePoints_Init
  517. // Note: the points are stored to the top of the specified buffer each call.
  518. //
  519. // Parameters:
  520. // @xCtl - retrieve context, must be initialized by @NFMGetScaleFreqs_Begin
  521. // @pnPointsRetrieve - IN/OUT; IN: specifies a number of points to retrieve; OUT: stores the value of actually read points;
  522. //
  523. // !!! Attention: user shall control the @pPointsArray buffer range itself when calling @getTablePoints_Init
  524. // !!! and guarantee, that it has enough room to recevie specified number of points [@nPointsRetrieve].
  525. //
  526. // Returns:
  527. // - eNFMGetPointError_DataError: error, can not load data;
  528. // - eNFMGetPointError_InvalidValue: error, invalid parameters;
  529. // - eNFMGetPointError_Success: success, all the points from all the segments have been read;
  530. // - eNFMGetPointError_OutOfBuffer: warning, points have been read, but it is required to continue because user buffer ran out;
  531. // - eNFMGetPointError_Limit: warning, points have been read, but the caller specified less points to read than actually available;
  532. int32_t (* getTablePoints_Next)( xSWGetTablePoints_t * xCtl, size_t * pnPointsRetrieve );
  533. }xTable;
  534. struct
  535. {
  536. // MEM:TABL:THER:CORR:FREQ:STAR?
  537. // Reads the start frequency of the thermocompensation data
  538. bool (* getStartFreq)( double * pStartFreq );
  539. // MEM:TABL:THER:CORR:FREQ:STOP?
  540. // Reads the stop frequency of the thermocompensation data
  541. bool (* getStopFreq)( double * pStopFreq );
  542. // Reads the amount of points in the thermocompensation data
  543. size_t (* getPointsCount )( );
  544. // MEM:TABL:THER:CORR:POIN?
  545. // Reads the amount of points in the thermocompensation data
  546. bool (* getPointsCountSafe )( int16_t * count );
  547. // // MEM:TABL:THER:CORR:MAGN?
  548. // // Reads the magnitude data points of the thermocompensation table
  549. // size_t (* getPointsMagn )( ePortComb_t portComb, ePortStateId_t portState,
  550. // sNFMGetPoints_t * pCtl );
  551. //
  552. // // MEM:TABL:THER:CORR:PHAS?
  553. // // Reads the phase data points of the thermocompensation table
  554. // size_t (* getPointsPhase )( ePortComb_t portComb, ePortStateId_t portState,
  555. // sNFMGetPoints_t * pCtl );
  556. // MEM:TABL:THERmo:CORRection:MAGNitude?
  557. // @getPointsThermoMagn_Init
  558. // Prepares the context before reading the data points of the thermocompensation table of magnitudes
  559. // This method is designed to replace the obsolete @getPointsMagn.
  560. // Parameters:
  561. // @portComb - port combination to request (NFM path);
  562. // @portState - port state to request (S-parameter);
  563. // @pDataBuffer - output data buffer;
  564. // @szDataBuffer - output data buffer capacity;
  565. // @xCtl - the control context to initialize;
  566. // Returns: 0 in case error, or number of points in case success.
  567. size_t (* getPointsThermoMagn_Init)( ePortComb_t portComb, ePortStateId_t portState,
  568. sNFMChrzPoint_t * pDataBuffer, size_t szDataBuffer,
  569. xNFMGetPointsSimplified_t * xCtl );
  570. // MEM:TABL:THERmo:CORRection:MAGNitude?
  571. // @getPointsThermoMagn_Next
  572. // Uses already prepared context and reads magnutude data points of the thermocompensation
  573. // table to the top of specified buffer (see @getPointsThermoMagn_Init).
  574. // This method is designed to replace the obsolete @getPointsMagn.
  575. // Parameters:
  576. // @xCtl - control context prepared by previous getPointsThermoMagn_Init call
  577. // @pnPointsRetrieve - IN/OUT; IN: specifies a number of points to retrieve; OUT: stores the value of actually read points;
  578. //
  579. // Returns:
  580. // - eNFMGetPointError_DataError: error, can not load data;
  581. // - eNFMGetPointError_InvalidValue: error, invalid parameters;
  582. // - eNFMGetPointError_Success: success, all the points from the table have been read;
  583. // - eNFMGetPointError_OutOfBuffer: warning, points have been read, but it is required to continue because user buffer ran out;
  584. // - eNFMGetPointError_Limit: warning, points have been read, but the caller specified less points to read than actually available;
  585. int32_t (* getPointsThermoMagn_Next)( xNFMGetPointsSimplified_t * xCtl, size_t * pnPointsRetrieve );
  586. // MEM:TABL:THERmo:CORRection:PHASe?
  587. // @getPointsThermoPhase_Init
  588. // Prepares the context before reading the data points of the thermocompensation table of phases
  589. // This method is designed to replace the obsolete @getPointsMagn.
  590. // Parameters:
  591. // @portComb - port combination to request (NFM path);
  592. // @portState - port state to request (S-parameter);
  593. // @pDataBuffer - output data buffer;
  594. // @szDataBuffer - output data buffer capacity;
  595. // @xCtl - the control context to initialize;
  596. // Returns: 0 in case error, or number of points in case success.
  597. size_t (* getPointsThermoPhase_Init)( ePortComb_t portComb, ePortStateId_t portState,
  598. sNFMChrzPoint_t * pDataBuffer, size_t szDataBuffer,
  599. xNFMGetPointsSimplified_t * xCtl );
  600. // MEM:TABL:THERmo:CORRection:PHASe?
  601. // @getPointsThermoPhase_Next
  602. // Uses already prepared context and reads phase data points of the thermocompensation
  603. // table to the top of specified buffer (see @getPointsThermoPhase_Init).
  604. // This method is designed to replace the obsolete @getPointsPhase.
  605. // Parameters:
  606. // @xCtl - control context prepared by previous getPointsThermoPhase_Init call
  607. // @pnPointsRetrieve - IN/OUT; IN: specifies a number of points to retrieve; OUT: stores the value of actually read points;
  608. //
  609. // Returns:
  610. // - eNFMGetPointError_DataError: error, can not load data;
  611. // - eNFMGetPointError_InvalidValue: error, invalid parameters;
  612. // - eNFMGetPointError_Success: success, all the points from the table have been read;
  613. // - eNFMGetPointError_OutOfBuffer: warning, points have been read, but it is required to continue because user buffer ran out;
  614. // - eNFMGetPointError_Limit: warning, points have been read, but the caller specified less points to read than actually available;
  615. int32_t (* getPointsThermoPhase_Next)( xNFMGetPointsSimplified_t * xCtl, size_t * pnPointsRetrieve );
  616. }
  617. xThermo;
  618. struct
  619. {
  620. bool ( * enable)( void );
  621. bool ( * disable)( void );
  622. bool ( * check)( void );
  623. }
  624. xMemoryProtection;
  625. }
  626. methods;
  627. }
  628. NFMClass_t;
  629. #include "nfm/nfm_base_mem.h"
  630. #include "nfm/nfm_base_model.h"
  631. extern NFMClass_t * NFMClass;
  632. void nfmbase_init();
  633. void nfmbase_test();
  634. // service: change model id
  635. bool NFM_ROM_ChangeModel( eNFMModel_t modelId );
  636. bool NFM_ROM_ChangeSerialNumber( const char * serial );
  637. bool SW_ROM_ChangeTableHeader( sTableHeaderCRC_t * hdrcrc );
  638. #endif