Esempio n. 1
0
        public static void Start()
        {
            var alldevices = DeviceService.GetAllDevices();

            var getwayAddresses = alldevices.Select(o => new { o.IPAddress, o.Port }).Distinct();

            foreach (var getwayItem in getwayAddresses)
            {
                var client = new MyTcpSocketClient(getwayItem.IPAddress, getwayItem.Port);

                bool success = false;
                do
                {
                    try
                    {
                        client.ConnectToServer();
                        success = true;
                    }
                    catch (Exception ex)
                    {
                        Console.WriteLine(ex.ToString());
                    }
                } while (success == false);

                Clients.Add(client);

                foreach (var device in alldevices.Where(o => o.Port == getwayItem.Port && o.IPAddress == getwayItem.IPAddress))
                {
                    DeviceItems.Add(new DeviceItem(device, client));
                }
            }
            if (StartCompleted != null)
            {
                StartCompleted(Clients);
            }
        }
Esempio n. 2
0
 public void SetClient(MyTcpSocketClient client)
 {
     Client = client;
 }
Esempio n. 3
0
 public DeviceItem(Device device, MyTcpSocketClient client)
 {
     this.Device = device;
     this.Client = client;
 }