mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-14 20:24:57 +00:00
Merge pull request #607 from PepperDash/hotfix/fusion-static-asset-fixes
Hotfix/fusion static asset fixes
This commit is contained in:
@@ -130,7 +130,7 @@ namespace PepperDash.Essentials
|
|||||||
|
|
||||||
if (CrestronEnvironment.DevicePlatform != eDevicePlatform.Server) // Handles 3-series running Windows CE OS
|
if (CrestronEnvironment.DevicePlatform != eDevicePlatform.Server) // Handles 3-series running Windows CE OS
|
||||||
{
|
{
|
||||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Starting Essentials v{0} on 3-series Appliance", Global.AssemblyVersion);
|
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Starting Essentials v{0} on {1} Appliance", Global.AssemblyVersion, Global.ProcessorSeries.ToString());
|
||||||
|
|
||||||
// Check if User/ProgramX exists
|
// Check if User/ProgramX exists
|
||||||
if (Directory.Exists(Global.ApplicationDirectoryPathPrefix + dirSeparator + "User"
|
if (Directory.Exists(Global.ApplicationDirectoryPathPrefix + dirSeparator + "User"
|
||||||
@@ -323,7 +323,12 @@ namespace PepperDash.Essentials
|
|||||||
// Skip this to prevent unnecessary warnings
|
// Skip this to prevent unnecessary warnings
|
||||||
if (devConf.Key == "processor")
|
if (devConf.Key == "processor")
|
||||||
{
|
{
|
||||||
if (devConf.Type.ToLower() != Global.ControlSystem.ControllerPrompt.ToLower())
|
var prompt = Global.ControlSystem.ControllerPrompt;
|
||||||
|
|
||||||
|
var typeMatch = String.Equals(devConf.Type, prompt, StringComparison.OrdinalIgnoreCase) &&
|
||||||
|
String.Equals(devConf.Type, prompt.Replace("-", ""), StringComparison.OrdinalIgnoreCase);
|
||||||
|
|
||||||
|
if (!typeMatch)
|
||||||
Debug.Console(0,
|
Debug.Console(0,
|
||||||
"WARNING: Config file defines processor type as '{0}' but actual processor is '{1}'! Some ports may not be available",
|
"WARNING: Config file defines processor type as '{0}' but actual processor is '{1}'! Some ports may not be available",
|
||||||
devConf.Type.ToUpper(), Global.ControlSystem.ControllerPrompt.ToUpper());
|
devConf.Type.ToUpper(), Global.ControlSystem.ControllerPrompt.ToUpper());
|
||||||
|
|||||||
@@ -30,27 +30,29 @@ namespace PepperDash.Essentials.Fusion
|
|||||||
|
|
||||||
foreach (var display in displays.Values.Cast<DisplayBase>())
|
foreach (var display in displays.Values.Cast<DisplayBase>())
|
||||||
{
|
{
|
||||||
Debug.Console(2, this, "Setting up Static Asset for {0}", display.Key);
|
var disp = display; // Local scope variable
|
||||||
|
|
||||||
display.UsageTracker = new UsageTracking(display) { UsageIsTracked = true };
|
Debug.Console(2, this, "Setting up Static Asset for {0}", disp.Key);
|
||||||
display.UsageTracker.DeviceUsageEnded += UsageTracker_DeviceUsageEnded;
|
|
||||||
|
disp.UsageTracker = new UsageTracking(disp) { UsageIsTracked = true };
|
||||||
|
disp.UsageTracker.DeviceUsageEnded += UsageTracker_DeviceUsageEnded;
|
||||||
|
|
||||||
var dispPowerOnAction = new Action<bool>(b =>
|
var dispPowerOnAction = new Action<bool>(b =>
|
||||||
{
|
{
|
||||||
if (!b)
|
if (!b)
|
||||||
{
|
{
|
||||||
display.PowerOn();
|
disp.PowerOn();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
var dispPowerOffAction = new Action<bool>(b =>
|
var dispPowerOffAction = new Action<bool>(b =>
|
||||||
{
|
{
|
||||||
if (!b)
|
if (!b)
|
||||||
{
|
{
|
||||||
display.PowerOff();
|
disp.PowerOff();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
var deviceConfig = ConfigReader.ConfigObject.GetDeviceForKey(display.Key);
|
var deviceConfig = ConfigReader.ConfigObject.GetDeviceForKey(disp.Key);
|
||||||
|
|
||||||
FusionAsset tempAsset;
|
FusionAsset tempAsset;
|
||||||
|
|
||||||
@@ -63,30 +65,36 @@ namespace PepperDash.Essentials.Fusion
|
|||||||
{
|
{
|
||||||
// Create a new asset
|
// Create a new asset
|
||||||
tempAsset = new FusionAsset(FusionRoomGuids.GetNextAvailableAssetNumber(FusionRoom),
|
tempAsset = new FusionAsset(FusionRoomGuids.GetNextAvailableAssetNumber(FusionRoom),
|
||||||
display.Name, "Display", "");
|
disp.Name, "Display", "");
|
||||||
FusionStaticAssets.Add(deviceConfig.Uid, tempAsset);
|
FusionStaticAssets.Add(deviceConfig.Uid, tempAsset);
|
||||||
}
|
}
|
||||||
|
|
||||||
var dispAsset = FusionRoom.CreateStaticAsset(tempAsset.SlotNumber, tempAsset.Name, "Display",
|
var dispAsset = FusionRoom.CreateStaticAsset(tempAsset.SlotNumber, tempAsset.Name, "Display",
|
||||||
tempAsset.InstanceId);
|
tempAsset.InstanceId);
|
||||||
dispAsset.PowerOn.OutputSig.UserObject = dispPowerOnAction;
|
|
||||||
dispAsset.PowerOff.OutputSig.UserObject = dispPowerOffAction;
|
|
||||||
|
|
||||||
var defaultTwoWayDisplay = display as IHasPowerControlWithFeedback;
|
if (dispAsset != null)
|
||||||
|
{
|
||||||
|
dispAsset.PowerOn.OutputSig.UserObject = dispPowerOnAction;
|
||||||
|
dispAsset.PowerOff.OutputSig.UserObject = dispPowerOffAction;
|
||||||
|
|
||||||
|
// Use extension methods
|
||||||
|
dispAsset.TrySetMakeModel(disp);
|
||||||
|
dispAsset.TryLinkAssetErrorToCommunication(disp);
|
||||||
|
}
|
||||||
|
|
||||||
|
var defaultTwoWayDisplay = disp as IHasPowerControlWithFeedback;
|
||||||
if (defaultTwoWayDisplay != null)
|
if (defaultTwoWayDisplay != null)
|
||||||
{
|
{
|
||||||
defaultTwoWayDisplay.PowerIsOnFeedback.LinkInputSig(FusionRoom.DisplayPowerOn.InputSig);
|
defaultTwoWayDisplay.PowerIsOnFeedback.LinkInputSig(FusionRoom.DisplayPowerOn.InputSig);
|
||||||
if (display is IDisplayUsage)
|
if (disp is IDisplayUsage)
|
||||||
{
|
{
|
||||||
(display as IDisplayUsage).LampHours.LinkInputSig(FusionRoom.DisplayUsage.InputSig);
|
(disp as IDisplayUsage).LampHours.LinkInputSig(FusionRoom.DisplayUsage.InputSig);
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultTwoWayDisplay.PowerIsOnFeedback.LinkInputSig(dispAsset.PowerOn.InputSig);
|
if(dispAsset != null)
|
||||||
|
defaultTwoWayDisplay.PowerIsOnFeedback.LinkInputSig(dispAsset.PowerOn.InputSig);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Use extension methods
|
|
||||||
dispAsset.TrySetMakeModel(display);
|
|
||||||
dispAsset.TryLinkAssetErrorToCommunication(display);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
|
|||||||
@@ -1676,20 +1676,46 @@ namespace PepperDash.Essentials.Core.Fusion
|
|||||||
public static FusionStaticAsset CreateStaticAsset(this FusionRoom fr, uint number, string name, string type,
|
public static FusionStaticAsset CreateStaticAsset(this FusionRoom fr, uint number, string name, string type,
|
||||||
string instanceId)
|
string instanceId)
|
||||||
{
|
{
|
||||||
Debug.Console(0, "Adding Fusion Static Asset '{0}' to slot {1} with GUID: '{2}'", name, number, instanceId);
|
try
|
||||||
|
{
|
||||||
|
Debug.Console(0, "Adding Fusion Static Asset '{0}' to slot {1} with GUID: '{2}'", name, number, instanceId);
|
||||||
|
|
||||||
fr.AddAsset(eAssetType.StaticAsset, number, name, type, instanceId);
|
fr.AddAsset(eAssetType.StaticAsset, number, name, type, instanceId);
|
||||||
return fr.UserConfigurableAssetDetails[number].Asset as FusionStaticAsset;
|
return fr.UserConfigurableAssetDetails[number].Asset as FusionStaticAsset;
|
||||||
|
}
|
||||||
|
catch (InvalidOperationException ex)
|
||||||
|
{
|
||||||
|
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Error creating Static Asset for device: '{0}'. Check that multiple devices don't have missing or duplicate uid properties in configuration. /r/nError: {1}", name, ex);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Debug.Console(2, Debug.ErrorLogLevel.Error, "Error creating Static Asset: {0}", e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static FusionOccupancySensor CreateOccupancySensorAsset(this FusionRoom fr, uint number, string name,
|
public static FusionOccupancySensor CreateOccupancySensorAsset(this FusionRoom fr, uint number, string name,
|
||||||
string type, string instanceId)
|
string type, string instanceId)
|
||||||
{
|
{
|
||||||
Debug.Console(0, "Adding Fusion Occupancy Sensor Asset '{0}' to slot {1} with GUID: '{2}'", name, number,
|
try
|
||||||
instanceId);
|
{
|
||||||
|
Debug.Console(0, "Adding Fusion Occupancy Sensor Asset '{0}' to slot {1} with GUID: '{2}'", name, number,
|
||||||
|
instanceId);
|
||||||
|
|
||||||
fr.AddAsset(eAssetType.OccupancySensor, number, name, type, instanceId);
|
fr.AddAsset(eAssetType.OccupancySensor, number, name, type, instanceId);
|
||||||
return fr.UserConfigurableAssetDetails[number].Asset as FusionOccupancySensor;
|
return fr.UserConfigurableAssetDetails[number].Asset as FusionOccupancySensor;
|
||||||
|
}
|
||||||
|
catch (InvalidOperationException ex)
|
||||||
|
{
|
||||||
|
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Error creating Static Asset for device: '{0}'. Check that multiple devices don't have missing or duplicate uid properties in configuration. Error: {1}", name, ex);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
Debug.Console(2, Debug.ErrorLogLevel.Error, "Error creating Static Asset: {0}", e);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -26,6 +26,8 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
public static LicenseManager LicenseManager { get; set; }
|
public static LicenseManager LicenseManager { get; set; }
|
||||||
|
|
||||||
|
public static eCrestronSeries ProcessorSeries { get { return CrestronEnvironment.ProgramCompatibility; } }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The file path prefix to the folder containing configuration files
|
/// The file path prefix to the folder containing configuration files
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user