Fixes bug that caused exceptions in Fusion GetProcessorEthernetValues() when ethernet link status came up. Adds logic for Fusion custom properties.

This commit is contained in:
Neil Dorin
2018-09-07 16:01:23 -06:00
parent 30506419df
commit 6a8ae5b244
2 changed files with 1928 additions and 1817 deletions

View File

@@ -1,355 +1,348 @@
using System; using System;
using System.Collections.Generic; using System.Collections.Generic;
using System.Linq; using System.Linq;
using System.Text; using System.Text;
using Crestron.SimplSharp; using Crestron.SimplSharp;
using Crestron.SimplSharp.CrestronIO; using Crestron.SimplSharp.CrestronIO;
using Crestron.SimplSharpPro; using Crestron.SimplSharpPro;
using Crestron.SimplSharpPro.DeviceSupport; using Crestron.SimplSharpPro.DeviceSupport;
using Crestron.SimplSharpPro.Fusion; using Crestron.SimplSharpPro.Fusion;
using PepperDash.Core; using PepperDash.Core;
using PepperDash.Essentials; using PepperDash.Essentials;
using PepperDash.Essentials.Core; using PepperDash.Essentials.Core;
using PepperDash.Essentials.Core.Config; using PepperDash.Essentials.Core.Config;
using PepperDash.Essentials.Devices.Common; using PepperDash.Essentials.Devices.Common;
using PepperDash.Essentials.Devices.Common.Occupancy; using PepperDash.Essentials.Devices.Common.Occupancy;
namespace PepperDash.Essentials.Fusion namespace PepperDash.Essentials.Fusion
{ {
public class EssentialsHuddleVtc1FusionController : EssentialsHuddleSpaceFusionSystemControllerBase public class EssentialsHuddleVtc1FusionController : EssentialsHuddleSpaceFusionSystemControllerBase
{ {
BooleanSigData CodecIsInCall; BooleanSigData CodecIsInCall;
public EssentialsHuddleVtc1FusionController(EssentialsHuddleVtc1Room room, uint ipId) public EssentialsHuddleVtc1FusionController(EssentialsHuddleVtc1Room room, uint ipId)
: base(room, ipId) : base(room, ipId)
{ {
} }
/// <summary> /// <summary>
/// Called in base class constructor before RVI and GUID files are built /// Called in base class constructor before RVI and GUID files are built
/// </summary> /// </summary>
protected override void ExecuteCustomSteps() protected override void ExecuteCustomSteps()
{ {
SetUpCodec(); SetUpCodec();
} }
/// <summary> /// <summary>
/// Creates a static asset for the codec and maps the joins to the main room symbol /// Creates a static asset for the codec and maps the joins to the main room symbol
/// </summary> /// </summary>
void SetUpCodec() void SetUpCodec()
{ {
try try
{ {
var codec = (Room as EssentialsHuddleVtc1Room).VideoCodec; var codec = (Room as EssentialsHuddleVtc1Room).VideoCodec;
if (codec == null) if (codec == null)
{ {
Debug.Console(1, this, "Cannot link codec to Fusion because codec is null"); Debug.Console(1, this, "Cannot link codec to Fusion because codec is null");
return; return;
} }
codec.UsageTracker = new UsageTracking(codec); codec.UsageTracker = new UsageTracking(codec);
codec.UsageTracker.UsageIsTracked = true; codec.UsageTracker.UsageIsTracked = true;
codec.UsageTracker.DeviceUsageEnded += UsageTracker_DeviceUsageEnded; codec.UsageTracker.DeviceUsageEnded += UsageTracker_DeviceUsageEnded;
var codecPowerOnAction = new Action<bool>(b => { if (!b) codec.StandbyDeactivate(); }); var codecPowerOnAction = new Action<bool>(b => { if (!b) codec.StandbyDeactivate(); });
var codecPowerOffAction = new Action<bool>(b => { if (!b) codec.StandbyActivate(); }); var codecPowerOffAction = new Action<bool>(b => { if (!b) codec.StandbyActivate(); });
// Map FusionRoom Attributes: // Map FusionRoom Attributes:
// Codec volume // Codec volume
var codecVolume = FusionRoom.CreateOffsetUshortSig(50, "Volume - Fader01", eSigIoMask.InputOutputSig); var codecVolume = FusionRoom.CreateOffsetUshortSig(50, "Volume - Fader01", eSigIoMask.InputOutputSig);
codecVolume.OutputSig.UserObject = new Action<ushort>(b => (codec as IBasicVolumeWithFeedback).SetVolume(b)); codecVolume.OutputSig.UserObject = new Action<ushort>(b => (codec as IBasicVolumeWithFeedback).SetVolume(b));
(codec as IBasicVolumeWithFeedback).VolumeLevelFeedback.LinkInputSig(codecVolume.InputSig); (codec as IBasicVolumeWithFeedback).VolumeLevelFeedback.LinkInputSig(codecVolume.InputSig);
// In Call Status // In Call Status
CodecIsInCall = FusionRoom.CreateOffsetBoolSig(69, "Conf - VC 1 In Call", eSigIoMask.InputSigOnly); CodecIsInCall = FusionRoom.CreateOffsetBoolSig(69, "Conf - VC 1 In Call", eSigIoMask.InputSigOnly);
codec.CallStatusChange += new EventHandler<PepperDash.Essentials.Devices.Common.Codec.CodecCallStatusItemChangeEventArgs>(codec_CallStatusChange); codec.CallStatusChange += new EventHandler<PepperDash.Essentials.Devices.Common.Codec.CodecCallStatusItemChangeEventArgs>(codec_CallStatusChange);
// Online status // Online status
if (codec is ICommunicationMonitor) if (codec is ICommunicationMonitor)
{ {
var c = codec as ICommunicationMonitor; var c = codec as ICommunicationMonitor;
var codecOnline = FusionRoom.CreateOffsetBoolSig(122, "Online - VC 1", eSigIoMask.InputSigOnly); var codecOnline = FusionRoom.CreateOffsetBoolSig(122, "Online - VC 1", eSigIoMask.InputSigOnly);
codecOnline.InputSig.BoolValue = c.CommunicationMonitor.Status == MonitorStatus.IsOk; codecOnline.InputSig.BoolValue = c.CommunicationMonitor.Status == MonitorStatus.IsOk;
c.CommunicationMonitor.StatusChange += (o, a) => c.CommunicationMonitor.StatusChange += (o, a) =>
{ {
codecOnline.InputSig.BoolValue = a.Status == MonitorStatus.IsOk; codecOnline.InputSig.BoolValue = a.Status == MonitorStatus.IsOk;
}; };
Debug.Console(0, this, "Linking '{0}' communication monitor to Fusion '{1}'", codec.Key, "Online - VC 1"); Debug.Console(0, this, "Linking '{0}' communication monitor to Fusion '{1}'", codec.Key, "Online - VC 1");
} }
// Codec IP Address // Codec IP Address
bool codecHasIpInfo = false; bool codecHasIpInfo = false;
var codecComm = codec.Communication; var codecComm = codec.Communication;
string codecIpAddress = string.Empty; string codecIpAddress = string.Empty;
int codecIpPort = 0; int codecIpPort = 0;
StringSigData codecIpAddressSig; StringSigData codecIpAddressSig;
StringSigData codecIpPortSig; StringSigData codecIpPortSig;
if(codecComm is GenericSshClient) if(codecComm is GenericSshClient)
{ {
codecIpAddress = (codecComm as GenericSshClient).Hostname; codecIpAddress = (codecComm as GenericSshClient).Hostname;
codecIpPort = (codecComm as GenericSshClient).Port; codecIpPort = (codecComm as GenericSshClient).Port;
codecHasIpInfo = true; codecHasIpInfo = true;
} }
else if (codecComm is GenericTcpIpClient) else if (codecComm is GenericTcpIpClient)
{ {
codecIpAddress = (codecComm as GenericTcpIpClient).Hostname; codecIpAddress = (codecComm as GenericTcpIpClient).Hostname;
codecIpPort = (codecComm as GenericTcpIpClient).Port; codecIpPort = (codecComm as GenericTcpIpClient).Port;
codecHasIpInfo = true; codecHasIpInfo = true;
} }
if (codecHasIpInfo) if (codecHasIpInfo)
{ {
codecIpAddressSig = FusionRoom.CreateOffsetStringSig(121, "IP Address - VC", eSigIoMask.InputSigOnly); codecIpAddressSig = FusionRoom.CreateOffsetStringSig(121, "IP Address - VC", eSigIoMask.InputSigOnly);
codecIpAddressSig.InputSig.StringValue = codecIpAddress; codecIpAddressSig.InputSig.StringValue = codecIpAddress;
codecIpPortSig = FusionRoom.CreateOffsetStringSig(150, "IP Port - VC", eSigIoMask.InputSigOnly); codecIpPortSig = FusionRoom.CreateOffsetStringSig(150, "IP Port - VC", eSigIoMask.InputSigOnly);
codecIpPortSig.InputSig.StringValue = codecIpPort.ToString(); codecIpPortSig.InputSig.StringValue = codecIpPort.ToString();
} }
var tempAsset = new FusionAsset(); var tempAsset = new FusionAsset();
var deviceConfig = ConfigReader.ConfigObject.Devices.FirstOrDefault(c => c.Key.Equals(codec.Key)); var deviceConfig = ConfigReader.ConfigObject.Devices.FirstOrDefault(c => c.Key.Equals(codec.Key));
if (FusionStaticAssets.ContainsKey(deviceConfig.Uid)) if (FusionStaticAssets.ContainsKey(deviceConfig.Uid))
{ {
tempAsset = FusionStaticAssets[deviceConfig.Uid]; tempAsset = FusionStaticAssets[deviceConfig.Uid];
} }
else else
{ {
// Create a new asset // Create a new asset
tempAsset = new FusionAsset(FusionRoomGuids.GetNextAvailableAssetNumber(FusionRoom), codec.Name, "Codec", ""); tempAsset = new FusionAsset(FusionRoomGuids.GetNextAvailableAssetNumber(FusionRoom), codec.Name, "Codec", "");
FusionStaticAssets.Add(deviceConfig.Uid, tempAsset); FusionStaticAssets.Add(deviceConfig.Uid, tempAsset);
} }
var codecAsset = FusionRoom.CreateStaticAsset(tempAsset.SlotNumber, tempAsset.Name, "Display", tempAsset.InstanceId); var codecAsset = FusionRoom.CreateStaticAsset(tempAsset.SlotNumber, tempAsset.Name, "Display", tempAsset.InstanceId);
codecAsset.PowerOn.OutputSig.UserObject = codecPowerOnAction; codecAsset.PowerOn.OutputSig.UserObject = codecPowerOnAction;
codecAsset.PowerOff.OutputSig.UserObject = codecPowerOffAction; codecAsset.PowerOff.OutputSig.UserObject = codecPowerOffAction;
codec.StandbyIsOnFeedback.LinkComplementInputSig(codecAsset.PowerOn.InputSig); codec.StandbyIsOnFeedback.LinkComplementInputSig(codecAsset.PowerOn.InputSig);
// TODO: Map relevant attributes on asset symbol // TODO: Map relevant attributes on asset symbol
codecAsset.TrySetMakeModel(codec); codecAsset.TrySetMakeModel(codec);
codecAsset.TryLinkAssetErrorToCommunication(codec); codecAsset.TryLinkAssetErrorToCommunication(codec);
} }
catch (Exception e) catch (Exception e)
{ {
Debug.Console(1, this, "Error setting up codec in Fusion: {0}", e); Debug.Console(1, this, "Error setting up codec in Fusion: {0}", e);
} }
} }
void codec_CallStatusChange(object sender, PepperDash.Essentials.Devices.Common.Codec.CodecCallStatusItemChangeEventArgs e) void codec_CallStatusChange(object sender, PepperDash.Essentials.Devices.Common.Codec.CodecCallStatusItemChangeEventArgs e)
{ {
var codec = (Room as EssentialsHuddleVtc1Room).VideoCodec; var codec = (Room as EssentialsHuddleVtc1Room).VideoCodec;
CodecIsInCall.InputSig.BoolValue = codec.IsInCall; CodecIsInCall.InputSig.BoolValue = codec.IsInCall;
} }
// These methods are overridden because they access the room class which is of a different type // These methods are overridden because they access the room class which is of a different type
protected override void CreateSymbolAndBasicSigs(uint ipId) protected override void CreateSymbolAndBasicSigs(uint ipId)
{ {
Debug.Console(1, this, "Creating Fusion Room symbol with GUID: {0}", RoomGuid); Debug.Console(1, this, "Creating Fusion Room symbol with GUID: {0}", RoomGuid);
FusionRoom = new FusionRoom(ipId, Global.ControlSystem, Room.Name, RoomGuid); FusionRoom = new FusionRoom(ipId, Global.ControlSystem, Room.Name, RoomGuid);
FusionRoom.ExtenderRoomViewSchedulingDataReservedSigs.Use(); FusionRoom.ExtenderRoomViewSchedulingDataReservedSigs.Use();
FusionRoom.ExtenderFusionRoomDataReservedSigs.Use(); FusionRoom.ExtenderFusionRoomDataReservedSigs.Use();
FusionRoom.Register(); FusionRoom.Register();
FusionRoom.FusionStateChange += FusionRoom_FusionStateChange; FusionRoom.FusionStateChange += FusionRoom_FusionStateChange;
FusionRoom.ExtenderRoomViewSchedulingDataReservedSigs.DeviceExtenderSigChange += FusionRoomSchedule_DeviceExtenderSigChange; FusionRoom.ExtenderRoomViewSchedulingDataReservedSigs.DeviceExtenderSigChange += FusionRoomSchedule_DeviceExtenderSigChange;
FusionRoom.ExtenderFusionRoomDataReservedSigs.DeviceExtenderSigChange += ExtenderFusionRoomDataReservedSigs_DeviceExtenderSigChange; FusionRoom.ExtenderFusionRoomDataReservedSigs.DeviceExtenderSigChange += ExtenderFusionRoomDataReservedSigs_DeviceExtenderSigChange;
FusionRoom.OnlineStatusChange += FusionRoom_OnlineStatusChange; FusionRoom.OnlineStatusChange += FusionRoom_OnlineStatusChange;
CrestronConsole.AddNewConsoleCommand(RequestFullRoomSchedule, "FusReqRoomSchedule", "Requests schedule of the room for the next 24 hours", ConsoleAccessLevelEnum.AccessOperator); CrestronConsole.AddNewConsoleCommand(RequestFullRoomSchedule, "FusReqRoomSchedule", "Requests schedule of the room for the next 24 hours", ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(ModifyMeetingEndTimeConsoleHelper, "FusReqRoomSchMod", "Ends or extends a meeting by the specified time", ConsoleAccessLevelEnum.AccessOperator); CrestronConsole.AddNewConsoleCommand(ModifyMeetingEndTimeConsoleHelper, "FusReqRoomSchMod", "Ends or extends a meeting by the specified time", ConsoleAccessLevelEnum.AccessOperator);
CrestronConsole.AddNewConsoleCommand(CreateAsHocMeeting, "FusCreateMeeting", "Creates and Ad Hoc meeting for on hour or until the next meeting", ConsoleAccessLevelEnum.AccessOperator); CrestronConsole.AddNewConsoleCommand(CreateAsHocMeeting, "FusCreateMeeting", "Creates and Ad Hoc meeting for on hour or until the next meeting", ConsoleAccessLevelEnum.AccessOperator);
// Room to fusion room // Room to fusion room
Room.OnFeedback.LinkInputSig(FusionRoom.SystemPowerOn.InputSig); Room.OnFeedback.LinkInputSig(FusionRoom.SystemPowerOn.InputSig);
// Moved to // Moved to
CurrentRoomSourceNameSig = FusionRoom.CreateOffsetStringSig(84, "Display 1 - Current Source", eSigIoMask.InputSigOnly); CurrentRoomSourceNameSig = FusionRoom.CreateOffsetStringSig(84, "Display 1 - Current Source", eSigIoMask.InputSigOnly);
// Don't think we need to get current status of this as nothing should be alive yet. // Don't think we need to get current status of this as nothing should be alive yet.
(Room as EssentialsHuddleVtc1Room).CurrentSingleSourceChange += Room_CurrentSourceInfoChange; (Room as EssentialsHuddleVtc1Room).CurrentSingleSourceChange += Room_CurrentSourceInfoChange;
FusionRoom.SystemPowerOn.OutputSig.SetSigFalseAction((Room as EssentialsHuddleVtc1Room).PowerOnToDefaultOrLastSource); 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"));
// NO!! room.RoomIsOn.LinkComplementInputSig(FusionRoom.SystemPowerOff.InputSig); // 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;";
CrestronEnvironment.EthernetEventHandler += CrestronEnvironment_EthernetEventHandler;
GetProcessorEthernetValues(); }
GetSystemInfo(); protected override void SetUpSources()
{
GetProcessorInfo(); // Sources
var dict = ConfigReader.ConfigObject.GetSourceListForKey((Room as EssentialsHuddleVtc1Room).SourceListKey);
CrestronEnvironment.EthernetEventHandler += CrestronEnvironment_EthernetEventHandler; if (dict != null)
} {
// NEW PROCESS:
protected override void SetUpSources() // Make these lists and insert the fusion attributes by iterating these
{ var setTopBoxes = dict.Where(d => d.Value.SourceDevice is ISetTopBoxControls);
// Sources uint i = 1;
var dict = ConfigReader.ConfigObject.GetSourceListForKey((Room as EssentialsHuddleVtc1Room).SourceListKey); foreach (var kvp in setTopBoxes)
if (dict != null) {
{ TryAddRouteActionSigs("Display 1 - Source TV " + i, 188 + i, kvp.Key, kvp.Value.SourceDevice);
// NEW PROCESS: i++;
// Make these lists and insert the fusion attributes by iterating these if (i > 5) // We only have five spots
var setTopBoxes = dict.Where(d => d.Value.SourceDevice is ISetTopBoxControls); break;
uint i = 1; }
foreach (var kvp in setTopBoxes)
{ var discPlayers = dict.Where(d => d.Value.SourceDevice is IDiscPlayerControls);
TryAddRouteActionSigs("Display 1 - Source TV " + i, 188 + i, kvp.Key, kvp.Value.SourceDevice); i = 1;
i++; foreach (var kvp in discPlayers)
if (i > 5) // We only have five spots {
break; TryAddRouteActionSigs("Display 1 - Source DVD " + i, 181 + i, kvp.Key, kvp.Value.SourceDevice);
} i++;
if (i > 5) // We only have five spots
var discPlayers = dict.Where(d => d.Value.SourceDevice is IDiscPlayerControls); break;
i = 1; }
foreach (var kvp in discPlayers)
{ var laptops = dict.Where(d => d.Value.SourceDevice is Laptop);
TryAddRouteActionSigs("Display 1 - Source DVD " + i, 181 + i, kvp.Key, kvp.Value.SourceDevice); i = 1;
i++; foreach (var kvp in laptops)
if (i > 5) // We only have five spots {
break; TryAddRouteActionSigs("Display 1 - Source Laptop " + i, 166 + i, kvp.Key, kvp.Value.SourceDevice);
} i++;
if (i > 10) // We only have ten spots???
var laptops = dict.Where(d => d.Value.SourceDevice is Laptop); break;
i = 1; }
foreach (var kvp in laptops)
{ foreach (var kvp in dict)
TryAddRouteActionSigs("Display 1 - Source Laptop " + i, 166 + i, kvp.Key, kvp.Value.SourceDevice); {
i++; var usageDevice = kvp.Value.SourceDevice as IUsageTracking;
if (i > 10) // We only have ten spots???
break; if (usageDevice != null)
} {
usageDevice.UsageTracker = new UsageTracking(usageDevice as Device);
foreach (var kvp in dict) usageDevice.UsageTracker.UsageIsTracked = true;
{ usageDevice.UsageTracker.DeviceUsageEnded += new EventHandler<DeviceUsageEventArgs>(UsageTracker_DeviceUsageEnded);
var usageDevice = kvp.Value.SourceDevice as IUsageTracking; }
}
if (usageDevice != null)
{ }
usageDevice.UsageTracker = new UsageTracking(usageDevice as Device); else
usageDevice.UsageTracker.UsageIsTracked = true; {
usageDevice.UsageTracker.DeviceUsageEnded += new EventHandler<DeviceUsageEventArgs>(UsageTracker_DeviceUsageEnded); Debug.Console(1, this, "WARNING: Config source list '{0}' not found for room '{1}'",
} (Room as EssentialsHuddleVtc1Room).SourceListKey, Room.Key);
} }
}
}
else protected override void SetUpDisplay()
{ {
Debug.Console(1, this, "WARNING: Config source list '{0}' not found for room '{1}'", try
(Room as EssentialsHuddleVtc1Room).SourceListKey, Room.Key); {
} //Setup Display Usage Monitoring
}
var displays = DeviceManager.AllDevices.Where(d => d is DisplayBase);
protected override void SetUpDisplay()
{ // Consider updating this in multiple display systems
try
{ foreach (DisplayBase display in displays)
//Setup Display Usage Monitoring {
display.UsageTracker = new UsageTracking(display);
var displays = DeviceManager.AllDevices.Where(d => d is DisplayBase); display.UsageTracker.UsageIsTracked = true;
display.UsageTracker.DeviceUsageEnded += new EventHandler<DeviceUsageEventArgs>(UsageTracker_DeviceUsageEnded);
// Consider updating this in multiple display systems }
foreach (DisplayBase display in displays) var defaultDisplay = (Room as EssentialsHuddleVtc1Room).DefaultDisplay as DisplayBase;
{ if (defaultDisplay == null)
display.UsageTracker = new UsageTracking(display); {
display.UsageTracker.UsageIsTracked = true; Debug.Console(1, this, "Cannot link null display to Fusion because default display is null");
display.UsageTracker.DeviceUsageEnded += new EventHandler<DeviceUsageEventArgs>(UsageTracker_DeviceUsageEnded); return;
} }
var defaultDisplay = (Room as EssentialsHuddleVtc1Room).DefaultDisplay as DisplayBase; var dispPowerOnAction = new Action<bool>(b => { if (!b) defaultDisplay.PowerOn(); });
if (defaultDisplay == null) var dispPowerOffAction = new Action<bool>(b => { if (!b) defaultDisplay.PowerOff(); });
{
Debug.Console(1, this, "Cannot link null display to Fusion because default display is null"); // Display to fusion room sigs
return; FusionRoom.DisplayPowerOn.OutputSig.UserObject = dispPowerOnAction;
} FusionRoom.DisplayPowerOff.OutputSig.UserObject = dispPowerOffAction;
defaultDisplay.PowerIsOnFeedback.LinkInputSig(FusionRoom.DisplayPowerOn.InputSig);
var dispPowerOnAction = new Action<bool>(b => { if (!b) defaultDisplay.PowerOn(); }); if (defaultDisplay is IDisplayUsage)
var dispPowerOffAction = new Action<bool>(b => { if (!b) defaultDisplay.PowerOff(); }); (defaultDisplay as IDisplayUsage).LampHours.LinkInputSig(FusionRoom.DisplayUsage.InputSig);
// Display to fusion room sigs
FusionRoom.DisplayPowerOn.OutputSig.UserObject = dispPowerOnAction;
FusionRoom.DisplayPowerOff.OutputSig.UserObject = dispPowerOffAction; MapDisplayToRoomJoins(1, 158, defaultDisplay);
defaultDisplay.PowerIsOnFeedback.LinkInputSig(FusionRoom.DisplayPowerOn.InputSig);
if (defaultDisplay is IDisplayUsage)
(defaultDisplay as IDisplayUsage).LampHours.LinkInputSig(FusionRoom.DisplayUsage.InputSig); var deviceConfig = ConfigReader.ConfigObject.Devices.FirstOrDefault(d => d.Key.Equals(defaultDisplay.Key));
//Check for existing asset in GUIDs collection
MapDisplayToRoomJoins(1, 158, defaultDisplay); var tempAsset = new FusionAsset();
if (FusionStaticAssets.ContainsKey(deviceConfig.Uid))
var deviceConfig = ConfigReader.ConfigObject.Devices.FirstOrDefault(d => d.Key.Equals(defaultDisplay.Key)); {
tempAsset = FusionStaticAssets[deviceConfig.Uid];
//Check for existing asset in GUIDs collection }
else
var tempAsset = new FusionAsset(); {
// Create a new asset
if (FusionStaticAssets.ContainsKey(deviceConfig.Uid)) tempAsset = new FusionAsset(FusionRoomGuids.GetNextAvailableAssetNumber(FusionRoom), defaultDisplay.Name, "Display", "");
{ FusionStaticAssets.Add(deviceConfig.Uid, tempAsset);
tempAsset = FusionStaticAssets[deviceConfig.Uid]; }
}
else var dispAsset = FusionRoom.CreateStaticAsset(tempAsset.SlotNumber, tempAsset.Name, "Display", tempAsset.InstanceId);
{ dispAsset.PowerOn.OutputSig.UserObject = dispPowerOnAction;
// Create a new asset dispAsset.PowerOff.OutputSig.UserObject = dispPowerOffAction;
tempAsset = new FusionAsset(FusionRoomGuids.GetNextAvailableAssetNumber(FusionRoom), defaultDisplay.Name, "Display", ""); defaultDisplay.PowerIsOnFeedback.LinkInputSig(dispAsset.PowerOn.InputSig);
FusionStaticAssets.Add(deviceConfig.Uid, tempAsset); // NO!! display.PowerIsOn.LinkComplementInputSig(dispAsset.PowerOff.InputSig);
} // Use extension methods
dispAsset.TrySetMakeModel(defaultDisplay);
var dispAsset = FusionRoom.CreateStaticAsset(tempAsset.SlotNumber, tempAsset.Name, "Display", tempAsset.InstanceId); dispAsset.TryLinkAssetErrorToCommunication(defaultDisplay);
dispAsset.PowerOn.OutputSig.UserObject = dispPowerOnAction; }
dispAsset.PowerOff.OutputSig.UserObject = dispPowerOffAction; catch (Exception e)
defaultDisplay.PowerIsOnFeedback.LinkInputSig(dispAsset.PowerOn.InputSig); {
// NO!! display.PowerIsOn.LinkComplementInputSig(dispAsset.PowerOff.InputSig); Debug.Console(1, this, "Error setting up display in Fusion: {0}", e);
// Use extension methods }
dispAsset.TrySetMakeModel(defaultDisplay);
dispAsset.TryLinkAssetErrorToCommunication(defaultDisplay); }
}
catch (Exception e) protected override void MapDisplayToRoomJoins(int displayIndex, int joinOffset, DisplayBase display)
{ {
Debug.Console(1, this, "Error setting up display in Fusion: {0}", e); string displayName = string.Format("Display {0} - ", displayIndex);
}
} if (display == (Room as EssentialsHuddleVtc1Room).DefaultDisplay)
{
protected override void MapDisplayToRoomJoins(int displayIndex, int joinOffset, DisplayBase display) // Power on
{ var defaultDisplayPowerOn = FusionRoom.CreateOffsetBoolSig((uint)joinOffset, displayName + "Power On", eSigIoMask.InputOutputSig);
string displayName = string.Format("Display {0} - ", displayIndex); defaultDisplayPowerOn.OutputSig.UserObject = new Action<bool>(b => { if (!b) display.PowerOn(); });
display.PowerIsOnFeedback.LinkInputSig(defaultDisplayPowerOn.InputSig);
if (display == (Room as EssentialsHuddleVtc1Room).DefaultDisplay) // Power Off
{ var defaultDisplayPowerOff = FusionRoom.CreateOffsetBoolSig((uint)joinOffset + 1, displayName + "Power Off", eSigIoMask.InputOutputSig);
// Power on defaultDisplayPowerOn.OutputSig.UserObject = new Action<bool>(b => { if (!b) display.PowerOff(); }); ;
var defaultDisplayPowerOn = FusionRoom.CreateOffsetBoolSig((uint)joinOffset, displayName + "Power On", eSigIoMask.InputOutputSig); display.PowerIsOnFeedback.LinkInputSig(defaultDisplayPowerOn.InputSig);
defaultDisplayPowerOn.OutputSig.UserObject = new Action<bool>(b => { if (!b) display.PowerOn(); });
display.PowerIsOnFeedback.LinkInputSig(defaultDisplayPowerOn.InputSig); // Current Source
var defaultDisplaySourceNone = FusionRoom.CreateOffsetBoolSig((uint)joinOffset + 8, displayName + "Source None", eSigIoMask.InputOutputSig);
// Power Off defaultDisplaySourceNone.OutputSig.UserObject = new Action<bool>(b => { if (!b) (Room as EssentialsHuddleVtc1Room).RunRouteAction("roomOff"); }); ;
var defaultDisplayPowerOff = FusionRoom.CreateOffsetBoolSig((uint)joinOffset + 1, displayName + "Power Off", eSigIoMask.InputOutputSig); }
defaultDisplayPowerOn.OutputSig.UserObject = new Action<bool>(b => { if (!b) display.PowerOff(); }); ; }
display.PowerIsOnFeedback.LinkInputSig(defaultDisplayPowerOn.InputSig); }
// 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"); }); ;
}
}
}
} }