Beispiel #1
0
        /// <summary>
        /// Create the graphic data file of the current cycle for the Ctrl_GraphWindow control
        /// </summary>
        /// <returns>Ctrl_GraphWindow data file</returns>
        public GW_DataFile CreateCycleGraphData()
        {
            GW_DataFile oGraphData = new GW_DataFile();

            oGraphData.DataSamplingMode = SamplingMode.MultipleRates;

            if (!(oCanNodesMap == null))
            {
                foreach (CycleTimeEvent TxEvent in TimeEvents)
                {
                    foreach (CANMessageData MsgData in TxEvent.MessagesData)
                    {
                        CANMessage MsgCfg = oCanNodesMap.GetCANMessage(NumberBaseConverter.Dec2Hex(MsgData.uMessageId), MessageResearchOption.Identifier);

                        if (!(MsgCfg == null))
                        {
                            TPCANMsg sTPMsg = new TPCANMsg();
                            sTPMsg.DATA = MsgData.byteMessageData;

                            CANMessageDecoded oMsgDecoded = new CANMessageDecoded(MsgCfg, sTPMsg);

                            if (oMsgDecoded.bMessageDecoded)
                            {
                                foreach (CANParameter oParam in oMsgDecoded.Parameters)
                                {
                                    GW_DataChannel oGraphChan = oGraphData.Get_DataChannel(oParam.Name);

                                    if (oGraphChan == null)
                                    {
                                        oGraphChan = new GW_DataChannel(oParam.Name, SamplingMode.MultipleRates);
                                        oGraphData.Channels.Add(oGraphChan);
                                    }

                                    SerieSample sSample = new SerieSample();
                                    sSample.SampleTime  = (double)TxEvent.TimeEvent / 1000;
                                    sSample.SampleValue = oParam.DecodedValue;

                                    oGraphChan.Add_ChannelValue(sSample);
                                }
                            }
                        }
                    }
                }
            }

            return(oGraphData);
        }
Beispiel #2
0
        /// <summary>
        /// Decodes the PCAN trace file CAN messages in raw format into the engineering format according to the specified CAN Configuration
        /// </summary>
        /// <returns>Decoding result (True: OK / False: Error)</returns>
        private bool DecodeTrcFile()
        {
            bool bComputeVirtuals = false;
            long iRecord          = 0;

            if (!(VCLibraries == null))
            {
                VCLibraries.InitLibrariesComputation();
                bComputeVirtuals = true;
            }

            foreach (TraceRecord Record in Records)
            {
                iRecord++;

                if (oCanConfig.IsUsedIdentifier(Record.MessageIdentifier))
                {
                    CANMessage oMessage = oCanConfig.GetCANMessage(Record.MessageIdentifier, MessageResearchOption.Identifier);

                    if (!(oMessage == null))
                    {
                        CANMessageDecoded oMsgDecoded = new CANMessageDecoded(oMessage, Record);

                        if (oMsgDecoded.bMessageDecoded)
                        {
                            foreach (CANParameter oParam in oMsgDecoded.Parameters)
                            {
                                AddDataSample(oParam.Name, Record.TimeOffset, oParam.DecodedValue);

                                if (bComputeVirtuals)
                                {
                                    VCLibraries.UpDateVariableElement(oParam.Name, oParam.DecodedValue);
                                }
                            }

                            if (bComputeVirtuals)
                            {
                                VCLibraries.ComputeLibraries();

                                foreach (CS_VirtualChannelsLibrary oLib in VCLibraries.Libraries)
                                {
                                    foreach (CS_VirtualChannel oVirtual in oLib.Channels)
                                    {
                                        if (oVirtual.bComputed && (oVirtual.bNewValue | iRecord == Records.Count))                                         //Virtual channel computation for the last record in order to have value until the end
                                        {
                                            oVirtual.bNewValue = false;

                                            if (!oVirtual.InError)
                                            {
                                                if (!Double.IsNaN(oVirtual.Value))
                                                {
                                                    AddDataSample(oVirtual.Name, Record.TimeOffset, oVirtual.Value);
                                                }
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }

            return(true);
        }