mirror of
https://github.com/PepperDash/Essentials.git
synced 2026-02-15 20:54:55 +00:00
Merge pull request #1067 from PepperDash/feature/joinmapReportingImprovements
Cleanup getjoinmap console return
This commit is contained in:
@@ -1,9 +1,7 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Data;
|
|
||||||
using System.Globalization;
|
using System.Globalization;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Runtime.InteropServices;
|
|
||||||
using System.Text;
|
using System.Text;
|
||||||
using Crestron.SimplSharp.Reflection;
|
using Crestron.SimplSharp.Reflection;
|
||||||
using Crestron.SimplSharp.CrestronIO;
|
using Crestron.SimplSharp.CrestronIO;
|
||||||
@@ -236,25 +234,45 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public void PrintJoinMapInfo()
|
public void PrintJoinMapInfo()
|
||||||
{
|
{
|
||||||
Debug.Console(0, "{0}:\n", GetType().Name);
|
var sb = JoinmapStringBuilder();
|
||||||
|
|
||||||
|
CrestronConsole.ConsoleCommandResponse(sb.ToString());
|
||||||
|
}
|
||||||
|
|
||||||
|
private StringBuilder JoinmapStringBuilder()
|
||||||
|
{
|
||||||
|
var sb = new StringBuilder();
|
||||||
|
|
||||||
// Get the joins of each type and print them
|
// Get the joins of each type and print them
|
||||||
Debug.Console(0, "Digitals:");
|
sb.AppendLine(String.Format("# {0}", GetType().Name));
|
||||||
var digitals = Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Digital) == eJoinType.Digital).ToDictionary(j => j.Key, j => j.Value);
|
sb.AppendLine();
|
||||||
Debug.Console(2, "Found {0} Digital Joins", digitals.Count);
|
sb.AppendLine("## Digitals");
|
||||||
PrintJoinList(GetSortedJoins(digitals));
|
sb.AppendLine();
|
||||||
|
// Get the joins of each type and print them
|
||||||
|
var digitals =
|
||||||
|
Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Digital) == eJoinType.Digital)
|
||||||
|
.ToDictionary(j => j.Key, j => j.Value);
|
||||||
|
var digitalSb = AppendJoinList(GetSortedJoins(digitals));
|
||||||
|
digitalSb.AppendLine("## Analogs");
|
||||||
|
digitalSb.AppendLine();
|
||||||
|
|
||||||
Debug.Console(0, "Analogs:");
|
var analogs =
|
||||||
var analogs = Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Analog) == eJoinType.Analog).ToDictionary(j => j.Key, j => j.Value);
|
Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Analog) == eJoinType.Analog)
|
||||||
Debug.Console(2, "Found {0} Analog Joins", analogs.Count);
|
.ToDictionary(j => j.Key, j => j.Value);
|
||||||
PrintJoinList(GetSortedJoins(analogs));
|
var analogSb = AppendJoinList(GetSortedJoins(analogs));
|
||||||
|
analogSb.AppendLine("## Serials");
|
||||||
|
analogSb.AppendLine();
|
||||||
|
|
||||||
Debug.Console(0, "Serials:");
|
var serials =
|
||||||
var serials = Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Serial) == eJoinType.Serial).ToDictionary(j => j.Key, j => j.Value);
|
Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Serial) == eJoinType.Serial)
|
||||||
Debug.Console(2, "Found {0} Serial Joins", serials.Count);
|
.ToDictionary(j => j.Key, j => j.Value);
|
||||||
PrintJoinList(GetSortedJoins(serials));
|
var serialSb = AppendJoinList(GetSortedJoins(serials));
|
||||||
|
|
||||||
|
sb.EnsureCapacity(sb.Length + digitalSb.Length + analogSb.Length + serialSb.Length);
|
||||||
|
sb.Append(digitalSb).Append(analogSb).Append(serialSb);
|
||||||
|
return sb;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Prints the join information to console
|
/// Prints the join information to console
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@@ -264,35 +282,9 @@ namespace PepperDash.Essentials.Core
|
|||||||
|
|
||||||
Debug.Console(0, "{0}:\n", pluginType);
|
Debug.Console(0, "{0}:\n", pluginType);
|
||||||
|
|
||||||
var sb = new StringBuilder();
|
|
||||||
|
|
||||||
sb.AppendLine(String.Format("# {0}", GetType().Name));
|
|
||||||
sb.AppendLine(String.Format("Generated from '{0}' on bridge '{1}'", deviceKey, bridgeKey));
|
|
||||||
sb.AppendLine();
|
|
||||||
sb.AppendLine("## Digitals");
|
|
||||||
// Get the joins of each type and print them
|
|
||||||
var digitals = Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Digital) == eJoinType.Digital).ToDictionary(j => j.Key, j => j.Value);
|
|
||||||
Debug.Console(2, "Found {0} Digital Joins", digitals.Count);
|
|
||||||
var digitalSb = AppendJoinList(GetSortedJoins(digitals));
|
|
||||||
digitalSb.AppendLine("## Analogs");
|
|
||||||
digitalSb.AppendLine();
|
|
||||||
|
|
||||||
Debug.Console(0, "Analogs:");
|
WriteJoinmapMarkdown(JoinmapStringBuilder(), pluginType, bridgeKey, deviceKey);
|
||||||
var analogs = Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Analog) == eJoinType.Analog).ToDictionary(j => j.Key, j => j.Value);
|
|
||||||
Debug.Console(2, "Found {0} Analog Joins", analogs.Count);
|
|
||||||
var analogSb = AppendJoinList(GetSortedJoins(analogs));
|
|
||||||
analogSb.AppendLine("## Serials");
|
|
||||||
analogSb.AppendLine();
|
|
||||||
|
|
||||||
Debug.Console(0, "Serials:");
|
|
||||||
var serials = Joins.Where(j => (j.Value.Metadata.JoinType & eJoinType.Serial) == eJoinType.Serial).ToDictionary(j => j.Key, j => j.Value);
|
|
||||||
Debug.Console(2, "Found {0} Serial Joins", serials.Count);
|
|
||||||
var serialSb = AppendJoinList(GetSortedJoins(serials));
|
|
||||||
|
|
||||||
sb.EnsureCapacity(sb.Length + digitalSb.Length + analogSb.Length + serialSb.Length);
|
|
||||||
sb.Append(digitalSb).Append(analogSb).Append(serialSb);
|
|
||||||
|
|
||||||
WriteJoinmapMarkdown(sb, pluginType, bridgeKey, deviceKey);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -313,7 +305,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="joins"></param>
|
/// <param name="joins"></param>
|
||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
List<KeyValuePair<string, JoinDataComplete>> GetSortedJoins(Dictionary<string, JoinDataComplete> joins)
|
static List<KeyValuePair<string, JoinDataComplete>> GetSortedJoins(Dictionary<string, JoinDataComplete> joins)
|
||||||
{
|
{
|
||||||
var sortedJoins = joins.ToList();
|
var sortedJoins = joins.ToList();
|
||||||
|
|
||||||
@@ -322,7 +314,7 @@ namespace PepperDash.Essentials.Core
|
|||||||
return sortedJoins;
|
return sortedJoins;
|
||||||
}
|
}
|
||||||
|
|
||||||
void PrintJoinList(List<KeyValuePair<string, JoinDataComplete>> joins)
|
void PrintJoinList(IEnumerable<KeyValuePair<string, JoinDataComplete>> joins)
|
||||||
{
|
{
|
||||||
foreach (var join in joins)
|
foreach (var join in joins)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user