mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-15 20:54:55 +00:00
Merged in feature/ecs-1242 (pull request #43)
Feature/ecs 1242 Approved-by: Neil Dorin <ndorin@pepperdash.com>
This commit is contained in:
@@ -223,6 +223,8 @@ namespace PepperDash.Essentials
|
|||||||
|
|
||||||
CrestronEnvironment.Sleep(1000);
|
CrestronEnvironment.Sleep(1000);
|
||||||
|
|
||||||
|
Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Shutting down room");
|
||||||
|
|
||||||
RunRouteAction("roomOff");
|
RunRouteAction("roomOff");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -275,8 +277,8 @@ namespace PepperDash.Essentials
|
|||||||
// Run this on a separate thread
|
// Run this on a separate thread
|
||||||
new CTimer(o =>
|
new CTimer(o =>
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "Run route action '{0}'", routeKey);
|
Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Run route action '{0}'", routeKey);
|
||||||
var dict = ConfigReader.ConfigObject.GetSourceListForKey(SourceListKey);
|
var dict = ConfigReader.ConfigObject.GetSourceListForKey(SourceListKey);
|
||||||
if(dict == null)
|
if(dict == null)
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "WARNING: Config source list '{0}' not found", SourceListKey);
|
Debug.Console(1, this, "WARNING: Config source list '{0}' not found", SourceListKey);
|
||||||
|
|||||||
@@ -334,8 +334,11 @@ namespace PepperDash.Essentials
|
|||||||
{
|
{
|
||||||
// Add Occupancy object from config
|
// Add Occupancy object from config
|
||||||
if (PropertiesConfig.Occupancy != null)
|
if (PropertiesConfig.Occupancy != null)
|
||||||
|
{
|
||||||
|
Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Setting Occupancy Provider for room");
|
||||||
this.SetRoomOccupancy(DeviceManager.GetDeviceForKey(PropertiesConfig.Occupancy.DeviceKey) as
|
this.SetRoomOccupancy(DeviceManager.GetDeviceForKey(PropertiesConfig.Occupancy.DeviceKey) as
|
||||||
IOccupancyStatusProvider, PropertiesConfig.Occupancy.TimeoutMinutes);
|
IOccupancyStatusProvider, PropertiesConfig.Occupancy.TimeoutMinutes);
|
||||||
|
}
|
||||||
|
|
||||||
this.LogoUrl = PropertiesConfig.Logo.GetUrl();
|
this.LogoUrl = PropertiesConfig.Logo.GetUrl();
|
||||||
this.SourceListKey = PropertiesConfig.SourceListKey;
|
this.SourceListKey = PropertiesConfig.SourceListKey;
|
||||||
@@ -359,6 +362,8 @@ namespace PepperDash.Essentials
|
|||||||
|
|
||||||
CrestronEnvironment.Sleep(1000);
|
CrestronEnvironment.Sleep(1000);
|
||||||
|
|
||||||
|
Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Shutting down room");
|
||||||
|
|
||||||
RunRouteAction("roomOff");
|
RunRouteAction("roomOff");
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -408,7 +413,7 @@ namespace PepperDash.Essentials
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
|
|
||||||
Debug.Console(1, this, "Run route action '{0}'", routeKey);
|
Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Run route action '{0}'", routeKey);
|
||||||
var dict = ConfigReader.ConfigObject.GetSourceListForKey(SourceListKey);
|
var dict = ConfigReader.ConfigObject.GetSourceListForKey(SourceListKey);
|
||||||
if (dict == null)
|
if (dict == null)
|
||||||
{
|
{
|
||||||
|
|||||||
@@ -0,0 +1,40 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using System.Text;
|
||||||
|
using Crestron.SimplSharp;
|
||||||
|
using Crestron.SimplSharpPro;
|
||||||
|
using Crestron.SimplSharpPro.GeneralIO;
|
||||||
|
|
||||||
|
using PepperDash.Core;
|
||||||
|
|
||||||
|
namespace PepperDash.Essentials.Core
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Wrapper class for CEN-IO-DIGIN-104 digital input module
|
||||||
|
/// </summary>
|
||||||
|
public class CenIoDigIn104Controller : Device, IDigitalInputPorts
|
||||||
|
{
|
||||||
|
public CenIoDi104 Di104 { get; private set; }
|
||||||
|
|
||||||
|
public CenIoDigIn104Controller(string key, string name, CenIoDi104 di104)
|
||||||
|
: base(key, name)
|
||||||
|
{
|
||||||
|
Di104 = di104;
|
||||||
|
}
|
||||||
|
|
||||||
|
#region IDigitalInputPorts Members
|
||||||
|
|
||||||
|
public CrestronCollection<DigitalInput> DigitalInputPorts
|
||||||
|
{
|
||||||
|
get { return Di104.DigitalInputPorts; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public int NumberOfDigitalInputPorts
|
||||||
|
{
|
||||||
|
get { return Di104.NumberOfDigitalInputPorts; }
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -52,6 +52,13 @@ namespace PepperDash.Essentials.Core
|
|||||||
Debug.Console(1, "Factory Attempting to create new Generic Comm Device");
|
Debug.Console(1, "Factory Attempting to create new Generic Comm Device");
|
||||||
return new GenericComm(dc);
|
return new GenericComm(dc);
|
||||||
}
|
}
|
||||||
|
else if (typeName == "ceniodigin104")
|
||||||
|
{
|
||||||
|
var control = CommFactory.GetControlPropertiesConfig(dc);
|
||||||
|
var ipid = control.CresnetIdInt;
|
||||||
|
|
||||||
|
return new CenIoDigIn104Controller(key, name, new Crestron.SimplSharpPro.GeneralIO.CenIoDi104(ipid, Global.ControlSystem));
|
||||||
|
}
|
||||||
|
|
||||||
// then check for types that have been added by plugin dlls.
|
// then check for types that have been added by plugin dlls.
|
||||||
if (FactoryMethods.ContainsKey(typeName))
|
if (FactoryMethods.ContainsKey(typeName))
|
||||||
|
|||||||
@@ -62,6 +62,10 @@
|
|||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.Fusion.dll</HintPath>
|
<HintPath>..\..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.Fusion.dll</HintPath>
|
||||||
</Reference>
|
</Reference>
|
||||||
|
<Reference Include="Crestron.SimplSharpPro.GeneralIO, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1099c178b3b54c3b, processorArchitecture=MSIL">
|
||||||
|
<SpecificVersion>False</SpecificVersion>
|
||||||
|
<HintPath>..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.GeneralIO.dll</HintPath>
|
||||||
|
</Reference>
|
||||||
<Reference Include="Crestron.SimplSharpPro.Remotes, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1099c178b3b54c3b, processorArchitecture=MSIL">
|
<Reference Include="Crestron.SimplSharpPro.Remotes, Version=1.0.0.0, Culture=neutral, PublicKeyToken=1099c178b3b54c3b, processorArchitecture=MSIL">
|
||||||
<SpecificVersion>False</SpecificVersion>
|
<SpecificVersion>False</SpecificVersion>
|
||||||
<HintPath>..\..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.Remotes.dll</HintPath>
|
<HintPath>..\..\..\..\..\..\..\..\..\..\ProgramData\Crestron\SDK\SSPDevices\Crestron.SimplSharpPro.Remotes.dll</HintPath>
|
||||||
@@ -114,6 +118,7 @@
|
|||||||
<Compile Include="Config\Essentials\ConfigWriter.cs" />
|
<Compile Include="Config\Essentials\ConfigWriter.cs" />
|
||||||
<Compile Include="Config\Essentials\EssentialsConfig.cs" />
|
<Compile Include="Config\Essentials\EssentialsConfig.cs" />
|
||||||
<Compile Include="Config\SourceDevicePropertiesConfigBase.cs" />
|
<Compile Include="Config\SourceDevicePropertiesConfigBase.cs" />
|
||||||
|
<Compile Include="Crestron IO\Inputs\CenIoDigIn104Controller.cs" />
|
||||||
<Compile Include="Crestron IO\Inputs\GenericDigitalInputDevice.cs" />
|
<Compile Include="Crestron IO\Inputs\GenericDigitalInputDevice.cs" />
|
||||||
<Compile Include="Crestron IO\Inputs\GenericVersiportInputDevice.cs" />
|
<Compile Include="Crestron IO\Inputs\GenericVersiportInputDevice.cs" />
|
||||||
<Compile Include="Crestron IO\Inputs\IDigitalInput.cs" />
|
<Compile Include="Crestron IO\Inputs\IDigitalInput.cs" />
|
||||||
|
|||||||
@@ -100,7 +100,8 @@ namespace PepperDash.Essentials.Core
|
|||||||
ShutdownPromptTimer.HasFinished += (o, a) => Shutdown(); // Shutdown is triggered
|
ShutdownPromptTimer.HasFinished += (o, a) => Shutdown(); // Shutdown is triggered
|
||||||
|
|
||||||
ShutdownPromptSeconds = 60;
|
ShutdownPromptSeconds = 60;
|
||||||
ShutdownVacancySeconds = 120;
|
ShutdownVacancySeconds = 120;
|
||||||
|
|
||||||
ShutdownType = eShutdownType.None;
|
ShutdownType = eShutdownType.None;
|
||||||
|
|
||||||
RoomVacancyShutdownTimer = new SecondsCountdownTimer(Key + "-vacancyOffTimer");
|
RoomVacancyShutdownTimer = new SecondsCountdownTimer(Key + "-vacancyOffTimer");
|
||||||
@@ -140,7 +141,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
case eVacancyMode.InShutdownWarning:
|
case eVacancyMode.InShutdownWarning:
|
||||||
{
|
{
|
||||||
StartShutdown(eShutdownType.Vacancy);
|
StartShutdown(eShutdownType.Vacancy);
|
||||||
Debug.Console(0, this, "Shutting Down due to vacancy.");
|
Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Shutting Down due to vacancy.");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
default:
|
default:
|
||||||
@@ -163,7 +164,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
ShutdownType = type;
|
ShutdownType = type;
|
||||||
ShutdownPromptTimer.Start();
|
ShutdownPromptTimer.Start();
|
||||||
|
|
||||||
Debug.Console(0, this, "ShutdwonPromptTimer Started. Type: {0}. Seconds: {1}", ShutdownType, ShutdownPromptTimer.SecondsToCount);
|
Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "ShutdownPromptTimer Started. Type: {0}. Seconds: {1}", ShutdownType, ShutdownPromptTimer.SecondsToCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void StartRoomVacancyTimer(eVacancyMode mode)
|
public void StartRoomVacancyTimer(eVacancyMode mode)
|
||||||
@@ -175,7 +176,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
VacancyMode = mode;
|
VacancyMode = mode;
|
||||||
RoomVacancyShutdownTimer.Start();
|
RoomVacancyShutdownTimer.Start();
|
||||||
|
|
||||||
Debug.Console(0, this, "Vacancy Timer Started. Mode: {0}. Seconds: {1}", VacancyMode, RoomVacancyShutdownTimer.SecondsToCount);
|
Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Vacancy Timer Started. Mode: {0}. Seconds: {1}", VacancyMode, RoomVacancyShutdownTimer.SecondsToCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -211,6 +212,9 @@ namespace PepperDash.Essentials.Core
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Room Occupancy set to device: '{0}'", (statusProvider as Device).Key);
|
||||||
|
Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "Timeout Minutes from Config is: {0}", timeoutMinutes);
|
||||||
|
|
||||||
// If status provider is fusion, set flag to remote
|
// If status provider is fusion, set flag to remote
|
||||||
if (statusProvider is Core.Fusion.EssentialsHuddleSpaceFusionSystemControllerBase)
|
if (statusProvider is Core.Fusion.EssentialsHuddleSpaceFusionSystemControllerBase)
|
||||||
OccupancyStatusProviderIsRemote = true;
|
OccupancyStatusProviderIsRemote = true;
|
||||||
@@ -218,16 +222,14 @@ namespace PepperDash.Essentials.Core
|
|||||||
if(timeoutMinutes > 0)
|
if(timeoutMinutes > 0)
|
||||||
RoomVacancyShutdownSeconds = timeoutMinutes * 60;
|
RoomVacancyShutdownSeconds = timeoutMinutes * 60;
|
||||||
|
|
||||||
Debug.Console(1, this, "RoomVacancyShutdownSeconds set to {0}", RoomVacancyShutdownSeconds);
|
Debug.Console(0, this, Debug.ErrorLogLevel.Notice, "RoomVacancyShutdownSeconds set to {0}", RoomVacancyShutdownSeconds);
|
||||||
|
|
||||||
RoomOccupancy = statusProvider;
|
RoomOccupancy = statusProvider;
|
||||||
|
|
||||||
OnRoomOccupancyIsSet();
|
|
||||||
|
|
||||||
RoomOccupancy.RoomIsOccupiedFeedback.OutputChange -= RoomIsOccupiedFeedback_OutputChange;
|
RoomOccupancy.RoomIsOccupiedFeedback.OutputChange -= RoomIsOccupiedFeedback_OutputChange;
|
||||||
RoomOccupancy.RoomIsOccupiedFeedback.OutputChange += RoomIsOccupiedFeedback_OutputChange;
|
RoomOccupancy.RoomIsOccupiedFeedback.OutputChange += RoomIsOccupiedFeedback_OutputChange;
|
||||||
|
|
||||||
Debug.Console(0, this, "Room Occupancy set to device: '{0}'", (statusProvider as Device).Key);
|
OnRoomOccupancyIsSet();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnRoomOccupancyIsSet()
|
void OnRoomOccupancyIsSet()
|
||||||
@@ -252,13 +254,13 @@ namespace PepperDash.Essentials.Core
|
|||||||
{
|
{
|
||||||
if (RoomOccupancy.RoomIsOccupiedFeedback.BoolValue == false)
|
if (RoomOccupancy.RoomIsOccupiedFeedback.BoolValue == false)
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "Notice: Vacancy Detected");
|
Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "Notice: Vacancy Detected");
|
||||||
// Trigger the timer when the room is vacant
|
// Trigger the timer when the room is vacant
|
||||||
StartRoomVacancyTimer(eVacancyMode.InInitialVacancy);
|
StartRoomVacancyTimer(eVacancyMode.InInitialVacancy);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.Console(1, this, "Notice: Occupancy Detected");
|
Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "Notice: Occupancy Detected");
|
||||||
// Reset the timer when the room is occupied
|
// Reset the timer when the room is occupied
|
||||||
RoomVacancyShutdownTimer.Cancel();
|
RoomVacancyShutdownTimer.Cancel();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -66,6 +66,11 @@ namespace PepperDash.Essentials.DM
|
|||||||
public const int RouteOffTime = 500;
|
public const int RouteOffTime = 500;
|
||||||
Dictionary<PortNumberType, CTimer> RouteOffTimers = new Dictionary<PortNumberType, CTimer>();
|
Dictionary<PortNumberType, CTimer> RouteOffTimers = new Dictionary<PortNumberType, CTimer>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Text that represents when an output has no source routed to it
|
||||||
|
/// </summary>
|
||||||
|
public string NoRouteText = "";
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Factory method to create a new chassis controller from config data. Limited to 8x8 right now
|
/// Factory method to create a new chassis controller from config data. Limited to 8x8 right now
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -128,6 +133,15 @@ namespace PepperDash.Essentials.DM
|
|||||||
|
|
||||||
controller.InputNames = properties.InputNames;
|
controller.InputNames = properties.InputNames;
|
||||||
controller.OutputNames = properties.OutputNames;
|
controller.OutputNames = properties.OutputNames;
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(properties.NoRouteText))
|
||||||
|
{
|
||||||
|
controller.NoRouteText = properties.NoRouteText;
|
||||||
|
Debug.Console(1, controller, "Setting No Route Text value to: {0}", controller.NoRouteText);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Debug.Console(1, controller, "NoRouteText not specified. Defaulting to blank string.", controller.NoRouteText);
|
||||||
|
|
||||||
controller.PropertiesConfig = properties;
|
controller.PropertiesConfig = properties;
|
||||||
return controller;
|
return controller;
|
||||||
}
|
}
|
||||||
@@ -217,7 +231,7 @@ namespace PepperDash.Essentials.DM
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return "";
|
return NoRouteText;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
OutputAudioRouteNameFeedbacks[tempX] = new StringFeedback(() =>
|
OutputAudioRouteNameFeedbacks[tempX] = new StringFeedback(() =>
|
||||||
@@ -228,7 +242,7 @@ namespace PepperDash.Essentials.DM
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return "";
|
return NoRouteText;
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -48,6 +48,11 @@ namespace PepperDash.Essentials.DM
|
|||||||
public const int RouteOffTime = 500;
|
public const int RouteOffTime = 500;
|
||||||
Dictionary<PortNumberType, CTimer> RouteOffTimers = new Dictionary<PortNumberType, CTimer>();
|
Dictionary<PortNumberType, CTimer> RouteOffTimers = new Dictionary<PortNumberType, CTimer>();
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Text that represents when an output has no source routed to it
|
||||||
|
/// </summary>
|
||||||
|
public string NoRouteText = "";
|
||||||
|
|
||||||
public static DmpsRoutingController GetDmpsRoutingController(string key, string name,
|
public static DmpsRoutingController GetDmpsRoutingController(string key, string name,
|
||||||
DmpsRoutingPropertiesConfig properties)
|
DmpsRoutingPropertiesConfig properties)
|
||||||
{
|
{
|
||||||
@@ -67,6 +72,9 @@ namespace PepperDash.Essentials.DM
|
|||||||
controller.InputNames = properties.InputNames;
|
controller.InputNames = properties.InputNames;
|
||||||
controller.OutputNames = properties.OutputNames;
|
controller.OutputNames = properties.OutputNames;
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(properties.NoRouteText))
|
||||||
|
controller.NoRouteText = properties.NoRouteText;
|
||||||
|
|
||||||
return controller;
|
return controller;
|
||||||
|
|
||||||
}
|
}
|
||||||
@@ -191,7 +199,7 @@ namespace PepperDash.Essentials.DM
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return "";
|
return NoRouteText;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
OutputAudioRouteNameFeedbacks[outputCard.Number] = new StringFeedback(() =>
|
OutputAudioRouteNameFeedbacks[outputCard.Number] = new StringFeedback(() =>
|
||||||
@@ -202,7 +210,7 @@ namespace PepperDash.Essentials.DM
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
return "";
|
return NoRouteText;
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -32,6 +32,9 @@ namespace PepperDash.Essentials.DM.Config
|
|||||||
[JsonProperty("outputNames")]
|
[JsonProperty("outputNames")]
|
||||||
public Dictionary<uint, string> OutputNames { get; set; }
|
public Dictionary<uint, string> OutputNames { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("noRouteText")]
|
||||||
|
public string NoRouteText { get; set; }
|
||||||
|
|
||||||
[JsonProperty("inputSlotSupportsHdcp2")]
|
[JsonProperty("inputSlotSupportsHdcp2")]
|
||||||
public Dictionary<uint, bool> InputSlotSupportsHdcp2 { get; set; }
|
public Dictionary<uint, bool> InputSlotSupportsHdcp2 { get; set; }
|
||||||
|
|
||||||
|
|||||||
@@ -20,6 +20,9 @@ namespace PepperDash.Essentials.DM.Config
|
|||||||
[JsonProperty("outputNames")]
|
[JsonProperty("outputNames")]
|
||||||
public Dictionary<uint, string> OutputNames { get; set; }
|
public Dictionary<uint, string> OutputNames { get; set; }
|
||||||
|
|
||||||
|
[JsonProperty("noRouteText")]
|
||||||
|
public string NoRouteText { get; set; }
|
||||||
|
|
||||||
public DmpsRoutingPropertiesConfig()
|
public DmpsRoutingPropertiesConfig()
|
||||||
{
|
{
|
||||||
InputNames = new Dictionary<uint, string>();
|
InputNames = new Dictionary<uint, string>();
|
||||||
|
|||||||
@@ -167,84 +167,91 @@ namespace PepperDash.Essentials.Devices.Displays
|
|||||||
/// <param name="sender"></param>
|
/// <param name="sender"></param>
|
||||||
void Communication_BytesReceived(object sender, GenericCommMethodReceiveBytesArgs e)
|
void Communication_BytesReceived(object sender, GenericCommMethodReceiveBytesArgs e)
|
||||||
{
|
{
|
||||||
// This is probably not thread-safe buffering
|
try
|
||||||
// Append the incoming bytes with whatever is in the buffer
|
|
||||||
var newBytes = new byte[IncomingBuffer.Length + e.Bytes.Length];
|
|
||||||
IncomingBuffer.CopyTo(newBytes, 0);
|
|
||||||
e.Bytes.CopyTo(newBytes, IncomingBuffer.Length);
|
|
||||||
|
|
||||||
if (Debug.Level == 2) // This check is here to prevent following string format from building unnecessarily on level 0 or 1
|
|
||||||
Debug.Console(2, this, "Received:{0}", ComTextHelper.GetEscapedText(newBytes));
|
|
||||||
|
|
||||||
// Need to find AA FF and have
|
|
||||||
for (int i = 0; i < newBytes.Length; i++)
|
|
||||||
{
|
{
|
||||||
if (newBytes[i] == 0xAA && newBytes[i + 1] == 0xFF)
|
// This is probably not thread-safe buffering
|
||||||
|
// Append the incoming bytes with whatever is in the buffer
|
||||||
|
var newBytes = new byte[IncomingBuffer.Length + e.Bytes.Length];
|
||||||
|
IncomingBuffer.CopyTo(newBytes, 0);
|
||||||
|
e.Bytes.CopyTo(newBytes, IncomingBuffer.Length);
|
||||||
|
|
||||||
|
if (Debug.Level == 2) // This check is here to prevent following string format from building unnecessarily on level 0 or 1
|
||||||
|
Debug.Console(2, this, "Received:{0}", ComTextHelper.GetEscapedText(newBytes));
|
||||||
|
|
||||||
|
// Need to find AA FF and have
|
||||||
|
for (int i = 0; i < newBytes.Length; i++)
|
||||||
{
|
{
|
||||||
newBytes = newBytes.Skip(i).ToArray(); // Trim off junk if there's "dirt" in the buffer
|
if (newBytes[i] == 0xAA && newBytes[i + 1] == 0xFF)
|
||||||
|
|
||||||
// parse it
|
|
||||||
// If it's at least got the header, then process it,
|
|
||||||
while (newBytes.Length > 4 && newBytes[0] == 0xAA && newBytes[1] == 0xFF)
|
|
||||||
{
|
{
|
||||||
var msgLen = newBytes[3];
|
newBytes = newBytes.Skip(i).ToArray(); // Trim off junk if there's "dirt" in the buffer
|
||||||
// if the buffer is shorter than the header (3) + message (msgLen) + checksum (1),
|
|
||||||
// give and save it for next time
|
|
||||||
if (newBytes.Length < msgLen + 4)
|
|
||||||
break;
|
|
||||||
|
|
||||||
// Good length, grab the message
|
// parse it
|
||||||
var message = newBytes.Skip(4).Take(msgLen).ToArray();
|
// If it's at least got the header, then process it,
|
||||||
|
while (newBytes.Length > 4 && newBytes[0] == 0xAA && newBytes[1] == 0xFF)
|
||||||
// At this point, the ack/nak is the first byte
|
|
||||||
if (message[0] == 0x41)
|
|
||||||
{
|
{
|
||||||
switch (message[1]) // type byte
|
var msgLen = newBytes[3];
|
||||||
|
// if the buffer is shorter than the header (3) + message (msgLen) + checksum (1),
|
||||||
|
// give and save it for next time
|
||||||
|
if (newBytes.Length < msgLen + 4)
|
||||||
|
break;
|
||||||
|
|
||||||
|
// Good length, grab the message
|
||||||
|
var message = newBytes.Skip(4).Take(msgLen).ToArray();
|
||||||
|
|
||||||
|
// At this point, the ack/nak is the first byte
|
||||||
|
if (message[0] == 0x41)
|
||||||
{
|
{
|
||||||
case 0x00: // General status
|
switch (message[1]) // type byte
|
||||||
//UpdatePowerFB(message[2], message[5]); // "power" can be misrepresented when the display sleeps
|
{
|
||||||
|
case 0x00: // General status
|
||||||
|
//UpdatePowerFB(message[2], message[5]); // "power" can be misrepresented when the display sleeps
|
||||||
|
|
||||||
// Handle the first power on fb when waiting for it.
|
// Handle the first power on fb when waiting for it.
|
||||||
if (IsPoweringOnIgnorePowerFb && message[2] == 0x01)
|
if (IsPoweringOnIgnorePowerFb && message[2] == 0x01)
|
||||||
IsPoweringOnIgnorePowerFb = false;
|
IsPoweringOnIgnorePowerFb = false;
|
||||||
// Ignore general-status power off messages when powering up
|
// Ignore general-status power off messages when powering up
|
||||||
if (!(IsPoweringOnIgnorePowerFb && message[2] == 0x00))
|
if (!(IsPoweringOnIgnorePowerFb && message[2] == 0x00))
|
||||||
UpdatePowerFB(message[2]);
|
UpdatePowerFB(message[2]);
|
||||||
UpdateVolumeFB(message[3]);
|
UpdateVolumeFB(message[3]);
|
||||||
UpdateMuteFb(message[4]);
|
UpdateMuteFb(message[4]);
|
||||||
UpdateInputFb(message[5]);
|
UpdateInputFb(message[5]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x11:
|
case 0x11:
|
||||||
UpdatePowerFB(message[2]);
|
UpdatePowerFB(message[2]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x12:
|
case 0x12:
|
||||||
UpdateVolumeFB(message[2]);
|
UpdateVolumeFB(message[2]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x13:
|
case 0x13:
|
||||||
UpdateMuteFb(message[2]);
|
UpdateMuteFb(message[2]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x14:
|
case 0x14:
|
||||||
UpdateInputFb(message[2]);
|
UpdateInputFb(message[2]);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
// Skip over what we've used and save the rest for next time
|
||||||
|
newBytes = newBytes.Skip(5 + msgLen).ToArray();
|
||||||
}
|
}
|
||||||
// Skip over what we've used and save the rest for next time
|
|
||||||
newBytes = newBytes.Skip(5 + msgLen).ToArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
break; // parsing will mean we can stop looking for header in loop
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Save whatever partial message is here
|
break; // parsing will mean we can stop looking for header in loop
|
||||||
IncomingBuffer = newBytes;
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// Save whatever partial message is here
|
||||||
|
IncomingBuffer = newBytes;
|
||||||
|
}
|
||||||
|
catch (Exception err)
|
||||||
|
{
|
||||||
|
Debug.Console(2, this, "Error parsing feedback: {0}", err);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@@ -256,6 +263,7 @@ namespace PepperDash.Essentials.Devices.Displays
|
|||||||
if (newVal != _PowerIsOn)
|
if (newVal != _PowerIsOn)
|
||||||
{
|
{
|
||||||
_PowerIsOn = newVal;
|
_PowerIsOn = newVal;
|
||||||
|
Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "Feedback Power State: {0}", _PowerIsOn);
|
||||||
PowerIsOnFeedback.FireUpdate();
|
PowerIsOnFeedback.FireUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -364,6 +372,8 @@ namespace PepperDash.Essentials.Devices.Displays
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public override void PowerOn()
|
public override void PowerOn()
|
||||||
{
|
{
|
||||||
|
Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "Powering On Display");
|
||||||
|
|
||||||
IsPoweringOnIgnorePowerFb = true;
|
IsPoweringOnIgnorePowerFb = true;
|
||||||
//Send(PowerOnCmd);
|
//Send(PowerOnCmd);
|
||||||
SendBytes(new byte[] { 0xAA, 0x11, 0x00, 0x01, 0x01, 0x00 });
|
SendBytes(new byte[] { 0xAA, 0x11, 0x00, 0x01, 0x01, 0x00 });
|
||||||
@@ -387,6 +397,8 @@ namespace PepperDash.Essentials.Devices.Displays
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public override void PowerOff()
|
public override void PowerOff()
|
||||||
{
|
{
|
||||||
|
Debug.Console(1, this, Debug.ErrorLogLevel.Notice, "Powering Off Display");
|
||||||
|
|
||||||
IsPoweringOnIgnorePowerFb = false;
|
IsPoweringOnIgnorePowerFb = false;
|
||||||
// If a display has unreliable-power off feedback, just override this and
|
// If a display has unreliable-power off feedback, just override this and
|
||||||
// remove this check.
|
// remove this check.
|
||||||
|
|||||||
Reference in New Issue
Block a user