using Aurora.Api; using Aurora.Api.DataType; using Aurora.Api.Devices; using PropertyTools.DataAnnotations; using System; using System.Collections.Generic; using System.IO.Ports; using System.Linq; using System.Text; using System.Threading.Tasks; namespace AuroraLight { public class LightConfig : IDeviceConfig { public IConnConfig ConnConfig { get; set; } [Category("Light Level")] [DisplayName("Channel 1 Level (0~255)")] [Description("Channel 1 Brightness")] public int Ch1Level { get; set; } = 200; [Category("Light Level")] [DisplayName("Channel 2 Level (0~255)")] [Description("Channel 2 Brightness")] public int Ch2Level { get; set; } = 200; [Category("Light Level")] [DisplayName("Channel 3 Level (0~255)")] [Description("Channel 3 Brightness")] public int Ch3Level { get; set; } = 200; [Category("Light Level")] [DisplayName("Channel 4 Level (0~255)")] [Description("Channel 4 Brightness")] public int Ch4Level { get; set; } = 200; public int GetChannelLevel(int channel) { switch (channel) { case 0: return Ch1Level; case 1: return Ch2Level; case 2: return Ch3Level; case 3: return Ch4Level; default: return Ch1Level; } } public void SetChannelLevel(int channel, int value) { switch (channel) { case 0: Ch1Level = value; break; case 1: Ch2Level = value; break; case 2: Ch3Level = value; break; case 3: Ch4Level = value; break; } } public LightConfig() { ConnConfig = new SerialConnConfig() { PortNum = 1, BaudRate = 19200, Parity = Parity.None, StopBits = StopBits.One, DataBits = 8, ReadTimeout = 500 }; Ch1Level = 200; Ch2Level = 200; Ch3Level = 200; Ch4Level = 200; } public static LightConfig GetDefaultConfig() { var config = new LightConfig(); config.ConnConfig = new SerialConnConfig() { PortNum = 1, BaudRate = 19200, Parity = Parity.None, StopBits = StopBits.One, DataBits = 8, ReadTimeout = 500 }; config.Ch1Level = 200; config.Ch2Level = 200; config.Ch3Level = 200; config.Ch4Level = 200; return config; } } }