Skip to content

Commit

Permalink
Merge pull request #101 from mcrossley/master
Browse files Browse the repository at this point in the history
v3.10.0 b3115
  • Loading branch information
mcrossley authored Feb 25, 2021
2 parents bddbb40 + 53c6da4 commit 76375b8
Show file tree
Hide file tree
Showing 34 changed files with 3,430 additions and 2,119 deletions.
8 changes: 4 additions & 4 deletions CumulusMX/AlarmSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ public string GetAlarmSettings()

var alarmUnits = new JsonAlarmUnits()
{
tempUnits = cumulus.TempUnitText,
pressUnits = cumulus.PressUnitText,
rainUnits = cumulus.RainUnitText,
windUnits = cumulus.WindUnitText
tempUnits = cumulus.Units.TempText,
pressUnits = cumulus.Units.PressText,
rainUnits = cumulus.Units.RainText,
windUnits = cumulus.Units.WindText
};

var data = new JsonAlarmSettingsData()
Expand Down
55 changes: 55 additions & 0 deletions CumulusMX/Api.cs
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ public EditController(IHttpContext context) : base(context)
[WebApiHandler(HttpVerbs.Get, RelativePath + "edit/*")]
public async Task<bool> GetEditData()
{
if (Station == null)
{
return await this.JsonResponseAsync("{}");
}

try
{
// read the last segment of the URL to determine what data the caller wants
Expand Down Expand Up @@ -129,6 +134,11 @@ public async Task<bool> GetEditData()
[WebApiHandler(HttpVerbs.Post, RelativePath + "edit/*")]
public async Task<bool> PostEditData()
{
if (Station == null)
{
return await this.JsonResponseAsync("{}");
}

try
{
// read the last segment of the URL to determine what data the caller wants
Expand Down Expand Up @@ -203,6 +213,11 @@ public DataController(IHttpContext context) : base(context)
[WebApiHandler(HttpVerbs.Get, RelativePath + "data/*")]
public async Task<bool> GetData()
{
if (Station == null)
{
return await this.JsonResponseAsync("{}");
}

try
{
// read the last segment of the URL to determine what data the caller wants
Expand Down Expand Up @@ -329,6 +344,11 @@ public GraphDataController(IHttpContext context) : base(context)
[WebApiHandler(HttpVerbs.Get, RelativePath + "graphdata/*")]
public async Task<bool> GetGraphData()
{
if (Station == null)
{
return await this.JsonResponseAsync("{}");
}

try
{
// read the last segment of the URL to determine what data the caller wants
Expand Down Expand Up @@ -403,6 +423,11 @@ public async Task<bool> SetGraphData()
[WebApiHandler(HttpVerbs.Get, RelativePath + "dailygraphdata/*")]
public async Task<bool> GetDailyGraphData()
{
if (Station == null)
{
return await this.JsonResponseAsync("{}");
}

try
{
// read the last segment of the URL to determine what data the caller wants
Expand Down Expand Up @@ -463,6 +488,11 @@ public RecordsController(IHttpContext context) : base(context)
[WebApiHandler(HttpVerbs.Get, RelativePath + "records/alltime/*")]
public async Task<bool> GetAlltimeData()
{
if (Station == null)
{
return await this.JsonResponseAsync("{}");
}

try
{
// read the last segment of the URL to determine what data the caller wants
Expand Down Expand Up @@ -493,6 +523,11 @@ public async Task<bool> GetAlltimeData()
[WebApiHandler(HttpVerbs.Get, RelativePath + "records/month/*")]
public async Task<bool> GetMonthlyRecordData()
{
if (Station == null)
{
return await this.JsonResponseAsync("{}");
}

try
{
// read the last segment of the URL to determine what data the caller wants
Expand Down Expand Up @@ -525,6 +560,11 @@ public async Task<bool> GetMonthlyRecordData()
[WebApiHandler(HttpVerbs.Get, RelativePath + "records/thismonth/*")]
public async Task<bool> GetThisMonthRecordData()
{
if (Station == null)
{
return await this.JsonResponseAsync("{}");
}

try
{
// read the last segment of the URL to determine what data the caller wants
Expand Down Expand Up @@ -555,6 +595,11 @@ public async Task<bool> GetThisMonthRecordData()
[WebApiHandler(HttpVerbs.Get, RelativePath + "records/thisyear/*")]
public async Task<bool> GetThisYearRecordData()
{
if (Station == null)
{
return await this.JsonResponseAsync("{}");
}

try
{
// read the last segment of the URL to determine what data the caller wants
Expand Down Expand Up @@ -604,6 +649,11 @@ public TodayYestDataController(IHttpContext context) : base(context) {}
[WebApiHandler(HttpVerbs.Get, RelativePath + "todayyest/*")]
public async Task<bool> GetYesterdayData()
{
if (Station == null)
{
return await this.JsonResponseAsync("{}");
}

try
{
// read the last segment of the URL to determine what data the caller wants
Expand Down Expand Up @@ -655,6 +705,11 @@ public ExtraDataController(IHttpContext context) : base(context) { }
[WebApiHandler(HttpVerbs.Get, RelativePath + "extra/*")]
public async Task<bool> GetExtraData()
{
if (Station == null)
{
return await this.JsonResponseAsync("{}");
}

try
{
// read the last segment of the URL to determine what data the caller wants
Expand Down
9 changes: 6 additions & 3 deletions CumulusMX/ApiTagProcessor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,17 +9,20 @@ public class ApiTagProcessor
{
private readonly Cumulus cumulus;
private readonly TokenParser tokenParser;
private readonly WebTags webtags;
private WebTags webtags;

internal ApiTagProcessor(Cumulus cumulus, WebTags webtags)
internal ApiTagProcessor(Cumulus cumulus)
{
this.cumulus = cumulus;
this.webtags = webtags;
tokenParser = new TokenParser();
tokenParser.OnToken += cumulus.TokenParserOnToken;
tokenParser.Encoding = new UTF8Encoding(false);
}

internal void SetWebTags(WebTags webtags)
{
this.webtags = webtags;
}

// Output the processed response as a JSON string
public string ProcessJson(string query)
Expand Down
4 changes: 1 addition & 3 deletions CumulusMX/AstroLib.cs
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,9 @@ private static double RadToDeg(double angle)
public static double SolarMax(DateTime timestamp, double longitude, double latitude, double altitude,
out double solarelevation, double transfactor, double turbidity, int method)
{
double az;

DateTime utctime = timestamp.ToUniversalTime();

CalculateSunPosition(utctime, latitude, longitude, out solarelevation, out az);
CalculateSunPosition(utctime, latitude, longitude, out solarelevation, out _);
var dEpoch = new DateTime(1990, 1, 1, 0, 0, 0);
double erv = CalcSunDistance(utctime, dEpoch);

Expand Down
96 changes: 51 additions & 45 deletions CumulusMX/CalibrationSettings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,9 @@ public string UpdateCalibrationConfig(IHttpContext context)
cumulus.Calib.WindSpeed.Mult = Convert.ToDouble(settings.multipliers.windspeed, invC);
cumulus.Calib.WindGust.Mult = Convert.ToDouble(settings.multipliers.windgust, invC);
cumulus.Calib.Temp.Mult = Convert.ToDouble(settings.multipliers.outdoortemp, invC);
cumulus.Calib.Temp.Mult2 = Convert.ToDouble(settings.multipliers.outdoortemp2, invC);
cumulus.Calib.Hum.Mult = Convert.ToDouble(settings.multipliers.humidity, invC);
cumulus.Calib.Hum.Mult2 = Convert.ToDouble(settings.multipliers.humidity2, invC);
cumulus.Calib.Rain.Mult = Convert.ToDouble(settings.multipliers.rainfall, invC);
cumulus.Calib.Solar.Mult = Convert.ToDouble(settings.multipliers.solar, invC);
cumulus.Calib.UV.Mult = Convert.ToDouble(settings.multipliers.uv, invC);
Expand Down Expand Up @@ -100,58 +102,60 @@ public string GetCalibrationAlpacaFormData()
{
//var InvC = new CultureInfo("");
var offsets = new JsonCalibrationSettingsOffsets()
{
pressure = cumulus.Calib.Press.Offset,
temperature = cumulus.Calib.Temp.Offset,
indoortemp = cumulus.Calib.InTemp.Offset,
humidity = (int)cumulus.Calib.Hum.Offset,
winddir = (int)cumulus.Calib.WindDir.Offset,
solar = cumulus.Calib.Solar.Offset,
uv = cumulus.Calib.UV.Offset,
wetbulb = cumulus.Calib.WetBulb.Offset
};
{
pressure = cumulus.Calib.Press.Offset,
temperature = cumulus.Calib.Temp.Offset,
indoortemp = cumulus.Calib.InTemp.Offset,
humidity = (int)cumulus.Calib.Hum.Offset,
winddir = (int)cumulus.Calib.WindDir.Offset,
solar = cumulus.Calib.Solar.Offset,
uv = cumulus.Calib.UV.Offset,
wetbulb = cumulus.Calib.WetBulb.Offset
};

var multipliers = new JsonCalibrationSettingsMultipliers()
{
pressure = cumulus.Calib.Press.Mult,
windspeed = cumulus.Calib.WindSpeed.Mult,
windgust = cumulus.Calib.WindGust.Mult,
humidity = cumulus.Calib.Hum.Mult,
outdoortemp = cumulus.Calib.Temp.Mult,
rainfall = cumulus.Calib.Rain.Mult,
solar = cumulus.Calib.Solar.Mult,
uv = cumulus.Calib.UV.Mult,
wetbulb = cumulus.Calib.WetBulb.Mult
};
{
pressure = cumulus.Calib.Press.Mult,
windspeed = cumulus.Calib.WindSpeed.Mult,
windgust = cumulus.Calib.WindGust.Mult,
humidity = cumulus.Calib.Hum.Mult,
humidity2 = cumulus.Calib.Hum.Mult2,
outdoortemp = cumulus.Calib.Temp.Mult,
outdoortemp2 = cumulus.Calib.Temp.Mult2,
rainfall = cumulus.Calib.Rain.Mult,
solar = cumulus.Calib.Solar.Mult,
uv = cumulus.Calib.UV.Mult,
wetbulb = cumulus.Calib.WetBulb.Mult
};

var spikeremoval = new JsonCalibrationSettingsSpikeRemoval()
{
humidity = cumulus.Spike.HumidityDiff,
windgust = cumulus.Spike.GustDiff,
windspeed = cumulus.Spike.WindDiff,
outdoortemp = cumulus.Spike.TempDiff,
maxhourlyrain = cumulus.Spike.MaxHourlyRain,
maxrainrate = cumulus.Spike.MaxRainRate,
pressure = cumulus.Spike.PressDiff
};
{
humidity = cumulus.Spike.HumidityDiff,
windgust = cumulus.Spike.GustDiff,
windspeed = cumulus.Spike.WindDiff,
outdoortemp = cumulus.Spike.TempDiff,
maxhourlyrain = cumulus.Spike.MaxHourlyRain,
maxrainrate = cumulus.Spike.MaxRainRate,
pressure = cumulus.Spike.PressDiff
};

var limits = new JsonCalibrationSettingsLimits()
{
temphigh = cumulus.Limit.TempHigh,
templow = cumulus.Limit.TempLow,
dewhigh = cumulus.Limit.DewHigh,
presshigh = cumulus.Limit.PressHigh,
presslow = cumulus.Limit.PressLow,
windhigh = cumulus.Limit.WindHigh
};

{
temphigh = cumulus.Limit.TempHigh,
templow = cumulus.Limit.TempLow,
dewhigh = cumulus.Limit.DewHigh,
presshigh = cumulus.Limit.PressHigh,
presslow = cumulus.Limit.PressLow,
windhigh = cumulus.Limit.WindHigh
};

var data = new JsonCalibrationSettingsData()
{
offsets = offsets,
multipliers = multipliers,
spikeremoval = spikeremoval,
limits = limits,
log = cumulus.ErrorLogSpikeRemoval
{
offsets = offsets,
multipliers = multipliers,
spikeremoval = spikeremoval,
limits = limits,
log = cumulus.ErrorLogSpikeRemoval
};

return data.ToJson();
Expand Down Expand Up @@ -203,7 +207,9 @@ public class JsonCalibrationSettingsMultipliers
public double windspeed { get; set; }
public double windgust { get; set; }
public double outdoortemp { get; set; }
public double outdoortemp2 { get; set; }
public double humidity { get; set; }
public double humidity2 { get; set; }
public double rainfall { get; set; }
public double solar { get; set; }
public double uv { get; set; }
Expand Down
Loading

0 comments on commit 76375b8

Please sign in to comment.