mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-06 08:16:11 +00:00
Updates to Feedback logic for use in bridge classes, refactored into separate files. Added SerialFeedback class for use with serial stream data that doesn't use Funcs to compute value on update.
This commit is contained in:
@@ -27,7 +27,7 @@ namespace PepperDash.Essentials.Core
|
||||
|
||||
public enum eCueType
|
||||
{
|
||||
Bool, Int, String, Void, Other
|
||||
Bool, Int, String, Serial, Void, Other
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -186,7 +186,7 @@ namespace PepperDash.Essentials.Core
|
||||
if (!PowerIsOnFeedback.BoolValue)
|
||||
{
|
||||
PowerOn();
|
||||
EventHandler<EventArgs> oneTimer = null;
|
||||
EventHandler<FeedbackEventArgs> oneTimer = null;
|
||||
oneTimer = (o, a) =>
|
||||
{
|
||||
if (IsWarmingUpFeedback.BoolValue) return; // Only catch done warming
|
||||
|
||||
@@ -54,7 +54,7 @@ namespace PepperDash.Essentials.Core
|
||||
|
||||
InputPorts = new RoutingPortCollection<RoutingInputPort>();
|
||||
|
||||
PowerIsOnFeedback.OutputChange += new EventHandler<EventArgs>(PowerIsOnFeedback_OutputChange);
|
||||
PowerIsOnFeedback.OutputChange += PowerIsOnFeedback_OutputChange;
|
||||
}
|
||||
|
||||
void PowerIsOnFeedback_OutputChange(object sender, EventArgs e)
|
||||
|
||||
@@ -0,0 +1,110 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharpPro;
|
||||
|
||||
namespace PepperDash.Essentials.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// A Feedback whose output is derived from the return value of a provided Func.
|
||||
/// </summary>
|
||||
public class BoolFeedback : Feedback
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the current value of the feedback, derived from the ValueFunc. The ValueFunc is
|
||||
/// evaluated whenever FireUpdate() is called
|
||||
/// </summary>
|
||||
public override bool BoolValue { get { return _BoolValue; } }
|
||||
bool _BoolValue;
|
||||
|
||||
public override eCueType Type { get { return eCueType.Bool; } }
|
||||
|
||||
/// <summary>
|
||||
/// Fake value to be used in test mode
|
||||
/// </summary>
|
||||
public bool TestValue { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Func that evaluates on FireUpdate
|
||||
/// </summary>
|
||||
public Func<bool> ValueFunc { get; private set; }
|
||||
|
||||
List<BoolInputSig> LinkedInputSigs = new List<BoolInputSig>();
|
||||
List<BoolInputSig> LinkedComplementInputSigs = new List<BoolInputSig>();
|
||||
|
||||
public BoolFeedback(Func<bool> valueFunc)
|
||||
: this(Cue.DefaultBoolCue, valueFunc)
|
||||
{
|
||||
}
|
||||
|
||||
public BoolFeedback(Cue cue, Func<bool> valueFunc)
|
||||
: base(cue)
|
||||
{
|
||||
if (cue == null) throw new ArgumentNullException("cue");
|
||||
ValueFunc = valueFunc;
|
||||
}
|
||||
|
||||
public override void FireUpdate()
|
||||
{
|
||||
bool newValue = InTestMode ? TestValue : ValueFunc.Invoke();
|
||||
if (newValue != _BoolValue)
|
||||
{
|
||||
_BoolValue = newValue;
|
||||
LinkedInputSigs.ForEach(s => UpdateSig(s));
|
||||
LinkedComplementInputSigs.ForEach(s => UpdateComplementSig(s));
|
||||
OnOutputChange(newValue);
|
||||
}
|
||||
}
|
||||
|
||||
public void LinkInputSig(BoolInputSig sig)
|
||||
{
|
||||
LinkedInputSigs.Add(sig);
|
||||
UpdateSig(sig);
|
||||
}
|
||||
|
||||
public void UnlinkInputSig(BoolInputSig sig)
|
||||
{
|
||||
LinkedInputSigs.Remove(sig);
|
||||
}
|
||||
|
||||
public void LinkComplementInputSig(BoolInputSig sig)
|
||||
{
|
||||
LinkedComplementInputSigs.Add(sig);
|
||||
UpdateComplementSig(sig);
|
||||
}
|
||||
|
||||
public void UnlinkComplementInputSig(BoolInputSig sig)
|
||||
{
|
||||
LinkedComplementInputSigs.Remove(sig);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return (InTestMode ? "TEST -- " : "") + BoolValue.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Puts this in test mode, sets the test value and fires an update.
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
public void SetTestValue(bool value)
|
||||
{
|
||||
TestValue = value;
|
||||
InTestMode = true;
|
||||
FireUpdate();
|
||||
}
|
||||
|
||||
void UpdateSig(BoolInputSig sig)
|
||||
{
|
||||
sig.BoolValue = _BoolValue;
|
||||
}
|
||||
|
||||
void UpdateComplementSig(BoolInputSig sig)
|
||||
{
|
||||
sig.BoolValue = !_BoolValue;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,88 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharpPro;
|
||||
|
||||
namespace PepperDash.Essentials.Core
|
||||
{
|
||||
public abstract class Feedback
|
||||
{
|
||||
public event EventHandler<FeedbackEventArgs> OutputChange;
|
||||
|
||||
public virtual bool BoolValue { get { return false; } }
|
||||
public virtual int IntValue { get { return 0; } }
|
||||
public virtual string StringValue { get { return ""; } }
|
||||
public virtual string SerialValue { get { return ""; } }
|
||||
|
||||
public Cue Cue { get; private set; }
|
||||
|
||||
public abstract eCueType Type { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Feedbacks can be put into test mode for simulation of events without real data.
|
||||
/// Using JSON debugging methods and the Set/ClearTestValue methods, we can simulate
|
||||
/// Feedback behaviors
|
||||
/// </summary>
|
||||
public bool InTestMode { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Base Constructor - empty
|
||||
/// </summary>
|
||||
protected Feedback()
|
||||
{
|
||||
}
|
||||
|
||||
protected Feedback(Cue cue)
|
||||
{
|
||||
Cue = cue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears test mode and fires update.
|
||||
/// </summary>
|
||||
public void ClearTestValue()
|
||||
{
|
||||
InTestMode = false;
|
||||
FireUpdate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fires an update synchronously
|
||||
/// </summary>
|
||||
public abstract void FireUpdate();
|
||||
|
||||
/// <summary>
|
||||
/// Fires the update asynchronously within a CrestronInvoke
|
||||
/// </summary>
|
||||
public void InvokeFireUpdate()
|
||||
{
|
||||
CrestronInvoke.BeginInvoke(o => FireUpdate());
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// Helper method that fires event. Use this intstead of calling OutputChange
|
||||
///// </summary>
|
||||
//protected void OnOutputChange()
|
||||
//{
|
||||
// if (OutputChange != null) OutputChange(this, EventArgs.Empty);
|
||||
//}
|
||||
|
||||
protected void OnOutputChange(bool value)
|
||||
{
|
||||
if (OutputChange != null) OutputChange(this, new FeedbackEventArgs(value));
|
||||
}
|
||||
|
||||
protected void OnOutputChange(int value)
|
||||
{
|
||||
if (OutputChange != null) OutputChange(this, new FeedbackEventArgs(value));
|
||||
}
|
||||
|
||||
|
||||
protected void OnOutputChange(string value)
|
||||
{
|
||||
if (OutputChange != null) OutputChange(this, new FeedbackEventArgs(value));
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
|
||||
using PepperDash.Core;
|
||||
|
||||
namespace PepperDash.Essentials.Core
|
||||
{
|
||||
public class FeedbackTest
|
||||
{
|
||||
public void doit()
|
||||
{
|
||||
var sf = new StringFeedback(() => "Ho");
|
||||
|
||||
sf.OutputChange += new EventHandler<FeedbackEventArgs>(sf_OutputChange);
|
||||
}
|
||||
|
||||
void sf_OutputChange(object sender, EventArgs e)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public class Hmmm
|
||||
{
|
||||
IBasicCommunication comm;
|
||||
|
||||
public Hmmm()
|
||||
{
|
||||
comm.TextReceived += new EventHandler<GenericCommMethodReceiveTextArgs>(comm_TextReceived);
|
||||
|
||||
var d = new Dictionary<string, EventHandler<GenericCommMethodReceiveTextArgs>>
|
||||
{
|
||||
{ "textReceived1", comm_TextReceived}
|
||||
};
|
||||
}
|
||||
|
||||
void comm_TextReceived(object sender, GenericCommMethodReceiveTextArgs e)
|
||||
{
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,337 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharpPro;
|
||||
|
||||
namespace PepperDash.Essentials.Core
|
||||
{
|
||||
public abstract class Feedback
|
||||
{
|
||||
public event EventHandler<FeedbackEventArgs> OutputChange;
|
||||
|
||||
public virtual bool BoolValue { get { return false; } }
|
||||
public virtual int IntValue { get { return 0; } }
|
||||
public virtual string StringValue { get { return ""; } }
|
||||
|
||||
public Cue Cue { get; private set; }
|
||||
|
||||
public abstract eCueType Type { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Feedbacks can be put into test mode for simulation of events without real data.
|
||||
/// Using JSON debugging methods and the Set/ClearTestValue methods, we can simulate
|
||||
/// Feedback behaviors
|
||||
/// </summary>
|
||||
public bool InTestMode { get; protected set; }
|
||||
|
||||
/// <summary>
|
||||
/// Base Constructor - empty
|
||||
/// </summary>
|
||||
protected Feedback()
|
||||
{
|
||||
}
|
||||
|
||||
protected Feedback(Cue cue)
|
||||
{
|
||||
Cue = cue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Clears test mode and fires update.
|
||||
/// </summary>
|
||||
public void ClearTestValue()
|
||||
{
|
||||
InTestMode = false;
|
||||
FireUpdate();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fires an update synchronously
|
||||
/// </summary>
|
||||
public abstract void FireUpdate();
|
||||
|
||||
/// <summary>
|
||||
/// Fires the update asynchronously within a CrestronInvoke
|
||||
/// </summary>
|
||||
public void InvokeFireUpdate()
|
||||
{
|
||||
CrestronInvoke.BeginInvoke(o => FireUpdate());
|
||||
}
|
||||
|
||||
///// <summary>
|
||||
///// Helper method that fires event. Use this intstead of calling OutputChange
|
||||
///// </summary>
|
||||
//protected void OnOutputChange()
|
||||
//{
|
||||
// if (OutputChange != null) OutputChange(this, EventArgs.Empty);
|
||||
//}
|
||||
|
||||
protected void OnOutputChange(bool value)
|
||||
{
|
||||
if (OutputChange != null) OutputChange(this, new FeedbackEventArgs(value));
|
||||
}
|
||||
|
||||
protected void OnOutputChange(int value)
|
||||
{
|
||||
if (OutputChange != null) OutputChange(this, new FeedbackEventArgs(value));
|
||||
}
|
||||
|
||||
|
||||
protected void OnOutputChange(string value)
|
||||
{
|
||||
if (OutputChange != null) OutputChange(this, new FeedbackEventArgs(value));
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// A Feedback whose output is derived from the return value of a provided Func.
|
||||
/// </summary>
|
||||
public class BoolFeedback : Feedback
|
||||
{
|
||||
/// <summary>
|
||||
/// Returns the current value of the feedback, derived from the ValueFunc. The ValueFunc is
|
||||
/// evaluated whenever FireUpdate() is called
|
||||
/// </summary>
|
||||
public override bool BoolValue { get { return _BoolValue; } }
|
||||
bool _BoolValue;
|
||||
|
||||
public override eCueType Type { get { return eCueType.Bool; } }
|
||||
|
||||
/// <summary>
|
||||
/// Fake value to be used in test mode
|
||||
/// </summary>
|
||||
public bool TestValue { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Func that evaluates on FireUpdate
|
||||
/// </summary>
|
||||
public Func<bool> ValueFunc { get; private set; }
|
||||
|
||||
List<BoolInputSig> LinkedInputSigs = new List<BoolInputSig>();
|
||||
List<BoolInputSig> LinkedComplementInputSigs = new List<BoolInputSig>();
|
||||
|
||||
public BoolFeedback(Func<bool> valueFunc)
|
||||
: this(Cue.DefaultBoolCue, valueFunc)
|
||||
{
|
||||
}
|
||||
|
||||
public BoolFeedback(Cue cue, Func<bool> valueFunc)
|
||||
: base(cue)
|
||||
{
|
||||
if (cue == null) throw new ArgumentNullException("cue");
|
||||
ValueFunc = valueFunc;
|
||||
}
|
||||
|
||||
public override void FireUpdate()
|
||||
{
|
||||
bool newValue = InTestMode ? TestValue : ValueFunc.Invoke();
|
||||
if (newValue != _BoolValue)
|
||||
{
|
||||
_BoolValue = newValue;
|
||||
LinkedInputSigs.ForEach(s => UpdateSig(s));
|
||||
LinkedComplementInputSigs.ForEach(s => UpdateComplementSig(s));
|
||||
OnOutputChange(newValue);
|
||||
}
|
||||
}
|
||||
|
||||
public void LinkInputSig(BoolInputSig sig)
|
||||
{
|
||||
LinkedInputSigs.Add(sig);
|
||||
UpdateSig(sig);
|
||||
}
|
||||
|
||||
public void UnlinkInputSig(BoolInputSig sig)
|
||||
{
|
||||
LinkedInputSigs.Remove(sig);
|
||||
}
|
||||
|
||||
public void LinkComplementInputSig(BoolInputSig sig)
|
||||
{
|
||||
LinkedComplementInputSigs.Add(sig);
|
||||
UpdateComplementSig(sig);
|
||||
}
|
||||
|
||||
public void UnlinkComplementInputSig(BoolInputSig sig)
|
||||
{
|
||||
LinkedComplementInputSigs.Remove(sig);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return (InTestMode ? "TEST -- " : "") + BoolValue.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Puts this in test mode, sets the test value and fires an update.
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
public void SetTestValue(bool value)
|
||||
{
|
||||
TestValue = value;
|
||||
InTestMode = true;
|
||||
FireUpdate();
|
||||
}
|
||||
|
||||
void UpdateSig(BoolInputSig sig)
|
||||
{
|
||||
sig.BoolValue = _BoolValue;
|
||||
}
|
||||
|
||||
void UpdateComplementSig(BoolInputSig sig)
|
||||
{
|
||||
sig.BoolValue = !_BoolValue;
|
||||
}
|
||||
}
|
||||
|
||||
//******************************************************************************
|
||||
public class IntFeedback : Feedback
|
||||
{
|
||||
public override int IntValue { get { return _IntValue; } } // ValueFunc.Invoke(); } }
|
||||
int _IntValue;
|
||||
public ushort UShortValue { get { return (ushort)_IntValue; } }
|
||||
|
||||
public override eCueType Type { get { return eCueType.Int; } }
|
||||
|
||||
public int TestValue { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Func evaluated on FireUpdate
|
||||
/// </summary>
|
||||
Func<int> ValueFunc;
|
||||
List<UShortInputSig> LinkedInputSigs = new List<UShortInputSig>();
|
||||
|
||||
public IntFeedback(Func<int> valueFunc)
|
||||
: this(Cue.DefaultIntCue, valueFunc)
|
||||
{
|
||||
}
|
||||
|
||||
public IntFeedback(Cue cue, Func<int> valueFunc)
|
||||
: base(cue)
|
||||
{
|
||||
if (cue == null) throw new ArgumentNullException("cue");
|
||||
ValueFunc = valueFunc;
|
||||
}
|
||||
|
||||
public override void FireUpdate()
|
||||
{
|
||||
var newValue = InTestMode ? TestValue : ValueFunc.Invoke();
|
||||
if (newValue != _IntValue)
|
||||
{
|
||||
_IntValue = newValue;
|
||||
LinkedInputSigs.ForEach(s => UpdateSig(s));
|
||||
OnOutputChange(newValue);
|
||||
}
|
||||
}
|
||||
|
||||
public void LinkInputSig(UShortInputSig sig)
|
||||
{
|
||||
LinkedInputSigs.Add(sig);
|
||||
UpdateSig(sig);
|
||||
}
|
||||
|
||||
public void UnlinkInputSig(UShortInputSig sig)
|
||||
{
|
||||
LinkedInputSigs.Remove(sig);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return (InTestMode ? "TEST -- " : "") + IntValue.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Puts this in test mode, sets the test value and fires an update.
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
public void SetTestValue(int value)
|
||||
{
|
||||
TestValue = value;
|
||||
InTestMode = true;
|
||||
FireUpdate();
|
||||
}
|
||||
|
||||
void UpdateSig(UShortInputSig sig)
|
||||
{
|
||||
sig.UShortValue = UShortValue;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
//******************************************************************************
|
||||
public class StringFeedback : Feedback
|
||||
{
|
||||
public override string StringValue { get { return _StringValue; } } // ValueFunc.Invoke(); } }
|
||||
string _StringValue;
|
||||
|
||||
public override eCueType Type { get { return eCueType.String; } }
|
||||
|
||||
/// <summary>
|
||||
/// Used in testing. Set/Clear functions
|
||||
/// </summary>
|
||||
public string TestValue { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Evalutated on FireUpdate
|
||||
/// </summary>
|
||||
public Func<string> ValueFunc { get; private set; }
|
||||
List<StringInputSig> LinkedInputSigs = new List<StringInputSig>();
|
||||
|
||||
public StringFeedback(Func<string> valueFunc)
|
||||
: this(Cue.DefaultStringCue, valueFunc)
|
||||
{
|
||||
}
|
||||
|
||||
public StringFeedback(Cue cue, Func<string> valueFunc)
|
||||
: base(cue)
|
||||
{
|
||||
if (cue == null) throw new ArgumentNullException("cue");
|
||||
ValueFunc = valueFunc;
|
||||
|
||||
}
|
||||
|
||||
public override void FireUpdate()
|
||||
{
|
||||
var newValue = InTestMode ? TestValue : ValueFunc.Invoke();
|
||||
if (newValue != _StringValue)
|
||||
{
|
||||
_StringValue = newValue;
|
||||
LinkedInputSigs.ForEach(s => UpdateSig(s));
|
||||
OnOutputChange(newValue);
|
||||
}
|
||||
}
|
||||
|
||||
public void LinkInputSig(StringInputSig sig)
|
||||
{
|
||||
LinkedInputSigs.Add(sig);
|
||||
UpdateSig(sig);
|
||||
}
|
||||
|
||||
public void UnlinkInputSig(StringInputSig sig)
|
||||
{
|
||||
LinkedInputSigs.Remove(sig);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return (InTestMode ? "TEST -- " : "") + StringValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Puts this in test mode, sets the test value and fires an update.
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
public void SetTestValue(string value)
|
||||
{
|
||||
TestValue = value;
|
||||
InTestMode = true;
|
||||
FireUpdate();
|
||||
}
|
||||
|
||||
void UpdateSig(StringInputSig sig)
|
||||
{
|
||||
sig.StringValue = _StringValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharpPro;
|
||||
|
||||
namespace PepperDash.Essentials.Core
|
||||
{
|
||||
public class IntFeedback : Feedback
|
||||
{
|
||||
public override int IntValue { get { return _IntValue; } } // ValueFunc.Invoke(); } }
|
||||
int _IntValue;
|
||||
public ushort UShortValue { get { return (ushort)_IntValue; } }
|
||||
|
||||
public override eCueType Type { get { return eCueType.Int; } }
|
||||
|
||||
public int TestValue { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Func evaluated on FireUpdate
|
||||
/// </summary>
|
||||
Func<int> ValueFunc;
|
||||
List<UShortInputSig> LinkedInputSigs = new List<UShortInputSig>();
|
||||
|
||||
public IntFeedback(Func<int> valueFunc)
|
||||
: this(Cue.DefaultIntCue, valueFunc)
|
||||
{
|
||||
}
|
||||
|
||||
public IntFeedback(Cue cue, Func<int> valueFunc)
|
||||
: base(cue)
|
||||
{
|
||||
if (cue == null) throw new ArgumentNullException("cue");
|
||||
ValueFunc = valueFunc;
|
||||
}
|
||||
|
||||
public override void FireUpdate()
|
||||
{
|
||||
var newValue = InTestMode ? TestValue : ValueFunc.Invoke();
|
||||
if (newValue != _IntValue)
|
||||
{
|
||||
_IntValue = newValue;
|
||||
LinkedInputSigs.ForEach(s => UpdateSig(s));
|
||||
OnOutputChange(newValue);
|
||||
}
|
||||
}
|
||||
|
||||
public void LinkInputSig(UShortInputSig sig)
|
||||
{
|
||||
LinkedInputSigs.Add(sig);
|
||||
UpdateSig(sig);
|
||||
}
|
||||
|
||||
public void UnlinkInputSig(UShortInputSig sig)
|
||||
{
|
||||
LinkedInputSigs.Remove(sig);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return (InTestMode ? "TEST -- " : "") + IntValue.ToString();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Puts this in test mode, sets the test value and fires an update.
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
public void SetTestValue(int value)
|
||||
{
|
||||
TestValue = value;
|
||||
InTestMode = true;
|
||||
FireUpdate();
|
||||
}
|
||||
|
||||
void UpdateSig(UShortInputSig sig)
|
||||
{
|
||||
sig.UShortValue = UShortValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,81 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharpPro;
|
||||
|
||||
namespace PepperDash.Essentials.Core
|
||||
{
|
||||
/// <summary>
|
||||
/// To be used for serial data feedback where the event chain / asynchronicity must be maintained
|
||||
/// and calculating the value based on a Func when it is needed will not suffice.
|
||||
/// </summary>
|
||||
public class SerialFeedback : Feedback
|
||||
{
|
||||
public override string SerialValue { get { return _SerialValue; } }
|
||||
string _SerialValue;
|
||||
|
||||
public override eCueType Type { get { return eCueType.Serial; } }
|
||||
|
||||
/// <summary>
|
||||
/// Used in testing. Set/Clear functions
|
||||
/// </summary>
|
||||
public string TestValue { get; private set; }
|
||||
|
||||
List<StringInputSig> LinkedInputSigs = new List<StringInputSig>();
|
||||
|
||||
public SerialFeedback()
|
||||
{
|
||||
}
|
||||
|
||||
public override void FireUpdate()
|
||||
{
|
||||
throw new NotImplementedException("This feedback type does not use Funcs");
|
||||
}
|
||||
|
||||
public void FireUpdate(string newValue)
|
||||
{
|
||||
_SerialValue = newValue;
|
||||
LinkedInputSigs.ForEach(s => UpdateSig(s, newValue));
|
||||
OnOutputChange(newValue);
|
||||
}
|
||||
|
||||
public void LinkInputSig(StringInputSig sig)
|
||||
{
|
||||
LinkedInputSigs.Add(sig);
|
||||
UpdateSig(sig);
|
||||
}
|
||||
|
||||
public void UnlinkInputSig(StringInputSig sig)
|
||||
{
|
||||
LinkedInputSigs.Remove(sig);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return (InTestMode ? "TEST -- " : "") + SerialValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Puts this in test mode, sets the test value and fires an update.
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
public void SetTestValue(string value)
|
||||
{
|
||||
TestValue = value;
|
||||
InTestMode = true;
|
||||
FireUpdate(TestValue);
|
||||
}
|
||||
|
||||
void UpdateSig(StringInputSig sig)
|
||||
{
|
||||
sig.StringValue = _SerialValue;
|
||||
}
|
||||
|
||||
void UpdateSig(StringInputSig sig, string value)
|
||||
{
|
||||
sig.StringValue = value;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,84 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharpPro;
|
||||
|
||||
namespace PepperDash.Essentials.Core
|
||||
{
|
||||
public class StringFeedback : Feedback
|
||||
{
|
||||
public override string StringValue { get { return _StringValue; } } // ValueFunc.Invoke(); } }
|
||||
string _StringValue;
|
||||
|
||||
public override eCueType Type { get { return eCueType.String; } }
|
||||
|
||||
/// <summary>
|
||||
/// Used in testing. Set/Clear functions
|
||||
/// </summary>
|
||||
public string TestValue { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Evalutated on FireUpdate
|
||||
/// </summary>
|
||||
public Func<string> ValueFunc { get; private set; }
|
||||
List<StringInputSig> LinkedInputSigs = new List<StringInputSig>();
|
||||
|
||||
public StringFeedback(Func<string> valueFunc)
|
||||
: this(Cue.DefaultStringCue, valueFunc)
|
||||
{
|
||||
}
|
||||
|
||||
public StringFeedback(Cue cue, Func<string> valueFunc)
|
||||
: base(cue)
|
||||
{
|
||||
if (cue == null) throw new ArgumentNullException("cue");
|
||||
ValueFunc = valueFunc;
|
||||
|
||||
}
|
||||
|
||||
public override void FireUpdate()
|
||||
{
|
||||
var newValue = InTestMode ? TestValue : ValueFunc.Invoke();
|
||||
if (newValue != _StringValue)
|
||||
{
|
||||
_StringValue = newValue;
|
||||
LinkedInputSigs.ForEach(s => UpdateSig(s));
|
||||
OnOutputChange(newValue);
|
||||
}
|
||||
}
|
||||
|
||||
public void LinkInputSig(StringInputSig sig)
|
||||
{
|
||||
LinkedInputSigs.Add(sig);
|
||||
UpdateSig(sig);
|
||||
}
|
||||
|
||||
public void UnlinkInputSig(StringInputSig sig)
|
||||
{
|
||||
LinkedInputSigs.Remove(sig);
|
||||
}
|
||||
|
||||
public override string ToString()
|
||||
{
|
||||
return (InTestMode ? "TEST -- " : "") + StringValue;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Puts this in test mode, sets the test value and fires an update.
|
||||
/// </summary>
|
||||
/// <param name="value"></param>
|
||||
public void SetTestValue(string value)
|
||||
{
|
||||
TestValue = value;
|
||||
InTestMode = true;
|
||||
FireUpdate();
|
||||
}
|
||||
|
||||
void UpdateSig(StringInputSig sig)
|
||||
{
|
||||
sig.StringValue = _StringValue;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -111,8 +111,11 @@
|
||||
<Compile Include="Crestron IO\Relay\GenericRelayDevice.cs" />
|
||||
<Compile Include="Crestron IO\Relay\ISwitchedOutput.cs" />
|
||||
<Compile Include="Devices\CodecInterfaces.cs" />
|
||||
<Compile Include="Feedbacks\FeedbackTest.cs" />
|
||||
<Compile Include="Feedbacks\BoolFeedback.cs" />
|
||||
<Compile Include="Feedbacks\FeedbackEventArgs.cs" />
|
||||
<Compile Include="Feedbacks\IntFeedback.cs" />
|
||||
<Compile Include="Feedbacks\SerialFeedback.cs" />
|
||||
<Compile Include="Feedbacks\StringFeedback.cs" />
|
||||
<Compile Include="Global\JobTimer.cs" />
|
||||
<Compile Include="Lighting\Lighting Interfaces.cs" />
|
||||
<Compile Include="Lighting\LightingBase.cs" />
|
||||
@@ -214,7 +217,7 @@
|
||||
<Compile Include="Devices\DeviceManager.cs" />
|
||||
<Compile Include="Devices\IrOutputPortController.cs" />
|
||||
<Compile Include="Display\DisplayBase.cs" />
|
||||
<Compile Include="Feedbacks\Feedbacks.cs" />
|
||||
<Compile Include="Feedbacks\FeedbackBase.cs" />
|
||||
<Compile Include="Room\Room.cs" />
|
||||
<Compile Include="Room\RoomCues.cs" />
|
||||
<Compile Include="Room\MOVED RoomEventArgs.cs" />
|
||||
|
||||
@@ -103,7 +103,7 @@ namespace PepperDash.Essentials.DM
|
||||
InputPorts = new RoutingPortCollection<RoutingInputPort>();
|
||||
OutputPorts = new RoutingPortCollection<RoutingOutputPort>();
|
||||
VolumeControls = new Dictionary<uint, DmCardAudioOutputController>();
|
||||
IsOnline.OutputChange += new EventHandler<EventArgs>(IsOnline_OutputChange);
|
||||
IsOnline.OutputChange += IsOnline_OutputChange;
|
||||
Chassis.DMOutputChange += new DMOutputEventHandler(Chassis_DMOutputChange);
|
||||
}
|
||||
|
||||
|
||||
@@ -112,6 +112,7 @@
|
||||
<Compile Include="MOVE IBasicVideoStatusFeedbacks.cs" />
|
||||
<Compile Include="Properties\AssemblyInfo.cs" />
|
||||
<Compile Include="VideoStatusHelpers.cs" />
|
||||
<None Include="app.config" />
|
||||
<None Include="Properties\ControlSystem.cfg" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
|
||||
11
Essentials DM/Essentials_DM/app.config
Normal file
11
Essentials DM/Essentials_DM/app.config
Normal file
@@ -0,0 +1,11 @@
|
||||
<?xml version="1.0"?>
|
||||
<configuration>
|
||||
<runtime>
|
||||
<assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
|
||||
<dependentAssembly>
|
||||
<assemblyIdentity name="ConsoleServiceCE" publicKeyToken="1099C178B3B54C3B" culture="neutral"/>
|
||||
<bindingRedirect oldVersion="0.0.0.0-1.0.6732.19368" newVersion="1.0.6732.19368"/>
|
||||
</dependentAssembly>
|
||||
</assemblyBinding>
|
||||
</runtime>
|
||||
</configuration>
|
||||
@@ -606,7 +606,7 @@ namespace PepperDash.Essentials.Devices.Displays
|
||||
else // if power is off, wait until we get on FB to send it.
|
||||
{
|
||||
// One-time event handler to wait for power on before executing switch
|
||||
EventHandler<EventArgs> handler = null; // necessary to allow reference inside lambda to handler
|
||||
EventHandler<FeedbackEventArgs> handler = null; // necessary to allow reference inside lambda to handler
|
||||
handler = (o, a) =>
|
||||
{
|
||||
if (!_IsWarmingUp) // Done warming
|
||||
|
||||
@@ -491,7 +491,7 @@ namespace PepperDash.Essentials.Devices.Displays
|
||||
else // if power is off, wait until we get on FB to send it.
|
||||
{
|
||||
// One-time event handler to wait for power on before executing switch
|
||||
EventHandler<EventArgs> handler = null; // necessary to allow reference inside lambda to handler
|
||||
EventHandler<FeedbackEventArgs> handler = null; // necessary to allow reference inside lambda to handler
|
||||
handler = (o, a) =>
|
||||
{
|
||||
if (!_IsWarmingUp) // Done warming
|
||||
|
||||
@@ -98,7 +98,7 @@ namespace PepperDash.Essentials.Devices.Common.Microphones
|
||||
{
|
||||
PrivacyDevice = privacyDevice;
|
||||
|
||||
PrivacyDevice.PrivacyModeIsOnFeedback.OutputChange += new EventHandler<EventArgs>(PrivacyModeIsOnFeedback_OutputChange);
|
||||
PrivacyDevice.PrivacyModeIsOnFeedback.OutputChange += PrivacyModeIsOnFeedback_OutputChange;
|
||||
}
|
||||
|
||||
void PrivacyModeIsOnFeedback_OutputChange(object sender, EventArgs e)
|
||||
@@ -124,7 +124,7 @@ namespace PepperDash.Essentials.Devices.Common.Microphones
|
||||
{
|
||||
Inputs.Add(input);
|
||||
|
||||
input.InputStateFeedback.OutputChange += new EventHandler<EventArgs>(InputStateFeedback_OutputChange);
|
||||
input.InputStateFeedback.OutputChange += InputStateFeedback_OutputChange;
|
||||
}
|
||||
|
||||
void RemoveInput(IDigitalInput input)
|
||||
|
||||
@@ -5,7 +5,6 @@ using Crestron.SimplSharp.CrestronIO;
|
||||
using Crestron.SimplSharpPro;
|
||||
using Crestron.SimplSharpPro.CrestronThread;
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Core.PortalSync;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Essentials.Devices.Common;
|
||||
using PepperDash.Essentials.DM;
|
||||
@@ -16,7 +15,6 @@ namespace PepperDash.Essentials
|
||||
{
|
||||
public class ControlSystem : CrestronControlSystem
|
||||
{
|
||||
PepperDashPortalSyncClient PortalSync;
|
||||
HttpLogoServer LogoServer;
|
||||
|
||||
public ControlSystem()
|
||||
@@ -59,7 +57,7 @@ namespace PepperDash.Essentials
|
||||
"Template URL: {1}", ConfigReader.ConfigObject.SystemUrl, ConfigReader.ConfigObject.TemplateUrl);
|
||||
}, "portalinfo", "Shows portal URLS from configuration", ConsoleAccessLevelEnum.AccessOperator);
|
||||
|
||||
//GoWithLoad();
|
||||
GoWithLoad();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@@ -174,7 +172,6 @@ namespace PepperDash.Essentials
|
||||
if (s.ToLower() == "enable")
|
||||
{
|
||||
CrestronConsole.ConsoleCommandResponse("Portal Sync features enabled");
|
||||
PortalSync = new PepperDashPortalSyncClient();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -68,12 +68,12 @@ namespace PepperDash.Essentials
|
||||
Room.CurrentVolumeDeviceChange += new EventHandler<VolumeDeviceChangeEventArgs>(Room_CurrentVolumeDeviceChange);
|
||||
|
||||
Room.OnFeedback.OutputChange += OnFeedback_OutputChange;
|
||||
Room.IsCoolingDownFeedback.OutputChange += new EventHandler<EventArgs>(IsCoolingDownFeedback_OutputChange);
|
||||
Room.IsWarmingUpFeedback.OutputChange += new EventHandler<EventArgs>(IsWarmingUpFeedback_OutputChange);
|
||||
Room.IsCoolingDownFeedback.OutputChange += IsCoolingDownFeedback_OutputChange;
|
||||
Room.IsWarmingUpFeedback.OutputChange += IsWarmingUpFeedback_OutputChange;
|
||||
|
||||
Room.ShutdownPromptTimer.HasStarted += new EventHandler<EventArgs>(ShutdownPromptTimer_HasStarted);
|
||||
Room.ShutdownPromptTimer.HasFinished += new EventHandler<EventArgs>(ShutdownPromptTimer_HasFinished);
|
||||
Room.ShutdownPromptTimer.WasCancelled += new EventHandler<EventArgs>(ShutdownPromptTimer_WasCancelled);
|
||||
Room.ShutdownPromptTimer.HasStarted += ShutdownPromptTimer_HasStarted;
|
||||
Room.ShutdownPromptTimer.HasFinished += ShutdownPromptTimer_HasFinished;
|
||||
Room.ShutdownPromptTimer.WasCancelled += ShutdownPromptTimer_WasCancelled;
|
||||
|
||||
// Registers for initial volume events, if possible
|
||||
var currentVolumeDevice = Room.CurrentVolumeControls;
|
||||
@@ -84,8 +84,8 @@ namespace PepperDash.Essentials
|
||||
{
|
||||
var newDev = currentVolumeDevice as IBasicVolumeWithFeedback;
|
||||
|
||||
newDev.MuteFeedback.OutputChange += new EventHandler<EventArgs>(VolumeLevelFeedback_OutputChange);
|
||||
newDev.VolumeLevelFeedback.OutputChange += new EventHandler<EventArgs>(VolumeLevelFeedback_OutputChange);
|
||||
newDev.MuteFeedback.OutputChange += VolumeLevelFeedback_OutputChange;
|
||||
newDev.VolumeLevelFeedback.OutputChange += VolumeLevelFeedback_OutputChange;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -210,8 +210,8 @@ namespace PepperDash.Essentials
|
||||
{
|
||||
var newDev = e.NewDev as IBasicVolumeWithFeedback;
|
||||
|
||||
newDev.MuteFeedback.OutputChange += new EventHandler<EventArgs>(VolumeLevelFeedback_OutputChange);
|
||||
newDev.VolumeLevelFeedback.OutputChange += new EventHandler<EventArgs>(VolumeLevelFeedback_OutputChange);
|
||||
newDev.MuteFeedback.OutputChange += VolumeLevelFeedback_OutputChange;
|
||||
newDev.VolumeLevelFeedback.OutputChange += VolumeLevelFeedback_OutputChange;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -210,7 +210,7 @@ namespace PepperDash.Essentials
|
||||
|
||||
RoomOccupancy = statusProvider;
|
||||
|
||||
RoomOccupancy.RoomIsOccupiedFeedback.OutputChange += new EventHandler<EventArgs>(RoomIsOccupiedFeedback_OutputChange);
|
||||
RoomOccupancy.RoomIsOccupiedFeedback.OutputChange += RoomIsOccupiedFeedback_OutputChange;
|
||||
}
|
||||
|
||||
void RoomIsOccupiedFeedback_OutputChange(object sender, EventArgs e)
|
||||
|
||||
@@ -45,7 +45,7 @@ namespace PepperDash.Essentials
|
||||
Devices = new List<IKeyed>();
|
||||
DeviceSubDrivers = new List<PanelDriverBase>();
|
||||
|
||||
Parent.AvDriver.PopupInterlock.IsShownFeedback.OutputChange += new EventHandler<EventArgs>(IsShownFeedback_OutputChange);
|
||||
Parent.AvDriver.PopupInterlock.IsShownFeedback.OutputChange += IsShownFeedback_OutputChange;
|
||||
|
||||
// Calculate the join offests for each device page and assign join actions for each button
|
||||
}
|
||||
|
||||
@@ -603,7 +603,7 @@ namespace PepperDash.Essentials
|
||||
|
||||
// respond to offs by cancelling dialog
|
||||
var onFb = CurrentRoom.OnFeedback;
|
||||
EventHandler<EventArgs> offHandler = null;
|
||||
EventHandler<FeedbackEventArgs> offHandler = null;
|
||||
offHandler = (o, a) =>
|
||||
{
|
||||
if (!onFb.BoolValue)
|
||||
|
||||
@@ -293,7 +293,7 @@ namespace PepperDash.Essentials.UIDrivers
|
||||
// Figure out some way to provide current input feedback
|
||||
if (display is TwoWayDisplayBase)
|
||||
{
|
||||
(display as TwoWayDisplayBase).CurrentInputFeedback.OutputChange += new EventHandler<EventArgs>(CurrentInputFeedback_OutputChange);
|
||||
(display as TwoWayDisplayBase).CurrentInputFeedback.OutputChange += CurrentInputFeedback_OutputChange;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -531,7 +531,7 @@ namespace PepperDash.Essentials
|
||||
else
|
||||
{
|
||||
// Rig a one-time handler to catch when the room is warmed and then dial call
|
||||
EventHandler<EventArgs> oneTimeHandler = null;
|
||||
EventHandler<FeedbackEventArgs> oneTimeHandler = null;
|
||||
oneTimeHandler = (o, a) =>
|
||||
{
|
||||
if (!CurrentRoom.IsWarmingUpFeedback.BoolValue)
|
||||
@@ -774,7 +774,7 @@ namespace PepperDash.Essentials
|
||||
|
||||
// respond to offs by cancelling dialog
|
||||
var onFb = CurrentRoom.OnFeedback;
|
||||
EventHandler<EventArgs> offHandler = null;
|
||||
EventHandler<FeedbackEventArgs> offHandler = null;
|
||||
offHandler = (o, a) =>
|
||||
{
|
||||
if (!onFb.BoolValue)
|
||||
@@ -932,7 +932,7 @@ namespace PepperDash.Essentials
|
||||
(_CurrentRoom.VideoCodec as IHasScheduleAwareness).CodecSchedule.MeetingsListHasChanged += CodecSchedule_MeetingsListHasChanged;
|
||||
|
||||
CallSharingInfoVisibleFeedback = new BoolFeedback(() => _CurrentRoom.VideoCodec.SharingContentIsOnFeedback.BoolValue);
|
||||
_CurrentRoom.VideoCodec.SharingContentIsOnFeedback.OutputChange += new EventHandler<EventArgs>(SharingContentIsOnFeedback_OutputChange);
|
||||
_CurrentRoom.VideoCodec.SharingContentIsOnFeedback.OutputChange += SharingContentIsOnFeedback_OutputChange;
|
||||
CallSharingInfoVisibleFeedback.LinkInputSig(TriList.BooleanInput[UIBoolJoin.CallSharedSourceInfoVisible]);
|
||||
|
||||
SetActiveCallListSharingContentStatus();
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user