Compare commits

..

4 Commits

Author SHA1 Message Date
Neil Dorin
f0ae0094dc Adds optional enable property to partition sensor config and defaults to enable 2023-07-19 09:50:48 -06:00
Trevor Payne
fcd4b5d772 Merge pull request #1118 from PepperDash/hotfix/AirMediaRegistration
Fix Airmedia Registration Issue
2023-07-12 12:52:56 -05:00
Trevor Payne
c3ba6d5c28 fix: fix issue where the customactivate for the base class was beig suppressed in airmedia controllers 2023-07-12 12:27:38 -05:00
Andrew Welker
acd3bad1f2 Merge pull request #1108 from PepperDash/release/1.14.0
1.14.0
2023-06-07 09:54:34 -06:00
4 changed files with 30 additions and 118 deletions

View File

@@ -2,7 +2,6 @@
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using Crestron.SimplSharp;
namespace PepperDash.Essentials.Core
@@ -21,109 +20,5 @@ namespace PepperDash.Essentials.Core
{
return string.IsNullOrEmpty(s) ? newString : s;
}
/// <summary>
/// Formats string to meet specified parameters
/// </summary>
/// <param name="inputString">string to be formatted</param>
/// <param name="outputStringLength">length of output string</param>
/// <param name="padCharacter">character to pad string with to reach desired output length</param>
/// <param name="justification">Justification of input string with regards to the overall string</param>
/// <param name="separateInput">If true, seperate input string from pad characters with a single space</param>
/// <returns></returns>
public static string AutoPadAndJustify(this string inputString, int outputStringLength, char padCharacter,
AutoPadJustification justification, bool separateInput)
{
var returnString = inputString;
var justifiedAndSeparateLength = (
separateInput
? (justification == AutoPadJustification.Center ? 2 : 1)
: 0);
if (outputStringLength <= inputString.Length + justifiedAndSeparateLength) return returnString;
var fillLength = outputStringLength - inputString.Length - justifiedAndSeparateLength;
switch (justification)
{
case (AutoPadJustification.Left):
{
returnString =
inputString +
new string(' ', separateInput ? 1 : 0) +
new string(padCharacter, fillLength);
break;
}
case (AutoPadJustification.Right):
{
returnString =
new string(padCharacter, fillLength) +
new string(' ', separateInput ? 1 : 0) +
inputString;
break;
}
case (AutoPadJustification.Center):
{
var halfFill = fillLength / 2;
returnString =
new string(padCharacter, halfFill + (fillLength % 2)) +
new string(' ', separateInput ? 1 : 0) +
inputString +
new string(' ', separateInput ? 1 : 0) +
new string(padCharacter, halfFill);
break;
}
}
return returnString;
}
/// <summary>
/// Formats string to meet specified parameters
/// </summary>
/// <param name="inputString">string to be formatted</param>
/// <param name="options">String formatting options</param>
/// <returns></returns>
public static string AutoPadAndJustify(this string inputString, AutoPadJustificationOptions options)
{
if (options == null)
return inputString;
var outputStringLength = options.OutputStringLength;
var padCharacter = options.PadCharacter;
var justification = options.Justification;
var separateInput = options.SeparateInput;
return AutoPadAndJustify(inputString, outputStringLength, padCharacter, justification,
separateInput);
}
}
public enum AutoPadJustification
{
Center,
Left,
Right
}
/// <summary>
/// Options for setting AutoPadJustification
/// </summary>
public class AutoPadJustificationOptions
{
/// <summary>
/// Text Justification for the string, relative to the length
/// </summary>
public AutoPadJustification Justification { get; set; }
/// <summary>
/// If true, separate input string from pad characters by a single ' ' character
/// </summary>
public bool SeparateInput { get; set; }
/// <summary>
/// Pad character to be inserted
/// </summary>
public char PadCharacter { get; set; }
/// <summary>
/// Total length of the output string
/// </summary>
public int OutputStringLength { get; set; }
}
}

View File

@@ -85,18 +85,32 @@ namespace PepperDash.Essentials.Core
{
if (_partitionSensor.IsOnline == false) return;
Debug.Console(1, this, "Attempting to apply settings to sensor from config");
// Default to enable
_partitionSensor.Enable.BoolValue = true;
if (PropertiesConfig.Sensitivity != null)
{
Debug.Console(1, this, "Sensitivity found, attempting to set value '{0}' from config",
PropertiesConfig.Sensitivity);
_partitionSensor.Sensitivity.UShortValue = (ushort) PropertiesConfig.Sensitivity;
}
else
{
Debug.Console(1, this, "Sensitivity null, no value specified in config");
}
Debug.Console(1, this, "Attempting to apply settings to sensor from config");
if (PropertiesConfig.Sensitivity != null)
{
Debug.Console(1, this, "Sensitivity found, attempting to set value '{0}' from config",
PropertiesConfig.Sensitivity);
_partitionSensor.Sensitivity.UShortValue = (ushort)PropertiesConfig.Sensitivity;
}
else
{
Debug.Console(1, this, "Sensitivity null, no value specified in config");
}
if (PropertiesConfig.Enable != null)
{
Debug.Console(1, this, "Enable found, attempting to set value '{0}' from config",
PropertiesConfig.Enable);
_partitionSensor.Enable.BoolValue = (bool)PropertiesConfig.Enable;
}
else
{
Debug.Console(1, this, "Enable null, no value specified in config");
}
}

View File

@@ -16,6 +16,9 @@ namespace PepperDash_Essentials_Core.PartitionSensor
/// The sensitivity range shall be between 1(lowest) to 10 (highest).
/// </remarks>
[JsonProperty("sensitivity")]
public ushort? Sensitivity { get; set; }
public ushort? Sensitivity { get; set; }
[JsonProperty("enable")]
public bool? Enable { get; set; }
}
}

View File

@@ -129,7 +129,7 @@ namespace PepperDash.Essentials.DM.AirMedia
else
AirMedia.DisplayControl.DisableAutomaticRouting();
return true;
return base.CustomActivate();
}
public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge)