public static void PacketGroundSensor(Packet Packet) { if (Packet == null || Packet.Data == null || Packet.Data.Payload == null || Packet.Data.Payload.Length != 40) { Log.Output(Log.Severity.WARNING, Log.Source.NETWORK, "Ground sensor packet invalid. Discarding. Length: " + Packet?.Data?.Payload?.Length); return; } DateTime Timestamp = DateTime.Now; int UVLight = UtilData.ToInt(UtilMain.SubArray(Packet.Data.Payload, 0, 4)); float AirQuality = UtilData.ToFloat(UtilMain.SubArray(Packet.Data.Payload, 4, 4)); float SoilMoist = UtilData.ToFloat(UtilMain.SubArray(Packet.Data.Payload, 8, 4)); uint ThermocoupleData = UtilData.ToUInt(UtilMain.SubArray(Packet.Data.Payload, 12, 4)); double AtmoTemp = UtilData.ToDouble(UtilMain.SubArray(Packet.Data.Payload, 16, 8)); double AtmoPres = UtilData.ToDouble(UtilMain.SubArray(Packet.Data.Payload, 24, 8)); double AtmoHumid = UtilData.ToDouble(UtilMain.SubArray(Packet.Data.Payload, 32, 8)); UV.Data.Add(new Datum <int>(Timestamp, UVLight)); AirPollution.Data.Add(new Datum <float>(Timestamp, AirQuality)); SoilMoisture.Data.Add(new Datum <float>(Timestamp, SoilMoist)); ThermoExt.Data.Add(new Datum <float>(Timestamp, MAX31855.ConvertExternalFromRaw(ThermocoupleData))); ThermoInt.Data.Add(new Datum <float>(Timestamp, MAX31855.ConvertInternalFromRaw(ThermocoupleData))); AirTemp.Data.Add(new Datum <double>(Timestamp, AtmoTemp)); AirPressure.Data.Add(new Datum <double>(Timestamp, AtmoPres)); AirHumidity.Data.Add(new Datum <double>(Timestamp, AtmoHumid)); }
public static void PacketSysSensor(Packet Packet) { if (Packet == null || Packet.Data == null || Packet.Data.Payload == null || Packet.Data.Payload.Length != 40) { Log.Output(Log.Severity.WARNING, Log.Source.NETWORK, "System sensor packet invalid. Discarding. Length: " + Packet?.Data?.Payload?.Length); return; } double SysA = UtilData.ToDouble(UtilMain.SubArray(Packet.Data.Payload, 0, 8)); double DrillA = UtilData.ToDouble(UtilMain.SubArray(Packet.Data.Payload, 8, 8)); double RailA = UtilData.ToDouble(UtilMain.SubArray(Packet.Data.Payload, 16, 8)); double SysV = UtilData.ToDouble(UtilMain.SubArray(Packet.Data.Payload, 24, 8)); DateTime Sample = new DateTime(UtilData.ToLong(UtilMain.SubArray(Packet.Data.Payload, 32, 8))); //Log.Output(Log.Severity.INFO, Log.Source.GUI, "Got sysA:" + SysCurrent + ", DrlA:" + DrillCurrent + ", SysV:" + SysVoltage); BaseMain.Window.UpdateGauges(SysV, SysA, DrillA, RailA); SupplyVoltage.Data.Add(new Datum <double>(Sample, SysV)); SystemCurrent.Data.Add(new Datum <double>(Sample, SysA)); DrillCurrent.Data.Add(new Datum <double>(Sample, DrillA)); RailCurrent.Data.Add(new Datum <double>(Sample, RailA)); }
/// <summary> Interperate next data block as double. </summary> /// <returns> Next data. </returns> public double NextDouble() { return(UtilData.ToDouble(NextData(sizeof(double)))); }