Esempio n. 1
0
        public IEnumerable <DecodedMessage> Decode(RawBusMessage reading)
        {
            int decodeCounter = 0;

            foreach (var sensorConfig in _sensorConfigs)
            {
                yield return(Decode(reading, sensorConfig, decodeCounter));

                decodeCounter++;
            }
        }
Esempio n. 2
0
        public DecodedMessage Decode(RawBusMessage reading, SensorConfig sensorConfig, int decodeCounter)
        {
            var baseValue  = GetDecodedBaseValue(reading.Data, sensorConfig);
            var finalValue = baseValue * sensorConfig.Precision;

            Console.WriteLine($"    Decoded Message: {reading.Counter} Sensor: {sensorConfig.SensorCode} {finalValue} {sensorConfig.Unit}");

            return(new DecodedMessage()
            {
                Label = sensorConfig.SensorCode,
                ReadingTime = reading.ReadingTime,
                Source = sensorConfig.ComponentCode,
                MachineId = reading.MachineId,
                Unit = sensorConfig.Unit,
                Value = finalValue,
                Counter = (double)reading.Counter + ((double)decodeCounter / 100.0)
            });
        }