Skip to content

Commit

Permalink
Merge pull request #34 from mcrossley/master
Browse files Browse the repository at this point in the history
b3055 - ver 3.1.2
  • Loading branch information
mcrossley authored Nov 4, 2019
2 parents 9b55a35 + 6d49bdc commit db582f2
Show file tree
Hide file tree
Showing 7 changed files with 131 additions and 119 deletions.
4 changes: 2 additions & 2 deletions CumulusMX/Cumulus.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@ namespace CumulusMX
public class Cumulus
{
/////////////////////////////////
public string Version = "3.1.1";
public string Build = "3054";
public string Version = "3.1.2";
public string Build = "3055";
/////////////////////////////////

private static string appGuid = "57190d2e-7e45-4efb-8c09-06a176cef3f3";
Expand Down
4 changes: 2 additions & 2 deletions CumulusMX/CumulusMX.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@
<UpdatePeriodically>false</UpdatePeriodically>
<UpdateRequired>false</UpdateRequired>
<MapFileExtensions>true</MapFileExtensions>
<ApplicationRevision>3054</ApplicationRevision>
<ApplicationVersion>3.1.1.3054</ApplicationVersion>
<ApplicationRevision>3055</ApplicationRevision>
<ApplicationVersion>3.1.2.3055</ApplicationVersion>
<UseApplicationTrust>false</UseApplicationTrust>
<PublishWizardCompleted>true</PublishWizardCompleted>
<BootstrapperEnabled>true</BootstrapperEnabled>
Expand Down
216 changes: 109 additions & 107 deletions CumulusMX/DataEditor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -548,6 +548,7 @@ internal string GetAllTimeRecDayFile()

return json;
}

internal string GetAllTimeRecLogFile()
{
var timeStampFormat = "dd/MM/yy HH:mm";
Expand Down Expand Up @@ -639,6 +640,9 @@ internal string GetAllTimeRecLogFile()
Double rainMidnight = 0;
Double totalRainfall = 0;

Double outsidetemp, dewpoint, speed, gust, rainrate, raintoday, pressure, chill, heat, apptemp;
int hum;

var watch = System.Diagnostics.Stopwatch.StartNew();

while (!finished)
Expand All @@ -647,6 +651,7 @@ internal string GetAllTimeRecLogFile()

if (File.Exists(logFile))
{
cumulus.LogDebugMessage($"GetAllTimeRecLogFile: Processing log file - {logFile}");
int linenum = 0;
try
{
Expand All @@ -656,9 +661,11 @@ internal string GetAllTimeRecLogFile()
{
// process each record in the file
linenum++;
var st = new List<string>(Regex.Split(line, CultureInfo.CurrentCulture.TextInfo.ListSeparator));
//var st = new List<string>(Regex.Split(line, CultureInfo.CurrentCulture.TextInfo.ListSeparator));
// Regex is very expensive, let's assume the separator is always a single character
var st = new List<string>(line.Split((CultureInfo.CurrentCulture.TextInfo.ListSeparator)[0]));
entrydate = station.ddmmyyhhmmStrToDate(st[0], st[1]);
// TODO: We need to work in meto dates not clock dates for hi/lows
// We need to work in meto dates not clock dates for day hi/lows
metoDate = entrydate.AddHours(cumulus.GetHourInc());

if (!started)
Expand All @@ -668,30 +675,51 @@ internal string GetAllTimeRecLogFile()
started = true;
}

var outsidetemp = Convert.ToDouble(st[2]);
var hum = Convert.ToInt32(st[3]);
var dewpoint = Convert.ToDouble(st[4]);
var speed = Convert.ToDouble(st[5]);
var gust = Convert.ToDouble(st[6]);
var rainrate = Convert.ToDouble(st[8]);
var raintoday = Convert.ToDouble(st[9]);
var pressure = Convert.ToDouble(st[10]);
var chill = 999.0;
outsidetemp = Convert.ToDouble(st[2]);
hum = Convert.ToInt32(st[3]);
dewpoint = Convert.ToDouble(st[4]);
speed = Convert.ToDouble(st[5]);
gust = Convert.ToDouble(st[6]);
rainrate = Convert.ToDouble(st[8]);
raintoday = Convert.ToDouble(st[9]);
pressure = Convert.ToDouble(st[10]);
if (st.Count >= 16)
{
chill = Convert.ToDouble(st[15]);
// low chill
if (chill < lowWindChillVal)
{
lowWindChillVal = chill;
lowWindChillTime = entrydate;
}

}
var heat = -999.0;
if (st.Count >= 17)
{
heat = Convert.ToDouble(st[16]);
// hi heat
if (heat > highHeatIndVal)
{
highHeatIndVal = heat;
highHeatIndTime = entrydate;
}
}
double apptemp = -999.0;
if (st.Count >= 22)
{
apptemp = Convert.ToDouble(st[21]);
// hi appt
if (apptemp > highAppTempVal)
{
highAppTempVal = apptemp;
highAppTempTime = entrydate;
}
// lo appt
if (apptemp < lowAppTempVal)
{
lowAppTempVal = apptemp;
lowAppTempTime = entrydate;
}
}

// hi temp
if (outsidetemp > highTempVal)
{
Expand All @@ -716,33 +744,69 @@ internal string GetAllTimeRecLogFile()
lowDewPtVal = dewpoint;
lowDewPtTime = entrydate;
}
if (apptemp > -999)
// hi hum
if (hum > highHumVal)
{
// hi appt
if (apptemp > highAppTempVal)
{
highAppTempVal = apptemp;
highAppTempTime = entrydate;
}
// lo appt
if (apptemp < lowAppTempVal)
{
lowAppTempVal = apptemp;
lowAppTempTime = entrydate;
}
highHumVal = hum;
highHumTime = entrydate;
}
// low chill
if (chill < lowWindChillVal)
// lo hum
if (hum < lowHumVal)
{
lowWindChillVal = chill;
lowWindChillTime = entrydate;
lowHumVal = hum;
lowHumTime = entrydate;
}
// hi heat
if (heat > highHeatIndVal)
// hi baro
if (pressure > highBaroVal)
{
highBaroVal = pressure;
highBaroTime = entrydate;
}
// lo hum
if (pressure < lowBaroVal)
{
lowBaroVal = pressure;
lowBaroTime = entrydate;
}
// hi gust
if (gust > highGustVal)
{
highHeatIndVal = heat;
highHeatIndTime = entrydate;
highGustVal = gust;
highGustTime = entrydate;
}
// hi wind
if (speed > highWindVal)
{
highWindVal = speed;
highWindTime = entrydate;
}
// hi rain rate
if (rainrate > highRainRateVal)
{
highRainRateVal = rainrate;
highRainRateTime = entrydate;
}
// hourly rain
/*
* need to track what the rainfall has been in the last rolling hour
* across day rollovers where the count resets
*/
AddLastHourRainEntry(entrydate, totalRainfall + raintoday);
RemoveOldRainData(entrydate);

var rainThisHour = HourRainLog.First().raincounter - HourRainLog.Last().raincounter;
if (rainThisHour > highRainHourVal)
{
highRainHourVal = rainThisHour;
highRainHourTime = entrydate;
}

if (monthlyRain > highRainMonthVal)
{
highRainMonthVal = monthlyRain;
highRainMonthTime = entrydate;
}

// same meto day
if (currentDay.Day == metoDate.Day && currentDay.Month == metoDate.Month && currentDay.Year == metoDate.Year)
{
Expand All @@ -752,8 +816,10 @@ internal string GetAllTimeRecLogFile()
if (outsidetemp < dayLowTemp)
dayLowTemp = outsidetemp;

if (dayRain < raintoday)
dayRain = raintoday;

dayWindRun += entrydate.Subtract(lastentrydate).TotalHours * speed;
dayRain = raintoday;
}
else // new meto day
{
Expand Down Expand Up @@ -836,95 +902,33 @@ internal string GetAllTimeRecLogFile()
dayRain = 0;
totalRainfall += raintoday;
}
// hi hum
if (hum > highHumVal)
{
highHumVal = hum;
highHumTime = entrydate;
}
// lo hum
if (hum < lowHumVal)
{
lowHumVal = hum;
lowHumTime = entrydate;
}
// hi baro
if (pressure > highBaroVal)
{
highBaroVal = pressure;
highBaroTime = entrydate;
}
// lo hum
if (pressure < lowBaroVal)
{
lowBaroVal = pressure;
lowBaroTime = entrydate;
}
// hi gust
if (gust > highGustVal)
{
highGustVal = gust;
highGustTime = entrydate;
}
// hi wind
if (speed > highWindVal)
{
highWindVal = speed;
highWindTime = entrydate;
}
// hi rain rate
if (rainrate > highRainRateVal)
{
highRainRateVal = rainrate;
highRainRateTime = entrydate;
}
// hourly rain
/*
* need to track what the rainfall has been in the last rolling hour
* across day rollovers where the count resets
*/
AddLastHourRainEntry(entrydate, totalRainfall + raintoday);
RemoveOldRainData(entrydate);

var rainThisHour = HourRainLog.First().raincounter - HourRainLog.Last().raincounter;
if (rainThisHour > highRainHourVal)
{
highRainHourVal = rainThisHour;
highRainHourTime = entrydate;
}

monthlyRain += dayRain;
if (monthlyRain > highRainMonthVal)
{
highRainMonthVal = monthlyRain;
highRainMonthTime = entrydate;
}

lastentrydate = entrydate;
lastRainMidnight = rainMidnight;
}
}
catch (Exception e)
{
cumulus.LogMessage("Error at line " + linenum + " of " + logFile + " : " + e.Message);
cumulus.LogMessage($"Error at line {linenum} of {logFile} : {e.Message}");
cumulus.LogMessage("Please edit the file to correct the error");
}
}
if (entrydate >= dateto || filedate > dateto.AddMonths(1))
else
{
cumulus.LogDebugMessage($"GetAllTimeRecLogFile: Log file not found - {logFile}");
}
if (filedate.Year >= dateto.Year && filedate.Month >= dateto.Month)
{
finished = true;
cumulus.LogDebugMessage("GetAllTimeRecLogFile: Finished processing the log files");
}
else
{
filedate = filedate.AddMonths(1);
logFile = cumulus.GetLogFileName(filedate);
}

}

// convert Hourly rain counter to user units.
//highRainDayVal *= cumulus.RainMult ;

json += "\"highTempValLogfile\":\"" + highTempVal.ToString(cumulus.TempFormat) + "\",";
json += "\"highTempTimeLogfile\":\"" + highTempTime.ToString(timeStampFormat) + "\",";
json += "\"lowTempValLogfile\":\"" + lowTempVal.ToString(cumulus.TempFormat) + "\",";
Expand Down Expand Up @@ -967,8 +971,6 @@ internal string GetAllTimeRecLogFile()
json += "\"highRainRateTimeLogfile\":\"" + highRainRateTime.ToString(timeStampFormat) + "\",";
json += "\"highHourlyRainValLogfile\":\"" + highRainHourVal.ToString(cumulus.RainFormat) + "\",";
json += "\"highHourlyRainTimeLogfile\":\"" + highRainHourTime.ToString(timeStampFormat) + "\",";
//json += "\"highHourlyRainValLogfile\":\"n/a\",";
//json += "\"highHourlyRainTimeLogfile\":\"n/a\",";
json += "\"highDailyRainValLogfile\":\"" + highRainDayVal.ToString(cumulus.RainFormat) + "\",";
json += "\"highDailyRainTimeLogfile\":\"" + highRainDayTime.ToString(dateStampFormat) + "\",";
json += "\"highMonthlyRainValLogfile\":\"" + highRainMonthVal.ToString(cumulus.RainFormat) + "\",";
Expand Down
2 changes: 1 addition & 1 deletion CumulusMX/DavisStation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ internal class DavisStation : WeatherStation
private int previousMinuteSetClock = 60;
private const string newline = "\n";
private DateTime lastRecepStatsTime;
private int commWaitTimeMs = 1000;
private const int commWaitTimeMs = 1000;
private int MaxArchiveRuns = 2;

private TcpClient socket;
Expand Down
6 changes: 3 additions & 3 deletions CumulusMX/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("CumulusMX")]
[assembly: AssemblyDescription("Build 3054")]
[assembly: AssemblyDescription("Build 3055")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("")]
[assembly: AssemblyProduct("CumulusMX")]
Expand All @@ -32,5 +32,5 @@
// You can specify all the values or you can default the Build and Revision Numbers
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]
[assembly: AssemblyVersion("3.1.1.3054")]
[assembly: AssemblyFileVersion("3.1.1.3054")]
[assembly: AssemblyVersion("3.1.2.3055")]
[assembly: AssemblyFileVersion("3.1.2.3055")]
4 changes: 2 additions & 2 deletions CumulusMX/WeatherStation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6308,13 +6308,13 @@ public void DoET(double value, DateTime timestamp)
if (Math.Round(value, 3) < Math.Round(StartofdayET,3)) // change b3046
{
// ET reset
cumulus.LogMessage(String.Format("*** ET Reset *** AnnualET: {0:0.000}, StartofdayET: {0:0.000}, StationET: {0:0.000}, CurrentET: {0:0.000}", AnnualETTotal, StartofdayET, value, ET));
cumulus.LogMessage(String.Format("*** ET Reset *** AnnualET: {0:0.000}, StartofdayET: {1:0.000}, StationET: {2:0.000}, CurrentET: {3:0.000}", AnnualETTotal, StartofdayET, value, ET));
AnnualETTotal = value; // add b3046
// set the start of day figure so it reflects the ET
// so far today
StartofdayET = AnnualETTotal - ET;
WriteTodayFile(timestamp, false);
cumulus.LogMessage(String.Format("New ET values. AnnualET: {0:0.000}, StartofdayET: {0:0.000}, StationET: {0:0.000}, CurrentET: {0:0.000}", AnnualETTotal, StartofdayET, value, ET));
cumulus.LogMessage(String.Format("New ET values. AnnualET: {0:0.000}, StartofdayET: {1:0.000}, StationET: {2:0.000}, CurrentET: {3:0.000}", AnnualETTotal, StartofdayET, value, ET));
}
else
{
Expand Down
Loading

0 comments on commit db582f2

Please sign in to comment.