public static void clear() { SensorManager.disconnectAll(); table.Rows.Clear(); global::CarSensX.Properties.Settings.Default.SensorSetXML = ""; global::CarSensX.Properties.Settings.Default.Save(); }
private static void disconnectAll() { Sensor[] sens = SensorManager.getAllSensors(); foreach (Sensor sen in sens) { sen.disconnect(); } }
public static void AddSensor(Sensor sensor) { SensorManager.initialize(); DataRow existing = table.Rows.Find(sensor.getIdentifier()); if (existing != null) { table.Rows.Remove(existing); } table.Rows.Add(new Object[] { sensor.getIdentifier(), sensor }); persist(); }
public static void RemoveSensor(Sensor sensor) { SensorManager.initialize(); DataRow sens = table.Rows.Find(sensor.getIdentifier()); table.Rows.Remove(sens); //foreach (DataRow row in SensorManager.table.Rows) //{ // String sens = (String)row.ItemArray[0]; // if (sens.Equals(sensor.getIdentifier())) // { // sensor.disconnect(); // SensorManager.table.Rows.Remove(row); // } //} persist(); }
public static Sensor[] getAllSensors() { SensorManager.initialize(); int mocks = global::CarSensX.Properties.Settings.Default.MockSensors; Sensor[] sens = new Sensor[table.Rows.Count + mocks]; int i = 0; foreach (DataRow row in SensorManager.table.Rows) { sens[i] = (Sensor)row.ItemArray[1]; i++; } for (i = i; i < sens.Length; i++) { sens[i] = new SensorMock(); sens[i].setName("MockSensor" + i); } return(sens); }