Example #1
0
 private void btnVxml_Click(object sender, EventArgs e)
 {
     org.unisens.Unisens u = null;
     try
     {
         UnisensFactory uf = UnisensFactoryBuilder.createFactory();
         u = uf.createUnisens(folderDialogue.SelectedPath);
         ValuesEntry ve = u.createValuesEntry("values.xml", new String[] { "A", "B" }, DataType.INT16, 250);
         ve.setFileFormat(ve.createXmlFileFormat());
         ve.append(new Value(1320, new short[] { 1, 4 }));
         ve.append(new Value(22968, new short[] { 2, 5 }));
         ve.append(new Value(30232, new short[] { 3, 6 }));
         u.save();
         ShowInfo("Parse file {values.xml} suceed!");
     }
     catch (Exception ex)
     {
         ShowError(ex.Message);
     }
     finally
     {
         if (u != null)
         {
             u.closeAll();
         }
     }
 }
Example #2
0
        private void valuesXml()
        {
            UnisensFactory uf = UnisensFactoryBuilder.createFactory();
            Unisens        u  = uf.createUnisens("C:\\TestData");
            ValuesEntry    ve = u.createValuesEntry("values.xml", new String[] { "A", "B" }, DataType.INT16, 250);

            ve.setFileFormat(ve.createXmlFileFormat());
            ve.append(new Value(1320, new short[] { 1, 4 }));
            ve.append(new Value(22968, new short[] { 2, 5 }));
            ve.append(new Value(30232, new short[] { 3, 6 }));
            u.save();
            u.closeAll();
        }
Example #3
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();
        }
Example #4
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;
            }
        }