-
Notifications
You must be signed in to change notification settings - Fork 23
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #112 from mcrossley/master
v3.11.2
- Loading branch information
Showing
18 changed files
with
32,173 additions
and
31,792 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,63 +1,63 @@ | ||
############################################################################### | ||
# Set default behavior to automatically normalize line endings. | ||
############################################################################### | ||
* text=auto | ||
|
||
############################################################################### | ||
# Set default behavior for command prompt diff. | ||
# | ||
# This is need for earlier builds of msysgit that does not have it on by | ||
# default for csharp files. | ||
# Note: This is only used by command line | ||
############################################################################### | ||
#*.cs diff=csharp | ||
|
||
############################################################################### | ||
# Set the merge driver for project and solution files | ||
# | ||
# Merging from the command prompt will add diff markers to the files if there | ||
# are conflicts (Merging from VS is not affected by the settings below, in VS | ||
# the diff markers are never inserted). Diff markers may cause the following | ||
# file extensions to fail to load in VS. An alternative would be to treat | ||
# these files as binary and thus will always conflict and require user | ||
# intervention with every merge. To do so, just uncomment the entries below | ||
############################################################################### | ||
#*.sln merge=binary | ||
#*.csproj merge=binary | ||
#*.vbproj merge=binary | ||
#*.vcxproj merge=binary | ||
#*.vcproj merge=binary | ||
#*.dbproj merge=binary | ||
#*.fsproj merge=binary | ||
#*.lsproj merge=binary | ||
#*.wixproj merge=binary | ||
#*.modelproj merge=binary | ||
#*.sqlproj merge=binary | ||
#*.wwaproj merge=binary | ||
|
||
############################################################################### | ||
# behavior for image files | ||
# | ||
# image files are treated as binary by default. | ||
############################################################################### | ||
#*.jpg binary | ||
#*.png binary | ||
#*.gif binary | ||
|
||
############################################################################### | ||
# diff behavior for common document formats | ||
# | ||
# Convert binary document formats to text before diffing them. This feature | ||
# is only available from the command line. Turn it on by uncommenting the | ||
# entries below. | ||
############################################################################### | ||
#*.doc diff=astextplain | ||
#*.DOC diff=astextplain | ||
#*.docx diff=astextplain | ||
#*.DOCX diff=astextplain | ||
#*.dot diff=astextplain | ||
#*.DOT diff=astextplain | ||
#*.pdf diff=astextplain | ||
#*.PDF diff=astextplain | ||
#*.rtf diff=astextplain | ||
#*.RTF diff=astextplain | ||
############################################################################### | ||
# Set default behavior to automatically normalize line endings. | ||
############################################################################### | ||
#* text=auto | ||
|
||
############################################################################### | ||
# Set default behavior for command prompt diff. | ||
# | ||
# This is need for earlier builds of msysgit that does not have it on by | ||
# default for csharp files. | ||
# Note: This is only used by command line | ||
############################################################################### | ||
#*.cs diff=csharp | ||
|
||
############################################################################### | ||
# Set the merge driver for project and solution files | ||
# | ||
# Merging from the command prompt will add diff markers to the files if there | ||
# are conflicts (Merging from VS is not affected by the settings below, in VS | ||
# the diff markers are never inserted). Diff markers may cause the following | ||
# file extensions to fail to load in VS. An alternative would be to treat | ||
# these files as binary and thus will always conflict and require user | ||
# intervention with every merge. To do so, just uncomment the entries below | ||
############################################################################### | ||
#*.sln merge=binary | ||
#*.csproj merge=binary | ||
#*.vbproj merge=binary | ||
#*.vcxproj merge=binary | ||
#*.vcproj merge=binary | ||
#*.dbproj merge=binary | ||
#*.fsproj merge=binary | ||
#*.lsproj merge=binary | ||
#*.wixproj merge=binary | ||
#*.modelproj merge=binary | ||
#*.sqlproj merge=binary | ||
#*.wwaproj merge=binary | ||
|
||
############################################################################### | ||
# behavior for image files | ||
# | ||
# image files are treated as binary by default. | ||
############################################################################### | ||
#*.jpg binary | ||
#*.png binary | ||
#*.gif binary | ||
|
||
############################################################################### | ||
# diff behavior for common document formats | ||
# | ||
# Convert binary document formats to text before diffing them. This feature | ||
# is only available from the command line. Turn it on by uncommenting the | ||
# entries below. | ||
############################################################################### | ||
#*.doc diff=astextplain | ||
#*.DOC diff=astextplain | ||
#*.docx diff=astextplain | ||
#*.DOCX diff=astextplain | ||
#*.dot diff=astextplain | ||
#*.DOT diff=astextplain | ||
#*.pdf diff=astextplain | ||
#*.PDF diff=astextplain | ||
#*.rtf diff=astextplain | ||
#*.RTF diff=astextplain |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,173 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace CumulusMX | ||
{ | ||
public class Alarm | ||
{ | ||
public Cumulus cumulus { get; set; } | ||
|
||
public bool Enabled { get; set; } | ||
public double Value { get; set; } | ||
public bool Sound { get; set; } | ||
public string SoundFile { get; set; } | ||
|
||
bool triggered; | ||
public bool Triggered | ||
{ | ||
get => triggered; | ||
set | ||
{ | ||
if (value) | ||
{ | ||
triggerCount++; | ||
TriggeredTime = DateTime.Now; | ||
|
||
// do we have a threshold value | ||
if (triggerCount >= TriggerThreshold) | ||
{ | ||
// If we were not set before, so we need to send an email? | ||
if (!triggered && Enabled && Email && cumulus.SmtpOptions.Enabled) | ||
{ | ||
// Construct the message - preamble, plus values | ||
var msg = cumulus.AlarmEmailPreamble + "\r\n" + string.Format(EmailMsg, Value, Units); | ||
if (!string.IsNullOrEmpty(LastError)) | ||
{ | ||
msg += "\r\nLast error: " + LastError; | ||
} | ||
cumulus.emailer.SendEmail(cumulus.AlarmDestEmail, cumulus.AlarmFromEmail, cumulus.AlarmEmailSubject, msg, cumulus.AlarmEmailHtml); | ||
} | ||
|
||
// If we get a new trigger, record the time | ||
triggered = true; | ||
} | ||
} | ||
else | ||
{ | ||
// If the trigger is cleared, check if we should be latching the value | ||
if (Latch) | ||
{ | ||
if (DateTime.Now > TriggeredTime.AddHours(LatchHours)) | ||
{ | ||
// We are latching, but the latch period has expired, clear the trigger | ||
triggered = false; | ||
triggerCount = 0; | ||
} | ||
} | ||
else | ||
{ | ||
// No latch, just clear the trigger | ||
triggered = false; | ||
triggerCount = 0; | ||
} | ||
} | ||
} | ||
} | ||
public DateTime TriggeredTime { get; set; } | ||
public bool Notify { get; set; } | ||
public bool Email { get; set; } | ||
public bool Latch { get; set; } | ||
public int LatchHours { get; set; } | ||
public string EmailMsg { get; set; } | ||
public string Units { get; set; } | ||
public string LastError { get; set; } | ||
int triggerCount = 0; | ||
public int TriggerThreshold { get; set; } | ||
} | ||
|
||
public class AlarmChange : Alarm | ||
{ | ||
//public bool changeUp { get; set; } | ||
//public bool changeDown { get; set; } | ||
|
||
bool upTriggered; | ||
public bool UpTriggered | ||
{ | ||
get => upTriggered; | ||
set | ||
{ | ||
if (value) | ||
{ | ||
// If we were not set before, so we need to send an email? | ||
if (!upTriggered && Enabled && Email && cumulus.SmtpOptions.Enabled) | ||
{ | ||
// Construct the message - preamble, plus values | ||
var msg = Program.cumulus.AlarmEmailPreamble + "\r\n" + string.Format(EmailMsgUp, Value, Units); | ||
cumulus.emailer.SendEmail(cumulus.AlarmDestEmail, cumulus.AlarmFromEmail, cumulus.AlarmEmailSubject, msg, cumulus.AlarmEmailHtml); | ||
} | ||
|
||
// If we get a new trigger, record the time | ||
upTriggered = true; | ||
UpTriggeredTime = DateTime.Now; | ||
} | ||
else | ||
{ | ||
// If the trigger is cleared, check if we should be latching the value | ||
if (Latch) | ||
{ | ||
if (DateTime.Now > UpTriggeredTime.AddHours(LatchHours)) | ||
{ | ||
// We are latching, but the latch period has expired, clear the trigger | ||
upTriggered = false; | ||
} | ||
} | ||
else | ||
{ | ||
// No latch, just clear the trigger | ||
upTriggered = false; | ||
} | ||
} | ||
} | ||
} | ||
public DateTime UpTriggeredTime { get; set; } | ||
|
||
|
||
bool downTriggered; | ||
public bool DownTriggered | ||
{ | ||
get => downTriggered; | ||
set | ||
{ | ||
if (value) | ||
{ | ||
// If we were not set before, so we need to send an email? | ||
if (!downTriggered && Enabled && Email && cumulus.SmtpOptions.Enabled) | ||
{ | ||
// Construct the message - preamble, plus values | ||
var msg = Program.cumulus.AlarmEmailPreamble + "\n" + string.Format(EmailMsgDn, Value, Units); | ||
cumulus.emailer.SendEmail(cumulus.AlarmDestEmail, cumulus.AlarmFromEmail, cumulus.AlarmEmailSubject, msg, cumulus.AlarmEmailHtml); | ||
} | ||
|
||
// If we get a new trigger, record the time | ||
downTriggered = true; | ||
DownTriggeredTime = DateTime.Now; | ||
} | ||
else | ||
{ | ||
// If the trigger is cleared, check if we should be latching the value | ||
if (Latch) | ||
{ | ||
if (DateTime.Now > DownTriggeredTime.AddHours(LatchHours)) | ||
{ | ||
// We are latching, but the latch period has expired, clear the trigger | ||
downTriggered = false; | ||
} | ||
} | ||
else | ||
{ | ||
// No latch, just clear the trigger | ||
downTriggered = false; | ||
} | ||
} | ||
} | ||
} | ||
|
||
public DateTime DownTriggeredTime { get; set; } | ||
|
||
public string EmailMsgUp { get; set; } | ||
public string EmailMsgDn { get; set; } | ||
} | ||
} |
Oops, something went wrong.