n2h5.cpp 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493
  1. //////////////////////////////////////////////////////////////////////////////
  2. //
  3. // (c) Copyright 2012 Blackrock Microsystems
  4. //
  5. // $Workfile: n2h5.c $
  6. // $Archive: /n2h5/n2h5.c $
  7. // $Revision: 1 $
  8. // $Date: 11/1/12 1:00p $
  9. // $Author: Ehsan $
  10. //
  11. // $NoKeywords: $
  12. //
  13. //////////////////////////////////////////////////////////////////////////////
  14. //
  15. // PURPOSE:
  16. //
  17. // Implementation of our types in terms of hdf5 types
  18. //
  19. // Note: all the types are committed to the most immediate parent group
  20. // while we try to keep the types in different version the same,
  21. // one should try to base reading on the field names rather than types
  22. //
  23. //////////////////////////////////////////////////////////////////////////////
  24. #include "stdafx.h"
  25. #include "n2h5.h"
  26. // Author & Date: Ehsan Azar Nov 13, 2012
  27. // Purpose: Create type for BmiFiltAttr_t and commit
  28. // Inputs:
  29. // loc - where to add the type
  30. // Outputs:
  31. // Returns the type id
  32. hid_t CreateFiltAttrType(hid_t loc)
  33. {
  34. herr_t ret;
  35. hid_t tid = -1;
  36. std::string strLink = "BmiFiltAttr_t";
  37. // If already there return it
  38. if(H5Lexists(loc, strLink.c_str(), H5P_DEFAULT))
  39. {
  40. tid = H5Topen(loc, strLink.c_str(), H5P_DEFAULT);
  41. return tid;
  42. }
  43. tid = H5Tcreate(H5T_COMPOUND, sizeof(BmiFiltAttr_t));
  44. ret = H5Tinsert(tid, "HighPassFreq", offsetof(BmiFiltAttr_t, hpfreq), H5T_NATIVE_UINT32);
  45. ret = H5Tinsert(tid, "HighPassOrder", offsetof(BmiFiltAttr_t, hporder), H5T_NATIVE_UINT32);
  46. ret = H5Tinsert(tid, "HighPassType", offsetof(BmiFiltAttr_t, hptype), H5T_NATIVE_UINT16);
  47. ret = H5Tinsert(tid, "LowPassFreq", offsetof(BmiFiltAttr_t, lpfreq), H5T_NATIVE_UINT32);
  48. ret = H5Tinsert(tid, "LowPassOrder", offsetof(BmiFiltAttr_t, lporder), H5T_NATIVE_UINT32);
  49. ret = H5Tinsert(tid, "LowPassType", offsetof(BmiFiltAttr_t, lptype), H5T_NATIVE_UINT16);
  50. ret = H5Tcommit(loc, strLink.c_str(), tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
  51. return tid;
  52. }
  53. // Author & Date: Ehsan Azar Nov 13, 2012
  54. // Purpose: Create type for BmiChanExtAttr_t and commit
  55. // Inputs:
  56. // loc - where to add the type
  57. // Outputs:
  58. // Returns the type id
  59. hid_t CreateChanExtAttrType(hid_t loc)
  60. {
  61. herr_t ret;
  62. hid_t tid = -1;
  63. std::string strLink = "BmiChanExtAttr_t";
  64. // If already there return it
  65. if(H5Lexists(loc, strLink.c_str(), H5P_DEFAULT))
  66. {
  67. tid = H5Topen(loc, strLink.c_str(), H5P_DEFAULT);
  68. return tid;
  69. }
  70. tid = H5Tcreate(H5T_COMPOUND, sizeof(BmiChanExtAttr_t));
  71. ret = H5Tinsert(tid, "NanoVoltsPerLSB", offsetof(BmiChanExtAttr_t, dFactor), H5T_NATIVE_DOUBLE);
  72. ret = H5Tinsert(tid, "PhysicalConnector", offsetof(BmiChanExtAttr_t, phys_connector), H5T_NATIVE_UINT8);
  73. ret = H5Tinsert(tid, "ConnectorPin", offsetof(BmiChanExtAttr_t, connector_pin), H5T_NATIVE_UINT8);
  74. ret = H5Tcommit(loc, strLink.c_str(), tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
  75. return tid;
  76. }
  77. // Author & Date: Ehsan Azar Nov 13, 2012
  78. // Purpose: Create type for BmiChanExt1Attr_t and commit
  79. // Inputs:
  80. // loc - where to add the type
  81. // Outputs:
  82. // Returns the type id
  83. hid_t CreateChanExt1AttrType(hid_t loc)
  84. {
  85. herr_t ret;
  86. hid_t tid = -1;
  87. std::string strLink = "BmiChanExt1Attr_t";
  88. // If already there return it
  89. if(H5Lexists(loc, strLink.c_str(), H5P_DEFAULT))
  90. {
  91. tid = H5Topen(loc, strLink.c_str(), H5P_DEFAULT);
  92. return tid;
  93. }
  94. tid = H5Tcreate(H5T_COMPOUND, sizeof(BmiChanExt1Attr_t));
  95. ret = H5Tinsert(tid, "SortCount", offsetof(BmiChanExt1Attr_t, sortCount), H5T_NATIVE_UINT8);
  96. ret = H5Tinsert(tid, "EnergyThreshold", offsetof(BmiChanExt1Attr_t, energy_thresh), H5T_NATIVE_UINT32);
  97. ret = H5Tinsert(tid, "HighThreshold", offsetof(BmiChanExt1Attr_t, high_thresh), H5T_NATIVE_INT32);
  98. ret = H5Tinsert(tid, "LowThreshold", offsetof(BmiChanExt1Attr_t, low_thresh), H5T_NATIVE_INT32);
  99. ret = H5Tcommit(loc, strLink.c_str(), tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
  100. return tid;
  101. }
  102. // Author & Date: Ehsan Azar Nov 13, 2012
  103. // Purpose: Create type for BmiChanExt2Attr_t and commit
  104. // Inputs:
  105. // loc - where to add the type
  106. // Outputs:
  107. // Returns the type id
  108. hid_t CreateChanExt2AttrType(hid_t loc)
  109. {
  110. herr_t ret;
  111. hid_t tid = -1;
  112. std::string strLink = "BmiChanExt2Attr_t";
  113. // If already there return it
  114. if(H5Lexists(loc, strLink.c_str(), H5P_DEFAULT))
  115. {
  116. tid = H5Topen(loc, strLink.c_str(), H5P_DEFAULT);
  117. return tid;
  118. }
  119. hid_t tid_attr_unit_str = H5Tcopy(H5T_C_S1);
  120. ret = H5Tset_size(tid_attr_unit_str, 16);
  121. tid = H5Tcreate(H5T_COMPOUND, sizeof(BmiChanExt2Attr_t));
  122. ret = H5Tinsert(tid, "DigitalMin", offsetof(BmiChanExt2Attr_t, digmin), H5T_NATIVE_INT32);
  123. ret = H5Tinsert(tid, "DigitalMax", offsetof(BmiChanExt2Attr_t, digmax), H5T_NATIVE_INT32);
  124. ret = H5Tinsert(tid, "AnalogMin", offsetof(BmiChanExt2Attr_t, anamin), H5T_NATIVE_INT32);
  125. ret = H5Tinsert(tid, "AnalogMax", offsetof(BmiChanExt2Attr_t, anamax), H5T_NATIVE_INT32);
  126. ret = H5Tinsert(tid, "AnalogUnit", offsetof(BmiChanExt2Attr_t, anaunit), tid_attr_unit_str);
  127. ret = H5Tcommit(loc, strLink.c_str(), tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
  128. H5Tclose(tid_attr_unit_str);
  129. return tid;
  130. }
  131. // Author & Date: Ehsan Azar Nov 13, 2012
  132. // Purpose: Create type for BmiChanAttr_t and commit
  133. // Inputs:
  134. // loc - where to add the type
  135. // Outputs:
  136. // Returns the type id
  137. hid_t CreateChanAttrType(hid_t loc)
  138. {
  139. herr_t ret;
  140. hid_t tid = -1;
  141. std::string strLink = "BmiChanAttr_t";
  142. // If already there return it
  143. if(H5Lexists(loc, strLink.c_str(), H5P_DEFAULT))
  144. {
  145. tid = H5Topen(loc, strLink.c_str(), H5P_DEFAULT);
  146. return tid;
  147. }
  148. hid_t tid_attr_label_str = H5Tcopy(H5T_C_S1);
  149. ret = H5Tset_size(tid_attr_label_str, 64);
  150. tid = H5Tcreate(H5T_COMPOUND, sizeof(BmiChanAttr_t));
  151. ret = H5Tinsert(tid, "ID", offsetof(BmiChanAttr_t, id), H5T_NATIVE_UINT16);
  152. ret = H5Tinsert(tid, "Label", offsetof(BmiChanAttr_t, szLabel), tid_attr_label_str);
  153. ret = H5Tcommit(loc, strLink.c_str(), tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
  154. H5Tclose(tid_attr_label_str);
  155. return tid;
  156. }
  157. // Author & Date: Ehsan Azar Nov 13, 2012
  158. // Purpose: Create type for BmiSamplingAttr_t and commit
  159. // Inputs:
  160. // loc - where to add the type
  161. // Outputs:
  162. // Returns the type id
  163. hid_t CreateSamplingAttrType(hid_t loc)
  164. {
  165. herr_t ret;
  166. hid_t tid = -1;
  167. std::string strLink = "BmiSamplingAttr_t";
  168. // If already there return it
  169. if(H5Lexists(loc, strLink.c_str(), H5P_DEFAULT))
  170. {
  171. tid = H5Topen(loc, strLink.c_str(), H5P_DEFAULT);
  172. return tid;
  173. }
  174. tid = H5Tcreate(H5T_COMPOUND, sizeof(BmiSamplingAttr_t));
  175. ret = H5Tinsert(tid, "Clock", offsetof(BmiSamplingAttr_t, fClock), H5T_NATIVE_FLOAT);
  176. ret = H5Tinsert(tid, "SampleRate", offsetof(BmiSamplingAttr_t, fSampleRate), H5T_NATIVE_FLOAT);
  177. ret = H5Tinsert(tid, "SampleBits", offsetof(BmiSamplingAttr_t, nSampleBits), H5T_NATIVE_UINT8);
  178. ret = H5Tcommit(loc, strLink.c_str(), tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
  179. return tid;
  180. }
  181. // Author & Date: Ehsan Azar Nov 13, 2012
  182. // Purpose: Create type for BmiRootAttr_t and commit
  183. // Inputs:
  184. // loc - where to add the type
  185. // Outputs:
  186. // Returns the type id
  187. hid_t CreateRootAttrType(hid_t loc)
  188. {
  189. herr_t ret;
  190. hid_t tid = -1;
  191. std::string strLink = "BmiRootAttr_t";
  192. // If already there return it
  193. if(H5Lexists(loc, strLink.c_str(), H5P_DEFAULT))
  194. {
  195. tid = H5Topen(loc, strLink.c_str(), H5P_DEFAULT);
  196. return tid;
  197. }
  198. hid_t tid_attr_str = H5Tcopy(H5T_C_S1);
  199. ret = H5Tset_size(tid_attr_str, 64);
  200. hid_t tid_attr_comment_str = H5Tcopy(H5T_C_S1);
  201. ret = H5Tset_size(tid_attr_comment_str, 1024);
  202. tid = H5Tcreate(H5T_COMPOUND, sizeof(BmiRootAttr_t));
  203. ret = H5Tinsert(tid, "MajorVersion", offsetof(BmiRootAttr_t, nMajorVersion), H5T_NATIVE_UINT32);
  204. ret = H5Tinsert(tid, "MinorVersion", offsetof(BmiRootAttr_t, nMinorVersion), H5T_NATIVE_UINT32);
  205. ret = H5Tinsert(tid, "Flags", offsetof(BmiRootAttr_t, nFlags), H5T_NATIVE_UINT32);
  206. ret = H5Tinsert(tid, "GroupCount", offsetof(BmiRootAttr_t, nGroupCount), H5T_NATIVE_UINT32);
  207. ret = H5Tinsert(tid, "Date", offsetof(BmiRootAttr_t, szDate), tid_attr_str); // date of the file creation
  208. ret = H5Tinsert(tid, "Application", offsetof(BmiRootAttr_t, szApplication), tid_attr_str); // application that created the file
  209. ret = H5Tinsert(tid, "Comment", offsetof(BmiRootAttr_t, szComment), tid_attr_comment_str); // file comments
  210. ret = H5Tcommit(loc, strLink.c_str(), tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
  211. H5Tclose(tid_attr_str);
  212. H5Tclose(tid_attr_comment_str);
  213. return tid;
  214. }
  215. // Author & Date: Ehsan Azar Nov 17, 2012
  216. // Purpose: Create type for BmiSynchAttr_t and commit
  217. // Inputs:
  218. // loc - where to add the type
  219. // Outputs:
  220. // Returns the type id
  221. hid_t CreateSynchAttrType(hid_t loc)
  222. {
  223. herr_t ret;
  224. hid_t tid = -1;
  225. std::string strLink = "BmiSynchAttr_t";
  226. // If already there return it
  227. if(H5Lexists(loc, strLink.c_str(), H5P_DEFAULT))
  228. {
  229. tid = H5Topen(loc, strLink.c_str(), H5P_DEFAULT);
  230. return tid;
  231. }
  232. hid_t tid_attr_label_str = H5Tcopy(H5T_C_S1);
  233. ret = H5Tset_size(tid_attr_label_str, 64);
  234. tid = H5Tcreate(H5T_COMPOUND, sizeof(BmiSynchAttr_t));
  235. ret = H5Tinsert(tid, "ID", offsetof(BmiSynchAttr_t, id), H5T_NATIVE_UINT16);
  236. ret = H5Tinsert(tid, "Label", offsetof(BmiSynchAttr_t, szLabel), tid_attr_label_str);
  237. ret = H5Tinsert(tid, "FPS", offsetof(BmiSynchAttr_t, fFps), H5T_NATIVE_FLOAT);
  238. ret = H5Tcommit(loc, strLink.c_str(), tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
  239. H5Tclose(tid_attr_label_str);
  240. return tid;
  241. }
  242. // Author & Date: Ehsan Azar Nov 13, 2012
  243. // Purpose: Create type for BmiTrackingAttr_t and commit
  244. // Inputs:
  245. // loc - where to add the type
  246. // Outputs:
  247. // Returns the type id
  248. hid_t CreateTrackingAttrType(hid_t loc)
  249. {
  250. herr_t ret;
  251. hid_t tid = -1;
  252. std::string strLink = "BmiTrackingAttr_t";
  253. // If already there return it
  254. if(H5Lexists(loc, strLink.c_str(), H5P_DEFAULT))
  255. {
  256. tid = H5Topen(loc, strLink.c_str(), H5P_DEFAULT);
  257. return tid;
  258. }
  259. hid_t tid_attr_label_str = H5Tcopy(H5T_C_S1);
  260. ret = H5Tset_size(tid_attr_label_str, 128);
  261. tid = H5Tcreate(H5T_COMPOUND, sizeof(BmiTrackingAttr_t));
  262. ret = H5Tinsert(tid, "Label", offsetof(BmiTrackingAttr_t, szLabel), tid_attr_label_str);
  263. ret = H5Tinsert(tid, "Type", offsetof(BmiTrackingAttr_t, type), H5T_NATIVE_UINT16);
  264. ret = H5Tinsert(tid, "TrackID", offsetof(BmiTrackingAttr_t, trackID), H5T_NATIVE_UINT16);
  265. ret = H5Tinsert(tid, "MaxPoints", offsetof(BmiTrackingAttr_t, maxPoints), H5T_NATIVE_UINT16);
  266. ret = H5Tcommit(loc, strLink.c_str(), tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
  267. H5Tclose(tid_attr_label_str);
  268. return tid;
  269. }
  270. // Author & Date: Ehsan Azar Nov 13, 2012
  271. // Purpose: Create type for BmiSpike16_t and commit
  272. // Note: For performance reasons and because spike length is constant during
  273. // and experiment we use fixed-length array here instead of varible-length
  274. // Inputs:
  275. // loc - where to add the type
  276. // spikeLength - the spike length to use
  277. // Outputs:
  278. // Returns the type id
  279. hid_t CreateSpike16Type(hid_t loc, uint16_t spikeLength)
  280. {
  281. herr_t ret;
  282. hid_t tid = -1;
  283. // e.g. for spike length of 48 type name will be "BmiSpike16_48_t"
  284. char szNum[4] = {'\0'};
  285. sprintf(szNum, "%u", spikeLength);
  286. std::string strLink = "BmiSpike16_";
  287. strLink += szNum;
  288. strLink += "_t";
  289. // If already there return it
  290. if(H5Lexists(loc, strLink.c_str(), H5P_DEFAULT))
  291. {
  292. tid = H5Topen(loc, strLink.c_str(), H5P_DEFAULT);
  293. return tid;
  294. }
  295. hsize_t dims[1] = {spikeLength};
  296. hid_t tid_arr_wave = H5Tarray_create(H5T_NATIVE_INT16, 1, dims);
  297. tid = H5Tcreate(H5T_COMPOUND, offsetof(BmiSpike16_t, wave) + sizeof(int16_t) * spikeLength);
  298. ret = H5Tinsert(tid, "TimeStamp", offsetof(BmiSpike16_t, dwTimestamp), H5T_NATIVE_UINT32);
  299. ret = H5Tinsert(tid, "Unit", offsetof(BmiSpike16_t, unit), H5T_NATIVE_UINT8);
  300. ret = H5Tinsert(tid, "Wave", offsetof(BmiSpike16_t, wave), tid_arr_wave);
  301. ret = H5Tcommit(loc, strLink.c_str(), tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
  302. H5Tclose(tid_arr_wave);
  303. return tid;
  304. }
  305. // Author & Date: Ehsan Azar Nov 23, 2012
  306. // Purpose: Create type for BmiDig16_t and commit
  307. // Inputs:
  308. // loc - where to add the type
  309. // Outputs:
  310. // Returns the type id
  311. hid_t CreateDig16Type(hid_t loc)
  312. {
  313. herr_t ret;
  314. hid_t tid = -1;
  315. std::string strLink = "BmiDig16_t";
  316. // If already there return it
  317. if(H5Lexists(loc, strLink.c_str(), H5P_DEFAULT))
  318. {
  319. tid = H5Topen(loc, strLink.c_str(), H5P_DEFAULT);
  320. return tid;
  321. }
  322. tid = H5Tcreate(H5T_COMPOUND, sizeof(BmiDig16_t));
  323. ret = H5Tinsert(tid, "TimeStamp", offsetof(BmiDig16_t, dwTimestamp), H5T_NATIVE_UINT32);
  324. ret = H5Tinsert(tid, "Value", offsetof(BmiDig16_t, value), H5T_NATIVE_UINT16);
  325. ret = H5Tcommit(loc, strLink.c_str(), tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
  326. return tid;
  327. }
  328. // Author & Date: Ehsan Azar Nov 13, 2012
  329. // Purpose: Create type for BmiSynch_t and commit
  330. // Inputs:
  331. // loc - where to add the type
  332. // Outputs:
  333. // Returns the type id
  334. hid_t CreateSynchType(hid_t loc)
  335. {
  336. herr_t ret;
  337. hid_t tid = H5Tcreate(H5T_COMPOUND, sizeof(BmiSynch_t));
  338. ret = H5Tinsert(tid, "TimeStamp", offsetof(BmiSynch_t, dwTimestamp), H5T_NATIVE_UINT32);
  339. ret = H5Tinsert(tid, "Split", offsetof(BmiSynch_t, split), H5T_NATIVE_UINT16);
  340. ret = H5Tinsert(tid, "Frame", offsetof(BmiSynch_t, frame), H5T_NATIVE_UINT32);
  341. ret = H5Tinsert(tid, "ElapsedTime", offsetof(BmiSynch_t, etime), H5T_NATIVE_UINT32);
  342. ret = H5Tcommit(loc, "BmiSynch_t", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
  343. return tid;
  344. }
  345. // Author & Date: Ehsan Azar Nov 20, 2012
  346. // Purpose: Create type for BmiTracking_t and commit
  347. // Inputs:
  348. // loc - where to add the type
  349. // dim - dimension (1D, 2D or 3D)
  350. // width - datapoint width in bytes
  351. // Outputs:
  352. // Returns the type id
  353. hid_t CreateTrackingType(hid_t loc, int dim, int width)
  354. {
  355. herr_t ret;
  356. hid_t tid_coords;
  357. std::string strLabel = "BmiTracking";
  358. // e.g. for 1D (32-bit) fixed-length, type name will be "BmiTracking32_1D_t"
  359. // for 2D (16-bit) fixed-length, type name will be "BmiTracking16_2D_t"
  360. switch (width)
  361. {
  362. case 1:
  363. strLabel += "8";
  364. tid_coords = H5Tcopy(H5T_NATIVE_UINT8);
  365. break;
  366. case 2:
  367. strLabel += "16";
  368. tid_coords = H5Tcopy(H5T_NATIVE_UINT16);
  369. break;
  370. case 4:
  371. strLabel += "32";
  372. tid_coords = H5Tcopy(H5T_NATIVE_UINT32);
  373. break;
  374. default:
  375. return 0;
  376. // should not happen
  377. break;
  378. }
  379. switch (dim)
  380. {
  381. case 1:
  382. strLabel += "_1D";
  383. break;
  384. case 2:
  385. strLabel += "_2D";
  386. break;
  387. case 3:
  388. strLabel += "_3D";
  389. break;
  390. default:
  391. return 0;
  392. // should not happen
  393. break;
  394. }
  395. strLabel += "_t";
  396. hid_t tid = -1;
  397. if(H5Lexists(loc, strLabel.c_str(), H5P_DEFAULT))
  398. {
  399. tid = H5Topen(loc, strLabel.c_str(), H5P_DEFAULT);
  400. } else {
  401. tid = H5Tcreate(H5T_COMPOUND, offsetof(BmiTracking_fl_t, coords) + dim * width * 1);
  402. ret = H5Tinsert(tid, "TimeStamp", offsetof(BmiTracking_fl_t, dwTimestamp), H5T_NATIVE_UINT32);
  403. ret = H5Tinsert(tid, "ParentID", offsetof(BmiTracking_fl_t, parentID), H5T_NATIVE_UINT16);
  404. ret = H5Tinsert(tid, "NodeCount", offsetof(BmiTracking_fl_t, nodeCount), H5T_NATIVE_UINT16);
  405. ret = H5Tinsert(tid, "ElapsedTime", offsetof(BmiTracking_fl_t, etime), H5T_NATIVE_UINT32);
  406. char corrd_labels[3][2] = {"x", "y", "z"};
  407. for (int i = 0; i < dim; ++i)
  408. ret = H5Tinsert(tid, corrd_labels[i], offsetof(BmiTracking_fl_t, coords) + i * width, tid_coords);
  409. ret = H5Tcommit(loc, strLabel.c_str(), tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
  410. }
  411. H5Tclose(tid_coords);
  412. return tid;
  413. }
  414. // Author & Date: Ehsan Azar Nov 19, 2012
  415. // Purpose: Create type for BmiComment_t and commit
  416. // Inputs:
  417. // loc - where to add the type
  418. // Outputs:
  419. // Returns the type id
  420. hid_t CreateCommentType(hid_t loc)
  421. {
  422. herr_t ret;
  423. // Use fixed-size comments because
  424. // it is faster, more tools support it, and also allows compression
  425. hid_t tid_str_array = H5Tcopy(H5T_C_S1);
  426. ret = H5Tset_size(tid_str_array, BMI_COMMENT_LEN);
  427. hid_t tid = H5Tcreate(H5T_COMPOUND, sizeof(BmiComment_t));
  428. ret = H5Tinsert(tid, "TimeStamp", offsetof(BmiComment_t, dwTimestamp), H5T_NATIVE_UINT32);
  429. ret = H5Tinsert(tid, "Data", offsetof(BmiComment_t, data), H5T_NATIVE_UINT32);
  430. ret = H5Tinsert(tid, "Flags", offsetof(BmiComment_t, flags), H5T_NATIVE_UINT8);
  431. ret = H5Tinsert(tid, "Comment", offsetof(BmiComment_t, szComment), tid_str_array);
  432. ret = H5Tcommit(loc, "BmiComment_t", tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
  433. H5Tclose(tid_str_array);
  434. return tid;
  435. }