Skip to content

Commit

Permalink
Merge pull request #85 from mcrossley/master
Browse files Browse the repository at this point in the history
b3093
  • Loading branch information
mcrossley authored Aug 28, 2020
2 parents 93d26b1 + 714ac6e commit 5d25576
Show file tree
Hide file tree
Showing 9 changed files with 794 additions and 586 deletions.
30 changes: 19 additions & 11 deletions CumulusMX/Cumulus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ namespace CumulusMX
public class Cumulus
{
/////////////////////////////////
public string Version = "3.8.2";
public string Build = "3092";
public string Version = "3.8.3";
public string Build = "3093";
/////////////////////////////////

public static SemaphoreSlim syncInit = new SemaphoreSlim(1);
Expand Down Expand Up @@ -359,7 +359,9 @@ public struct TExtraFiles
public string TempFormat;

internal int WindDPlaces = 1;
internal int WindAvgDPlaces = 1;
public string WindFormat;
public string WindAvgFormat;

internal int HumDPlaces = 0;
public string HumFormat;
Expand Down Expand Up @@ -1202,6 +1204,7 @@ public Cumulus(int HTTPport, bool DebugEnabled, string startParms)

TempFormat = "F" + TempDPlaces;
WindFormat = "F" + WindDPlaces;
WindAvgFormat = "F" + WindAvgDPlaces;
RainFormat = "F" + RainDPlaces;
PressFormat = "F" + PressDPlaces;
HumFormat = "F" + HumDPlaces;
Expand Down Expand Up @@ -1935,7 +1938,7 @@ internal async void UpdateTwitter()
else
{
// default message
status.Append($"Wind {station.WindAverage.ToString(WindFormat)} {WindUnitText} {station.AvgBearingText}.");
status.Append($"Wind {station.WindAverage.ToString(WindAvgFormat)} {WindUnitText} {station.AvgBearingText}.");
status.Append($" Barometer {station.Pressure.ToString(PressFormat)} {PressUnitText}, {station.Presstrendstr}.");
status.Append($" Temperature {station.OutdoorTemperature.ToString(TempFormat)} {TempUnitText}.");
status.Append($" Rain today {station.RainToday.ToString(RainFormat)}{RainUnitText}.");
Expand Down Expand Up @@ -3401,6 +3404,11 @@ private void ReadIniFile()
RoundWindSpeed = ini.GetValue("Station", "RoundWindSpeed", false);

WindDPlaces = RoundWindSpeed ? 0 : WindDPlace[WindUnit];
WindAvgDPlaces = WindDPlaces;

// Wind speed decimals overrides - readonly
WindDPlaces = ini.GetValue("Station", "WindSpeedDecimals", WindDPlaces);
WindAvgDPlaces = ini.GetValue("Station", "WindSpeedAvgDecimals", WindAvgDPlaces);

TempDPlaces = TempDPlace[TempUnit];
PressDPlaces = PressDPlace[PressUnit];
Expand Down Expand Up @@ -5548,7 +5556,7 @@ public void DoLogFile(DateTime timestamp, bool live) // Writes an entry to the n
file.Write(station.OutdoorTemperature.ToString(TempFormat) + ListSeparator);
file.Write(station.OutdoorHumidity + ListSeparator);
file.Write(station.OutdoorDewpoint.ToString(TempFormat) + ListSeparator);
file.Write(station.WindAverage.ToString(WindFormat) + ListSeparator);
file.Write(station.WindAverage.ToString(WindAvgFormat) + ListSeparator);
file.Write(station.RecentMaxGust.ToString(WindFormat) + ListSeparator);
file.Write(station.AvgBearing + ListSeparator);
file.Write(station.RainRate.ToString(RainFormat) + ListSeparator);
Expand Down Expand Up @@ -5595,7 +5603,7 @@ public void DoLogFile(DateTime timestamp, bool live) // Writes an entry to the n
values.Append(station.OutdoorTemperature.ToString(TempFormat, InvC) + ",");
values.Append(station.OutdoorHumidity + ",");
values.Append(station.OutdoorDewpoint.ToString(TempFormat, InvC) + ",");
values.Append(station.WindAverage.ToString(WindFormat, InvC) + ",");
values.Append(station.WindAverage.ToString(WindAvgFormat, InvC) + ",");
values.Append(station.RecentMaxGust.ToString(WindFormat, InvC) + ",");
values.Append(station.AvgBearing + ",");
values.Append(station.RainRate.ToString(RainFormat, InvC) + ",");
Expand Down Expand Up @@ -7107,7 +7115,7 @@ 59 8.4 Feels Like temperature
file.Write(station.OutdoorTemperature.ToString(TempFormat, InvC) + ' '); // 3
file.Write(station.OutdoorHumidity.ToString() + ' '); // 4
file.Write(station.OutdoorDewpoint.ToString(TempFormat, InvC) + ' '); // 5
file.Write(station.WindAverage.ToString(WindFormat, InvC) + ' '); // 6
file.Write(station.WindAverage.ToString(WindAvgFormat, InvC) + ' '); // 6
file.Write(station.WindLatest.ToString(WindFormat, InvC) + ' '); // 7
file.Write(station.Bearing.ToString() + ' '); // 8
file.Write(station.RainRate.ToString(RainFormat, InvC) + ' '); // 9
Expand Down Expand Up @@ -7135,7 +7143,7 @@ 59 8.4 Feels Like temperature
file.Write(station.HighTempTodayTime.ToString("HH:mm ") ); // 28
file.Write(station.LowTempToday.ToString(TempFormat, InvC) + ' '); // 29
file.Write(station.LowTempTodayTime.ToString("HH:mm ")); // 30
file.Write(station.HighWindToday.ToString(WindFormat, InvC) + ' '); // 31
file.Write(station.HighWindToday.ToString(WindAvgFormat, InvC) + ' '); // 31
file.Write(station.HighWindTodayTime.ToString("HH:mm ")); // 32
file.Write(station.HighGustToday.ToString(WindFormat, InvC) + ' '); // 33
file.Write(station.HighGustTodayTime.ToString("HH:mm ")); // 34
Expand Down Expand Up @@ -7185,7 +7193,7 @@ 59 8.4 Feels Like temperature
values.Append(station.OutdoorTemperature.ToString(TempFormat, InvC) + ',');
values.Append(station.OutdoorHumidity.ToString() + ',');
values.Append(station.OutdoorDewpoint.ToString(TempFormat, InvC) + ',');
values.Append(station.WindAverage.ToString(WindFormat, InvC) + ',');
values.Append(station.WindAverage.ToString(WindAvgFormat, InvC) + ',');
values.Append(station.WindLatest.ToString(WindFormat, InvC) + ',');
values.Append(station.Bearing.ToString() + ',');
values.Append(station.RainRate.ToString(RainFormat, InvC) + ',');
Expand All @@ -7210,7 +7218,7 @@ 59 8.4 Feels Like temperature
values.Append(station.HighTempTodayTime.ToString("HH:mm") + "',");
values.Append(station.LowTempToday.ToString(TempFormat, InvC) + ",'");
values.Append(station.LowTempTodayTime.ToString("HH:mm") + "',");
values.Append(station.HighWindToday.ToString(WindFormat, InvC) + ",'");
values.Append(station.HighWindToday.ToString(WindAvgFormat, InvC) + ",'");
values.Append(station.HighWindTodayTime.ToString("HH:mm") + "',");
values.Append(station.HighGustToday.ToString(WindFormat, InvC) + ",'");
values.Append(station.HighGustTodayTime.ToString("HH:mm") + "',");
Expand Down Expand Up @@ -8180,7 +8188,7 @@ public void SetMonthlySqlCreateString()
strb.Append("Temp decimal(4," + TempDPlaces + ") NOT NULL,");
strb.Append("Humidity decimal(4," + HumDPlaces + ") NOT NULL,");
strb.Append("Dewpoint decimal(4," + TempDPlaces + ") NOT NULL,");
strb.Append("Windspeed decimal(4," + WindDPlaces + ") NOT NULL,");
strb.Append("Windspeed decimal(4," + WindAvgDPlaces + ") NOT NULL,");
strb.Append("Windgust decimal(4," + WindDPlaces + ") NOT NULL,");
strb.Append("Windbearing VARCHAR(3) NOT NULL,");
strb.Append("RainRate decimal(4," + RainDPlaces + ") NOT NULL,");
Expand Down Expand Up @@ -8229,7 +8237,7 @@ internal void SetDayfileSqlCreateString()
strb.Append("TMaxRR varchar(5) NOT NULL,TotRainFall decimal(6," + RainDPlaces + ") NOT NULL,");
strb.Append("AvgTemp decimal(4," + TempDPlaces + ") NOT NULL,");
strb.Append("TotWindRun decimal(5," + WindRunDPlaces +") NOT NULL,");
strb.Append("HighAvgWSpeed decimal(3," + WindDPlaces + "),");
strb.Append("HighAvgWSpeed decimal(3," + WindAvgDPlaces + "),");
strb.Append("THAvgWSpeed varchar(5),LowHum decimal(4," + HumDPlaces + "),");
strb.Append("TLowHum varchar(5),");
strb.Append("HighHum decimal(4," + HumDPlaces + "),");
Expand Down
16 changes: 8 additions & 8 deletions CumulusMX/DataEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ internal string GetAllTimeRecData()
json.Append($"\"lowBarometerTime\":\"{station.alltimerecarray[WeatherStation.AT_LowPress].timestamp.ToString(timeStampFormat)}\",");
// Records - Wind values
json.Append($"\"highGustVal\":\"{station.alltimerecarray[WeatherStation.AT_HighGust].value.ToString(cumulus.WindFormat)}\",");
json.Append($"\"highWindVal\":\"{station.alltimerecarray[WeatherStation.AT_HighWind].value.ToString(cumulus.WindFormat)}\",");
json.Append($"\"highWindVal\":\"{station.alltimerecarray[WeatherStation.AT_HighWind].value.ToString(cumulus.WindAvgFormat)}\",");
json.Append($"\"highWindRunVal\":\"{station.alltimerecarray[WeatherStation.AT_HighWindrun].value.ToString(cumulus.WindRunFormat)}\",");
// Records - Wind times
json.Append($"\"highGustTime\":\"{station.alltimerecarray[WeatherStation.AT_HighGust].timestamp.ToString(timeStampFormat)}\",");
Expand Down Expand Up @@ -617,7 +617,7 @@ internal string GetRecordsDayFile(string recordType)
json.Append($"\"lowBarometerTimeDayfile\":\"{lowBaroTime.ToString(timeStampFormat)}\",");
json.Append($"\"highGustValDayfile\":\"{highGustVal.ToString(cumulus.WindFormat)}\",");
json.Append($"\"highGustTimeDayfile\":\"{highGustTime.ToString(timeStampFormat)}\",");
json.Append($"\"highWindValDayfile\":\"{highWindVal.ToString(cumulus.WindFormat)}\",");
json.Append($"\"highWindValDayfile\":\"{highWindVal.ToString(cumulus.WindAvgFormat)}\",");
json.Append($"\"highWindTimeDayfile\":\"{highWindTime.ToString(timeStampFormat)}\",");
json.Append($"\"highWindRunValDayfile\":\"{highWindRunVal.ToString(cumulus.WindRunFormat)}\",");
json.Append($"\"highWindRunTimeDayfile\":\"{highWindRunTime.ToString(dateStampFormat)}\",");
Expand Down Expand Up @@ -1124,7 +1124,7 @@ internal string GetRecordsLogFile(string recordType)
json.Append($"\"lowBarometerTimeLogfile\":\"{lowBaroTime.ToString(timeStampFormat)}\",");
json.Append($"\"highGustValLogfile\":\"{highGustVal.ToString(cumulus.WindFormat)}\",");
json.Append($"\"highGustTimeLogfile\":\"{highGustTime.ToString(timeStampFormat)}\",");
json.Append($"\"highWindValLogfile\":\"{highWindVal.ToString(cumulus.WindFormat)}\",");
json.Append($"\"highWindValLogfile\":\"{highWindVal.ToString(cumulus.WindAvgFormat)}\",");
json.Append($"\"highWindTimeLogfile\":\"{highWindTime.ToString(timeStampFormat)}\",");
json.Append($"\"highWindRunValLogfile\":\"{highWindRunVal.ToString(cumulus.WindRunFormat)}\",");
json.Append($"\"highWindRunTimeLogfile\":\"{highWindRunTime.ToString(dateStampFormat)}\",");
Expand Down Expand Up @@ -1663,7 +1663,7 @@ internal string GetMonthlyRecData()
json.Append($"\"{m}-lowBarometerTime\":\"{station.monthlyrecarray[WeatherStation.AT_LowPress, m].timestamp.ToString(timeStampFormat)}\",");
// Records - Wind values
json.Append($"\"{m}-highGustVal\":\"{station.monthlyrecarray[WeatherStation.AT_HighGust, m].value.ToString(cumulus.WindFormat)}\",");
json.Append($"\"{m}-highWindVal\":\"{station.monthlyrecarray[WeatherStation.AT_HighWind, m].value.ToString(cumulus.WindFormat)}\",");
json.Append($"\"{m}-highWindVal\":\"{station.monthlyrecarray[WeatherStation.AT_HighWind, m].value.ToString(cumulus.WindAvgFormat)}\",");
json.Append($"\"{m}-highWindRunVal\":\"{station.monthlyrecarray[WeatherStation.AT_HighWindrun, m].value.ToString(cumulus.WindRunFormat)}\",");
// Records - Wind times
json.Append($"\"{m}-highGustTime\":\"{station.monthlyrecarray[WeatherStation.AT_HighGust, m].timestamp.ToString(timeStampFormat)}\",");
Expand Down Expand Up @@ -2088,7 +2088,7 @@ internal string GetMonthlyRecDayFile()
json.Append($"\"{m}-lowBarometerTimeDayfile\":\"{lowBaroTime[i].ToString(timeStampFormat)}\",");
json.Append($"\"{m}-highGustValDayfile\":\"{highGustVal[i].ToString(cumulus.WindFormat)}\",");
json.Append($"\"{m}-highGustTimeDayfile\":\"{highGustTime[i].ToString(timeStampFormat)}\",");
json.Append($"\"{m}-highWindValDayfile\":\"{highWindVal[i].ToString(cumulus.WindFormat)}\",");
json.Append($"\"{m}-highWindValDayfile\":\"{highWindVal[i].ToString(cumulus.WindAvgFormat)}\",");
json.Append($"\"{m}-highWindTimeDayfile\":\"{highWindTime[i].ToString(timeStampFormat)}\",");
json.Append($"\"{m}-highWindRunValDayfile\":\"{highWindRunVal[i].ToString(cumulus.WindRunFormat)}\",");
json.Append($"\"{m}-highWindRunTimeDayfile\":\"{highWindRunTime[i].ToString(dateStampFormat)}\",");
Expand Down Expand Up @@ -2592,7 +2592,7 @@ internal string GetMonthlyRecLogFile()
json.Append($"\"{m}-lowBarometerTimeLogfile\":\"{lowBaroTime[i].ToString(timeStampFormat)}\",");
json.Append($"\"{m}-highGustValLogfile\":\"{highGustVal[i].ToString(cumulus.WindFormat)}\",");
json.Append($"\"{m}-highGustTimeLogfile\":\"{highGustTime[i].ToString(timeStampFormat)}\",");
json.Append($"\"{m}-highWindValLogfile\":\"{highWindVal[i].ToString(cumulus.WindFormat)}\",");
json.Append($"\"{m}-highWindValLogfile\":\"{highWindVal[i].ToString(cumulus.WindAvgFormat)}\",");
json.Append($"\"{m}-highWindTimeLogfile\":\"{highWindTime[i].ToString(timeStampFormat)}\",");
json.Append($"\"{m}-highWindRunValLogfile\":\"{highWindRunVal[i].ToString(cumulus.WindRunFormat)}\",");
json.Append($"\"{m}-highWindRunTimeLogfile\":\"{highWindRunTime[i].ToString(dateStampFormat)}\",");
Expand Down Expand Up @@ -2670,7 +2670,7 @@ internal string GetThisMonthRecData()
// Records - Wind
json.Append($"\"highGustVal\":\"{station.HighGustThisMonth.ToString(cumulus.WindFormat)}\",");
json.Append($"\"highGustTime\":\"{station.HighGustThisMonthTS.ToString(timeStampFormat)}\",");
json.Append($"\"highWindVal\":\"{station.HighWindThisMonth.ToString(cumulus.WindFormat)}\",");
json.Append($"\"highWindVal\":\"{station.HighWindThisMonth.ToString(cumulus.WindAvgFormat)}\",");
json.Append($"\"highWindTime\":\"{station.HighWindThisMonthTS.ToString(timeStampFormat)}\",");
json.Append($"\"highWindRunVal\":\"{station.HighDailyWindrunThisMonth.ToString(cumulus.WindRunFormat)}\",");
json.Append($"\"highWindRunTime\":\"{station.HighDailyWindrunThisMonthTS.ToString(dateStampFormat)}\",");
Expand Down Expand Up @@ -2954,7 +2954,7 @@ internal string GetThisYearRecData()
// Records - Wind
json.Append($"\"highGustVal\":\"{station.HighGustThisYear.ToString(cumulus.WindFormat)}\",");
json.Append($"\"highGustTime\":\"{station.HighGustThisYearTS.ToString(timeStampFormat)}\",");
json.Append($"\"highWindVal\":\"{station.HighWindThisYear.ToString(cumulus.WindFormat)}\",");
json.Append($"\"highWindVal\":\"{station.HighWindThisYear.ToString(cumulus.WindAvgFormat)}\",");
json.Append($"\"highWindTime\":\"{station.HighWindThisYearTS.ToString(timeStampFormat)}\",");
json.Append($"\"highWindRunVal\":\"{station.HighDailyWindrunThisYear.ToString(cumulus.WindRunFormat)}\",");
json.Append($"\"highWindRunTime\":\"{station.HighDailyWindrunThisYearTS.ToString(dateStampFormat)}\",");
Expand Down
4 changes: 2 additions & 2 deletions CumulusMX/DataStruct.cs
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ public string HighTempTodayRounded
[DataMember(Name="HighWindToday")]
public string HighWindTodayRounded
{
get { return HighWindToday.ToString(cumulus.WindFormat); }
get { return HighWindToday.ToString(cumulus.WindAvgFormat); }
set { }
}

Expand Down Expand Up @@ -503,7 +503,7 @@ public String WindLatestRounded
[DataMember(Name = "WindAverage")]
public String WindAverageRounded
{
get { return WindAverage.ToString(cumulus.WindFormat); }
get { return WindAverage.ToString(cumulus.WindAvgFormat); }
set { }
}

Expand Down
Loading

0 comments on commit 5d25576

Please sign in to comment.