From f5b589bc2e374a72a07d98e7c240b5b735098ad8 Mon Sep 17 00:00:00 2001 From: Heath Volmer Date: Mon, 25 Jun 2018 11:28:56 -0600 Subject: [PATCH] FeedbackEventArgs; various test things; few handler changes --- .../Devices/IUsageTracking.cs | 2 +- .../Feedbacks/FeedbackEventArgs.cs | 48 +++++++++++++++++++ .../Feedbacks/FeedbackTest.cs | 46 ++++++++++++++++++ .../Feedbacks/Feedbacks.cs | 38 ++++++++++----- .../PepperDash_Essentials_Core.csproj | 4 +- .../Essentials_DM/Essentials_DM.csproj | 2 +- .../Essentials Devices Common.csproj | 2 +- .../PepperDashEssentials.csproj | 8 +--- .../CotijaEssentialsHuddleSpaceRoomBridge.cs | 2 +- 9 files changed, 130 insertions(+), 22 deletions(-) create mode 100644 Essentials Core/PepperDashEssentialsBase/Feedbacks/FeedbackEventArgs.cs create mode 100644 Essentials Core/PepperDashEssentialsBase/Feedbacks/FeedbackTest.cs diff --git a/Essentials Core/PepperDashEssentialsBase/Devices/IUsageTracking.cs b/Essentials Core/PepperDashEssentialsBase/Devices/IUsageTracking.cs index 850f6ce4..6d234010 100644 --- a/Essentials Core/PepperDashEssentialsBase/Devices/IUsageTracking.cs +++ b/Essentials Core/PepperDashEssentialsBase/Devices/IUsageTracking.cs @@ -40,7 +40,7 @@ namespace PepperDash.Essentials.Core InUseTracker = new InUseTracking(); - InUseTracker.InUseFeedback.OutputChange +=new EventHandler(InUseFeedback_OutputChange); + InUseTracker.InUseFeedback.OutputChange += InUseFeedback_OutputChange; //new EventHandler(); } void InUseFeedback_OutputChange(object sender, EventArgs e) diff --git a/Essentials Core/PepperDashEssentialsBase/Feedbacks/FeedbackEventArgs.cs b/Essentials Core/PepperDashEssentialsBase/Feedbacks/FeedbackEventArgs.cs new file mode 100644 index 00000000..9a7f5c29 --- /dev/null +++ b/Essentials Core/PepperDashEssentialsBase/Feedbacks/FeedbackEventArgs.cs @@ -0,0 +1,48 @@ +using System; +using System.Collections.Generic; +using System.Linq; +using System.Text; +using Crestron.SimplSharp; + +namespace PepperDash.Essentials.Core +{ + public class FeedbackEventArgs : EventArgs + { + public bool BoolValue { get; private set; } + public int IntValue { get; private set; } + public ushort UShortValue + { + get + { + return (ushort)IntValue; + } + } + public string StringValue { get; private set; } + public eFeedbackEventType Type { get; private set; } + + public FeedbackEventArgs(bool value) + { + BoolValue = value; + Type = eFeedbackEventType.TypeBool; + } + + public FeedbackEventArgs(int value) + { + IntValue = value; + Type = eFeedbackEventType.TypeInt; + } + + public FeedbackEventArgs(string value) + { + StringValue = value; + Type = eFeedbackEventType.TypeString; + } + } + + public enum eFeedbackEventType + { + TypeBool, + TypeInt, + TypeString + } +} \ No newline at end of file diff --git a/Essentials Core/PepperDashEssentialsBase/Feedbacks/FeedbackTest.cs b/Essentials Core/PepperDashEssentialsBase/Feedbacks/FeedbackTest.cs new file mode 100644 index 00000000..87b94d95 --- /dev/null +++ b/Essentials Core/PepperDashEssentialsBase/Feedbacks/FeedbackTest.cs @@ -0,0 +1,46 @@ +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(sf_OutputChange); + } + + void sf_OutputChange(object sender, EventArgs e) + { + throw new NotImplementedException(); + } + + } + + public class Hmmm + { + IBasicCommunication comm; + + public Hmmm() + { + comm.TextReceived += new EventHandler(comm_TextReceived); + + var d = new Dictionary> + { + { "textReceived1", comm_TextReceived} + }; + } + + void comm_TextReceived(object sender, GenericCommMethodReceiveTextArgs e) + { + throw new NotImplementedException(); + } + } +} \ No newline at end of file diff --git a/Essentials Core/PepperDashEssentialsBase/Feedbacks/Feedbacks.cs b/Essentials Core/PepperDashEssentialsBase/Feedbacks/Feedbacks.cs index 10669b1e..d06afdd7 100644 --- a/Essentials Core/PepperDashEssentialsBase/Feedbacks/Feedbacks.cs +++ b/Essentials Core/PepperDashEssentialsBase/Feedbacks/Feedbacks.cs @@ -9,7 +9,7 @@ namespace PepperDash.Essentials.Core { public abstract class Feedback { - public event EventHandler OutputChange; + public event EventHandler OutputChange; public virtual bool BoolValue { get { return false; } } public virtual int IntValue { get { return 0; } } @@ -60,13 +60,29 @@ namespace PepperDash.Essentials.Core 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); - } + ///// + ///// 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)); + } + + 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)); + } } /// @@ -116,7 +132,7 @@ namespace PepperDash.Essentials.Core _BoolValue = newValue; LinkedInputSigs.ForEach(s => UpdateSig(s)); LinkedComplementInputSigs.ForEach(s => UpdateComplementSig(s)); - OnOutputChange(); + OnOutputChange(newValue); } } @@ -205,7 +221,7 @@ namespace PepperDash.Essentials.Core { _IntValue = newValue; LinkedInputSigs.ForEach(s => UpdateSig(s)); - OnOutputChange(); + OnOutputChange(newValue); } } @@ -282,7 +298,7 @@ namespace PepperDash.Essentials.Core { _StringValue = newValue; LinkedInputSigs.ForEach(s => UpdateSig(s)); - OnOutputChange(); + OnOutputChange(newValue); } } diff --git a/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj b/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj index d3b35297..f24f3778 100644 --- a/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj +++ b/Essentials Core/PepperDashEssentialsBase/PepperDash_Essentials_Core.csproj @@ -73,7 +73,7 @@ False - ..\..\..\pepperdash-simplsharp-core\Pepperdash Core\CLZ Builds\PepperDash_Core.dll + ..\..\..\pepperdash-simplsharp-core\CLZ Builds\PepperDash_Core.dll False @@ -111,6 +111,8 @@ + + diff --git a/Essentials DM/Essentials_DM/Essentials_DM.csproj b/Essentials DM/Essentials_DM/Essentials_DM.csproj index 3fc5cc46..6c80575f 100644 --- a/Essentials DM/Essentials_DM/Essentials_DM.csproj +++ b/Essentials DM/Essentials_DM/Essentials_DM.csproj @@ -57,7 +57,7 @@ False - ..\..\..\PepperDash.Core\Pepperdash Core\Pepperdash Core\bin\PepperDash_Core.dll + ..\..\..\pepperdash-simplsharp-core\CLZ Builds\PepperDash_Core.dll False diff --git a/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.csproj b/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.csproj index 27a958c1..e04417a4 100644 --- a/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.csproj +++ b/Essentials Devices Common/Essentials Devices Common/Essentials Devices Common.csproj @@ -65,7 +65,7 @@ False - ..\..\..\PepperDash.Core\Pepperdash Core\Pepperdash Core\bin\PepperDash_Core.dll + ..\..\..\pepperdash-simplsharp-core\CLZ Builds\PepperDash_Core.dll False diff --git a/Essentials/PepperDashEssentials/PepperDashEssentials.csproj b/Essentials/PepperDashEssentials/PepperDashEssentials.csproj index fb2aa9d6..c3bd3819 100644 --- a/Essentials/PepperDashEssentials/PepperDashEssentials.csproj +++ b/Essentials/PepperDashEssentials/PepperDashEssentials.csproj @@ -71,13 +71,9 @@ ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.UI.dll - - False - ..\..\..\pepperdash-portal-sync\SspPortalSync\SspPortalSync\bin\PepperDashCorePortalSync.dll - False - ..\..\Release Package\PepperDash_Core.dll + ..\..\..\pepperdash-simplsharp-core\CLZ Builds\PepperDash_Core.dll False @@ -101,7 +97,7 @@ False - ..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpReflectionInterface.dll + ..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpReflectionInterface.dll diff --git a/Essentials/PepperDashEssentials/Room/Cotija/RoomBridges/CotijaEssentialsHuddleSpaceRoomBridge.cs b/Essentials/PepperDashEssentials/Room/Cotija/RoomBridges/CotijaEssentialsHuddleSpaceRoomBridge.cs index 8bbdfcd5..80111ee0 100644 --- a/Essentials/PepperDashEssentials/Room/Cotija/RoomBridges/CotijaEssentialsHuddleSpaceRoomBridge.cs +++ b/Essentials/PepperDashEssentials/Room/Cotija/RoomBridges/CotijaEssentialsHuddleSpaceRoomBridge.cs @@ -67,7 +67,7 @@ namespace PepperDash.Essentials Room.CurrentVolumeDeviceChange += new EventHandler(Room_CurrentVolumeDeviceChange); - Room.OnFeedback.OutputChange += new EventHandler(OnFeedback_OutputChange); + Room.OnFeedback.OutputChange += OnFeedback_OutputChange; Room.IsCoolingDownFeedback.OutputChange += new EventHandler(IsCoolingDownFeedback_OutputChange); Room.IsWarmingUpFeedback.OutputChange += new EventHandler(IsWarmingUpFeedback_OutputChange);