mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-01-11 19:44:52 +00:00
Refactored how configuration, IR and SGD file path prefixes are handled, in order to be able to handle a different file structure if running on XiO Edge
This commit is contained in:
@@ -20,7 +20,7 @@ namespace PepperDash.Essentials.Core
|
||||
{
|
||||
get
|
||||
{
|
||||
return string.Format(@"\NVRAM\Program{0}\IR\", InitialParametersClass.ApplicationNumber);
|
||||
return Global.FilePathPrefix + @"IR\";
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -13,19 +13,18 @@ namespace PepperDash.Essentials.Core
|
||||
{
|
||||
public static CrestronControlSystem ControlSystem { get; set; }
|
||||
|
||||
public static LicenseManager LicenseManager { get; set; }
|
||||
|
||||
//public static EssentialsHttpServer HttpConfigServer
|
||||
//{
|
||||
// get
|
||||
// {
|
||||
// if (_HttpConfigServer == null)
|
||||
// _HttpConfigServer = new EssentialsHttpServer();
|
||||
// return _HttpConfigServer;
|
||||
// }
|
||||
//}
|
||||
//static EssentialsHttpServer _HttpConfigServer;
|
||||
|
||||
public static LicenseManager LicenseManager { get; set; }
|
||||
|
||||
public static string FilePathPrefix { get; private set; }
|
||||
|
||||
/// <summary>
|
||||
/// Sets the file path prefix
|
||||
/// </summary>
|
||||
/// <param name="prefix"></param>
|
||||
public static void SetFilePathPrefix(string prefix)
|
||||
{
|
||||
FilePathPrefix = prefix;
|
||||
}
|
||||
|
||||
static Global()
|
||||
{
|
||||
|
||||
@@ -55,9 +55,9 @@
|
||||
<HintPath>..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.DM.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="mscorlib" />
|
||||
<Reference Include="PepperDash_Core, Version=1.0.1.20241, Culture=neutral, processorArchitecture=MSIL">
|
||||
<Reference Include="PepperDash_Core, Version=1.0.4.20530, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\pepperdash-simplsharp-core\Pepperdash Core\CLZ Builds\PepperDash_Core.dll</HintPath>
|
||||
<HintPath>..\..\..\PepperDash.Core\Pepperdash Core\Pepperdash Core\bin\PepperDash_Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SimplSharpCustomAttributesInterface, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1099c178b3b54c3b, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
|
||||
@@ -59,9 +59,9 @@
|
||||
<HintPath>..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.GeneralIO.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="mscorlib" />
|
||||
<Reference Include="PepperDash_Core, Version=1.0.1.20241, Culture=neutral, processorArchitecture=MSIL">
|
||||
<Reference Include="PepperDash_Core, Version=1.0.4.20530, Culture=neutral, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
<HintPath>..\..\..\pepperdash-simplsharp-core\Pepperdash Core\CLZ Builds\PepperDash_Core.dll</HintPath>
|
||||
<HintPath>..\..\..\PepperDash.Core\Pepperdash Core\Pepperdash Core\bin\PepperDash_Core.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="SimplSharpCustomAttributesInterface, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1099c178b3b54c3b, processorArchitecture=MSIL">
|
||||
<SpecificVersion>False</SpecificVersion>
|
||||
|
||||
@@ -5,6 +5,7 @@ using Crestron.SimplSharp.CrestronIO;
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using PepperDash.Core;
|
||||
using PepperDash.Essentials.Core;
|
||||
using PepperDash.Essentials.Core.Config;
|
||||
|
||||
namespace PepperDash.Essentials
|
||||
@@ -21,13 +22,13 @@ namespace PepperDash.Essentials
|
||||
Debug.Console(0, "Loading unmerged system/template portal configuration file.");
|
||||
try
|
||||
{
|
||||
var filePath = string.Format(@"\NVRAM\program{0}\ConfigurationFile.json",
|
||||
InitialParametersClass.ApplicationNumber);
|
||||
var filePath = Global.FilePathPrefix + @"ConfigurationFile.json";
|
||||
|
||||
if (!File.Exists(filePath))
|
||||
{
|
||||
Debug.Console(0,
|
||||
"ERROR: Configuration file not present. Please load file to {0} and reset program", filePath);
|
||||
return false;
|
||||
Debug.Console(0,
|
||||
"ERROR: Configuration file not present. Please load file to {0} and reset program", filePath);
|
||||
return false;
|
||||
}
|
||||
|
||||
using (StreamReader fs = new StreamReader(filePath))
|
||||
|
||||
@@ -17,7 +17,7 @@ namespace PepperDash.Essentials
|
||||
{
|
||||
public static class FactoryHelper
|
||||
{
|
||||
public static string IrDriverPathPrefix = @"\NVRAM\IR\";
|
||||
public static string IrDriverPathPrefix = Global.FilePathPrefix + @"IR\";
|
||||
|
||||
public static void HandleUnknownType(JToken devToken, string type)
|
||||
{
|
||||
|
||||
@@ -54,9 +54,34 @@ namespace PepperDash.Essentials
|
||||
"Template URL: {1}", ConfigReader.ConfigObject.SystemUrl, ConfigReader.ConfigObject.TemplateUrl);
|
||||
}, "portalinfo", "Shows portal URLS from configuration", ConsoleAccessLevelEnum.AccessOperator);
|
||||
|
||||
|
||||
DeterminePlatform();
|
||||
|
||||
GoWithLoad();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Determines if the program is running on a processor (appliance) or server (XiO Edge).
|
||||
///
|
||||
/// Sets Global.FilePathPrefix based on platform
|
||||
/// </summary>
|
||||
public void DeterminePlatform()
|
||||
{
|
||||
string filePathPrefix;
|
||||
|
||||
if (CrestronEnvironment.DevicePlatform != eDevicePlatform.Server)
|
||||
{
|
||||
filePathPrefix = string.Format(@"\NVRAM\program{0}\",
|
||||
InitialParametersClass.ApplicationNumber);
|
||||
}
|
||||
else
|
||||
{
|
||||
filePathPrefix = (@"\USER\");
|
||||
}
|
||||
|
||||
Global.SetFilePathPrefix(filePathPrefix);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Do it, yo
|
||||
/// </summary>
|
||||
@@ -109,17 +134,16 @@ namespace PepperDash.Essentials
|
||||
bool SetupFilesystem()
|
||||
{
|
||||
Debug.Console(0, "Verifying and/or creating folder structure");
|
||||
var appNum = InitialParametersClass.ApplicationNumber;
|
||||
var configDir = @"\NVRAM\Program" + appNum;
|
||||
var configDir = Global.FilePathPrefix;
|
||||
var configExists = Directory.Exists(configDir);
|
||||
if (!configExists)
|
||||
Directory.Create(configDir);
|
||||
|
||||
var irDir = string.Format(@"\NVRAM\Program{0}\ir", appNum);
|
||||
var irDir = Global.FilePathPrefix + @"ir";
|
||||
if (!Directory.Exists(irDir))
|
||||
Directory.Create(irDir);
|
||||
|
||||
var sgdDir = string.Format(@"\NVRAM\Program{0}\sgd", appNum);
|
||||
var sgdDir = Global.FilePathPrefix + @"sgd";
|
||||
if (!Directory.Exists(sgdDir))
|
||||
Directory.Create(sgdDir);
|
||||
|
||||
|
||||
@@ -140,17 +140,20 @@ namespace PepperDash.Essentials.Fusion
|
||||
|
||||
var slot = Global.ControlSystem.ProgramNumber;
|
||||
|
||||
string guidFilePath = string.Format(@"\NVRAM\Program{0}\{1}-FusionGuids.json", Global.ControlSystem.ProgramNumber, InitialParametersClass.ProgramIDTag);
|
||||
string guidFilePath = Global.FilePathPrefix + string.Format(@"{1}-FusionGuids.json", Global.ControlSystem.ProgramNumber, InitialParametersClass.ProgramIDTag);
|
||||
|
||||
GuidFileExists = File.Exists(guidFilePath);
|
||||
|
||||
if (GuidFileExists)
|
||||
// Check if file exists
|
||||
if (!GuidFileExists)
|
||||
{
|
||||
ReadGuidFile(guidFilePath);
|
||||
// Does not exist. Create GUIDs
|
||||
GUIDs = new FusionRoomGuids(Room.Name, ipId, GUIDs.GenerateNewRoomGuid(slot, mac), FusionStaticAssets);
|
||||
}
|
||||
else
|
||||
{
|
||||
GUIDs = new FusionRoomGuids(Room.Name, ipId, GUIDs.GenerateNewRoomGuid(slot, mac), FusionStaticAssets);
|
||||
// Exists. Read GUIDs
|
||||
ReadGuidFile(guidFilePath);
|
||||
}
|
||||
|
||||
CreateSymbolAndBasicSigs(IpId);
|
||||
@@ -267,11 +270,11 @@ namespace PepperDash.Essentials.Fusion
|
||||
|
||||
}
|
||||
|
||||
Debug.Console(0, this, "Fusion Guids successfully read from file:");
|
||||
Debug.Console(0, this, "Fusion Guids successfully read from file: {0}", filePath);
|
||||
|
||||
Debug.Console(1, this, "\nRoom Name: {0}\nIPID: {1:x}\n RoomGuid: {2}", Room.Name, IpId, RoomGuid);
|
||||
|
||||
foreach (KeyValuePair<int, FusionAsset> item in FusionStaticAssets)
|
||||
foreach (var item in FusionStaticAssets)
|
||||
{
|
||||
Debug.Console(1, this, "\nAsset Name: {0}\nAsset No: {1}\n Guid: {2}", item.Value.Name, item.Value.SlotNumber, item.Value.InstanceId);
|
||||
}
|
||||
|
||||
@@ -4,5 +4,5 @@
|
||||
[assembly: AssemblyCompany("PepperDash Technology Corp")]
|
||||
[assembly: AssemblyProduct("PepperDashEssentials")]
|
||||
[assembly: AssemblyCopyright("Copyright © PepperDash Technology Corp 2017")]
|
||||
[assembly: AssemblyVersion("1.0.47.*")]
|
||||
[assembly: AssemblyVersion("1.0.48.*")]
|
||||
|
||||
|
||||
@@ -94,7 +94,7 @@ namespace PepperDash.Essentials
|
||||
Debug.Console(0, this, "WARNING: Registration failed. Continuing, but panel may not function: {0}", regSuccess);
|
||||
|
||||
// Give up cleanly if SGD is not present.
|
||||
var sgdName = @"\NVRAM\Program" + InitialParametersClass.ApplicationNumber
|
||||
var sgdName = Global.FilePathPrefix
|
||||
+ @"\sgd\" + props.SgdFile;
|
||||
if (!File.Exists(sgdName))
|
||||
{
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user