private void SetVirtualReference()
        {
            if (!(TV_VirtualChannels.SelectedNode == null))
            {
                if (TV_VirtualChannels.SelectedNode.Tag.ToString() == "Channel")
                {
                    VirtualParameter sReference = new VirtualParameter();
                    sReference.LibraryName = TV_VirtualChannels.SelectedNode.Parent.Text;
                    sReference.ChannelName = TV_VirtualChannels.SelectedNode.Text;

                    CS_VirtualChannel oVirtual = oVCLibCollection.GetVirtualChannel(sReference.LibraryName, sReference.ChannelName);

                    FrmCaller.SetVirtualChannelReference(sReference, oVirtual);
                    this.Close();
                }
                else
                {
                    MessageBox.Show("You current selection is a library not a virtual channel !", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
                }
            }
            else
            {
                MessageBox.Show("You must select a virtual channel !", Application.ProductName, MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }
        }
Ejemplo n.º 2
0
        public Frm_VirtualChannelTest(Frm_VirtualChannel FrmParent, CS_VirtualChannel TestChannel)
        {
            //
            // The InitializeComponent() call is required for Windows Forms designer support.
            //
            InitializeComponent();

            FormParent    = FrmParent;
            bExprModified = false;

            if (!(TestChannel == null))
            {
                oChannel          = TestChannel;
                ChannelRefLibName = oChannel.ParentLibrary.Name;

                oTestLibrary           = new CS_VirtualChannelsLibrary();
                oChannel.ParentLibrary = oTestLibrary;
                oTestLibrary.Channels.Add(oChannel);

                oTestLibCollection = new CS_VCLibrariesCollection();
                oTestLibCollection.AddLibrary(oTestLibrary);
            }
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Converts the decoded PCAN trace file into a XML data file
        /// </summary>
        /// <param name="OutputFolder">Output file folder</param>
        /// <returns>Converion result (True: OK / False: Error)</returns>
        private bool WriteXmlRecordData(string OutputFolder)
        {
            if (Channels.Count == 0)
            {
                return(false);
            }

            GW_DataFile oDataFile = new GW_DataFile();

            oDataFile.DataSamplingMode = SamplingMode.MultipleRates;

            //Set data file properties
            oDataFile.DataStartTime = this.AbsDTStartTime;
            oDataFile.UserComment   = "Data file created "
                                      + DateTime.Now.ToShortDateString()
                                      + " "
                                      + DateTime.Now.ToShortTimeString();

            //Data file custom properties
            GW_XmlDataFileCustomProperty oCustProp;

            oCustProp               = new GW_XmlDataFileCustomProperty();
            oCustProp.Name          = "Base PCAN Trc file";
            oCustProp.PropertyValue = Path.GetFileName(this.BaseTrcFilePath);
            oDataFile.XmlDataFileCustomProperties.Add(oCustProp);

            oCustProp               = new GW_XmlDataFileCustomProperty();
            oCustProp.Name          = "Data decode CAN Configuration";
            oCustProp.PropertyValue = Path.GetFileName(this.oCanConfig.ConfigFilePath);
            oDataFile.XmlDataFileCustomProperties.Add(oCustProp);

            for (int i = 0; i < this.VCLibraries.Libraries.Count; i++)
            {
                oCustProp               = new GW_XmlDataFileCustomProperty();
                oCustProp.Name          = "Data decode virtual channels library #" + (i + 1).ToString();
                oCustProp.PropertyValue = Path.GetFileName(VCLibraries.Libraries[i].Name);
                oDataFile.XmlDataFileCustomProperties.Add(oCustProp);
            }

            //Set data channels
            foreach (RecordDataChannel oRecChan in Channels)
            {
                GW_DataChannel oDataChan = new GW_DataChannel(oRecChan.Name, SamplingMode.MultipleRates);

                //Channel properties
                CANParameter oCANSig = this.oCanConfig.GetCANParameter(oRecChan.Name);

                if (!(oCANSig == null)) //A CAN parameter has been found, GW_DataChannel properties will be filled using properties of the CAN Parameter
                {
                    oDataChan.Description           = oCANSig.Comment;
                    oDataChan.Unit                  = oCANSig.Unit;
                    oDataChan.GraphicFormat         = CANStreamTools.Convert_CSSignalFormatToSerieValueFormat(oCANSig.ValueFormat);
                    oDataChan.ChannelReferenceLines = CANStreamTools.Convert_CSAlarmsToSerieReferenceLines(oCANSig.Alarms);
                }
                else //No CAN parameter found, search among virtual channels
                {
                    CS_VirtualChannel oVirtual = null;

                    foreach (CS_VirtualChannelsLibrary oVirtLib in this.VCLibraries.Libraries)
                    {
                        oVirtual = oVirtLib.GetVirtualChannel(oRecChan.Name);

                        if (!(oVirtual == null))
                        {
                            break;
                        }
                    }

                    if (!(oVirtual == null)) //A virtual channel has been found, GW_DataChannel properties will be filled using properties of the virtual channel
                    {
                        oDataChan.Description           = oVirtual.Comment;
                        oDataChan.Unit                  = oVirtual.Unit;
                        oDataChan.GraphicFormat         = CANStreamTools.Convert_CSSignalFormatToSerieValueFormat(oVirtual.ValueFormat);
                        oDataChan.ChannelReferenceLines = CANStreamTools.Convert_CSAlarmsToSerieReferenceLines(oVirtual.Alarms);
                    }
                    else //No virtual channel found, GW_DataChannel will keeps its default properties values
                    {
                        //Nothing to do
                    }
                }

                //Channel samples value
                foreach (RecordDataSample oRecSample in oRecChan.Samples)
                {
                    SerieSample sDataSample = new SerieSample();

                    sDataSample.SampleTime  = oRecSample.TimeStamp / 1000;
                    sDataSample.SampleValue = oRecSample.SampleValue;

                    oDataChan.Samples.Add(sDataSample);
                }

                oDataFile.Channels.Add(oDataChan);
            }


            string OutFilePath = BuildOutputFilePtah(OutputFolder, RecordConversionFormat.Xml);

            oDataFile.Write_XmlDataFile(OutFilePath);

            return(true);
        }