Skip to content

Commit

Permalink
Merge pull request #34 from arup-group/dev
Browse files Browse the repository at this point in the history
Refreshed the UI to be more responsive for the user (and easier to maintain and extend in the future for the developer) including better display of current state and progress
Fixed some bugs related to units other than metres
Revamped the application's internal data cache to make receiving from streams faster, particularly for models with tens of thousands of elements
Included calls to enable some telemetry
Improved logging of data to the technical log for future problem diagnosis and solving
The command line interface (headless) version of this app is affected by the UI change; it has been partly tested but might still need further work in order to replace the previous version
The progress bar currently doesn't work perfectly when sending/receiving in continuous mode
  • Loading branch information
nic-burgers-arup committed Jun 9, 2021
2 parents e6fa69c + 7f8c5be commit 8e49d1c
Show file tree
Hide file tree
Showing 126 changed files with 7,120 additions and 3,898 deletions.
Binary file removed Resource/SpeckleCore.dll
Binary file not shown.
30 changes: 20 additions & 10 deletions SpeckleGSA.sln
Expand Up @@ -5,8 +5,6 @@ VisualStudioVersion = 16.0.29411.108
MinimumVisualStudioVersion = 10.0.40219.1
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SpeckleGSA", "SpeckleGSA\SpeckleGSA.csproj", "{6D8CA3AD-E530-4CDA-AF79-9715A7583F4F}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SpeckleGSAUI", "SpeckleGSAUI\SpeckleGSAUI.csproj", "{74BD53B7-5588-4CBC-86A3-EFBBC99DB7ED}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SpeckleGSAProxy", "SpeckleGSAProxy\SpeckleGSAProxy.csproj", "{88AE85C3-1966-4B71-8C91-242C80DCE6D4}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SpeckleGSAInterfaces", "SpeckleGSAInterfaces\SpeckleGSAInterfaces.csproj", "{5CA1BFFE-F623-4677-8412-9D20F0017523}"
Expand All @@ -20,6 +18,10 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SpeckleUtil", "SpeckleUtil\
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SpeckleInterface", "SpeckleInterface\SpeckleInterface.csproj", "{CA38DD0E-4A12-4B5B-9544-62B6FFC0BB25}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SpeckleGSAUI", "SpeckleGSAUI\SpeckleGSAUI.csproj", "{401876C8-F543-406A-B071-A3A15E008082}"
EndProject
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SpeckleGSAUI.Test", "SpeckleGSAUI.Test\SpeckleGSAUI.Test.csproj", "{6A46D120-26C8-4F97-9390-B99A3855105F}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Expand All @@ -36,14 +38,6 @@ Global
{6D8CA3AD-E530-4CDA-AF79-9715A7583F4F}.Release|Any CPU.Build.0 = Release|Any CPU
{6D8CA3AD-E530-4CDA-AF79-9715A7583F4F}.Release|x64.ActiveCfg = Release|x64
{6D8CA3AD-E530-4CDA-AF79-9715A7583F4F}.Release|x64.Build.0 = Release|x64
{74BD53B7-5588-4CBC-86A3-EFBBC99DB7ED}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{74BD53B7-5588-4CBC-86A3-EFBBC99DB7ED}.Debug|Any CPU.Build.0 = Debug|Any CPU
{74BD53B7-5588-4CBC-86A3-EFBBC99DB7ED}.Debug|x64.ActiveCfg = Debug|x64
{74BD53B7-5588-4CBC-86A3-EFBBC99DB7ED}.Debug|x64.Build.0 = Debug|x64
{74BD53B7-5588-4CBC-86A3-EFBBC99DB7ED}.Release|Any CPU.ActiveCfg = Release|Any CPU
{74BD53B7-5588-4CBC-86A3-EFBBC99DB7ED}.Release|Any CPU.Build.0 = Release|Any CPU
{74BD53B7-5588-4CBC-86A3-EFBBC99DB7ED}.Release|x64.ActiveCfg = Release|x64
{74BD53B7-5588-4CBC-86A3-EFBBC99DB7ED}.Release|x64.Build.0 = Release|x64
{88AE85C3-1966-4B71-8C91-242C80DCE6D4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{88AE85C3-1966-4B71-8C91-242C80DCE6D4}.Debug|Any CPU.Build.0 = Debug|Any CPU
{88AE85C3-1966-4B71-8C91-242C80DCE6D4}.Debug|x64.ActiveCfg = Debug|Any CPU
Expand Down Expand Up @@ -84,6 +78,22 @@ Global
{CA38DD0E-4A12-4B5B-9544-62B6FFC0BB25}.Release|Any CPU.Build.0 = Release|Any CPU
{CA38DD0E-4A12-4B5B-9544-62B6FFC0BB25}.Release|x64.ActiveCfg = Release|Any CPU
{CA38DD0E-4A12-4B5B-9544-62B6FFC0BB25}.Release|x64.Build.0 = Release|Any CPU
{401876C8-F543-406A-B071-A3A15E008082}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{401876C8-F543-406A-B071-A3A15E008082}.Debug|Any CPU.Build.0 = Debug|Any CPU
{401876C8-F543-406A-B071-A3A15E008082}.Debug|x64.ActiveCfg = Debug|Any CPU
{401876C8-F543-406A-B071-A3A15E008082}.Debug|x64.Build.0 = Debug|Any CPU
{401876C8-F543-406A-B071-A3A15E008082}.Release|Any CPU.ActiveCfg = Release|Any CPU
{401876C8-F543-406A-B071-A3A15E008082}.Release|Any CPU.Build.0 = Release|Any CPU
{401876C8-F543-406A-B071-A3A15E008082}.Release|x64.ActiveCfg = Release|Any CPU
{401876C8-F543-406A-B071-A3A15E008082}.Release|x64.Build.0 = Release|Any CPU
{6A46D120-26C8-4F97-9390-B99A3855105F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{6A46D120-26C8-4F97-9390-B99A3855105F}.Debug|Any CPU.Build.0 = Debug|Any CPU
{6A46D120-26C8-4F97-9390-B99A3855105F}.Debug|x64.ActiveCfg = Debug|Any CPU
{6A46D120-26C8-4F97-9390-B99A3855105F}.Debug|x64.Build.0 = Debug|Any CPU
{6A46D120-26C8-4F97-9390-B99A3855105F}.Release|Any CPU.ActiveCfg = Release|Any CPU
{6A46D120-26C8-4F97-9390-B99A3855105F}.Release|Any CPU.Build.0 = Release|Any CPU
{6A46D120-26C8-4F97-9390-B99A3855105F}.Release|x64.ActiveCfg = Release|Any CPU
{6A46D120-26C8-4F97-9390-B99A3855105F}.Release|x64.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
Expand Down
36 changes: 24 additions & 12 deletions SpeckleGSA/AppResource/GsaAppResources.cs
Expand Up @@ -4,22 +4,34 @@

namespace SpeckleGSA
{
public class GsaAppResources : IGSAAppResources
public class GsaAppResources : IGSAAppResources, IGSALocalAppResources
{
public IGSASettings Settings { get => gsaSettings; }
public IGSAProxy Proxy { get => gsaProxy; }
//For the kit(s) use only
public IGSACacheForKit Cache { get => gsaCache; }
public IGSAMessenger Messenger { get => gsaMessenger; }
public IGSAProxy Proxy { get => LocalProxy; }
public IGSASettings Settings { get => LocalSettings; }
public IGSAMessenger Messenger { get => LocalMessenger; }

/// <summary>
/// Static class which interfaces with GSA
/// </summary>
//For local use only - which can be overridden with mocks for testing purposes
public IGSACache LocalCache
{
get => gsaCache;
set
{
if (value is GSACache)
{
gsaCache = (GSACache)value;
}
}
}
public IGSALocalSettings LocalSettings { get; set; } = new Settings();
public IGSALocalMessenger LocalMessenger { get; set; } = new GsaMessenger();

public ISpeckleObjectMerger Merger { get; set; } = new SpeckleObjectMerger();

public IGSALocalProxy LocalProxy { get; set; } = new GSAProxy();

public Settings gsaSettings = new Settings();
public ISpeckleObjectMerger Merger = new SpeckleObjectMerger();
public GSAProxy gsaProxy = new GSAProxy();
public GSACache gsaCache = new GSACache();
public GsaMessenger gsaMessenger = new GsaMessenger();
private GSACache gsaCache = new GSACache();

public GsaAppResources()
{
Expand Down
25 changes: 24 additions & 1 deletion SpeckleGSA/AppResource/GsaMessenger.cs
Expand Up @@ -6,7 +6,7 @@

namespace SpeckleGSA
{
public class GsaMessenger : IGSAMessenger, ISpeckleAppMessenger
public class GsaMessenger : IGSALocalMessenger, ISpeckleAppMessenger
{
public event EventHandler<MessageEventArgs> MessageAdded;

Expand All @@ -23,6 +23,23 @@ public void ResetLoggedMessageCount()
}
}

public bool Append(IEnumerable<string> messagePortionsToMatch, IEnumerable<string> additional)
{
lock (syncLock)
{
if (MessageCache.Count() > 0 && messagePortionsToMatch != null && messagePortionsToMatch.Count() > 0 && additional != null && additional.Count() > 0)
{
//This uses LINQ which isn't efficient but when there are messages, there shouldn't be too many - there isn't a great need to make this very efficient
var matching = MessageCache.Where(mc => (messagePortionsToMatch.All(mptm => mc.MessagePortions.Any(mp => mp.Equals(mptm, StringComparison.InvariantCultureIgnoreCase))))).ToList();
foreach (var m in matching)
{
m.MessagePortions = m.MessagePortions.Concat(additional).ToArray();
}
}
}
return true;
}

public bool CacheMessage(SpeckleGSAInterfaces.MessageIntent intent, SpeckleGSAInterfaces.MessageLevel level, Exception ex, params string[] messagePortions)
{
lock (syncLock)
Expand All @@ -43,6 +60,8 @@ public bool CacheMessage(SpeckleGSAInterfaces.MessageIntent intent, SpeckleGSAIn

public bool Message(SpeckleGSAInterfaces.MessageIntent intent, SpeckleGSAInterfaces.MessageLevel level, params string[] messagePortions)
{
return CacheMessage(intent, level, messagePortions);
/*
if ((intent == SpeckleGSAInterfaces.MessageIntent.TechnicalLog)
//TO DO: review this assumption that messages with 2 portions are to be consolidated
|| (intent == SpeckleGSAInterfaces.MessageIntent.Display && messagePortions.Count() == 2))
Expand All @@ -55,10 +74,13 @@ public bool Message(SpeckleGSAInterfaces.MessageIntent intent, SpeckleGSAInterfa
MessageAdded?.Invoke(null, new MessageEventArgs(intent, level, messagePortions));
}
return true;
*/
}

public bool Message(SpeckleGSAInterfaces.MessageIntent intent, SpeckleGSAInterfaces.MessageLevel level, Exception ex, params string[] messagePortions)
{
return CacheMessage(intent, level, ex, messagePortions);
/*
if (intent == SpeckleGSAInterfaces.MessageIntent.TechnicalLog)
{
//Currently cache these so that the app has the provision to add more context before it's logged
Expand All @@ -69,6 +91,7 @@ public bool Message(SpeckleGSAInterfaces.MessageIntent intent, SpeckleGSAInterfa
MessageAdded?.Invoke(null, new MessageEventArgs(intent, level, ex, messagePortions));
}
return true;
*/
}

public void Trigger()
Expand Down
31 changes: 31 additions & 0 deletions SpeckleGSA/AppResource/GsaResultParams.cs
@@ -0,0 +1,31 @@
using SpeckleGSAInterfaces;
using System.Collections.Generic;

namespace SpeckleGSA
{
public class GsaResultParams : IGSAResultParams
{
public int ResHeader { get; set; }
public int Flags { get; set; }
public List<string> Keys { get; set; } //Field/column headers
public string Keyword { get; set; } //TODO: is this still necessary?

public GsaResultParams(int resHeader, int flags, List<string> keys)
{
this.ResHeader = resHeader;
this.Flags = flags;
this.Keys = keys;
}

public GsaResultParams(string keyword, int resHeader, int flags, List<string> keys)
{
this.ResHeader = resHeader;
this.Flags = flags;
this.Keys = keys;
if (!string.IsNullOrEmpty(keyword))
{
this.Keyword = keyword;
}
}
}
}
16 changes: 16 additions & 0 deletions SpeckleGSA/AppResource/IGSALocalAppResources.cs
@@ -0,0 +1,16 @@
using SpeckleGSAInterfaces;
using SpeckleGSAProxy;
using SpeckleUtil;

namespace SpeckleGSA
{
public interface IGSALocalAppResources : IGSAAppResources
{
IGSACache LocalCache { get; set; }
IGSALocalSettings LocalSettings { get; set; }
IGSALocalProxy LocalProxy { get; }
IGSALocalMessenger LocalMessenger { get; set; }

ISpeckleObjectMerger Merger { get; set; }
}
}
13 changes: 13 additions & 0 deletions SpeckleGSA/AppResource/IGSALocalMessenger.cs
@@ -0,0 +1,13 @@
using SpeckleGSAInterfaces;
using System;
using System.Collections.Generic;

namespace SpeckleGSA
{
public interface IGSALocalMessenger : IGSAMessenger
{
bool Append(IEnumerable<string> messagePortionsToMatch, IEnumerable<string> additional);
void Trigger();
event EventHandler<MessageEventArgs> MessageAdded;
}
}
14 changes: 14 additions & 0 deletions SpeckleGSA/AppResource/IGSALocalSettings.cs
@@ -0,0 +1,14 @@
using SpeckleGSAInterfaces;

namespace SpeckleGSA
{
public interface IGSALocalSettings : IGSASettings
{
int LoggingMinimumLevel { get; set; }
bool SendOnlyResults { get; set; }
bool SendOnlyMeaningfulNodes { get; set; }
bool SeparateStreams { get; set; }
string ServerAddress { get; set; }
bool VerboseErrors { get; set; }
}
}
20 changes: 10 additions & 10 deletions SpeckleGSA/AppResource/Settings.cs
Expand Up @@ -11,15 +11,15 @@ namespace SpeckleGSA
/// <summary>
/// Static class to store settings.
/// </summary>
public class Settings : IGSASettings
public class Settings : IGSALocalSettings
{
public bool SendOnlyMeaningfulNodes = true;
public bool SeparateStreams = false;
public bool SendOnlyMeaningfulNodes { get; set; } = true;
public bool SeparateStreams { get; set; } = false;
public int PollingRate = 2000;
public string ServerAddress = "";
public string ServerAddress { get; set; } = "";

//Default values for properties specified in the interface
public string Units { get; set; }
public string Units { get; set; } = "mm";
public GSATargetLayer TargetLayer { get; set; } = GSATargetLayer.Design;
public double CoincidentNodeAllowance { get; set; } = 0.1;
public bool SendOnlyResults { get; set; } = false;
Expand All @@ -28,7 +28,7 @@ public class Settings : IGSASettings

private int loggingthreshold = 3;

public bool VerboseErrors = false;
public bool VerboseErrors { get; set; } = false;

public string ObjectUrl(string id)
{
Expand Down Expand Up @@ -72,10 +72,10 @@ public int LoggingMinimumLevel
}
}

public Dictionary<string, Tuple<int, int, List<string>>> NodalResults { get; set; } = new Dictionary<string, Tuple<int, int, List<string>>>();
public Dictionary<string, Tuple<int, int, List<string>>> Element1DResults { get; set; } = new Dictionary<string, Tuple<int, int, List<string>>>();
public Dictionary<string, Tuple<int, int, List<string>>> Element2DResults { get; set; } = new Dictionary<string, Tuple<int, int, List<string>>>();
public Dictionary<string, Tuple<string, int, int, List<string>>> MiscResults { get; set; } = new Dictionary<string, Tuple<string, int, int, List<string>>>();
public Dictionary<string, IGSAResultParams> NodalResults { get; set; } = new Dictionary<string, IGSAResultParams>();
public Dictionary<string, IGSAResultParams> Element1DResults { get; set; } = new Dictionary<string, IGSAResultParams>();
public Dictionary<string, IGSAResultParams> Element2DResults { get; set; } = new Dictionary<string, IGSAResultParams>();
public Dictionary<string, IGSAResultParams> MiscResults { get; set; } = new Dictionary<string, IGSAResultParams>();

public List<string> ResultCases { get; set; } = new List<string>();
public bool ResultInLocalAxis { get; set; } = false;
Expand Down
3 changes: 1 addition & 2 deletions SpeckleGSA/Extensions.cs
@@ -1,14 +1,13 @@
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using System.Threading.Tasks.Dataflow;

namespace SpeckleGSA
{
public static class Extensions
public static class Extensions
{
public static Dictionary<U, V> MergeDictionaries<U, V>(this IEnumerable<Dictionary<U, V>> ds)
{
Expand Down
31 changes: 31 additions & 0 deletions SpeckleGSA/ProgressEstimator/ProcessingPhase.cs
@@ -0,0 +1,31 @@
namespace SpeckleGSA
{
//Used for estimation of work for progress bar
internal class ProcessingPhase
{
public WorkPhase Phase { get; set; }
public double Weighting { get; set; }
public double Total { get; set; }
public double Current { get; set; }

public void Clear()
{
this.Total = 0;
this.Current = 0;
}

public ProcessingPhase(WorkPhase phase, double weighting)
{
this.Phase = phase;
this.Weighting = weighting;
}
}

internal enum WorkPhase
{
CacheRead,
CacheUpdate,
Conversion,
ApiCalls
}
}

0 comments on commit 8e49d1c

Please sign in to comment.