mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-15 12:44:58 +00:00
Changes base class to EssentialsBridgeableDevice
* adds LinkToApi method
This commit is contained in:
@@ -4,21 +4,22 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using Crestron.SimplSharp;
|
using Crestron.SimplSharp;
|
||||||
using Crestron.SimplSharpPro;
|
using Crestron.SimplSharpPro;
|
||||||
|
using Crestron.SimplSharpPro.DeviceSupport;
|
||||||
using Crestron.SimplSharpPro.DM;
|
using Crestron.SimplSharpPro.DM;
|
||||||
using Crestron.SimplSharpPro.DM.Cards;
|
using Crestron.SimplSharpPro.DM.Cards;
|
||||||
|
using Newtonsoft.Json;
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
using PepperDash.Essentials.Core;
|
using PepperDash.Essentials.Core;
|
||||||
|
using PepperDash.Essentials.Core.Bridges;
|
||||||
using PepperDash.Essentials.DM.Config;
|
using PepperDash.Essentials.DM.Config;
|
||||||
|
using PepperDash_Essentials_Core.Devices;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.DM
|
namespace PepperDash.Essentials.DM
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Exposes the volume levels for Program, Aux1 or Aux2 outputs on a DMPS3 chassis
|
/// Exposes the volume levels for Program, Aux1 or Aux2 outputs on a DMPS3 chassis
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public class DmpsAudioOutputController : Device
|
public class DmpsAudioOutputController : EssentialsBridgeableDevice
|
||||||
{
|
{
|
||||||
Card.Dmps3OutputBase OutputCard;
|
Card.Dmps3OutputBase OutputCard;
|
||||||
|
|
||||||
@@ -100,6 +101,62 @@ namespace PepperDash.Essentials.DM
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApi bridge)
|
||||||
|
{
|
||||||
|
var joinMap = new DmpsAudioOutputControllerJoinMap();
|
||||||
|
|
||||||
|
var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey);
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(joinMapSerialized))
|
||||||
|
joinMap = JsonConvert.DeserializeObject<DmpsAudioOutputControllerJoinMap>(joinMapSerialized);
|
||||||
|
|
||||||
|
joinMap.OffsetJoinNumbers(joinStart);
|
||||||
|
|
||||||
|
Debug.Console(1, this, "Linking to Trilist '{0}'", trilist.ID.ToString("X"));
|
||||||
|
|
||||||
|
if (MasterVolumeLevel != null)
|
||||||
|
{
|
||||||
|
SetUpDmpsAudioOutputJoins(trilist, MasterVolumeLevel, joinMap.MasterVolume);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (SourceVolumeLevel != null)
|
||||||
|
{
|
||||||
|
SetUpDmpsAudioOutputJoins(trilist, SourceVolumeLevel, joinMap.SourceVolume);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Codec1VolumeLevel != null)
|
||||||
|
{
|
||||||
|
SetUpDmpsAudioOutputJoins(trilist, Codec1VolumeLevel, joinMap.Codec1Volume);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (Codec2VolumeLevel != null)
|
||||||
|
{
|
||||||
|
SetUpDmpsAudioOutputJoins(trilist, Codec2VolumeLevel, joinMap.Codec2Volume);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static void SetUpDmpsAudioOutputJoins(BasicTriList trilist, DmpsAudioOutput output, uint joinStart)
|
||||||
|
{
|
||||||
|
var volumeLevelJoin = joinStart;
|
||||||
|
var muteOnJoin = joinStart;
|
||||||
|
var muteOffJoin = joinStart + 1;
|
||||||
|
var volumeUpJoin = joinStart + 2;
|
||||||
|
var volumeDownJoin = joinStart + 3;
|
||||||
|
|
||||||
|
|
||||||
|
trilist.SetUShortSigAction(volumeLevelJoin, output.SetVolume);
|
||||||
|
output.VolumeLevelFeedback.LinkInputSig(trilist.UShortInput[volumeLevelJoin]);
|
||||||
|
|
||||||
|
trilist.SetSigTrueAction(muteOnJoin, output.MuteOn);
|
||||||
|
output.MuteFeedback.LinkInputSig(trilist.BooleanInput[muteOnJoin]);
|
||||||
|
trilist.SetSigTrueAction(muteOffJoin, output.MuteOff);
|
||||||
|
output.MuteFeedback.LinkComplementInputSig(trilist.BooleanInput[muteOffJoin]);
|
||||||
|
|
||||||
|
trilist.SetBoolSigAction(volumeUpJoin, output.VolumeUp);
|
||||||
|
trilist.SetBoolSigAction(volumeDownJoin, output.VolumeDown);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class DmpsAudioOutput : IBasicVolumeWithFeedback
|
public class DmpsAudioOutput : IBasicVolumeWithFeedback
|
||||||
|
|||||||
Reference in New Issue
Block a user