/// <summary> /// Выбирает из последовательности CAN-сообщений в БЛОК-сообщения указанного типа /// </summary> /// <typeparam name="T">Тип сообщений БЛОК</typeparam> /// <param name="FramesFlow">Поток CAN-сообдений</param> /// <returns>Последовательность сообщений БЛОК указанного типа</returns> public static IEnumerable <T> OfFrameType <T>(this IEnumerable <CanFrame> FramesFlow) where T : BlokFrame, new() { var FilteringDescriptors = new HashSet <int>(BlokFrame.GetDescriptors <T>().Values); return(FramesFlow.Where(f => FilteringDescriptors.Contains(f.Descriptor)).Select(f => BlokFrame.GetBlokFrame <T>(f))); }
private static void FillWithData(BlokFrame Frame, byte[] DataBytes) { try { Frame.Decode(DataBytes); } catch (Exception exc) { throw new BlokFrameProtocolException(String.Format("Ошибка при декодировании CAN-сообщения {0}: {1}", Frame.GetType().Name, exc.Message), exc); } }