wxr
2020-02-27 37c33341f75841dc39c535eb62a3603f596516a1
HDL_ON/Entity/Function/Light/Light.cs
@@ -8,7 +8,23 @@
    {
        public Light()
        {
            bus_DeviceType = "Relay";
        }
        /// <summary>
        ///
        /// </summary>
        /// <returns></returns>
        protected override string GetFunctionType()
        {
            string type = "Relay";
            if (PropertyArray.Contains("brightness"))
            {
                type = "Dimmer";
                if (PropertyArray.Contains("color"))
                {
                    type = "RGB";
                }
            }
            return type;
        }
        /// <summary>
@@ -18,7 +34,6 @@
        /// </summary>
        public int state = 0;
        public List<string> PropertyArray = new List<string>();
        /// <summary>
        /// 拼接、获取A协议操作数据
@@ -30,13 +45,23 @@
            {
                sendJob = new JObject { { "Namespace", a_Protocol_Namespace }, { "Command", command }, { "Type", "device" } };
                var data = new JObject { { "Switch", state }, { "sid", sid } };
                JObject data = null;
                switch (functionType)
                {
                    case "Relay"://继电器控制
                        data = new JObject { { "switch", state }, { "sid", sid } };
                        break;
                    case "Dimmer":
                        data = new JObject { { "Switch", state }, { "brightness", dicPropert["brightness"] }, { "sid", sid } };
                        break;
                }
                sendJob.Add("objects", data);
                return sendJob;
            }
            else if(command == "read")
            {
                sendJob = new JObject { { "Namespace", a_Protocol_Namespace }, { "Command", command }, { "Type", "device" } };
                var data = new JObject {{ "sid", sid } };
                sendJob.Add("objects", data);
            }
            return sendJob;
        }