From 85d2e4e1dc461c038d60113e4fc5ffe63c957b00 Mon Sep 17 00:00:00 2001 From: jdevito Date: Thu, 30 Jan 2025 16:39:56 -0600 Subject: [PATCH] fix: update template repo 1. update workflow files 2. Add 3-series SLN and csproj files - Remove from project when using the template if not needed 3. Update 4-series SLN and csproj files 4. Moved SLN's to root of project 5. Rename *.cs files to identify naming convention of 'MakeModel' 6. Upate packages.config to reference latest Essentials v1 release --- .../EssentialsPlugins-builds-caller.yml | 2 + epi-make-model.3Series.sln | 20 + ....4Series.sln => epi-make-model.4Series.sln | 2 +- packages.config | 2 +- src/Directory.Build.props | 2 +- ...geJoinMap.cs => MakeModelBridgeJoinMap.cs} | 200 +++--- ...nfigObject.cs => MakeModelConfigObject.cs} | 10 +- ...onDevice.cs => MakeModelCrestronDevice.cs} | 18 +- ...inTemplateDevice.cs => MakeModelDevice.cs} | 597 +++++++++--------- ...TemplateFactory.cs => MakeModelFactory.cs} | 12 +- ...LogicDevice.cs => MakeModelLogicDevice.cs} | 12 +- src/PDT.EssentialsPluginTemplate.nuspec | 23 - ...I.csproj => epi-make-model.3Series.csproj} | 228 +++---- .....csproj => epi-make-model.4Series.csproj} | 24 +- 14 files changed, 579 insertions(+), 573 deletions(-) create mode 100644 epi-make-model.3Series.sln rename PDT.EssentialsPluginTemplate.EPI.4Series.sln => epi-make-model.4Series.sln (83%) rename src/{EssentialsPluginTemplateBridgeJoinMap.cs => MakeModelBridgeJoinMap.cs} (94%) rename src/{EssentialsPluginTemplateConfigObject.cs => MakeModelConfigObject.cs} (99%) rename src/{EssentialsPluginTemplateCrestronDevice.cs => MakeModelCrestronDevice.cs} (98%) rename src/{EssentialsPluginTemplateDevice.cs => MakeModelDevice.cs} (96%) rename src/{EssentialsPluginTemplateFactory.cs => MakeModelFactory.cs} (99%) rename src/{EssentialsPluginTemplateLogicDevice.cs => MakeModelLogicDevice.cs} (98%) delete mode 100644 src/PDT.EssentialsPluginTemplate.nuspec rename src/{PDT.EssentialsPluginTemplate.EPI.csproj => epi-make-model.3Series.csproj} (82%) rename src/{PDT.EssentialsPluginTemplate.EPI.4Series..csproj => epi-make-model.4Series.csproj} (67%) diff --git a/.github/workflows/EssentialsPlugins-builds-caller.yml b/.github/workflows/EssentialsPlugins-builds-caller.yml index 6d9f244..63a2fcd 100644 --- a/.github/workflows/EssentialsPlugins-builds-caller.yml +++ b/.github/workflows/EssentialsPlugins-builds-caller.yml @@ -9,6 +9,7 @@ jobs: getVersion: uses: PepperDash/workflow-templates/.github/workflows/essentialsplugins-getversion.yml@main secrets: inherit + build-3Series: uses: PepperDash/workflow-templates/.github/workflows/essentialsplugins-3Series-builds.yml@main secrets: inherit @@ -19,6 +20,7 @@ jobs: version: ${{ needs.getVersion.outputs.version }} tag: ${{ needs.getVersion.outputs.tag }} channel: ${{ needs.getVersion.outputs.channel }} + build-4Series: uses: PepperDash/workflow-templates/.github/workflows/essentialsplugins-4Series-builds.yml@main secrets: inherit diff --git a/epi-make-model.3Series.sln b/epi-make-model.3Series.sln new file mode 100644 index 0000000..b106642 --- /dev/null +++ b/epi-make-model.3Series.sln @@ -0,0 +1,20 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "epi-make-model.3Series", "src\epi-make-model.3Series.csproj", "{9D249E47-8F95-4437-A6BB-563510287AD1}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Any CPU = Debug|Any CPU + Release|Any CPU = Release|Any CPU + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {9D249E47-8F95-4437-A6BB-563510287AD1}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9D249E47-8F95-4437-A6BB-563510287AD1}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9D249E47-8F95-4437-A6BB-563510287AD1}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9D249E47-8F95-4437-A6BB-563510287AD1}.Release|Any CPU.Build.0 = Release|Any CPU + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/PDT.EssentialsPluginTemplate.EPI.4Series.sln b/epi-make-model.4Series.sln similarity index 83% rename from PDT.EssentialsPluginTemplate.EPI.4Series.sln rename to epi-make-model.4Series.sln index af0013f..e073161 100644 --- a/PDT.EssentialsPluginTemplate.EPI.4Series.sln +++ b/epi-make-model.4Series.sln @@ -3,7 +3,7 @@ Microsoft Visual Studio Solution File, Format Version 12.00 # Visual Studio Version 17 VisualStudioVersion = 17.11.35327.3 MinimumVisualStudioVersion = 10.0.40219.1 -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "PDT.EssentialsPluginTemplate.EPI.4Series.", "src\PDT.EssentialsPluginTemplate.EPI.4Series..csproj", "{52E6E0A0-A710-4B5F-AF52-08816F5C99BB}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "epi-make-model.4Series", "src\epi-make-model.4Series.csproj", "{52E6E0A0-A710-4B5F-AF52-08816F5C99BB}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution diff --git a/packages.config b/packages.config index 2a12f4c..c0df495 100644 --- a/packages.config +++ b/packages.config @@ -1,3 +1,3 @@ - + \ No newline at end of file diff --git a/src/Directory.Build.props b/src/Directory.Build.props index ef365ad..db59da5 100644 --- a/src/Directory.Build.props +++ b/src/Directory.Build.props @@ -5,7 +5,7 @@ PepperDash Technologies PepperDash Technologies PepperDash Essentials Plugin Template - Copyright © 2024 + Copyright © 2025 https://github.com/PepperDash/EssentialsPluginTemplate.git git Crestron; 4series diff --git a/src/EssentialsPluginTemplateBridgeJoinMap.cs b/src/MakeModelBridgeJoinMap.cs similarity index 94% rename from src/EssentialsPluginTemplateBridgeJoinMap.cs rename to src/MakeModelBridgeJoinMap.cs index 140d021..0d20a8f 100644 --- a/src/EssentialsPluginTemplateBridgeJoinMap.cs +++ b/src/MakeModelBridgeJoinMap.cs @@ -1,101 +1,101 @@ -using PepperDash.Essentials.Core; - -namespace EssentialsPluginTemplate -{ - /// - /// Plugin device Bridge Join Map - /// - /// - /// Rename the class to match the device plugin being developed. Reference Essentials JoinMaps, if one exists for the device plugin being developed - /// - /// - /// - /// "EssentialsPluginBridgeJoinMapTemplate" renamed to "SamsungMdcBridgeJoinMap" - /// - public class EssentialsPluginTemplateBridgeJoinMap : JoinMapBaseAdvanced - { - #region Digital - - // TODO [ ] Add digital joins below plugin being developed - - [JoinName("IsOnline")] - public JoinDataComplete IsOnline = new JoinDataComplete( - new JoinData - { - JoinNumber = 1, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Is Online", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Digital - }); - - [JoinName("Connect")] - public JoinDataComplete Connect = new JoinDataComplete( - new JoinData - { - JoinNumber = 2, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Connect (Held)/Disconnect (Release) & corresponding feedback", - JoinCapabilities = eJoinCapabilities.ToFromSIMPL, - JoinType = eJoinType.Digital - }); - - #endregion - - - #region Analog - - // TODO [ ] Add analog joins below plugin being developed - - [JoinName("Status")] - public JoinDataComplete Status = new JoinDataComplete( - new JoinData - { - JoinNumber = 1, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Socket Status", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Analog - }); - - #endregion - - - #region Serial - - // TODO [ ] Add serial joins below plugin being developed - - public JoinDataComplete DeviceName = new JoinDataComplete( - new JoinData - { - JoinNumber = 1, - JoinSpan = 1 - }, - new JoinMetadata - { - Description = "Device Name", - JoinCapabilities = eJoinCapabilities.ToSIMPL, - JoinType = eJoinType.Serial - }); - - #endregion - - /// - /// Plugin device BridgeJoinMap constructor - /// - /// This will be the join it starts on the EISC bridge - public EssentialsPluginTemplateBridgeJoinMap(uint joinStart) - : base(joinStart, typeof(EssentialsPluginTemplateBridgeJoinMap)) - { - } - } +using PepperDash.Essentials.Core; + +namespace PepperDash.Essentials.Plugin +{ + /// + /// Plugin device Bridge Join Map + /// + /// + /// Rename the class to match the device plugin being developed. Reference Essentials JoinMaps, if one exists for the device plugin being developed + /// + /// + /// + /// "EssentialsPluginBridgeJoinMapTemplate" renamed to "SamsungMdcBridgeJoinMap" + /// + public class EssentialsPluginTemplateBridgeJoinMap : JoinMapBaseAdvanced + { + #region Digital + + // TODO [ ] Add digital joins below plugin being developed + + [JoinName("IsOnline")] + public JoinDataComplete IsOnline = new JoinDataComplete( + new JoinData + { + JoinNumber = 1, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Is Online", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Digital + }); + + [JoinName("Connect")] + public JoinDataComplete Connect = new JoinDataComplete( + new JoinData + { + JoinNumber = 2, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Connect (Held)/Disconnect (Release) & corresponding feedback", + JoinCapabilities = eJoinCapabilities.ToFromSIMPL, + JoinType = eJoinType.Digital + }); + + #endregion + + + #region Analog + + // TODO [ ] Add analog joins below plugin being developed + + [JoinName("Status")] + public JoinDataComplete Status = new JoinDataComplete( + new JoinData + { + JoinNumber = 1, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Socket Status", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Analog + }); + + #endregion + + + #region Serial + + // TODO [ ] Add serial joins below plugin being developed + + public JoinDataComplete DeviceName = new JoinDataComplete( + new JoinData + { + JoinNumber = 1, + JoinSpan = 1 + }, + new JoinMetadata + { + Description = "Device Name", + JoinCapabilities = eJoinCapabilities.ToSIMPL, + JoinType = eJoinType.Serial + }); + + #endregion + + /// + /// Plugin device BridgeJoinMap constructor + /// + /// This will be the join it starts on the EISC bridge + public EssentialsPluginTemplateBridgeJoinMap(uint joinStart) + : base(joinStart, typeof(EssentialsPluginTemplateBridgeJoinMap)) + { + } + } } \ No newline at end of file diff --git a/src/EssentialsPluginTemplateConfigObject.cs b/src/MakeModelConfigObject.cs similarity index 99% rename from src/EssentialsPluginTemplateConfigObject.cs rename to src/MakeModelConfigObject.cs index e216796..b247414 100644 --- a/src/EssentialsPluginTemplateConfigObject.cs +++ b/src/MakeModelConfigObject.cs @@ -1,8 +1,8 @@ -using System.Collections.Generic; -using Newtonsoft.Json; -using PepperDash.Essentials.Core; - -namespace EssentialsPluginTemplate +using System.Collections.Generic; +using Newtonsoft.Json; +using PepperDash.Essentials.Core; + +namespace PepperDash.Essentials.Plugin { /// /// Plugin device configuration object diff --git a/src/EssentialsPluginTemplateCrestronDevice.cs b/src/MakeModelCrestronDevice.cs similarity index 98% rename from src/EssentialsPluginTemplateCrestronDevice.cs rename to src/MakeModelCrestronDevice.cs index 8836cc5..71c91c1 100644 --- a/src/EssentialsPluginTemplateCrestronDevice.cs +++ b/src/MakeModelCrestronDevice.cs @@ -1,13 +1,13 @@ // For Basic SIMPL# Classes -// For Basic SIMPL#Pro classes - -using Crestron.SimplSharpPro.DeviceSupport; -using Crestron.SimplSharpPro; -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; - -namespace EssentialsPluginTemplate +// For Basic SIMPL#Pro classes + +using Crestron.SimplSharpPro; +using Crestron.SimplSharpPro.DeviceSupport; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; + +namespace PepperDash.Essentials.Plugin { /// /// Plugin device diff --git a/src/EssentialsPluginTemplateDevice.cs b/src/MakeModelDevice.cs similarity index 96% rename from src/EssentialsPluginTemplateDevice.cs rename to src/MakeModelDevice.cs index b6d2031..da423a2 100644 --- a/src/EssentialsPluginTemplateDevice.cs +++ b/src/MakeModelDevice.cs @@ -1,299 +1,298 @@ -// For Basic SIMPL# Classes -// For Basic SIMPL#Pro classes - -using Crestron.SimplSharpPro.DeviceSupport; -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; -using PepperDash.Essentials.Core.Queues; - - -namespace EssentialsPluginTemplate -{ - /// - /// Plugin device template for third party devices that use IBasicCommunication - /// - /// - /// Rename the class to match the device plugin being developed. - /// - /// - /// "EssentialsPluginDeviceTemplate" renamed to "SamsungMdcDevice" - /// - public class EssentialsPluginTemplateDevice : EssentialsBridgeableDevice - { - /// - /// It is often desirable to store the config - /// - private EssentialsPluginTemplateConfigObject _config; - - /// - /// Provides a queue and dedicated worker thread for processing feedback messages from a device. - /// - private GenericQueue ReceiveQueue; - - #region IBasicCommunication Properties and Constructor. Remove if not needed. - - // TODO [ ] Add, modify, remove properties and fields as needed for the plugin being developed - private readonly IBasicCommunication _comms; - private readonly GenericCommunicationMonitor _commsMonitor; - - // _comms gather for ASCII based API's - // TODO [ ] If not using an ASCII based API, delete the properties below - private readonly CommunicationGather _commsGather; - - /// - /// Set this value to that of the delimiter used by the API (if applicable) - /// - private const string CommsDelimiter = "\r"; - - // _comms byte buffer for HEX/byte based API's - // TODO [ ] If not using an HEX/byte based API, delete the properties below - private byte[] _commsByteBuffer = { }; - - - - /// - /// Connects/disconnects the comms of the plugin device - /// - /// - /// triggers the _comms.Connect/Disconnect as well as thee comms monitor start/stop - /// - public bool Connect - { - get { return _comms.IsConnected; } - set - { - if (value) - { - _comms.Connect(); - _commsMonitor.Start(); - } - else - { - _comms.Disconnect(); - _commsMonitor.Stop(); - } - } - } - - /// - /// Reports connect feedback through the bridge - /// - public BoolFeedback ConnectFeedback { get; private set; } - - /// - /// Reports online feedback through the bridge - /// - public BoolFeedback OnlineFeedback { get; private set; } - - /// - /// Reports socket status feedback through the bridge - /// - public IntFeedback StatusFeedback { get; private set; } - - /// - /// Plugin device constructor for devices that need IBasicCommunication - /// - /// - /// - /// - /// - public EssentialsPluginTemplateDevice(string key, string name, EssentialsPluginTemplateConfigObject config, IBasicCommunication comms) - : base(key, name) - { - Debug.Console(0, this, "Constructing new {0} instance", name); - - // TODO [ ] Update the constructor as needed for the plugin device being developed - - _config = config; - - ReceiveQueue = new GenericQueue(key + "-rxqueue"); // If you need to set the thread priority, use one of the available overloaded constructors. - - ConnectFeedback = new BoolFeedback(() => Connect); - OnlineFeedback = new BoolFeedback(() => _commsMonitor.IsOnline); - StatusFeedback = new IntFeedback(() => (int)_commsMonitor.Status); - - _comms = comms; - _commsMonitor = new GenericCommunicationMonitor(this, _comms, _config.PollTimeMs, _config.WarningTimeoutMs, _config.ErrorTimeoutMs, Poll); - - var socket = _comms as ISocketStatus; - if (socket != null) - { - // device comms is IP **ELSE** device comms is RS232 - socket.ConnectionChange += socket_ConnectionChange; - Connect = true; - } - - #region Communication data event handlers. Comment out any that don't apply to the API type - - // Only one of the below handlers should be necessary. - - // _comms gather for any API that has a defined delimiter - // TODO [ ] If not using an ASCII based API, remove the line below - _commsGather = new CommunicationGather(_comms, CommsDelimiter); - _commsGather.LineReceived += Handle_LineRecieved; - - // _comms byte buffer for HEX/byte based API's with no delimiter - // TODO [ ] If not using an HEX/byte based API, remove the line below - _comms.BytesReceived += Handle_BytesReceived; - - // _comms byte buffer for HEX/byte based API's with no delimiter - // TODO [ ] If not using an HEX/byte based API, remove the line below - _comms.TextReceived += Handle_TextReceived; - - #endregion - } - - - private void socket_ConnectionChange(object sender, GenericSocketStatusChageEventArgs args) - { - if (ConnectFeedback != null) - ConnectFeedback.FireUpdate(); - - if (StatusFeedback != null) - StatusFeedback.FireUpdate(); - } - - // TODO [ ] If not using an API with a delimeter, delete the method below - private void Handle_LineRecieved(object sender, GenericCommMethodReceiveTextArgs args) - { - // TODO [ ] Implement method - - // Enqueues the message to be processed in a dedicated thread, but the specified method - ReceiveQueue.Enqueue(new ProcessStringMessage(args.Text, ProcessFeedbackMessage)); - } - - // TODO [ ] If not using an HEX/byte based API with no delimeter, delete the method below - private void Handle_BytesReceived(object sender, GenericCommMethodReceiveBytesArgs args) - { - // TODO [ ] Implement method - throw new System.NotImplementedException(); - } - - // TODO [ ] If not using an ASCII based API with no delimeter, delete the method below - void Handle_TextReceived(object sender, GenericCommMethodReceiveTextArgs e) - { - // TODO [ ] Implement method - throw new System.NotImplementedException(); - } - - /// - /// This method should perform any necessary parsing of feedback messages from the device - /// - /// - void ProcessFeedbackMessage(string message) - { - - } - - - // TODO [ ] If not using an ACII based API, delete the properties below - /// - /// Sends text to the device plugin comms - /// - /// - /// Can be used to test commands with the device plugin using the DEVPROPS and DEVJSON console commands - /// - /// Command to be sent - public void SendText(string text) - { - if (string.IsNullOrEmpty(text)) return; - - _comms.SendText(string.Format("{0}{1}", text, CommsDelimiter)); - } - - // TODO [ ] If not using an HEX/byte based API, delete the properties below - /// - /// Sends bytes to the device plugin comms - /// - /// - /// Can be used to test commands with the device plugin using the DEVPROPS and DEVJSON console commands - /// - /// Bytes to be sent - public void SendBytes(byte[] bytes) - { - if (bytes == null) return; - - _comms.SendBytes(bytes); - } - - /// - /// Polls the device - /// - /// - /// Poll method is used by the communication monitor. Update the poll method as needed for the plugin being developed - /// - public void Poll() - { - // TODO [ ] Update Poll method as needed for the plugin being developed - // Example: SendText("getstatus"); - throw new System.NotImplementedException(); - } - - #endregion - - - #region Overrides of EssentialsBridgeableDevice - - /// - /// Links the plugin device to the EISC bridge - /// - /// - /// - /// - /// - public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) - { - var joinMap = new EssentialsPluginTemplateBridgeJoinMap(joinStart); - - // This adds the join map to the collection on the bridge - if (bridge != null) - { - bridge.AddJoinMap(Key, joinMap); - } - - var customJoins = JoinMapHelper.TryGetJoinMapAdvancedForDevice(joinMapKey); - - if (customJoins != null) - { - joinMap.SetCustomJoinData(customJoins); - } - - Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); - Debug.Console(0, "Linking to Bridge Type {0}", GetType().Name); - - // TODO [ ] Implement bridge links as needed - - // links to bridge - trilist.SetString(joinMap.DeviceName.JoinNumber, Name); - - trilist.SetBoolSigAction(joinMap.Connect.JoinNumber, sig => Connect = sig); - ConnectFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Connect.JoinNumber]); - - StatusFeedback.LinkInputSig(trilist.UShortInput[joinMap.Status.JoinNumber]); - OnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); - - UpdateFeedbacks(); - - trilist.OnlineStatusChange += (o, a) => - { - if (!a.DeviceOnLine) return; - - trilist.SetString(joinMap.DeviceName.JoinNumber, Name); - UpdateFeedbacks(); - }; - } - - private void UpdateFeedbacks() - { - // TODO [ ] Update as needed for the plugin being developed - ConnectFeedback.FireUpdate(); - OnlineFeedback.FireUpdate(); - StatusFeedback.FireUpdate(); - } - - #endregion - - } -} - +// For Basic SIMPL# Classes +// For Basic SIMPL#Pro classes + +using Crestron.SimplSharpPro.DeviceSupport; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; +using PepperDash.Essentials.Core.Queues; + +namespace PepperDash.Essentials.Plugin +{ + /// + /// Plugin device template for third party devices that use IBasicCommunication + /// + /// + /// Rename the class to match the device plugin being developed. + /// + /// + /// "EssentialsPluginDeviceTemplate" renamed to "SamsungMdcDevice" + /// + public class EssentialsPluginTemplateDevice : EssentialsBridgeableDevice + { + /// + /// It is often desirable to store the config + /// + private EssentialsPluginTemplateConfigObject _config; + + /// + /// Provides a queue and dedicated worker thread for processing feedback messages from a device. + /// + private GenericQueue ReceiveQueue; + + #region IBasicCommunication Properties and Constructor. Remove if not needed. + + // TODO [ ] Add, modify, remove properties and fields as needed for the plugin being developed + private readonly IBasicCommunication _comms; + private readonly GenericCommunicationMonitor _commsMonitor; + + // _comms gather for ASCII based API's + // TODO [ ] If not using an ASCII based API, delete the properties below + private readonly CommunicationGather _commsGather; + + /// + /// Set this value to that of the delimiter used by the API (if applicable) + /// + private const string CommsDelimiter = "\r"; + + // _comms byte buffer for HEX/byte based API's + // TODO [ ] If not using an HEX/byte based API, delete the properties below + private byte[] _commsByteBuffer = { }; + + + + /// + /// Connects/disconnects the comms of the plugin device + /// + /// + /// triggers the _comms.Connect/Disconnect as well as thee comms monitor start/stop + /// + public bool Connect + { + get { return _comms.IsConnected; } + set + { + if (value) + { + _comms.Connect(); + _commsMonitor.Start(); + } + else + { + _comms.Disconnect(); + _commsMonitor.Stop(); + } + } + } + + /// + /// Reports connect feedback through the bridge + /// + public BoolFeedback ConnectFeedback { get; private set; } + + /// + /// Reports online feedback through the bridge + /// + public BoolFeedback OnlineFeedback { get; private set; } + + /// + /// Reports socket status feedback through the bridge + /// + public IntFeedback StatusFeedback { get; private set; } + + /// + /// Plugin device constructor for devices that need IBasicCommunication + /// + /// + /// + /// + /// + public EssentialsPluginTemplateDevice(string key, string name, EssentialsPluginTemplateConfigObject config, IBasicCommunication comms) + : base(key, name) + { + Debug.Console(0, this, "Constructing new {0} instance", name); + + // TODO [ ] Update the constructor as needed for the plugin device being developed + + _config = config; + + ReceiveQueue = new GenericQueue(key + "-rxqueue"); // If you need to set the thread priority, use one of the available overloaded constructors. + + ConnectFeedback = new BoolFeedback(() => Connect); + OnlineFeedback = new BoolFeedback(() => _commsMonitor.IsOnline); + StatusFeedback = new IntFeedback(() => (int)_commsMonitor.Status); + + _comms = comms; + _commsMonitor = new GenericCommunicationMonitor(this, _comms, _config.PollTimeMs, _config.WarningTimeoutMs, _config.ErrorTimeoutMs, Poll); + + var socket = _comms as ISocketStatus; + if (socket != null) + { + // device comms is IP **ELSE** device comms is RS232 + socket.ConnectionChange += socket_ConnectionChange; + Connect = true; + } + + #region Communication data event handlers. Comment out any that don't apply to the API type + + // Only one of the below handlers should be necessary. + + // _comms gather for any API that has a defined delimiter + // TODO [ ] If not using an ASCII based API, remove the line below + _commsGather = new CommunicationGather(_comms, CommsDelimiter); + _commsGather.LineReceived += Handle_LineRecieved; + + // _comms byte buffer for HEX/byte based API's with no delimiter + // TODO [ ] If not using an HEX/byte based API, remove the line below + _comms.BytesReceived += Handle_BytesReceived; + + // _comms byte buffer for HEX/byte based API's with no delimiter + // TODO [ ] If not using an HEX/byte based API, remove the line below + _comms.TextReceived += Handle_TextReceived; + + #endregion + } + + + private void socket_ConnectionChange(object sender, GenericSocketStatusChageEventArgs args) + { + if (ConnectFeedback != null) + ConnectFeedback.FireUpdate(); + + if (StatusFeedback != null) + StatusFeedback.FireUpdate(); + } + + // TODO [ ] If not using an API with a delimeter, delete the method below + private void Handle_LineRecieved(object sender, GenericCommMethodReceiveTextArgs args) + { + // TODO [ ] Implement method + + // Enqueues the message to be processed in a dedicated thread, but the specified method + ReceiveQueue.Enqueue(new ProcessStringMessage(args.Text, ProcessFeedbackMessage)); + } + + // TODO [ ] If not using an HEX/byte based API with no delimeter, delete the method below + private void Handle_BytesReceived(object sender, GenericCommMethodReceiveBytesArgs args) + { + // TODO [ ] Implement method + throw new System.NotImplementedException(); + } + + // TODO [ ] If not using an ASCII based API with no delimeter, delete the method below + void Handle_TextReceived(object sender, GenericCommMethodReceiveTextArgs e) + { + // TODO [ ] Implement method + throw new System.NotImplementedException(); + } + + /// + /// This method should perform any necessary parsing of feedback messages from the device + /// + /// + void ProcessFeedbackMessage(string message) + { + + } + + + // TODO [ ] If not using an ACII based API, delete the properties below + /// + /// Sends text to the device plugin comms + /// + /// + /// Can be used to test commands with the device plugin using the DEVPROPS and DEVJSON console commands + /// + /// Command to be sent + public void SendText(string text) + { + if (string.IsNullOrEmpty(text)) return; + + _comms.SendText(string.Format("{0}{1}", text, CommsDelimiter)); + } + + // TODO [ ] If not using an HEX/byte based API, delete the properties below + /// + /// Sends bytes to the device plugin comms + /// + /// + /// Can be used to test commands with the device plugin using the DEVPROPS and DEVJSON console commands + /// + /// Bytes to be sent + public void SendBytes(byte[] bytes) + { + if (bytes == null) return; + + _comms.SendBytes(bytes); + } + + /// + /// Polls the device + /// + /// + /// Poll method is used by the communication monitor. Update the poll method as needed for the plugin being developed + /// + public void Poll() + { + // TODO [ ] Update Poll method as needed for the plugin being developed + // Example: SendText("getstatus"); + throw new System.NotImplementedException(); + } + + #endregion + + + #region Overrides of EssentialsBridgeableDevice + + /// + /// Links the plugin device to the EISC bridge + /// + /// + /// + /// + /// + public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge) + { + var joinMap = new EssentialsPluginTemplateBridgeJoinMap(joinStart); + + // This adds the join map to the collection on the bridge + if (bridge != null) + { + bridge.AddJoinMap(Key, joinMap); + } + + var customJoins = JoinMapHelper.TryGetJoinMapAdvancedForDevice(joinMapKey); + + if (customJoins != null) + { + joinMap.SetCustomJoinData(customJoins); + } + + Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X")); + Debug.Console(0, "Linking to Bridge Type {0}", GetType().Name); + + // TODO [ ] Implement bridge links as needed + + // links to bridge + trilist.SetString(joinMap.DeviceName.JoinNumber, Name); + + trilist.SetBoolSigAction(joinMap.Connect.JoinNumber, sig => Connect = sig); + ConnectFeedback.LinkInputSig(trilist.BooleanInput[joinMap.Connect.JoinNumber]); + + StatusFeedback.LinkInputSig(trilist.UShortInput[joinMap.Status.JoinNumber]); + OnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]); + + UpdateFeedbacks(); + + trilist.OnlineStatusChange += (o, a) => + { + if (!a.DeviceOnLine) return; + + trilist.SetString(joinMap.DeviceName.JoinNumber, Name); + UpdateFeedbacks(); + }; + } + + private void UpdateFeedbacks() + { + // TODO [ ] Update as needed for the plugin being developed + ConnectFeedback.FireUpdate(); + OnlineFeedback.FireUpdate(); + StatusFeedback.FireUpdate(); + } + + #endregion + + } +} + diff --git a/src/EssentialsPluginTemplateFactory.cs b/src/MakeModelFactory.cs similarity index 99% rename from src/EssentialsPluginTemplateFactory.cs rename to src/MakeModelFactory.cs index 0b58f52..e94994a 100644 --- a/src/EssentialsPluginTemplateFactory.cs +++ b/src/MakeModelFactory.cs @@ -1,9 +1,9 @@ -using System.Collections.Generic; -using PepperDash.Core; -using PepperDash.Essentials.Core; -using Crestron.SimplSharpPro.UI; - -namespace EssentialsPluginTemplate +using System.Collections.Generic; +using Crestron.SimplSharpPro.UI; +using PepperDash.Core; +using PepperDash.Essentials.Core; + +namespace PepperDash.Essentials.Plugin { /// /// Plugin device factory for devices that use IBasicCommunication diff --git a/src/EssentialsPluginTemplateLogicDevice.cs b/src/MakeModelLogicDevice.cs similarity index 98% rename from src/EssentialsPluginTemplateLogicDevice.cs rename to src/MakeModelLogicDevice.cs index 0685a43..44aeeec 100644 --- a/src/EssentialsPluginTemplateLogicDevice.cs +++ b/src/MakeModelLogicDevice.cs @@ -1,9 +1,9 @@ -using Crestron.SimplSharpPro.DeviceSupport; -using PepperDash.Core; -using PepperDash.Essentials.Core; -using PepperDash.Essentials.Core.Bridges; - -namespace EssentialsPluginTemplate +using Crestron.SimplSharpPro.DeviceSupport; +using PepperDash.Core; +using PepperDash.Essentials.Core; +using PepperDash.Essentials.Core.Bridges; + +namespace PepperDash.Essentials.Plugin { /// /// Plugin device template for logic devices that don't communicate outside the program diff --git a/src/PDT.EssentialsPluginTemplate.nuspec b/src/PDT.EssentialsPluginTemplate.nuspec deleted file mode 100644 index e72f807..0000000 --- a/src/PDT.EssentialsPluginTemplate.nuspec +++ /dev/null @@ -1,23 +0,0 @@ - - - - PDT.EssentialsPluginTemplate - docs\README.md - 2.0.2 - Essentials Plugin Template - PepperDash Technologies - pepperdash - false - MIT - https://github.com/PepperDash/EssentialsPluginTemplate - Copyright 2022 - This software iserves as a template for generating new Essentials-Compliant plugins - crestron 3series 4series essentials pepperdash pepperdashessentials epi essentials plugin - - - - - - - - \ No newline at end of file diff --git a/src/PDT.EssentialsPluginTemplate.EPI.csproj b/src/epi-make-model.3Series.csproj similarity index 82% rename from src/PDT.EssentialsPluginTemplate.EPI.csproj rename to src/epi-make-model.3Series.csproj index edda00c..03aa3ce 100644 --- a/src/PDT.EssentialsPluginTemplate.EPI.csproj +++ b/src/epi-make-model.3Series.csproj @@ -1,115 +1,115 @@ - - - Release - AnyCPU - 9.0.30729 - 2.0 - {9D249E47-8F95-4437-A6BB-563510287AD1} - Library - Properties - PDT.EssentialsPluginTemplate.EPI - PDT.EssentialsPluginTemplate.EPI - {0B4745B0-194B-4BB6-8E21-E9057CA92300};{4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} - WindowsCE - E2BECB1F-8C8C-41ba-B736-9BE7D946A398 - 5.0 - SmartDeviceProject1 - v3.5 - Windows CE - - - - - .allowedReferenceRelatedFileExtensions - true - full - false - bin\Debug\ - DEBUG;TRACE; - prompt - 4 - 512 - true - true - off - - - .allowedReferenceRelatedFileExtensions - none - true - bin\Release\ - prompt - 4 - 512 - true - true - off - - - - False - ..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.UI.dll - - - False - ..\packages\PepperDashEssentials\lib\net35\Essentials Devices Common.dll - - - - False - ..\packages\PepperDashEssentials\lib\net35\PepperDashEssentials.dll - - - False - ..\packages\PepperDashEssentials\lib\net35\PepperDash_Core.dll - - - False - ..\packages\PepperDashEssentials\lib\net35\PepperDash_Essentials_Core.dll - - - False - ..\packages\PepperDashEssentials\lib\net35\PepperDash_Essentials_DM.dll - - - False - ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpCustomAttributesInterface.dll - False - - - False - ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpHelperInterface.dll - False - - - False - ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpNewtonsoft.dll - - - False - ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpPro.exe - False - - - False - ..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SimplSharpReflectionInterface.dll - - - - - - - - - - - - - - - - - - rem S# Pro preparation will execute after these operations - + + + Release + AnyCPU + 9.0.30729 + 2.0 + {9D249E47-8F95-4437-A6BB-563510287AD1} + Library + Properties + PepperDash.Essentials.Plugin + MakeModelPlugin + {0B4745B0-194B-4BB6-8E21-E9057CA92300};{4D628B5B-2FBC-4AA6-8C16-197242AEB884};{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC} + WindowsCE + E2BECB1F-8C8C-41ba-B736-9BE7D946A398 + 5.0 + SmartDeviceProject1 + v3.5 + Windows CE + + + + + .allowedReferenceRelatedFileExtensions + true + full + false + bin\Debug\ + DEBUG;TRACE; + prompt + 4 + 512 + true + true + off + + + .allowedReferenceRelatedFileExtensions + none + true + bin\Release\ + prompt + 4 + 512 + true + true + off + + + + False + C:\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.UI.dll + + + False + ..\packages\PepperDashEssentials\lib\net35\Essentials Devices Common.dll + + + + False + ..\packages\PepperDashEssentials\lib\net35\PepperDashEssentials.dll + + + False + ..\packages\PepperDashEssentials\lib\net35\PepperDash_Core.dll + + + False + ..\packages\PepperDashEssentials\lib\net35\PepperDash_Essentials_Core.dll + + + False + ..\packages\PepperDashEssentials\lib\net35\PepperDash_Essentials_DM.dll + + + False + C:\ProgramData\Crestron\SDK\SimplSharpCustomAttributesInterface.dll + False + + + False + C:\ProgramData\Crestron\SDK\SimplSharpHelperInterface.dll + False + + + False + C:\ProgramData\Crestron\SDK\SimplSharpNewtonsoft.dll + + + False + C:\ProgramData\Crestron\SDK\SimplSharpPro.exe + False + + + False + C:\ProgramData\Crestron\SDK\SimplSharpReflectionInterface.dll + + + + + + + + + + + + + + + + + + rem S# Pro preparation will execute after these operations + \ No newline at end of file diff --git a/src/PDT.EssentialsPluginTemplate.EPI.4Series..csproj b/src/epi-make-model.4Series.csproj similarity index 67% rename from src/PDT.EssentialsPluginTemplate.EPI.4Series..csproj rename to src/epi-make-model.4Series.csproj index 1f930c1..59740a8 100644 --- a/src/PDT.EssentialsPluginTemplate.EPI.4Series..csproj +++ b/src/epi-make-model.4Series.csproj @@ -4,12 +4,12 @@ net472 - PDT.EssentialsPluginTemplate.EPI + PepperDash.Essentials.Plugin false - PDT.EssentialsPluginTemplate.EPI + PepperDash.Essentials.Plugin.Make.Model PepperDash Technologies This software is a template for a PepperDash Essentials Plugin. - Copyright 2024 + Copyright 2025 1.0.0-local true $(Version) @@ -31,10 +31,18 @@ - - + + - - - + + + + + + + + + + + \ No newline at end of file