Exemplo n.º 1
0
        /// <summary>
        /// ctor for message
        /// </summary>
        /// <param name="canMsg"></param>
        /// <param name="sigType"></param>
        /// <param name="opstate"></param>
        /// <param name="var"></param>
        public Connection(DbcMessage canMsg, CanTxSignalType sigType, OpState opstate, Variant var)
        {
            SourceCANTxSignal = canMsg;
            TargetSignalType  = sigType;
            Variant           = var;
            ConnectedOpState  = opstate;


            PrepareParameters();
            cloneArtifacts();
            RegisterChildChangeEvent();
        }
Exemplo n.º 2
0
        static void Main(string[] args)
        {
            byte[] datas = {0xB4,0XE5,0x93};
            DbcMessage msg = new DbcMessage("MESSAGE");

               DbcSignal signal = msg.Add("signal1 ");
            signal.StartBit = 0;
            signal.Size = 4;

            DbcSignal signal1 = msg.Add("signal2 ");
            signal1.StartBit = 8;
            signal1.Size = 9;

             //   msg.Add("signal2");
              //  msg.Add("signal3");
            msg.AddMessageDatas(datas, 3);
            Console.ReadKey();
        }
 public bool IsConnectionExists(DbcMessage canMsg, CanTxSignalType sigType, OpState opstate, Variant var)
 {
     return(_connections.Any(p => (p.SourceCANTxSignal is DbcMessage) && ((DbcMessage)p.SourceCANTxSignal).Name == canMsg.Name && p.TargetSignalType.Name == sigType.Name && p.ConnectedOpState.Name == opstate.Name && p.Variant.RbVariant == var.RbVariant));
 }
        public ItemsChangeObservableCollection <Connection> GetConnectionFromItem(DbcMessage message)
        {
            IEnumerable <Connection> tempList = from x in _connections where ((x.SourceCANTxSignal is DbcMessage) && (x.SourceCANTxSignal as DbcMessage).Name == message.Name) select x;

            return(new ItemsChangeObservableCollection <Connection>(tempList));
        }
Exemplo n.º 5
0
        public object Convert(object[] value, Type targetType, object parameter, CultureInfo culture)
        {
            object CANTxItem = (value[0] as TreeViewItem).DataContext;
            ObservableCollection <DbcMessage> BaseDBC = (ObservableCollection <DbcMessage>)value[1];

            if (CANTxItem is DbcMessage)
            {
                if (BaseDBC.Where(x => (x.Name == ((DbcMessage)CANTxItem).Name) && (x.ID == ((DbcMessage)CANTxItem).ID) && (x.DLC == ((DbcMessage)CANTxItem).DLC) && (x.CycleTime == ((DbcMessage)CANTxItem).CycleTime)).Count() > 0)
                {
                    DbcMessage seletectMessage = (DbcMessage)CANTxItem;
                    ObservableCollection <DbcMessage> founds = new ObservableCollection <DbcMessage>(BaseDBC.Where(x => (x.ID == ((DbcMessage)CANTxItem).ID) && (x.DLC == ((DbcMessage)CANTxItem).DLC) && (x.CycleTime == ((DbcMessage)CANTxItem).CycleTime)));
                    bool layoutSame = true;

                    foreach (var sig in founds[0].Signals)
                    {
                        if (seletectMessage.Signals.Where(x => x.StartBit == sig.StartBit && x.Length == sig.Length).Count() == 0)
                        {
                            layoutSame = false;
                        }
                    }

                    foreach (var sig in seletectMessage.Signals)
                    {
                        if (founds[0].Signals.Where(x => x.StartBit == sig.StartBit && x.Length == sig.Length).Count() == 0)
                        {
                            layoutSame = false;
                        }
                    }

                    if (layoutSame)
                    {
                        return(new BitmapImage(new Uri("pack://application:,,,/Icon/Ok.png", UriKind.Absolute)));
                    }
                    else
                    {
                        return(new BitmapImage(new Uri("pack://application:,,,/Icon/layoutChanged.png", UriKind.Absolute)));
                    }
                }
                else if (BaseDBC.Where(x => x.ID == ((DbcMessage)CANTxItem).ID).Count() == 0)
                {
                    return(new BitmapImage(new Uri("pack://application:,,,/Icon/removed.png", UriKind.Absolute)));
                }
                else
                {
                    return(new BitmapImage(new Uri("pack://application:,,,/Icon/modified.png", UriKind.Absolute)));
                }
            }
            else if (CANTxItem is DbcSignal)
            {
                if ((BaseDBC.Where(x => (x.Signals.Where(y => y.StartBit == ((DbcSignal)CANTxItem).StartBit &&
                                                         y.Length == ((DbcSignal)CANTxItem).Length &&
                                                         y.Offset == ((DbcSignal)CANTxItem).Offset &&
                                                         y.Factor == ((DbcSignal)CANTxItem).Factor &&
                                                         y.ValueType == ((DbcSignal)CANTxItem).ValueType &&
                                                         y.ByteOrder == ((DbcSignal)CANTxItem).ByteOrder &&
                                                         y.Name == ((DbcSignal)CANTxItem).Name &&
                                                         y.InMessage == ((DbcSignal)CANTxItem).InMessage).Count() > 0
                                         )
                                   ).Count() > 0
                     )
                    )
                {
                    return(new BitmapImage(new Uri("pack://application:,,,/Icon/Ok.png", UriKind.Absolute)));
                }
                else if ((BaseDBC.Where(x => (x.Signals.Where(y => y.StartBit == ((DbcSignal)CANTxItem).StartBit &&
                                                              y.Length == ((DbcSignal)CANTxItem).Length &&
                                                              y.InMessage == ((DbcSignal)CANTxItem).InMessage).Count() > 0

                                              )
                                        ).Count() == 0))
                {
                    return(new BitmapImage(new Uri("pack://application:,,,/Icon/removed.png", UriKind.Absolute)));
                }
                else
                {
                    return(new BitmapImage(new Uri("pack://application:,,,/Icon/modified.png", UriKind.Absolute)));
                }
            }
            else
            {
                return(new BitmapImage(new Uri("pack://application:,,,/Icon/Nok.png", UriKind.Absolute)));
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// 
        /// </summary>
        private void GetDbcMessageInfo()
        {
            string[] sentences = _fileString.Split('\n');
            string[] wordToMatch = { "BO_", "SG_" };

            //提取出dbc文件中以"BO_"和"SG_"开头的行,这些行分别代表message和signal

            var sentenceQuery = from sentence in sentences
                                let w = sentence.Split(new char[] { '.', '?', '!', ' ', ';', ':', ',' },
                                                        StringSplitOptions.RemoveEmptyEntries)
                                //   where w.First().ToString() == "BO_"
                                where w.Intersect(wordToMatch).Count() > 0
                                select sentence;

            sentenceQuery = from sentence in sentenceQuery
                            let w = sentence.Split(new char[] { '.', '?', '!', ' ', ';', ':', ',' },
                                                    StringSplitOptions.RemoveEmptyEntries)
                            where (w.First().ToString() == "BO_") || (w.First().ToString() == "SG_")
                            select sentence;

            string[] w1 = new String[30];
            int index = 0;
             DbcSignal signal;
            foreach(string line in sentenceQuery)
            {
                w1 = line.Split(new char[] { ' ', ';', ':', ',', '|', '@', '(', ')', '[', ']', '{', '}' }, StringSplitOptions.RemoveEmptyEntries);
                if(w1[0].Equals("BO_"))
                {
                    //if(index!=0)
                    //    index++;
                    _messageArray[index] = new DbcMessage(w1[2]);
                    _messageArray[index].MessageId = (ushort)Convert.ToDecimal(w1[1]);
                    _messageArray[index].MessageSize = (byte)Convert.ToDecimal(w1[3]);
                    index++;
                }
                else if(w1[0].Equals("SG_"))
                {
                    signal = _messageArray[index-1].Add(w1[1]);
                    signal.Size = SearchDbcSignalSize(line);
                    signal.StartBit = SearchDbcSignalStartBit(line);
                    signal.Maximum = SearchDbcSignalMaximun(line);
                    signal.Minimum = SearchDbcSignalMinimun(line);
                }

            }
            _messageCount = index;
        }