Ejemplo n.º 1
0
 /// <summary>
 /// The message which has been sent ot the target, so the time stamp needs to be logged
 /// </summary>
 /// <param name="message"></param>
 /// <param name="start"></param>
 /// <param name="stop"></param>
 public CSentMessageViewModel(CMessageViewModel message, int start, int stop)
 {
     _message = new CMessageViewModel()
     {
         MessageName = message.MessageName, MessageId = message.MessageId, MessageData = message.MessageData, MessageDlc = message.MessageDlc
     };
     _startTime = start;
     _stopTime  = stop;
 }
Ejemplo n.º 2
0
 public CSentMessageViewModel(CStepViewModel step)
 {
     _message = step.StepMessage;
     _signal  = step.StepSignal;
 }
Ejemplo n.º 3
0
        void LoadDbcExecute()
        {
            try
            {
                FilterOutString = "Loading database";
                Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
                dlg.DefaultExt = ".dbc";
                dlg.Filter     = "DBC Files (*.dbc)|*.dbc";
                if (dlg.ShowDialog() == true)
                {
                    String sPath = dlg.FileName;
                    if (System.IO.File.Exists(sPath))
                    {
                        const string MESSAGES_EXP = @"BO_ (?<message_id>[0-9]+) (?<message_name>[a-zA-Z0-9_]+): (?<message_dlc>[0-8]) (?<message_ecu>[a-zA-Z0-9_]+)\r\n(?<message_signals>( SG_[^\r\n]+\r\n)+)";
                        const string SIGNALS_EXP  = @"SG_ (?<signal_name>[a-zA-Z0-9_]+)(?<signal_sbit>[a-zA-Z0-9_ ]*): (?<signal_sbit>[0-9]+)\|(?<signal_len>[0-9]+)\@(?<signal_intel>[0-9]+)(?<signal_signed>[\+\-]+)";

                        StreamReader    sr          = new StreamReader(sPath);
                        String          FileContent = sr.ReadToEnd();
                        MatchCollection mcMessages  = Regex.Matches(FileContent, MESSAGES_EXP, RegexOptions.Multiline);
                        Match           mComment;
                        Int64           i64MsgId;
                        string          sCommentPattern;
                        _messages.Clear();
                        foreach (Match mMessages in mcMessages)
                        {
                            CMessageViewModel oMsvm = new CMessageViewModel();
                            i64MsgId = Convert.ToInt64(mMessages.Groups["message_id"].Value);
                            if (i64MsgId == 1414)
                            {
                            }
                            if (i64MsgId <= Int32.MaxValue)
                            {
                                oMsvm.MessageId   = Convert.ToInt32(i64MsgId);
                                oMsvm.MessageName = Convert.ToString(mMessages.Groups["message_name"].Value);
                                oMsvm.MessageDlc  = Convert.ToInt32(mMessages.Groups["message_dlc"].Value);
                                oMsvm.MessageEcu  = Convert.ToString(mMessages.Groups["message_ecu"].Value);
                                oMsvm.MessageData = new byte[oMsvm.MessageDlc];
                                sCommentPattern   = @"CM_ BO_ " + mMessages.Groups["message_id"].Value.ToString() + @" ""(?<message_comment>.*)""";
                                mComment          = Regex.Match(FileContent, sCommentPattern);
                                if (mComment.Success)
                                {
                                    oMsvm.MessageComment = mComment.Groups["message_comment"].Value;
                                }
                                MatchCollection mcSignals = Regex.Matches(mMessages.Groups["message_signals"].ToString(), SIGNALS_EXP, RegexOptions.Multiline);
                                foreach (Match mSignals in mcSignals)
                                {
                                    CSignalViewModel oSigvm = new CSignalViewModel();
                                    oSigvm.SignalName     = Convert.ToString(mSignals.Groups["signal_name"].Value);
                                    oSigvm.SignalStartBit = Convert.ToInt32(mSignals.Groups["signal_sbit"].Value);
                                    oSigvm.SignalLenght   = Convert.ToInt32(mSignals.Groups["signal_len"].Value);
                                    oSigvm.SignalIntel    = Convert.ToString(mSignals.Groups["signal_intel"].Value);
                                    oSigvm.SignalSigned   = Convert.ToString(mSignals.Groups["signal_signed"].Value);
                                    sCommentPattern       = @"CM_ SG_ " + mMessages.Groups["message_id"].Value.ToString() + @" " + mSignals.Groups["signal_name"].Value.ToString() + @" ""(?<signal_comment>.*)""";
                                    mComment = Regex.Match(FileContent, sCommentPattern);
                                    if (mComment.Success)
                                    {
                                        oSigvm.SignalComment = mComment.Groups["signal_comment"].Value;
                                    }
                                    oMsvm.Signals.Add(oSigvm);
                                }
                                this.Messages.Add(oMsvm);
                            }
                        }
                        ProjectPathDbc = (String)sPath;
                    }
                    else
                    {
                        MessageBox.Show(String.Format("The File {0} does not exist", sPath));
                    }
                }
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
            FilterOutString = "Database loaded";
        }