예제 #1
0
        private void btnScsv_Click(object sender, EventArgs e)
        {
            org.unisens.Unisens u = null;
            try
            {
                UnisensFactory uf = UnisensFactoryBuilder.createFactory();

                u = uf.createUnisens(folderDialogue.SelectedPath);
                var           se  = u.createSignalEntry("signal.csv", new String[] { "A", "B" }, DataType.INT16, 250);
                var           A   = new short[][] { new short[] { 1, 4 }, new short[] { 2, 5 }, new short[] { 3, 6 } };
                CsvFileFormat cff = se.createCsvFileFormat();
                cff.setSeparator(";");
                cff.setDecimalSeparator(".");
                se.setFileFormat(cff);
                se.append(A);
                u.save();
                ShowInfo("Parse file {signal.csv} suceed!");
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }
            finally
            {
                if (u != null)
                {
                    u.closeAll();
                }
            }
        }
예제 #2
0
        private void btnSbin_Click(object sender, EventArgs e)
        {
            org.unisens.Unisens u = null;
            try
            {
                UnisensFactory uf = UnisensFactoryBuilder.createFactory();

                u = uf.createUnisens(folderDialogue.SelectedPath);
                SignalEntry se = u.createSignalEntry("signal.bin", new String[] { "A", "B" }, DataType.INT16, 250);
                var         A  = new short[][] { new short[] { 1, 4 }, new short[] { 2, 5 }, new short[] { 3, 6 } };
                //se.setFileFormat(se.createXmlFileFormat());
                var B = new short[][] { new short[] { 2, 4 }, new short[] { 3, 5 }, new short[] { 4, 6 } };
                se.append(A);
                se.append(B);
                u.save();
                ShowInfo("Parse file {signal.bin} suceed!");
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }
            finally
            {
                if (u != null)
                {
                    u.closeAll();
                }
            }
        }
예제 #3
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();
         }
     }
 }
예제 #4
0
        private void btnExml_Click(object sender, EventArgs e)
        {
            org.unisens.Unisens u = null;
            try
            {
                UnisensFactory uf = UnisensFactoryBuilder.createFactory();

                u = uf.createUnisens(folderDialogue.SelectedPath);
                var ee = u.createEventEntry("event.xml", 1000);
                ee.setFileFormat(ee.createXmlFileFormat());
                ee.append(new Event(124, "N", "NORMAL"));
                ee.append(new Event(346, "N", "NORMAL"));
                ee.append(new Event(523, "V", "PVC"));
                u.save();
                ShowInfo("Parse file {event.xml} suceed!");
            }
            catch (Exception ex)
            {
                ShowError(ex.Message);
            }
            finally
            {
                if (u != null)
                {
                    u.closeAll();
                }
            }
        }
예제 #5
0
        public IEnumerable <XElement> Main(XDocument unisensxml, IEnumerable <XElement> selectedsignals, string path, double time_cursor, double time_start, double time_end, string parameter)
        {
            List <XElement> returnElementList = new List <XElement>();
            string          groupId           = null;
            DialogNewGroup  dialogNewGroup    = new DialogNewGroup();

            dialogNewGroup.Topmost = true;
            if (dialogNewGroup.ShowDialog() != (DialogNewGroup.newgroup))
            {
                groupId = DialogNewGroup.idOfTheGroup;
            }
            path = path.Substring(0, path.Length - 11);
            UnisensFactory factory = UnisensFactoryBuilder.createFactory();

            org.unisens.Unisens unisens      = factory.createUnisens(path);
            org.unisens.Group   group        = (org.unisens.Group)unisens.createGroup(groupId);
            XElement            groupElement = new XElement("{http://www.unisens.org/unisens2.0}group",
                                                            new XAttribute("id", groupId)
                                                            );

            foreach (XElement xe in selectedsignals)
            {
                XElement xelement = new XElement("{http://www.unisens.org/unisens2.0}groupEntry",
                                                 new XAttribute("ref", xe.Attribute("id").Value));
                groupElement.Add(xelement);
            }

            returnElementList.Add(groupElement);
            unisensxml.Root.Add(groupElement);
            unisens.closeAll();
            return(returnElementList);
        }
예제 #6
0
        /// <summary>
        /// Main function for plug-ins, called by UnisensViewer.
        /// </summary>
        /// <param name="unisensxml">unisens.xml file.</param>
        /// <param name="selectedsignals">All information from unisens.xml of the selected signals.</param>
        /// <param name="path">Path of the current unisens.xml file.</param>
        /// <param name="time_cursor">Time in seconds of current cursor position. Is 0, if the plug-in is called via plug-in menu.</param>
        /// <param name="time_start">Time in seconds of start of the current selection. Is 0, when no selection exists.</param>
        /// <param name="time_end">Time in seconds of end of the current selection. Is 0, when no selection exists.</param>
        /// <param name="parameter">Additional parameter of the key bindings.</param>
        /// <returns>
        /// Returned signals have to be described by the corresponding Unisens XML element (e.g. signalEntry or eventEntry). UnisensViewer displays the returned signals directly.
        /// </returns>
        public IEnumerable <XElement> Main(XDocument unisensxml, IEnumerable <XElement> selectedsignals, string path, double time_cursor, double time_start, double time_end, string parameter)
        {
            //// When time_cursor is used (context menu or hot key), read data from cursor position. Otherwise read data from selection.
            //if (time_cursor != 0)
            //{
            //    time_start = time_cursor;
            //    time_end = time_cursor;
            //}
            List <string> entryIds = GetEntryList(selectedsignals, "SignalEntry");

            if (entryIds.Count == 0)
            {
                MessageBox.Show("The selected entry is no signalEntry. "
                                , "Wrong signalEntry",
                                MessageBoxButtons.OK, MessageBoxIcon.Error);
                return(null);
            }
            else if (entryIds.Count > 1)
            {
                if (MessageBox.Show("More than one matching entry was selected. I use \n" +
                                    entryIds[0] + " for further processing.",
                                    "SignalEntry overkill",
                                    MessageBoxButtons.OKCancel, MessageBoxIcon.Information) == DialogResult.Cancel)
                {
                    return(null);
                }
            }
            path = path.Substring(0, path.Length - 11);
            UnisensFactory factory = UnisensFactoryBuilder.createFactory();

            org.unisens.Unisens unisens = factory.createUnisens(path);
            entry            = (org.unisens.SignalEntry)unisens.getEntry(entryIds[0]);
            unisensXml       = unisensxml;
            selectedSignals  = selectedsignals;
            pluginTimeStart  = time_start;
            pluginTimeEnd    = time_end;
            pluginTimeLength = time_end - time_start;
            DialogMeasurement dlgMeasurement = new DialogMeasurement();

            dlgMeasurement.Topmost = true;
            dlgMeasurement.Show();

            return(null);
        }