public void H5resize_memoryTest2() { IntPtr size = new IntPtr(1024 * 1024); // uninitialized allocation IntPtr ptr = H5.allocate_memory(size, 0); Assert.IsFalse(ptr == IntPtr.Zero); // reallocate size = new IntPtr(1024 * 1024 * 10); IntPtr ptr1 = Marshal.ReAllocHGlobal(ptr, size); Assert.IsFalse(ptr1 == IntPtr.Zero); Assert.IsTrue(H5.free_memory(ptr1) >= 0); // reallocate to size zero -> free ptr = H5.allocate_memory(size, 1); Assert.IsFalse(ptr == IntPtr.Zero); size = new IntPtr(0); ptr1 = Marshal.ReAllocHGlobal(ptr, size); Assert.IsFalse(ptr1 == IntPtr.Zero); // H5resize_memory(NULL, 0) Returns NULL (undefined in C standard). size = new IntPtr(0); //Assert.IsTrue(Marshal.ReAllocHGlobal(IntPtr.Zero, size) == IntPtr.Zero); }
public void Start() { cli1_1.text = ""; cli2_1.text = ""; cli1_2.text = ""; cli2_2.text = ""; cli1_3.text = ""; cli2_3.text = ""; cli1_4.text = ""; cli2_4.text = ""; cli1_5.text = ""; cli2_5.text = ""; F1.SetActive(false); H1.SetActive(false); H11.SetActive(false); F2.SetActive(false); H2.SetActive(false); H22.SetActive(false); F3.SetActive(false); H3.SetActive(false); H33.SetActive(false); F4.SetActive(false); H4.SetActive(false); H44.SetActive(false); F5.SetActive(false); H5.SetActive(false); H55.SetActive(false); }
public void Reset(Control host) { H1.Reset(host); H2.Reset(host); H3.Reset(host); H4.Reset(host); H5.Reset(host); H6.Reset(host); BlockQuote.Reset(host); P.Reset(host); FigCaption.Reset(host); Pre.Reset(host); Dt.Reset(host); Dd.Reset(host); Li.Reset(host); A.Reset(host); Span.Reset(host); Label.Reset(host); Q.Reset(host); Cite.Reset(host); I.Reset(host); Em.Reset(host); Mark.Reset(host); Time.Reset(host); Code.Reset(host); Strong.Reset(host); }
private void Validate(ILogger logger, IOptions <HdfExplorerOptions> options) { uint isLibraryThreadSafe; // check thread safety of HDF library isLibraryThreadSafe = 0; H5.is_library_threadsafe(ref isLibraryThreadSafe); if (isLibraryThreadSafe <= 0) { logger.LogError("The libary 'hdf5.dll' is not thread safe."); } // asp base URL logger.LogInformation($"Listening on: { options.Value.AspBaseUrl }"); // check if database directory is confiured and existing if (string.IsNullOrWhiteSpace(options.Value.DataBaseFolderPath)) { logger.LogError($"No database directory path has been configured."); } else if (!Directory.Exists(options.Value.DataBaseFolderPath)) { logger.LogWarning($"Configured database directory path { options.Value.DataBaseFolderPath } does not exist."); } else { logger.LogInformation($"Database directory found at path: { options.Value.DataBaseFolderPath }"); } }
void EnsureH5Lib() { if (_h5_lib_id == null) { _h5_lib_id = H5.Open(); } }
//[Ignore] public void ShouldPersistToHDF5() { // Check and delete the HDF5 file here, NOT in TearDown, because we // want the file to exist after the test run (contrary to everything // unit-testing preaches) so that we can look at the file contents via // h5dump to verify what it looks like; unfortunately, at this time, // unit-testing HDF5 is a PITA (pain in the ass, for those of you // who are acronymatically challenged), so approval testing // is the next-best-thing we can do at the moment. if (File.Exists("..\\..\\..\\ShouldPersistToHDF5.h5")) { File.Delete("..\\..\\..\\ShouldPersistToHDF5.h5"); } var gID = new Guid("{2F2719F7-4A8C-4C22-9698-BE999DBC5385}"); using (var exp = new EpochHDF5Persistor("..\\..\\..\\ShouldPersistToHDF5.h5", null, () => gID)) { var time = new DateTimeOffset(1000, TimeSpan.Zero); var guid = new Guid("053C64D4-ED7A-4128-AA43-ED115716A97D"); var props = new Dictionary <string, object>(); props["key1"] = "value1"; props["key2"] = 2; exp.BeginEpochGroup("label", "source identifier", new[] { "keyword1", "keyword2" }, props, guid, time); exp.Serialize(testEpoch); exp.EndEpochGroup(); exp.Close(); } H5.Close(); Approvals.VerifyFile("..\\..\\..\\ShouldPersistToHDF5.h5"); }
public void H5TSdataset_creationTest1() { // run only if we have a thread-safe build of the library hbool_t flag = 0; Assert.IsTrue(H5.is_library_threadsafe(ref flag) >= 0); if (flag > 0) { // Create the new Thread and use the FileCreateProcedure method Thread1 = new Thread(new ThreadStart(DatasetCreateProcedure)); Thread1.Name = "Thread1"; Thread2 = new Thread(new ThreadStart(DatasetCreateProcedure)); Thread2.Name = "Thread2"; Thread3 = new Thread(new ThreadStart(DatasetCreateProcedure)); Thread3.Name = "Thread3"; Thread4 = new Thread(new ThreadStart(DatasetCreateProcedure)); Thread4.Name = "Thread4"; // Start running the thread Thread4.Start(); Thread2.Start(); Thread1.Start(); Thread3.Start(); // Join the independent thread to this thread to wait until // DatasetCreateProcedure ends Thread1.Join(); Thread2.Join(); Thread3.Join(); Thread4.Join(); } }
public static string GetHdfVersion() { uint majnum = 0, minnum = 0, relnum = 0; H5.get_libversion(ref majnum, ref minnum, ref relnum); return(majnum + "." + minnum + "." + relnum); }
public void H5DreadTest2() { hid_t mem_type = H5T.create(H5T.class_t.STRING, H5T.VARIABLE); Assert.IsTrue(H5T.set_cset(mem_type, H5T.cset_t.UTF8) >= 0); Assert.IsTrue(H5T.set_strpad(mem_type, H5T.str_t.NULLTERM) >= 0); hid_t fspace = H5D.get_space(m_v0_utf8_dset); Assert.IsTrue(fspace >= 0); hssize_t count = H5S.get_simple_extent_npoints(fspace); Assert.IsTrue(count > 0); Assert.IsTrue(H5S.close(fspace) >= 0); IntPtr[] rdata = new IntPtr[count]; GCHandle hnd = GCHandle.Alloc(rdata, GCHandleType.Pinned); Assert.IsTrue(H5D.read(m_v0_utf8_dset, mem_type, H5S.ALL, H5S.ALL, H5P.DEFAULT, hnd.AddrOfPinnedObject()) >= 0); for (int i = 0; i < rdata.Length; ++i) { int len = 0; while (Marshal.ReadByte(rdata[i], len) != 0) { ++len; } byte[] buffer = new byte[len]; Marshal.Copy(rdata[i], buffer, 0, buffer.Length); string s = Encoding.UTF8.GetString(buffer); Assert.IsTrue(s == ((string)m_utf8strings[i])); Assert.IsTrue(H5.free_memory(rdata[i]) >= 0); } Assert.IsTrue(H5D.read(m_v2_utf8_dset, mem_type, H5S.ALL, H5S.ALL, H5P.DEFAULT, hnd.AddrOfPinnedObject()) >= 0); for (int i = 0; i < rdata.Length; ++i) { int len = 0; while (Marshal.ReadByte(rdata[i], len) != 0) { ++len; } byte[] buffer = new byte[len]; Marshal.Copy(rdata[i], buffer, 0, buffer.Length); string s = Encoding.UTF8.GetString(buffer); Assert.IsTrue(s == ((string)m_utf8strings[i])); Assert.IsTrue(H5.free_memory(rdata[i]) >= 0); } hnd.Free(); }
/// <summary> /// Close the library, flush all buffers, close all file handles. /// </summary> public static void Close() { H5.close(); #if DEBUG H5Base.nObjects = 0; #endif Debug.WriteLine("closing hdf5 library... goodbye."); }
public void H5set_free_list_limitsTest1() { Assert.IsTrue( H5.set_free_list_limits(-1, -1, -1, -1, -1, -1) >= 0); Assert.IsTrue( H5.set_free_list_limits(1024, -1, 4096, -1, -1, 1024) >= 0); }
public void H5Fget_obj_idsTest2() { IntPtr buf = H5.allocate_memory(new IntPtr(10 * sizeof(hid_t)), 0); Assert.IsFalse( H5F.get_obj_ids(Utilities.RandomInvalidHandle(), H5F.OBJ_ALL, new IntPtr(10), buf).ToInt32() > 0); Assert.IsTrue(H5.free_memory(buf) >= 0); }
public void H5get_libversionTest1() { uint majnum = 0, minnum = 0, relnum = 0; Assert.IsTrue( H5.get_libversion(ref majnum, ref minnum, ref relnum) >= 0); Assert.IsTrue(majnum == 1); Assert.IsTrue(minnum >= 8); }
public void H5resize_memoryTest3() { IntPtr size = new IntPtr(1024 * 1024); // reallocate from NULL -> allocation IntPtr ptr = Marshal.ReAllocHGlobal(IntPtr.Zero, size); Assert.IsFalse(ptr == IntPtr.Zero); Assert.IsTrue(H5.free_memory(ptr) >= 0); }
public void Merge(params DocumentStyle[] styles) { if (styles != null) { foreach (var style in styles) { Section.Merge(style.Section); Article.Merge(style.Article); Header.Merge(style.Header); Footer.Merge(style.Footer); Main.Merge(style.Main); Figure.Merge(style.Figure); Details.Merge(style.Details); Summary.Merge(style.Summary); Div.Merge(style.Div); Ul.Merge(style.Ul); Ol.Merge(style.Ol); Dl.Merge(style.Dl); Td.Merge(style.Td); Table.Merge(style.Table); Img.Merge(style.Img); YouTube.Merge(style.YouTube); Channel9.Merge(style.Channel9); H1.Merge(style.H1); H2.Merge(style.H2); H3.Merge(style.H3); H4.Merge(style.H4); H5.Merge(style.H5); H6.Merge(style.H6); BlockQuote.Merge(style.BlockQuote); P.Merge(style.P); FigCaption.Merge(style.FigCaption); Pre.Merge(style.Pre); Dt.Merge(style.Dt); Dd.Merge(style.Dd); Li.Merge(style.Li); A.Merge(style.A); Span.Merge(style.Span); Label.Merge(style.Label); Q.Merge(style.Q); Cite.Merge(style.Cite); I.Merge(style.I); Em.Merge(style.Em); Mark.Merge(style.Mark); Time.Merge(style.Time); Code.Merge(style.Code); Strong.Merge(style.Strong); } } }
public void H5Fget_obj_idsTest1() { IntPtr buf = H5.allocate_memory(new IntPtr(10 * sizeof(hid_t)), 0); Assert.IsTrue( H5F.get_obj_ids(m_v0_class_file, H5F.OBJ_ALL, new IntPtr(10), buf).ToInt32() > 0); Assert.IsTrue( H5F.get_obj_ids(m_v2_class_file, H5F.OBJ_ALL, new IntPtr(10), buf).ToInt32() > 0); Assert.IsTrue(H5.free_memory(buf) >= 0); }
public void H5is_library_threadsafeTest1() { uint majnum = 0, minnum = 0, relnum = 0; Assert.IsTrue( H5.get_libversion(ref majnum, ref minnum, ref relnum) >= 0); Assert.IsTrue(majnum == 1); Assert.IsTrue(minnum >= 8); if ((minnum == 8 && relnum >= 16) || majnum >= 10) { uint is_ts = 0; Assert.IsTrue(H5.is_library_threadsafe(ref is_ts) >= 0); } }
public void H5free_memoryTest2() { IntPtr size = new IntPtr(1024 * 1024); // uninitialized allocation IntPtr ptr = Marshal.AllocHGlobal(size); Assert.IsFalse(ptr == IntPtr.Zero); Assert.IsTrue(H5.free_memory(ptr) >= 0); // size = 0 size = new IntPtr(0); ptr = Marshal.AllocHGlobal(size); Assert.IsTrue(H5.free_memory(ptr) >= 0); }
public Mat73Writer(Mat73Settings settings, ILogger logger) : base(settings, logger) { _settings = settings; _chunkPeriod = TimeSpan.FromMinutes(1); // check thread safety var isLibraryThreadSafe = 0U; H5.is_library_threadsafe(ref isLibraryThreadSafe); if (isLibraryThreadSafe <= 0) { throw new Exception(ErrorMessage.Mat73Writer_HdfLibraryNotThreadSafe); } }
public static IEnumerable <string> ReadStrings(int groupId, string name) { int memId = H5T.create(H5T.class_t.STRING, H5T.VARIABLE); H5T.set_cset(memId, H5T.cset_t.UTF8); H5T.set_strpad(memId, H5T.str_t.NULLTERM); name = ToHdf5Name(name); var datasetId = H5D.open(groupId, name); int spaceId = H5D.get_space(datasetId); long count = H5S.get_simple_extent_npoints(spaceId); H5S.close(spaceId); IntPtr[] rdata = new IntPtr[count]; GCHandle hnd = GCHandle.Alloc(rdata, GCHandleType.Pinned); H5D.read(datasetId, memId, H5S.ALL, H5S.ALL, H5P.DEFAULT, hnd.AddrOfPinnedObject()); var strs = new List <string>(); for (int i = 0; i < rdata.Length; ++i) { int len = 0; while (Marshal.ReadByte(rdata[i], len) != 0) { ++len; } byte[] buffer = new byte[len]; Marshal.Copy(rdata[i], buffer, 0, buffer.Length); string s = Encoding.UTF8.GetString(buffer); strs.Add(s); H5.free_memory(rdata[i]); } hnd.Free(); H5T.close(memId); H5D.close(datasetId); return(strs); }
public void H5TSforeachTest1() { // run only if we have a thread-safe build of the library hbool_t flag = 0; Assert.IsTrue(H5.is_library_threadsafe(ref flag) >= 0); if (flag > 0) { List <string> ls = new List <string>(); for (int i = 0; i < NUM_FILES; ++i) { ls.Add(Path.GetTempFileName()); } var totalLength = 0; Parallel.ForEach <string, TaskLocals> (ls, () => { TaskLocals tl = new TaskLocals(); tl.handle = -1; tl.runningLength = 0; return(tl); }, (name, loop, taskLocals) => { // handle is "thread-local" taskLocals.handle = H5F.create(name, H5F.ACC_TRUNC); Assert.IsTrue(H5F.close(taskLocals.handle) >= 0); Assert.IsTrue(H5F.is_hdf5(name) > 0); File.Delete(name); taskLocals.handle = -1; taskLocals.runningLength += name.Length; return(taskLocals); }, (taskLocals) => { Interlocked.Add(ref totalLength, taskLocals.runningLength); } ); Assert.IsTrue(totalLength > NUM_FILES); } }
protected virtual void Dispose(bool disposing) { if (!_disposed) { if (disposing) { // Dispose managed resources CloseDocument(); if (_openHdf5FileCount == 0) { H5.Close(); } GC.SuppressFinalize(this); } } _disposed = true; }
public void H5Tget_tagTest1() { hid_t dtype = H5T.create(H5T.class_t.OPAQUE, new IntPtr(1024)); Assert.IsTrue(dtype >= 0); Assert.IsTrue( H5T.set_tag(dtype, "Mary had a little lamb...") >= 0); IntPtr tag = H5T.get_tag(dtype); Assert.IsTrue(tag.ToInt64() >= 0); Assert.IsTrue(Marshal.PtrToStringAnsi(tag) == "Mary had a little lamb..."); Assert.IsTrue(H5.free_memory(tag) >= 0); Assert.IsTrue(H5T.close(dtype) >= 0); }
public void H5allocate_memoryTest2() { IntPtr size = new IntPtr(1024 * 1024); // uninitialized allocation IntPtr ptr = H5.allocate_memory(size, 0); Assert.IsFalse(ptr == IntPtr.Zero); Marshal.FreeHGlobal(ptr); // initialize with zeros ptr = H5.allocate_memory(size, 1); Assert.IsFalse(ptr == IntPtr.Zero); Marshal.FreeHGlobal(ptr); // size = 0 -> NULL return size = new IntPtr(0); ptr = H5.allocate_memory(size, 0); Assert.IsTrue(ptr == IntPtr.Zero); Marshal.FreeHGlobal(ptr); }
public void H5free_memoryTest1() { IntPtr size = new IntPtr(1024 * 1024); // uninitialized allocation IntPtr ptr = H5.allocate_memory(size, 0); Assert.IsFalse(ptr == IntPtr.Zero); Assert.IsTrue(H5.free_memory(ptr) >= 0); // initialize with zeros ptr = H5.allocate_memory(size, 1); Assert.IsFalse(ptr == IntPtr.Zero); Assert.IsTrue(H5.free_memory(ptr) >= 0); // size = 0 -> NULL return size = new IntPtr(0); ptr = H5.allocate_memory(size, 0); Assert.IsTrue(ptr == IntPtr.Zero); Assert.IsTrue(H5.free_memory(ptr) >= 0); }
public HDF5GroupObject open(string file) { if (H5F.is_hdf5(file)) { int result = H5.Open(); if (result < 0) { Console.WriteLine("can't open the file!"); } // get fildID. H5FileId fileID = H5F.open(file, H5F.OpenMode.ACC_RDONLY); //get groupid H5GroupId rootid = H5G.open(fileID, "/"); HDF5GroupObject hdf5Object = new HDF5GroupObject(); createHD5GroupObject(rootid, "/", ref hdf5Object); return(hdf5Object); } else { Console.WriteLine("this is not HDF5 file! please try open hdf5 file again."); return(null); } }
private string GetModelConfig() { long fileId = H5F.open(this.fileName, H5F.ACC_RDONLY); long attrId = H5A.open(fileId, @"model_config"); long typeId = H5A.get_type(attrId); long spaceId = H5A.get_space(attrId); long count = H5S.get_simple_extent_npoints(spaceId); H5S.close(spaceId); IntPtr[] dest = new IntPtr[count]; GCHandle handle = GCHandle.Alloc(dest, GCHandleType.Pinned); H5A.read(attrId, typeId, handle.AddrOfPinnedObject()); var attrStrings = new List <string>(); for (int i = 0; i < dest.Length; ++i) { int attrLength = 0; while (Marshal.ReadByte(dest[i], attrLength) != 0) { ++attrLength; } byte[] buffer = new byte[attrLength]; Marshal.Copy(dest[i], buffer, 0, buffer.Length); string stringPart = Encoding.UTF8.GetString(buffer); attrStrings.Add(stringPart); H5.free_memory(dest[i]); } handle.Free(); return(attrStrings.ToArray().ToString()); }
public void H5Fget_files_imageTest1() { string fname = Path.GetTempFileName(); hid_t file = H5F.create(fname, H5F.ACC_TRUNC); Assert.IsTrue(file >= 0); IntPtr buf_len = new IntPtr(); ssize_t size = H5F.get_file_image(file, IntPtr.Zero, buf_len); Assert.IsTrue(size.ToInt32() > 0); IntPtr buf = H5.allocate_memory(new IntPtr(size.ToInt32()), 1); Assert.IsTrue(buf != IntPtr.Zero); Assert.IsTrue(H5F.get_file_image(file, IntPtr.Zero, buf_len).ToInt32() > 0); Assert.IsTrue(H5.free_memory(buf) >= 0); Assert.IsTrue(H5F.close(file) >= 0); File.Delete(fname); }
/// <summary> /// Creates block element based on paragraph type /// </summary> /// <param name="type"></param> /// <returns></returns> private static HTMLItem CreateBlock(ParagraphConvTargetEnumV2 type) { HTMLItem paragraph; switch (type) { case ParagraphConvTargetEnumV2.H1: paragraph = new H1(HTMLElementType.XHTML11); break; case ParagraphConvTargetEnumV2.H2: paragraph = new H2(HTMLElementType.XHTML11); break; case ParagraphConvTargetEnumV2.H3: paragraph = new H3(HTMLElementType.XHTML11); break; case ParagraphConvTargetEnumV2.H4: paragraph = new H4(HTMLElementType.XHTML11); break; case ParagraphConvTargetEnumV2.H5: paragraph = new H5(HTMLElementType.XHTML11); break; case ParagraphConvTargetEnumV2.H6: paragraph = new H6(HTMLElementType.XHTML11); break; default: // Paragraph or anything else paragraph = new Paragraph(HTMLElementType.XHTML11); break; } return(paragraph); }
public void ClearMenuAttempts() { F1.SetActive(false); H1.SetActive(false); H11.SetActive(false); F2.SetActive(false); H2.SetActive(false); H22.SetActive(false); F3.SetActive(false); H3.SetActive(false); H33.SetActive(false); F4.SetActive(false); H4.SetActive(false); H44.SetActive(false); F5.SetActive(false); H5.SetActive(false); H55.SetActive(false); cli1_1.SetText(""); cli2_1.SetText(""); cli1_2.SetText(""); cli2_2.SetText(""); cli1_3.SetText(""); cli2_3.SetText(""); cli1_4.SetText(""); cli2_4.SetText(""); cli1_5.SetText(""); cli2_5.SetText(""); }