mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-16 13:15:03 +00:00
Adds properties config for SIMPL Messenger classes and adds SetupDeviceMessengers() to MobileControlDdvc01RoomBridge to add individual device messengers
This commit is contained in:
@@ -95,7 +95,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
|
|||||||
: base(key, messagePath)
|
: base(key, messagePath)
|
||||||
{
|
{
|
||||||
EISC = eisc;
|
EISC = eisc;
|
||||||
JoinStart = joinStart;
|
JoinStart = joinStart - 1;
|
||||||
|
|
||||||
EISC.SetUShortSigAction(UshortJoin.CameraPresetCount + JoinStart, (u) => SendCameraFullMessageObject());
|
EISC.SetUShortSigAction(UshortJoin.CameraPresetCount + JoinStart, (u) => SendCameraFullMessageObject());
|
||||||
|
|
||||||
@@ -130,7 +130,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
|
|||||||
// camera presets
|
// camera presets
|
||||||
for (uint i = 1; i <= 6; i++)
|
for (uint i = 1; i <= 6; i++)
|
||||||
{
|
{
|
||||||
addAction("/cameraPreset" + (i), BoolJoin.CameraPresetStart + JoinStart + i);
|
addAction("/cameraPreset" + (i), BoolJoin.CameraPresetStart + i + JoinStart);
|
||||||
}
|
}
|
||||||
|
|
||||||
asc.AddAction(MessagePath + "/fullStatus", new Action(SendCameraFullMessageObject));
|
asc.AddAction(MessagePath + "/fullStatus", new Action(SendCameraFullMessageObject));
|
||||||
@@ -150,7 +150,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
|
|||||||
{
|
{
|
||||||
for (uint i = 1; i <= EISC.GetUshort(UshortJoin.CameraPresetCount); i++)
|
for (uint i = 1; i <= EISC.GetUshort(UshortJoin.CameraPresetCount); i++)
|
||||||
{
|
{
|
||||||
var presetName = EISC.GetString(JoinStart + StringJoin.CameraPresetNameStart + i);
|
var presetName = EISC.GetString(StringJoin.CameraPresetNameStart + i + JoinStart);
|
||||||
var preset = new CameraPreset((int)i, presetName, string.IsNullOrEmpty(presetName), true);
|
var preset = new CameraPreset((int)i, presetName, string.IsNullOrEmpty(presetName), true);
|
||||||
presetList.Add(preset);
|
presetList.Add(preset);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
|
|||||||
: base(key, messagePath)
|
: base(key, messagePath)
|
||||||
{
|
{
|
||||||
EISC = eisc;
|
EISC = eisc;
|
||||||
JoinStart = joinStart;
|
JoinStart = joinStart - 1;
|
||||||
|
|
||||||
EISC.SetStringSigAction(JoinStart + StringJoin.CurrentSource, (s) => SendRoutingFullMessageObject(s));
|
EISC.SetStringSigAction(JoinStart + StringJoin.CurrentSource, (s) => SendRoutingFullMessageObject(s));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using Crestron.SimplSharp;
|
||||||
|
|
||||||
|
using PepperDash.Essentials.Bridges;
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.AppServer.Messengers
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Properties to configure a SIMPL Messenger
|
||||||
|
/// </summary>
|
||||||
|
public class SimplMessengerPropertiesConfig : EiscApiPropertiesConfig.ApiDevicePropertiesConfig
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -110,7 +110,6 @@ namespace PepperDash.Essentials.Room.MobileControl
|
|||||||
/// 621
|
/// 621
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public const uint SourceIsEnabledJoinStart = 621;
|
public const uint SourceIsEnabledJoinStart = 621;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class UshortJoin
|
public class UshortJoin
|
||||||
@@ -755,6 +754,8 @@ namespace PepperDash.Essentials.Room.MobileControl
|
|||||||
co.Devices.Add(conf);
|
co.Devices.Add(conf);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
SetupDeviceMessengers();
|
||||||
|
|
||||||
Debug.Console(0, this, "******* CONFIG FROM DDVC: \r{0}", JsonConvert.SerializeObject(ConfigReader.ConfigObject, Formatting.Indented));
|
Debug.Console(0, this, "******* CONFIG FROM DDVC: \r{0}", JsonConvert.SerializeObject(ConfigReader.ConfigObject, Formatting.Indented));
|
||||||
|
|
||||||
var handler = ConfigurationIsReady;
|
var handler = ConfigurationIsReady;
|
||||||
@@ -766,6 +767,63 @@ namespace PepperDash.Essentials.Room.MobileControl
|
|||||||
ConfigIsLoaded = true;
|
ConfigIsLoaded = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Iterates device config and adds messengers as neede for each device type
|
||||||
|
/// </summary>
|
||||||
|
void SetupDeviceMessengers()
|
||||||
|
{
|
||||||
|
try
|
||||||
|
{
|
||||||
|
foreach (var device in ConfigReader.ConfigObject.Devices)
|
||||||
|
{
|
||||||
|
if (device.Group.Equals("appServerMessenger"))
|
||||||
|
{
|
||||||
|
var props = JsonConvert.DeserializeObject<SimplMessengerPropertiesConfig>(device.Properties.ToString());
|
||||||
|
|
||||||
|
var messengerKey = string.Format("device-{0}-{1}", this.Key, Parent.Key);
|
||||||
|
|
||||||
|
MessengerBase messenger = null;
|
||||||
|
|
||||||
|
var dev = ConfigReader.ConfigObject.GetDeviceForKey(props.DeviceKey);
|
||||||
|
|
||||||
|
if (dev == null)
|
||||||
|
{
|
||||||
|
Debug.Console(1, this, "Unable to find device config for key: '{0}'", props.DeviceKey);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var type = device.Type.ToLower();
|
||||||
|
|
||||||
|
if (type.Equals("simplcameramessenger"))
|
||||||
|
{
|
||||||
|
Debug.Console(2, this, "Adding SIMPLCameraMessenger for: '{0}'", props.DeviceKey);
|
||||||
|
messenger = new SIMPLCameraMessenger(messengerKey, EISC, "/device/" + props.DeviceKey, props.JoinStart);
|
||||||
|
|
||||||
|
}
|
||||||
|
else if (type.Equals("simplroutemessenger"))
|
||||||
|
{
|
||||||
|
Debug.Console(2, this, "Adding SIMPLRouteMessenger for: '{0}'", props.DeviceKey);
|
||||||
|
messenger = new SIMPLRouteMessenger(messengerKey, EISC, "/device/" + props.DeviceKey, props.JoinStart);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (messenger != null)
|
||||||
|
{
|
||||||
|
DeviceManager.AddDevice(messenger);
|
||||||
|
messenger.RegisterWithAppServer(Parent);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.Console(2, this, "Unable to add messenger for device: '{0}' of type: '{1}'", props.DeviceKey, type);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Debug.Console(2, this, "Error Setting up Device Managers: {0}", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
///
|
///
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
@@ -269,10 +269,10 @@ namespace PepperDash.Essentials.Bridges
|
|||||||
public EssentialsControlPropertiesConfig Control { get; set; }
|
public EssentialsControlPropertiesConfig Control { get; set; }
|
||||||
|
|
||||||
[JsonProperty("devices")]
|
[JsonProperty("devices")]
|
||||||
public List<ApiDevice> Devices { get; set; }
|
public List<ApiDevicePropertiesConfig> Devices { get; set; }
|
||||||
|
|
||||||
|
|
||||||
public class ApiDevice
|
public class ApiDevicePropertiesConfig
|
||||||
{
|
{
|
||||||
[JsonProperty("deviceKey")]
|
[JsonProperty("deviceKey")]
|
||||||
public string DeviceKey { get; set; }
|
public string DeviceKey { get; set; }
|
||||||
|
|||||||
@@ -115,8 +115,9 @@
|
|||||||
<Compile Include="AppServer\Messengers\Ddvc01VtcMessenger.cs" />
|
<Compile Include="AppServer\Messengers\Ddvc01VtcMessenger.cs" />
|
||||||
<Compile Include="AppServer\Messengers\IRunRouteActionMessenger.cs" />
|
<Compile Include="AppServer\Messengers\IRunRouteActionMessenger.cs" />
|
||||||
<Compile Include="AppServer\Messengers\MessengerBase.cs" />
|
<Compile Include="AppServer\Messengers\MessengerBase.cs" />
|
||||||
<Compile Include="AppServer\Messengers\SIMPLCameraBaseMessenger.cs" />
|
<Compile Include="AppServer\Messengers\SIMPLCameraMessenger.cs" />
|
||||||
<Compile Include="AppServer\Messengers\SIMPLIRunRouteActionMessenger.cs" />
|
<Compile Include="AppServer\Messengers\SimplMessengerPropertiesConfig.cs" />
|
||||||
|
<Compile Include="AppServer\Messengers\SIMPLRouteMessenger.cs" />
|
||||||
<Compile Include="AppServer\Messengers\SystemMonitorMessenger.cs" />
|
<Compile Include="AppServer\Messengers\SystemMonitorMessenger.cs" />
|
||||||
<Compile Include="AppServer\Messengers\VideoCodecBaseMessenger.cs" />
|
<Compile Include="AppServer\Messengers\VideoCodecBaseMessenger.cs" />
|
||||||
<Compile Include="Audio\EssentialsVolumeLevelConfig.cs" />
|
<Compile Include="Audio\EssentialsVolumeLevelConfig.cs" />
|
||||||
|
|||||||
@@ -39,5 +39,25 @@ namespace PepperDash.Essentials.Core.Config
|
|||||||
|
|
||||||
return SourceLists[key];
|
return SourceLists[key];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Checks Devices for an item with a Key that matches and returns it if found. Otherwise, retunes null
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="key">Key of desired device</param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public DeviceConfig GetDeviceForKey(string key)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(key))
|
||||||
|
return null;
|
||||||
|
|
||||||
|
var deviceConfig = Devices.FirstOrDefault(d => d.Key.Equals(key));
|
||||||
|
|
||||||
|
if (deviceConfig != null)
|
||||||
|
return deviceConfig;
|
||||||
|
else
|
||||||
|
{
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user