mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-16 05:05:00 +00:00
Updates SIMPLCameraMessenger and adds SIMPLRouteMessenger
This commit is contained in:
@@ -7,7 +7,6 @@ using Crestron.SimplSharp;
|
|||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
using PepperDash.Essentials.Core;
|
using PepperDash.Essentials.Core;
|
||||||
|
|
||||||
using Newtonsoft.Json.Linq;
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.AppServer.Messengers
|
namespace PepperDash.Essentials.AppServer.Messengers
|
||||||
{
|
{
|
||||||
@@ -16,7 +15,7 @@ namespace PepperDash.Essentials.AppServer.Messengers
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Device being bridged
|
/// Device being bridged
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public IRunRouteAction RoutingDevice {get; set;}
|
public IRunRouteAction RoutingDevice {get; private set;}
|
||||||
|
|
||||||
public IRunRouteActionMessenger(string key, IRunRouteAction routingDevice, string messagePath)
|
public IRunRouteActionMessenger(string key, IRunRouteAction routingDevice, string messagePath)
|
||||||
: base(key, messagePath)
|
: base(key, messagePath)
|
||||||
|
|||||||
@@ -1,176 +0,0 @@
|
|||||||
using System;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using Crestron.SimplSharp;
|
|
||||||
using Crestron.SimplSharpPro.DeviceSupport;
|
|
||||||
using Crestron.SimplSharpPro.EthernetCommunication;
|
|
||||||
|
|
||||||
using PepperDash.Core;
|
|
||||||
using PepperDash.Essentials.Core;
|
|
||||||
using PepperDash.Essentials.Devices.Common.Cameras;
|
|
||||||
|
|
||||||
namespace PepperDash.Essentials.AppServer.Messengers
|
|
||||||
{
|
|
||||||
public class SIMPLCameraBaseMessenger : MessengerBase
|
|
||||||
{
|
|
||||||
BasicTriList EISC;
|
|
||||||
|
|
||||||
CameraBase Camera;
|
|
||||||
|
|
||||||
uint JoinStart;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 811
|
|
||||||
/// </summary>
|
|
||||||
const uint BCameraControlUp = 1;
|
|
||||||
/// <summary>
|
|
||||||
/// 812
|
|
||||||
/// </summary>
|
|
||||||
const uint BCameraControlDown = 2;
|
|
||||||
/// <summary>
|
|
||||||
/// 813
|
|
||||||
/// </summary>
|
|
||||||
const uint BCameraControlLeft = 3;
|
|
||||||
/// <summary>
|
|
||||||
/// 814
|
|
||||||
/// </summary>
|
|
||||||
const uint BCameraControlRight = 4;
|
|
||||||
/// <summary>
|
|
||||||
/// 815
|
|
||||||
/// </summary>
|
|
||||||
const uint BCameraControlZoomIn = 5;
|
|
||||||
/// <summary>
|
|
||||||
/// 816
|
|
||||||
/// </summary>
|
|
||||||
const uint BCameraControlZoomOut = 6;
|
|
||||||
/// <summary>
|
|
||||||
/// 821 - 826
|
|
||||||
/// </summary>
|
|
||||||
const uint BCameraPresetStart = 11;
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// 831
|
|
||||||
/// </summary>
|
|
||||||
const uint BCameraModeAuto = 21;
|
|
||||||
/// <summary>
|
|
||||||
/// 832
|
|
||||||
/// </summary>
|
|
||||||
const uint BCameraModeManual = 22;
|
|
||||||
/// <summary>
|
|
||||||
/// 833
|
|
||||||
/// </summary>
|
|
||||||
const uint BCameraModeOff = 23;
|
|
||||||
|
|
||||||
|
|
||||||
public SIMPLCameraBaseMessenger(string key, CameraBase camera, BasicTriList eisc, string messagePath, uint joinStart)
|
|
||||||
: base(key, messagePath)
|
|
||||||
{
|
|
||||||
if (camera == null)
|
|
||||||
throw new ArgumentNullException("camera");
|
|
||||||
|
|
||||||
EISC = eisc;
|
|
||||||
Camera = camera;
|
|
||||||
JoinStart = joinStart;
|
|
||||||
|
|
||||||
var presetsCamera = Camera as IHasCameraPresets;
|
|
||||||
|
|
||||||
if (presetsCamera != null)
|
|
||||||
{
|
|
||||||
presetsCamera.PresetsListHasChanged += new EventHandler<EventArgs>(presetsCamera_PresetsListHasChanged);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void presetsCamera_PresetsListHasChanged(object sender, EventArgs e)
|
|
||||||
{
|
|
||||||
var presetsCamera = Camera as IHasCameraPresets;
|
|
||||||
|
|
||||||
var presetList = new List<CameraPreset>();
|
|
||||||
|
|
||||||
if (presetsCamera != null)
|
|
||||||
presetList = presetsCamera.Presets;
|
|
||||||
|
|
||||||
PostStatusMessage(new
|
|
||||||
{
|
|
||||||
presets = presetList
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
protected override void CustomRegisterWithAppServer(MobileControlSystemController appServerController)
|
|
||||||
{
|
|
||||||
var asc = appServerController;
|
|
||||||
|
|
||||||
|
|
||||||
// Add press and holds using helper action
|
|
||||||
Action<string, uint> addPHAction = (s, u) =>
|
|
||||||
AppServerController.AddAction(MessagePath + s, new PressAndHoldAction(b => EISC.SetBool(u, b)));
|
|
||||||
addPHAction("/cameraUp", BCameraControlUp + JoinStart);
|
|
||||||
addPHAction("/cameraDown", BCameraControlDown + JoinStart);
|
|
||||||
addPHAction("/cameraLeft", BCameraControlLeft + JoinStart);
|
|
||||||
addPHAction("/cameraRight", BCameraControlRight + JoinStart);
|
|
||||||
addPHAction("/cameraZoomIn", BCameraControlZoomIn + JoinStart);
|
|
||||||
addPHAction("/cameraZoomOut", BCameraControlZoomOut + JoinStart);
|
|
||||||
|
|
||||||
Action<string, uint> addAction = (s, u) =>
|
|
||||||
AppServerController.AddAction(MessagePath + s, new Action(() => EISC.PulseBool(u, 100)));
|
|
||||||
|
|
||||||
addAction("/cameraModeAuto", BCameraModeAuto);
|
|
||||||
addAction("/cameraModeManual", BCameraModeManual);
|
|
||||||
addAction("/cameraModeOff", BCameraModeOff);
|
|
||||||
|
|
||||||
// camera presets
|
|
||||||
for (uint i = 0; i < 6; i++)
|
|
||||||
{
|
|
||||||
addAction("/cameraPreset" + (i + 1), BCameraPresetStart + i);
|
|
||||||
}
|
|
||||||
|
|
||||||
asc.AddAction(MessagePath + "/fullStatus", new Action(SendCameraFullMessageObject));
|
|
||||||
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Helper method to update the full status of the camera
|
|
||||||
/// </summary>
|
|
||||||
void SendCameraFullMessageObject()
|
|
||||||
{
|
|
||||||
var presetsCamera = Camera as IHasCameraPresets;
|
|
||||||
|
|
||||||
var presetList = new List<CameraPreset>();
|
|
||||||
|
|
||||||
if (presetsCamera != null)
|
|
||||||
presetList = presetsCamera.Presets;
|
|
||||||
|
|
||||||
PostStatusMessage(new
|
|
||||||
{
|
|
||||||
cameraMode = GetCameraMode(),
|
|
||||||
hasPresets = Camera is IHasCameraPresets,
|
|
||||||
presets = presetList
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
///
|
|
||||||
/// </summary>
|
|
||||||
void PostCameraMode()
|
|
||||||
{
|
|
||||||
PostStatusMessage(new
|
|
||||||
{
|
|
||||||
cameraMode = GetCameraMode()
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Computes the current camera mode
|
|
||||||
/// </summary>
|
|
||||||
/// <returns></returns>
|
|
||||||
string GetCameraMode()
|
|
||||||
{
|
|
||||||
string m;
|
|
||||||
if (EISC.GetBool(BCameraModeAuto)) m = eCameraControlMode.Auto.ToString().ToLower();
|
|
||||||
else if (EISC.GetBool(BCameraModeManual)) m = eCameraControlMode.Manual.ToString().ToLower();
|
|
||||||
else m = eCameraControlMode.Off.ToString().ToLower();
|
|
||||||
return m;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,191 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using Crestron.SimplSharp;
|
||||||
|
using Crestron.SimplSharpPro.DeviceSupport;
|
||||||
|
using Crestron.SimplSharpPro.EthernetCommunication;
|
||||||
|
|
||||||
|
using PepperDash.Core;
|
||||||
|
using PepperDash.Essentials.Core;
|
||||||
|
using PepperDash.Essentials.Devices.Common.Cameras;
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.AppServer.Messengers
|
||||||
|
{
|
||||||
|
public class SIMPLCameraMessenger : MessengerBase
|
||||||
|
{
|
||||||
|
BasicTriList EISC;
|
||||||
|
|
||||||
|
uint JoinStart;
|
||||||
|
|
||||||
|
public class BoolJoin
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 1
|
||||||
|
/// </summary>
|
||||||
|
public const uint CameraControlUp = 1;
|
||||||
|
/// <summary>
|
||||||
|
/// 2
|
||||||
|
/// </summary>
|
||||||
|
public const uint CameraControlDown = 2;
|
||||||
|
/// <summary>
|
||||||
|
/// 3
|
||||||
|
/// </summary>
|
||||||
|
public const uint CameraControlLeft = 3;
|
||||||
|
/// <summary>
|
||||||
|
/// 4
|
||||||
|
/// </summary>
|
||||||
|
public const uint CameraControlRight = 4;
|
||||||
|
/// <summary>
|
||||||
|
/// 5
|
||||||
|
/// </summary>
|
||||||
|
public const uint CameraControlZoomIn = 5;
|
||||||
|
/// <summary>
|
||||||
|
/// 6
|
||||||
|
/// </summary>
|
||||||
|
public const uint CameraControlZoomOut = 6;
|
||||||
|
/// <summary>
|
||||||
|
/// 10
|
||||||
|
/// </summary>
|
||||||
|
public const uint CameraHasPresets = 10;
|
||||||
|
/// <summary>
|
||||||
|
/// 11 - 20
|
||||||
|
/// </summary>
|
||||||
|
public const uint CameraPresetStart = 10;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// 21
|
||||||
|
/// </summary>
|
||||||
|
public const uint CameraModeAuto = 21;
|
||||||
|
/// <summary>
|
||||||
|
/// 22
|
||||||
|
/// </summary>
|
||||||
|
public const uint CameraModeManual = 22;
|
||||||
|
/// <summary>
|
||||||
|
/// 23
|
||||||
|
/// </summary>
|
||||||
|
public const uint CameraModeOff = 23;
|
||||||
|
/// <summary>
|
||||||
|
/// 24
|
||||||
|
/// </summary>
|
||||||
|
public const uint CameraSupportsModeAuto = 24;
|
||||||
|
/// <summary>
|
||||||
|
/// 25
|
||||||
|
/// </summary>
|
||||||
|
public const uint CameraSupportsModeOff = 25;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class UshortJoin
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 10
|
||||||
|
/// </summary>
|
||||||
|
public const uint CameraPresetCount = 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
public class StringJoin
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 11-20
|
||||||
|
/// </summary>
|
||||||
|
public const uint CameraPresetNameStart = 10;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SIMPLCameraMessenger(string key, BasicTriList eisc, string messagePath, uint joinStart)
|
||||||
|
: base(key, messagePath)
|
||||||
|
{
|
||||||
|
EISC = eisc;
|
||||||
|
JoinStart = joinStart;
|
||||||
|
|
||||||
|
EISC.SetUShortSigAction(UshortJoin.CameraPresetCount + JoinStart, (u) => SendCameraFullMessageObject());
|
||||||
|
|
||||||
|
EISC.SetBoolSigAction(BoolJoin.CameraModeAuto, (b) => PostCameraMode());
|
||||||
|
EISC.SetBoolSigAction(BoolJoin.CameraModeManual, (b) => PostCameraMode());
|
||||||
|
EISC.SetBoolSigAction(BoolJoin.CameraModeOff, (b) => PostCameraMode());
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected override void CustomRegisterWithAppServer(MobileControlSystemController appServerController)
|
||||||
|
{
|
||||||
|
var asc = appServerController;
|
||||||
|
|
||||||
|
|
||||||
|
// Add press and holds using helper action
|
||||||
|
Action<string, uint> addPHAction = (s, u) =>
|
||||||
|
AppServerController.AddAction(MessagePath + s, new PressAndHoldAction(b => EISC.SetBool(u, b)));
|
||||||
|
addPHAction("/cameraUp", BoolJoin.CameraControlUp + JoinStart);
|
||||||
|
addPHAction("/cameraDown", BoolJoin.CameraControlDown + JoinStart);
|
||||||
|
addPHAction("/cameraLeft", BoolJoin.CameraControlLeft + JoinStart);
|
||||||
|
addPHAction("/cameraRight", BoolJoin.CameraControlRight + JoinStart);
|
||||||
|
addPHAction("/cameraZoomIn", BoolJoin.CameraControlZoomIn + JoinStart);
|
||||||
|
addPHAction("/cameraZoomOut", BoolJoin.CameraControlZoomOut + JoinStart);
|
||||||
|
|
||||||
|
Action<string, uint> addAction = (s, u) =>
|
||||||
|
AppServerController.AddAction(MessagePath + s, new Action(() => EISC.PulseBool(u, 100)));
|
||||||
|
|
||||||
|
addAction("/cameraModeAuto", BoolJoin.CameraModeAuto);
|
||||||
|
addAction("/cameraModeManual", BoolJoin.CameraModeManual);
|
||||||
|
addAction("/cameraModeOff", BoolJoin.CameraModeOff);
|
||||||
|
|
||||||
|
// camera presets
|
||||||
|
for (uint i = 1; i <= 6; i++)
|
||||||
|
{
|
||||||
|
addAction("/cameraPreset" + (i), BoolJoin.CameraPresetStart + JoinStart + i);
|
||||||
|
}
|
||||||
|
|
||||||
|
asc.AddAction(MessagePath + "/fullStatus", new Action(SendCameraFullMessageObject));
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Helper method to update the full status of the camera
|
||||||
|
/// </summary>
|
||||||
|
void SendCameraFullMessageObject()
|
||||||
|
{
|
||||||
|
var presetList = new List<CameraPreset>();
|
||||||
|
|
||||||
|
// Build a list of camera presets based on the names and count
|
||||||
|
if (EISC.GetBool(JoinStart + BoolJoin.CameraHasPresets))
|
||||||
|
{
|
||||||
|
for (uint i = 1; i <= EISC.GetUshort(UshortJoin.CameraPresetCount); i++)
|
||||||
|
{
|
||||||
|
var presetName = EISC.GetString(JoinStart + StringJoin.CameraPresetNameStart + i);
|
||||||
|
var preset = new CameraPreset((int)i, presetName, string.IsNullOrEmpty(presetName), true);
|
||||||
|
presetList.Add(preset);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
PostStatusMessage(new
|
||||||
|
{
|
||||||
|
cameraMode = GetCameraMode(),
|
||||||
|
hasPresets = EISC.GetBool(BoolJoin.CameraHasPresets),
|
||||||
|
presets = presetList
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
///
|
||||||
|
/// </summary>
|
||||||
|
void PostCameraMode()
|
||||||
|
{
|
||||||
|
PostStatusMessage(new
|
||||||
|
{
|
||||||
|
cameraMode = GetCameraMode()
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Computes the current camera mode
|
||||||
|
/// </summary>
|
||||||
|
/// <returns></returns>
|
||||||
|
string GetCameraMode()
|
||||||
|
{
|
||||||
|
string m;
|
||||||
|
if (EISC.GetBool(BoolJoin.CameraModeAuto)) m = eCameraControlMode.Auto.ToString().ToLower();
|
||||||
|
else if (EISC.GetBool(BoolJoin.CameraModeManual)) m = eCameraControlMode.Manual.ToString().ToLower();
|
||||||
|
else m = eCameraControlMode.Off.ToString().ToLower();
|
||||||
|
return m;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,66 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using Crestron.SimplSharp;
|
||||||
|
using Crestron.SimplSharpPro.DeviceSupport;
|
||||||
|
|
||||||
|
using PepperDash.Core;
|
||||||
|
using PepperDash.Essentials.Core;
|
||||||
|
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.AppServer.Messengers
|
||||||
|
{
|
||||||
|
public class SIMPLRouteMessenger : MessengerBase
|
||||||
|
{
|
||||||
|
BasicTriList EISC;
|
||||||
|
|
||||||
|
uint JoinStart;
|
||||||
|
|
||||||
|
public class StringJoin
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// 1
|
||||||
|
/// </summary>
|
||||||
|
public const uint CurrentSource = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SIMPLRouteMessenger(string key, BasicTriList eisc, string messagePath, uint joinStart)
|
||||||
|
: base(key, messagePath)
|
||||||
|
{
|
||||||
|
EISC = eisc;
|
||||||
|
JoinStart = joinStart;
|
||||||
|
|
||||||
|
EISC.SetStringSigAction(JoinStart + StringJoin.CurrentSource, (s) => SendRoutingFullMessageObject(s));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
protected override void CustomRegisterWithAppServer(MobileControlSystemController appServerController)
|
||||||
|
{
|
||||||
|
appServerController.AddAction(MessagePath + "/fullStatus", new Action(() =>
|
||||||
|
{
|
||||||
|
SendRoutingFullMessageObject(EISC.GetString(JoinStart + StringJoin.CurrentSource));
|
||||||
|
}));
|
||||||
|
|
||||||
|
appServerController.AddAction(string.Format(@"/device/inRoomPc-1/source"), new Action<SourceSelectMessageContent>(c =>
|
||||||
|
{
|
||||||
|
EISC.SetString(JoinStart + StringJoin.CurrentSource, c.SourceListItem);
|
||||||
|
}));
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Helper method to update full status of the routing device
|
||||||
|
/// </summary>
|
||||||
|
void SendRoutingFullMessageObject(string sourceKey)
|
||||||
|
{
|
||||||
|
if (string.IsNullOrEmpty(sourceKey))
|
||||||
|
sourceKey = "none";
|
||||||
|
|
||||||
|
PostStatusMessage(new
|
||||||
|
{
|
||||||
|
selectedSourceKey = sourceKey
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -116,6 +116,7 @@
|
|||||||
<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\SIMPLCameraBaseMessenger.cs" />
|
||||||
|
<Compile Include="AppServer\Messengers\SIMPLIRunRouteActionMessenger.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" />
|
||||||
|
|||||||
@@ -80,8 +80,8 @@ namespace PepperDash.Essentials.Devices.Common.Cameras
|
|||||||
|
|
||||||
public class CameraPreset : PresetBase
|
public class CameraPreset : PresetBase
|
||||||
{
|
{
|
||||||
public CameraPreset(int id, string description, bool def, bool isDef)
|
public CameraPreset(int id, string description, bool isDefined, bool isDefinable)
|
||||||
: base(id, description, def, isDef)
|
: base(id, description, isDefined, isDefinable)
|
||||||
{
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user