mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-16 05:05:00 +00:00
added feedback for IrOutputController and added join map
This commit is contained in:
@@ -1,5 +1,7 @@
|
|||||||
using System.Collections.Generic;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using Crestron.SimplSharpPro.DeviceSupport;
|
using Crestron.SimplSharpPro.DeviceSupport;
|
||||||
|
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.Core.Bridges;
|
||||||
@@ -7,28 +9,97 @@ using PepperDash.Essentials.Core.Config;
|
|||||||
|
|
||||||
namespace PepperDash_Essentials_Core.Devices
|
namespace PepperDash_Essentials_Core.Devices
|
||||||
{
|
{
|
||||||
public class GenericIRController: EssentialsBridgeableDevice
|
public class GenericIrController: EssentialsBridgeableDevice
|
||||||
{
|
{
|
||||||
|
//data storage for bridging
|
||||||
|
private BasicTriList _trilist;
|
||||||
|
private uint _joinStart;
|
||||||
|
private string _joinMapKey;
|
||||||
|
private EiscApiAdvanced _bridge;
|
||||||
|
|
||||||
private readonly IrOutputPortController _port;
|
private readonly IrOutputPortController _port;
|
||||||
|
|
||||||
public GenericIRController(string key, string name, IrOutputPortController irPort) : base(key, name)
|
public GenericIrController(string key, string name, IrOutputPortController irPort) : base(key, name)
|
||||||
{
|
{
|
||||||
_port = irPort;
|
_port = irPort;
|
||||||
|
|
||||||
DeviceManager.AddDevice(_port);
|
DeviceManager.AddDevice(_port);
|
||||||
|
|
||||||
|
_port.DriverLoaded.OutputChange += DriverLoadedOnOutputChange;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void DriverLoadedOnOutputChange(object sender, FeedbackEventArgs args)
|
||||||
|
{
|
||||||
|
if (!args.BoolValue)
|
||||||
|
{
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
LinkToApi(_trilist, _joinStart, _joinMapKey, _bridge);
|
||||||
}
|
}
|
||||||
|
|
||||||
#region Overrides of EssentialsBridgeableDevice
|
#region Overrides of EssentialsBridgeableDevice
|
||||||
|
|
||||||
public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge)
|
public override void LinkToApi(BasicTriList trilist, uint joinStart, string joinMapKey, EiscApiAdvanced bridge)
|
||||||
{
|
{
|
||||||
throw new System.NotImplementedException();
|
//if driver isn't loaded yet, store the variables until it is loaded, then call the LinkToApi method again
|
||||||
|
if (!_port.DriverIsLoaded)
|
||||||
|
{
|
||||||
|
_trilist = trilist;
|
||||||
|
_joinStart = joinStart;
|
||||||
|
_joinMapKey = joinMapKey;
|
||||||
|
_bridge = bridge;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
var joinMap = new GenericIrControllerJoinMap(joinStart);
|
||||||
|
|
||||||
|
var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey);
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(joinMapSerialized))
|
||||||
|
joinMap = JsonConvert.DeserializeObject<GenericIrControllerJoinMap>(joinMapSerialized);
|
||||||
|
|
||||||
|
for (uint i = 0; i < _port.IrFileCommands.Length; i++)
|
||||||
|
{
|
||||||
|
joinMap.Joins.Add(_port.IrFileCommands[i],
|
||||||
|
new JoinDataComplete(new JoinData {JoinNumber = i + joinStart, JoinSpan = 1},
|
||||||
|
new JoinMetadata
|
||||||
|
{
|
||||||
|
Description = _port.IrFileCommands[i],
|
||||||
|
JoinCapabilities = eJoinCapabilities.FromSIMPL,
|
||||||
|
JoinType = eJoinType.Digital
|
||||||
|
}));
|
||||||
|
|
||||||
|
var index = i;
|
||||||
|
trilist.SetBoolSigAction(i + joinStart, (b) => Press(_port.IrFileCommands[index], b));
|
||||||
|
}
|
||||||
|
|
||||||
|
if (bridge != null)
|
||||||
|
{
|
||||||
|
bridge.AddJoinMap(Key, joinMap);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
|
public void Press(string command, bool pressRelease)
|
||||||
|
{
|
||||||
|
_port.PressRelease(command, pressRelease);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class GenericIrControllerFactory : EssentialsDeviceFactory<GenericIRController>
|
public sealed class GenericIrControllerJoinMap : JoinMapBaseAdvanced
|
||||||
|
{
|
||||||
|
public GenericIrControllerJoinMap(uint joinStart) : base(joinStart)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public class GenericIrControllerFactory : EssentialsDeviceFactory<GenericIrController>
|
||||||
{
|
{
|
||||||
public GenericIrControllerFactory()
|
public GenericIrControllerFactory()
|
||||||
{
|
{
|
||||||
@@ -42,7 +113,7 @@ namespace PepperDash_Essentials_Core.Devices
|
|||||||
|
|
||||||
var irPort = IRPortHelper.GetIrOutputPortController(dc);
|
var irPort = IRPortHelper.GetIrOutputPortController(dc);
|
||||||
|
|
||||||
return new GenericIRController(dc.Key, dc.Name, irPort);
|
return new GenericIrController(dc.Key, dc.Name, irPort);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|||||||
@@ -21,6 +21,8 @@ namespace PepperDash.Essentials.Core
|
|||||||
uint IrPortUid;
|
uint IrPortUid;
|
||||||
IROutputPort IrPort;
|
IROutputPort IrPort;
|
||||||
|
|
||||||
|
public BoolFeedback DriverLoaded { get; private set; }
|
||||||
|
|
||||||
public ushort StandardIrPulseTime { get; set; }
|
public ushort StandardIrPulseTime { get; set; }
|
||||||
public string DriverFilepath { get; private set; }
|
public string DriverFilepath { get; private set; }
|
||||||
public bool DriverIsLoaded { get; private set; }
|
public bool DriverIsLoaded { get; private set; }
|
||||||
@@ -93,13 +95,15 @@ namespace PepperDash.Essentials.Core
|
|||||||
DriverFilepath = path;
|
DriverFilepath = path;
|
||||||
StandardIrPulseTime = 200;
|
StandardIrPulseTime = 200;
|
||||||
DriverIsLoaded = true;
|
DriverIsLoaded = true;
|
||||||
|
|
||||||
|
DriverLoaded.FireUpdate();
|
||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
DriverIsLoaded = false;
|
DriverIsLoaded = false;
|
||||||
var message = string.Format("WARNING IR Driver '{0}' failed to load", path);
|
var message = string.Format("WARNING IR Driver '{0}' failed to load", path);
|
||||||
Debug.Console(0, this, message);
|
Debug.Console(0, this, Debug.ErrorLogLevel.Error, message);
|
||||||
ErrorLog.Error(message);
|
DriverLoaded.FireUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -200,6 +200,7 @@
|
|||||||
<Compile Include="Devices\DeviceFeedbackExtensions.cs" />
|
<Compile Include="Devices\DeviceFeedbackExtensions.cs" />
|
||||||
<Compile Include="Devices\EssentialsBridgeableDevice.cs" />
|
<Compile Include="Devices\EssentialsBridgeableDevice.cs" />
|
||||||
<Compile Include="Devices\EssentialsDevice.cs" />
|
<Compile Include="Devices\EssentialsDevice.cs" />
|
||||||
|
<Compile Include="Devices\GenericIRController.cs" />
|
||||||
<Compile Include="Devices\IProjectorInterfaces.cs" />
|
<Compile Include="Devices\IProjectorInterfaces.cs" />
|
||||||
<Compile Include="Devices\PC\InRoomPc.cs" />
|
<Compile Include="Devices\PC\InRoomPc.cs" />
|
||||||
<Compile Include="Devices\PC\Laptop.cs" />
|
<Compile Include="Devices\PC\Laptop.cs" />
|
||||||
|
|||||||
Reference in New Issue
Block a user