using System;
|
using Newtonsoft.Json.Linq;
|
|
namespace HDL_ON.Entity
|
{
|
public class Curtain : Function
|
{
|
/*
|
窗帘属性列表:trait: [switch,openLevel,lock]
|
属性 描述
|
on_off on/off/stop;
|
openLevel 0-100;
|
lock boolean (Lock锁定控制)
|
*/
|
public Curtain()
|
{
|
}
|
/// <summary>
|
/// 开关百分比
|
/// 0-100
|
/// </summary>
|
[Newtonsoft.Json.JsonIgnore]
|
public int openLevel
|
{
|
get
|
{
|
try
|
{
|
string o = "0";
|
dicPropert.TryGetValue("openLevel", out o);
|
return o == "" ? 0 : Convert.ToInt32(o);
|
}
|
catch
|
{
|
MainPage.Log("openLevel 数据获取失败.");
|
return 0;
|
}
|
}
|
set
|
{
|
try
|
{
|
dicPropert["openLevel"] = value.ToString();
|
}
|
catch
|
{
|
MainPage.Log("openLevel 数据刷新失败.");
|
}
|
}
|
}
|
|
/// <summary>
|
/// 拼接、获取A协议操作数据
|
/// </summary>
|
public override JObject GetSendJObject(CommandType_A command)
|
{
|
var sendJob = new JObject();
|
if (command == CommandType_A.write)
|
{
|
|
sendJob = new JObject { { "vendor_code", vendor_code }, { "Command", command.ToString() }, { "Type", "device" } };
|
JObject data = null;
|
switch (functionType)
|
{
|
case FunctionType.Curtain:
|
data = new JObject { { "on_off", on_off }, { "sid", sid } };
|
break;
|
case FunctionType.MotorCurtain:
|
case FunctionType.RollingShutter:
|
data = new JObject { { "openLevel", openLevel}, { "sid", sid } };
|
break;
|
}
|
sendJob.Add("objects", data);
|
}
|
else if (command == CommandType_A.read)
|
{
|
sendJob = new JObject { { "vendor_code", vendor_code }, { "Command", command.ToString() }, { "Type", "device" } };
|
var data = new JObject { { "sid", sid } };
|
sendJob.Add("objects", data);
|
}
|
return sendJob;
|
}
|
|
|
}
|
}
|