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

@@ -21,32 +21,39 @@ namespace PepperDash.Essentials.Core
{
public static void DumpFeedbacksToConsole(this IHasFeedback source, bool getCurrentStates)
{
var outputs = source.Feedbacks.OrderBy(x => x.Type);
if (outputs != null)
var feedbacks = source.Feedbacks.OrderBy(x => x.Type);
if (feedbacks != null)
{
Debug.Console(0, source, "\n\nAvailable outputs:");
foreach (var o in outputs)
Debug.Console(0, source, "\n\nAvailable feedbacks:");
foreach (var f in feedbacks)
{
string val = "";
if (getCurrentStates)
{
switch (o.Type)
{
case eCueType.Bool:
val = " = " + o.BoolValue;
break;
case eCueType.Int:
val = " = " + o.IntValue;
break;
case eCueType.String:
val = " = " + o.StringValue;
break;
//case eOutputType.Other:
// break;
}
if (f is BoolFeedback)
val = " = " + f.BoolValue;
else if(f is IntFeedback)
val = " = " + f.IntValue;
else if(f is StringFeedback)
val = " = " + f.StringValue;
//switch (f.Type)
//{
// case eCueType.Bool:
// val = " = " + f.BoolValue;
// break;
// case eCueType.Int:
// val = " = " + f.IntValue;
// break;
// case eCueType.String:
// val = " = " + f.StringValue;
// break;
// //case eOutputType.Other:
// // break;
//}
}
Debug.Console(0, "{0,-8} {1,5} {2}{3}", o.Type, o.Cue.Number,
(string.IsNullOrEmpty(o.Cue.Name) ? "-none-" : o.Cue.Name), val);
Debug.Console(0, "{0,-8} {1}{2}", f.GetType(),
(string.IsNullOrEmpty(f.Cue.Name) ? "-none-" : f.Cue.Name), val);
}
}
else

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);
}
}
}