Exemplo n.º 1
0
        private void KnxNetDiscovery_DeviceRemoved(object sender, SparkAlljoyn.Discovery.AdapterDiscoveryEventArgs e)
        {
            var matchingDevices = devices.Where(d => d.SerialNumber == e.DeviceId).ToList();

            foreach (var device in matchingDevices)
            {
                this.NotifyDeviceRemoval(device);
                devices.Remove(device);
            }
        }
Exemplo n.º 2
0
        private void IrTransDiscovery_DeviceDiscovered(object sender, SparkAlljoyn.Discovery.AdapterDiscoveryEventArgs e)
        {
            var conn = e.Device as IrTransClient;

            conn.Connect();

            var device = new IrTransDevice(this, conn, "TXXXX", "IrTrans", "IrTrans", "1.0.0.0", e.DeviceId, "IrTrans");

            devices.Add(device);
            this.NotifyDeviceArrival(device);
        }
Exemplo n.º 3
0
        private void Roomba_DeviceDiscovered(object sender, SparkAlljoyn.Discovery.AdapterDiscoveryEventArgs e)
        {
            var conn = e.Device as RoombaClient;

            Task.Factory.StartNew(async() =>
            {
                conn.Connect();
                var device = new RoombaDevice(this, conn, "Roomba", "Roomba", "Roomba", "1.0.0.0", e.DeviceId, "Roomba");
                devices.Add(device);
                await device.AquireCurrentState();
                this.NotifyDeviceArrival(device);
            });
        }
Exemplo n.º 4
0
        private void HoermannDiscovery_DeviceDiscovered(object sender, SparkAlljoyn.Discovery.AdapterDiscoveryEventArgs e)
        {
            var conn = e.Device as HoermannClient;

            conn.Connect();

            var device = new HoermannDevice(this, conn, "Hoermann", "Hoermann", "TXXX2", "1.0.0.0", e.DeviceId, "Hoermann");

            devices.Add(device);
            this.NotifyDeviceArrival(device);

            // TEMP
            var msg = MCP.CreateLoginCmd("admin", "0000");

            conn.SendMessage(msg);
        }
Exemplo n.º 5
0
        private void KnxDeviceDiscovery_DeviceDiscovered(object sender, SparkAlljoyn.Discovery.AdapterDiscoveryEventArgs e)
        {
            var conn = e.Device as KnxNetTunnelingConnection;

            if (devices.Count > 0)
            {
                return;
            }

            Task.Factory.StartNew(async() =>
            {
                // TEST
                //var t = new OpenWeather();
                //this.NotifyDeviceArrival(t);
                //await t.AquireCurrentState();

                var storageFolder = await Windows.ApplicationModel.Package.Current.InstalledLocation.GetFolderAsync("Data");
                var storageFile   = await storageFolder.GetFileAsync("Visu.xml");
                var visuXml       = await Windows.Data.Xml.Dom.XmlDocument.LoadFromFileAsync(storageFile);

                var deviceNodes = visuXml.SelectNodes("//device[alljoyn[@bridge='knxnetip']]");
                foreach (Windows.Data.Xml.Dom.XmlElement deviceNode in deviceNodes)
                {
                    var alljoynNode  = (Windows.Data.Xml.Dom.XmlElement)deviceNode.SelectSingleNode("alljoyn");
                    KnxDevice device = null;

                    if (deviceNode.GetAttribute("type") == "switch")
                    {
                        device = new KnxSwitch(this, conn, "Switch Device", deviceNode.GetAttribute("id"), "Knx Switch")
                        {
                            SwitchAddr       = alljoynNode.GetAttribute("knxaddr"),
                            SwitchStatusAddr = alljoynNode.GetAttribute("knxsaddr")
                        };
                    }
                    else if (deviceNode.GetAttribute("type") == "presence")
                    {
                        device = new KnxPresence(this, conn, "Presence Device", deviceNode.GetAttribute("id"), "Knx Presence")
                        {
                            PresenceStatusAddr = alljoynNode.GetAttribute("knxsaddr")
                        };
                    }
                    else if (deviceNode.GetAttribute("type") == "hvac")
                    {
                        device = new KnxHvac(this, conn, "Hvac Device", deviceNode.GetAttribute("id"), "Knx Hvac")
                        {
                            OpModeAddr                  = alljoynNode.GetAttribute("knxmodeaddr"),
                            OpModeStatusAddr            = alljoynNode.GetAttribute("knxmodesaddr"),
                            TargetTemperatureAddr       = alljoynNode.GetAttribute("knxtargettempaddr"),
                            TargetTemperatureStatusAddr = alljoynNode.GetAttribute("knxtargettempsaddr"),
                            TemperatureAddr             = alljoynNode.GetAttribute("knxtempaddr"),
                            HumidityAddr                = alljoynNode.GetAttribute("knxhumaddr"),
                            CO2Addr = alljoynNode.GetAttribute("knxco2addr")
                        };
                    }
                    else if (deviceNode.GetAttribute("type") == "shutterblinds")
                    {
                        device = new KnxShutterBlinds(this, conn, "Jalousie Device", deviceNode.GetAttribute("id"), "Knx Jalousie")
                        {
                            PositionAddr       = alljoynNode.GetAttribute("knxposaddr"),
                            PositionStatusAddr = alljoynNode.GetAttribute("knxpossaddr"),
                            FlapsAddr          = alljoynNode.GetAttribute("knxflapaddr"),
                            FlapsStatusAddr    = alljoynNode.GetAttribute("knxflapsaddr")
                        };
                    }
                    else if (deviceNode.GetAttribute("type") == "weather")
                    {
                        device = new KnxWeather(this, conn, "Weather Device", deviceNode.GetAttribute("id"), "Knx Weather")
                        {
                            TemperatureAddr = alljoynNode.GetAttribute("knxtempaddr"),
                            RainAddr        = alljoynNode.GetAttribute("knxrainaddr"),
                            WindAddr        = alljoynNode.GetAttribute("knxwindaddr"),
                            DawnAddr        = alljoynNode.GetAttribute("knxdawnaddr")
                        };
                    }

                    if (device != null)
                    {
                        devices.Add(device);
                        conn.Disconnected += (object s, EventArgs args) =>
                        {
                            this.NotifyDeviceRemoval(device);
                            devices.Remove(device);
                        };

                        await device.AquireCurrentState();
                        this.NotifyDeviceArrival(device);
                    }
                }
            });
        }