public DeviceStatus(WeatherPacket packet) { SerialNumber = packet.serial_number; HubSN = packet.hub_sn; Timestamp = WeatherPacket.FromUnixTimeSeconds(packet.timestamp); Uptime = packet.uptime; Voltage = packet.voltage; try { if (!int.TryParse(packet.firmware_revision.ToString(), out var i)) { i = -1; } FirmwareRevision = i; } catch (Exception e) { var ex = e.Message; } RSSI = packet.rssi; HubRSSI = packet.hub_rssi; SensorStatus = packet.sensor_status; Debug = packet.debug; }
public LightningStrike(WeatherPacket packet) { SerialNumber = packet.serial_number; HubSN = packet.hub_sn; if (packet.evt.Count == 3) { Timestamp = WeatherPacket.FromUnixTimeSeconds(packet.evt[0]); Distance = Convert.ToInt32(packet.evt[1]); Energy = Convert.ToInt32(packet.evt[2]); } }
public RapidWind(WeatherPacket packet) { //string sn, string hubsn, List<decimal> ob SerialNumber = packet.serial_number; HubSN = packet.hub_sn; if (packet.ob.Count == 3) { Timestamp = WeatherPacket.FromUnixTimeSeconds((long)packet.ob[0]); WindSpeed = packet.ob[1]; WindDirection = (int)packet.ob[2]; } }
private static void LoadObservation(Observation o, decimal?[] ob) { o.Timestamp = WeatherPacket.FromUnixTimeSeconds(WeatherPacket.Getlong(ob[0])); o.WindLull = WeatherPacket.GetDecimal(ob[1]); o.WindAverage = WeatherPacket.GetDecimal(ob[2]); o.WindGust = WeatherPacket.GetDecimal(ob[3]); o.WindDirection = WeatherPacket.GetInt(ob[4]); o.WindSampleInt = WeatherPacket.GetInt(ob[5]); o.StationPressure = WeatherPacket.GetDecimal(ob[6]); o.Temperature = WeatherPacket.GetDecimal(ob[7]); o.Humidity = WeatherPacket.GetDecimal(ob[8]); o.Illuminance = WeatherPacket.GetInt(ob[9]); o.UV = WeatherPacket.GetDecimal(ob[10]); o.SolarRadiation = WeatherPacket.GetInt(ob[11]); o.Precipitation = WeatherPacket.GetDecimal(ob[12]); switch (WeatherPacket.GetInt(ob[13])) { case 0: o.PrecipType = WeatherPacket.PrecipType.None; break; case 1: o.PrecipType = WeatherPacket.PrecipType.Rain; break; case 2: o.PrecipType = WeatherPacket.PrecipType.Hail; break; default: o.PrecipType = WeatherPacket.PrecipType.None; break; } o.LightningAvgDist = WeatherPacket.GetInt(ob[14]); o.LightningCount = WeatherPacket.GetInt(ob[15]); o.BatteryVoltage = WeatherPacket.GetDecimal(ob[16]); o.ReportInterval = WeatherPacket.GetInt(ob[17]); if (ob.Length >= 21) { // these are only available for history data, not from the UDP message o.LocalDayRain = WeatherPacket.GetInt(ob[18]); o.FinalRainChecked = WeatherPacket.GetInt(ob[19]); o.LocalRainChecked = WeatherPacket.GetInt(ob[20]); } }
public HubStatus(WeatherPacket packet) { //string sn, string hubsn, List<decimal> ob SerialNumber = packet.serial_number; Timestamp = WeatherPacket.FromUnixTimeSeconds(packet.timestamp); if (packet.radio_stats.Count == 5) { RadioVersion = packet.radio_stats[0]; RadioReboots = packet.radio_stats[1]; RadioBusErrors = packet.radio_stats[2]; FirmwareRevision = packet.firmware_revision.ToString(); Uptime = packet.uptime; Rssi = packet.rssi; ResetFlags = packet.reset_flags; Seq = packet.seq; switch (packet.radio_stats[3]) { case 0: RadioStatus = WeatherPacket.RadioStatus.RadioOff; break; case 1: RadioStatus = WeatherPacket.RadioStatus.RadioOn; break; case 3: RadioStatus = WeatherPacket.RadioStatus.RadioActive; break; default: RadioStatus = WeatherPacket.RadioStatus.RadioOff; break; } } }
public PrecipEvent(WeatherPacket packet) { SerialNumber = packet.serial_number; HubSN = packet.hub_sn; Timestamp = WeatherPacket.FromUnixTimeSeconds(packet.evt[0]); }