コード例 #1
0
        public async Task EndInit()
        {
            var response = await _core.HttpClient.GetObjectAsync <GetRoomControlFullResponse>("room_control/get_terminal_devices/");

            if (response.Success)
            {
                _devices      = response.Result.Devices.Select(d => d).ToList();
                _deviceServer = response.Result.Server;
            }
            return;
        }
コード例 #2
0
    private void Start()
    {
        this.here   = this.GetComponent <SphereCollider>();
        this.server = FindObjectOfType <DeviceServer>();
        var head = this.transform;

        while (this.anim == null && head != null)
        {
            this.anim = head.GetComponent <Animation>();
            head      = head.transform.parent;
        }
    }
コード例 #3
0
    public void Awake()
    {
        instance = this;

        PrintLocalIPAddresses();

        tcpListener = new TcpListener(IPAddress.Any, serverPort);
        tcpListener.Start();
        tcpListener.BeginAcceptTcpClient(OnServerConnect, null);

        Debug.Log("Server listening on port " + serverPort);
    }
コード例 #4
0
        /// <summary>
        /// 编辑PDA目的地信息
        /// </summary>
        /// <param name="destination">PDA目的地主体</param>
        /// <returns></returns>
        public ResultModel <Model_Destination> EditPDADestination(Model_Destination destination)
        {
            ResultModel <Model_Destination> result = new ResultModel <Model_Destination>();

            try
            {
                result.Data = DeviceServer.EditPDADestinations(destination);
            }
            catch (Exception ex)
            {
                result.Code    = 1;
                result.Message = ex.Message;
            }
            return(result);
        }
コード例 #5
0
        /// <summary>
        /// 获取PDA 设备目的地 信息
        /// </summary>
        /// <param name="deviceId">device_destination的id </param>
        /// <param name="pdaNumber">可选参数[PDA编号,为0时默认查询所有PDA信息]</param>
        /// <param name="pageIndexAndCount">可选参数[分页参数,格式为"页索引.每页数量".例如:1.50,表示每页显示50条,当前查询第1页]</param>
        /// <returns></returns>
        public ResultModel <List <Model_Destination> > GetPDADestinationList(int deviceId = 0, int pdaNumber = 0, string pageIndexAndCount = null)
        {
            ResultModel <List <Model_Destination> > result = new ResultModel <List <Model_Destination> >();

            try
            {
                result.Data = DeviceServer.GetPDADestinationLists(deviceId, pdaNumber, pageIndexAndCount);
            }
            catch (Exception ex)
            {
                result.Code    = 1;
                result.Message = ex.Message;
            }
            return(result);
        }
コード例 #6
0
        /// <summary>
        /// 编辑或删除PDA信息
        /// Id不为0时表示编辑PDA信息
        /// Id为-1时通过PDA编号删除该PDA
        /// Id为0时表示添加PDA信息
        /// </summary>
        /// <param name="pdaInfo">PDA信息</param>
        /// <returns></returns>
        public ResultModel <Model_PDAInfo> EditPDA(Model_PDAInfo pdaInfo)
        {
            ResultModel <Model_PDAInfo> result = new ResultModel <Model_PDAInfo>();

            try
            {
                result.Data = DeviceServer.EditPDAs(pdaInfo);
            }
            catch (Exception ex)
            {
                result.Code    = 1;
                result.Message = ex.Message;
            }
            return(result);
        }
コード例 #7
0
        public async Task <BunqResponse> Register(string description, string secret)
        {
            var data = new DeviceServer()
            {
                Description = description,
                Secret      = secret,
                //PermittedIps
            };

            var request = new HttpRequestMessage(HttpMethod.Post, ENDPOINT_URL_POST)
            {
                Content = new ByteArrayContent(Encoding.UTF8.GetBytes(BunqJsonConvert.SerializeObject(data, Formatting.Indented))),
            };

            var response = await Client.BunqSendAsync(request);

            return(response);
        }
コード例 #8
0
        public RoomControlsViewModel(PanaceaServices core, List <Device> devices, DeviceServer deviceServer)
        {
            _core              = core;
            _devices           = devices;
            _deviceServer      = deviceServer;
            LightingDevices    = new List <Device>();
            GlassDevices       = new List <Device>();
            TemperatureDevices = new List <Device>();
            if (devices.Any(d => d.Group.Type == DeviceType.Lighting))
            {
                LightingDevices = devices.Where(d => d.Group.Type == DeviceType.Lighting).ToList();
            }

            if (devices.Any(d => d.Group.Type == DeviceType.Temperature))
            {
                TemperatureDevices = devices.Where(d => d.Group.Type == DeviceType.Temperature).ToList();
            }

            if (devices.Any(d => d.Group.Type == DeviceType.Glass))
            {
                GlassDevices = devices.Where(d => d.Group.Type == DeviceType.Glass).ToList();
            }

            BlindsColumnWidth      = new GridLength(4, GridUnitType.Star);
            LightsColumnWidth      = new GridLength(4, GridUnitType.Star);
            TemperatureColumnWidth = new GridLength(6, GridUnitType.Star);
            GlassesColumnWidth     = new GridLength(6, GridUnitType.Star);
            setupTimers();
            setupCommands();

#if DEBUG
            _temperatureManager = new VoidManager(_devices);
#else
            _temperatureManager = new TemperatureManager(_deviceServer.ServerUrl, _deviceServer.Username, _deviceServer.Password);
#endif
        }
コード例 #9
0
 void Start()
 {
     this.server = FindObjectOfType <DeviceServer>();
     this.mat    = GetComponent <Renderer>().material;
 }
コード例 #10
0
 private void RegisterDevice(string deviceDescription, IList <string> permittedIps)
 {
     DeviceServer.Create(this, GenerateRequestBodyBytes(deviceDescription, permittedIps));
 }