Skip to content

Commit

Permalink
Merge pull request #166 from mcrossley/master
Browse files Browse the repository at this point in the history
v3.23.0 merge
  • Loading branch information
mcrossley authored Dec 30, 2022
2 parents ba34246 + 4482092 commit a5c33ca
Show file tree
Hide file tree
Showing 41 changed files with 2,828 additions and 5,392 deletions.
Binary file removed $tf1/localversion.tf1
Binary file not shown.
Binary file removed $tf1/localversion.tfb
Binary file not shown.
Binary file removed $tf1/pendingchanges.tf1
Binary file not shown.
Binary file removed $tf1/pendingchanges.tfb
Binary file not shown.
Binary file removed $tf1/properties.tf1
Binary file not shown.
4 changes: 0 additions & 4 deletions .nuget/packages.config

This file was deleted.

9 changes: 2 additions & 7 deletions CumulusMX.sln
Original file line number Diff line number Diff line change
@@ -1,15 +1,10 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29926.136
# Visual Studio Version 17
VisualStudioVersion = 17.4.33205.214
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "CumulusMX", "CumulusMX\CumulusMX.csproj", "{67A70E28-25C7-4C7F-BD7B-959AE6834B2C}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = ".nuget", ".nuget", "{8756765F-BCCF-45E0-BC5D-2DB8222349CF}"
ProjectSection(SolutionItems) = preProject
.nuget\packages.config = .nuget\packages.config
EndProjectSection
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{D1F48911-8B85-43F9-B207-3B23E81F5119}"
ProjectSection(SolutionItems) = preProject
.editorconfig = .editorconfig
Expand Down
72 changes: 58 additions & 14 deletions CumulusMX/Alarm.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,22 @@ public class Alarm
public Cumulus cumulus { get; set; }

public string Name { get; }
public bool Enabled { get; set; }
public virtual bool Enabled
{
get => enabled;
set
{
enabled = value;

// if we are disabled, clear any exisitng alarms
if (!value)
{
triggered = false;
triggerCount = 0;
triggeredTime = DateTime.MinValue;
}
}
}
public double Value { get; set; }
public bool Sound { get; set; }
public string SoundFile { get; set; }
Expand All @@ -17,7 +32,7 @@ public bool Triggered
get => triggered;
set
{
if (cumulus.NormalRunning)
if (enabled && cumulus.NormalRunning)
{
doTriggered(value);
}
Expand All @@ -37,6 +52,7 @@ public bool Triggered
public int TriggerThreshold { get; set; }

AlarmTypes type;
private protected bool enabled;
bool triggered;
int triggerCount = 0;
DateTime triggeredTime;
Expand All @@ -49,7 +65,7 @@ public Alarm(string AlarmName, AlarmTypes AlarmType)

public void CheckAlarm(double value)
{
if (cumulus.NormalRunning)
if (enabled && cumulus.NormalRunning)
{
doTriggered((type == AlarmTypes.Above && value > Value) || (type == AlarmTypes.Below && value < Value));
}
Expand All @@ -66,7 +82,7 @@ private void doTriggered(bool value)
if (triggerCount >= TriggerThreshold)
{
// If we were not set before, so we need to send an email?
if (!triggered && Enabled)
if (!triggered)
{
cumulus.LogMessage($"Alarm ({Name}): Triggered, value = {Value}");

Expand All @@ -87,9 +103,12 @@ private void doTriggered(bool value)
{
try
{
cumulus.LogMessage($"Alarm ({Name}): Starting external program: '{Action}', with parameters: {ActionParams}");
// Prepare the process to run
Utils.RunExternalTask(Action, ActionParams, false);
var parser = new TokenParser();
parser.InputText = ActionParams;
var args = parser.ToStringFromString();
cumulus.LogMessage($"Alarm ({Name}): Starting external program: '{Action}', with parameters: {args}");
Utils.RunExternalTask(Action, args, false);
}
catch (Exception ex)
{
Expand Down Expand Up @@ -133,13 +152,32 @@ public AlarmChange(string AlarmName) : base(AlarmName, AlarmTypes.Change)
{
}

public override bool Enabled
{
get => enabled;
set
{
enabled = value;

// if we are disabled, clear any exisitng alarms
if (!value)
{
upTriggered = false;
UpTriggeredTime = DateTime.MinValue;

downTriggered = false;
DownTriggeredTime = DateTime.MinValue;
}
}
}

bool upTriggered;
public bool UpTriggered
{
get => upTriggered;
set
{
if (cumulus.NormalRunning)
if (enabled && cumulus.NormalRunning)
{
doUpTriggered(value);
}
Expand All @@ -154,7 +192,7 @@ public bool DownTriggered
get => downTriggered;
set
{
if (cumulus.NormalRunning)
if (enabled && cumulus.NormalRunning)
{
doDownTriggered(value);
}
Expand All @@ -166,7 +204,7 @@ public bool DownTriggered

public new void CheckAlarm(double value)
{
if (cumulus.NormalRunning)
if (enabled && cumulus.NormalRunning)
{

if (value > Value)
Expand All @@ -192,7 +230,7 @@ private void doUpTriggered(bool value)
if (value)
{
// If we were not set before, so we need to send an email etc?
if (!upTriggered && Enabled)
if (!upTriggered)
{
cumulus.LogMessage($"Alarm ({Name}): Up triggered, value = {Value}");

Expand All @@ -209,9 +247,12 @@ private void doUpTriggered(bool value)
{
try
{
cumulus.LogMessage($"Alarm ({Name}): Starting external program: '{Action}', with parameters: {ActionParams}");
// Prepare the process to run
Utils.RunExternalTask(Action, ActionParams, false);
var parser = new TokenParser();
parser.InputText = ActionParams;
var args = parser.ToStringFromString();
cumulus.LogMessage($"Alarm ({Name}): Starting external program: '{Action}', with parameters: {args}");
Utils.RunExternalTask(Action, args, false);
}
catch (Exception ex)
{
Expand Down Expand Up @@ -266,9 +307,12 @@ private void doDownTriggered(bool value)
{
try
{
cumulus.LogMessage($"Alarm ({Name}): Starting external program: '{Action}', with parameters: {ActionParams}");
// Prepare the process to run
Utils.RunExternalTask(Action, ActionParams, false);
var parser = new TokenParser();
parser.InputText = ActionParams;
var args = parser.ToStringFromString();
cumulus.LogMessage($"Alarm ({Name}): Starting external program: '{Action}', with parameters: {args}");
Utils.RunExternalTask(Action, args, false);
}
catch (Exception ex)
{
Expand Down
Loading

0 comments on commit a5c33ca

Please sign in to comment.