mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-16 05:05:00 +00:00
Added initial filesystem set up that puts all folders in place on initial run
This commit is contained in:
@@ -16,13 +16,21 @@ namespace PepperDash.Essentials
|
||||
{
|
||||
public static EssentialsConfig ConfigObject { get; private set; }
|
||||
|
||||
public static void LoadConfig2()
|
||||
public static bool LoadConfig2()
|
||||
{
|
||||
Debug.Console(0, "Using unmerged system/template configs.");
|
||||
try
|
||||
{
|
||||
using (StreamReader fs = new StreamReader(string.Format(@"\NVRAM\program{0}\ConfigurationFile.json",
|
||||
InitialParametersClass.ApplicationNumber)))
|
||||
var filePath = string.Format(@"\NVRAM\program{0}\ConfigurationFile.json",
|
||||
InitialParametersClass.ApplicationNumber);
|
||||
if (!File.Exists(filePath))
|
||||
{
|
||||
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))
|
||||
{
|
||||
var doubleObj = JObject.Parse(fs.ReadToEnd());
|
||||
ConfigObject = MergeConfigs(doubleObj).ToObject<EssentialsConfig>();
|
||||
@@ -38,13 +46,13 @@ namespace PepperDash.Essentials
|
||||
{
|
||||
ConfigObject.TemplateUrl= doubleObj["template_url"].Value<string>();
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
return true;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.Console(0, "Config failed: \r{0}", e);
|
||||
Debug.Console(0, "ERROR: Config load failed: \r{0}", e);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Linq;
|
||||
using Crestron.SimplSharp;
|
||||
using Crestron.SimplSharp.CrestronIO;
|
||||
using Crestron.SimplSharpPro;
|
||||
using Crestron.SimplSharpPro.CrestronThread;
|
||||
using PepperDash.Core;
|
||||
@@ -49,33 +50,82 @@ namespace PepperDash.Essentials
|
||||
/// </summary>
|
||||
public void GoWithLoad()
|
||||
{
|
||||
// var thread = new Thread(o =>
|
||||
// {
|
||||
try
|
||||
try
|
||||
{
|
||||
CrestronConsole.AddNewConsoleCommand(EnablePortalSync, "portalsync", "Loads Portal Sync",
|
||||
ConsoleAccessLevelEnum.AccessOperator);
|
||||
|
||||
//PortalSync = new PepperDashPortalSyncClient();
|
||||
|
||||
Debug.Console(0, "Starting Essentials load from configuration");
|
||||
|
||||
var filesReady = SetupFilesystem();
|
||||
if (filesReady)
|
||||
{
|
||||
CrestronConsole.AddNewConsoleCommand(EnablePortalSync, "portalsync", "Loads Portal Sync",
|
||||
ConsoleAccessLevelEnum.AccessOperator);
|
||||
Debug.Console(0, "Folder structure verified. Loading config...");
|
||||
if (!ConfigReader.LoadConfig2())
|
||||
return;
|
||||
|
||||
//PortalSync = new PepperDashPortalSyncClient();
|
||||
|
||||
Debug.Console(0, "Starting Essentials load from configuration");
|
||||
ConfigReader.LoadConfig2();
|
||||
LoadDevices();
|
||||
LoadTieLines();
|
||||
LoadRooms();
|
||||
|
||||
LogoServer = new HttpLogoServer(8080, @"\html\logo");
|
||||
try
|
||||
{
|
||||
LogoServer = new HttpLogoServer(8080, @"\html\logo");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
|
||||
Debug.Console(0, "WARNING: Logo server cannot be started on port 8080:\n{0}", e);
|
||||
}
|
||||
|
||||
DeviceManager.ActivateAll();
|
||||
Debug.Console(0, "Essentials load complete\r" +
|
||||
"-------------------------------------------------------------");
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.Console(0, "FATAL INITIALIZE ERROR. System is in an inconsistent state:\r{0}", e);
|
||||
"-------------------------------------------------------------");
|
||||
}
|
||||
// return null;
|
||||
// }, null);
|
||||
else
|
||||
{
|
||||
Debug.Console(0,
|
||||
"------------------------------------------------\n" +
|
||||
"------------------------------------------------\n" +
|
||||
"------------------------------------------------\n" +
|
||||
"Essentials file structure setup completed.\n" +
|
||||
"Please load config, sgd and ir files and\n" +
|
||||
"restart program.\n" +
|
||||
"------------------------------------------------\n" +
|
||||
"------------------------------------------------\n" +
|
||||
"------------------------------------------------");
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.Console(0, "FATAL INITIALIZE ERROR. System is in an inconsistent state:\r{0}", e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Verifies filesystem is set up. IR, SGD, and program1 folders
|
||||
/// </summary>
|
||||
bool SetupFilesystem()
|
||||
{
|
||||
Debug.Console(0, "Verifying and/or creating folder structure");
|
||||
var appNum = InitialParametersClass.ApplicationNumber;
|
||||
var configDir = @"\NVRAM\Program" + appNum;
|
||||
var configExists = Directory.Exists(configDir);
|
||||
if (!configExists)
|
||||
Directory.Create(configDir);
|
||||
|
||||
var irDir = string.Format(@"\NVRAM\Program{0}\ir", appNum);
|
||||
if (!Directory.Exists(irDir))
|
||||
Directory.Create(irDir);
|
||||
|
||||
var sgdDir = string.Format(@"\NVRAM\Program{0}\sgd", appNum);
|
||||
if (!Directory.Exists(sgdDir))
|
||||
Directory.Create(sgdDir);
|
||||
|
||||
return configExists;
|
||||
}
|
||||
|
||||
public void EnablePortalSync(string s)
|
||||
|
||||
@@ -139,7 +139,7 @@
|
||||
<Compile Include="Room\Config\EssentialsHuddleVtc1PropertiesConfig.cs" />
|
||||
<Compile Include="Room\Config\EssentialsRoomEmergencyConfig.cs" />
|
||||
<Compile Include="Room\Cotija\CotijaConfig.cs" />
|
||||
<Compile Include="Room\Cotija\CotijaRoomBridge.cs" />
|
||||
<Compile Include="Room\Cotija\RoomBridges\CotijaEssentialsHuddleSpaceRoomBridge.cs" />
|
||||
<Compile Include="Room\Cotija\DeviceTypeInterfaces\IChannelExtensions.cs" />
|
||||
<Compile Include="Room\Cotija\DeviceTypeInterfaces\IColorExtensions.cs" />
|
||||
<Compile Include="Room\Cotija\DeviceTypeInterfaces\IDPadExtensions.cs" />
|
||||
|
||||
@@ -4,5 +4,5 @@
|
||||
[assembly: AssemblyCompany("PepperDash Technology Corp")]
|
||||
[assembly: AssemblyProduct("PepperDashEssentials")]
|
||||
[assembly: AssemblyCopyright("Copyright © PepperDash Technology Corp 2017")]
|
||||
[assembly: AssemblyVersion("1.0.15.*")]
|
||||
[assembly: AssemblyVersion("1.0.17.*")]
|
||||
|
||||
|
||||
@@ -53,6 +53,7 @@ namespace PepperDash.Essentials
|
||||
public CotijaSystemController(string key, string name, CotijaConfig config) : base(key, name)
|
||||
{
|
||||
Config = config;
|
||||
Debug.Console(0, this, "Mobile UI controller initializing for server:{0}", config.ServerUrl);
|
||||
|
||||
CotijaRooms = new List<CotijaEssentialsHuddleSpaceRoomBridge>();
|
||||
|
||||
|
||||
@@ -98,7 +98,7 @@ namespace PepperDash.Essentials
|
||||
+ @"\sgd\" + props.SgdFile;
|
||||
if (!File.Exists(sgdName))
|
||||
{
|
||||
Debug.Console(0, this, "WARNING: Smart object file '{0}' not present. Exiting TSW load", sgdName);
|
||||
Debug.Console(0, this, "ERROR: Smart object file '{0}' not present. Exiting TSW load", sgdName);
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Binary file not shown.
Binary file not shown.
Reference in New Issue
Block a user