AR Design
UBC EML collab with UBC SALA - visualizing IoT data in AR
DataWidget.cs
Go to the documentation of this file.
1 using ARDesign.Influx;
2 using System;
3 using System.Collections.Generic;
4 using System.Linq;
5 using UnityEngine;
6 
7 namespace ARDesign
8 {
9  namespace Widgets
10  {
11 
16  public class DataWidget : InfluxType<IDictionary<DateTime, Vector2>>
17  {
18  #region PRIVATE_MEMBER_VARIABLES
19  private DataWidgetHandler wid;
20  private Vector2 curVal;
21  private string label;
22  #endregion //PRIVATE_MEMBER_VARIABLES
23 
24  #region PUBLIC_METHODS
25 
30  public string GetLabel()
31  {
32  return label;
33  }
34 
38  public void SetCurrentValues()
39  {
40  if (!isDataBuilt)
41  {
42  throw new Exception("Error!data not build");
43  }
44  else
45  {
46  curVal = dataVals[dataVals.Keys.Max()];
47  }
48 
49  }
50 
55  public Vector2 GetCurrentValue()
56  {
57  return curVal;
58  }
59 
64  public void SetLabel(string toSet)
65  {
66  label = toSet;
67  wid.UpdateLabel();
68  }
69  #endregion //PUBLIC_METHODS
70 
71  #region PRIVATE_METHODS
72  protected override void CastWidget()
73  {
74  wid = (DataWidgetHandler)widget;
75  }
76 
77  protected override void ParseSetUpText(string webReturn)
78  {
79  dataVals = Utility.ParseValuesNoType(webReturn);
80 
81  isDataBuilt = true;
83  //StartCoroutine(wid.BuildGraph());
84  }
85 
86  protected override void ParseUpdateText(string webResult)
87  {
88  dataVals = Utility.ParseValuesNoType(webResult, dataVals);
90  }
91 
92  protected override string SetQueryUrl()
93  {
94  return BuildUrlWithoutLimitSetType(GetLabel());
95  }
96 
97  protected override string SetUpdateUrl()
98  {
99  return BuildUrlWithLimitSetType(GetLabel(), 1);
100  }
101  #endregion //PRIVATE_METHODS
102 
103  }
104  }
105 }
override void ParseUpdateText(string webResult)
Definition: DataWidget.cs:86
override string SetUpdateUrl()
Definition: DataWidget.cs:97
override void CastWidget()
Definition: DataWidget.cs:72
Static helper functions for Influx querying and serialization
Definition: Utility.cs:14
void SetLabel(string toSet)
Manually sets the widget label
Definition: DataWidget.cs:64
override void ParseSetUpText(string webReturn)
Definition: DataWidget.cs:77
This ensures type agnostic functions can be run on InfluxReaders - All widgets should inherit from TH...
Definition: InfluxReader.cs:18
void SetCurrentValues()
Sets the widget current value - the newest dictionary entry
Definition: DataWidget.cs:38
Handler class for data displaying widgets
override string SetQueryUrl()
Definition: DataWidget.cs:92
static IDictionary< DateTime, Vector2 > ParseValuesNoType(string jsonToParse)
Parses the values from a given json string - for use in populating widgets
Definition: Utility.cs:63
void UpdateLabel()
Sets label of widget ot displat type of data
Vector2 GetCurrentValue()
Returns the widget current value
Definition: DataWidget.cs:55
string GetLabel()
Returns the type of the widget
Definition: DataWidget.cs:30
Widget storing data for a specific type dataVal is of type IDictionary<DateTime, Vector2> ...
Definition: DataWidget.cs:16