Пример #1
0
        public LogFileReader(string path, SerializerSession settings)
        {
            _session = settings;
            Messages = new ByteMessageCollection(_session);
            var lines = System.IO.File.ReadAllLines(path);
            int nr    = 1;

            var parameter = lines.FirstOrDefault(e => e.Contains("; RadioChannel:"));

            if (parameter != null)
            {
                int start = parameter.IndexOf(';') + 2;
                parameter = parameter.Substring(start).Trim();
                _session.SetParametersByString(parameter);
            }
            else
            {
                //throw new Exception("Parameter string in logfile.Line should start with 'RadioChannel'.");
            }
            //6/1/2017 12:02:23 AM; 00-00-00-00-01-58
            foreach (var item in lines)
            {
                var split = item.Split(';');
                if (split.Length == 2)
                {
                    string bytestr = split[1].Trim();
                    if (bytestr.StartsWith("00-"))
                    {
                        Messages.Add(bytestr.GetBytes(), nr, split[0]);
                        nr += 1;
                    }
                    else
                    {
                    }
                }
            }
            _session.PumpDataHistory.ExtractHistoryEvents();
        }
Пример #2
0
        public override void SetValue(List <byte> bytes, int fieldOffset, PropertyInfo propertyInfo, Object value, SerializerSession settings)
        {
            var len = (bytes.Count - From) + Add;

            bytes[fieldOffset] = BitConverter.GetBytes(len)[0];
        }
Пример #3
0
 public override void SetValue(List <byte> bytes, int fieldOffset, PropertyInfo propertyInfo, Object value, SerializerSession settings)
 {
     if (fieldOffset <= bytes.Count)
     {
         var temp = bytes.ToList().GetRange(From, bytes.Count - From).ToArray();
         bytes[fieldOffset] = temp.OneByteSum();
     }
 }
Пример #4
0
        public override void SetValue(List <byte> bytes, int fieldOffset, PropertyInfo propertyInfo, Object value, SerializerSession settings)
        {
            var element = (BinaryType)value.GetType().GetTypeInfo().GetCustomAttribute(typeof(BinaryType));

            if (fieldOffset == 1000)
            {
                fieldOffset = bytes.Count - 2;
            }

            // do not get the crc-field
            var temp = bytes.GetRange(0, bytes.Count - 2);

            var crc = temp.ToArray().GetCrc16citt() & 0xffff;

            var crcbytes = BitConverter.GetBytes((short)crc).ToList();

            if (!element.IsLittleEndian)
            {
                crcbytes = crcbytes.ToArray().Reverse().ToList();
            }

            bytes[fieldOffset]     = crcbytes[0];
            bytes[fieldOffset + 1] = crcbytes[1];
            propertyInfo.SetValue(value, crcbytes.ToArray());

            //    if (element.IsLittleEndian)
            //{
            //    bytes[fieldOffset] = crcbytes[0];
            //    bytes[fieldOffset + 1] = crcbytes[1];
            //    propertyInfo.SetValue(value, crcbytes);
            //}
            //else
            //{
            //    bytes[fieldOffset] = crcbytes[1];
            //    bytes[fieldOffset + 1] = crcbytes[0];
            //    propertyInfo.SetValue(value, crcbytes);
            //}
        }
Пример #5
0
        public override void SetValue(List <byte> bytes, int fieldOffset, PropertyInfo propertyInfo, Object value, SerializerSession settings)
        {
            //ForEncryption = bytes[1] == 0x00;

            if (settings.SessionCommunicationParameters.EncryptKey == null || settings.SessionCommunicationParameters.EncryptIV == null)
            {
                throw new Exception("Missing encryptKey/IV in serializationsettings.");
            }

            var temp = bytes.ToList().GetRange(fieldOffset, Length).ToArray();

            var crp = temp.CryptMessage(ForEncryption, settings.SessionCommunicationParameters.EncryptKey, settings.SessionCommunicationParameters.EncryptIV);

            for (int i = 0; i < crp.Length; i++)
            {
                bytes[fieldOffset + i] = crp[i];
            }
        }
Пример #6
0
 public abstract void SetValue(List <byte> bytes, int fieldOffset, PropertyInfo propertyInfo, Object value, SerializerSession settings);
Пример #7
0
 public Serializer(SerializerSession session)
 {
     _session = session;
 }
Пример #8
0
        //public DateTime? From { get; set; }
        //public DateTime? To { get; set; }

        public PumpDataHistory(SerializerSession session)
        {
            _session = session;
        }
Пример #9
0
 public MultiPacketHandler(SerializerSession session)
 {
     _session = session;
     _seri    = new Serializer(_session);
 }
 public SessionCommunicationParameters(SerializerSession session)
 {
     _session = session;
 }
Пример #11
0
 public PythonLogFileReader(string path, SerializerSession session) : this(session)
 {
     var lines = System.IO.File.ReadAllLines(path);
     ReadLines(lines);
 }
Пример #12
0
 public PythonLogFileReader(SerializerSession session)
 {
     _session = session;
     Messages = new ByteMessageCollection(_session);
 }