generated from PepperDash/EssentialsPluginTemplate
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
11e9065
commit a53db9e
Showing
24 changed files
with
706 additions
and
500 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
using epi_videoCodec_ciscoExtended.UserInterface.UserInterfaceExtensions; | ||
using Newtonsoft.Json; | ||
using PepperDash.Core; | ||
using PepperDash.Essentials.Core; | ||
using PepperDash.Essentials.Core.Config; | ||
using PepperDash.Essentials.Core.Devices; | ||
using PepperDash.Essentials.Devices.Common.VideoCodec.Interfaces; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace epi_videoCodec_ciscoExtended.UserInterface | ||
{ | ||
public interface ICiscoCodecUserInterface | ||
{ | ||
CiscoCodec CiscoCodec { get; } | ||
CiscoCodecUserInterfaceConfig ConfigProps { get; } | ||
IVideoCodecUiExtensionsHandler VideoCodecUiExtensionsHandler { get; } | ||
ICiscoCodecUiExtensions UiExtensions { get; } | ||
} | ||
|
||
public class CiscoCodecUserInterface : ReconfigurableDevice, ICiscoCodecUserInterface, IReconfigurableDevice | ||
{ | ||
public CiscoCodec CiscoCodec { get; } | ||
public CiscoCodecUserInterfaceConfig ConfigProps { get; } | ||
public IVideoCodecUiExtensionsHandler VideoCodecUiExtensionsHandler { get; } | ||
|
||
public ICiscoCodecUiExtensions UiExtensions { get; } | ||
|
||
public T ParseConfigProps<T>(DeviceConfig config) | ||
{ | ||
return JsonConvert.DeserializeObject<T>(config.Properties.ToString()); | ||
} | ||
|
||
public CiscoCodecUserInterface(DeviceConfig config): base(config) | ||
{ | ||
ParseConfigProps< CiscoCodecUserInterfaceConfig>(config); | ||
CiscoCodec = DeviceManager.GetDeviceForKey(ConfigProps.VideoCodecKey) as CiscoCodec; | ||
|
||
if(CiscoCodec == null) | ||
{ | ||
var msg = $"Video codec UserInterface could not find codec with key '{ConfigProps.VideoCodecKey}'."; | ||
Debug.LogMessage(new NullReferenceException(msg), msg, this); | ||
return; | ||
} | ||
|
||
UiExtensions = ConfigProps.Extensions; | ||
VideoCodecUiExtensionsHandler = new UiExtensionsHandler(this, CiscoCodec.EnqueueCommand); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
using epi_videoCodec_ciscoExtended.UserInterface.UserInterfaceExtensions; | ||
using Newtonsoft.Json; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace epi_videoCodec_ciscoExtended.UserInterface | ||
{ | ||
public class CiscoCodecUserInterfaceConfig | ||
{ | ||
[JsonProperty("extensions")] | ||
public Extensions Extensions { get; set; } | ||
|
||
[JsonProperty("videoCodecKey")] | ||
public string VideoCodecKey { get; set; } | ||
} | ||
|
||
public class CiscoCodecUserInterfaceMobileControlConfig : CiscoCodecUserInterfaceConfig | ||
{ | ||
[JsonProperty("defaultRoomKey")] | ||
public string DefaultRoomKey { get; set; } | ||
|
||
[JsonProperty("useDirectServer")] | ||
public bool UseDirectServer { get; set; } | ||
} | ||
} |
109 changes: 109 additions & 0 deletions
109
src/UserInterface/CiscoUiMobileControlTouchpanelController.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,109 @@ | ||
| ||
using PepperDash.Core; | ||
using PepperDash.Essentials.Core; | ||
using PepperDash.Essentials.Core.Config; | ||
using PepperDash.Essentials.Core.DeviceTypeInterfaces; | ||
using System; | ||
using System.Linq; | ||
using Feedback = PepperDash.Essentials.Core.Feedback; | ||
|
||
namespace epi_videoCodec_ciscoExtended.UserInterface | ||
{ | ||
public class CiscoUiMobileControlTouchpanelController : CiscoCodecUserInterface, IMobileControlTouchpanelController | ||
{ | ||
private readonly CiscoCodecUserInterfaceMobileControlConfig McConfigProps; | ||
private IMobileControlRoomMessenger _bridge; | ||
private IMobileControl mc; | ||
private string _appUrl; | ||
|
||
public StringFeedback AppUrlFeedback { get; private set; } | ||
private readonly StringFeedback QrCodeUrlFeedback; | ||
private readonly StringFeedback McServerUrlFeedback; | ||
private readonly StringFeedback UserCodeFeedback; | ||
|
||
public FeedbackCollection<Feedback> Feedbacks { get; private set; } | ||
|
||
public string DefaultRoomKey => McConfigProps.DefaultRoomKey; | ||
|
||
public bool UseDirectServer => McConfigProps.UseDirectServer; | ||
|
||
bool IMobileControlTouchpanelController.ZoomRoomController => false; | ||
|
||
public CiscoUiMobileControlTouchpanelController(DeviceConfig config) : base(config) | ||
{ | ||
McConfigProps = ParseConfigProps<CiscoCodecUserInterfaceMobileControlConfig>(config); | ||
|
||
AddPostActivationAction(SubscribeForMobileControlUpdates); | ||
|
||
AppUrlFeedback = new StringFeedback(() => _appUrl); | ||
QrCodeUrlFeedback = new StringFeedback(() => _bridge?.QrCodeUrl); | ||
McServerUrlFeedback = new StringFeedback(() => _bridge?.McServerUrl); | ||
UserCodeFeedback = new StringFeedback(() => _bridge?.UserCode); | ||
|
||
Feedbacks = new FeedbackCollection<Feedback> | ||
{ | ||
AppUrlFeedback, QrCodeUrlFeedback, McServerUrlFeedback, UserCodeFeedback | ||
}; | ||
} | ||
|
||
public override bool CustomActivate() | ||
{ | ||
mc = DeviceManager.AllDevices.OfType<IMobileControl>().FirstOrDefault(); | ||
|
||
if (mc == null) | ||
{ | ||
return base.CustomActivate(); | ||
} | ||
|
||
return base.CustomActivate(); | ||
} | ||
|
||
private void SubscribeForMobileControlUpdates() | ||
{ | ||
foreach (var dev in DeviceManager.AllDevices) | ||
{ | ||
Debug.LogMessage(Serilog.Events.LogEventLevel.Verbose, $"{dev.Key}:{dev.GetType().Name}", this); | ||
} | ||
|
||
var mcList = DeviceManager.AllDevices.OfType<IMobileControl>().ToList(); | ||
|
||
if (mcList.Count == 0) | ||
{ | ||
Debug.LogMessage(Serilog.Events.LogEventLevel.Verbose, $"No Mobile Control controller found", this); | ||
return; | ||
} | ||
|
||
// use first in list, since there should only be one. | ||
var mc = mcList[0]; | ||
|
||
var bridge = mc.GetRoomBridge(McConfigProps.DefaultRoomKey); | ||
|
||
if (bridge == null) | ||
{ | ||
Debug.LogMessage(Serilog.Events.LogEventLevel.Verbose, $"No Mobile Control bridge for {McConfigProps.DefaultRoomKey} found ", this); | ||
return; | ||
} | ||
|
||
_bridge = bridge; | ||
|
||
_bridge.UserCodeChanged += UpdateFeedbacks; | ||
_bridge.AppUrlChanged += (s, a) => { Debug.Console(0, this, "AppURL changed"); UpdateFeedbacks(s, a); }; | ||
} | ||
|
||
public void SetAppUrl(string url) | ||
{ | ||
_appUrl = url; | ||
AppUrlFeedback.FireUpdate(); | ||
} | ||
|
||
private void UpdateFeedbacks(object sender, EventArgs args) | ||
{ | ||
UpdateFeedbacks(); | ||
} | ||
|
||
private void UpdateFeedbacks() | ||
{ | ||
foreach (var feedback in Feedbacks) { feedback.FireUpdate(); } | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
using Newtonsoft.Json; | ||
using System.Collections.Generic; | ||
using System.Xml.Serialization; | ||
using epi_videoCodec_ciscoExtended.Xml; | ||
using PepperDash.Core; | ||
using Serilog.Events; | ||
using Crestron.SimplSharp; | ||
using System; | ||
using epi_videoCodec_ciscoExtended.UserInterface.UserInterfaceExtensions.Panels; | ||
|
||
namespace epi_videoCodec_ciscoExtended.UserInterface.UserInterfaceExtensions | ||
{ | ||
/// <summary> | ||
/// json config to build xml commands | ||
/// xml config for command raw data to configure UIExtensions via API | ||
/// Json attributes for config, xml attributes for command structure | ||
/// </summary> | ||
[XmlRoot("Extensions")] | ||
public class Extensions : ICiscoCodecUiExtensions | ||
{ | ||
[XmlElement("Version")] | ||
public string Version { get; set; } | ||
|
||
[XmlIgnore] | ||
[JsonProperty("configId")] //0-40 | ||
public ushort ConfigId { get; set; } | ||
|
||
[XmlElement("Panel")] | ||
[JsonProperty("panels")] | ||
public List<Panel> Panels { get; set; } | ||
//other extensions later | ||
|
||
[JsonIgnore] | ||
[XmlIgnore] | ||
public PanelsHandler PanelsHandler { get; set; } | ||
|
||
public void Initialize(IKeyed parent, Action<string> enqueueCommand) | ||
{ | ||
Debug.LogMessage(LogEventLevel.Debug, "Extensions Initialize, Panels from config: null: {0}, length: {1}", parent, Panels == null, Panels.Count); | ||
PanelsHandler = new PanelsHandler(parent, enqueueCommand, Panels); | ||
Debug.LogMessage(LogEventLevel.Debug, xCommand(), parent); | ||
enqueueCommand(xCommand()); | ||
} | ||
|
||
/// <summary> | ||
/// string literal for multiline command | ||
/// </summary> | ||
/// <returns></returns> | ||
public string xCommand() => $@"xCommand UserInterface Extensions Set ConfigId: {ConfigId} | ||
{toXmlString()} | ||
.{CiscoCodec.Delimiter}"; | ||
|
||
/// <summary> | ||
/// converts the props on this object with xml attributes to | ||
/// an xml string for the xCommand | ||
/// </summary> | ||
/// <returns></returns> | ||
string toXmlString() | ||
{ | ||
try | ||
{ | ||
return XmlConverter.SerializeObject(this); | ||
} | ||
catch (Exception ex) | ||
{ | ||
Debug.LogMessage(ex, "XML Command Serialize Failed", null); | ||
return ""; | ||
} | ||
} | ||
} | ||
} |
22 changes: 22 additions & 0 deletions
22
src/UserInterface/UserInterfaceExtensions/ICiscoCodecUiExtensions.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
using epi_videoCodec_ciscoExtended.UserInterface.UserInterfaceExtensions.Panels; | ||
using PepperDash.Core; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace epi_videoCodec_ciscoExtended.UserInterface.UserInterfaceExtensions | ||
{ | ||
public interface ICiscoCodecUiExtensions | ||
{ | ||
List<Panel> Panels { get; } | ||
//other extensions later | ||
|
||
PanelsHandler PanelsHandler { get; } | ||
|
||
void Initialize(IKeyed parent, Action<string> enqueueCommand); | ||
|
||
string xCommand(); | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/UserInterface/UserInterfaceExtensions/ICiscoCodecUiExtensionsHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace epi_videoCodec_ciscoExtended.UserInterface.UserInterfaceExtensions | ||
{ | ||
public interface ICiscoCodecUiExtensionsHandler | ||
{ | ||
/// <summary> | ||
/// Called by receive parser to parse event feedback | ||
/// </summary> | ||
/// <param name="panel"></param> | ||
void ParseStatus(Panels.CiscoCodecEvents.Panel panel); | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
src/UserInterface/UserInterfaceExtensions/Panels/ICiscoCodecUiExtensionsPanel.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
using Crestron.SimplSharpPro.DeviceSupport; | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Drawing; | ||
using System.Linq; | ||
using System.Security.Policy; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
|
||
namespace epi_videoCodec_ciscoExtended.UserInterface.UserInterfaceExtensions.Panels | ||
{ | ||
public interface ICiscoCodecUiExtensionsPanel | ||
{ | ||
/// <summary> | ||
/// click event for panel button | ||
/// </summary> | ||
event EventHandler ClickedEvent; | ||
|
||
/// <summary> | ||
/// numbered order of panels shown on cisco ui | ||
/// </summary> | ||
ushort Order { get; } | ||
|
||
/// <summary> | ||
/// Panel id string. Must be unique per config | ||
/// </summary> | ||
string PanelId { get; } | ||
|
||
/// <summary> | ||
/// For a Panel Button CallControls, ControlPanel, Hidden | ||
/// </summary> | ||
string Location { get; } | ||
|
||
/// <summary> | ||
/// Briefing, Camera, Concierge, Disc, Handset, Help, Helpdesk, | ||
/// Home, Hvac, Info, Input, Language, Laptop, Lightbulb, Media, | ||
/// Microphone, Power, Proximity, Record, Spark, Tv, Webex, | ||
/// General, Custom | ||
/// The icon on the button.Use one of the preinstalled icons from | ||
/// the list or select Custom to use a custom icon that has been | ||
/// uploaded to the device. | ||
/// </summary> | ||
string Icon { get; } | ||
|
||
/// <summary> | ||
/// The unique identifier of the uploaded custom icon. | ||
/// </summary> | ||
string IconId { get; } | ||
|
||
/// <summary> | ||
/// The new name of the custom panel, action button, or web app. | ||
/// </summary> | ||
string Name { get; } | ||
} | ||
} |
Oops, something went wrong.