예제 #1
0
        private static void AddToAllMessagesList(CAN_Message msg)
        {
            bool messageAlreadyThere = false;

            foreach (CAN_Message temp in allCANMessages)
            {
                if (msg.ID.Equals(temp.ID))
                {
                    temp.Count++;
                    temp.canData        = msg.canData;
                    messageAlreadyThere = true;

                    if (!Enumerable.SequenceEqual(temp.canData, msg.canData))
                    {
                        temp.DataChanges++;
                    }
                }
            }
            if (!messageAlreadyThere)
            {
                allCANMessages.Add(msg);
            }

            if (!FILTERS_ACTIVE)
            {
                comListener.CAN_MessageList_Update(allCANMessages);
            }
            else
            {
                CalculateFilteredMessageList();
                comListener.CAN_MessageList_Update(filteredCANMessages);
            }
        }
예제 #2
0
        private static void handleReceivedData(string data)
        {
            if (data.StartsWith("##START##"))
            {
                if (data.EndsWith("##END##"))
                {
                    try
                    {
                        data = data.Replace("##START##", "");
                        data = data.Replace("##END##", "");

                        string[] parts = new string[10];
                        parts = data.Split('%');

                        CAN_Message canMessage = new CAN_Message();

                        for (int i = 0; i < parts.Length; i++)
                        {
                            if (i == 0)
                            {
                                canMessage.ID = parts[i];
                            }                                              // ID
                            if (i == 1)
                            {
                                canMessage.DLC = parts[i];
                            }                                              // DLC
                            if (i > 1)                                     // CAN Data
                            {
                                canMessage.canData[i - 2] = parts[i];
                            }
                        }

                        //comListener.CAN_Message_Received(canMessage);
                        AddToAllMessagesList(canMessage);
                    }
                    catch (Exception ex)
                    {
                        comListener.CAN_Receive_Error(ex.Message);
                    }
                }
            }

            if (data.StartsWith("##CanSPEED##"))
            {
                data = data.Replace("##CanSPEED##", "");
                data = data.Remove(data.LastIndexOf("kbps") + 4);
                comListener.CAN_CanSpeed_Received(data);
            }
        }
예제 #3
0
 public void CAN_Message_Received(CAN_Message msg)
 {
     listView_data.Dispatcher.Invoke(new Action(() => {
         listView_data.Items.Add(new ListViewItemCANMsg
         {
             ID    = msg.ID,
             DLC   = msg.DLC,
             Bit1  = msg.canData[0],
             Bit2  = msg.canData[1],
             Bit3  = msg.canData[2],
             Bit4  = msg.canData[3],
             Bit5  = msg.canData[4],
             Bit6  = msg.canData[5],
             Bit7  = msg.canData[6],
             Bit8  = msg.canData[7],
             Count = msg.Count.ToString()
         });
     }));
 }