├── README.md
├── en-US.json
├── Settings_Data.cs
├── UiDefinition.xml
├── Device_Name.json
├── Device_Name_Transport.cs
├── Device_Name_Protocol.cs
└── Device_Name.cs
/README.md:
--------------------------------------------------------------------------------
1 | # Crestron-Home-Extension-Driver-Template
2 |
3 | These files make up a template I've created for writing extension drivers for Crestron Home. Typically I include a zip file of my VS solution folder
4 | so anyone can simply download the entire soluion and start using it. However, because of the size of the solution folder for a Crestron Home project,
5 | that isn't possible as the file is larger than allowed by Github.
6 |
--------------------------------------------------------------------------------
/en-US.json:
--------------------------------------------------------------------------------
1 | {
2 | "MainPageTitle": "Home_Extension_Template",
3 | "DisplayTextLabel": "Display Text",
4 |
5 | "SettingsPageTitle": "Settings",
6 | "SubheaderLabel": "Subheader",
7 | "ChecboxLabel": "Checkbox Label",
8 | "CheckboxSecondaryLabel": "Checkbox Secondary Label",
9 | "TextEntryLabel": "Text Entry Field Label",
10 |
11 | "ButtonSettingsLabel": "Settings",
12 | "SaveButtonName": "Save",
13 |
14 | "SequenceTriggeredMethodLabel": "Template Sequence Trigger"
15 |
16 | }
--------------------------------------------------------------------------------
/Settings_Data.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.Linq;
4 | using System.Text;
5 | using System.Threading.Tasks;
6 |
7 | namespace Home_Extension_Template
8 | {
9 | public class Settings_Data
10 | {
11 | #region Declarations
12 | public bool Checkbox_Setting;
13 | public int Text_Entry_Setting;
14 | #endregion Declarations
15 |
16 | //****************************************************************************************
17 | //
18 | // Settings_Data - Constructor
19 | //
20 | //****************************************************************************************
21 | public Settings_Data()
22 | {
23 | Checkbox_Setting = false;
24 | Text_Entry_Setting = 0;
25 | }
26 | //****************************************************************************************
27 | //
28 | // Save -
29 | //
30 | //****************************************************************************************
31 | public void Save(bool Checkbox_Setting, int Text_Entry_Setting)
32 | {
33 | this.Checkbox_Setting = Checkbox_Setting;
34 | this.Text_Entry_Setting = Text_Entry_Setting;
35 | }
36 | }
37 | }
38 |
--------------------------------------------------------------------------------
/UiDefinition.xml:
--------------------------------------------------------------------------------
1 |
2 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
--------------------------------------------------------------------------------
/Device_Name.json:
--------------------------------------------------------------------------------
1 | {
2 | "CrestronSerialDeviceApi": {
3 | "DeviceSupport": {
4 | },
5 | "DeviceSupport2": [],
6 | "GeneralInformation": {
7 | "DeviceType": "Generic Device",
8 | "Manufacturer": "Generic Device Manufacturer",
9 | "BaseModel": "Generic 1",
10 | "VersionDate": " 2021-03-22 06:56:42.4853 ",
11 | "DriverVersion": "1.0.000.0000",
12 | "SdkVersion": "6.0.0",
13 | "Description": "Generic Device Template",
14 | "Guid": "fd3d06cb-2f93-4dac-8b96-f59a3d390bb1",
15 | "ExtensionDeviceData": {
16 | "IsExtensionDevice": true,
17 | "IsMediaDevice": false,
18 | "IsMediaSource": false
19 | },
20 | "SupportedSeries": [ "Generic Device Series" ],
21 | "SupportedModels": [ "Generic 1" ]
22 | },
23 | "Api": {
24 | "Communication": {
25 | "CommunicationType": 5,
26 | "Protocol": -1,
27 | "Baud": -1,
28 | "Parity": -1,
29 | "HwHandshake": -1,
30 | "SwHandshake": -1,
31 | "DataBits": 0,
32 | "StopBits": -1,
33 | "Port": 80,
34 | "EnableAutoPolling": true,
35 | "EnableAutoReconnect": false,
36 | "TimeBetweenCommands": 250,
37 | "ResponseTimeout": 3000,
38 | "WaitForResponse": false,
39 | "IpProtocol": 0,
40 | "IsUserAdjustable": false,
41 | "Authentication": {
42 | "Type": "None",
43 | "Required": false
44 | },
45 | "IsSecure": false,
46 | "UserAdjustableProperties": [],
47 | "DeviceId": 0
48 | }
49 | },
50 | "UserAttributes": [
51 | {
52 | "TypeName": "Custom",
53 | "ParameterId": "DeviceID",
54 | "Label": "Device ID",
55 | "Description": "ID of your device - Required for communications",
56 | "Persistent": true,
57 | "RequiredForConnection": "Before",
58 | "Data": {
59 | "DataType": "String",
60 | "Mask": "",
61 | "DefaultValue": ""
62 | }
63 | }
64 | ],
65 | "Dependencies": [""]
66 | }
67 | }
--------------------------------------------------------------------------------
/Device_Name_Transport.cs:
--------------------------------------------------------------------------------
1 | using Crestron.RAD.Common.Transports;
2 |
3 | namespace Home_Extension_Template
4 | {
5 | public class Device_Name_Transport : ATransportDriver
6 | {
7 | #region Declarations
8 | public Device_Name Device;
9 | #endregion Declarations
10 |
11 | //****************************************************************************************
12 | //
13 | // Device_Name_Transport - Constructor
14 | //
15 | //****************************************************************************************
16 | public Device_Name_Transport(Device_Name Device)
17 | {
18 | #region Debug Message
19 | Log("Device_Name_Transport - Constructor - Start");
20 | #endregion Debug Message
21 |
22 | IsEthernetTransport = true;
23 | IsConnected = true;
24 | this.Device = Device;
25 |
26 | #region Debug Message
27 | Log("Device_Name_Transport - Constructor - Finish");
28 | #endregion Debug Message
29 | }
30 |
31 | #region Overrides
32 | //****************************************************************************************
33 | //
34 | // Start -
35 | //
36 | //****************************************************************************************
37 | public override void Start()
38 | {
39 | #region Debug Message
40 | Log("Device_Name_Transport - Start - Start");
41 | #endregion Debug Message
42 |
43 | #region Debug Message
44 | Log("Device_Name_Transport - Start - Finish");
45 | #endregion Debug Message
46 | }
47 |
48 | //****************************************************************************************
49 | //
50 | // Stop -
51 | //
52 | //****************************************************************************************
53 | public override void Stop()
54 | {
55 | #region Debug Message
56 | Log("Device_Name_Transport - Stop - Start");
57 | #endregion Debug Message
58 |
59 | #region Debug Message
60 | Log("Device_Name_Transport - Stop - Finish");
61 | #endregion Debug Message
62 | }
63 |
64 | //****************************************************************************************
65 | //
66 | // SendMethod -
67 | //
68 | //****************************************************************************************
69 | public override void SendMethod(string message, object[] parameters)
70 | {
71 | #region Debug Message
72 | Log("Device_Name_Transport - SendMethod - Start");
73 | #endregion Debug Message
74 |
75 | #region Debug Message
76 | Log("Device_Name_Transport - SendMethod - Finish");
77 | #endregion Debug Message
78 | }
79 | #endregion Overrides
80 | }
81 | }
--------------------------------------------------------------------------------
/Device_Name_Protocol.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Crestron.RAD.Common.BasicDriver;
3 |
4 | namespace Home_Extension_Template
5 | {
6 | public class Device_Name_Protocol : ABaseDriverProtocol, IDisposable
7 | {
8 | #region Declarations
9 | private readonly Device_Name Device;
10 | public Device_Name.UI_Update_Delegate UI_Update;
11 | #endregion Declarations
12 |
13 | //****************************************************************************************
14 | //
15 | // Device_Name_Protocol - Constructor
16 | //
17 | //****************************************************************************************
18 | public Device_Name_Protocol(Device_Name_Transport transport, byte id) : base(transport, id)
19 | {
20 | #region Debug Message
21 | Log("Device_Name_Protocol - Constructor - Start");
22 | #endregion Debug Message
23 |
24 | Transport = transport;
25 | Device = transport.Device;
26 |
27 | #region Debug Message
28 | Log("Device_Name_Protocol - Constructor - Finish");
29 | #endregion Debug Message
30 | }
31 |
32 | //****************************************************************************************
33 | //
34 | // Start -
35 | //
36 | //****************************************************************************************
37 | public void Start()
38 | {
39 | #region Debug Message
40 | Log("Device_Name_Protocol - Start - Start");
41 | #endregion Debug Message
42 |
43 | PollingInterval = 60000;//60 seconds in ms
44 | EnableAutoPolling = true;
45 |
46 | #region Debug Message
47 | Log("Device_Name_Protocol - Start - Finish");
48 | #endregion Debug Message
49 | }
50 |
51 | //****************************************************************************************
52 | //
53 | // Stop -
54 | //
55 | //****************************************************************************************
56 | public void Stop()
57 | {
58 | #region Debug Message
59 | Log("Device_Name_Protocol - Stop - Start");
60 | #endregion Debug Message
61 |
62 | EnableAutoPolling = false;
63 |
64 | #region Debug Message
65 | Log("Device_Name_Protocol - Stop - Finish");
66 | #endregion Debug Message
67 | }
68 |
69 | //****************************************************************************************
70 | //
71 | // Poll - Built in Polling Routing
72 | //
73 | //****************************************************************************************
74 | protected override void Poll()
75 | {
76 | #region Debug Message
77 | Log("Device_Name_Protocol - Poll - Start");
78 | #endregion Debug Message
79 |
80 | //TODO Do the work to get data from your device/cloud service
81 |
82 | #region Test Code
83 | // Increment the counter so there is something to watch in the UI
84 | // When the counter gets to 10 trigger an event
85 | Device.Counter++;
86 | if (Device.Counter >= 11)
87 | {
88 | Device.Counter = 1;
89 | }
90 | else if (Device.Counter == 10)
91 | {
92 | Device.Trigger_Event();
93 | }
94 |
95 | #region Debug Message
96 | Log("Device_Name_Protocol - Poll Counter = " + Device.Counter.ToString());
97 | #endregion Debug Message
98 | #endregion Test Code
99 |
100 | //Update your UI with the information
101 | UI_Update();
102 |
103 | #region Debug Message
104 | Log("Device_Name_Protocol - Poll - Finish");
105 | #endregion Debug Message
106 | }
107 |
108 | #region Overrides
109 | //****************************************************************************************
110 | //
111 | // ConnectionChangedEvent -
112 | //
113 | //****************************************************************************************
114 | protected override void ConnectionChangedEvent(bool connection)
115 | {
116 | #region Debug Message
117 | Log("Device_Name_Protocol - ConnectionChangedEvent - Start");
118 | #endregion Debug Message
119 |
120 | #region Debug Message
121 | Log("Device_Name_Protocol - ConnectionChangedEvent - Finish");
122 | #endregion Debug Message
123 | }
124 |
125 | //****************************************************************************************
126 | //
127 | // ChooseDeconstructMethod -
128 | //
129 | //****************************************************************************************
130 | protected override void ChooseDeconstructMethod(ValidatedRxData validatedData)
131 | {
132 | #region Debug Message
133 | Log("Device_Name_Protocol - ChooseDeconstructMethod - Start");
134 | #endregion Debug Message
135 |
136 | #region Debug Message
137 | Log("Device_Name_Protocol - ChooseDeconstructMethod - Finish");
138 | #endregion Debug Message
139 | }
140 |
141 | //****************************************************************************************
142 | //
143 | // SetUserAttribute -
144 | //
145 | //****************************************************************************************
146 | public override void SetUserAttribute(string attributeId, string attributeValue)
147 | {
148 | #region Debug Message
149 | Log("Device_Name_Protocol - SetUserAttribute - Start");
150 | #endregion Debug Message
151 |
152 | if (string.IsNullOrEmpty(attributeValue))
153 | {
154 | Log("Device_Name_Protocol - SetUserAttribute - User attribute value was null or empty");
155 | }
156 | else
157 | {
158 | switch (attributeId)
159 | {
160 | case "DeviceID":
161 | Device.Device_ID = attributeValue;
162 | #region Debug Message
163 | Log("Device_Name_Protocol - SetUserAttribute - Device ID has been set:" + attributeValue);
164 | #endregion Debug Message
165 | break;
166 | }
167 | }
168 |
169 | #region Debug Message
170 | Log("Device_Name_Protocol - SetUserAttribute - Finish");
171 | #endregion Debug Message
172 | }
173 | #endregion Overrides
174 |
175 | }
176 | }
177 |
--------------------------------------------------------------------------------
/Device_Name.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using Crestron.RAD.Common.Interfaces;
3 | using Crestron.RAD.Common.Interfaces.ExtensionDevice;
4 | using Crestron.RAD.DeviceTypes.ExtensionDevice;
5 | using Crestron.RAD.Common.Attributes.Programming;
6 | using Crestron.RAD.Common.Enums;
7 |
8 |
9 | namespace Home_Extension_Template
10 | {
11 |
12 | public class Device_Name : AExtensionDevice, ICloudConnected
13 | {
14 | #region Declarations
15 | public Device_Name_Transport Transport;
16 | public Device_Name_Protocol Protocol;
17 | public string Device_ID;
18 | public int Counter = 1;
19 |
20 | //Settings
21 | public Settings_Data Settings;
22 | private const string Filename = "Template_Settings_Data";
23 | #endregion Declarations
24 |
25 | #region Property keys
26 | private const string Display_Text_Key = "DisplayText";
27 | private const string Checkbox_Value_Key = "CheckboxValue";
28 | private const string Text_Entry_Value_Key = "TextEntryValue";
29 | #endregion Property keys
30 |
31 | #region UI properties
32 | private PropertyValue Display_Text_Property;
33 | private PropertyValue Checkbox_Value_Property;
34 | private PropertyValue Text_Entry_Value_Property;
35 | #endregion UI properties
36 |
37 | #region Events
38 | [ProgrammableEvent]
39 | public event EventHandler Event_ID;
40 | #endregion Events
41 |
42 | #region Delegates
43 | public delegate void UI_Update_Delegate();
44 | #endregion Delegates
45 |
46 | //****************************************************************************************
47 | //
48 | // Device_Name - Constructor
49 | //
50 | //****************************************************************************************
51 | public Device_Name()
52 | {
53 | #region Debug Message
54 | Log("Device_Name - Constructor - Start");
55 | #endregion Debug Message
56 |
57 | #region Debug Message
58 | Log("Device_Name - Constructor - Finish");
59 | #endregion Debug Message
60 | }
61 |
62 | //****************************************************************************************
63 | //
64 | // Initialize - ICloudConnected Interface
65 | //
66 | //****************************************************************************************
67 | public void Initialize()
68 | {
69 | EnableLogging = true;
70 |
71 | #region Debug Message
72 | Log("Device_Name - Initialize - Start");
73 | #endregion Debug Message
74 |
75 | #region Setup Delegates
76 | UI_Update_Delegate del = new UI_Update_Delegate(Update_UI);
77 | #endregion Setup Delegates
78 |
79 | #region Setup UI
80 | Create_Device_Definition();
81 | #endregion Setup UI
82 |
83 | #region Setup Transport
84 | try
85 | {
86 | Transport = new Device_Name_Transport(this)
87 | {
88 | EnableLogging = InternalEnableLogging,
89 | CustomLogger = InternalCustomLogger,
90 | EnableRxDebug = InternalEnableRxDebug,
91 | EnableTxDebug = InternalEnableTxDebug
92 | };
93 | ConnectionTransport = Transport;
94 | }
95 | catch (Exception e)
96 | {
97 | string err = "Device_Name - Initialize - Error Setting Up Transport: " + e;
98 | #region Debug Message
99 | Log(err);
100 | #endregion Debug Message
101 | Crestron.SimplSharp.ErrorLog.Error(err + "\n");
102 | }
103 | #endregion Setup Transport
104 |
105 | #region Setup Protocol
106 | try
107 | {
108 | Protocol = new Device_Name_Protocol(Transport, Id)
109 | {
110 | EnableLogging = InternalEnableLogging,
111 | CustomLogger = InternalCustomLogger,
112 | UI_Update = del
113 | };
114 |
115 | DeviceProtocol = Protocol;
116 | DeviceProtocol.Initialize(DriverData);
117 | }
118 | catch (Exception e)
119 | {
120 | string err = "Device_Name - Initialize - Error Setting Up Protocol: " + e;
121 | #region Debug Message
122 | Log(err);
123 | #endregion Debug Message
124 | Crestron.SimplSharp.ErrorLog.Error(err + "\n");
125 | }
126 | #endregion Setup Protocol
127 |
128 | #region Debug Message
129 | Log("Device_Name - Initialize - Finish");
130 | #endregion Debug Message
131 | }
132 |
133 | //****************************************************************************************
134 | //
135 | // Create_Device_Definition -
136 | //
137 | //****************************************************************************************
138 | private void Create_Device_Definition()
139 | {
140 | #region Debug Message
141 | Log("Device_Name - Create_Device_Definition - Start");
142 | #endregion Debug Message
143 |
144 | Display_Text_Property = CreateProperty(new PropertyDefinition(Display_Text_Key, null, DevicePropertyType.String));
145 | Checkbox_Value_Property = CreateProperty(new PropertyDefinition(Checkbox_Value_Key, null, DevicePropertyType.Boolean));
146 | Text_Entry_Value_Property = CreateProperty(new PropertyDefinition(Text_Entry_Value_Key, null, DevicePropertyType.Int32));
147 |
148 | #region Debug Message
149 | Log("Device_Name - Create_Device_Definition - Finish");
150 | #endregion Debug Message
151 | }
152 |
153 | //****************************************************************************************
154 | //
155 | // Update_UI -
156 | //
157 | //****************************************************************************************
158 | public void Update_UI()
159 | {
160 | #region Debug Message
161 | Log("Device_Name - Update_UI - Start");
162 | #endregion Debug Message
163 |
164 | Display_Text_Property.Value = Counter.ToString();
165 |
166 | Commit();
167 |
168 | #region Debug Message
169 | Log("Device_Name - Update_UI - Finish");
170 | #endregion Debug Message
171 | }
172 |
173 | //****************************************************************************************
174 | //
175 | // Trigger_Event -
176 | //
177 | //****************************************************************************************
178 | public void Trigger_Event()
179 | {
180 | #region Debug Message
181 | Log("Device_Name - Trigger_Event - Start");
182 | #endregion Debug Message
183 |
184 | var Event = Event_ID;
185 | Event?.Invoke(this, new EventArgs());
186 |
187 | #region Debug Message
188 | Log("Device_Name - Trigger_Event - Finish");
189 | #endregion Debug Message
190 | }
191 |
192 | //****************************************************************************************
193 | //
194 | // Sequence_Triggered_Method -
195 | //
196 | //****************************************************************************************
197 | [ProgrammableOperation("^SequenceTriggeredMethodLabel")]
198 | public void Sequence_Triggered_Method()
199 | {
200 | #region Debug Message
201 | Log("Device_Name - Sequence_Triggered_Method - Start");
202 | #endregion Debug Message
203 |
204 | #region Debug Message
205 | Log("Device_Name - Sequence_Triggered_Method - Finish");
206 | #endregion Debug Message
207 | }
208 |
209 | #region Overrides
210 | //****************************************************************************************
211 | //
212 | // Dispose -
213 | //
214 | //****************************************************************************************
215 | public override void Dispose()
216 | {
217 | #region Debug Message
218 | Log("Device_Name - Dispose - Start");
219 | #endregion Debug Message
220 |
221 | base.Dispose();
222 |
223 | #region Debug Message
224 | Log("Device_Name - Dispose - Finish");
225 | #endregion Debug Message
226 | }
227 |
228 | //****************************************************************************************
229 | //
230 | // DoCommand -
231 | //
232 | //****************************************************************************************
233 | protected override IOperationResult DoCommand(string command, string[] parameters)
234 | {
235 | #region Debug Message
236 | Log("Device_Name - DoCommand - Start");
237 | #endregion Debug Message
238 |
239 | switch (command)
240 | {
241 | case "ShowSettings":
242 | //Load Boolean Values
243 | Checkbox_Value_Property.Value = Settings.Checkbox_Setting;
244 | //Load String Values
245 | Text_Entry_Value_Property.Value = Settings.Text_Entry_Setting;
246 | break;
247 |
248 | case "SaveSettings":
249 | Settings.Save(Checkbox_Value_Property.Value, Text_Entry_Value_Property.Value);
250 | //Make Settings Persistant
251 | SaveSetting(Filename, Settings);
252 | break;
253 | }
254 |
255 | Commit();
256 |
257 | #region Debug Message
258 | Log("Device_Name - DoCommand - Finish");
259 | #endregion Debug Message
260 |
261 | return new OperationResult(OperationResultCode.Success);
262 | }
263 |
264 | //****************************************************************************************
265 | //
266 | // SetDriverPropertyValue -
267 | //
268 | //****************************************************************************************
269 | protected override IOperationResult SetDriverPropertyValue(string propertyKey, T value)
270 | {
271 | #region Debug Message
272 | Log("Device_Name - SetDriverPropertyValue 1 - Start");
273 | #endregion Debug Message
274 |
275 | switch (propertyKey)
276 | {
277 | case "CheckboxValue":
278 | Checkbox_Value_Property.Value = value.Equals(true);
279 | #region Debug Message
280 | Log("Device_Name - SetDriverPropertyValue 1 - CheckboxValue= " + Checkbox_Value_Property.Value);
281 | #endregion Debug Message
282 | break;
283 |
284 | case "TextEntryValue":
285 | var TextEntryValue = value as int?;
286 | if (TextEntryValue != null)
287 | {
288 | Text_Entry_Value_Property.Value = (int)TextEntryValue;
289 | }
290 | else
291 | {
292 | #region Debug Message
293 | Log("Device_Name - SetDriverPropertyValue 1 - Couldn't Convert value to int");
294 | #endregion Debug Message
295 | }
296 | #region Debug Message
297 | Log("Device_Name - SetDriverPropertyValue 1 - TextEntryValue = " + Text_Entry_Value_Property.Value);
298 | #endregion Debug Message
299 | break;
300 |
301 | default:
302 | #region Debug Message
303 | Log("Device_Name - SetDriverPropertyValue 1 - Unhandled PropertyKey = " + propertyKey);
304 | #endregion Debug Message
305 | break;
306 | }
307 |
308 | Commit();
309 |
310 | #region Debug Message
311 | Log("Device_Name - SetDriverPropertyValue 1 - Finish");
312 | #endregion Debug Message
313 |
314 | return new OperationResult(OperationResultCode.Success);
315 | }
316 |
317 | //****************************************************************************************
318 | //
319 | // SetDriverPropertyValue -
320 | //
321 | //****************************************************************************************
322 | protected override IOperationResult SetDriverPropertyValue(string objectId, string propertyKey, T value)
323 | {
324 | #region Debug Message
325 | Log("Device_Name - SetDriverPropertyValue 2 - Start");
326 | #endregion Debug Message
327 |
328 | Commit();
329 |
330 | #region Debug Message
331 | Log("Device_Name - SetDriverPropertyValue 2 - Finish");
332 | #endregion Debug Message
333 |
334 | return new OperationResult(OperationResultCode.Success);
335 | }
336 |
337 | //****************************************************************************************
338 | //
339 | // Connect -
340 | //
341 | //****************************************************************************************
342 | public override void Connect()
343 | {
344 | #region Debug Message
345 | Log("Device_Name - Connect - Start");
346 | #endregion Debug Message
347 |
348 | if (Protocol == null)
349 | {
350 | #region Debug Message
351 | Log("Device_Name - Connect - Protocol was null when Connect was called");
352 | #endregion Debug Message
353 | }
354 | else
355 | {
356 | #region Load Persistant Settings
357 | var temp = GetSetting(Filename);
358 | if (temp != null)
359 | {
360 | Settings = (Settings_Data)temp;
361 | }
362 | else
363 | {
364 | //No Persistant Notifications - Create From Scratch and Save for Next Time
365 | Settings = new Settings_Data();
366 | SaveSetting(Filename, Settings);
367 | }
368 | #endregion Load Persistant Notifications
369 |
370 | base.Connect();
371 |
372 | // Set Connected flag to true
373 | Connected = true;
374 |
375 | Protocol.Start();
376 | }
377 |
378 | #region Debug Message
379 | Log("Device_Name - Connect - Finish");
380 | #endregion Debug Message
381 | }
382 |
383 | //****************************************************************************************
384 | //
385 | // Disconnect -
386 | //
387 | //****************************************************************************************
388 | public override void Disconnect()
389 | {
390 | #region Debug Message
391 | Log("Device_Name - Disconnect - Start");
392 | #endregion Debug Message
393 |
394 | if (Protocol == null)
395 | {
396 | #region Debug Message
397 | Log("Device_Name - DisconnectProtocol was null when Disconnect was called");
398 | #endregion Debug Message
399 | }
400 | else
401 | {
402 | Protocol.Stop();
403 |
404 | base.Disconnect();
405 |
406 | // Set Connected flag to false
407 | Connected = false;
408 | }
409 |
410 | #region Debug Message
411 | Log("Device_Name - Disconnect - Finish");
412 | #endregion Debug Message
413 | }
414 | #endregion Overrides
415 | }
416 | }
417 |
--------------------------------------------------------------------------------