Skip to content

Commit

Permalink
[AB#44] Filter exporting metrics by interval minutes.
Browse files Browse the repository at this point in the history
  • Loading branch information
Shuai Zhang committed Dec 20, 2019
1 parent 5e0c220 commit ddd0735
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -612,3 +612,4 @@ $RECYCLE.BIN/
!/dev-support/bin
/.ionide
/output
*.tmp
Original file line number Diff line number Diff line change
Expand Up @@ -170,16 +170,30 @@ await sw
+ "环境温度(摄氏度),出水压力(米),回水压力(米),"
+ "加热器功率(千瓦),水泵流量(立方米/小时)")
.ConfigureAwait(true);

var metricInterval = TimeSpan.FromMinutes(this.IntervalMinutes);
DateTimeOffset lastKnownMetricCreateTime = DateTimeOffset.MinValue;
foreach (Metric m in metrics)
{
DateTimeOffset createTimeThreshold = lastKnownMetricCreateTime
.AddSeconds(metricInterval.TotalSeconds * 0.9);

var createTime = m.CreateTime.ToDateTimeOffset();
if (createTime < createTimeThreshold)
{
continue;
}

await sw
.WriteLineAsync(
$"{m.CreateTime.ToDateTimeOffset().ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture)},"
$"{createTime.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss", CultureInfo.InvariantCulture)},"
+ $"{m.OutputWaterCelsiusDegree:F2},{m.InputWaterCelsiusDegree:F2},"
+ $"{m.HeaterOutputWaterCelsiusDegree:F2},{m.EnvironmentCelsiusDegree:F2},"
+ $"{m.OutputWaterPressureMeter:F2},{m.InputWaterPressureMeter:F2},"
+ $"{m.HeaterPowerKilowatt:F2},{m.WaterPumpFlowRateCubicMeterPerHour:F2}")
.ConfigureAwait(true);

lastKnownMetricCreateTime = createTime;
}
}
}
Expand Down

0 comments on commit ddd0735

Please sign in to comment.