AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
ParentWidget.cs
Go to the documentation of this file.
1 using ARDesign.Influx;
2 using System.Collections;
3 using System.Collections.Generic;
4 using UnityEngine;
5 namespace ARDesign
6 {
7  namespace Widgets
8  {
9 
15  public class ParentWidget : InfluxType<string[]>
16  {
17  #region PRIVATE_MEMBER_VARIABLES
18 
22  private ParentWidgetHandler wid;
23 
27  private IList<DataWidget> children;
28  #endregion //PRIVATE MEMBER VARIABLES
29 
30  #region PUBLIC_METHODS
31 
36  public void AddChild(DataWidget dw)
37  {
38  if (children == null)
39  {
40  children = new List<DataWidget>();
41  }
42 
43  children.Add(dw);
44  SetupChildWidget(dw);
45  }
46  #endregion //PUBLIC_METHODS
47 
48  #region PRIVATE_METHODS
49  protected override void CastWidget()
50  {
51  wid = (ParentWidgetHandler)widget;
52  }
53 
54 
59  protected override void ParseSetUpText(string webReturn)
60  {
61  dataVals = Utility.ParseLabels(webReturn);
62  //Debug.Log(webReturn);
64 
65  //Code for building children should go here
66  JSONBuilder.instance.AddWidget(children);
67  }
68 
73  private void SetupChildWidget(DataWidget child)
74  {
75  child.SetDBVals(measure, building, room);
76  }
77 
82  protected override void ParseUpdateText(string webResult)
83  {
84  throw new System.NotImplementedException();
85  }
86 
91  protected override string SetQueryUrl()
92  {
93  //Debug.Log(BuildUrlTagList("type"));
94  return BuildUrlTagList("type");
95  }
96 
97  protected override string SetUpdateUrl()
98  {
99  return BuildUrlTagList("type");
100  }
101  #endregion //PRIVATE METHODS
102  }
103  }
104 }
Handler class for parent widgets - includes building child widget objects
Singleton object for handling scene loading and widget creation
Definition: JSONBuilder.cs:16
override string SetQueryUrl()
Queries a list of types in the measure
Definition: ParentWidget.cs:91
void AddChild(DataWidget dw)
Adds a child widget to the parent
Definition: ParentWidget.cs:36
static string [] ParseLabels(string jsonToParse)
Queries database for type labels (ie CO2, temperature, etc)
Definition: Utility.cs:110
Reader class for parent widgets Parent widgets query a measurement for a list of types (ie...
Definition: ParentWidget.cs:15
Static helper functions for Influx querying and serialization
Definition: Utility.cs:14
override void ParseSetUpText(string webReturn)
Pareses the setup query and builds the widget and all its children
Definition: ParentWidget.cs:59
override string SetUpdateUrl()
Definition: ParentWidget.cs:97
This ensures type agnostic functions can be run on InfluxReaders - All widgets should inherit from TH...
Definition: InfluxReader.cs:18
static JSONBuilder instance
Definition: JSONBuilder.cs:18
override void ParseUpdateText(string webResult)
Parent widgets should never be updated - toUpdate is always false
Definition: ParentWidget.cs:82
Widget storing data for a specific type dataVal is of type IDictionary<DateTime, Vector2> ...
Definition: DataWidget.cs:16
void BuildChildren(string[] labels)
Builds a child widget for each label