public void addSensor(IoTSensor sensor) {
     this.availableSensors.Add(sensor);
 }
 public async Task refreshSensors()
 {
     if (SharedVariables.client.isConnected())
     {
         HavissIoTCommandBuilder commandBuilder = new HavissIoTCommandBuilder();
         if (Config.username.Length > 0)
         {
             if (Config.password.Length > 0)
             {
                 commandBuilder.addUser(Config.username, Config.password);
             }
             else
             {
                 commandBuilder.addUser(Config.username);
             }
         }
         commandBuilder.listSensors();
         String response = await SharedVariables.client.request(commandBuilder.getJsonString());
         JObject jsonObject = null;
         JArray jsonArray = null;
         try
         {
             jsonObject = JObject.Parse(response);
             jsonArray = jsonObject.GetValue("r") as JArray;
         }
         catch (Exception ex)
         {
             Debug.WriteLine(ex.Message);
             jsonObject = null;
             jsonArray = null;
         }
         if (jsonArray != null)
         {
             foreach (JObject s in jsonArray)
             {
                 try
                 {
                     string sensorName = (string)s.GetValue("name");
                     string sensorTopic = (string)s.GetValue("topic");
                     string sensorType = (string)s.GetValue("type");
                     bool toStore = (bool)s.GetValue("toStore");
                     IoTSensor sensor = new IoTSensor(sensorName, sensorTopic, sensorType, toStore);
                     SharedVariables.sensorHandler.addSensor(sensor);
                 }
                 catch (Exception ex)
                 {
                     Debug.WriteLine(ex.Message);
                 }
             }
         }
     }
 }
 //When a new sensor is selected
 private void sensor_select_SelectionChanged(object sender, SelectionChangedEventArgs e)
 {
     if (this.sensor_select.Items.Count > 0)
     {
         string sensorName = sensorNames[sensor_select.SelectedIndex];
         this.currentSensor = SharedVariables.sensorHandler.getSensorByName(sensorName);
         //(values_chart.Series[0] as LineSeries).ItemsSource = this.currentSensor.getValues();
         this.sensor_name.Text = this.currentSensor.getName();
     }
 }