mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-15 20:54:55 +00:00
fixes new interface property
This commit is contained in:
@@ -1,83 +1,83 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
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.DeviceSupport;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using PepperDash.Core;
|
using PepperDash.Core;
|
||||||
using PepperDash.Essentials.Core.Bridges;
|
using PepperDash.Essentials.Core.Bridges;
|
||||||
|
|
||||||
namespace PepperDash.Essentials.Core.Lighting
|
namespace PepperDash.Essentials.Core.Lighting
|
||||||
{
|
{
|
||||||
public abstract class LightingBase : EssentialsBridgeableDevice, ILightingScenes
|
public abstract class LightingBase : EssentialsBridgeableDevice, ILightingScenes
|
||||||
{
|
{
|
||||||
#region ILightingScenes Members
|
#region ILightingScenes Members
|
||||||
|
|
||||||
public event EventHandler<LightingSceneChangeEventArgs> LightingSceneChange;
|
public event EventHandler<LightingSceneChangeEventArgs> LightingSceneChange;
|
||||||
|
|
||||||
public List<LightingScene> LightingScenes { get; protected set; }
|
public List<LightingScene> LightingScenes { get; protected set; }
|
||||||
|
|
||||||
public LightingScene CurrentLightingScene { get; protected set; }
|
public LightingScene CurrentLightingScene { get; protected set; }
|
||||||
|
|
||||||
public IntFeedback CurrentLightingSceneFeedback { get; protected set; }
|
public IntFeedback CurrentLightingSceneFeedback { get; protected set; }
|
||||||
|
|
||||||
#endregion
|
#endregion
|
||||||
|
|
||||||
protected LightingBase(string key, string name)
|
protected LightingBase(string key, string name)
|
||||||
: base(key, name)
|
: base(key, name)
|
||||||
{
|
|
||||||
LightingScenes = new List<LightingScene>();
|
|
||||||
|
|
||||||
CurrentLightingScene = new LightingScene();
|
|
||||||
//CurrentLightingSceneFeedback = new IntFeedback(() => { return int.Parse(this.CurrentLightingScene.ID); });
|
|
||||||
}
|
|
||||||
|
|
||||||
public abstract void SelectScene(LightingScene scene);
|
|
||||||
|
|
||||||
public void SimulateSceneSelect(string sceneName)
|
|
||||||
{
|
|
||||||
Debug.Console(1, this, "Simulating selection of scene '{0}'", sceneName);
|
|
||||||
|
|
||||||
var scene = LightingScenes.FirstOrDefault(s => s.Name.Equals(sceneName));
|
|
||||||
|
|
||||||
if (scene != null)
|
|
||||||
{
|
|
||||||
CurrentLightingScene = scene;
|
|
||||||
OnLightingSceneChange();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Sets the IsActive property on each scene and fires the LightingSceneChange event
|
|
||||||
/// </summary>
|
|
||||||
protected void OnLightingSceneChange()
|
|
||||||
{
|
|
||||||
foreach (var scene in LightingScenes)
|
|
||||||
{
|
|
||||||
if (scene == CurrentLightingScene)
|
|
||||||
scene.IsActive = true;
|
|
||||||
|
|
||||||
else
|
|
||||||
scene.IsActive = false;
|
|
||||||
}
|
|
||||||
|
|
||||||
var handler = LightingSceneChange;
|
|
||||||
if (handler != null)
|
|
||||||
{
|
|
||||||
handler(this, new LightingSceneChangeEventArgs(CurrentLightingScene));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
protected GenericLightingJoinMap LinkLightingToApi(LightingBase lightingDevice, BasicTriList trilist, uint joinStart,
|
|
||||||
string joinMapKey, EiscApiAdvanced bridge)
|
|
||||||
{
|
{
|
||||||
var joinMap = new GenericLightingJoinMap(joinStart);
|
LightingScenes = new List<LightingScene>();
|
||||||
|
|
||||||
var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey);
|
CurrentLightingScene = new LightingScene();
|
||||||
|
//CurrentLightingSceneFeedback = new IntFeedback(() => { return int.Parse(this.CurrentLightingScene.ID); });
|
||||||
if (!string.IsNullOrEmpty(joinMapSerialized))
|
}
|
||||||
|
|
||||||
|
public abstract void SelectScene(LightingScene scene);
|
||||||
|
|
||||||
|
public void SimulateSceneSelect(string sceneName)
|
||||||
|
{
|
||||||
|
Debug.Console(1, this, "Simulating selection of scene '{0}'", sceneName);
|
||||||
|
|
||||||
|
var scene = LightingScenes.FirstOrDefault(s => s.Name.Equals(sceneName));
|
||||||
|
|
||||||
|
if (scene != null)
|
||||||
|
{
|
||||||
|
CurrentLightingScene = scene;
|
||||||
|
OnLightingSceneChange();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Sets the IsActive property on each scene and fires the LightingSceneChange event
|
||||||
|
/// </summary>
|
||||||
|
protected void OnLightingSceneChange()
|
||||||
|
{
|
||||||
|
foreach (var scene in LightingScenes)
|
||||||
|
{
|
||||||
|
if (scene == CurrentLightingScene)
|
||||||
|
scene.IsActive = true;
|
||||||
|
|
||||||
|
else
|
||||||
|
scene.IsActive = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
var handler = LightingSceneChange;
|
||||||
|
if (handler != null)
|
||||||
|
{
|
||||||
|
handler(this, new LightingSceneChangeEventArgs(CurrentLightingScene));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected GenericLightingJoinMap LinkLightingToApi(LightingBase lightingDevice, BasicTriList trilist, uint joinStart,
|
||||||
|
string joinMapKey, EiscApiAdvanced bridge)
|
||||||
|
{
|
||||||
|
var joinMap = new GenericLightingJoinMap(joinStart);
|
||||||
|
|
||||||
|
var joinMapSerialized = JoinMapHelper.GetSerializedJoinMapForDevice(joinMapKey);
|
||||||
|
|
||||||
|
if (!string.IsNullOrEmpty(joinMapSerialized))
|
||||||
joinMap = JsonConvert.DeserializeObject<GenericLightingJoinMap>(joinMapSerialized);
|
joinMap = JsonConvert.DeserializeObject<GenericLightingJoinMap>(joinMapSerialized);
|
||||||
|
|
||||||
if (bridge != null)
|
if (bridge != null)
|
||||||
@@ -87,52 +87,52 @@ namespace PepperDash.Essentials.Core.Lighting
|
|||||||
else
|
else
|
||||||
{
|
{
|
||||||
Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
|
Debug.Console(0, this, "Please update config to use 'eiscapiadvanced' to get all join map features for this device.");
|
||||||
}
|
}
|
||||||
|
|
||||||
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 Lighting Type {0}", lightingDevice.GetType().Name.ToString());
|
Debug.Console(0, "Linking to Lighting Type {0}", lightingDevice.GetType().Name.ToString());
|
||||||
|
|
||||||
// GenericLighitng Actions & FeedBack
|
// GenericLighitng Actions & FeedBack
|
||||||
trilist.SetUShortSigAction(joinMap.SelectScene.JoinNumber, u => lightingDevice.SelectScene(lightingDevice.LightingScenes[u]));
|
trilist.SetUShortSigAction(joinMap.SelectScene.JoinNumber, u => lightingDevice.SelectScene(lightingDevice.LightingScenes[u]));
|
||||||
|
|
||||||
var sceneIndex = 0;
|
var sceneIndex = 0;
|
||||||
foreach (var scene in lightingDevice.LightingScenes)
|
foreach (var scene in lightingDevice.LightingScenes)
|
||||||
{
|
{
|
||||||
trilist.SetSigTrueAction((uint)(joinMap.SelectSceneDirect.JoinNumber + sceneIndex), () => lightingDevice.SelectScene(lightingDevice.LightingScenes[sceneIndex]));
|
trilist.SetSigTrueAction((uint)(joinMap.SelectSceneDirect.JoinNumber + sceneIndex), () => lightingDevice.SelectScene(lightingDevice.LightingScenes[sceneIndex]));
|
||||||
scene.IsActiveFeedback.LinkInputSig(trilist.BooleanInput[(uint)(joinMap.SelectSceneDirect.JoinNumber + sceneIndex)]);
|
scene.IsActiveFeedback.LinkInputSig(trilist.BooleanInput[(uint)(joinMap.SelectSceneDirect.JoinNumber + sceneIndex)]);
|
||||||
trilist.StringInput[(uint)(joinMap.SelectSceneDirect.JoinNumber + sceneIndex)].StringValue = scene.Name;
|
trilist.StringInput[(uint)(joinMap.SelectSceneDirect.JoinNumber + sceneIndex)].StringValue = scene.Name;
|
||||||
trilist.BooleanInput[(uint)(joinMap.ButtonVisibility.JoinNumber + sceneIndex)].BoolValue = true;
|
trilist.BooleanInput[(uint)(joinMap.ButtonVisibility.JoinNumber + sceneIndex)].BoolValue = true;
|
||||||
sceneIndex++;
|
sceneIndex++;
|
||||||
}
|
}
|
||||||
|
|
||||||
return joinMap;
|
return joinMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public class LightingScene
|
public class LightingScene
|
||||||
{
|
{
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
public string ID { get; set; }
|
public string ID { get; set; }
|
||||||
bool _IsActive;
|
bool _IsActive;
|
||||||
public bool IsActive
|
public bool IsActive
|
||||||
{
|
{
|
||||||
get
|
get
|
||||||
{
|
{
|
||||||
return _IsActive;
|
return _IsActive;
|
||||||
}
|
}
|
||||||
set
|
set
|
||||||
{
|
{
|
||||||
_IsActive = value;
|
_IsActive = value;
|
||||||
IsActiveFeedback.FireUpdate();
|
IsActiveFeedback.FireUpdate();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public BoolFeedback IsActiveFeedback { get; set; }
|
public BoolFeedback IsActiveFeedback { get; set; }
|
||||||
|
|
||||||
public LightingScene()
|
public LightingScene()
|
||||||
{
|
{
|
||||||
IsActiveFeedback = new BoolFeedback(new Func<bool>(() => IsActive));
|
IsActiveFeedback = new BoolFeedback(new Func<bool>(() => IsActive));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -31,7 +31,7 @@ namespace PepperDash.Essentials.Core.Shades
|
|||||||
public interface IShadesOpenCloseStop : IShadesOpenClose
|
public interface IShadesOpenCloseStop : IShadesOpenClose
|
||||||
{
|
{
|
||||||
void StopOrPreset();
|
void StopOrPreset();
|
||||||
string StopOrPresetButtonLabel;
|
string StopOrPresetButtonLabel { get; }
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
Reference in New Issue
Block a user