diff --git a/src/PepperDash.Core/Device.cs b/src/PepperDash.Core/Device.cs
index fda30c4c..ef9f6111 100644
--- a/src/PepperDash.Core/Device.cs
+++ b/src/PepperDash.Core/Device.cs
@@ -11,35 +11,35 @@ namespace PepperDash.Core
public class Device : IKeyName
{
- ///
- /// Unique Key
- ///
+ ///
+ /// Unique Key
+ ///
public string Key { get; protected set; }
///
/// Name of the devie
///
- public string Name { get; protected set; }
- ///
- ///
- ///
+ public string Name { get; protected set; }
+ ///
+ ///
+ ///
public bool Enabled { get; protected set; }
- /////
- ///// A place to store reference to the original config object, if any. These values should
- ///// NOT be used as properties on the device as they are all publicly-settable values.
- /////
- //public DeviceConfig Config { get; private set; }
- /////
- ///// Helper method to check if Config exists
- /////
- //public bool HasConfig { get { return Config != null; } }
+ /////
+ ///// A place to store reference to the original config object, if any. These values should
+ ///// NOT be used as properties on the device as they are all publicly-settable values.
+ /////
+ //public DeviceConfig Config { get; private set; }
+ /////
+ ///// Helper method to check if Config exists
+ /////
+ //public bool HasConfig { get { return Config != null; } }
List _PreActivationActions;
List _PostActivationActions;
- ///
- ///
- ///
+ ///
+ ///
+ ///
public static Device DefaultDevice { get { return _DefaultDevice; } }
static Device _DefaultDevice = new Device("Default", "Default");
@@ -54,27 +54,27 @@ namespace PepperDash.Core
Name = "";
}
- ///
- /// Constructor with key and name
- ///
- ///
- ///
+ ///
+ /// Constructor with key and name
+ ///
+ ///
+ ///
public Device(string key, string name) : this(key)
{
Name = name;
}
- //public Device(DeviceConfig config)
- // : this(config.Key, config.Name)
- //{
- // Config = config;
- //}
+ //public Device(DeviceConfig config)
+ // : this(config.Key, config.Name)
+ //{
+ // Config = config;
+ //}
- ///
- /// Adds a pre activation action
- ///
- ///
+ ///
+ /// Adds a pre activation action
+ ///
+ ///
public void AddPreActivationAction(Action act)
{
if (_PreActivationActions == null)
@@ -82,10 +82,10 @@ namespace PepperDash.Core
_PreActivationActions.Add(act);
}
- ///
- /// Adds a post activation action
- ///
- ///
+ ///
+ /// Adds a post activation action
+ ///
+ ///
public void AddPostActivationAction(Action act)
{
if (_PostActivationActions == null)
@@ -93,55 +93,58 @@ namespace PepperDash.Core
_PostActivationActions.Add(act);
}
- ///
- /// Executes the preactivation actions
- ///
- public void PreActivate()
- {
- if (_PreActivationActions != null)
- _PreActivationActions.ForEach(a => {
+ ///
+ /// Executes the preactivation actions
+ ///
+ public void PreActivate()
+ {
+ if (_PreActivationActions != null)
+ _PreActivationActions.ForEach(a =>
+ {
try
{
a.Invoke();
- } catch (Exception e)
- {
+ }
+ catch (Exception e)
+ {
Debug.LogMessage(e, "Error in PreActivationAction: " + e.Message, this);
}
- });
- }
+ });
+ }
///
/// Gets this device ready to be used in the system. Runs any added pre-activation items, and
/// all post-activation at end. Classes needing additional logic to
/// run should override CustomActivate()
///
- public bool Activate()
+ public bool Activate()
{
- //if (_PreActivationActions != null)
- // _PreActivationActions.ForEach(a => a.Invoke());
+ //if (_PreActivationActions != null)
+ // _PreActivationActions.ForEach(a => a.Invoke());
var result = CustomActivate();
- //if(result && _PostActivationActions != null)
- // _PostActivationActions.ForEach(a => a.Invoke());
- return result;
+ //if(result && _PostActivationActions != null)
+ // _PostActivationActions.ForEach(a => a.Invoke());
+ return result;
}
- ///
- /// Executes the postactivation actions
- ///
- public void PostActivate()
- {
- if (_PostActivationActions != null)
- _PostActivationActions.ForEach(a => {
- try
- {
- a.Invoke();
- }
- catch (Exception e)
- {
- Debug.LogMessage(e, "Error in PostActivationAction: " + e.Message, this);
- }
- });
- }
+ ///
+ /// Executes the postactivation actions
+ ///
+ public void PostActivate()
+ {
+ if (_PostActivationActions != null)
+ _PostActivationActions.ForEach(a =>
+ {
+ try
+ {
+ a.Invoke();
+ }
+ catch (Exception e)
+ {
+ Debug.LogMessage(e, "Error in PostActivationAction: " + e.Message, this);
+ }
+ });
+ }
///
/// Called in between Pre and PostActivationActions when Activate() is called.
@@ -158,14 +161,14 @@ namespace PepperDash.Core
///
public virtual bool Deactivate() { return true; }
- ///
- /// Call this method to start communications with a device. Overriding classes do not need to call base.Initialize()
- ///
- public virtual void Initialize()
- {
- }
+ ///
+ /// Call this method to start communications with a device. Overriding classes do not need to call base.Initialize()
+ ///
+ public virtual void Initialize()
+ {
+ }
- ///
+ ///
/// Helper method to check object for bool value false and fire an Action method
///
/// Should be of type bool, others will be ignored
@@ -175,5 +178,15 @@ namespace PepperDash.Core
if (o is bool && !(bool)o) a();
}
+ ///
+ /// Returns a string representation of the object, including its key and name.
+ ///
+ /// The returned string is formatted as "{Key} - {Name}". If the Name property is
+ /// null or empty, "---" is used in place of the name.
+ /// A string that represents the object, containing the key and name in the format "{Key} - {Name}".
+ public override string ToString()
+ {
+ return string.Format("{0} - {1}", Key, string.IsNullOrEmpty(Name) ? "---" : Name);
+ }
}
}
\ No newline at end of file
diff --git a/src/PepperDash.Essentials.Core/Devices/DeviceManager.cs b/src/PepperDash.Essentials.Core/Devices/DeviceManager.cs
index eaf696ba..5cd921b8 100644
--- a/src/PepperDash.Essentials.Core/Devices/DeviceManager.cs
+++ b/src/PepperDash.Essentials.Core/Devices/DeviceManager.cs
@@ -248,7 +248,7 @@ namespace PepperDash.Essentials.Core
foreach (var dev in Devices.Values.OfType())
{
- CrestronConsole.ConsoleCommandResponse($"{dev.Key}|{dev.Name}: {dev.CommunicationMonitor.Status}\r\n");
+ CrestronConsole.ConsoleCommandResponse($"{dev}: {dev.CommunicationMonitor.Status}\r\n");
}
}
diff --git a/src/PepperDash.Essentials.Core/Devices/EssentialsDevice.cs b/src/PepperDash.Essentials.Core/Devices/EssentialsDevice.cs
index bdb8b45a..778f9226 100644
--- a/src/PepperDash.Essentials.Core/Devices/EssentialsDevice.cs
+++ b/src/PepperDash.Essentials.Core/Devices/EssentialsDevice.cs
@@ -20,19 +20,20 @@ namespace PepperDash.Essentials.Core
public event EventHandler Initialized;
private bool _isInitialized;
- public bool IsInitialized {
+ public bool IsInitialized
+ {
get { return _isInitialized; }
- private set
- {
+ private set
+ {
if (_isInitialized == value) return;
-
+
_isInitialized = value;
if (_isInitialized)
{
Initialized?.Invoke(this, new EventArgs());
}
- }
+ }
}
protected EssentialsDevice(string key)
@@ -80,8 +81,9 @@ namespace PepperDash.Essentials.Core
///
/// Override this method to build and create custom Mobile Control Messengers during the Activation phase
///
- protected virtual void CreateMobileControlMessengers() {
-
+ protected virtual void CreateMobileControlMessengers()
+ {
+
}
}