chore: move all files to file-scoped namespace

This commit is contained in:
Andrew Welker 2025-07-04 16:02:32 -05:00 committed by Neil Dorin
parent aaa5b0532b
commit 3ece4f0b7b
522 changed files with 39628 additions and 45678 deletions

View file

@ -5,195 +5,165 @@ using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro;
namespace PepperDash.Essentials.Core
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>
/// A Feedback whose output is derived from the return value of a provided Func.
/// Returns the current value of the feedback, derived from the ValueFunc. The ValueFunc is
/// evaluated whenever FireUpdate() is called
/// </summary>
public class BoolFeedback : Feedback
public override bool BoolValue { get { return _BoolValue; } }
bool _BoolValue;
/// <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>();
List<Crestron.SimplSharpPro.DeviceSupport.Feedback> LinkedCrestronFeedbacks = new List<Crestron.SimplSharpPro.DeviceSupport.Feedback>();
/// <summary>
/// Creates the feedback with the Func as described.
/// </summary>
/// <remarks>
/// While the linked sig value will be updated with the current value stored when it is linked to a EISC Bridge,
/// it will NOT reflect an actual value from a device until <seealso cref="FireUpdate"/> has been called
/// </remarks>
/// <param name="valueFunc">Delegate to invoke when this feedback needs to be updated</param>
public BoolFeedback(Func<bool> valueFunc)
: this(null, valueFunc)
{
/// <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;
}
/// <summary>
/// Fake value to be used in test mode
/// </summary>
public bool TestValue { get; private set; }
/// <summary>
/// Creates the feedback with the Func as described.
/// </summary>
/// <remarks>
/// While the linked sig value will be updated with the current value stored when it is linked to a EISC Bridge,
/// it will NOT reflect an actual value from a device until <seealso cref="FireUpdate"/> has been called
/// </remarks>
/// <param name="key">Key to find this Feedback</param>
/// <param name="valueFunc">Delegate to invoke when this feedback needs to be updated</param>
public BoolFeedback(string key, Func<bool> valueFunc)
: base(key)
{
ValueFunc = valueFunc;
}
/// <summary>
/// Gets or sets the ValueFunc
/// </summary>
public Func<bool> ValueFunc { get; private set; }
public void SetValueFunc(Func<bool> newFunc)
{
ValueFunc = newFunc;
}
List<BoolInputSig> LinkedInputSigs = new List<BoolInputSig>();
List<BoolInputSig> LinkedComplementInputSigs = new List<BoolInputSig>();
List<Crestron.SimplSharpPro.DeviceSupport.Feedback> LinkedCrestronFeedbacks = new List<Crestron.SimplSharpPro.DeviceSupport.Feedback>();
/// <summary>
/// Creates the feedback with the Func as described.
/// </summary>
/// <remarks>
/// While the linked sig value will be updated with the current value stored when it is linked to a EISC Bridge,
/// it will NOT reflect an actual value from a device until <seealso cref="FireUpdate"/> has been called
/// </remarks>
/// <param name="valueFunc">Delegate to invoke when this feedback needs to be updated</param>
[Obsolete("use constructor with Key parameter. This constructor will be removed in a future version")]
public BoolFeedback(Func<bool> valueFunc)
: this(null, valueFunc)
public override void FireUpdate()
{
bool newValue = InTestMode ? TestValue : ValueFunc.Invoke();
if (newValue != _BoolValue)
{
}
/// <summary>
/// Creates the feedback with the Func as described.
/// </summary>
/// <remarks>
/// While the linked sig value will be updated with the current value stored when it is linked to a EISC Bridge,
/// it will NOT reflect an actual value from a device until <seealso cref="FireUpdate"/> has been called
/// </remarks>
/// <param name="key">Key to find this Feedback</param>
/// <param name="valueFunc">Delegate to invoke when this feedback needs to be updated</param>
public BoolFeedback(string key, Func<bool> valueFunc)
: base(key)
{
ValueFunc = valueFunc;
}
/// <summary>
/// Sets the ValueFunc
/// </summary>
/// <param name="newFunc">New function to set as the ValueFunc</param>
public void SetValueFunc(Func<bool> newFunc)
{
ValueFunc = newFunc;
}
/// <summary>
/// FireUpdate method
/// </summary>
/// <inheritdoc />
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);
}
}
/// <summary>
/// Links an input sig
/// </summary>
/// <param name="sig"></param>
/// <summary>
/// LinkInputSig method
/// </summary>
public void LinkInputSig(BoolInputSig sig)
{
LinkedInputSigs.Add(sig);
UpdateSig(sig);
}
/// <summary>
/// Unlinks an inputs sig
/// </summary>
/// <param name="sig"></param>
/// <summary>
/// UnlinkInputSig method
/// </summary>
public void UnlinkInputSig(BoolInputSig sig)
{
LinkedInputSigs.Remove(sig);
}
/// <summary>
/// Links an input sig to the complement value
/// </summary>
/// <param name="sig"></param>
public void LinkComplementInputSig(BoolInputSig sig)
{
LinkedComplementInputSigs.Add(sig);
UpdateComplementSig(sig);
}
/// <summary>
/// Unlinks an input sig to the complement value
/// </summary>
/// <param name="sig"></param>
/// <summary>
/// UnlinkComplementInputSig method
/// </summary>
public void UnlinkComplementInputSig(BoolInputSig sig)
{
LinkedComplementInputSigs.Remove(sig);
}
/// <summary>
/// Links a Crestron Feedback object
/// </summary>
/// <param name="feedback"></param>
public void LinkCrestronFeedback(Crestron.SimplSharpPro.DeviceSupport.Feedback feedback)
{
LinkedCrestronFeedbacks.Add(feedback);
UpdateCrestronFeedback(feedback);
}
/// <summary>
///
/// </summary>
/// <param name="feedback"></param>
/// <summary>
/// UnlinkCrestronFeedback method
/// </summary>
public void UnlinkCrestronFeedback(Crestron.SimplSharpPro.DeviceSupport.Feedback feedback)
{
LinkedCrestronFeedbacks.Remove(feedback);
}
/// <summary>
/// ToString override
/// </summary>
/// <returns></returns>
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>
/// <summary>
/// SetTestValue method
/// </summary>
public void SetTestValue(bool value)
{
TestValue = value;
InTestMode = true;
FireUpdate();
}
void UpdateSig(BoolInputSig sig)
{
sig.BoolValue = _BoolValue;
}
void UpdateComplementSig(BoolInputSig sig)
{
sig.BoolValue = !_BoolValue;
}
void UpdateCrestronFeedback(Crestron.SimplSharpPro.DeviceSupport.Feedback feedback)
{
feedback.State = _BoolValue;
_BoolValue = newValue;
LinkedInputSigs.ForEach(s => UpdateSig(s));
LinkedComplementInputSigs.ForEach(s => UpdateComplementSig(s));
OnOutputChange(newValue);
}
}
/// <summary>
/// Links an input sig
/// </summary>
/// <param name="sig"></param>
public void LinkInputSig(BoolInputSig sig)
{
LinkedInputSigs.Add(sig);
UpdateSig(sig);
}
/// <summary>
/// Unlinks an inputs sig
/// </summary>
/// <param name="sig"></param>
public void UnlinkInputSig(BoolInputSig sig)
{
LinkedInputSigs.Remove(sig);
}
/// <summary>
/// Links an input sig to the complement value
/// </summary>
/// <param name="sig"></param>
public void LinkComplementInputSig(BoolInputSig sig)
{
LinkedComplementInputSigs.Add(sig);
UpdateComplementSig(sig);
}
/// <summary>
/// Unlinks an input sig to the complement value
/// </summary>
/// <param name="sig"></param>
public void UnlinkComplementInputSig(BoolInputSig sig)
{
LinkedComplementInputSigs.Remove(sig);
}
/// <summary>
/// Links a Crestron Feedback object
/// </summary>
/// <param name="feedback"></param>
public void LinkCrestronFeedback(Crestron.SimplSharpPro.DeviceSupport.Feedback feedback)
{
LinkedCrestronFeedbacks.Add(feedback);
UpdateCrestronFeedback(feedback);
}
/// <summary>
///
/// </summary>
/// <param name="feedback"></param>
public void UnlinkCrestronFeedback(Crestron.SimplSharpPro.DeviceSupport.Feedback feedback)
{
LinkedCrestronFeedbacks.Remove(feedback);
}
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;
}
void UpdateCrestronFeedback(Crestron.SimplSharpPro.DeviceSupport.Feedback feedback)
{
feedback.State = _BoolValue;
}
}

View file

@ -1,29 +1,24 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro;
using Crestron.SimplSharp;
namespace PepperDash.Essentials.Core
{
/// <summary>
/// Represents a BoolFeedbackPulse
/// </summary>
/// <summary>
/// Represents a BoolFeedbackPulse
/// </summary>
public class BoolFeedbackPulse
{
/// <summary>
/// Gets or sets the TimeoutMs
/// </summary>
/// <summary>
/// Gets or sets the TimeoutMs
/// </summary>
public uint TimeoutMs { get; set; }
/// <summary>
/// Gets or sets the CanRetrigger
/// </summary>
/// <summary>
/// Gets or sets the CanRetrigger
/// </summary>
public bool CanRetrigger { get; set; }
/// <summary>
/// Gets or sets the Feedback
/// </summary>
/// <summary>
/// Gets or sets the Feedback
/// </summary>
public BoolFeedback Feedback { get; private set; }
CTimer Timer;
@ -68,12 +63,12 @@ namespace PepperDash.Essentials.Core
Timer.Reset(TimeoutMs);
}
/// <summary>
/// Cancel method
/// </summary>
/// <summary>
/// Cancel method
/// </summary>
public void Cancel()
{
if(Timer != null)
if (Timer != null)
Timer.Reset(0);
}
}

View file

@ -4,8 +4,8 @@ using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro;
namespace PepperDash.Essentials.Core
{
namespace PepperDash.Essentials.Core;
/// <summary>
/// A class that wraps a BoolFeedback with logic that extends it's true state for
/// a time period after the value goes false.
@ -81,5 +81,4 @@ namespace PepperDash.Essentials.Core
Feedback.FireUpdate();
Timer = null;
}
}
}
}

View file

@ -5,8 +5,8 @@ using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro;
namespace PepperDash.Essentials.Core
{
namespace PepperDash.Essentials.Core;
/// <summary>
/// Abstract base class for BoolOutputLogicals
@ -98,7 +98,7 @@ namespace PepperDash.Essentials.Core
public void ClearOutputs()
{
OutputsIn.Clear();
Evaluate();
Evaluate();
}
/// <summary>
@ -190,5 +190,4 @@ namespace PepperDash.Essentials.Core
ComputedValue = newValue;
Output.FireUpdate();
}
}
}
}

View file

@ -1,10 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro;
using PepperDash.Core;
namespace PepperDash.Essentials.Core
@ -120,4 +115,4 @@ namespace PepperDash.Essentials.Core
if (OutputChange != null) OutputChange(this, new FeedbackEventArgs(value));
}
}
}
}

View file

@ -4,22 +4,21 @@ using System.Linq;
using System.Text;
using Crestron.SimplSharp;
namespace PepperDash.Essentials.Core
namespace PepperDash.Essentials.Core;
/// <summary>
/// Basically a List , with an indexer to find feedbacks by key name
/// </summary>
public class FeedbackCollection<T> : List<T> where T : Feedback
{
/// <summary>
/// Basically a List , with an indexer to find feedbacks by key name
/// Case-insensitive port lookup linked to feedbacks' keys
/// </summary>
public class FeedbackCollection<T> : List<T> where T : Feedback
public T this[string key]
{
/// <summary>
/// Case-insensitive port lookup linked to feedbacks' keys
/// </summary>
public T this[string key]
get
{
get
{
return this.FirstOrDefault(i => i.Key.Equals(key, StringComparison.OrdinalIgnoreCase));
}
return this.FirstOrDefault(i => i.Key.Equals(key, StringComparison.OrdinalIgnoreCase));
}
}
}

View file

@ -4,93 +4,96 @@ using System.Linq;
using System.Text;
using Crestron.SimplSharp;
namespace PepperDash.Essentials.Core
namespace PepperDash.Essentials.Core;
/// <summary>
/// Represents a FeedbackEventArgs
/// </summary>
public class FeedbackEventArgs : EventArgs
{
/// <summary>
/// Represents a FeedbackEventArgs
/// Gets or sets the BoolValue
/// </summary>
public class FeedbackEventArgs : EventArgs
public bool BoolValue { get; private set; }
/// <summary>
/// Gets or sets the IntValue
/// </summary>
public int IntValue { get; private set; }
/// <summary>
/// Gets or sets the UShortValue
/// </summary>
public ushort UShortValue
{
/// <summary>
/// Gets or sets the BoolValue
/// </summary>
public bool BoolValue { get; private set; }
/// <summary>
/// Gets or sets the IntValue
/// </summary>
public int IntValue { get; private set; }
/// <summary>
/// Gets or sets the UShortValue
/// </summary>
public ushort UShortValue
get
{
get
{
return (ushort)IntValue;
}
}
/// <summary>
/// Gets or sets the StringValue
/// </summary>
public string StringValue { get; private set; }
/// <summary>
/// Gets or sets the Type
/// </summary>
public eFeedbackEventType Type { get; private set; }
/// <summary>
/// Constructor for BoolValue
/// </summary>
/// <param name="value">value to set</param>
public FeedbackEventArgs(bool value)
{
BoolValue = value;
Type = eFeedbackEventType.TypeBool;
}
/// <summary>
/// Constructor for IntValue
/// </summary>
/// <param name="value">value to set</param>
public FeedbackEventArgs(int value)
{
IntValue = value;
Type = eFeedbackEventType.TypeInt;
}
/// <summary>
/// Constructor for StringValue
/// </summary>
/// <param name="value">value to set</param>
public FeedbackEventArgs(string value)
{
StringValue = value;
Type = eFeedbackEventType.TypeString;
return (ushort)IntValue;
}
}
/// <summary>
/// Enumeration of eFeedbackEventType values
/// Gets or sets the StringValue
/// </summary>
public enum eFeedbackEventType
public string StringValue { get; private set; }
/// <summary>
/// Gets or sets the Type
/// </summary>
public eFeedbackEventType Type { get; private set; }
/// <summary>
/// Constructor for BoolValue
/// </summary>
/// <param name="value">value to set</param>
public FeedbackEventArgs(bool value)
{
/// <summary>
/// Boolean type feedback event
/// </summary>
TypeBool,
/// <summary>
/// Integer type feedback event
/// </summary>
TypeInt,
/// <summary>
/// String type feedback event
/// </summary>
TypeString
BoolValue = value;
Type = eFeedbackEventType.TypeBool;
}
}
/// <summary>
/// Constructor for IntValue
/// </summary>
/// <param name="value">value to set</param>
public FeedbackEventArgs(int value)
{
IntValue = value;
Type = eFeedbackEventType.TypeInt;
}
/// <summary>
/// Constructor for StringValue
/// </summary>
/// <param name="value">value to set</param>
public FeedbackEventArgs(string value)
{
StringValue = value;
Type = eFeedbackEventType.TypeString;
}
}
/// <summary>
/// Enumeration of eFeedbackEventType values
/// </summary>
public enum eFeedbackEventType
{
/// <summary>
/// Boolean type feedback event
/// </summary>
TypeBool,
/// <summary>
/// Integer type feedback event
/// </summary>
TypeInt,
/// <summary>
/// String type feedback event
/// </summary>
TypeString
}

View file

@ -5,132 +5,98 @@ using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro;
namespace PepperDash.Essentials.Core
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>
/// Represents a IntFeedback
/// Func evaluated on FireUpdate
/// </summary>
public class IntFeedback : Feedback
Func<int> ValueFunc;
List<UShortInputSig> LinkedInputSigs = new List<UShortInputSig>();
/// <summary>
/// Creates the feedback with the Func as described.
/// </summary>
/// <remarks>
/// While the linked sig value will be updated with the current value stored when it is linked to a EISC Bridge,
/// it will NOT reflect an actual value from a device until <seealso cref="FireUpdate"/> has been called
/// </remarks>
/// <param name="valueFunc">Delegate to invoke when this feedback needs to be updated</param>
public IntFeedback(Func<int> valueFunc)
: this(null, valueFunc)
{
/// <summary>
/// Gets or sets the IntValue
/// </summary>
public override int IntValue { get { return _IntValue; } } // ValueFunc.Invoke(); } }
int _IntValue;
/// <summary>
/// Gets or sets the UShortValue
/// </summary>
public ushort UShortValue { get { return (ushort)_IntValue; } }
}
//public override eCueType Type { get { return eCueType.Int; } }
/// <summary>
/// Creates the feedback with the Func as described.
/// </summary>
/// <remarks>
/// While the linked sig value will be updated with the current value stored when it is linked to a EISC Bridge,
/// it will NOT reflect an actual value from a device until <seealso cref="FireUpdate"/> has been called
/// </remarks>
/// <param name="key">Key to find this Feedback</param>
/// <param name="valueFunc">Delegate to invoke when this feedback needs to be updated</param>
public IntFeedback(string key, Func<int> valueFunc)
: base(key)
{
ValueFunc = valueFunc;
}
/// <summary>
/// Gets or sets the TestValue
/// </summary>
public int TestValue { get; private set; }
public void SetValueFunc(Func<int> newFunc)
{
ValueFunc = newFunc;
}
/// <summary>
/// Func evaluated on FireUpdate
/// </summary>
Func<int> ValueFunc;
List<UShortInputSig> LinkedInputSigs = new List<UShortInputSig>();
/// <summary>
/// Creates the feedback with the Func as described.
/// </summary>
/// <remarks>
/// While the linked sig value will be updated with the current value stored when it is linked to a EISC Bridge,
/// it will NOT reflect an actual value from a device until <seealso cref="FireUpdate"/> has been called
/// </remarks>
/// <param name="valueFunc">Delegate to invoke when this feedback needs to be updated</param>
[Obsolete("use constructor with Key parameter. This constructor will be removed in a future version")]
public IntFeedback(Func<int> valueFunc)
: this(null, valueFunc)
public override void FireUpdate()
{
var newValue = InTestMode ? TestValue : ValueFunc.Invoke();
if (newValue != _IntValue)
{
}
/// <summary>
/// Creates the feedback with the Func as described.
/// </summary>
/// <remarks>
/// While the linked sig value will be updated with the current value stored when it is linked to a EISC Bridge,
/// it will NOT reflect an actual value from a device until <seealso cref="FireUpdate"/> has been called
/// </remarks>
/// <param name="key">Key to find this Feedback</param>
/// <param name="valueFunc">Delegate to invoke when this feedback needs to be updated</param>
public IntFeedback(string key, Func<int> valueFunc)
: base(key)
{
ValueFunc = valueFunc;
}
/// <summary>
/// Sets the ValueFunc
/// </summary>
/// <param name="newFunc">function to set</param>
public void SetValueFunc(Func<int> newFunc)
{
ValueFunc = newFunc;
}
/// <summary>
/// FireUpdate method
/// </summary>
/// <inheritdoc />
public override void FireUpdate()
{
var newValue = InTestMode ? TestValue : ValueFunc.Invoke();
if (newValue != _IntValue)
{
_IntValue = newValue;
LinkedInputSigs.ForEach(s => UpdateSig(s));
OnOutputChange(newValue);
}
}
/// <summary>
/// LinkInputSig method
/// </summary>
public void LinkInputSig(UShortInputSig sig)
{
LinkedInputSigs.Add(sig);
UpdateSig(sig);
}
/// <summary>
/// UnlinkInputSig method
/// </summary>
public void UnlinkInputSig(UShortInputSig sig)
{
LinkedInputSigs.Remove(sig);
}
/// <summary>
/// ToString method
/// </summary>
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>
/// <summary>
/// SetTestValue method
/// </summary>
public void SetTestValue(int value)
{
TestValue = value;
InTestMode = true;
FireUpdate();
}
void UpdateSig(UShortInputSig sig)
{
sig.UShortValue = UShortValue;
_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;
}
}

View file

@ -5,112 +5,81 @@ using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro;
namespace PepperDash.Essentials.Core
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>
/// 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.
/// Used in testing. Set/Clear functions
/// </summary>
public class SerialFeedback : Feedback
public string TestValue { get; private set; }
List<StringInputSig> LinkedInputSigs = new List<StringInputSig>();
public SerialFeedback()
{
/// <summary>
/// Gets the SerialValue
/// </summary>
public override string SerialValue { get { return _SerialValue; } }
string _SerialValue;
}
//public override eCueType Type { get { return eCueType.Serial; } }
public SerialFeedback(string key)
: base(key)
{
}
/// <summary>
/// Gets or sets the TestValue
/// </summary>
public string TestValue { get; private set; }
public override void FireUpdate()
{
throw new NotImplementedException("This feedback type does not use Funcs");
}
List<StringInputSig> LinkedInputSigs = new List<StringInputSig>();
public void FireUpdate(string newValue)
{
_SerialValue = newValue;
LinkedInputSigs.ForEach(s => UpdateSig(s, newValue));
OnOutputChange(newValue);
}
/// <summary>
/// Constructor
/// </summary>
[Obsolete("use constructor with Key parameter. This constructor will be removed in a future version")]
public SerialFeedback()
{
}
public void LinkInputSig(StringInputSig sig)
{
LinkedInputSigs.Add(sig);
UpdateSig(sig);
}
/// <summary>
/// Constructor with Key parameter
/// </summary>
/// <param name="key">Key to find this Feedback</param>
public SerialFeedback(string key)
: base(key)
{
}
public void UnlinkInputSig(StringInputSig sig)
{
LinkedInputSigs.Remove(sig);
}
/// <summary>
/// FireUpdate method
/// </summary>
/// <inheritdoc />
public override void FireUpdate()
{
throw new NotImplementedException("This feedback type does not use Funcs");
}
public override string ToString()
{
return (InTestMode ? "TEST -- " : "") + SerialValue;
}
/// <summary>
/// FireUpdate method
/// </summary>
public void FireUpdate(string newValue)
{
_SerialValue = newValue;
LinkedInputSigs.ForEach(s => UpdateSig(s, newValue));
OnOutputChange(newValue);
}
/// <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);
}
/// <summary>
/// LinkInputSig method
/// </summary>
public void LinkInputSig(StringInputSig sig)
{
LinkedInputSigs.Add(sig);
UpdateSig(sig);
}
void UpdateSig(StringInputSig sig)
{
sig.StringValue = _SerialValue;
}
/// <summary>
/// UnlinkInputSig method
/// </summary>
public void UnlinkInputSig(StringInputSig sig)
{
LinkedInputSigs.Remove(sig);
}
/// <summary>
/// ToString method
/// </summary>
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>
/// <summary>
/// SetTestValue method
/// </summary>
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;
}
void UpdateSig(StringInputSig sig, string value)
{
sig.StringValue = value;
}
}

View file

@ -5,126 +5,98 @@ using System.Text;
using Crestron.SimplSharp;
using Crestron.SimplSharpPro;
namespace PepperDash.Essentials.Core
namespace PepperDash.Essentials.Core;
public class StringFeedback : Feedback
{
public override string StringValue { get { return _StringValue; } } // ValueFunc.Invoke(); } }
string _StringValue;
/// <summary>
/// Represents a StringFeedback
/// Used in testing. Set/Clear functions
/// </summary>
public class StringFeedback : Feedback
public string TestValue { get; private set; }
/// <summary>
/// Evaluated on FireUpdate
/// </summary>
public Func<string> ValueFunc { get; private set; }
List<StringInputSig> LinkedInputSigs = new List<StringInputSig>();
/// <summary>
/// Creates the feedback with the Func as described.
/// </summary>
/// <remarks>
/// While the linked sig value will be updated with the current value stored when it is linked to a EISC Bridge,
/// it will NOT reflect an actual value from a device until <seealso cref="FireUpdate"/> has been called
/// </remarks>
/// <param name="valueFunc">Delegate to invoke when this feedback needs to be updated</param>
public StringFeedback(Func<string> valueFunc)
: this(null, valueFunc)
{
/// <summary>
/// Gets or sets the StringValue
/// </summary>
public override string StringValue { get { return _StringValue; } } // ValueFunc.Invoke(); } }
string _StringValue;
}
/// <summary>
/// Gets or sets the TestValue
/// </summary>
public string TestValue { get; private set; }
/// <summary>
/// Creates the feedback with the Func as described.
/// </summary>
/// <remarks>
/// While the linked sig value will be updated with the current value stored when it is linked to a EISC Bridge,
/// it will NOT reflect an actual value from a device until <seealso cref="FireUpdate"/> has been called
/// </remarks>
/// <param name="key">Key to find this Feedback</param>
/// <param name="valueFunc">Delegate to invoke when this feedback needs to be updated</param>
public StringFeedback(string key, Func<string> valueFunc)
: base(key)
{
ValueFunc = valueFunc;
}
/// <summary>
/// Gets or sets the ValueFunc
/// </summary>
public Func<string> ValueFunc { get; private set; }
List<StringInputSig> LinkedInputSigs = new List<StringInputSig>();
public void SetValueFunc(Func<string> newFunc)
{
ValueFunc = newFunc;
}
/// <summary>
/// Creates the feedback with the Func as described.
/// </summary>
/// <remarks>
/// While the linked sig value will be updated with the current value stored when it is linked to a EISC Bridge,
/// it will NOT reflect an actual value from a device until <seealso cref="FireUpdate"/> has been called
/// </remarks>
/// <param name="valueFunc">Delegate to invoke when this feedback needs to be updated</param>
[Obsolete("use constructor with Key parameter. This constructor will be removed in a future version")]
public StringFeedback(Func<string> valueFunc)
: this(null, valueFunc)
public override void FireUpdate()
{
var newValue = InTestMode ? TestValue : ValueFunc.Invoke();
if (newValue != _StringValue)
{
}
/// <summary>
/// Creates the feedback with the Func as described.
/// </summary>
/// <remarks>
/// While the linked sig value will be updated with the current value stored when it is linked to a EISC Bridge,
/// it will NOT reflect an actual value from a device until <seealso cref="FireUpdate"/> has been called
/// </remarks>
/// <param name="key">Key to find this Feedback</param>
/// <param name="valueFunc">Delegate to invoke when this feedback needs to be updated</param>
public StringFeedback(string key, Func<string> valueFunc)
: base(key)
{
ValueFunc = valueFunc;
}
/// <summary>
/// Sets the ValueFunc
/// </summary>
/// <param name="newFunc">function to set</param>
public void SetValueFunc(Func<string> newFunc)
{
ValueFunc = newFunc;
}
/// <summary>
/// FireUpdate method
/// </summary>
/// <inheritdoc />
public override void FireUpdate()
{
var newValue = InTestMode ? TestValue : ValueFunc.Invoke();
if (newValue != _StringValue)
{
_StringValue = newValue;
LinkedInputSigs.ForEach(s => UpdateSig(s));
OnOutputChange(newValue);
}
}
/// <summary>
/// LinkInputSig method
/// </summary>
public void LinkInputSig(StringInputSig sig)
{
LinkedInputSigs.Add(sig);
UpdateSig(sig);
}
/// <summary>
/// UnlinkInputSig method
/// </summary>
public void UnlinkInputSig(StringInputSig sig)
{
LinkedInputSigs.Remove(sig);
}
/// <summary>
/// ToString method
/// </summary>
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>
/// <summary>
/// SetTestValue method
/// </summary>
public void SetTestValue(string value)
{
TestValue = value;
InTestMode = true;
FireUpdate();
}
void UpdateSig(StringInputSig sig)
{
sig.StringValue = _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;
}
}