public void testSignalEntry_DOUBLE_BE()
 {
     signalEntry           = (SignalEntry)unisens.createSignalEntry("se_double_be.bin", new String[] { "a", "b" }, DataType.DOUBLE, sampleRate);
     signalEntryFileFormat = (BinFileFormat)signalEntry.getFileFormat();
     signalEntryFileFormat.setEndianess(Endianess.BIG);
     signalEntry.append(double64);
     assertArrayEqual(double64, (double[][])signalEntry.read(double64.Length));
 }
 public void testSignalEntry_UINT32_1x1_LE()
 {
     signalEntry           = (SignalEntry)unisens.createSignalEntry("se_uint32_1x1_le.bin", new String[] { "a" }, DataType.UINT32, sampleRate);
     signalEntryFileFormat = (BinFileFormat)signalEntry.getFileFormat();
     signalEntryFileFormat.setEndianess(Endianess.LITTLE);
     signalEntry.append(uint32_1_1);
     assertArrayEqual(uint32_1_1, (UInt32[][])signalEntry.read(uint32_1_1.Length));
 }
 public void testSignalEntry_FLOAT_BE()
 {
     signalEntry           = (SignalEntry)unisens.createSignalEntry("se_float_be.bin", new String[] { "a", "b" }, DataType.FLOAT, sampleRate);
     signalEntryFileFormat = (BinFileFormat)signalEntry.getFileFormat();
     signalEntryFileFormat.setEndianess(Endianess.BIG);
     signalEntry.append(float32);
     assertArrayEqual(float32, (float[][])signalEntry.read(float32.Length));
 }
 public void testSignalEntry_INT32_LE()
 {
     signalEntry           = (SignalEntry)unisens.createSignalEntry("se_int32_le.bin", new String[] { "a", "b" }, DataType.INT32, sampleRate);
     signalEntryFileFormat = (BinFileFormat)signalEntry.getFileFormat();
     signalEntryFileFormat.setEndianess(Endianess.LITTLE);
     signalEntry.append(int32);
     assertArrayEqual(int32, (int[][])signalEntry.read(int32.Length));
 }
 public void testSignalEntry_UINT16_BE()
 {
     signalEntry           = (SignalEntry)unisens.createSignalEntry("se_uint16_be.bin", new String[] { "a", "b" }, DataType.UINT16, sampleRate);
     signalEntryFileFormat = (BinFileFormat)signalEntry.getFileFormat();
     signalEntryFileFormat.setEndianess(Endianess.BIG);
     signalEntry.append(uint16);
     assertArrayEqual(uint16, (UInt16[][])signalEntry.read(uint16.Length));
 }
 public void testSignalEntry_UINT8_LE()
 {
     signalEntry           = (SignalEntry)unisens.createSignalEntry("se_uint8_le.bin", new String[] { "a", "b" }, DataType.UINT8, sampleRate);
     signalEntryFileFormat = (BinFileFormat)signalEntry.getFileFormat();
     signalEntryFileFormat.setEndianess(Endianess.LITTLE);
     signalEntry.append(uint8);
     assertArrayEqual(uint8, (byte[][])signalEntry.read(uint8.Length));
 }
Ejemplo n.º 7
0
 public void testValuesEntry_BIN_UINT32()
 {
     valuesEntry = unisens.createValuesEntry("ve_uint32.bin", new String[] { "a", "b" }, DataType.UINT32, 400);
     valuesEntryBinFileFormat = new BinFileFormatImpl();
     valuesEntryBinFileFormat.setEndianess(Endianess.LITTLE);
     valuesEntry.setFileFormat(valuesEntryBinFileFormat);
     valuesEntry.append(uint32);
     assertValueList(uint32, valuesEntry.read(5));
 }
        public void testSignalEntry_INT8_LE_1_CHANNEL_1_SAMPLE()
        {
            signalEntry           = (SignalEntry)unisens.createSignalEntry("se_int8_le_1_1.bin", new String[] { "a" }, DataType.INT8, sampleRate);
            signalEntryFileFormat = (BinFileFormat)signalEntry.getFileFormat();
            signalEntryFileFormat.setEndianess(Endianess.LITTLE);
            signalEntry.append(int8_1_1);

            assertArrayEqual(int8_1_1, (sbyte[][])signalEntry.read(int8.Length));
        }
 public void testSignalEntry_INT16_BE()
 {
     short[][] tmp = int16;
     signalEntry           = (SignalEntry)unisens.createSignalEntry("se_int16_be.bin", new String[] { "a", "b" }, DataType.INT16, sampleRate);
     signalEntryFileFormat = (BinFileFormat)signalEntry.getFileFormat();
     signalEntryFileFormat.setEndianess(Endianess.BIG);
     signalEntry.setFileFormat(signalEntryFileFormat);
     signalEntry.append(tmp);
     assertArrayEqual(int16, (short[][])signalEntry.read(int16.Length));
 }
        public void testZSaveUnisens()
        {
            unisens.closeAll();

            unisens = factory.createUnisens(EXAMPLE_TEMP_SIGNAL_ENTRY);
            Assert.AreEqual(timestampStart.ToString(), unisens.getTimestampStart().ToString());
            signalEntry           = (SignalEntry)unisens.createSignalEntry("se_double_be.bin", new String[] { "a", "b" }, DataType.DOUBLE, sampleRate);
            signalEntryFileFormat = (BinFileFormat)signalEntry.getFileFormat();
            signalEntryFileFormat.setEndianess(Endianess.BIG);
            signalEntry.append(double64);
            unisens.save();

            signalEntry = (SignalEntry)unisens.getEntry("se_double_be.bin");
            Assert.AreEqual("BIN", signalEntry.getFileFormat().getFileFormatName());
            Assert.AreEqual(DataType.DOUBLE, signalEntry.getDataType());
            Assert.AreEqual(sampleRate, signalEntry.getSampleRate(), 0);
            Assert.IsTrue(signalEntry.getFileFormat() is BinFileFormat);
            Assert.AreEqual(Endianess.BIG, ((BinFileFormat)signalEntry.getFileFormat()).getEndianess());

            unisens.deleteEntry(signalEntry);
            unisens.save();
        }
Ejemplo n.º 11
0
        internal XmlElement createElement(XmlDocument document)
        {
            document.AppendChild(document.CreateXmlDeclaration("1.0", "UTF-8", ""));
            var unisensElement = document.CreateElement(Constants.UNISENS, "http://www.unisens.org/unisens2.0");

            unisensElement.SetAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance");
            unisensElement.SetAttribute("xsi:schemaLocation", "http://www.unisens.org/unisens2.0 http://www.unisens.org/unisens2.0/unisens.xsd");
            //.Attributes.Append(document.CreateAttribute("http://www.w3.org/2001/XMLSchema-instance",);
            //"xsi:schemaLocation",
            //"http://www.unisens.org/unisens2.0 http://www.unisens.org/unisens2.0/unisens.xsd")));

            if (getComment() != null)
            {
                unisensElement.SetAttribute(Constants.UNISENS_COMMENT, getComment());
            }
            if (getDuration() != 0)
            {
                unisensElement.SetAttribute(Constants.UNISENS_DURATION, "" + getDuration());
            }
            if (getTimestampStart() != null)
            {
                unisensElement.SetAttribute(Constants.UNISENS_TIMESTAMP_START,
                                            Utilities.convertDateToString(timestampStart));
            }

            ;
            if (getMeasurementId() != null)
            {
                unisensElement.SetAttribute(Constants.UNISENS_MEASUREMENT_ID, getMeasurementId());
            }
            if (getVersion() != null)
            {
                unisensElement.SetAttribute(Constants.UNISENS_VERSION, getVersion());
            }

            if (customAttributes.Count > 0)
            {
                XmlElement customAttributesElement = document.CreateElement(Constants.CUSTOM_ATTRIBUTES, unisensElement.NamespaceURI);
                foreach (string key in customAttributes.Keys)
                {
                    XmlElement customAttributeElement = document.CreateElement(Constants.CUSTOM_ATTRIBUTE);
                    customAttributeElement.SetAttribute(Constants.CUSTOM_ATTRIBUTE_KEY, key);
                    customAttributeElement.SetAttribute(Constants.CUSTOM_ATTRIBUTE_VALUE, customAttributes[key]);
                    customAttributesElement.AppendChild(customAttributeElement);
                }
                unisensElement.AppendChild(customAttributesElement);
            }

            if (context != null)
            {
                XmlElement contextElement = document.CreateElement(Constants.CONTEXT, unisensElement.NamespaceURI);
                if (context.getSchemaUrl() != null)
                {
                    contextElement.SetAttribute(Constants.CONTEXT_SCHEMAURL, context.getSchemaUrl());
                }
                unisensElement.AppendChild(contextElement);
            }

            Entry entry;

            foreach (Entry t in entries)
            {
                entry = (Entry)t;
                XmlElement entryElement = null;

                if (entry is SignalEntry)
                {
                    entryElement = document.CreateElement(Constants.SIGNALENTRY, unisensElement.NamespaceURI);
                }
                if (entry is ValuesEntry)
                {
                    entryElement = document.CreateElement(Constants.VALUESENTRY, unisensElement.NamespaceURI);
                }
                if (entry is EventEntry)
                {
                    entryElement = document.CreateElement(Constants.EVENTENTRY, unisensElement.NamespaceURI);
                }
                if (entry is CustomEntry)
                {
                    entryElement = document.CreateElement(Constants.CUSTOMENTRY, unisensElement.NamespaceURI);
                }

                if (entry.getComment() != null)
                {
                    entryElement.SetAttribute(Constants.ENTRY_COMMENT, entry.getComment());
                }
                if (entry.getContentClass() != null)
                {
                    entryElement.SetAttribute(Constants.ENTRY_CONTENTCLASS, entry.getContentClass());
                }
                if (entry.getSource() != null)
                {
                    entryElement.SetAttribute(Constants.ENTRY_SOURCE, entry.getSource());
                }
                if (entry.getSourceId() != null)
                {
                    entryElement.SetAttribute(Constants.ENTRY_SOURCE_ID, entry.getSourceId());
                }
                if (entry.getId() != null)
                {
                    entryElement.SetAttribute(Constants.ENTRY_ID, entry.getId());
                }

                if (entry.getCustomAttributes().Count > 0)
                {
                    XmlElement customAttributesElement = document.CreateElement(Constants.CUSTOM_ATTRIBUTES, unisensElement.NamespaceURI);
                    foreach (string key in customAttributes.Keys)
                    {
                        var customAttributeElement = document.CreateElement(Constants.CUSTOM_ATTRIBUTE);
                        customAttributeElement.SetAttribute(Constants.CUSTOM_ATTRIBUTE_KEY, key);
                        customAttributeElement.SetAttribute(Constants.CUSTOM_ATTRIBUTE_VALUE, customAttributes[key]);
                        customAttributesElement.AppendChild(customAttributeElement);
                    }
                    unisensElement.AppendChild(customAttributesElement);
                }

                FileFormat fileFormat        = entry.getFileFormat();
                XmlElement fileFormatElement = null;

                if (fileFormat is BinFileFormat)
                {
                    BinFileFormat binFileFormat = (BinFileFormat)fileFormat;
                    fileFormatElement = document.CreateElement(Constants.BINFILEFORMAT, unisensElement.NamespaceURI);
                    fileFormatElement.SetAttribute(Constants.BINFILEFORMAT_ENDIANESS, binFileFormat.getEndianess().ToString().ToUpper());
                }
                if (fileFormat is CsvFileFormat)
                {
                    CsvFileFormat csvFileFormat = (CsvFileFormat)fileFormat;
                    fileFormatElement = document.CreateElement(Constants.CSVFILEFORMAT, unisensElement.NamespaceURI);
                    fileFormatElement.SetAttribute(Constants.CSVFILEFORMAT_SEPARATOR, csvFileFormat.getSeparator());
                    fileFormatElement.SetAttribute(Constants.CSVFILEFORMAT_DECIMAL_SEPARATOR, csvFileFormat.getDecimalSeparator());
                }
                if (fileFormat is XmlFileFormat)
                {
                    fileFormatElement = document.CreateElement(Constants.XMLFILEFORMAT, unisensElement.NamespaceURI);
                }
                if (fileFormat is CustomFileFormat)
                {
                    CustomFileFormat customFileFormat = (CustomFileFormat)fileFormat;
                    fileFormatElement = document.CreateElement(Constants.CUSTOMFILEFORMAT, unisensElement.NamespaceURI);
                    fileFormatElement.SetAttribute(Constants.CUSTOMFILEFORMAT_FILEFORMATNAME, customFileFormat.getFileFormatName());
                    Dictionary <string, string> attributes = customFileFormat.getAttributes();
                    var attrNames = attributes.Keys;
                    foreach (string attrName in attrNames)
                    {
                        fileFormatElement.SetAttribute(attrName, attributes[attrName]);
                    }
                }
                if (fileFormat.getComment() != null)
                {
                    fileFormatElement.SetAttribute(Constants.FILEFORMAT_COMMENT, fileFormat.getComment());
                }

                entryElement.AppendChild(fileFormatElement);

                if (entry is MeasurementEntry)
                {
                    var measurementEntry = (MeasurementEntry)entry;
                    if (measurementEntry.getAdcResolution() != 0)
                    {
                        entryElement.SetAttribute(Constants.MEASUREMENTENTRY_ADCRESOLUTION, "" + measurementEntry.getAdcResolution());
                    }
                    if (measurementEntry.getAdcZero() != 0)
                    {
                        entryElement.SetAttribute(Constants.MEASUREMENTENTRY_ADCZERO, "" + measurementEntry.getAdcZero());
                    }
                    if (measurementEntry.getBaseline() != 0)
                    {
                        entryElement.SetAttribute(Constants.MEASUREMENTENTRY_BASELINE, "" + measurementEntry.getBaseline());
                    }
                    entryElement.SetAttribute(Constants.MEASUREMENTENTRY_DATATYPE, measurementEntry.getDataType().ToString().ToLower());
                    if (measurementEntry.getLsbValue() != 0)
                    {
                        entryElement.SetAttribute(Constants.MEASUREMENTENTRY_LSBVALUE, measurementEntry.getLsbValue().ToString(decimalFormat));
                    }
                    if (measurementEntry.getSampleRate() != 0)
                    {
                        entryElement.SetAttribute(Constants.TIMEDENTRY_SAMPLERATE, measurementEntry.getSampleRate().ToString(decimalFormat));
                    }
                    if (measurementEntry.getUnit() != null)
                    {
                        entryElement.SetAttribute(Constants.MEASUREMENTENTRY_UNIT, measurementEntry.getUnit());
                    }

                    string[] channelNames = measurementEntry.getChannelNames();

                    foreach (string t1 in channelNames)
                    {
                        XmlElement channelElement = document.CreateElement(Constants.CHANNEL, unisensElement.NamespaceURI);
                        channelElement.SetAttribute(Constants.CHANNEL_NAME, t1);
                        entryElement.AppendChild(channelElement);
                    }
                }
                if (entry is EventEntry)
                {
                    EventEntry eventEntry = (EventEntry)entry;
                    if (eventEntry.getSampleRate() != 0)
                    {
                        entryElement.SetAttribute(Constants.TIMEDENTRY_SAMPLERATE, eventEntry.getSampleRate().ToString(decimalFormat));
                    }
                    if (eventEntry.getTypeLength() != 0)
                    {
                        entryElement.SetAttribute(Constants.EVENTENTRY_TYPE_LENGTH, "" + eventEntry.getTypeLength());
                    }
                    if (eventEntry.getCommentLength() != 0)
                    {
                        entryElement.SetAttribute(Constants.EVENTENTRY_COMMENT_LENGTH, "" + eventEntry.getCommentLength());
                    }
                }

                if (entry is CustomEntry)
                {
                    CustomEntry customEntry = (CustomEntry)entry;
                    Dictionary <string, string> attributes = customEntry.getAttributes();
                    ICollection <string>        keySet     = attributes.Keys;
                    foreach (String key in keySet)
                    {
                        entryElement.SetAttribute(key, attributes[key]);
                    }
                }

                unisensElement.AppendChild(entryElement);
            }
            Group      group;
            XmlElement groupElement;
            XmlElement groupEntryElement;

            foreach (Group t in groups)
            {
                group        = (Group)t;
                groupElement = document.CreateElement(Constants.GROUP, unisensElement.NamespaceURI);

                if (group.getComment() != null)
                {
                    groupElement.SetAttribute(Constants.GROUP_COMMENT, group.getComment());
                }
                if (group.getId() != null)
                {
                    groupElement.SetAttribute(Constants.GROUP_ID, group.getId());
                }

                var entriList = group.getEntries();
                foreach (Entry e in entriList)
                {
                    groupEntryElement = document.CreateElement(Constants.GROUPENTRY, unisensElement.NamespaceURI);
                    groupEntryElement.SetAttribute(Constants.GROUPENTRY_REF, ((Entry)e).getId());
                    groupElement.AppendChild(groupEntryElement);
                }
                unisensElement.AppendChild(groupElement);
            }
            return(unisensElement);
        }
Ejemplo n.º 12
0
 internal BinFileFormatImpl(BinFileFormat binFileFormat)
     : base(binFileFormat)
 {
     _endianess = binFileFormat.getEndianess();
 }
Ejemplo n.º 13
0
        private void signalTest(string fileFormat, DataType dataType)
        {
            string[]       Channelnames = { "CH1", "CH2" };
            UnisensFactory uf           = UnisensFactoryBuilder.createFactory();
            Unisens        u            = uf.createUnisens(path);
            string         fileName     = "signal_" + dataType.ToString() + "_" + fileFormat + "." + fileFormat.Substring(0, 3);
            string         fileName1    = "value_" + dataType.ToString() + "_" + fileFormat + "." + fileFormat.Substring(0, 3);
            ValuesEntry    ve           = u.createValuesEntry(fileName1, new String[] { "A", "B" }, dataType, 250);
            SignalEntry    se           = u.createSignalEntry(fileName, new String[] { "A", "B" }, dataType, 250);

            switch (fileFormat)
            {
            case "bin_LITTLE":
                // BIN
                BinFileFormat bffsili = se.createBinFileFormat();
                bffsili.setEndianess(Endianess.LITTLE);
                se.setFileFormat(bffsili);
                BinFileFormat bffva = ve.createBinFileFormat();
                bffva.setEndianess(Endianess.LITTLE);
                ve.setFileFormat(bffva);
                break;

            case "bin_BIG":
                // BIN
                BinFileFormat bffsibi = se.createBinFileFormat();
                bffsibi.setEndianess(Endianess.BIG);
                se.setFileFormat(bffsibi);
                BinFileFormat bffvabi = ve.createBinFileFormat();
                bffvabi.setEndianess(Endianess.BIG);
                ve.setFileFormat(bffvabi);
                break;

            case "xml":
                // XML
                XmlFileFormat xffsi = se.createXmlFileFormat();
                se.setFileFormat(xffsi);
                XmlFileFormat xffva = ve.createXmlFileFormat();
                ve.setFileFormat(xffva);
                break;

            case "csv":
                // CSV
                CsvFileFormat cffsi = se.createCsvFileFormat();
                cffsi.setSeparator("\t");
                cffsi.setDecimalSeparator(",");
                se.setFileFormat(cffsi);
                CsvFileFormat cffva = ve.createCsvFileFormat();
                cffva.setComment("csv , 2 channel ");
                cffva.setSeparator(";");
                cffva.setDecimalSeparator(".");
                ve.setFileFormat(cffva);
                break;
            }

            var samplestamp = new long[3] {
                1320, 22968, 30232
            };

            switch (dataType)
            {
            case DataType.INT8:
                var A = new sbyte[][] { new sbyte[] { -128, 127 }, new sbyte[] { 2, 5 }, new sbyte[] { 3, 6 } };
                se.append(A);
                ValueList valueList = new ValueList(samplestamp, A);
                ve.appendValuesList(valueList);
                break;

            case DataType.UINT8:
                var B = new byte[][] { new byte[] { 255, 4 }, new byte[] { 2, 5 }, new byte[] { 3, 6 } };
                se.append(B);
                ValueList valueList1 = new ValueList(samplestamp, B);
                ve.appendValuesList(valueList1);
                break;

            case DataType.INT16:
                var C = new short[][] { new short[] { -32768, 32767 }, new short[] { 2, 5 }, new short[] { 3, 6 } };
                se.append(C);
                ValueList valueList2 = new ValueList(samplestamp, C);
                ve.appendValuesList(valueList2);
                break;

            case DataType.UINT16:
                var D = new UInt16[][] { new UInt16[] { 65535, 4 }, new UInt16[] { 2, 5 }, new UInt16[] { 3, 6 } };
                se.append(D);
                ValueList valueList3 = new ValueList(samplestamp, D);
                ve.appendValuesList(valueList3);
                break;

            case DataType.INT32:
                var E = new int[][] { new int[] { -2147483648, 2147483647 }, new int[] { 2, 5 }, new int[] { 3, 6 } };
                se.append(E);
                ValueList valueList4 = new ValueList(samplestamp, E);
                ve.appendValuesList(valueList4);
                break;

            case DataType.UINT32:
                var F = new UInt32[][] { new UInt32[] { 4294967295, 4 }, new UInt32[] { 2, 5 }, new UInt32[] { 3, 6 } };
                se.append(F);
                ValueList valueList5 = new ValueList(samplestamp, F);
                ve.appendValuesList(valueList5);
                break;

            case DataType.FLOAT:
                var G = new float[][] { new float[] { 123.4567F, 4 }, new float[] { 2, 5 }, new float[] { 3, 6 } };
                se.append(G);
                ValueList valueList6 = new ValueList(samplestamp, G);
                ve.appendValuesList(valueList6);
                break;

            case DataType.DOUBLE:
                var H = new double[][] { new double[] { 123.4567D, 4 }, new double[] { 2, 5 }, new double[] { 3, 6 } };
                se.append(H);
                ValueList valueList7 = new ValueList(samplestamp, H);
                ve.appendValuesList(valueList7);
                break;
            }
            u.save();
            //Console.WriteLine("hallo");
            //Console.WriteLine(uf.ToString());
            //Console.ReadKey();
        }
Ejemplo n.º 14
0
        // WRITE
        private void signalTest(string fileFormat, DataType dataType)
        {
            string[]       Channelnames = { "CH1", "CH2" };
            UnisensFactory uf           = UnisensFactoryBuilder.createFactory();
            Unisens        u            = uf.createUnisens(path);
            string         fileName     = "signal_" + dataType.ToString() + "." + fileFormat;

            SignalEntry se = u.createSignalEntry(fileName, new String[] { "A", "B" }, dataType, 250);

            switch (fileFormat)
            {
            case "bin":
                // BIN
                BinFileFormat bff = se.createBinFileFormat();
                bff.setEndianess(Endianess.LITTLE);
                se.setFileFormat(bff);
                break;

            case "xml":
                // XML
                XmlFileFormat xff = se.createXmlFileFormat();
                se.setFileFormat(xff);
                break;

            case "csv":
                // CSV
                CsvFileFormat cff = se.createCsvFileFormat();
                cff.setSeparator("\t");
                cff.setDecimalSeparator(".");
                se.setFileFormat(cff);
                break;
            }

            switch (dataType)
            {
            case DataType.INT8:
                var A = new sbyte[][] { new sbyte[] { 127, -128 }, new sbyte[] { 2, 5 }, new sbyte[] { 3, 6 } };
                //var A = new byte[][] { new byte[] { 127, 255 }, new byte[] { 1, 0 }, new byte[] { 3, 6 } };
                se.append(A);
                break;

            case DataType.UINT8:
                //var B = new short[][] { new short[] { 255, 0 }, new short[] { 2, 5 }, new short[] { 3, 6 } };
                var B = new byte[][] { new byte[] { 127, 255 }, new byte[] { 1, 0 }, new byte[] { 3, 6 } };
                se.append(B);
                break;

            case DataType.INT16:
                var C = new short[][] { new short[] { 32767, -32768 }, new short[] { 2, 5 }, new short[] { 3, 6 } };
                se.append(C);
                break;

            case DataType.UINT16:
                var D = new UInt16[][] { new UInt16[] { 65535, 0 }, new UInt16[] { 2, 5 }, new UInt16[] { 3, 6 } };
                se.append(D);
                break;

            case DataType.INT32:
                var E = new int[][] { new int[] { 2147483647, -2147483648 }, new int[] { 2, 5 }, new int[] { 3, 6 } };
                se.append(E);
                break;

            case DataType.UINT32:
                var F = new UInt32[][] { new UInt32[] { 4294967295, 0 }, new UInt32[] { 2, 5 }, new UInt32[] { 3, 6 } };
                se.append(F);
                break;

            case DataType.FLOAT:
                var G = new float[][] { new float[] { 123.4567F, 4 }, new float[] { 2, 5 }, new float[] { 3, 6 } };
                se.append(G);
                break;

            case DataType.DOUBLE:
                var H = new double[][] { new double[] { 123.4567D, 4 }, new double[] { 2, 5 }, new double[] { 3, 6 } };
                se.append(H);
                break;
            }

            // Attributes
            se.setAdcResolution(16);
            se.setBaseline(0);
            se.setAdcZero(0);
            se.setComment("FhG - Elektroden ");
            se.setContentClass("ECG");
            se.setSourceId("ecg_m500_250 .bin ");
            se.setSource("FhG-Elektroden , ADS8345 ");
            se.setUnit("uV");
            se.setLsbValue(1.8273);
            se.setSampleRate(250);
            se.setChannelNames(Channelnames);

            // Save and close
            u.save();
            u.closeAll();
        }
Ejemplo n.º 15
0
        private void valueTest(string fileFormat, DataType dataType)
        {
            UnisensFactory uf       = UnisensFactoryBuilder.createFactory();
            Unisens        u        = uf.createUnisens(path);
            string         fileName = "value_" + dataType.ToString() + "." + fileFormat;
            ValuesEntry    ve       = u.createValuesEntry(fileName, new String[] { "A", "B" }, dataType, 250);

            switch (fileFormat)
            {
            case "bin":
                // BIN
                BinFileFormat bff = ve.createBinFileFormat();
                bff.setEndianess(Endianess.LITTLE);
                ve.setFileFormat(bff);
                break;

            case "xml":
                // XML
                XmlFileFormat xff = ve.createXmlFileFormat();
                ve.setFileFormat(xff);
                break;

            case "csv":
                // CSV
                CsvFileFormat cff = ve.createCsvFileFormat();
                cff.setComment("csv , 2 channel ");
                cff.setSeparator(";");
                cff.setDecimalSeparator(".");
                ve.setFileFormat(cff);
                break;
            }

            var samplestamp = new long[3] {
                1320, 22968, 30232
            };

            switch (dataType)
            {
            case DataType.INT8:
                var       A         = new sbyte[][] { new sbyte[] { 127, 4 }, new sbyte[] { 2, 5 }, new sbyte[] { 3, 6 } };
                ValueList valueList = new ValueList(samplestamp, A);
                ve.appendValuesList(valueList);
                break;

            case DataType.UINT8:
                var       B          = new short[][] { new short[] { 255, 4 }, new short[] { 2, 5 }, new short[] { 3, 6 } };
                ValueList valueList1 = new ValueList(samplestamp, B);
                ve.appendValuesList(valueList1);
                break;

            case DataType.INT16:
                var       C          = new short[][] { new short[] { 32767, 4 }, new short[] { 2, 5 }, new short[] { 3, 6 } };
                ValueList valueList2 = new ValueList(samplestamp, C);
                ve.appendValuesList(valueList2);
                break;

            case DataType.UINT16:
                var       D          = new int[][] { new int[] { 65535, 4 }, new int[] { 2, 5 }, new int[] { 3, 6 } };
                ValueList valueList3 = new ValueList(samplestamp, D);
                ve.appendValuesList(valueList3);
                break;

            case DataType.INT32:
                var       E          = new int[][] { new int[] { 2147483647, 4 }, new int[] { 2, 5 }, new int[] { 3, 6 } };
                ValueList valueList4 = new ValueList(samplestamp, E);
                ve.appendValuesList(valueList4);
                break;

            //case DataType.UINT32:
            //    var F = new long[][] { new long[] { 4294967295, 4 }, new long[] { 2, 5 }, new long[] { 3, 6 } };
            //    ValueList valueList5 = new ValueList(samplestamp, F);
            //    ve.appendValuesList(valueList5);
            //    break;
            case DataType.FLOAT:
                var       G          = new float[][] { new float[] { 123.4567F, 4 }, new float[] { 2, 5 }, new float[] { 3, 6 } };
                ValueList valueList6 = new ValueList(samplestamp, G);
                ve.appendValuesList(valueList6);
                break;

            case DataType.DOUBLE:
                var       H          = new double[][] { new double[] { 123.4567D, 4 }, new double[] { 2, 5 }, new double[] { 3, 6 } };
                ValueList valueList7 = new ValueList(samplestamp, H);
                ve.appendValuesList(valueList7);
                break;
            }
        }