Skip to content

Commit cf3f35a

Browse files
committed
feat: update for Essentials 2 & remove deprecation warnings
BREAKING CHANGE: Drop 3-series support
1 parent ba5d0f3 commit cf3f35a

14 files changed

+496
-451
lines changed

.editorconfig

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
root=true
2+
3+
[*.cs]
4+
indent_style=space
5+
indent_size=2
6+
7+
# .editorconfig
8+
9+
# Define a naming style for camelCase without an underscore prefix
10+
dotnet_naming_style.private_field_camel_case.capitalization = camel_case
11+
dotnet_naming_style.private_field_camel_case.required_prefix =
12+
13+
# Define a naming rule for private fields to use the defined style
14+
dotnet_naming_rule.private_field_no_underscore.symbols = private_fields
15+
dotnet_naming_rule.private_field_no_underscore.style = private_field_camel_case
16+
dotnet_naming_rule.private_field_no_underscore.severity = warning
17+
18+
# Define the symbol kind for private fields
19+
dotnet_naming_symbols.private_fields.applicable_kinds = field
20+
dotnet_naming_symbols.private_fields.applicable_accessibilities = private

.vscode/extensions.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
{
2+
"recommendations": [
3+
"ms-dotnettools.vscode-dotnet-runtime",
4+
"ms-dotnettools.csharp",
5+
"ms-dotnettools.csdevkit",
6+
"vivaxy.vscode-conventional-commits",
7+
"mhutchie.git-graph"
8+
]
9+
}

.vscode/settings.json

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
{
2+
"workbench.colorCustomizations": {
3+
"activityBar.activeBackground": "#8c57e5",
4+
"activityBar.background": "#8c57e5",
5+
"activityBar.foreground": "#e7e7e7",
6+
"activityBar.inactiveForeground": "#e7e7e799",
7+
"activityBarBadge.background": "#6e3411",
8+
"activityBarBadge.foreground": "#e7e7e7",
9+
"commandCenter.border": "#e7e7e799",
10+
"sash.hoverBorder": "#8c57e5",
11+
"statusBar.background": "#6e2bde",
12+
"statusBar.foreground": "#e7e7e7",
13+
"statusBarItem.hoverBackground": "#8c57e5",
14+
"statusBarItem.remoteBackground": "#6e2bde",
15+
"statusBarItem.remoteForeground": "#e7e7e7",
16+
"titleBar.activeBackground": "#6e2bde",
17+
"titleBar.activeForeground": "#e7e7e7",
18+
"titleBar.inactiveBackground": "#6e2bde99",
19+
"titleBar.inactiveForeground": "#e7e7e799"
20+
},
21+
"peacock.color": "#6e2bde",
22+
"[csharp]": {
23+
"editor.defaultFormatter": "ms-dotnettools.csharp",
24+
"editor.formatOnSave": true,
25+
"editor.formatOnSaveMode": "file"
26+
},
27+
"csharp.inlayHints.enableInlayHintsForImplicitObjectCreation": true,
28+
"csharp.inlayHints.enableInlayHintsForImplicitVariableTypes": true,
29+
"csharp.inlayHints.enableInlayHintsForLambdaParameterTypes": true,
30+
"csharp.inlayHints.enableInlayHintsForTypes": true,
31+
"dotnet.formatting.organizeImportsOnFormat": true
32+
}

epi-make-model.3Series.sln

Lines changed: 0 additions & 20 deletions
This file was deleted.

packages.config

Lines changed: 0 additions & 3 deletions
This file was deleted.

src/MakeModelConfigObject.cs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
using System.Collections.Generic;
2-
using Newtonsoft.Json;
3-
using PepperDash.Essentials.Core;
4-
1+
using System.Collections.Generic;
2+
using Newtonsoft.Json;
3+
using PepperDash.Essentials.Core;
4+
55
namespace PepperDash.Essentials.Plugin
66
{
77
/// <summary>
@@ -14,7 +14,7 @@ namespace PepperDash.Essentials.Plugin
1414
/// "EssentialsPluginConfigObjectTemplate" renamed to "SamsungMdcConfig"
1515
/// </example>
1616
[ConfigSnippet("\"properties\":{\"control\":{}")]
17-
public class EssentialsPluginTemplateConfigObject
17+
public class MakeModelConfig
1818
{
1919
/// <summary>
2020
/// JSON control object
@@ -27,7 +27,7 @@ public class EssentialsPluginTemplateConfigObject
2727
/// <example>
2828
/// <code>
2929
/// "control": {
30-
/// "method": "tcpIp",
30+
/// "method": "tcpIp",
3131
/// "controlPortDevKey": "processor",
3232
/// "controlPortNumber": 1,
3333
/// "comParams": {
@@ -139,7 +139,7 @@ public class EssentialsPluginTemplateConfigObject
139139
/// </code>
140140
/// </example>
141141
[JsonProperty("DeviceDictionary")]
142-
public Dictionary<string, EssentialsPluginTemplateConfigObjectDictionary> DeviceDictionary { get; set; }
142+
public Dictionary<string, MakeModelConfigDictionary> DeviceDictionary { get; set; }
143143

144144
/// <summary>
145145
/// Constuctor
@@ -148,9 +148,9 @@ public class EssentialsPluginTemplateConfigObject
148148
/// If using a collection you must instantiate the collection in the constructor
149149
/// to avoid exceptions when reading the configuration file
150150
/// </remarks>
151-
public EssentialsPluginTemplateConfigObject()
151+
public MakeModelConfig()
152152
{
153-
DeviceDictionary = new Dictionary<string, EssentialsPluginTemplateConfigObjectDictionary>();
153+
DeviceDictionary = new Dictionary<string, MakeModelConfigDictionary>();
154154
}
155155
}
156156

@@ -172,7 +172,7 @@ public EssentialsPluginTemplateConfigObject()
172172
/// }
173173
/// </code>
174174
/// </example>
175-
public class EssentialsPluginTemplateConfigObjectDictionary
175+
public class MakeModelConfigDictionary
176176
{
177177
/// <summary>
178178
/// Serializes collection name property

src/MakeModelCrestronDevice.cs

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,29 @@
11
// For Basic SIMPL# Classes
2-
// For Basic SIMPL#Pro classes
3-
4-
using Crestron.SimplSharpPro;
5-
using Crestron.SimplSharpPro.DeviceSupport;
6-
using PepperDash.Core;
7-
using PepperDash.Essentials.Core;
8-
using PepperDash.Essentials.Core.Bridges;
9-
2+
// For Basic SIMPL#Pro classes
3+
4+
using Crestron.SimplSharpPro;
5+
using Crestron.SimplSharpPro.DeviceSupport;
6+
using PepperDash.Core.Logging;
7+
using PepperDash.Essentials.Core;
8+
using PepperDash.Essentials.Core.Bridges;
9+
1010
namespace PepperDash.Essentials.Plugin
1111
{
12-
/// <summary>
13-
/// Plugin device
14-
/// </summary>
15-
/// <remarks>
16-
/// Rename the class to match the device plugin being developed.
17-
/// </remarks>
18-
/// <example>
19-
/// "EssentialsPluginDeviceTemplate" renamed to "SamsungMdcDevice"
20-
/// </example>
21-
public class EssentialsPluginTemplateCrestronDevice : CrestronGenericBridgeableBaseDevice
12+
/// <summary>
13+
/// Plugin device
14+
/// </summary>
15+
/// <remarks>
16+
/// Rename the class to match the device plugin being developed.
17+
/// </remarks>
18+
/// <example>
19+
/// "EssentialsPluginDeviceTemplate" renamed to "SamsungMdcDevice"
20+
/// </example>
21+
public class MakeModelCrestronDevice : CrestronGenericBridgeableBaseDevice
2222
{
2323
/// <summary>
2424
/// It is often desirable to store the config
2525
/// </summary>
26-
private EssentialsPluginTemplateConfigObject _config;
26+
private readonly MakeModelConfig config;
2727

2828

2929
#region Constructor for Devices without IBasicCommunication. Remove if not needed
@@ -34,16 +34,16 @@ public class EssentialsPluginTemplateCrestronDevice : CrestronGenericBridgeableB
3434
/// <param name="name"></param>
3535
/// <param name="config"></param>
3636
/// <param name="hardware"></param>
37-
public EssentialsPluginTemplateCrestronDevice(string key, string name, EssentialsPluginTemplateConfigObject config, GenericBase hardware)
37+
public MakeModelCrestronDevice(string key, string name, MakeModelConfig config, GenericBase hardware)
3838
: base(key, name, hardware)
3939
{
40-
Debug.Console(0, this, "Constructing new {0} instance", name);
40+
this.LogInformation("Constructing new {0} instance", name);
4141

4242
// The base class takes care of registering the hardware device for you
4343

4444
// TODO [ ] Update the constructor as needed for the plugin device being developed
4545

46-
_config = config;
46+
this.config = config;
4747
}
4848

4949
#endregion
@@ -63,10 +63,7 @@ public override void LinkToApi(BasicTriList trilist, uint joinStart, string join
6363
var joinMap = new EssentialsPluginTemplateBridgeJoinMap(joinStart);
6464

6565
// This adds the join map to the collection on the bridge
66-
if (bridge != null)
67-
{
68-
bridge.AddJoinMap(Key, joinMap);
69-
}
66+
bridge?.AddJoinMap(Key, joinMap);
7067

7168
var customJoins = JoinMapHelper.TryGetJoinMapAdvancedForDevice(joinMapKey);
7269

@@ -75,8 +72,8 @@ public override void LinkToApi(BasicTriList trilist, uint joinStart, string join
7572
joinMap.SetCustomJoinData(customJoins);
7673
}
7774

78-
Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
79-
Debug.Console(0, "Linking to Bridge Type {0}", GetType().Name);
75+
this.LogDebug("Linking to Trilist {id}", trilist.ID.ToString("X"));
76+
this.LogInformation("Linking to Bridge Type {type}", GetType().Name);
8077

8178
// TODO [ ] Implement bridge links as needed
8279

Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
using System.Collections.Generic;
2+
using Crestron.SimplSharpPro.UI;
3+
using PepperDash.Core;
4+
using PepperDash.Essentials.Core;
5+
6+
namespace PepperDash.Essentials.Plugin
7+
{
8+
9+
/// <summary>
10+
/// Plugin device factory for Crestron wrapper devices
11+
/// </summary>
12+
/// <remarks>
13+
/// Rename the class to match the device plugin being developed
14+
/// </remarks>
15+
/// <example>
16+
/// "EssentialsPluginFactoryTemplate" renamed to "MyCrestronDeviceFactory"
17+
/// </example>
18+
public class MakeModelCrestronDeviceFactory : EssentialsPluginDeviceFactory<MakeModelCrestronDevice>
19+
{
20+
/// <summary>
21+
/// Plugin device factory constructor
22+
/// </summary>
23+
/// <remarks>
24+
/// Update the MinimumEssentialsFrameworkVersion & TypeNames as needed when creating a plugin
25+
/// </remarks>
26+
/// <example>
27+
/// Set the minimum Essentials Framework Version
28+
/// <code>
29+
/// MinimumEssentialsFrameworkVersion = "1.6.4;
30+
/// </code>
31+
/// In the constructor we initialize the list with the typenames that will build an instance of this device
32+
/// <code>
33+
/// TypeNames = new List<string>() { "SamsungMdc", "SamsungMdcDisplay" };
34+
/// </code>
35+
/// </example>
36+
public MakeModelCrestronDeviceFactory()
37+
{
38+
// Set the minimum Essentials Framework Version
39+
// TODO [ ] Update the Essentials minimum framework version which this plugin has been tested against
40+
MinimumEssentialsFrameworkVersion = "2.12.1";
41+
42+
// In the constructor we initialize the list with the typenames that will build an instance of this device
43+
// TODO [ ] Update the TypeNames for the plugin being developed
44+
TypeNames = new List<string>() { "examplePluginCrestronDevice" };
45+
}
46+
47+
/// <summary>
48+
/// Builds and returns an instance of EssentialsPluginTemplateCrestronDevice
49+
/// </summary>
50+
/// <param name="dc">device configuration</param>
51+
/// <returns>plugin device or null</returns>
52+
/// <remarks>
53+
/// The example provided below takes the device key, name, properties config and the comms device created.
54+
/// Modify the EssetnialsPlugingDeviceTemplate constructor as needed to meet the requirements of the plugin device.
55+
/// </remarks>
56+
/// <seealso cref="PepperDash.Core.eControlMethod"/>
57+
public override EssentialsDevice BuildDevice(PepperDash.Essentials.Core.Config.DeviceConfig dc)
58+
{
59+
60+
Debug.LogDebug("[{key}] Factory Attempting to create new device from type: {type}", dc.Key, dc.Type);
61+
62+
// get the plugin device properties configuration object & check for null
63+
var propertiesConfig = dc.Properties.ToObject<MakeModelConfig>();
64+
if (propertiesConfig == null)
65+
{
66+
Debug.LogWarning("[{key}] Factory: failed to read properties config for {name}", dc.Key, dc.Name);
67+
return null;
68+
}
69+
70+
var controlConfig = CommFactory.GetControlPropertiesConfig(dc);
71+
72+
if (controlConfig == null)
73+
{
74+
var myTouchpanel = new Tsw760(controlConfig.IpIdInt, Global.ControlSystem);
75+
76+
return new MakeModelCrestronDevice(dc.Key, dc.Name, propertiesConfig, myTouchpanel);
77+
}
78+
else
79+
{
80+
Debug.LogWarning("[{key}] Factory: Unable to get control properties from device config for {name}", dc.Key, dc.Name);
81+
return null;
82+
}
83+
}
84+
}
85+
86+
}
87+

0 commit comments

Comments
 (0)