Updates to IRunRouteAction to require specification of sourceListKey

This commit is contained in:
Neil Dorin
2019-12-04 22:36:25 -07:00
parent 042c94e6cf
commit e74d8c2497
11 changed files with 264 additions and 54 deletions

View File

@@ -69,7 +69,45 @@ namespace PepperDash.Essentials
var routeRoom = Room as IRunRouteAction;
if(routeRoom != null)
Parent.AddAction(string.Format(@"/room/{0}/source", Room.Key), new Action<SourceSelectMessageContent>(c =>
routeRoom.RunRouteAction(c.SourceListItem)));
{
if(string.IsNullOrEmpty(c.SourceListKey))
routeRoom.RunRouteAction(c.SourceListItem, Room.SourceListKey);
else
{
routeRoom.RunRouteAction(c.SourceListItem, c.SourceListKey);
}
}));
//****************Temp until testing complete. Then move to own messenger***********************
var routeDevice = DeviceManager.GetDeviceForKey("inRoomPc-1") as IRunRouteAction;
if (routeDevice != null)
{
Parent.AddAction(string.Format(@"/device/inRoomPc-1/source"), new Action<SourceSelectMessageContent>(c =>
{
routeDevice.RunRouteAction(c.SourceListItem, c.SourceListKey);
}));
var sinkDevice = routeDevice as IRoutingSinkNoSwitching;
if(sinkDevice != null)
{
sinkDevice.CurrentSourceChange += new SourceInfoChangeHandler((o, a) =>
{
var contentObject = new
{
selectedSourceKey = sinkDevice.CurrentSourceInfoKey
};
Parent.SendMessageToServer(JObject.FromObject(new
{
type = "/device/inRoomPc-1/status",
content = contentObject
}));
});
}
}
var defaultRoom = Room as IRunDefaultPresentRoute;
if(defaultRoom != null)
@@ -455,6 +493,7 @@ namespace PepperDash.Essentials
public class SourceSelectMessageContent
{
public string SourceListItem { get; set; }
public string SourceListKey { get; set; }
}
/// <summary>

View File

@@ -186,7 +186,7 @@ namespace PepperDash.Essentials.Fusion
FusionRoom.SystemPowerOn.OutputSig.SetSigFalseAction((Room as EssentialsHuddleVtc1Room).PowerOnToDefaultOrLastSource);
FusionRoom.SystemPowerOff.OutputSig.SetSigFalseAction(() => (Room as EssentialsHuddleVtc1Room).RunRouteAction("roomOff"));
FusionRoom.SystemPowerOff.OutputSig.SetSigFalseAction(() => (Room as EssentialsHuddleVtc1Room).RunRouteAction("roomOff", Room.SourceListKey));
// NO!! room.RoomIsOn.LinkComplementInputSig(FusionRoom.SystemPowerOff.InputSig);
@@ -342,7 +342,7 @@ namespace PepperDash.Essentials.Fusion
// Current Source
var defaultDisplaySourceNone = FusionRoom.CreateOffsetBoolSig((uint)joinOffset + 8, displayName + "Source None", eSigIoMask.InputOutputSig);
defaultDisplaySourceNone.OutputSig.UserObject = new Action<bool>(b => { if (!b) (Room as EssentialsHuddleVtc1Room).RunRouteAction("roomOff"); }); ;
defaultDisplaySourceNone.OutputSig.UserObject = new Action<bool>(b => { if (!b) (Room as EssentialsHuddleVtc1Room).RunRouteAction("roomOff", Room.SourceListKey); }); ;
}
}
}

View File

@@ -348,7 +348,7 @@ namespace PepperDash.Essentials
CrestronEnvironment.Sleep(1000);
RunRouteAction("roomOff");
RunRouteAction("roomOff", SourceListKey);
}
/// <summary>
@@ -357,7 +357,7 @@ namespace PepperDash.Essentials
public override bool RunDefaultPresentRoute()
{
if (DefaultSourceItem != null)
RunRouteAction(DefaultSourceItem);
RunRouteAction(DefaultSourceItem, SourceListKey);
return DefaultSourceItem != null;
}
@@ -368,7 +368,7 @@ namespace PepperDash.Essentials
/// <returns></returns>
public bool RunDefaultCallRoute()
{
RunRouteAction(DefaultCodecRouteString);
RunRouteAction(DefaultCodecRouteString, SourceListKey);
return true;
}
@@ -376,9 +376,9 @@ namespace PepperDash.Essentials
///
/// </summary>
/// <param name="routeKey"></param>
public void RunRouteAction(string routeKey)
public void RunRouteAction(string routeKey, string sourceListKey)
{
RunRouteAction(routeKey, null);
RunRouteAction(routeKey, sourceListKey, null);
}
/// <summary>
@@ -386,7 +386,7 @@ namespace PepperDash.Essentials
/// route or commands
/// </summary>
/// <param name="name"></param>
public void RunRouteAction(string routeKey, Action successCallback)
public void RunRouteAction(string routeKey, string sourceListKey, Action successCallback)
{
// Run this on a separate thread
new CTimer(o =>
@@ -398,10 +398,10 @@ namespace PepperDash.Essentials
{
Debug.Console(1, this, "Run route action '{0}'", routeKey);
var dict = ConfigReader.ConfigObject.GetSourceListForKey(SourceListKey);
var dict = ConfigReader.ConfigObject.GetSourceListForKey(sourceListKey);
if (dict == null)
{
Debug.Console(1, this, "WARNING: Config source list '{0}' not found", SourceListKey);
Debug.Console(1, this, "WARNING: Config source list '{0}' not found", sourceListKey);
return;
}
@@ -619,7 +619,7 @@ namespace PepperDash.Essentials
{
if (!EnablePowerOnToLastSource || LastSourceKey == null)
return;
RunRouteAction(LastSourceKey);
RunRouteAction(LastSourceKey, SourceListKey);
}
/// <summary>
@@ -630,7 +630,7 @@ namespace PepperDash.Essentials
var allRooms = DeviceManager.AllDevices.Where(d =>
d is EssentialsHuddleSpaceRoom && !(d as EssentialsHuddleSpaceRoom).ExcludeFromGlobalFunctions);
foreach (var room in allRooms)
(room as EssentialsHuddleSpaceRoom).RunRouteAction("roomOff");
(room as EssentialsHuddleSpaceRoom).RunRouteAction("roomOff", (room as EssentialsHuddleSpaceRoom).SourceListKey);
}
#region IPrivacy Members

View File

@@ -223,7 +223,7 @@ namespace PepperDash.Essentials
CrestronEnvironment.Sleep(1000);
RunRouteAction("roomOff");
RunRouteAction("roomOff", SourceListKey);
}
/// <summary>
@@ -237,7 +237,7 @@ namespace PepperDash.Essentials
return false;
}
RunRouteAction(DefaultSourceItem);
RunRouteAction(DefaultSourceItem, SourceListKey);
return true;
}
@@ -260,9 +260,9 @@ namespace PepperDash.Essentials
///
/// </summary>
/// <param name="routeKey"></param>
public void RunRouteAction(string routeKey)
public void RunRouteAction(string routeKey, string sourceListKey)
{
RunRouteAction(routeKey, null);
RunRouteAction(routeKey, sourceListKey, null);
}
/// <summary>
@@ -270,16 +270,16 @@ namespace PepperDash.Essentials
/// route or commands
/// </summary>
/// <param name="name"></param>
public void RunRouteAction(string routeKey, Action successCallback)
public void RunRouteAction(string routeKey, string sourceListKey, Action successCallback)
{
// Run this on a separate thread
new CTimer(o =>
{
Debug.Console(1, this, "Run route action '{0}'", routeKey);
var dict = ConfigReader.ConfigObject.GetSourceListForKey(SourceListKey);
var dict = ConfigReader.ConfigObject.GetSourceListForKey(sourceListKey);
if(dict == null)
{
Debug.Console(1, this, "WARNING: Config source list '{0}' not found", SourceListKey);
Debug.Console(1, this, "WARNING: Config source list '{0}' not found", sourceListKey);
return;
}
@@ -287,7 +287,7 @@ namespace PepperDash.Essentials
if (!dict.ContainsKey(routeKey))
{
Debug.Console(1, this, "WARNING: No item '{0}' found on config list '{1}'",
routeKey, SourceListKey);
routeKey, sourceListKey);
return;
}
@@ -426,7 +426,7 @@ namespace PepperDash.Essentials
{
if (!EnablePowerOnToLastSource || LastSourceKey == null)
return;
RunRouteAction(LastSourceKey);
RunRouteAction(LastSourceKey, SourceListKey);
}
/// <summary>
@@ -494,7 +494,7 @@ namespace PepperDash.Essentials
var allRooms = DeviceManager.AllDevices.Where(d =>
d is EssentialsHuddleSpaceRoom && !(d as EssentialsHuddleSpaceRoom).ExcludeFromGlobalFunctions);
foreach (var room in allRooms)
(room as EssentialsHuddleSpaceRoom).RunRouteAction("roomOff");
(room as EssentialsHuddleSpaceRoom).RunRouteAction("roomOff", (room as EssentialsHuddleSpaceRoom).SourceListKey);
}
}
}

View File

@@ -348,7 +348,7 @@ namespace PepperDash.Essentials
CrestronEnvironment.Sleep(1000);
RunRouteAction("roomOff");
RunRouteAction("roomOff", SourceListKey);
}
/// <summary>
@@ -357,7 +357,7 @@ namespace PepperDash.Essentials
public override bool RunDefaultPresentRoute()
{
if (DefaultSourceItem != null)
RunRouteAction(DefaultSourceItem);
RunRouteAction(DefaultSourceItem, SourceListKey);
return DefaultSourceItem != null;
}
@@ -368,7 +368,7 @@ namespace PepperDash.Essentials
/// <returns></returns>
public bool RunDefaultCallRoute()
{
RunRouteAction(DefaultCodecRouteString);
RunRouteAction(DefaultCodecRouteString, SourceListKey);
return true;
}
@@ -376,9 +376,9 @@ namespace PepperDash.Essentials
///
/// </summary>
/// <param name="routeKey"></param>
public void RunRouteAction(string routeKey)
public void RunRouteAction(string routeKey, string sourceListKey)
{
RunRouteAction(routeKey, null);
RunRouteAction(routeKey, sourceListKey, null);
}
/// <summary>
@@ -386,7 +386,7 @@ namespace PepperDash.Essentials
/// route or commands
/// </summary>
/// <param name="name"></param>
public void RunRouteAction(string routeKey, Action successCallback)
public void RunRouteAction(string routeKey, string sourceListKey, Action successCallback)
{
// Run this on a separate thread
new CTimer(o =>
@@ -398,10 +398,10 @@ namespace PepperDash.Essentials
{
Debug.Console(1, this, "Run route action '{0}'", routeKey);
var dict = ConfigReader.ConfigObject.GetSourceListForKey(SourceListKey);
var dict = ConfigReader.ConfigObject.GetSourceListForKey(sourceListKey);
if (dict == null)
{
Debug.Console(1, this, "WARNING: Config source list '{0}' not found", SourceListKey);
Debug.Console(1, this, "WARNING: Config source list '{0}' not found", sourceListKey);
return;
}
@@ -608,7 +608,7 @@ namespace PepperDash.Essentials
{
if (!EnablePowerOnToLastSource || LastSourceKey == null)
return;
RunRouteAction(LastSourceKey);
RunRouteAction(LastSourceKey, SourceListKey);
}
/// <summary>
@@ -619,7 +619,7 @@ namespace PepperDash.Essentials
var allRooms = DeviceManager.AllDevices.Where(d =>
d is EssentialsHuddleSpaceRoom && !(d as EssentialsHuddleSpaceRoom).ExcludeFromGlobalFunctions);
foreach (var room in allRooms)
(room as EssentialsHuddleSpaceRoom).RunRouteAction("roomOff");
(room as EssentialsHuddleSpaceRoom).RunRouteAction("roomOff", (room as EssentialsHuddleSpaceRoom).SourceListKey);
}
#region IPrivacy Members

View File

@@ -941,7 +941,7 @@ namespace PepperDash.Essentials
if (_CurrentRoom != null)
_CurrentRoom.CurrentSourceChange += new SourceInfoChangeHandler(CurrentRoom_CurrentSingleSourceChange);
TriList.SetSigFalseAction(UIBoolJoin.CallStopSharingPress, () => _CurrentRoom.RunRouteAction("codecOsd"));
TriList.SetSigFalseAction(UIBoolJoin.CallStopSharingPress, () => _CurrentRoom.RunRouteAction("codecOsd", _CurrentRoom.SourceListKey));
(Parent as EssentialsPanelMainInterfaceDriver).HeaderDriver.SetupHeaderButtons(this, CurrentRoom);
}
@@ -987,7 +987,7 @@ namespace PepperDash.Essentials
if (CurrentRoom.CurrentSourceInfo != null && CurrentRoom.CurrentSourceInfo.DisableCodecSharing)
{
Debug.Console(1, CurrentRoom, "Transitioning to in-call, cancelling non-sharable source");
CurrentRoom.RunRouteAction("codecOsd");
CurrentRoom.RunRouteAction("codecOsd", CurrentRoom.SourceListKey);
}
}

View File

@@ -332,7 +332,7 @@ namespace PepperDash.Essentials.Core.Fusion
FusionRoom.SystemPowerOn.OutputSig.SetSigFalseAction((Room as EssentialsRoomBase).PowerOnToDefaultOrLastSource);
FusionRoom.SystemPowerOff.OutputSig.SetSigFalseAction(() => (Room as IRunRouteAction).RunRouteAction("roomOff"));
FusionRoom.SystemPowerOff.OutputSig.SetSigFalseAction(() => (Room as IRunRouteAction).RunRouteAction("roomOff", Room.SourceListKey));
// NO!! room.RoomIsOn.LinkComplementInputSig(FusionRoom.SystemPowerOff.InputSig);
FusionRoom.ErrorMessage.InputSig.StringValue =
"3: 7 Errors: This is a really long error message;This is a really long error message;This is a really long error message;This is a really long error message;This is a really long error message;This is a really long error message;This is a really long error message;";
@@ -1086,7 +1086,7 @@ namespace PepperDash.Essentials.Core.Fusion
SourceToFeedbackSigs.Add(pSrc, sigD.InputSig);
// And respond to selection in Fusion
sigD.OutputSig.SetSigFalseAction(() => (Room as IRunRouteAction).RunRouteAction(routeKey));
sigD.OutputSig.SetSigFalseAction(() => (Room as IRunRouteAction).RunRouteAction(routeKey, Room.SourceListKey));
}
catch (Exception)
{
@@ -1288,7 +1288,7 @@ namespace PepperDash.Essentials.Core.Fusion
// Current Source
var defaultDisplaySourceNone = FusionRoom.CreateOffsetBoolSig((uint)joinOffset + 8, displayName + "Source None", eSigIoMask.InputOutputSig);
defaultDisplaySourceNone.OutputSig.UserObject = new Action<bool>(b => { if (!b) (Room as IRunRouteAction).RunRouteAction("roomOff"); }); ;
defaultDisplaySourceNone.OutputSig.UserObject = new Action<bool>(b => { if (!b) (Room as IRunRouteAction).RunRouteAction("roomOff", Room.SourceListKey); }); ;
}
}

View File

@@ -35,9 +35,10 @@ namespace PepperDash.Essentials.Core
/// </summary>
public interface IRunRouteAction
{
void RunRouteAction(string routeKey);
void RunRouteAction(string routeKey, string sourceListKey);
void RunRouteAction(string routeKey, string sourceListKey, Action successCallback);
void RunRouteAction(string routeKey, Action successCallback);
}
/// <summary>

View File

@@ -120,6 +120,7 @@
<Compile Include="Evertz\GenericHttpClient.cs" />
<Compile Include="ImageProcessors\AnalogWay\AnalongWayLiveCore.cs" />
<Compile Include="ImageProcessors\AnalogWay\AnalogWayLiveCorePropertiesConfig.cs" />
<Compile Include="SoftCodec\BlueJeansPc.cs" />
<Compile Include="VideoCodec\CiscoCodec\CiscoCamera.cs" />
<Compile Include="VideoCodec\CiscoCodec\RoomPresets.cs" />
<Compile Include="Cameras\CameraControl.cs" />

View File

@@ -144,22 +144,27 @@ namespace PepperDash.Essentials.Devices.Common
return new Core.Devices.Laptop(key, name);
}
else if (typeName == "mockvc")
{
return new VideoCodec.MockVC(dc);
}
else if (typeName == "bluejeanspc")
{
return new SoftCodec.BlueJeansPc(key, name);
}
else if (typeName == "mockac")
{
var props = JsonConvert.DeserializeObject<AudioCodec.MockAcPropertiesConfig>(properties.ToString());
return new AudioCodec.MockAC(key, name, props);
}
else if (typeName == "mockvc")
{
return new VideoCodec.MockVC(dc);
}
else if (typeName.StartsWith("ciscospark"))
{
var comm = CommFactory.CreateCommForDevice(dc);
return new VideoCodec.Cisco.CiscoSparkCodec(dc, comm);
}
else if (typeName == "mockac")
{
var props = JsonConvert.DeserializeObject<AudioCodec.MockAcPropertiesConfig>(properties.ToString());
return new AudioCodec.MockAC(key, name, props);
}
else if (typeName.StartsWith("ciscospark"))
{
var comm = CommFactory.CreateCommForDevice(dc);
return new VideoCodec.Cisco.CiscoSparkCodec(dc, comm);
}
else if (typeName == "zoomroom")
{

View File

@@ -0,0 +1,164 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Crestron.SimplSharp;
using PepperDash.Core;
using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Routing;
using PepperDash.Essentials.Core.Devices;
using PepperDash.Essentials.Core.Config;
namespace PepperDash.Essentials.Devices.Common.SoftCodec
{
public class BlueJeansPc : InRoomPc, IRoutingInputs, IRunRouteAction, IRoutingSinkNoSwitching
{
public RoutingInputPort AnyVideoIn { get; private set; }
#region IRoutingInputs Members
public RoutingPortCollection<RoutingInputPort> InputPorts { get; private set; }
#endregion
public BlueJeansPc(string key, string name)
: base(key, name)
{
InputPorts = new RoutingPortCollection<RoutingInputPort>();
InputPorts.Add(AnyVideoIn = new RoutingInputPort(RoutingPortNames.AnyVideoIn, eRoutingSignalType.AudioVideo, eRoutingPortConnectionType.None, 0, this));
}
#region IRunRouteAction Members
public void RunRouteAction(string routeKey, string sourceListKey)
{
RunRouteAction(routeKey, sourceListKey, null);
}
public void RunRouteAction(string routeKey, string sourceListKey, Action successCallback)
{
CrestronInvoke.BeginInvoke(o =>
{
Debug.Console(1, this, "Run route action '{0}' on SourceList: {1}", routeKey, sourceListKey);
var dict = ConfigReader.ConfigObject.GetSourceListForKey(sourceListKey);
if (dict == null)
{
Debug.Console(1, this, "WARNING: Config source list '{0}' not found", sourceListKey);
return;
}
// Try to get the list item by it's string key
if (!dict.ContainsKey(routeKey))
{
Debug.Console(1, this, "WARNING: No item '{0}' found on config list '{1}'",
routeKey, sourceListKey);
return;
}
var item = dict[routeKey];
foreach (var route in item.RouteList)
{
DoRoute(route);
}
// store the name and UI info for routes
if (item.SourceKey == "none")
{
CurrentSourceInfoKey = routeKey;
CurrentSourceInfo = null;
}
else if (item.SourceKey != null)
{
CurrentSourceInfoKey = routeKey;
CurrentSourceInfo = item;
}
// report back when done
if (successCallback != null)
successCallback();
});
}
#endregion
/// <summary>
///
/// </summary>
/// <param name="route"></param>
/// <returns></returns>
bool DoRoute(SourceRouteListItem route)
{
IRoutingSinkNoSwitching dest = null;
dest = DeviceManager.GetDeviceForKey(route.DestinationKey) as IRoutingSinkNoSwitching;
if (dest == null)
{
Debug.Console(1, this, "Cannot route, unknown destination '{0}'", route.DestinationKey);
return false;
}
if (route.SourceKey.Equals("$off", StringComparison.OrdinalIgnoreCase))
{
dest.ReleaseRoute();
if (dest is IPower)
(dest as IPower).PowerOff();
}
else
{
var source = DeviceManager.GetDeviceForKey(route.SourceKey) as IRoutingOutputs;
if (source == null)
{
Debug.Console(1, this, "Cannot route unknown source '{0}' to {1}", route.SourceKey, route.DestinationKey);
return false;
}
dest.ReleaseAndMakeRoute(source, route.Type);
}
return true;
}
#region IHasCurrentSourceInfoChange Members
public string CurrentSourceInfoKey { get; set; }
/// <summary>
/// The SourceListItem last run - containing names and icons
/// </summary>
public SourceListItem CurrentSourceInfo
{
get { return _CurrentSourceInfo; }
set
{
if (value == _CurrentSourceInfo) return;
var handler = CurrentSourceChange;
// remove from in-use tracker, if so equipped
if (_CurrentSourceInfo != null && _CurrentSourceInfo.SourceDevice is IInUseTracking)
(_CurrentSourceInfo.SourceDevice as IInUseTracking).InUseTracker.RemoveUser(this, "control");
if (handler != null)
handler(_CurrentSourceInfo, ChangeType.WillChange);
_CurrentSourceInfo = value;
// add to in-use tracking
if (_CurrentSourceInfo != null && _CurrentSourceInfo.SourceDevice is IInUseTracking)
(_CurrentSourceInfo.SourceDevice as IInUseTracking).InUseTracker.AddUser(this, "control");
if (handler != null)
handler(_CurrentSourceInfo, ChangeType.DidChange);
}
}
SourceListItem _CurrentSourceInfo;
public event SourceInfoChangeHandler CurrentSourceChange;
#endregion
}
}