mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-04-12 12:06:58 +00:00
Heavy touch ups to comms (324); Fixed source display on turn-on (322); Added gear visibility in code (336)
This commit is contained in:
parent
efd5b59bda
commit
9e9b8628a4
12 changed files with 231 additions and 280 deletions
|
|
@ -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
|
||||
{
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue