structures.h 14 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569
  1. /*
  2. * structures.h
  3. *
  4. * Authors:
  5. * Liu Jieqing <jqing.liu@careray.com>
  6. *
  7. * 2009-1-15 File created.
  8. *
  9. * This file is the structures commonly used throughout the
  10. * whole system. Need to increase and improve gradually.
  11. *
  12. *
  13. * Modification history:
  14. * 2013-01-21 modified, add some 1500P used structures
  15. * and others
  16. * 2013-02-28 modified, add Correction struct
  17. */
  18. #ifndef __STRUCTURES_H__
  19. #define __STRUCTURES_H__
  20. #define STRLEN 256
  21. #define DOSELENGTH 8192
  22. #define IMAGEHEAD 65536
  23. /*
  24. * Structures used to save the detector information
  25. *
  26. * rawImageWidth ¡ª The original image width of the detector
  27. * rawImageHeight ¡ª The original image height of the detector
  28. * maxPixelValue ¡ª The max value of each pixel
  29. * bitsPerPixel ¡ª Number of bits per pixel
  30. * hardWareVersion[STRLEN] ¡ª The version of hardware
  31. * softWareVersion[STRLEN] ¡ª The version of software
  32. * serialNumber[STRLEN] ¡ª The serial number of the detector
  33. * DetectorDescription[STRLEN] ¡ª A string that describes the detector, STRLEN is a macro definition, 256
  34. */
  35. struct DetectorInfo
  36. {
  37. int rawImageWidth;
  38. int rawImageHeight;
  39. int maxPixelValue;
  40. int bitsPerPixel;
  41. char hardWareVersion[STRLEN];
  42. char softWareVersion[STRLEN];
  43. char serialNumber[STRLEN];
  44. char detectorDescription[STRLEN];
  45. };
  46. /*
  47. * Structure used to save current detector temperature information
  48. * maxTemperature ¡ª Max detector temperature of temperature sensors currently
  49. * aveTemperature ¡ª Average detector temperature of temperature sensors currently
  50. * overhot_flag ¡ª Detector over hot flag
  51. */
  52. struct Temperature
  53. {
  54. float reserved[5];
  55. float maxTemperature;
  56. float aveTemperature;
  57. int overhot_flag; //Status infor, see enum TempStatus
  58. };
  59. //µç³ØÐÅÏ¢(Used for 1500P)
  60. struct BatteryInfo
  61. {
  62. int manu_access;
  63. int alarm_capa; //unit: mAh
  64. int alarm_time; //unit: min
  65. int mode; //range: 0x0000~0xffff
  66. int atrate; //-32768mA~32768mA
  67. int atrate_tofull; //unit: min
  68. int atrate_toempty; //unit: min
  69. int atrate_ok; //unit: min
  70. float temperature; //unit: C
  71. float voltage; //unit: V
  72. float current; //unit: A
  73. float ave_current; //unit: A
  74. float max_error;
  75. float relative_state_of_charge;
  76. float absolute_state_of_charge;
  77. int rest_capacity; //unit mAh
  78. int full_capacity; //unit mAh
  79. int run_time_to_empty;
  80. int ave_time_to_empty;
  81. float charging_current; //unit: A
  82. float charging_voltage; //unit: V
  83. int battery_status;
  84. int cycle_count;
  85. int design_capacity; //mAh
  86. float design_voltage; //V
  87. float cell4_voltage; //V
  88. float cell3_voltage; //V
  89. float cell2_voltage; //V
  90. float cell1_voltage; //V
  91. };
  92. struct WirelessInfo
  93. {
  94. char essid[32];
  95. char mode[16];
  96. char freq[16];
  97. char channel[16];
  98. char bit_rate[16];
  99. char encypt_key[64];
  100. char security_mode[16];
  101. char link_quality[16];
  102. char signal_level[16]; //signal level
  103. char noise_level[16];
  104. char sensitivity[16];
  105. char reserved1[16]; //the first 256 bytes
  106. unsigned long long tx_packets;
  107. unsigned long long rx_packets;
  108. unsigned long long tx_bytes;
  109. unsigned long long rx_bytes;
  110. int reserved[64]; //the second 256 bytes
  111. };
  112. /*
  113. * Structure used to save the current detector status information
  114. *
  115. * currentMode ¡ª Current mode of the detector
  116. * detectorState ¡ª Current detector state
  117. * frameRate ¡ª Current frame rate
  118. * temperature ¡ª Detector temperature of temperature sensors currently
  119. */
  120. struct StatusInfo
  121. {
  122. int checkMode;
  123. int detectorState;
  124. float frameRate;
  125. Temperature temperature;
  126. BatteryInfo batInfo;
  127. WirelessInfo wireless_info;
  128. };
  129. /*
  130. * Structure to save the current mode infomation.
  131. *
  132. * modeId ¡ª The mode id for the information retrieved.
  133. * acqType ¡ª Acquisition type. Variable is set to 0 for radiograph modes or 1 for fluoroscopy modes.
  134. * imageWidth ¡ª The number of column of an image in current mode.
  135. * imageHeight ¡ª The number of line of an image in current mode.
  136. * linesPerPixel ¡ª The number of lines per pixel, >1 when binning is used.
  137. * colsPerPixel ¡ª The number of column per pixel, >1 when binning is used.
  138. * imageSize ¡ª The size of image in byte.
  139. * maxFrameRate ¡ª The maximum allowed frame rate for the mode.
  140. * modeDescription ¡ª A string that describes the mode.
  141. */
  142. struct ModeInfo
  143. {
  144. int modeId;
  145. int acqType;
  146. int imageWidth;
  147. int imageHeight;
  148. int linesPerPixel;
  149. int colsPerPixel;
  150. int imageSize;
  151. float maxFrameRate;
  152. char modeDescription[STRLEN];
  153. };
  154. /*
  155. * Structure used to save the correction option.
  156. * fixedCorr ¡ª TRUE enable fixed method correction;FALSE disable
  157. * non_fixedCorr ¡ª TRUE enable portable method correction for fixed detector; FALSE disable.
  158. * portableCorr ¡ª TRUE enable portable method correction for mobile detector; FALSE disable.
  159. */
  160. struct UserCorrection
  161. {
  162. BOOL fixedCorr;
  163. BOOL non_fixedCorr;
  164. BOOL portableCorr;
  165. };
  166. /*
  167. * Structure used to get rad mode exposure parameters.
  168. *
  169. * expStatus ¡ª see ExposureStatus
  170. * inside_offs_corrflag ¡ª
  171. * realtime_offset ¡ª if contain offset image int the first image
  172. * frame_number ¡ª The number of frames acquired.
  173. * fetchable ¡ª The acquisition or calibration process is complete or not. FALSE: completed, TRUE: complete.
  174. * calComplete ¡ª TRUE: calibration complete, FALSE: calibration in progress or not in progress.
  175. * errorCode ¡ª Non zero means an error occured.
  176. * expose_flag ¡ª expose flag used in auto or manual sync
  177. */
  178. struct ExpProgress
  179. {
  180. int expStatus;
  181. BOOL inside_offs_corrflag;
  182. int realtime_offset;
  183. int frame_number;
  184. BOOL fetchable;
  185. int errorCode;
  186. BOOL calComplete;
  187. BOOL expose_flag;
  188. };
  189. //for rad mode
  190. struct CalibProgress
  191. {
  192. int expStatus;
  193. int expTime;
  194. int totalFrameNum;
  195. int currentFrameNum;
  196. BOOL fetchable;
  197. int errorCode;
  198. BOOL calComplete;
  199. BOOL expose_flag;
  200. };
  201. //only for fluoro mode
  202. struct CalibrationInfo
  203. {
  204. int nTotalFrameNum;
  205. int nCurrentFrameNum;
  206. int nCurrentFrameMeanValue;
  207. char szErrorMsg[256];
  208. int nResult;
  209. int nTargetGrayValue;
  210. int nExposureReady;
  211. int nExposureDetected;
  212. int nFrameNumAcquiredInDetr;
  213. int nFrameNumEnough;
  214. };
  215. struct FrameAttr
  216. {
  217. int image_width; //!<The object image width of the detector
  218. int image_height; //!<The object image height of the detector
  219. int pixel_bits; //!<the number of every pixel of the object image.
  220. int image_datatype; //UINT_16 or UINT_32
  221. };
  222. struct UnuploadedImgInfo
  223. {
  224. BOOL existFlag; //resume image flag
  225. int width;
  226. int height;
  227. float finishedRate; //transferred rate
  228. BOOL withHead;
  229. int bitDepth;
  230. };
  231. struct CalParams
  232. {
  233. char gain_image_dir[STRLEN];
  234. char portable_cal_kv[STRLEN];//used for 1500Rm or 1500P and so on
  235. char normal_cal_kv[STRLEN]; //used for 1500R or 500M and so on
  236. int ofst_cal_num; //offset image number in dark calibration
  237. int linear_dose_num; //dose number in gain calibration
  238. int linear_num_per_dose; //exposure number per dose in gain calibration
  239. int time_interval; //every calibration image's time interval
  240. };
  241. struct DetectorActiveState
  242. {
  243. int detectorNum; //1, single; 2, dual detectors
  244. int detectorAType;
  245. int detectorBType;
  246. int activeDetectorID;
  247. BOOL detectorAstate; //TRUE, connected
  248. BOOL detectorBstate; //TRUE, connected
  249. };
  250. struct SurfaceFitResult
  251. {
  252. float R2; //calibration threshold
  253. int x0; //reserved
  254. int y0;//reserved
  255. float param1;//reserved
  256. float param2;//reserved
  257. float param3;//reserved
  258. float param4;//reserved
  259. };
  260. struct irDA
  261. {
  262. int irDAEnable;
  263. int irDAOffset;
  264. int irDAPulse;
  265. int irDAIHTL;
  266. int irDAILTL;
  267. int irDAGain;
  268. int irDADrive;
  269. };
  270. struct SHSParam
  271. {
  272. char hardwareVersion[STRLEN];
  273. char pairedID[STRLEN];
  274. int heartbeatInterval;
  275. int timeoutPeriod; //unit: min, timeout for detector to shut down
  276. int buzzerEnabled;
  277. int touchSensorEnabled;
  278. irDA irDACfg;
  279. int handSwitchEnabled;
  280. };
  281. struct SHSStatus
  282. {
  283. int connectedToDetector;
  284. int beingTouched;
  285. int batteryRemainingCapacity;
  286. int signalIntensity;
  287. int secondsLeft; //seconds left to shut down detector
  288. SHSParam handSwitchSettings;
  289. };
  290. struct WirelessStationConf
  291. {
  292. char wireless_station_SSID[STRLEN];
  293. char wireless_mode[STRLEN];
  294. char wireless_channel[STRLEN];
  295. };
  296. struct TrainHead
  297. {
  298. float temperature;
  299. int integTime;
  300. long generatedTime;
  301. int reserved[5];
  302. };
  303. struct TemperatureSlotWarnMsg
  304. {
  305. int nDetectorID;
  306. int nMissingExpTime;
  307. float fMissingTemperature;
  308. float fCurrentTemperature;
  309. float fToleranceTemperature;
  310. };
  311. struct TemperatureSlotTrainMsg
  312. {
  313. int nDetectorID;
  314. int nExpTimeOfSlot;
  315. float fTemperatureOfSlot;
  316. };
  317. enum DetectorType
  318. {
  319. CareView_1500R,
  320. CareView_1500Rm,
  321. CareView_1500P,
  322. CareView_1500C,
  323. CareView_1800R,
  324. CareView_500M,
  325. CareView_500I,
  326. CareView_500P,
  327. CareView_900F,
  328. CareView_1800I,
  329. CareView_1500L,
  330. CareView_1500Cw,
  331. CareView_300P,
  332. CareView_750M,
  333. CareView_1800L,
  334. CareView_1800RV2,
  335. CareView_1500PV2,
  336. CareView_750Cw,
  337. CareView_0331IF,
  338. CareView_750I,
  339. CareView_1800IF,
  340. CareView_750C,
  341. CareView_1800Cw,
  342. CareView_1500S,
  343. CareView_750S,
  344. CareView_750Mc,
  345. CareView_240I,
  346. CareView_1800RF,
  347. CareView_1800LE,
  348. CareView_1800CwE,
  349. AniView_D4343,
  350. CareView_1500CwE,
  351. CareView_1500Sf,
  352. CareView_750Sf,
  353. CareView_1500CwII,
  354. Unkown_Type //δ֪ÐͺÅ
  355. };
  356. /*
  357. * Enum for detector mode
  358. *
  359. * CR_RAD_MODE ¡ª Rad mode
  360. * CR_FLUORO_MODE ¡ª Fluoro mode
  361. * CR_LAGFLUORO_MODE ¡ª Lag testing mode
  362. * CR_CUSTFLUORO_MODE ¡ª Customized fluoro mode
  363. */
  364. enum CheckMode
  365. {
  366. MODE_UNDEFINED = 0,
  367. MODE_RAD=0x10,
  368. MODE_TEST = 0x14, //!<used just for self-test
  369. MODE_BIN22 = 0x15,
  370. MODE_NDT = 0x16, //NDT mode, for industry application.
  371. MODE_PREV = 0x17, //preview mode, for 500M
  372. MODE_BIN44= 0x18,
  373. MODE_BIN88= 0x19,
  374. MODE_DUAL_ENERGY = 0x1A,
  375. MODE_FLU_ROI_A_BIN11 = 0x1B, //1280 x 1280, 1-bin
  376. MODE_FLU_ROI_A_BIN22 = 0x1C, //640 x 640, 2-bin
  377. MODE_FLU_FULLSIZE_BIN22 = 0x1D, //1408 x 1152, 2-bin
  378. MODE_MAXID
  379. };
  380. /*
  381. * Enum for detector state
  382. *
  383. * CR_BOOT ¡ª Detector is booting
  384. * CR_STANDBY ¡ª Detector is ready, waiting for command
  385. * CR_ACQUISTION ¡ª Detector is in image acquisition state
  386. * CR_SLEEP ¡ª Detector is in sleeping mode
  387. * CR_ERROR ¡ª An error occured
  388. */
  389. enum DetectorState
  390. {
  391. CR_BOOT,
  392. CR_STANDBY,
  393. CR_ACQUISTION,
  394. CR_SLEEP,
  395. CR_ERROR
  396. };
  397. enum CalibrationType
  398. {
  399. CR_CALIB_OFFSET,
  400. CR_CALIB_GAIN
  401. };
  402. /*
  403. * Enum for exposure state
  404. *
  405. * CR_EXP_ERROR ¡ª An error occurred
  406. * CR_EXP_INIT ¡ª Detector is initiating
  407. * CR_EXP_READY ¡ª Detector is ready for x-ray pulse
  408. * CR_EXP_WAIT_PERMISSION ¡ª X-ray pulse comes. Detector is waiting for PC¡®s exposure permission.
  409. * CR_EXP_PERMITTED ¡ª PC¡¯s permission is received
  410. * CR_EXP_EXPOSE ¡ª X-ray exposure is in progress
  411. * CR_EXP_COMPLETE ¡ª Exposure complete, image will be ready soon
  412. * EXP_STANDBY ¡ª no use
  413. */
  414. enum ExposureStatus
  415. {
  416. CR_EXP_ERROR = -1,
  417. CR_EXP_INIT,
  418. CR_EXP_READY,
  419. CR_EXP_WAIT_PERMISSION,
  420. CR_EXP_PERMITTED,
  421. CR_EXP_EXPOSE,
  422. CR_EXP_COMPLETE,
  423. };
  424. /*
  425. * Enum for progress type to query
  426. *
  427. * CR_RAD_PROG ¡ª Query rad acquisition progress
  428. * CR_CAL_PROG ¡ª Query calibration progress
  429. */
  430. enum ProgType
  431. {
  432. CR_RAD_PROG, //Query rad acquisition progress
  433. CR_CAL_PROG //Query calibration progress
  434. };
  435. //ͬ²½Ä£Ê½
  436. enum SyncMode
  437. {
  438. UNDEF_SYNC, //undefined sync mode
  439. EXT_SYNC, //external sync mode (exist sync cable)
  440. SOFT_SYNC, //software sync mode
  441. AUTO_SYNC, //auto sync mode
  442. MANUAL_SYNC, //manual sync mode
  443. SCAN_SYNC,
  444. AED_SYNC
  445. };
  446. /*!
  447. @enum POWER_MODE_ID
  448. @¹¦ºÄģʽ
  449. @brief power mode IDs, provide multiplex power management pattern for detector.
  450. */
  451. enum PowerMode
  452. {
  453. PWR_STANDBY, //set front-end into nap mode
  454. PWR_FULL_RUNNING, //set front-end into normal mode.
  455. PWR_SMART_RUNNING, //set front-end into nap mode at the integration phase.
  456. PWR_DOWN_FE = 4, //set front-end into power-down mode.
  457. PWR_SLEEPING, //unsupported
  458. PWR_DEEP_SLEEPING, //unsupported
  459. PWR_SUSPEND //unsupported
  460. };
  461. enum ImageDataType
  462. {
  463. UINT_16, //full image
  464. UINT_32,
  465. INT_16,
  466. INT_32,
  467. FLOAT_32,
  468. DOUBLE_64
  469. };
  470. enum TempStatus
  471. {
  472. IN_NORMAL_TEMP=0, //status indicator turns green
  473. IN_WARN_TEMP, //status indicator turns yellow
  474. OVER_MAX_TEMP_LIMIT, //status indicator turns red, and take the detector into low power, neither enter to 'ready' state.
  475. OVER_MIN_TEMP_LIMIT, //status indicator turns red.
  476. INVAILD_TEMP //invalid temperature turns orange
  477. };
  478. enum DetectorIndex
  479. {
  480. DETECTOR_I,
  481. DETECTOR_II
  482. };
  483. enum TemperatureSlotStatus
  484. {
  485. TEMP_SLOT_EXIST,
  486. TEMP_SLOT_ABSENCE,
  487. };
  488. //////////////////////////////////////////////////////////////////////////
  489. enum event_id
  490. {
  491. EVT_DISCONNECT,
  492. EVT_READY,
  493. EVT_EXP_EN,
  494. EVT_IMAGE_ARRIVE,
  495. EVT_AEC_PREV_MODE_READY,
  496. EVT_AEC_RAD_MODE_READY,
  497. EVT_AEC_PREV_IMG_ARRIVE,
  498. EVT_AEC_RAD_IMG_ARRIVE,
  499. EVT_DETECTOR_ERROR,
  500. EVT_EXPOSE_FLAG_FALSE,
  501. EVT_EXPOSE_FLAG_TRUE,
  502. EVT_INITIAL,
  503. EVT_UNUPLOADED_IMG_EXIST,
  504. EVT_CONNECTED,
  505. EVT_SECOND_PANEL_CONNECTED,
  506. EVT_SECOND_PANEL_DISCONNECTED,
  507. EVT_SHS_STATUS_CHANGED,
  508. EVT_IMAGE_TRANSFER_FAILED,
  509. EVT_TEMPERATURE_SLOT_MISSING,
  510. EVT_TEMPERATURE_SLOT_TRAIN_START,
  511. EVT_TEMPERATURE_SLOT_TRAIN_FINISH,
  512. EVT_TEMPERATURE_SLOT_TRAIN_ABORT,
  513. EVT_USELESS_IMAGE,
  514. EVT_EXP_PROGRESS,
  515. EVT_NEW_FRAME,
  516. EVT_CALIB_IN_PROGRESS,
  517. EVT_CALIB_FINISHED,
  518. EVT_PREV_IMAGE_ARRIVED,
  519. EVT_CALIB_FILES_DOWNLOAD_FAILED
  520. };
  521. struct Event
  522. {
  523. int width;
  524. int height;
  525. int bits;
  526. void* data;
  527. };
  528. typedef void (__stdcall*eventCallback)(int eventID, Event* eventData);
  529. #endif // __STRUCTURES_H__