예제 #1
0
        private void AppendText(string p)
        {
            Console.WriteLine(p);
            String[] bytes = p.Split(',');

            if (count == 0)
            {
                count = int.Parse(bytes[1], System.Globalization.NumberStyles.HexNumber);
                ids   = new String[count];
            }

            int currentSensor = int.Parse(bytes[2], System.Globalization.NumberStyles.HexNumber);

            String deviceId = "";

            for (int i = 9; i <= 16; i++)
            {
                deviceId += bytes[i] + ".";
            }
            deviceId = deviceId.Substring(0, deviceId.Length - 1);
            if (!ids.Contains(deviceId))
            {
                ids[currentSensor - 1] = deviceId;
                Sensor newSens = new SensorThermometer();
                newSens.setDeviceIdentifier(deviceId);
                newSens.disconnect();
                DataRow row = set.Rows.Add();
                row.ItemArray = new Object[] { SensorType.THERMOMETER, deviceId, newSens };
                Console.WriteLine("Added " + deviceId);
            }

            if (set.Rows.Count == count)
            {
                Device.Disconnect();
                this.updated = true;
                Console.WriteLine("Disconnected");
            }
        }
예제 #2
0
 public void disconnect()
 {
     Device.Disconnect();
 }