Skip to content

Commit

Permalink
feat: add device info parsing
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-welker committed May 1, 2023
1 parent c86659f commit 56fd681
Show file tree
Hide file tree
Showing 5 changed files with 425 additions and 384 deletions.
11 changes: 6 additions & 5 deletions src/Extensions.cs
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace epi.switcher.extron.quantum
{
Expand All @@ -11,7 +9,8 @@ internal static class Extensions
public static IEnumerable<string> TokenizeParams(this string s, char separator = ' ')
{
var inQuotes = false;
return s.Split(c => {
return s.Split(c =>
{
if (c == '\"')
inQuotes = !inQuotes;
return !inQuotes && c == separator;
Expand All @@ -21,7 +20,7 @@ public static IEnumerable<string> TokenizeParams(this string s, char separator =
public static IEnumerable<string> Split(this string s, Func<char, bool> controller)
{
var n = 0;
for(var c = 0; c < s.Length; c++)
for (var c = 0; c < s.Length; c++)
{
if (!controller(s[c])) continue;
yield return s.Substring(n, c - n);
Expand All @@ -37,6 +36,8 @@ public static IEnumerable<string> Split(this string s, Func<char, bool> controll
public static string Next(this IEnumerator<string> enumerator) => enumerator.MoveNext() ? enumerator.Current.EmptyIfNull() : string.Empty;

public static bool NextEquals(this IEnumerator<string> enumerator, string other, StringComparison comparison) => enumerator.Next().Equals(other, comparison);


public static bool NextContains(this IEnumerator<string> enumerator, string other) => enumerator.Next().Contains(other);

}
}
284 changes: 142 additions & 142 deletions src/ExtronQuantumConfig.cs
Original file line number Diff line number Diff line change
@@ -1,112 +1,112 @@
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json;
using PepperDash.Essentials.Core;
using System.Collections.Generic;

namespace EssentialsPluginTemplate
namespace epi.switcher.extron.quantum
{
/// <summary>
/// Plugin device configuration object
/// </summary>
/// <remarks>
/// Rename the class to match the device plugin being created
/// </remarks>
/// <example>
/// "EssentialsPluginConfigObjectTemplate" renamed to "SamsungMdcConfig"
/// </example>
[ConfigSnippet("\"properties\":{\"control\":{}")]
public class ExtronQuantumConfig
{
/// <summary>
/// Plugin device configuration object
/// </summary>
/// <remarks>
/// Rename the class to match the device plugin being created
/// </remarks>
/// <example>
/// "EssentialsPluginConfigObjectTemplate" renamed to "SamsungMdcConfig"
/// </example>
[ConfigSnippet("\"properties\":{\"control\":{}")]
public class ExtronQuantumConfig
{

[JsonProperty("control")]
public EssentialsControlPropertiesConfig Control { get; set; }
[JsonProperty("control")]
public EssentialsControlPropertiesConfig Control { get; set; }

/// <summary>
/// Serializes the poll time value
/// </summary>
/// <remarks>
/// This is an exmaple device plugin property. This should be modified or deleted as needed for the plugin being built.
/// </remarks>
/// <value>
/// PollTimeMs property gets/sets the value as a long
/// </value>
/// <example>
/// <code>
/// "properties": {
/// "polltimeMs": 30000
/// }
/// </code>
/// </example>
[JsonProperty("pollTimeMs")]
public long PollTimeMs { get; set; }
/// <summary>
/// Serializes the poll time value
/// </summary>
/// <remarks>
/// This is an exmaple device plugin property. This should be modified or deleted as needed for the plugin being built.
/// </remarks>
/// <value>
/// PollTimeMs property gets/sets the value as a long
/// </value>
/// <example>
/// <code>
/// "properties": {
/// "polltimeMs": 30000
/// }
/// </code>
/// </example>
[JsonProperty("pollTimeMs")]
public long PollTimeMs { get; set; }

/// <summary>
/// Serializes the warning timeout value
/// </summary>
/// <remarks>
/// This is an exmaple device plugin property. This should be modified or deleted as needed for the plugin being built.
/// </remarks>
/// <value>
/// WarningTimeoutMs property gets/sets the value as a long
/// </value>
/// <example>
/// <code>
/// "properties": {
/// "warningTimeoutMs": 180000
/// }
/// </code>
/// </example>
[JsonProperty("warningTimeoutMs")]
public long WarningTimeoutMs { get; set; }
/// <summary>
/// Serializes the warning timeout value
/// </summary>
/// <remarks>
/// This is an exmaple device plugin property. This should be modified or deleted as needed for the plugin being built.
/// </remarks>
/// <value>
/// WarningTimeoutMs property gets/sets the value as a long
/// </value>
/// <example>
/// <code>
/// "properties": {
/// "warningTimeoutMs": 180000
/// }
/// </code>
/// </example>
[JsonProperty("warningTimeoutMs")]
public long WarningTimeoutMs { get; set; }

/// <summary>
/// Serializes the error timeout value
/// </summary>
/// /// <remarks>
/// This is an exmaple device plugin property. This should be modified or deleted as needed for the plugin being built.
/// </remarks>
/// <value>
/// ErrorTimeoutMs property gets/sets the value as a long
/// </value>
/// <example>
/// <code>
/// "properties": {
/// "errorTimeoutMs": 300000
/// }
/// </code>
/// </example>
[JsonProperty("errorTimeoutMs")]
public long ErrorTimeoutMs { get; set; }
/// <summary>
/// Serializes the error timeout value
/// </summary>
/// /// <remarks>
/// This is an exmaple device plugin property. This should be modified or deleted as needed for the plugin being built.
/// </remarks>
/// <value>
/// ErrorTimeoutMs property gets/sets the value as a long
/// </value>
/// <example>
/// <code>
/// "properties": {
/// "errorTimeoutMs": 300000
/// }
/// </code>
/// </example>
[JsonProperty("errorTimeoutMs")]
public long ErrorTimeoutMs { get; set; }

/// <summary>
/// Example dictionary of objects
/// </summary>
/// <remarks>
/// This is an example collection configuration object. This should be modified or deleted as needed for the plugin being built.
/// </remarks>
/// <example>
/// <code>
/// "properties": {
/// "presets": {
/// "preset1": {
/// "enabled": true,
/// "name": "Preset 1"
/// }
/// }
/// }
/// </code>
/// </example>
/// <example>
/// <code>
/// "properties": {
/// "inputNames": {
/// "input1": "Input 1",
/// "input2": "Input 2"
/// }
/// }
/// </code>
/// </example>
[JsonProperty("inputs")]
public Dictionary<string, NameValue> Inputs { get; set; }
/// <summary>
/// Example dictionary of objects
/// </summary>
/// <remarks>
/// This is an example collection configuration object. This should be modified or deleted as needed for the plugin being built.
/// </remarks>
/// <example>
/// <code>
/// "properties": {
/// "presets": {
/// "preset1": {
/// "enabled": true,
/// "name": "Preset 1"
/// }
/// }
/// }
/// </code>
/// </example>
/// <example>
/// <code>
/// "properties": {
/// "inputNames": {
/// "input1": "Input 1",
/// "input2": "Input 2"
/// }
/// }
/// </code>
/// </example>
[JsonProperty("inputs")]
public Dictionary<string, NameValue> Inputs { get; set; }

[JsonProperty("windows")]
public Dictionary<string, NameValue> Windows { get; set; }
Expand All @@ -123,49 +123,49 @@ public class ExtronQuantumConfig
/// to avoid exceptions when reading the configuration file
/// </remarks>
public ExtronQuantumConfig()
{
Inputs = new Dictionary<string, NameValue>();
{
Inputs = new Dictionary<string, NameValue>();
Windows = new Dictionary<string, NameValue>();
Presets = new Dictionary<string, string>();
}
}
}
}

/// <summary>
/// Example plugin configuration dictionary object
/// </summary>
/// <remarks>
/// This is an example collection of configuration objects. This can be modified or deleted as needed for the plugin being built.
/// </remarks>
/// <example>
/// <code>
/// "properties": {
/// "dictionary": {
/// "item1": {
/// "name": "Item 1 Name",
/// "value": "Item 1 Value"
/// }
/// }
/// }
/// </code>
/// </example>
public class NameValue
{
/// <summary>
/// Serializes collection name property
/// </summary>
/// <remarks>
/// This is an example collection of configuration objects. This can be modified or deleted as needed for the plugin being built.
/// </remarks>
[JsonProperty("name")]
public string Name { get; set; }
/// <summary>
/// Example plugin configuration dictionary object
/// </summary>
/// <remarks>
/// This is an example collection of configuration objects. This can be modified or deleted as needed for the plugin being built.
/// </remarks>
/// <example>
/// <code>
/// "properties": {
/// "dictionary": {
/// "item1": {
/// "name": "Item 1 Name",
/// "value": "Item 1 Value"
/// }
/// }
/// }
/// </code>
/// </example>
public class NameValue
{
/// <summary>
/// Serializes collection name property
/// </summary>
/// <remarks>
/// This is an example collection of configuration objects. This can be modified or deleted as needed for the plugin being built.
/// </remarks>
[JsonProperty("name")]
public string Name { get; set; }

/// <summary>
/// Serializes collection value property
/// </summary>
/// <remarks>
/// This is an example collection of configuration objects. This can be modified or deleted as needed for the plugin being built.
/// </remarks>
[JsonProperty("value")]
public uint Value { get; set; }
}
/// <summary>
/// Serializes collection value property
/// </summary>
/// <remarks>
/// This is an example collection of configuration objects. This can be modified or deleted as needed for the plugin being built.
/// </remarks>
[JsonProperty("value")]
public uint Value { get; set; }
}
}
Loading

0 comments on commit 56fd681

Please sign in to comment.