mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-15 20:54:55 +00:00
Merge pull request #144 from PepperDash/feature/update-Display-Joinmap
resolves #143 - Joinmap and Bridge updated
This commit is contained in:
@@ -7,111 +7,71 @@ using PepperDash.Essentials.Core;
|
|||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Bridges
|
namespace PepperDash.Essentials.Core.Bridges
|
||||||
{
|
{
|
||||||
public class DisplayControllerJoinMap : JoinMapBase
|
public class DisplayControllerJoinMap : JoinMapBaseAdvanced
|
||||||
{
|
{
|
||||||
#region Digitals
|
[JoinName("Name")]
|
||||||
/// <summary>
|
public JoinDataComplete Name = new JoinDataComplete(new JoinData() { JoinNumber = 1, JoinSpan = 1 },
|
||||||
/// Turns the display off and reports power off feedback
|
new JoinMetadata() { Label = "Name", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial });
|
||||||
/// </summary>
|
|
||||||
public uint PowerOff { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Turns the display on and repots power on feedback
|
|
||||||
/// </summary>
|
|
||||||
public uint PowerOn { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Indicates that the display device supports two way communication when high
|
|
||||||
/// </summary>
|
|
||||||
public uint IsTwoWayDisplay { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Increments the volume while high
|
|
||||||
/// </summary>
|
|
||||||
public uint VolumeUp { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Decrements teh volume while high
|
|
||||||
/// </summary>
|
|
||||||
public uint VolumeDown { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Toggles the mute state. Feedback is high when volume is muted
|
|
||||||
/// </summary>
|
|
||||||
public uint VolumeMute { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Range of digital joins to select inputs and report current input as feedback
|
|
||||||
/// </summary>
|
|
||||||
public uint InputSelectOffset { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Range of digital joins to report visibility for input buttons
|
|
||||||
/// </summary>
|
|
||||||
public uint ButtonVisibilityOffset { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// High if the device is online
|
|
||||||
/// </summary>
|
|
||||||
public uint IsOnline { get; set; }
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Analogs
|
[JoinName("PowerOff")]
|
||||||
/// <summary>
|
public JoinDataComplete PowerOff = new JoinDataComplete(new JoinData() { JoinNumber = 1, JoinSpan = 1 },
|
||||||
/// Analog join to set the input and report current input as feedback
|
new JoinMetadata() { Label = "Power Off", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital });
|
||||||
/// </summary>
|
|
||||||
public uint InputSelect { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Sets the volume level and reports the current level as feedback
|
|
||||||
/// </summary>
|
|
||||||
public uint VolumeLevel { get; set; }
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
#region Serials
|
[JoinName("PowerOn")]
|
||||||
/// <summary>
|
public JoinDataComplete PowerOn = new JoinDataComplete(new JoinData() { JoinNumber = 2, JoinSpan = 1 },
|
||||||
/// Reports the name of the display as defined in config as feedback
|
new JoinMetadata() { Label = "Power On", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital });
|
||||||
/// </summary>
|
|
||||||
public uint Name { get; set; }
|
|
||||||
/// <summary>
|
|
||||||
/// Range of serial joins that reports the names of the inputs as feedback
|
|
||||||
/// </summary>
|
|
||||||
public uint InputNamesOffset { get; set; }
|
|
||||||
#endregion
|
|
||||||
|
|
||||||
public DisplayControllerJoinMap()
|
[JoinName("IsTwoWayDisplay")]
|
||||||
|
public JoinDataComplete IsTwoWayDisplay = new JoinDataComplete(new JoinData() { JoinNumber = 3, JoinSpan = 1 },
|
||||||
|
new JoinMetadata() { Label = "Is Two Way Display", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital });
|
||||||
|
|
||||||
|
[JoinName("VolumeUp")]
|
||||||
|
public JoinDataComplete VolumeUp = new JoinDataComplete(new JoinData() { JoinNumber = 5, JoinSpan = 1 },
|
||||||
|
new JoinMetadata() { Label = "Volume Up", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital });
|
||||||
|
|
||||||
|
[JoinName("VolumeLevel")]
|
||||||
|
public JoinDataComplete VolumeLevel = new JoinDataComplete(new JoinData() { JoinNumber = 5, JoinSpan = 1 },
|
||||||
|
new JoinMetadata() { Label = "Volume Level", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog });
|
||||||
|
|
||||||
|
[JoinName("VolumeDown")]
|
||||||
|
public JoinDataComplete VolumeDown = new JoinDataComplete(new JoinData() { JoinNumber = 6, JoinSpan = 1 },
|
||||||
|
new JoinMetadata() { Label = "Volume Down", JoinCapabilities = eJoinCapabilities.FromSIMPL, JoinType = eJoinType.Digital });
|
||||||
|
|
||||||
|
[JoinName("VolumeMute")]
|
||||||
|
public JoinDataComplete VolumeMute = new JoinDataComplete(new JoinData() { JoinNumber = 7, JoinSpan = 1 },
|
||||||
|
new JoinMetadata() { Label = "Volume Mute", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital });
|
||||||
|
|
||||||
|
[JoinName("VolumeMuteOn")]
|
||||||
|
public JoinDataComplete VolumeMuteOn = new JoinDataComplete(new JoinData() { JoinNumber = 8, JoinSpan = 1 },
|
||||||
|
new JoinMetadata() { Label = "Volume Mute On", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital });
|
||||||
|
|
||||||
|
[JoinName("VolumeMuteOff")]
|
||||||
|
public JoinDataComplete VolumeMuteOff = new JoinDataComplete(new JoinData() { JoinNumber = 9, JoinSpan = 1 },
|
||||||
|
new JoinMetadata() { Label = "Volume Mute Off", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital });
|
||||||
|
|
||||||
|
[JoinName("InputSelectOffset")]
|
||||||
|
public JoinDataComplete InputSelectOffset = new JoinDataComplete(new JoinData() { JoinNumber = 11, JoinSpan = 10 },
|
||||||
|
new JoinMetadata() { Label = "Input Select", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Digital });
|
||||||
|
|
||||||
|
[JoinName("InputNamesOffset")]
|
||||||
|
public JoinDataComplete InputNamesOffset = new JoinDataComplete(new JoinData() { JoinNumber = 11, JoinSpan = 10 },
|
||||||
|
new JoinMetadata() { Label = "Input Names Offset", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Serial });
|
||||||
|
|
||||||
|
[JoinName("InputSelect")]
|
||||||
|
public JoinDataComplete InputSelect = new JoinDataComplete(new JoinData() { JoinNumber = 11, JoinSpan = 1 },
|
||||||
|
new JoinMetadata() { Label = "Input Select", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.Analog });
|
||||||
|
|
||||||
|
[JoinName("ButtonVisibilityOffset")]
|
||||||
|
public JoinDataComplete ButtonVisibilityOffset = new JoinDataComplete(new JoinData() { JoinNumber = 41, JoinSpan = 10 },
|
||||||
|
new JoinMetadata() { Label = "Button Visibility Offset", JoinCapabilities = eJoinCapabilities.ToFromSIMPL, JoinType = eJoinType.DigitalSerial });
|
||||||
|
|
||||||
|
[JoinName("IsOnline")]
|
||||||
|
public JoinDataComplete IsOnline = new JoinDataComplete(new JoinData() { JoinNumber = 50, JoinSpan = 1 },
|
||||||
|
new JoinMetadata() { Label = "Is Online", JoinCapabilities = eJoinCapabilities.ToSIMPL, JoinType = eJoinType.Digital });
|
||||||
|
|
||||||
|
public DisplayControllerJoinMap(uint joinStart)
|
||||||
|
: base(joinStart, typeof(CameraControllerJoinMap))
|
||||||
{
|
{
|
||||||
// Digital
|
|
||||||
IsOnline = 50;
|
|
||||||
PowerOff = 1;
|
|
||||||
PowerOn = 2;
|
|
||||||
IsTwoWayDisplay = 3;
|
|
||||||
VolumeUp = 5;
|
|
||||||
VolumeDown = 6;
|
|
||||||
VolumeMute = 7;
|
|
||||||
|
|
||||||
ButtonVisibilityOffset = 40;
|
|
||||||
InputSelectOffset = 10;
|
|
||||||
|
|
||||||
// Analog
|
|
||||||
InputSelect = 11;
|
|
||||||
VolumeLevel = 5;
|
|
||||||
|
|
||||||
// Serial
|
|
||||||
Name = 1;
|
|
||||||
InputNamesOffset = 10;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void OffsetJoinNumbers(uint joinStart)
|
|
||||||
{
|
|
||||||
var joinOffset = joinStart - 1;
|
|
||||||
|
|
||||||
IsOnline = IsOnline + joinOffset;
|
|
||||||
PowerOff = PowerOff + joinOffset;
|
|
||||||
PowerOn = PowerOn + joinOffset;
|
|
||||||
IsTwoWayDisplay = IsTwoWayDisplay + joinOffset;
|
|
||||||
ButtonVisibilityOffset = ButtonVisibilityOffset + joinOffset;
|
|
||||||
Name = Name + joinOffset;
|
|
||||||
InputNamesOffset = InputNamesOffset + joinOffset;
|
|
||||||
InputSelectOffset = InputSelectOffset + joinOffset;
|
|
||||||
|
|
||||||
InputSelect = InputSelect + joinOffset;
|
|
||||||
|
|
||||||
VolumeUp = VolumeUp + joinOffset;
|
|
||||||
VolumeDown = VolumeDown + joinOffset;
|
|
||||||
VolumeMute = VolumeMute + joinOffset;
|
|
||||||
VolumeLevel = VolumeLevel + joinOffset;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -121,24 +121,22 @@ namespace PepperDash.Essentials.Core
|
|||||||
var inputNumber = 0;
|
var inputNumber = 0;
|
||||||
var inputKeys = new List<string>();
|
var inputKeys = new List<string>();
|
||||||
|
|
||||||
var joinMap = new DisplayControllerJoinMap();
|
var joinMap = new DisplayControllerJoinMap(joinStart);
|
||||||
|
|
||||||
var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey);
|
var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey);
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(joinMapSerialized))
|
if (!string.IsNullOrEmpty(joinMapSerialized))
|
||||||
joinMap = JsonConvert.DeserializeObject<DisplayControllerJoinMap>(joinMapSerialized);
|
joinMap = JsonConvert.DeserializeObject<DisplayControllerJoinMap>(joinMapSerialized);
|
||||||
|
|
||||||
joinMap.OffsetJoinNumbers(joinStart);
|
|
||||||
|
|
||||||
Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
|
Debug.Console(1, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
|
||||||
Debug.Console(0, "Linking to Display: {0}", displayDevice.Name);
|
Debug.Console(0, "Linking to Display: {0}", displayDevice.Name);
|
||||||
|
|
||||||
trilist.StringInput[joinMap.Name].StringValue = displayDevice.Name;
|
trilist.StringInput[joinMap.Name.JoinNumber].StringValue = displayDevice.Name;
|
||||||
|
|
||||||
var commMonitor = displayDevice as ICommunicationMonitor;
|
var commMonitor = displayDevice as ICommunicationMonitor;
|
||||||
if (commMonitor != null)
|
if (commMonitor != null)
|
||||||
{
|
{
|
||||||
commMonitor.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline]);
|
commMonitor.CommunicationMonitor.IsOnlineFeedback.LinkInputSig(trilist.BooleanInput[joinMap.IsOnline.JoinNumber]);
|
||||||
}
|
}
|
||||||
|
|
||||||
var inputNumberFeedback = new IntFeedback(() => inputNumber);
|
var inputNumberFeedback = new IntFeedback(() => inputNumber);
|
||||||
@@ -148,16 +146,16 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
if (twoWayDisplay != null)
|
if (twoWayDisplay != null)
|
||||||
{
|
{
|
||||||
trilist.SetBool(joinMap.IsTwoWayDisplay, true);
|
trilist.SetBool(joinMap.IsTwoWayDisplay.JoinNumber, true);
|
||||||
|
|
||||||
twoWayDisplay.CurrentInputFeedback.OutputChange += (o, a) => Debug.Console(0, "CurrentInputFeedback_OutputChange {0}", a.StringValue);
|
twoWayDisplay.CurrentInputFeedback.OutputChange += (o, a) => Debug.Console(0, "CurrentInputFeedback_OutputChange {0}", a.StringValue);
|
||||||
|
|
||||||
|
|
||||||
inputNumberFeedback.LinkInputSig(trilist.UShortInput[joinMap.InputSelect]);
|
inputNumberFeedback.LinkInputSig(trilist.UShortInput[joinMap.InputSelect.JoinNumber]);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Power Off
|
// Power Off
|
||||||
trilist.SetSigTrueAction(joinMap.PowerOff, () =>
|
trilist.SetSigTrueAction(joinMap.PowerOff.JoinNumber, () =>
|
||||||
{
|
{
|
||||||
inputNumber = 102;
|
inputNumber = 102;
|
||||||
inputNumberFeedback.FireUpdate();
|
inputNumberFeedback.FireUpdate();
|
||||||
@@ -179,10 +177,10 @@ namespace PepperDash.Essentials.Core
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
displayDevice.PowerIsOnFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.PowerOff]);
|
displayDevice.PowerIsOnFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.PowerOff.JoinNumber]);
|
||||||
|
|
||||||
// PowerOn
|
// PowerOn
|
||||||
trilist.SetSigTrueAction(joinMap.PowerOn, () =>
|
trilist.SetSigTrueAction(joinMap.PowerOn.JoinNumber, () =>
|
||||||
{
|
{
|
||||||
inputNumber = 0;
|
inputNumber = 0;
|
||||||
inputNumberFeedback.FireUpdate();
|
inputNumberFeedback.FireUpdate();
|
||||||
@@ -190,21 +188,27 @@ namespace PepperDash.Essentials.Core
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
displayDevice.PowerIsOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.PowerOn]);
|
displayDevice.PowerIsOnFeedback.LinkInputSig(trilist.BooleanInput[joinMap.PowerOn.JoinNumber]);
|
||||||
|
|
||||||
var count = 1;
|
for (int i = 0; i < displayDevice.InputPorts.Count; i++)
|
||||||
foreach (var input in displayDevice.InputPorts)
|
|
||||||
{
|
{
|
||||||
inputKeys.Add(input.Key);
|
if (i < joinMap.InputNamesOffset.JoinSpan)
|
||||||
var tempKey = inputKeys.ElementAt(count - 1);
|
{
|
||||||
trilist.SetSigTrueAction((ushort)(joinMap.InputSelectOffset + count), () => displayDevice.ExecuteSwitch(displayDevice.InputPorts[tempKey].Selector));
|
inputKeys.Add(displayDevice.InputPorts[i].Key);
|
||||||
Debug.Console(2, displayDevice, "Setting Input Select Action on Digital Join {0} to Input: {1}", joinMap.InputSelectOffset + count, displayDevice.InputPorts[tempKey].Key.ToString());
|
var tempKey = inputKeys.ElementAt(i);
|
||||||
trilist.StringInput[(ushort)(joinMap.InputNamesOffset + count)].StringValue = input.Key.ToString();
|
trilist.SetSigTrueAction((ushort)(joinMap.InputSelectOffset.JoinNumber + i),
|
||||||
count++;
|
() => displayDevice.ExecuteSwitch(displayDevice.InputPorts[tempKey].Selector));
|
||||||
|
Debug.Console(2, displayDevice, "Setting Input Select Action on Digital Join {0} to Input: {1}",
|
||||||
|
joinMap.InputSelectOffset.JoinNumber + i, displayDevice.InputPorts[tempKey].Key.ToString());
|
||||||
|
trilist.StringInput[(ushort)(joinMap.InputNamesOffset.JoinNumber + i)].StringValue = displayDevice.InputPorts[i].Key.ToString();
|
||||||
|
}
|
||||||
|
else
|
||||||
|
Debug.Console(0, displayDevice, Debug.ErrorLogLevel.Warning, "Device has {0} inputs. The Join Map allows up to {1} inputs. Discarding inputs {2} - {3} from bridge.",
|
||||||
|
displayDevice.InputPorts.Count, joinMap.InputNamesOffset.JoinSpan, i + 1, displayDevice.InputPorts.Count);
|
||||||
}
|
}
|
||||||
|
|
||||||
Debug.Console(2, displayDevice, "Setting Input Select Action on Analog Join {0}", joinMap.InputSelect);
|
Debug.Console(2, displayDevice, "Setting Input Select Action on Analog Join {0}", joinMap.InputSelect);
|
||||||
trilist.SetUShortSigAction(joinMap.InputSelect, (a) =>
|
trilist.SetUShortSigAction(joinMap.InputSelect.JoinNumber, (a) =>
|
||||||
{
|
{
|
||||||
if (a == 0)
|
if (a == 0)
|
||||||
{
|
{
|
||||||
@@ -229,17 +233,22 @@ namespace PepperDash.Essentials.Core
|
|||||||
var volumeDisplay = displayDevice as IBasicVolumeControls;
|
var volumeDisplay = displayDevice as IBasicVolumeControls;
|
||||||
if (volumeDisplay == null) return;
|
if (volumeDisplay == null) return;
|
||||||
|
|
||||||
trilist.SetBoolSigAction(joinMap.VolumeUp, volumeDisplay.VolumeUp);
|
trilist.SetBoolSigAction(joinMap.VolumeUp.JoinNumber, volumeDisplay.VolumeUp);
|
||||||
trilist.SetBoolSigAction(joinMap.VolumeDown, volumeDisplay.VolumeDown);
|
trilist.SetBoolSigAction(joinMap.VolumeDown.JoinNumber, volumeDisplay.VolumeDown);
|
||||||
trilist.SetSigTrueAction(joinMap.VolumeMute, volumeDisplay.MuteToggle);
|
trilist.SetSigTrueAction(joinMap.VolumeMute.JoinNumber, volumeDisplay.MuteToggle);
|
||||||
|
|
||||||
var volumeDisplayWithFeedback = volumeDisplay as IBasicVolumeWithFeedback;
|
var volumeDisplayWithFeedback = volumeDisplay as IBasicVolumeWithFeedback;
|
||||||
|
|
||||||
if (volumeDisplayWithFeedback == null) return;
|
if (volumeDisplayWithFeedback == null) return;
|
||||||
|
trilist.SetSigTrueAction(joinMap.VolumeMuteOn.JoinNumber, volumeDisplayWithFeedback.MuteOn);
|
||||||
|
trilist.SetSigTrueAction(joinMap.VolumeMuteOff.JoinNumber, volumeDisplayWithFeedback.MuteOff);
|
||||||
|
|
||||||
trilist.SetUShortSigAction(joinMap.VolumeLevel, volumeDisplayWithFeedback.SetVolume);
|
|
||||||
volumeDisplayWithFeedback.VolumeLevelFeedback.LinkInputSig(trilist.UShortInput[joinMap.VolumeLevel]);
|
trilist.SetUShortSigAction(joinMap.VolumeLevel.JoinNumber, volumeDisplayWithFeedback.SetVolume);
|
||||||
volumeDisplayWithFeedback.MuteFeedback.LinkInputSig(trilist.BooleanInput[joinMap.VolumeMute]);
|
volumeDisplayWithFeedback.VolumeLevelFeedback.LinkInputSig(trilist.UShortInput[joinMap.VolumeLevel.JoinNumber]);
|
||||||
|
volumeDisplayWithFeedback.MuteFeedback.LinkInputSig(trilist.BooleanInput[joinMap.VolumeMute.JoinNumber]);
|
||||||
|
volumeDisplayWithFeedback.MuteFeedback.LinkInputSig(trilist.BooleanInput[joinMap.VolumeMuteOn.JoinNumber]);
|
||||||
|
volumeDisplayWithFeedback.MuteFeedback.LinkComplementInputSig(trilist.BooleanInput[joinMap.VolumeMuteOff.JoinNumber]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user