mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-04-12 12:06:58 +00:00
Added ConfigWriter class. Updated AV Funciton Driver UI classes to show shutdown prompt when room about to shut down for vacancy.
This commit is contained in:
parent
6afe1729bf
commit
c3bea683fc
7 changed files with 1667 additions and 1599 deletions
67
PepperDashEssentials/Config/ConfigWriter.cs
Normal file
67
PepperDashEssentials/Config/ConfigWriter.cs
Normal file
|
|
@ -0,0 +1,67 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using Crestron.SimplSharp;
|
||||
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
|
||||
{
|
||||
public class ConfigWriter
|
||||
{
|
||||
|
||||
public static bool WriteConfig()
|
||||
{
|
||||
bool success = false;
|
||||
|
||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Writing Configuration to file");
|
||||
|
||||
var fileLock = new CCriticalSection();
|
||||
|
||||
|
||||
var filePath = Global.FilePathPrefix + "LocalConfig" + Global.DirectorySeparator + "configurationFile.json";
|
||||
|
||||
Debug.Console(0, Debug.ErrorLogLevel.Notice, "Attempting to write config file: '{0}'", filePath);
|
||||
|
||||
var configData = JsonConvert.SerializeObject(ConfigReader.ConfigObject);
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
if (fileLock.TryEnter())
|
||||
{
|
||||
using (StreamWriter sw = new StreamWriter(filePath))
|
||||
{
|
||||
sw.Write(configData);
|
||||
sw.Flush();
|
||||
}
|
||||
|
||||
success = true;
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Console(0, Debug.ErrorLogLevel.Error, "Unable to enter FileLock");
|
||||
success = false;
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
Debug.Console(0, Debug.ErrorLogLevel.Error, "Error: Config write failed: \r{0}", e);
|
||||
success = false;
|
||||
}
|
||||
finally
|
||||
{
|
||||
if (fileLock != null && !fileLock.Disposed)
|
||||
fileLock.Leave();
|
||||
|
||||
}
|
||||
|
||||
return success;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -35,6 +35,8 @@ namespace PepperDash.Essentials
|
|||
//CrestronConsole.AddNewConsoleCommand(s => GoWithLoad(), "go", "Loads configuration file",
|
||||
// ConsoleAccessLevelEnum.AccessOperator);
|
||||
|
||||
CrestronConsole.AddNewConsoleCommand(S => { ConfigWriter.WriteConfig(); }, "writeconfig", "writes the current config to a file", ConsoleAccessLevelEnum.AccessOperator);
|
||||
|
||||
CrestronConsole.AddNewConsoleCommand(s =>
|
||||
{
|
||||
foreach (var tl in TieLineCollection.Default)
|
||||
|
|
|
|||
|
|
@ -127,6 +127,7 @@
|
|||
<Compile Include="Configuration ORIGINAL\Factories\DisplayFactory.cs" />
|
||||
<Compile Include="Configuration ORIGINAL\Factories\FactoryHelper.cs" />
|
||||
<Compile Include="Config\ConfigReader.cs" />
|
||||
<Compile Include="Config\ConfigWriter.cs" />
|
||||
<Compile Include="Config\EssentialsConfig.cs" />
|
||||
<Compile Include="Factory\DeviceFactory.cs" />
|
||||
<Compile Include="Devices\Amplifier.cs" />
|
||||
|
|
|
|||
|
|
@ -273,8 +273,6 @@ namespace PepperDash.Essentials.Room.Behaviours
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
void CalculateAndSetAcknowledgeExpirationTimeout(ScheduledEvent schEvent, DateTime time1, DateTime time2)
|
||||
{
|
||||
Debug.Console(1, this, "time1.Hour = {0}", time1.Hour);
|
||||
|
|
@ -421,7 +419,7 @@ namespace PepperDash.Essentials.Room.Behaviours
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Callback for event that enables feature
|
||||
/// Callback for event that enables feature. Enables feature if config property is true
|
||||
/// </summary>
|
||||
/// <param name="SchEvent"></param>
|
||||
/// <param name="type"></param>
|
||||
|
|
@ -437,7 +435,7 @@ namespace PepperDash.Essentials.Room.Behaviours
|
|||
}
|
||||
|
||||
/// <summary>
|
||||
/// Callback for event that enables feature
|
||||
/// Callback for event that enables feature. Disables feature
|
||||
/// </summary>
|
||||
/// <param name="SchEvent"></param>
|
||||
/// <param name="type"></param>
|
||||
|
|
|
|||
|
|
@ -1 +1 @@
|
|||
Subproject commit 5c2202723fd8d3d5b5a3d17e600c47f0e10b61c2
|
||||
Subproject commit bf9115f17b481c8a1a65128ba02c6da90523ac17
|
||||
Loading…
Add table
Add a link
Reference in a new issue