Home - nagasudhirpulla/wpf_scada_dashboard GitHub Wiki

Data Structure Hierarchy for the dashboard

Board
    Cells => Each cell has optional name, row position, column position, width, height, width mode, height mode etc
      UserControl that can acquire data config via UI as well as functions. Hence the VizConfig will be a member of the
      User Control. This should implement an interface with the
      following methods.
      InvokeConfigUI, SetDataCofig(List<IRelaventPointConfig>), GetCellConfig, GetCellConfigJSON,
      StopFetch, StartFetch (Handle the already running fetches), 
      Event Emitter that emits events to board(like write in main console)
      StartViz, StopViz, GetCurrentVizData, GetVizData
      ShowContextMenu, HandleContextMenuSelection
      and more

There will also be fetchers for each type of Data point like ScadaFetcher, PMUFetcher, WebFetcher for fetching the point data from data sources.

Addressing Serialization and de-serialization of a list of mixed classes derived from a base class

Case - We have a list of VizConfig objects, but the list members can be ScadaLinePlotVizConfig objects/ PMULinePlotVizConfig objects / ScadaMapVizConfig objects / PMUMapVizConfig objects since these all are derived from VizConfig base class.

Problem Statement - If you have a list of mixed types of classes derived from a class that are serialized, then while de-serialization, we cannot figure out the specific class type (It is possible, by inspecting properties of the serialized JSON string, but it is not a beautiful solution).

  1. Wrapping a class with Class with class name can be one of the solution -- https://stackoverflow.com/questions/38679972/determine-type-during-json-deserialize

  2. Another idea can be to use an immutable string property in the object that specifies the class type, which will be useful for de-serialization.

I think solution 2 would be a good idea for our problem since the classes to be serialized are designed by us.

The solution is implemented using the second point philosophy using the technique in the link below.

http://skrift.io/articles/archive/bulletproof-interface-deserialization-in-jsonnet/

The key is to use a custom deserializer for each interace.

Get the type of a variable / object in C#

https://msdn.microsoft.com/en-us/library/system.object.gettype(v=vs.110).aspx

Using GetType() method, we can get most specific object type

null values support for objects in C# using Nullable

https://www.infoworld.com/article/3051617/application-development/how-to-work-with-nullable-types-in-c.html

https://docs.microsoft.com/en-us/dotnet/csharp/programming-guide/nullable-types/

Change UserControls in WPF to achieve the tabbed view effect (If possible, use animations for transitions)

Handling Custom Data structure values for plotting in livecharts

https://lvcharts.net/App/examples/v1/wpf/Types%20and%20Configuration

Messaging from parent to child using event handlers

https://stackoverflow.com/questions/14977927/how-do-i-pass-objects-in-eventargs

Newtonsoft serializing only non default values

https://www.newtonsoft.com/json/help/html/ReducingSerializedJSONSize.htm