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 { /// /// Base class for all feedback types /// public abstract class Feedback : IKeyed { /// /// Occurs when the output value changes /// public event EventHandler OutputChange; /// /// Gets or sets the Key /// public string Key { get; private set; } /// /// Gets or sets the BoolValue /// /// public virtual bool BoolValue { get { return false; } } /// /// Gets or sets the IntValue /// public virtual int IntValue { get { return 0; } } /// /// Gets or sets the StringValue /// public virtual string StringValue { get { return ""; } } /// /// Gets or sets the SerialValue /// public virtual string SerialValue { get { return ""; } } /// /// Gets or sets the InTestMode /// public bool InTestMode { get; protected set; } /// /// Base Constructor - empty /// [Obsolete("use constructor with Key parameter. This constructor will be removed in a future version")] protected Feedback() : this(null) { } /// /// Constructor with Key parameter /// /// The key for the feedback protected Feedback(string key) { if (key == null) Key = ""; else Key = key; } /// /// ClearTestValue method /// public void ClearTestValue() { InTestMode = false; FireUpdate(); } /// /// Fires an update synchronously /// public abstract void FireUpdate(); /// /// Fires the update asynchronously within a CrestronInvoke /// public void InvokeFireUpdate() { CrestronInvoke.BeginInvoke(o => FireUpdate()); } /// /// Helper method that fires event. Use this intstead of calling OutputChange /// //protected void OnOutputChange() //{ // if (OutputChange != null) OutputChange(this, EventArgs.Empty); //} protected void OnOutputChange(bool value) { if (OutputChange != null) OutputChange(this, new FeedbackEventArgs(value)); } /// /// Helper method that fires event. Use this intstead of calling OutputChange /// /// value to seed eventArgs protected void OnOutputChange(int value) { if (OutputChange != null) OutputChange(this, new FeedbackEventArgs(value)); } /// /// Helper method that fires event. Use this intstead of calling OutputChange /// /// value to seed eventArgs protected void OnOutputChange(string value) { if (OutputChange != null) OutputChange(this, new FeedbackEventArgs(value)); } } }