Heavy touch ups to comms (324); Fixed source display on turn-on (322); Added gear visibility in code (336)

This commit is contained in:
Heath Volmer
2017-08-11 15:14:38 -06:00
parent efd5b59bda
commit 9e9b8628a4
12 changed files with 231 additions and 280 deletions

View File

@@ -24,6 +24,7 @@ namespace PepperDash.Essentials.Core
long PollTime;
CTimer PollTimer;
string PollString;
Action PollAction;
/// <summary>
///
@@ -47,6 +48,30 @@ namespace PepperDash.Essentials.Core
PollString = pollString;
}
/// <summary>
/// Poll is a provided action instead of string
/// </summary>
/// <param name="parent"></param>
/// <param name="client"></param>
/// <param name="pollTime"></param>
/// <param name="warningTime"></param>
/// <param name="errorTime"></param>
/// <param name="pollBytes"></param>
public GenericCommunicationMonitor(IKeyed parent, IBasicCommunication client, long pollTime,
long warningTime, long errorTime, Action pollAction) :
base(parent, warningTime, errorTime)
{
if (pollTime > warningTime || pollTime > errorTime)
throw new ArgumentException("pollTime must be less than warning or errorTime");
if (pollTime < 5000)
throw new ArgumentException("pollTime cannot be less than 5000 ms");
Client = client;
PollTime = pollTime;
PollAction = pollAction;
}
/// <summary>
/// Build the monitor from a config object
/// </summary>
@@ -88,7 +113,10 @@ namespace PepperDash.Essentials.Core
if (Client.IsConnected)
{
Debug.Console(2, Client, "Monitor, Polling");
Client.SendText(PollString);
if(PollAction != null)
PollAction.Invoke();
else
Client.SendText(PollString);
}
else
{

View File

@@ -29,7 +29,6 @@ namespace PepperDash.Essentials.Core
_Status = value;
OnStatusChange(value);
}
}
}
MonitorStatus _Status;
@@ -96,5 +95,12 @@ namespace PepperDash.Essentials.Core
ErrorTimer = null;
}
public void ResetErrorTimers()
{
if(WarningTimer != null)
WarningTimer.Reset(WarningTime, WarningTime);
if(ErrorTimer != null)
ErrorTimer.Reset(ErrorTime, ErrorTime);
}
}
}