예제 #1
0
 public static void clear()
 {
     SensorManager.disconnectAll();
     table.Rows.Clear();
     global::CarSens.Properties.Settings.Default.SensorSetXML = "";
     global::CarSens.Properties.Settings.Default.Save();
 }
예제 #2
0
 private static void disconnectAll()
 {
     Sensor[] sens = SensorManager.getAllSensors();
     foreach (Sensor sen in sens)
     {
         sen.disconnect();
     }
 }
예제 #3
0
        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();
        }
예제 #4
0
        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();
        }
예제 #5
0
        public static Sensor[] getAllSensors()
        {
            SensorManager.initialize();


            int mocks = global::CarSens.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);
        }