Exemple #1
0
        private void ParseReceiveData(ParsingDataIncommingEventArgs e,
                                      List <KeyValuePair <string, string> > itemsToAdd)
        {
            if (!e.PostiveResponse || dcmDocument == null || dcmDocument.VdfDocument == null)
            {
                return;
            }

            DcmConfig.SubFunction subFunction = FindFunction(e.RequestData);
            if (subFunction == null)
            {
                return;
            }

            // 执行解析数据
            List <byte> data = new List <byte>();

            for (int i = subFunction.Prefix.Count; i < e.ResponseData.Count; i++)
            {
                data.Add(e.ResponseData[i]);
            }

            var message = dcmDocument.VdfDocument.Message(subFunction.Message);

            foreach (var entry in message.SignalTable)
            {
                string value = VdfEncoder.Encode(data, entry.Value, true);
                itemsToAdd.Add(new KeyValuePair <string, string>(entry.Value.Name, value));
            }
        }
        internal void OnParsingDataIncomming(ParsingDataIncommingEventArgs e)
        {
            if (InvokeRequired)
            {
                OnParsingDataIncommingCallback callback = OnParsingDataIncomming;
                Invoke(callback, e);
            }
            else
            {
                if (e.ResponseData == null || e.ResponseData.Count < 2)
                {
                    return;
                }

                // 更新Key
                int       sid           = e.ResponseData[0];
                const int securitySid   = 0x67;
                int       securityLevel = e.ResponseData[1];

                if ((sid == securitySid) && (securityLevel % 2 == 1))
                {
                    List <byte> seed = new List <byte>();
                    for (int i = 2; i < e.ResponseData.Count; i++)
                    {
                        seed.Add(e.ResponseData[i]);
                    }
                    UpdateSecurityKey(securityLevel, seed);
                }
            }
        }
Exemple #3
0
        internal void OnParsingDataIncomming(ParsingDataIncommingEventArgs e)
        {
            if (dcmDataDGV.InvokeRequired)
            {
                AddItemsCallback callback = new AddItemsCallback(OnParsingDataIncomming);
                dcmDataDGV.Invoke(callback, e);
            }
            else
            {
                dcmDataDGV.SuspendLayout();

                // 添加请求ID
                if (e.RequestData != null)
                {
                    dcmDataDGV.Rows.Add(new string[] { string.Format("Tx{0:X3}", e.RequestCanId),
                                                       Utils.HexArrayToString(e.RequestData) });
                }

                // 添加响应ID
                if (e.ResponseData != null)
                {
                    dcmDataDGV.Rows.Add(new string[] { string.Format("Rx{0:X3}", e.ResponseCanId),
                                                       Utils.HexArrayToString(e.ResponseData) });
                }
                else
                {
                    dcmDataDGV.Rows.Add(new string[] { "<Empty>", "<Empty>" });
                }

                // 设置响应数据前景色
                var cell = dcmDataDGV[ColumnDataIndex, dcmDataDGV.Rows.Count - 1];
                cell.Selected = true;

                // 添加、解析数据
                List <KeyValuePair <string, string> > itemsToAdd
                    = new List <KeyValuePair <string, string> >();
                itemsToAdd.AddRange(e.EntryList);
                ParseReceiveData(e, itemsToAdd);

                ResponseDataTag tag = new ResponseDataTag
                {
                    ParsedList      = itemsToAdd,
                    PostiveResponse = e.PostiveResponse
                };
                cell.Tag = tag;

                dcmDataDGV.ResumeLayout();

                // 手动通知选择变化
                dcmDataDGV_SelectionChanged(dcmDataDGV, EventArgs.Empty);
            }
        }