Exemple #1
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();
        }
Exemple #2
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();
        }
Exemple #3
0
        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);
        }