diff --git a/Essentials Core/PepperDashEssentialsBase/Config/DeviceConfig.cs b/Essentials Core/PepperDashEssentialsBase/Config/DeviceConfig.cs index e9ed7931..bb95da01 100644 --- a/Essentials Core/PepperDashEssentialsBase/Config/DeviceConfig.cs +++ b/Essentials Core/PepperDashEssentialsBase/Config/DeviceConfig.cs @@ -16,6 +16,9 @@ namespace PepperDash.Essentials.Core.Config [JsonProperty("key")] public string Key { get; set; } + [JsonProperty("uid")] + public int Uid { get; set; } + [JsonProperty("name")] public string Name { get; set; } diff --git a/Essentials Core/PepperDashEssentialsBase/Devices/IUsageTracking.cs b/Essentials Core/PepperDashEssentialsBase/Devices/IUsageTracking.cs index 1dbc123d..a9909e7c 100644 --- a/Essentials Core/PepperDashEssentialsBase/Devices/IUsageTracking.cs +++ b/Essentials Core/PepperDashEssentialsBase/Devices/IUsageTracking.cs @@ -30,8 +30,12 @@ namespace PepperDash.Essentials.Core public DateTime UsageStartTime { get; protected set; } public DateTime UsageEndTime { get; protected set; } - public UsageTracking() + public Device Parent { get; private set; } + + public UsageTracking(Device parent) { + Parent = parent; + InUseTracker = new InUseTracking(); InUseTracker.InUseFeedback.OutputChange +=new EventHandler(InUseFeedback_OutputChange); @@ -63,16 +67,26 @@ namespace PepperDash.Essentials.Core /// public void EndDeviceUsage() { - UsageEndTime = DateTime.Now; - - var timeUsed = UsageEndTime - UsageStartTime; - - var handler = DeviceUsageEnded; - - if (handler != null) + try { - Debug.Console(1, "Device Usage Ended at {1}. In use for {2} minutes.", UsageEndTime, timeUsed.Minutes); - handler(this, new DeviceUsageEventArgs() { UsageEndTime = UsageEndTime, MinutesUsed = timeUsed.Minutes }); + UsageEndTime = DateTime.Now; + + if (UsageStartTime != null) + { + var timeUsed = UsageEndTime - UsageStartTime; + + var handler = DeviceUsageEnded; + + if (handler != null) + { + Debug.Console(1, "Device Usage Ended for: {0} at {1}. In use for {2} minutes.", Parent.Name, UsageEndTime, timeUsed.Minutes); + handler(this, new DeviceUsageEventArgs() { UsageEndTime = UsageEndTime, MinutesUsed = timeUsed.Minutes }); + } + } + } + catch (Exception e) + { + Debug.Console(1, "Error ending device usage: {0}", e); } } } diff --git a/Essentials DM/Essentials_DM/Chassis/DmCardAudioOutput.cs b/Essentials DM/Essentials_DM/Chassis/DmCardAudioOutput.cs index 3a069c39..6c5c0275 100644 --- a/Essentials DM/Essentials_DM/Chassis/DmCardAudioOutput.cs +++ b/Essentials DM/Essentials_DM/Chassis/DmCardAudioOutput.cs @@ -90,7 +90,6 @@ namespace PepperDash.Essentials.DM { if (pressRelease) Output.Volume.CreateRamp(0, 400); -#warning SCALE THIS RAMP else Output.Volume.StopRamp(); } diff --git a/Essentials Devices Common/Essentials Devices Common/DSP/BiampTesira/BiampTesiraForteDspLevel.cs b/Essentials Devices Common/Essentials Devices Common/DSP/BiampTesira/BiampTesiraForteDspLevel.cs index 31c69528..c1b6884c 100644 --- a/Essentials Devices Common/Essentials Devices Common/DSP/BiampTesira/BiampTesiraForteDspLevel.cs +++ b/Essentials Devices Common/Essentials Devices Common/DSP/BiampTesira/BiampTesiraForteDspLevel.cs @@ -10,18 +10,6 @@ using System.Text.RegularExpressions; namespace PepperDash.Essentials.Devices.Common.DSP { - - // QUESTIONS: - // - // When subscribing, just use the Instance ID for Custom Name? - - // Verbose on subscriptions? - - // ! "publishToken":"name" "value":-77.0 - // ! "myLevelName" -77 - -#warning Working here when set aside for config editor work - public class TesiraForteLevelControl : TesiraForteControlPoint, IDspLevelControl, IKeyed { bool _IsMuted; diff --git a/Essentials/PepperDashEssentials/ControlSystem.cs b/Essentials/PepperDashEssentials/ControlSystem.cs index 06816ff6..1c16c428 100644 --- a/Essentials/PepperDashEssentials/ControlSystem.cs +++ b/Essentials/PepperDashEssentials/ControlSystem.cs @@ -29,8 +29,8 @@ namespace PepperDash.Essentials /// public override void InitializeSystem() { - //CrestronConsole.AddNewConsoleCommand(s => GoWithLoad(), "go", "Reloads configuration file", - // ConsoleAccessLevelEnum.AccessOperator); + CrestronConsole.AddNewConsoleCommand(s => GoWithLoad(), "go", "Reloads configuration file", + ConsoleAccessLevelEnum.AccessOperator); //CrestronConsole.AddNewConsoleCommand(s => TearDown(), "ungo", "Reloads configuration file", // ConsoleAccessLevelEnum.AccessOperator); CrestronConsole.AddNewConsoleCommand(s => @@ -40,7 +40,7 @@ namespace PepperDash.Essentials }, "listtielines", "Prints out all tie lines", ConsoleAccessLevelEnum.AccessOperator); - GoWithLoad(); + //GoWithLoad(); } /// diff --git a/Essentials/PepperDashEssentials/Fusion/FusionRviDataClasses.cs b/Essentials/PepperDashEssentials/Fusion/FusionRviDataClasses.cs index c1ad5078..e08d806f 100644 --- a/Essentials/PepperDashEssentials/Fusion/FusionRviDataClasses.cs +++ b/Essentials/PepperDashEssentials/Fusion/FusionRviDataClasses.cs @@ -3,6 +3,9 @@ using System.Collections.Generic; using System.Linq; using System.Text; using Crestron.SimplSharp; +using Crestron.SimplSharpPro.Fusion; + +using PepperDash.Core; namespace PepperDash.Essentials.Fusion { @@ -16,47 +19,144 @@ namespace PepperDash.Essentials.Fusion public string RoomName { get; set; } public uint IpId { get; set; } public string RoomGuid { get; set; } - public List StaticAssets { get; set; } + public FusionOccupancySensorAsset OccupancyAsset { get; set; } + public Dictionary StaticAssets { get; set; } public FusionRoomGuids() { - StaticAssets = new List(); + StaticAssets = new Dictionary(); + OccupancyAsset = new FusionOccupancySensorAsset(); } - public FusionRoomGuids(string roomName, uint ipId, string roomGuid, List staticAssets) + public FusionRoomGuids(string roomName, uint ipId, string roomGuid, Dictionary staticAssets) { RoomName = roomName; IpId = ipId; RoomGuid = roomGuid; - StaticAssets = new List(staticAssets); + StaticAssets = staticAssets; + OccupancyAsset = new FusionOccupancySensorAsset(); + } + + public FusionRoomGuids(string roomName, uint ipId, string roomGuid, Dictionary staticAssets, FusionOccupancySensorAsset occAsset) + { + RoomName = roomName; + IpId = ipId; + RoomGuid = roomGuid; + + StaticAssets = staticAssets; + OccupancyAsset = occAsset; + } + + /// + /// Generates a new room GUID prefixed by the program slot number and NIC MAC address + /// + /// + /// + public string GenerateNewRoomGuid(uint progSlot, string mac) + { + Guid roomGuid = Guid.NewGuid(); + + return string.Format("{0}-{1}-{2}", progSlot, mac, roomGuid.ToString()); + } + + + /// + /// Adds an asset to the StaticAssets collection and returns the new asset + /// + /// + /// + /// + /// + /// + /// + public FusionAsset AddStaticAsset(FusionRoom room, int uid, string assetName, string type, string instanceId) + { + var slotNum = GetNextAvailableAssetNumber(room); + + Debug.Console(2, "Adding Fusion Asset: {0} of Type: {1} at Slot Number: {2} with GUID: {3}", assetName, type, slotNum, instanceId); + + var tempAsset = new FusionAsset(slotNum, assetName, type, instanceId); + + StaticAssets.Add(uid, tempAsset); + + return tempAsset; + } + + /// + /// Returns the next available slot number in the Fusion UserConfigurableAssetDetails collection + /// + /// + /// + public static uint GetNextAvailableAssetNumber(FusionRoom room) + { + uint slotNum = 0; + + foreach (var item in room.UserConfigurableAssetDetails) + { + if(item.Number > slotNum) + slotNum = item.Number; + } + + if (slotNum < 5) + { + slotNum = 5; + } + else + slotNum = slotNum + 1; + + Debug.Console(2, "#Next available fusion asset number is: {0}", slotNum); + + return slotNum; + } + + } + + public class FusionOccupancySensorAsset + { + // SlotNumber fixed at 4 + + public uint SlotNumber { get { return 4; } } + public string Name { get { return "Occupancy Sensor"; } } + public eAssetType Type { get; set; } + public string InstanceId { get; set; } + + public FusionOccupancySensorAsset() + { + } + + public FusionOccupancySensorAsset(eAssetType type) + { + Type = type; + + InstanceId = Guid.NewGuid().ToString(); } } public class FusionAsset { - public uint Number { get; set; } + public uint SlotNumber { get; set; } public string Name { get; set; } - public string Type { get; set; } - public string InstanceID { get; set; } + public string Type { get; set; } + public string InstanceId { get;set; } public FusionAsset() { } - public FusionAsset(uint slotNum, string assetName, string type, string instanceID) + public FusionAsset(uint slotNum, string assetName, string type, string instanceId) { - Number = slotNum; + SlotNumber = slotNum; Name = assetName; Type = type; - if (string.IsNullOrEmpty(instanceID)) + if (string.IsNullOrEmpty(instanceId)) { - InstanceID = Guid.NewGuid().ToString(); + InstanceId = Guid.NewGuid().ToString(); } else { - InstanceID = instanceID; + InstanceId = instanceId; } } } diff --git a/Essentials/PepperDashEssentials/Fusion/FusionSystemController.cs b/Essentials/PepperDashEssentials/Fusion/FusionSystemController.cs index 895a4c04..ff69dff7 100644 --- a/Essentials/PepperDashEssentials/Fusion/FusionSystemController.cs +++ b/Essentials/PepperDashEssentials/Fusion/FusionSystemController.cs @@ -34,7 +34,7 @@ namespace PepperDash.Essentials.Fusion Dictionary SourceToFeedbackSigs = new Dictionary(); - BooleanSigData OccupancyStatusSig; + //BooleanSigData OccupancyStatusSig; StatusMonitorCollection ErrorMessageRollUp; @@ -103,7 +103,9 @@ namespace PepperDash.Essentials.Fusion public long PushNotificationTimeout = 5000; - List FusionAssets; + Dictionary FusionStaticAssets; + + FusionOccupancySensorAsset FusionOccSensor; //ScheduleResponseEvent NextMeeting; @@ -115,7 +117,7 @@ namespace PepperDash.Essentials.Fusion IpId = ipId; - FusionAssets = new List(); + FusionStaticAssets = new Dictionary(); GUIDs = new FusionRoomGuids(); @@ -133,11 +135,7 @@ namespace PepperDash.Essentials.Fusion } else { - IpId = ipId; - - Guid roomGuid = Guid.NewGuid(); - - GUIDs.RoomGuid = string.Format("{0}-{1}-{2}", slot, mac, roomGuid.ToString()); + GUIDs = new FusionRoomGuids(Room.Name, ipId, GUIDs.GenerateNewRoomGuid(slot, mac), FusionStaticAssets); } CreateSymbolAndBasicSigs(IpId); @@ -145,7 +143,7 @@ namespace PepperDash.Essentials.Fusion SetUpCommunitcationMonitors(); SetUpDisplay(); SetUpError(); - SetUpOccupancy(); + //SetUpOccupancy(); // Make it so! FusionRVI.GenerateFileForAllFusionDevices(); @@ -154,7 +152,7 @@ namespace PepperDash.Essentials.Fusion } /// - /// Generates the guid file in NVRAM + /// Generates the guid file in NVRAM. If the file already exists it will be overwritten. /// /// path for the file void GenerateGuidFile(string filePath) @@ -176,7 +174,10 @@ namespace PepperDash.Essentials.Fusion Debug.Console(1, this, "Writing GUIDs to file"); - GUIDs = new FusionRoomGuids(Room.Name, IpId, RoomGuid, FusionAssets); + if (FusionOccSensor == null) + GUIDs = new FusionRoomGuids(Room.Name, IpId, RoomGuid, FusionStaticAssets); + else + GUIDs = new FusionRoomGuids(Room.Name, IpId, RoomGuid, FusionStaticAssets, FusionOccSensor); var JSON = JsonConvert.SerializeObject(GUIDs, Newtonsoft.Json.Formatting.Indented); @@ -229,7 +230,7 @@ namespace PepperDash.Essentials.Fusion IpId = GUIDs.IpId; - FusionAssets = GUIDs.StaticAssets; + FusionStaticAssets = GUIDs.StaticAssets; } @@ -237,9 +238,9 @@ namespace PepperDash.Essentials.Fusion Debug.Console(1, this, "\nRoom Name: {0}\nIPID: {1:x}\n RoomGuid: {2}", Room.Name, IpId, RoomGuid); - foreach (FusionAsset asset in FusionAssets) + foreach (KeyValuePair item in FusionStaticAssets) { - Debug.Console(1, this, "\nAsset Name: {0}\nAsset No: {1}\n Guid: {2}", asset.Name, asset.Number, asset.InstanceID); + Debug.Console(1, this, "\nAsset Name: {0}\nAsset No: {1}\n Guid: {2}", item.Value.Name, item.Value.SlotNumber, item.Value.InstanceId); } } catch (Exception e) @@ -367,15 +368,15 @@ namespace PepperDash.Essentials.Fusion Firmware.InputSig.StringValue = InitialParametersClass.FirmwareVersion; - var programs = ProcessorProgReg.GetProcessorProgReg(); + //var programs = ProcessorProgReg.GetProcessorProgReg(); - for (int i = 1; i < Global.ControlSystem.NumProgramsSupported; i++) - { - var join = 62 + i; - var progNum = i + 1; - if (programs[i].Exists) - Program[i].InputSig.StringValue = programs[i].Name; - } + //for (int i = 1; i < Global.ControlSystem.NumProgramsSupported; i++) + //{ + // var join = 62 + i; + // var progNum = i + 1; + // if (programs[i].Exists) + // Program[i].InputSig.StringValue = programs[i].Name; + //} } @@ -497,7 +498,7 @@ namespace PepperDash.Essentials.Fusion Debug.Console(1, this, "No meeting in progress. Unable to modify end time."); return; } -#warning Need to add logic to properly extend from the current time. See S+ module for reference. + if (extendMinutes > -1) { if(extendMinutes > 0) @@ -860,7 +861,7 @@ namespace PepperDash.Essentials.Fusion if (usageDevice != null) { - usageDevice.UsageTracker = new UsageTracking(); + usageDevice.UsageTracker = new UsageTracking(usageDevice as Device); usageDevice.UsageTracker.UsageIsTracked = true; usageDevice.UsageTracker.DeviceUsageEnded += new EventHandler(UsageTracker_DeviceUsageEnded); } @@ -881,11 +882,11 @@ namespace PepperDash.Essentials.Fusion /// void UsageTracker_DeviceUsageEnded(object sender, DeviceUsageEventArgs e) { - var device = sender as Device; + var deviceTracker = sender as UsageTracking; - var configDevice = ConfigReader.ConfigObject.Devices.Where(d => d.Key.Equals(device.Key)); + var configDevice = ConfigReader.ConfigObject.Devices.Where(d => d.Key.Equals(deviceTracker.Parent)); - string group = ConfigReader.GetGroupForDeviceKey(device.Key); + string group = ConfigReader.GetGroupForDeviceKey(deviceTracker.Parent.Key); string currentMeetingId = ""; @@ -894,10 +895,10 @@ namespace PepperDash.Essentials.Fusion //String Format: "USAGE||[Date YYYY-MM-DD]||[Time HH-mm-ss]||TIME||[Asset_Type]||[Asset_Name]||[Minutes_used]||[Asset_ID]||[Meeting_ID]" // [Asset_ID] property does not appear to be used in Crestron SSI examples. They are sending "-" instead so that's what is replicated here - string deviceUsage = string.Format("USAGE||{0}||{1}||TIME||{2}||{3}||{4}||{5}||{6})", e.UsageEndTime.ToString("YYYY-MM-DD"), e.UsageEndTime.ToString("HH-mm-ss"), - group, device.Name, e.MinutesUsed, "-", currentMeetingId); + string deviceUsage = string.Format("USAGE||{0}||{1}||TIME||{2}||{3}||{4}||{5}||{6})", e.UsageEndTime.ToString("yyyy-MM-dd"), e.UsageEndTime.ToString("HH-mm-ss"), + group, deviceTracker.Parent.Name, e.MinutesUsed, "-", currentMeetingId); - Debug.Console(1, this, "Device usage for: {0} ended at {1}. In use for {2} minutes", device.Name, e.UsageEndTime, e.MinutesUsed); + Debug.Console(1, this, "Device usage for: {0} ended at {1}. In use for {2} minutes", deviceTracker.Parent.Name, e.UsageEndTime, e.MinutesUsed); FusionRoom.DeviceUsage.InputSig.StringValue = deviceUsage; } @@ -952,8 +953,7 @@ namespace PepperDash.Essentials.Fusion if (attrNum > 10) continue; attrName = "Online - Touch Panel " + attrNum; - attrNum += 200; -#warning should this be 150 + attrNum += 150; } // add xpanel here @@ -963,7 +963,6 @@ namespace PepperDash.Essentials.Fusion continue; attrName = "Online - XPanel " + attrNum; attrNum += 160; -#warning should this be 160 } //else @@ -972,8 +971,7 @@ namespace PepperDash.Essentials.Fusion if (attrNum > 10) continue; attrName = "Online - Display " + attrNum; - attrNum += 240; -#warning should this be 170 + attrNum += 170; } //else if (dev is DvdDeviceBase) //{ @@ -1003,68 +1001,73 @@ namespace PepperDash.Essentials.Fusion void SetUpDisplay() { - //Setup Display Usage Monitoring - - var displays = DeviceManager.AllDevices.Where(d => d is DisplayBase); - -#warning should work for now in single room systems but will grab all devices regardless of room assignment. In multi-room systems, this will need to be handled differently. - - foreach (DisplayBase display in displays) + try { - display.UsageTracker = new UsageTracking(); - display.UsageTracker.UsageIsTracked = true; - display.UsageTracker.DeviceUsageEnded += new EventHandler(UsageTracker_DeviceUsageEnded); + //Setup Display Usage Monitoring + + var displays = DeviceManager.AllDevices.Where(d => d is DisplayBase); + + // Consider updating this in multiple display systems + + foreach (DisplayBase display in displays) + { + display.UsageTracker = new UsageTracking(display); + display.UsageTracker.UsageIsTracked = true; + display.UsageTracker.DeviceUsageEnded += new EventHandler(UsageTracker_DeviceUsageEnded); + } + + var defaultDisplay = Room.DefaultDisplay as DisplayBase; + if (defaultDisplay == null) + { + Debug.Console(1, this, "Cannot link null display to Fusion"); + return; + } + + var dispPowerOnAction = new Action(b => { if (!b) defaultDisplay.PowerOn(); }); + var dispPowerOffAction = new Action(b => { if (!b) defaultDisplay.PowerOff(); }); + + // Display to fusion room sigs + FusionRoom.DisplayPowerOn.OutputSig.UserObject = dispPowerOnAction; + FusionRoom.DisplayPowerOff.OutputSig.UserObject = dispPowerOffAction; + defaultDisplay.PowerIsOnFeedback.LinkInputSig(FusionRoom.DisplayPowerOn.InputSig); + if (defaultDisplay is IDisplayUsage) + (defaultDisplay as IDisplayUsage).LampHours.LinkInputSig(FusionRoom.DisplayUsage.InputSig); + + + + MapDisplayToRoomJoins(1, 158, defaultDisplay); + + + var deviceConfig = ConfigReader.ConfigObject.Devices.FirstOrDefault(d => d.Key.Equals(defaultDisplay.Key)); + + //Check for existing asset in GUIDs collection + + var tempAsset = new FusionAsset(); + + if (FusionStaticAssets.ContainsKey(deviceConfig.Uid)) + { + tempAsset = FusionStaticAssets[deviceConfig.Uid]; + } + else + { + // Create a new asset + tempAsset = new FusionAsset(FusionRoomGuids.GetNextAvailableAssetNumber(FusionRoom), defaultDisplay.Name, "Display", ""); + FusionStaticAssets.Add(deviceConfig.Uid, tempAsset); + } + + var dispAsset = FusionRoom.CreateStaticAsset(tempAsset.SlotNumber, tempAsset.Name, "Display", tempAsset.InstanceId); + dispAsset.PowerOn.OutputSig.UserObject = dispPowerOnAction; + dispAsset.PowerOff.OutputSig.UserObject = dispPowerOffAction; + defaultDisplay.PowerIsOnFeedback.LinkInputSig(dispAsset.PowerOn.InputSig); + // NO!! display.PowerIsOn.LinkComplementInputSig(dispAsset.PowerOff.InputSig); + // Use extension methods + dispAsset.TrySetMakeModel(defaultDisplay); + dispAsset.TryLinkAssetErrorToCommunication(defaultDisplay); } - - var defaultDisplay = Room.DefaultDisplay as DisplayBase; - if (defaultDisplay == null) - { - Debug.Console(1, this, "Cannot link null display to Fusion"); - return; - } - - var dispPowerOnAction = new Action(b => { if (!b) defaultDisplay.PowerOn(); }); - var dispPowerOffAction = new Action(b => { if (!b) defaultDisplay.PowerOff(); }); - - // Display to fusion room sigs - FusionRoom.DisplayPowerOn.OutputSig.UserObject = dispPowerOnAction; - FusionRoom.DisplayPowerOff.OutputSig.UserObject = dispPowerOffAction; - defaultDisplay.PowerIsOnFeedback.LinkInputSig(FusionRoom.DisplayPowerOn.InputSig); - if (defaultDisplay is IDisplayUsage) - (defaultDisplay as IDisplayUsage).LampHours.LinkInputSig(FusionRoom.DisplayUsage.InputSig); - - - - MapDisplayToRoomJoins(1, 158, defaultDisplay); - - //Room.CurrentSingleSourceChange += new SourceInfoChangeHandler(Room_CurrentSingleSourceChange); - - // static assets --------------- testing - // Make a display asset - string dispAssetInstanceId; - - //Check for existing GUID - var tempAsset = FusionAssets.FirstOrDefault(a => a.Name.Equals("Display")); - if(tempAsset != null) - dispAssetInstanceId = tempAsset.InstanceID; - else + catch (Exception e) { - var nextSlotNum = FusionAssets.Count + 3; //Account for slot number offset - - tempAsset = new FusionAsset((uint)nextSlotNum, defaultDisplay.Name, "Display", ""); - FusionAssets.Add(tempAsset); - dispAssetInstanceId = tempAsset.InstanceID; + Debug.Console(1, this, "Error setting up display in Fusion: {0}", e); } - - var dispAsset = FusionRoom.CreateStaticAsset(tempAsset.Number, defaultDisplay.Name, "Display", dispAssetInstanceId); - dispAsset.PowerOn.OutputSig.UserObject = dispPowerOnAction; - dispAsset.PowerOff.OutputSig.UserObject = dispPowerOffAction; - defaultDisplay.PowerIsOnFeedback.LinkInputSig(dispAsset.PowerOn.InputSig); - // NO!! display.PowerIsOn.LinkComplementInputSig(dispAsset.PowerOff.InputSig); - // Use extension methods - dispAsset.TrySetMakeModel(defaultDisplay); - dispAsset.TryLinkAssetErrorToCommunication(defaultDisplay); - } @@ -1072,23 +1075,25 @@ namespace PepperDash.Essentials.Fusion /// Maps room attributes to a display at a specified index /// /// - /// + /// a void MapDisplayToRoomJoins(int displayIndex, int joinOffset, DisplayBase display) { string displayName = string.Format("Display {0} - ", displayIndex); - var defaultDisplayPowerOn = FusionRoom.CreateOffsetBoolSig((uint)joinOffset, displayIndex + "Power On", eSigIoMask.InputOutputSig); - defaultDisplayPowerOn.OutputSig.UserObject = new Action(b => { if (!b) display.PowerOn(); }); - display.PowerIsOnFeedback.LinkInputSig(defaultDisplayPowerOn.InputSig); - - var defaultDisplayPowerOff = FusionRoom.CreateOffsetBoolSig((uint)joinOffset + 1, displayIndex + "Power Off", eSigIoMask.InputOutputSig); - defaultDisplayPowerOn.OutputSig.UserObject = new Action(b => { if (!b) display.PowerOff(); }); ; - display.PowerIsOnFeedback.LinkInputSig(defaultDisplayPowerOn.InputSig); if(display == Room.DefaultDisplay) { + var defaultDisplayPowerOn = FusionRoom.CreateOffsetBoolSig((uint)joinOffset, displayIndex + "Power On", eSigIoMask.InputOutputSig); + defaultDisplayPowerOn.OutputSig.UserObject = new Action(b => { if (!b) display.PowerOn(); }); + display.PowerIsOnFeedback.LinkInputSig(defaultDisplayPowerOn.InputSig); + + var defaultDisplayPowerOff = FusionRoom.CreateOffsetBoolSig((uint)joinOffset + 1, displayIndex + "Power Off", eSigIoMask.InputOutputSig); + defaultDisplayPowerOn.OutputSig.UserObject = new Action(b => { if (!b) display.PowerOff(); }); ; + display.PowerIsOnFeedback.LinkInputSig(defaultDisplayPowerOn.InputSig); + + var defaultDisplaySourceNone = FusionRoom.CreateOffsetBoolSig((uint)joinOffset + 8, displayIndex + "Source None", eSigIoMask.InputOutputSig); - defaultDisplaySourceNone.OutputSig.UserObject = new Action(b => { if (!b) Room.RunRouteAction("$off"); }); ; + defaultDisplaySourceNone.OutputSig.UserObject = new Action(b => { if (!b) Room.RunRouteAction("roomOff"); }); ; display.PowerIsOnFeedback.LinkInputSig(defaultDisplaySourceNone.InputSig); var dict = ConfigReader.ConfigObject.GetSourceListForKey(Room.SourceListKey); @@ -1098,9 +1103,8 @@ namespace PepperDash.Essentials.Fusion if(item.Key != "roomOff") { var defaultDisplaySource = FusionRoom.CreateOffsetBoolSig((uint)joinOffset + (uint)item.Value.Order + 9 , string.Format("{0}Source {1}", displayIndex, item.Value.Order), eSigIoMask.InputOutputSig); - defaultDisplaySource.OutputSig.UserObject = new Action(b => { if (!b) Room.RunRouteAction(item.Value.SourceKey); }); ; + defaultDisplaySource.OutputSig.UserObject = new Action(b => { if (!b) Room.RunRouteAction(item.Key); }); -#warning Figure out how to link these sigs together //defaultDisplaySource.InputSig = Source[item.Value.Order].InputSig; } @@ -1144,28 +1148,23 @@ namespace PepperDash.Essentials.Fusion } void SetUpOccupancy() - { + { + + // Need to have the room occupancy object first and somehow determine the slot number of the Occupancy asset but will not be able to use the UID from config likely. + // Consider defining an object just for Room Occupancy (either eAssetType.Occupancy Sensor (local) or eAssetType.RemoteOccupancySensor (from Fusion sched. panel)) and reserving slot 4 for that asset (statics would start at 5) -#warning Add actual object logic check here //if (Room.OccupancyObj != null) //{ - string occAssetId; - var tempAsset = FusionAssets.FirstOrDefault(a => a.Type.Equals("Occupancy Sensor")); + var tempOccAsset = GUIDs.OccupancyAsset; - if(tempAsset != null) - occAssetId = tempAsset.InstanceID; - else + if(tempOccAsset == null) { - var nextAssetNum = FusionAssets.Count + 3; //Account for slot number offset - - tempAsset = new FusionAsset((uint)nextAssetNum, "Occupancy Sensor", "Occupancy Sensor", ""); - FusionAssets.Add(tempAsset); - occAssetId = tempAsset.InstanceID; + FusionOccSensor = new FusionOccupancySensorAsset(eAssetType.OccupancySensor); + tempOccAsset = FusionOccSensor; } - var occSensorAsset = FusionRoom.CreateOccupancySensorAsset(tempAsset.Number, tempAsset.Name, tempAsset.Type, occAssetId); - //FusionRoom.AddAsset(eAssetType.OccupancySensor, tempAsset.Number, tempAsset.Name, tempAsset.Type, tempAsset.InstanceID); + var occSensorAsset = FusionRoom.CreateOccupancySensorAsset(tempOccAsset.SlotNumber, tempOccAsset.Name, "Occupancy Sensor", tempOccAsset.InstanceId); occSensorAsset.RoomOccupied.AddSigToRVIFile = true; diff --git a/Essentials/PepperDashEssentials/Room/Cotija/DeviceTypeInterfaces/INumericExtensions.cs b/Essentials/PepperDashEssentials/Room/Cotija/DeviceTypeInterfaces/INumericExtensions.cs index 008b5b25..83a6f4cc 100644 --- a/Essentials/PepperDashEssentials/Room/Cotija/DeviceTypeInterfaces/INumericExtensions.cs +++ b/Essentials/PepperDashEssentials/Room/Cotija/DeviceTypeInterfaces/INumericExtensions.cs @@ -26,7 +26,7 @@ namespace PepperDash.Essentials.Room.Cotija controller.AddAction(prefix + "num9", new PressAndHoldAction(dev.Digit0)); controller.AddAction(prefix + "dash", new PressAndHoldAction(dev.KeypadAccessoryButton1)); controller.AddAction(prefix + "enter", new PressAndHoldAction(dev.KeypadAccessoryButton2)); -#warning Deal with the Accessory functions on the numpad later + // Deal with the Accessory functions on the numpad later } public static void UnlinkActions(this INumericKeypad dev, CotijaSystemController controller) diff --git a/Release Package/PepperDashEssentials.cpz b/Release Package/PepperDashEssentials.cpz index 6832493f..d816a84f 100644 Binary files a/Release Package/PepperDashEssentials.cpz and b/Release Package/PepperDashEssentials.cpz differ diff --git a/Release Package/PepperDashEssentials.dll b/Release Package/PepperDashEssentials.dll index 3a391dfe..ec46827a 100644 Binary files a/Release Package/PepperDashEssentials.dll and b/Release Package/PepperDashEssentials.dll differ