Exemplo n.º 1
0
        public void WriteAndReadStructsWithDatetime()
        {
            string filename = Path.Combine(folder, "testCompounds.H5");

            try
            {
                var fileId = Hdf5.CreateFile(filename);
                Assert.IsTrue(fileId > 0);
                var status = Hdf5.WriteCompounds(fileId, "/test", wDataList);
                Hdf5.CloseFile(fileId);
            }
            catch (Exception ex)
            {
                CreateExceptionAssert(ex);
            }

            try
            {
                var fileId = Hdf5.OpenFile(filename);
                Assert.IsTrue(fileId > 0);
                var cmpList = Hdf5.ReadCompounds <WData>(fileId, "/test").ToArray();
                Hdf5.CloseFile(fileId);
                CollectionAssert.AreEqual(wDataList, cmpList);
            }
            catch (Exception ex)
            {
                CreateExceptionAssert(ex);
            }
        }
Exemplo n.º 2
0
        public void WriteAndReadStructsWithArray()
        {
            string filename = Path.Combine(folder, "testArrayCompounds.H5");

            try
            {
                var fileId = Hdf5.CreateFile(filename);
                Assert.IsTrue(fileId > 0);
                var status = Hdf5.WriteCompounds(fileId, "/test", responseList);
                Hdf5.CloseFile(fileId);
            }
            catch (Exception ex)
            {
                CreateExceptionAssert(ex);
            }

            try
            {
                var fileId = Hdf5.OpenFile(filename);
                Assert.IsTrue(fileId > 0);
                Responses[] cmpList = Hdf5.ReadCompounds <Responses>(fileId, "/test").ToArray();
                Hdf5.CloseFile(fileId);
                var isSame = responseList.Zip(cmpList, (r, c) =>
                {
                    return(r.MCID == c.MCID &&
                           r.PanelIdx == c.PanelIdx &&
                           r.ResponseValues.Zip(c.ResponseValues, (rr, cr) => rr == cr).All(v => v == true));
                });
                Assert.IsTrue(isSame.All(s => s == true));
            }
            catch (Exception ex)
            {
                CreateExceptionAssert(ex);
            }
        }
Exemplo n.º 3
0
        public void WriteAndReadStructs()
        {
            string filename = Path.Combine(folder, "testCompoundsWithDifferentDisplayName.H5");
            Dictionary <string, List <string> > attributes = new Dictionary <string, List <string> >();

            try
            {
                var fileId = Hdf5.CreateFile(filename);
                Assert.IsTrue(fileId > 0);
                var status = Hdf5.WriteCompounds(fileId, "/test", wData2List, attributes);
                Hdf5.CloseFile(fileId);
            }
            catch (Exception ex)
            {
                CreateExceptionAssert(ex);
            }

            try
            {
                var fileId = Hdf5.OpenFile(filename);
                Assert.IsTrue(fileId > 0);
                var cmpList = Hdf5.ReadCompounds <WData2>(fileId, "/test", "").ToArray();
                Hdf5.CloseFile(fileId);
                CollectionAssert.AreEqual(wData2List, cmpList);
            }
            catch (Exception ex)
            {
                CreateExceptionAssert(ex);
            }
        }
Exemplo n.º 4
0
        public void WriteAndReadSystemEvent()
        {
            string             filename = Path.Combine(folder, "testCompounds.H5");
            List <SystemEvent> se       = new List <SystemEvent>();
            Dictionary <string, List <string> > attributes = new Dictionary <string, List <string> >();

            try
            {
                se.Add(new SystemEvent(5, "55", "3300000000000000000000000", "555555555555555555555555555555555"));
                se.Add(new SystemEvent(1, "255", "3d3000000000007777773", "ggggggggggggdf"));

                var fileId = Hdf5.CreateFile(filename);
                Assert.IsTrue(fileId > 0);
                var status = Hdf5.WriteCompounds(fileId, "/test", se, attributes);
                Hdf5.CloseFile(fileId);
            }
            catch (Exception ex)
            {
                CreateExceptionAssert(ex);
            }

            try
            {
                var fileId = Hdf5.OpenFile(filename);
                Assert.IsTrue(fileId > 0);
                var cmpList = Hdf5.ReadCompounds <SystemEvent>(fileId, "/test", "").ToArray();
                Hdf5.CloseFile(fileId);
                CollectionAssert.AreEqual(se, cmpList);
            }
            catch (Exception ex)
            {
                CreateExceptionAssert(ex);
            }
        }
        public void ReadSystemEvents()
        {
            string groupName = rootName + eventsName;

            if (Hdf5.GroupExists(fileId, groupName))
            {
                var e = Hdf5.ReadCompounds <SystemEvent>(fileId, groupName, "");
                Events.AddRange(e);
            }
        }
Exemplo n.º 6
0
        public void ReadStructs()
        {
            string filename = Path.Combine(folder, "data", "testCompounds_WData2_WData3.H5");

            try
            {
                var fileId = Hdf5.OpenFile(filename);
                Assert.IsTrue(fileId > 0);
                var cmpList = Hdf5.ReadCompounds <WData3>(fileId, "/test", "").ToArray();
                Hdf5.CloseFile(fileId);
                CollectionAssert.AreEqual(wData2List, cmpList);
            }
            catch (Exception ex)
            {
                CreateExceptionAssert(ex);
            }
        }