Пример #1
0
 public void Check()
 {
     //var d = new Device(IPAddress.Parse("192.168.1.230"));
     var devices = DataBaseClasses.DataBaseClass.Instancedb().GetAllDevices();
     foreach (var device in devices)
     {
         var d = new Device(IPAddress.Parse(device.ip_address));
         byte[] dat = {0, 0};
         d.send_packet(dat);
     }
 }
Пример #2
0
        public bool SwitchOn(string consoleId)
        {
            if (!String.IsNullOrWhiteSpace(consoleId))
            {
                List<device_endpoints_t> allEndPoints = DataBaseClass.Instancedb().GetAllEndPoints();
                var console = (from c in allEndPoints
                               where c.playstation_id == consoleId
                               select c).SingleOrDefault();
                List<devices_t> allDevices = DataBaseClass.Instancedb().GetAllDevices();
                string iPaddress = (from i in allDevices
                                    where console != null && i.device_id == console.device_id
                                    select i.ip_address).SingleOrDefault();
                if (iPaddress != null)
                {
                    var device = new Device(IPAddress.Parse(iPaddress));
                    if (console != null)
                    {
                        var ep = new Endpoint(device, (byte)console.endpoint_index);

                        while (true)
                        {
                            for (int i = 0; i < 5; i++)
                            {
                                if (!ep.On())
                                {
                                    Thread.Sleep(100);
                                }
                                else
                                {
                                    return true;
                                }
                            }
                            if (!ep.On())
                            {
                                DialogResult dr = MessageBox.Show(
                                    @"Нет соединения! Нажмите Повторить чтобы попытатся снова.", @"Ошибка", MessageBoxButtons.RetryCancel);
                                TextFileWriter.TextFileWriterInstance()
                                    .AddSomeDataToLogReport("Нет соединения с приставкой " + consoleId,
                                        Options.FileTypeErrorsLogs);
                                if (dr == DialogResult.Cancel)
                                {
                                    return false;
                                }
                            }
                            else
                            {
                                SwitchOff(consoleId);
                                return false;
                            }

                        }
                    }
                }
            }
            return false;
            //return true;
        }
Пример #3
0
 public DevicesWithEndPoints(Device device, List<Endpoint> endpointsOfDevice)
 {
     _device = device;
     _endpointsList = endpointsOfDevice;
 }
Пример #4
0
 //        public AddNewSessionController()
 //        {
 //            _addNewSessionModel = new AddNewSessionModel();
 //        }
 public List<Endpoint> LoadingOfEndPoints(Device dev)
 {
     var endpoints = new List<Endpoint>();
     for (int i = 1; i <= 16 /*table_numComboBox.Items.Count*/; i++)
     {
         var ep = new Endpoint(dev, (byte)i);
         endpoints.Add(ep);
     }
     return endpoints;
 }