public static async Task <AllPanelInfo> GetAllPanelInfo(string ip, string port, string auth_token)
        {
            AllPanelInfo result  = null;
            string       address = $"http://{ip}:{port}/api/v1/{auth_token}";

            using (HttpClient hc = new HttpClient())
            {
                var response = hc.GetAsync(address).GetAwaiter().GetResult();
                if (response.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    string res = await response.Content.ReadAsStringAsync();

                    result = JsonConvert.DeserializeObject <AllPanelInfo>(res);
                }
            }
            return(result);
        }
Esempio n. 2
0
        private void UpdateInfos(AllPanelInfo allPanelInfo)
        {
            if (allPanelInfo == null)
            {
                return;
            }

            Name            = allPanelInfo.Name;
            Model           = allPanelInfo.Model;
            Manufacturer    = allPanelInfo.Manufacturer;
            SerialNumber    = allPanelInfo.SerialNumber;
            HardwareVersion = allPanelInfo.HardwareVersion;
            FirmwareVersion = allPanelInfo.FirmwareVersion;

            switch (Model)
            {
            case "NL22":
                DeviceType = EDeviceType.LightPanles;
                break;

            case "NL29":
                DeviceType = EDeviceType.Canvas;
                break;

            case "NL42":
                DeviceType = EDeviceType.Shapes;
                break;

            case "NL45":
                DeviceType = EDeviceType.Essentials;
                break;

            case "NL52":
                DeviceType = EDeviceType.Elements;
                break;

            case "NL59":
                DeviceType = EDeviceType.Lines;
                break;
            }

            NumberOfPanels       = allPanelInfo.PanelLayout.Layout.NumberOfPanels;
            globalOrientation    = allPanelInfo.PanelLayout.GlobalOrientation.Value;
            GlobalOrientationMin = (ushort)allPanelInfo.PanelLayout.GlobalOrientation.Min;
            GlobalOrientationMax = (ushort)allPanelInfo.PanelLayout.GlobalOrientation.Max;

            EffectList     = allPanelInfo.Effects.List.ToArray();
            SelectedEffect = allPanelInfo.Effects.Selected;
            PowerOn        = allPanelInfo.State.On.On;
            PowerOff       = !PowerOn;

            brightness         = allPanelInfo.State.Brightness.Value;
            BrightnessMin      = (ushort)allPanelInfo.State.Brightness.Min;
            BrightnessMax      = (ushort)allPanelInfo.State.Brightness.Max;
            hue                = allPanelInfo.State.Hue.Value;
            HueMin             = (ushort)allPanelInfo.State.Hue.Min;
            HueMax             = (ushort)allPanelInfo.State.Hue.Max;
            saturation         = allPanelInfo.State.Saturation.Value;
            SaturationMin      = (ushort)allPanelInfo.State.Saturation.Min;
            SaturationMax      = (ushort)allPanelInfo.State.Saturation.Max;
            colorTemprature    = allPanelInfo.State.ColorTemprature.Value;
            ColorTempratureMin = (ushort)allPanelInfo.State.ColorTemprature.Min;
            ColorTempratureMax = (ushort)allPanelInfo.State.ColorTemprature.Max;
            ColorMode          = allPanelInfo.State.ColorMode;

            UpdatedInfos?.Invoke(this, EventArgs.Empty);

            UpdatePanelLayout(allPanelInfo.PanelLayout.Layout);
        }