using System;
using System.Collections.Generic;
namespace HDL_ON.Entity
{
public class Scene : Function
{
public Scene()
{
}
///
/// 场景类型
///
public SceneType sceneType = SceneType.OrdinaryScenes;
///
/// 场景背景
///
public string ImagePath = "Intelligence/Gallery/scenebg1.png";//"FunctionIcon/Scene/s1.png";
///
/// 场景功能列表
///
public List sceneFunctionList = new List();
///
/// 生成场景sid
///
public void NewSid()
{
string sSceneid = "";
try
{
string sOidBeginsWith = "000101";//厂商 + 通讯方式
DateTime dt = DateTime.Now;
DateTime startTime = TimeZoneInfo.ConvertTimeToUtc(new DateTime(2020, 1, 1));
long m = (long)((dt - startTime).TotalMilliseconds / 10);
string sTimeSpan = "00000000";
byte[] arry = new byte[4];
arry[0] = (byte)(m & 0xFF);
arry[1] = (byte)((m & 0xFF00) >> 8);
arry[2] = (byte)((m & 0xFF0000) >> 16);
arry[3] = (byte)((m >> 24) & 0xFF);
sTimeSpan = arry[0].ToString("X2") + arry[1].ToString("X2") + arry[2].ToString("X2") + arry[3].ToString("X2");
if (sTimeSpan.Length > 8)
{
sTimeSpan = sTimeSpan.Substring(0, 8);
}
else
{
sTimeSpan = "00000000";
}
sSceneid = sOidBeginsWith + sTimeSpan;
sSceneid += "0A";
sSceneid += "0A01";
//0A01 物模型为场景, 0001 表示 1 号场景功能
int iTopSceneId = 1;
Random random = new Random();
iTopSceneId = random.Next(0, 255);
iTopSceneId += random.Next(0, 255);
sSceneid += iTopSceneId.ToString("X4");//场景号 两个byte
sSceneid += "1100";
sid = sSceneid;
}
catch
{
sid = sSceneid;
}
}
}
}
//5.1.14获取场景列表
//请求参数
//{
// "namespace": "HDL",
// "type": "scene",
// "command": "get_list"
//}
//返回值 json格式 所有场景id及场景里执行的目标数据
//返回例子
//{
// "namespace": "HDL",
// "command": "get_list_respond",
// "type": "scene",
// "number": [{
// "scene_id": "0001",
// "scene_name": "dinner",
// "objects": [{
// "sid": "00010019101209000025670100010001",
//"data_type": "string ",
// "value": "on"
// }]
// }]
//}
//说明 获取场景列表和属性,只开,只关,既开又关
//5.1.15创建场景
//请求参数
//{
// "namespace": "HDL",
// "command": "create",
// "type": "scene",
// "objects": [{
// "scene_name": "Away ",
// "status": "single_off"
// }]
//}
//返回值 json格式
//返回例子 {
// "namespace": "HDL",
// "command": "create_respond",
// "type": "scene",
// "objects": [{
// "scene_id": "0004",
// "name": "Away",
// "status": "single_off"
// }]
//}
//说明 创建场景
//5.1.16添加目标到场景
//请求参数
//{
// "namespace": "HDL",
// "command": "add_member",
// "type": "scene",
// "number": [{
// "scene_id": "0001",
// "objects": [{
// "sid": "00010019101209000025670100010001",
// "function": [{
// "attri": "switch",
//"data_type": "string ",
// "value": "on"
// }]
// }]
// }, {
// "scene_id": "0002",
// "objects": [{
// "sid": "00010019101209000025670200010001",
// "function": [{
// "attri": "brightness",
//"data_type": "int",
// "value": 50
// }]
// }]
// }]
//}
//返回值 json格式
//返回例子 {
// "namespace": "HDL",
// "command": "add_member_respond",
// "type": "scene",
// "scene_id": "0001",
// "value": "success"
//}
//说明 成功添加目标的场景列表
//5.1.17删除场景命令
//请求参数
//{
// "namespace": "HDL",
// "command": "delete",
// "type": "scene",
// "objects": [{
// "scene_id": "0001"
// }]
//}
//返回值 json格式
//返回例子 {
// "namespace": "HDL",
// "command": "delete_respond",
// "type": "scene",
// "scene_id": "0001",
// "value": "success"
//}
//说明 删除场景
//5.1.18删除场景里的目标
//请求参数
//{
// "Namespace": "HDL",
// "Command": "delete_member",
// "type": "scene",
// "number": [{
// "scene_id": "0001",
// "objects": [{
// "sid": "00010019101209000025670100010001"
// }, {
// "sid": "00010019101209000025670100010002"
// }]
// }]
//}
//返回值 json格式
//返回例子 {
// "namespace": "HDL",
// "command": "delete_member_respond",
// "type": "scene",
// "scenesid": "0001",
// "sid": "00010019101209000025670100010001",
// "value": "success"
//}
//说明 删除场景内设备
//5.1.19配置场景分组(足内场景状态自动记录最后一次记录)
//请求参数 {
// "namespace": "HDL",
// "command": "group",
// "type": "scene",
// "objects": [{
// "group_id": 1,
// "scene_ids": [{
// "scene_id": "0001"
// }, {
// "scene_id": "0002"
// }]
// }]
//}
//返回值 json格式
//返回例子 {
// "namespace": "HDL",
// "command": "group_respond",
// "type": "scene",
// "group_id": "0001",
// "value": "success"
//}
//说明 控制场景
//5.1.20读取场景分组
//请求参数
//{
// "namespace": "HDL",
// "command": "read_group",
// "type": "scene",
// "objects": [{
// "group_id": 1
// }]
//}
//返回值 json格式
//返回例子 {
// "namespace": "HDL",
// "command": "read_group_respond",
// "type": "scene",
// "objects": [{
// "group_id": 1,
// "scene_ids": [{
// "scene_id": "0001"
// }, {
// "scene_id": "0002"
// }]
// }]
//}
//说明 控制场景
//5.1.21控制场景
//请求参数
//{
// "namespace": "HDL",
// "command": "contrl",
// "type": "scene",
// "objects": [{
// "scene_id": "0001",
// "value": “on”
// }]
//}
//返回值 json格式
//返回例子 {
// "namespace": "HDL",
// "command": "contrl_respond",
// "type": "scene",
// "scene_id": "0001",
// "value": "success"
//}
//说明 控制场景