Beispiel #1
0
 public override string ToString()
 {
     return($"CONFIG Version:{Version}" + Environment.NewLine +
            $" S Interval:{ShortInterval}, L Interval:{LongInterval}, Batt Thresh:{BatteryThreshold_mV} " +
            $"Batt E Thresh:{BatteryEmergencyThres_mV}, Demand Relay:{DemandRelay}" + Environment.NewLine +
            $" Relay Commands:({StationsToRelayCommands.ToCsv(b => ((char)b).ToString())}) " + Environment.NewLine +
            $" Relay Weather:({StationsToRelayWeather.ToCsv(b => ((char)b).ToString())})" + Environment.NewLine +
            $" Freq:{Frequency_Hz / 1.0E6:F3} Hz, BW:{Bandwidth_Hz/1.0E3:F3} kHz, TxPower:{TxPower}, SF:{SpreadingFactor}, CSMA_P:{CSMA_P}, CSMA_Slot:{CSMA_Timeslot} uS, OB_Preamble:{OutboundPreambleLength}" + Environment.NewLine +
            $" TsOffset:{TsOffset}, TSGain:{TsGain}, WdCalibMin:({WdCalib1x}, {WdCalib1y}), WdCalibMax:{WdCalib2}" + Environment.NewLine +
            $" ChargeV: {ChargeVoltage_mV} mV, ChargeResponsitivity: {ChargeResponseRate}, FreezingChargeV: {SafeFreezingChargeLevel_mV} mV, FreezingPwm: {SafeFreezingPwm}" + Environment.NewLine +
            $" Record Types: ({MessageRecordTypes.ToCsv()}) Non Relay Records: {NonRelayRecording}");
 }
Beispiel #2
0
        public QueryConfigResponse(Span <byte> inputData)
            : base(inputData, out var consumed)
        {
            inputData             = inputData.Slice(consumed);
            using MemoryStream ms = new MemoryStream();
            ms.Write(inputData);
            ms.Seek(0, SeekOrigin.Begin);
            BinaryReader br = new BinaryReader(ms);

            Initialised = br.ReadBoolean();
            if (VersionNumber >= new Version(2, 1))
            {
                StationID = (char)br.ReadByte();
            }
            ShortInterval            = br.ReadUInt32();
            LongInterval             = br.ReadUInt32();
            BatteryThreshold_mV      = br.ReadUInt16();
            BatteryEmergencyThres_mV = br.ReadUInt16();
            DemandRelay             = br.ReadBoolean();
            StationsToRelayCommands = new List <byte>();
            for (int i = 0; i < ArraySize; i++)
            {
                var stationID = br.ReadByte();
                if (stationID != 0)
                {
                    StationsToRelayCommands.Add(stationID);
                }
            }
            StationsToRelayWeather = new List <byte>();
            for (int i = 0; i < ArraySize; i++)
            {
                var stationID = br.ReadByte();
                if (stationID != 0)
                {
                    StationsToRelayWeather.Add(stationID);
                }
            }
            Frequency_Hz           = br.ReadUInt32();
            Bandwidth_Hz           = br.ReadUInt16() * 100;
            TxPower                = br.ReadInt16();
            SpreadingFactor        = br.ReadByte();
            CSMA_P                 = br.ReadByte();
            CSMA_Timeslot          = br.ReadUInt32();
            OutboundPreambleLength = br.ReadUInt16();
            TsOffset               = br.ReadSByte();
            TsGain                 = br.ReadByte();
            WdCalib1               = br.ReadInt16();
            WdCalib2               = br.ReadInt16();
            if (VersionNumber >= new Version(2, 2))
            {
                ChargeVoltage_mV           = br.ReadUInt16();
                ChargeResponseRate         = br.ReadUInt16();
                SafeFreezingChargeLevel_mV = br.ReadUInt16();
                SafeFreezingPwm            = br.ReadByte();
            }
            if (VersionNumber >= new Version(2, 3))
            {
                for (int i = 0; i < TypeArraySize; i++)
                {
                    var recordType = br.ReadByte();
                    if (recordType != 0)
                    {
                        MessageRecordTypes.Add((char)recordType);
                    }
                }
                NonRelayRecording = br.ReadBoolean();
            }
        }