wxr
2020-09-11 8df24b0a3dfd5b6f39c5393ef24eab25b70ab858
202009111

1.修复房间创建保存
2.增加接收bus上传数据:开合帘、卷帘
14个文件已修改
825 ■■■■■ 已修改文件
.vs/HDL_APP_Project/xs/UserPrefs.xml 60 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL-ON_Android/Properties/AndroidManifest.xml 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/DriverLayer/CommonPage.cs 217 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/DriverLayer/Control.cs 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/DriverLayer/Control_Bus.cs 5 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/Entity/Function/AC.cs 4 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/Entity/Function/Function.cs 495 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/Entity/FunctionList.cs 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/UI/UI0-Public/PublicAssmebly.cs 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/UI/UI2/2-Classification/ClassificaitionPublicBLL.cs 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/UI/UI2/2-Classification/ClassificationPageBLL.cs 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/UI/UI2/2-Classification/FunctionPageBLL.cs 15 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/UI/UI2/4-PersonalCenter/RoomListManage/RoomEditPageBLL.cs 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
HDL_ON/UI/UI2/FuntionControlView/Light/DimmerPage.cs 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
.vs/HDL_APP_Project/xs/UserPrefs.xml
@@ -1,53 +1,20 @@
<Properties StartupConfiguration="{09712674-2A38-407B-B1E2-560B2C352F9A}|Default">
  <MonoDevelop.Ide.ItemProperties.HDL-ON__iOS automaticSigning="False" PreferredExecutionTarget="MonoDevelop.IPhone.IPhoneSimulatorTarget.61286FD1-B849-4457-AA51-F3CD79A395F6" />
  <MonoDevelop.Ide.Workbench ActiveDocument="HDL_ON/Entity/Function/Function.cs">
  <MonoDevelop.Ide.Workbench ActiveDocument="HDL_ON/Entity/FunctionList.cs">
    <Files>
      <File FileName="HDL_ON/DriverLayer/Control.cs" Line="107" Column="61" />
      <File FileName="HDL_ON/Entity/Enumerative/Command.cs" Line="1561" Column="21" />
      <File FileName="HDL_ON/UI/UI2/1-HomePage/HomePageBLL.cs" Line="160" Column="38" />
      <File FileName="HDL_ON/UI/UI2/3-Intelligence/IntelligencePage.cs" Line="392" Column="2" />
      <File FileName="HDL_ON/Entity/AProtocolEntity.cs" Line="10" Column="30" />
      <File FileName="HDL_ON/UI/UI2/FuntionControlView/AC/ACPageBLL.cs" Line="91" Column="35" />
      <File FileName="HDL_ON/UI/UI2/3-Intelligence/SceneEditPage.cs" Line="466" Column="60" />
      <File FileName="HDL_ON/UI/UI2/3-Intelligence/SetSceneFunctionInfoPage.cs" Line="150" Column="45" />
      <File FileName="HDL_ON/Entity/Function/Function.cs" Line="157" Column="32" />
      <File FileName="HDL_ON/DriverLayer/CommonPage.cs" Line="169" Column="67" />
      <File FileName="HDL_ON/Entity/Function/Light.cs" Line="91" Column="14" />
      <File FileName="HDL_ON/Entity/Function/AC.cs" Line="303" Column="17" />
      <File FileName="HDL_ON/Entity/Function/Curtain.cs" Line="26" Column="27" />
      <File FileName="HDL_ON/DAL/Net/TcpListener.cs" Line="215" Column="53" />
      <File FileName="HDL_ON/UI/UI0-Public/UpdataTcpResidenceDataDialog.cs" Line="47" Column="64" />
      <File FileName="HDL_ON/Entity/FunctionList.cs" Line="172" Column="44" />
    </Files>
    <Pads>
      <Pad Id="ProjectPad">
        <State name="__root__">
          <Node name="HDL_APP_Project" expanded="True">
            <Node name="HDL_ON" expanded="True">
              <Node name="DAL" expanded="True">
                <Node name="Net" expanded="True" />
                <Node name="Server" expanded="True" />
              </Node>
              <Node name="DriverLayer" expanded="True" />
              <Node name="Entity" expanded="True">
                <Node name="Enumerative" expanded="True" />
                <Node name="Function" expanded="True">
                  <Node name="Function.cs" selected="True" />
                </Node>
              </Node>
              <Node name="UI" expanded="True">
                <Node name="UI0-Public" expanded="True" />
                <Node name="UI1-Login" expanded="True" />
                <Node name="UI2" expanded="True">
                  <Node name="1-HomePage" expanded="True" />
                  <Node name="2-Classification" expanded="True" />
                  <Node name="3-Intelligence" expanded="True" />
                  <Node name="FuntionControlView" expanded="True">
                    <Node name="AC" expanded="True" />
                    <Node name="Curtain" expanded="True" />
                    <Node name="Electrical" expanded="True" />
                    <Node name="Light" expanded="True" />
                    <Node name="Music" expanded="True">
                      <Node name="View" expanded="True" />
                    </Node>
                  </Node>
                </Node>
              </Node>
            </Node>
            <Node name="HDL-ON_Android" expanded="True" />
            <Node name="HDL-ON_Android" selected="True" />
          </Node>
        </State>
      </Pad>
@@ -64,20 +31,15 @@
    <String>Shared.Droid.TouchID/Shared.Droid.TouchID.csproj</String>
    <String>Shared.IOS/Shared.IOS.csproj</String>
  </DisabledProjects>
  <MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" />
  <MonoDevelop.Ide.ItemProperties.HDL-ON__Android AndroidDesignerPreferredTheme="AppTheme" AndroidDesignerPreferredDevice="Nexus 4" PreferredExecutionTarget="Android.364c4b3158493098" />
  <MonoDevelop.Ide.Workspace ActiveConfiguration="Release|iPhone" />
  <MonoDevelop.Ide.ItemProperties.HDL-ON__Android AndroidDesignerPreferredTheme="AppTheme" AndroidDesignerPreferredDevice="Nexus 4" PreferredExecutionTarget="Android.SelectDevice" />
  <MonoDevelop.Ide.DebuggingService.Breakpoints>
    <BreakpointStore>
      <Breakpoint file="/Users/nigel/Desktop/HDL_APP_Project/HDL_ON/UI/UI2/FuntionControlView/Light/RGBPageBLL.cs" relfile="HDL_ON/UI/UI2/FuntionControlView/Light/RGBPageBLL.cs" line="115" column="1" />
      <Breakpoint file="/Users/nigel/Desktop/HDL_APP_Project/HDL_ON/DriverLayer/CommonPage.cs" relfile="HDL_ON/DriverLayer/CommonPage.cs" line="395" column="1" />
      <Breakpoint file="/Users/nigel/Desktop/HDL_APP_Project/HDL_ON/UI/UI2/FuntionControlView/FoolHeating/FloorHeatingPage.cs" relfile="HDL_ON/UI/UI2/FuntionControlView/FoolHeating/FloorHeatingPage.cs" line="351" column="1" />
      <Breakpoint file="/Users/nigel/Desktop/HDL_APP_Project/HDL_ON/UI/UI2/FuntionControlView/FoolHeating/FloorHeatingPage.cs" relfile="HDL_ON/UI/UI2/FuntionControlView/FoolHeating/FloorHeatingPage.cs" line="311" column="1" />
      <Breakpoint file="/Users/nigel/Desktop/HDL_APP_Project/HDL_ON/DriverLayer/CommonPage.cs" relfile="HDL_ON/DriverLayer/CommonPage.cs" line="414" column="1" />
      <Breakpoint file="/Users/nigel/Desktop/HDL_APP_Project/HDL_ON/UI/UI2/4-PersonalCenter/ResidentialManage/RoomEditPageBLL.cs" relfile="HDL_ON/UI/UI2/4-PersonalCenter/ResidentialManage/RoomEditPageBLL.cs" line="76" column="1" />
      <Breakpoint file="/Users/nigel/Desktop/HDL_APP_Project/HDL_ON/UI/UI2/3-Intelligence/SetSceneLocationPage.cs" relfile="HDL_ON/UI/UI2/3-Intelligence/SetSceneLocationPage.cs" line="38" column="1" />
      <Breakpoint file="/Users/nigel/Desktop/HDL_APP_Project/HDL_ON/UI/UI2/3-Intelligence/IntelligencePage.cs" relfile="HDL_ON/UI/UI2/3-Intelligence/IntelligencePage.cs" line="384" column="1" />
      <Breakpoint file="/Users/nigel/Desktop/HDL_APP_Project/HDL_ON/UI/UI2/3-Intelligence/SetSceneFunctionInfoPage.cs" relfile="HDL_ON/UI/UI2/3-Intelligence/SetSceneFunctionInfoPage.cs" line="504" column="1" />
      <Breakpoint file="/Users/nigel/Desktop/HDL_APP_Project/HDL_ON/UI/UI2/3-Intelligence/SetSceneFunctionInfoPage.cs" relfile="HDL_ON/UI/UI2/3-Intelligence/SetSceneFunctionInfoPage.cs" line="144" column="1" />
    </BreakpointStore>
  </MonoDevelop.Ide.DebuggingService.Breakpoints>
  <MultiItemStartupConfigurations />
HDL-ON_Android/Properties/AndroidManifest.xml
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="202009094" android:versionName="1.0.1.202009094" package="com.hdl.onpro">
<manifest xmlns:android="http://schemas.android.com/apk/res/android" android:versionCode="202009111" android:versionName="1.0.1.202009111" package="com.hdl.onpro">
    <uses-sdk android:minSdkVersion="23" android:targetSdkVersion="26" />
    <!--    定位权限-->
    <uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
HDL_ON/DriverLayer/CommonPage.cs
@@ -1,10 +1,8 @@
using System;
using System.Collections.Generic;
using System.Text;
using HDL_ON.DAL.Net;
using HDL_ON.Entity;
using HDL_ON.UI;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Shared;
using Shared.Net;
@@ -13,8 +11,6 @@
    public static class CommonPage
    {
        public static Action RefreshAir;
        public static string FindGatewayChilrenIPAddress = new NetWiFi().BroadcastIpAddress.ToString();
        private static string ip = "0.0.0.0";
        public static System.Net.IPEndPoint EndPoint
        {
            get
@@ -28,16 +24,6 @@
                    //防止异常导致程序退出
                    return new System.Net.IPEndPoint(System.Net.IPAddress.Parse("127.0.0.1"), 6000);
                }
            }
        }
        public static System.Net.IPEndPoint GetGatewayIP_EndPoint
        {
            get
            {
                //防止异常导致程序退出
                return new System.Net.IPEndPoint(System.Net.IPAddress.Parse("224.0.168.188"), 6688);
            }
        }
@@ -65,30 +51,6 @@
                }
            }
        }
        //public static bool isHttpListenerStart;
        //public static DateTime dt;
        //public static byte currentSubnetID = 0;
        //public static void InitHttpListener()
        //{
        //    if (isHttpListenerStart)
        //    {
        //        return;
        //    }
        //    Console.WriteLine("Init Http Listener !");
        //    HttpListener.Start(new NetWiFi().IpAddress, 6002);
        //    HttpListener.EventHandler -= httpListener_EventHandler;
        //    HttpListener.EventHandler += httpListener_EventHandler;
        //    isHttpListenerStart = true;
        //}
        //public static void CloseHttpListener()
        //{
        //    //isHttpListenerStart = false;
        //    //return;
        //    if (!isHttpListenerStart)
        //        return;
        //    HttpListener.Close();
        //    isHttpListenerStart = false;
        //}
        /// <summary>
        /// 初始化处理socket接收的数据 
        /// </summary>
@@ -117,65 +79,54 @@
                switch (command)
                {
                    case Command.SetSingleLightACK:
                        foreach (var light in DB_ResidenceData.functionList.lights)
                        var queryList = new List<Function>();
                        queryList.AddRange(DB_ResidenceData.functionList.electricals);
                        queryList.AddRange(DB_ResidenceData.functionList.lights);
                        foreach (var updataObj in queryList)
                        {
                            if (light.GetBusId() == subnetID + "_" + deviceID + "_" + receiveBytes[0])
                            if (updataObj.GetBusId() == subnetID + "_" + deviceID + "_" + receiveBytes[0])
                            {
                                if (light.functionType != FunctionType.RGB)
                                if (updataObj.functionType != FunctionType.RGB)
                                {
                                    light.trait_on_off.value = receiveBytes[2] == 0 ? "off" : "on";
                                    if (light.trait_on_off.value.ToString() == "on")
                                    var newState = receiveBytes[2] == 0 ? "off" : "on";
                                    if (updataObj.trait_on_off.value.ToString() == newState)
                                    {
                                        light.brightness = receiveBytes[2];
                                        light.lastState = Language.StringByID(StringId.Brightness) + " : " + receiveBytes[2] + "%";
                                        //状态一样,不用再刷新页面
                                        break;
                                    }
                                    HomePage.UpdataFunctionStates(light);
                                    RoomPage.UpdataStates(light);
                                    FunctionPage.UpdataStates(light);
                                    ClassificationPage.UpdataInfo(light);
                                    switch (light.functionType)
                                    if (updataObj.trait_on_off.value.ToString() == "on")
                                    {
                                        if (updataObj.functionType == FunctionType.Fan)
                                        {
                                            (updataObj as Fan).openLevel = receiveBytes[2];
                                            updataObj.lastState = Language.StringByID(StringId.Level) + " : " + receiveBytes[2];
                                        }
                                        else
                                        {
                                            (updataObj as Light).brightness = receiveBytes[2];
                                            updataObj.lastState = Language.StringByID(StringId.Brightness) + " : " + receiveBytes[2] + "%";
                                        }
                                    }
                                    HomePage.UpdataFunctionStates(updataObj);
                                    RoomPage.UpdataStates(updataObj);
                                    FunctionPage.UpdataStates(updataObj);
                                    ClassificationPage.UpdataInfo(updataObj);
                                    switch (updataObj.functionType)
                                    {
                                        case FunctionType.Relay:
                                            RelayPage.UpdataState(light);
                                            RelayPage.UpdataState(updataObj as Light);
                                            break;
                                        case FunctionType.Dimmer:
                                            DimmerPage.UpdataStates(light);
                                            DimmerPage.UpdataStates(updataObj as Light);
                                            break;
                                    }
                                }
                            }
                        }
                        foreach (var e in DB_ResidenceData.functionList.electricals)
                        {
                            if (e.GetBusId() == subnetID + "_" + deviceID + "_" + receiveBytes[0])
                            {
                                if (e.functionType == FunctionType.Fan)
                                {
                                    var fan = e as Fan;
                                    fan.trait_on_off.value = receiveBytes[2] == 0 ? "off" : "on";
                                    if (fan.trait_on_off.value == "on")
                                    {
                                        fan.openLevel = receiveBytes[2];
                                        fan.lastState = Language.StringByID(StringId.Level) + " : " + receiveBytes[2];
                                    }
                                    HomePage.UpdataFunctionStates(fan);
                                    RoomPage.UpdataStates(fan);
                                    FunctionPage.UpdataStates(fan);
                                    ClassificationPage.UpdataInfo(fan);
                                    switch (fan.functionType)
                                    {
                                        case FunctionType.Fan:
                                            FanPage.UpdataState(fan);
                                            break;
                                        case FunctionType.Socket:
                                            FanPage.UpdataState(updataObj as Fan);
                                            break;
                                    }
                                    break;
                                }
                            }
                        }
                        break;
                    case Command.ReadLightAllLoopBrightnessACK:
                        for (int i = 0; i < receiveBytes[0]; i++)
@@ -455,7 +406,6 @@
                    case Command.ReadDeviceLoopInfoACK:
                        FunctionType dt = (FunctionType)(11 * 256 + receiveBytes[1]);
                        string tag = receiveBytes[1] + "_" + subnetID + "_" + deviceID + "_" + receiveBytes[2];
                        foreach (var sensor in DB_ResidenceData.functionList.sensorsEnvironmentalScience)
                        {
                            if (sensor.bus_Data != null)
@@ -567,39 +517,6 @@
                                HomePage.UpdataFunctionStates(ac);
                                ClassificationPage.UpdataInfo(ac);
                                ACPage.UpdataStates(ac);
                                //else if (common.Type == DeviceType.FoolHeatPanel)
                                {
                                    //switch (receiveBytes[0])
                                    //{
                                    //    case 20://
                                    //        fh.Status = receiveBytes[1];
                                    //        break;
                                    //    case 21:
                                    //        fh.TemperatureType = receiveBytes[1];
                                    //        if (receiveBytes[1] == 5)
                                    //        {
                                    //            if (fh.Timer == 0)//时间模式的时间段标志 (0:白天,1:夜晚) (1byte)     //20110112加时间段标志
                                    //                Control.ControlBytesSend(Command.ReadInstructionPanelKey, fh.SubnetID, fh.DeviceID, new byte[] { 26, 2, fh.LoopID }, SendCount.Zero);
                                    //            else
                                    //                Control.ControlBytesSend(Command.ReadInstructionPanelKey, fh.SubnetID, fh.DeviceID, new byte[] { 27, 3, fh.LoopID }, SendCount.Zero);
                                    //        }
                                    //        else
                                    //            Control.ControlBytesSend(Command.ReadInstructionPanelKey, fh.SubnetID, fh.DeviceID, new byte[] { (byte)(receiveBytes[1] + 24), fh.LoopID }, SendCount.Zero);
                                    //        break;
                                    //    case 25:
                                    //        fh.NormalTemperature = receiveBytes[1];
                                    //        break;
                                    //    case 26:
                                    //        fh.DayTemperature = receiveBytes[1];
                                    //        break;
                                    //    case 27:
                                    //        fh.NightTemperature = receiveBytes[1];
                                    //        break;
                                    //    case 28:
                                    //        fh.AwayTemperature = receiveBytes[1];
                                    //        break;
                                    //}
                                }
                            }
                        }
                        break;
@@ -612,12 +529,6 @@
                                ac.indoorTemp = receiveBytes[1];
                                FunctionPage.UpdataStates(ac);
                            }
                            //else if (common.Type == DeviceType.FoolHeatPanel)
                            //    {
                            //        var tempFH22 = common as FoolHeatPanel;
                            //        tempFH22.IndoorTemperature = receiveBytes[1];
                            //        UserFHPage.UpdateIndoorTemp(tempFH22.CommonLoopID, receiveBytes[1]);
                            //    }
                        }
                        break;
                }
@@ -641,67 +552,5 @@
            }
            return s;//
        }
        /* 2020-09-01弃用,使用tcp接收数据
        static void httpListener_EventHandler(System.Collections.Specialized.NameValueCollection nameValueCollection, System.IO.Stream outputStream, System.IO.Stream inputStream)
        {
            try
            {
                if (nameValueCollection["Command"] != null && nameValueCollection["Command"].StartsWith("Get"))
                {
                    string tempFileName = nameValueCollection["Command"].Replace("Get", "");
                    if ("AllFiles" == tempFileName)
                    {
                        byte[] bytes = Encoding.UTF8.GetBytes(JsonConvert.SerializeObject(FileUtils.ReadFiles()));
                        outputStream.Write(bytes, 0, bytes.Length);
                        outputStream.Flush();
                    }
                    else
                    {
                        byte[] bytes;
                        if (!FileUtils.Exists(tempFileName))
                        {
                            bytes = Encoding.UTF8.GetBytes("文件名不存在!");
                            outputStream.Write(bytes, 0, bytes.Length);
                            outputStream.Flush();
                            return;
                        }
                        System.IO.FileStream fs = new System.IO.FileStream(Application.RootPath + tempFileName, System.IO.FileMode.Open);
                        bytes = new byte[fs.Length];
                        fs.Read(bytes, 0, bytes.Length);
                        fs.Close();
                        outputStream.Write(bytes, 0, bytes.Length);
                        outputStream.Flush();
                    }
                }
                else if (nameValueCollection["Command"].StartsWith("Upload"))
                {
                    string path = Application.RootPath + nameValueCollection["Command"].Replace("Upload", "");
                    string dePath = nameValueCollection["Command"].Replace("Upload", "");
                    FileUtils.WriteFileByInputStream(path, inputStream);
                    var reString = CommonPage.MyEncodingUTF8.GetString(FileUtils.ReadFile(path));
                    var common = JsonConvert.DeserializeObject<AProtocolEntity>(reString);
                    //Console.WriteLine(common.ToString());
                    if(dePath == "FunctionList")
                    {
                        foreach(var obj in common.objects)
                        {
                            DB_ResidenceData.functionList.AddFunction(obj);
                        }
                        DB_ResidenceData.functionList.GetAllFunction();
                    }
                }
                else
                {
                    byte[] bytes = System.Text.Encoding.UTF8.GetBytes("请求命令无效!");
                    outputStream.Write(bytes, 0, bytes.Length);
                    outputStream.Flush();
                }
            }
            catch (Exception ex)
            {
                MainPage.Log("httpListener_EventHandler" + ex.ToString());
            }
        }
        */
    }
}
HDL_ON/DriverLayer/Control.cs
@@ -219,7 +219,6 @@
                var deviceId = function.bus_Data.DeviceID;
                var loopId = function.bus_Data.LoopID;
                switch (function.functionCategory)
                {
                    case FunctionCategory.Light:
@@ -501,7 +500,7 @@
                        {
                            case FunctionType.Fan:
                                var fan = function as Fan;
                                ControlBytesSend(Command.SetSingleLightACK, subnetId, deviceId, new byte[] { fan.bus_Data.LoopID });
                                ControlBytesSend(Command.SetSingleLight, subnetId, deviceId, new byte[] { fan.bus_Data.LoopID });
                                break;
                        }
                        break;
@@ -510,7 +509,7 @@
                        {
                            case FunctionType.Socket:
                                var s = function as SwitchSocket;
                                ControlBytesSend(Command.SetSingleLightACK, subnetId, deviceId, new byte[] { s.bus_Data.LoopID });
                                ControlBytesSend(Command.SetSingleLight, subnetId, deviceId, new byte[] { s.bus_Data.LoopID });
                                break;
                        }
                        break;
HDL_ON/DriverLayer/Control_Bus.cs
@@ -1,14 +1,11 @@
using System;
using System.Collections.Generic;
using System.Net.Sockets;
using System.Text;
using HDL_ON.DAL;
using HDL_ON.DAL.Net;
using HDL_ON.Entity;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using Shared;
using Shared.Net;
namespace HDL_ON
{
@@ -816,7 +813,7 @@
                var sendJob = new JObject {{ "command", "search" } };
                var SearchGateway = JsonConvert.SerializeObject(sendJob);
                var SearchGatewayPayload = Encoding.ASCII.GetBytes(SearchGateway);
                Packet = new Packet(SearchGatewayPayload, CommonPage.GetGatewayIP_EndPoint);
                Packet = new Packet(SearchGatewayPayload, new System.Net.IPEndPoint(System.Net.IPAddress.Parse("224.0.168.188"), 6688));
                System.Threading.Thread thread = new System.Threading.Thread(new System.Threading.ParameterizedThreadStart(managerSendCount));
                thread.IsBackground = true;
                thread.Start(Packet);
HDL_ON/Entity/Function/AC.cs
@@ -1,8 +1,5 @@
using System;
using System.Collections;
using System.Collections.Generic;
using Newtonsoft.Json.Linq;
using Shared;
namespace HDL_ON.Entity
{
@@ -257,7 +254,6 @@
                return _trait_temp;
            }
        }
        Trait _trait_swting;
        [Newtonsoft.Json.JsonIgnore]
HDL_ON/Entity/Function/Function.cs
@@ -1,12 +1,253 @@
using System;
using System.Collections.Generic;
using System.Linq;
using Newtonsoft.Json.Linq;
using HDL_ON;
using Shared;
namespace HDL_ON.Entity
{
    /// <summary>
    /// 功能类能满足数据使用要求,子类只是为了方便使用属性
    /// </summary>
    public class Function
    {
        public Function()
        {
        }
        /// <summary>
        /// 数据存储文件名
        /// </summary>
        [Newtonsoft.Json.JsonIgnore]
        public string savePath
        {
            get
            {
                return "FunctionData_" + sid;
            }
        }
        #region base info
        /// <summary>
        /// HDL统一协议格式:14bytes
        /// 举例: 来源   厂商代码 通讯方式  产品时间戳   产品类别 物模型类  通道号   大小类别
        //       1byte    1byte    1byte      4byte        1byte    2byte   2byte   2byte
        /// 来源:00    默认原生态系统数据 、01    网关或者其他A设备、02    调试软件、03    APP应用程序、04    第三方网关或者平台
        /// 厂商代码:01    HDL
        /// 通讯方式:01    HDL Bus、02    Zigbee、03 KNX、04 Z-Wave
        /// 产品时间戳:4bytes    以2020年1月1日算出的时间戳0.1s为单位
        /// 产品类别:01    调光器、02 继电器、03    干接点模块、04    传感器、05 面板
        /// 物模型类型:
        ///     01    开关类:01 开关、02 插座、03
        ///     02    照明: 01 开关、02    调光、03    色温、04    LED
        ///     03    遮阳: 01    窗帘电机、02 百叶窗、03 开合帘、04 卷帘
        ///     04    恒温器:01 空调、02 地暖、03 毛细空调
        ///     05    新风
        ///     06    影音
        ///     07    音乐
        ///     08    能源
        ///     09    安防
        /// 大类别    1bytes    (预留)
        /// 小类别    1byte    (预留)
        /// </summary>
        public string sid = "0301011234567801012301230123";
        /// <summary>
        /// A协议功能的特性
        /// 如:是AC功能:特性:on_off,mode,fan,temperature
        /// attri
        /// </summary>
        public List<Trait> function = new List<Trait>();
        /// <summary>
        /// 房间ID列表
        /// 该功能添加到到房间列表
        /// </summary>
        public List<string> roomIdList = new List<string>();
        /// <summary>
        /// bus协议数据格式
        /// 使用A协议控制时,改属性为空
        /// </summary>
        public BusData bus_Data;
        /// <summary>
        /// 延时
        /// </summary>
        public int delay = 0;
        /// <summary>
        /// 延时显示的文本
        /// </summary>
        [Newtonsoft.Json.JsonIgnore]
        public string delayText
        {
            get
            {
                string text = "";
                switch (delay)
                {
                    case 0:
                        text = Language.StringByID(StringId.NoDelay);
                        break;
                    case 30:
                        text = "30s";
                        break;
                    case 60:
                        text = "1min";
                        break;
                    case 120:
                        text = "2min";
                        break;
                    case 300:
                        text = "5min";
                        break;
                }
                return text;
            }
        }
        #endregion
        /// <summary>
        /// 功能类别
        /// 如:空调类、灯光类、窗帘类
        /// </summary>
        public FunctionCategory functionCategory
        {
            get
            {
                try
                {
                    var _functionCategoryString = sid.Substring(16, 2);
                    var _functionCategory = Convert.ToInt32(_functionCategoryString, 16);
                    return (FunctionCategory)Enum.ToObject(typeof(FunctionCategory), _functionCategory);
                }
                catch (Exception ex)
                {
                    MainPage.Log($"get FunctionCategory error : {ex.Message}");
                    return FunctionCategory.UnKown;
                }
            }
        }
        public FunctionType functionType
        {
            get
            {
                var _functionTypeString = sid.Substring(16, 4);
                return (FunctionType)Enum.ToObject(typeof(FunctionType), Convert.ToInt32(_functionTypeString, 16));
            }
        }
        /// <summary>
        /// 备注
        /// </summary>
        public string name;
        /// <summary>
        /// 最后控制的一次状态
        /// </summary>
        [Newtonsoft.Json.JsonIgnore]
        public string lastState = "";
        Trait _trait_on_off;
        [Newtonsoft.Json.JsonIgnore]
        public Trait trait_on_off
        {
            get
            {
                if (_trait_on_off == null)
                {
                    _trait_on_off = function.Find((obj) => obj.name == "on_off");
                    //找不到属性需要声明一个,防止报错闪退
                    if (_trait_on_off == null)
                    {
                        _trait_on_off = new Trait()
                        {
                            name = "on_off",
                            value_key = new List<string> { "on", "off" },
                            max = 1,
                            min = 0,
                        };
                    }
                    _trait_on_off.value = "on";
                }
                return _trait_on_off;
            }
            //set
            //{
            //    _trait_on_off = value;
            //}
        }
        /// <summary>
        /// 是否收藏
        /// </summary>
        public bool collection = false;
        /// <summary>
        /// 使用次数
        /// </summary>
        public double usageCount = 0;
        /// <summary>
        /// 使用频率
        /// </summary>
        public double usageFrequency {
            get
            {
                return usageCount / 7;
            }
        }
        /// <summary>
        /// 固定的序号
        /// </summary>
        public int fixedSerialNumber = int.MaxValue;
        public string GetBusId ()
        {
            string busId = "";
            if (bus_Data != null)
            {
                busId = bus_Data.SubnetID + "_" + bus_Data.DeviceID + "_" + bus_Data.LoopID;
            }
            return busId;
        }
        /// <summary>
        /// 获取设备添加到房间的房间名称
        /// </summary>
        /// <returns></returns>
        public string GetRoomListName()
        {
            string roomNameList = "";
            foreach(var roomId in roomIdList)
            {
                var findRoom = DB_ResidenceData.rooms.Find(obj => obj.sid == roomId);
                if (findRoom == null)
                    continue;
                if(roomNameList != "")
                {
                    roomNameList += ",";
                }
                roomNameList += findRoom.floorName + findRoom.name;
            }
            if (roomNameList == "" && functionType == FunctionType.Scene)
            {
                roomNameList = Language.StringByID(StringId.WholeHouseScene);
            }
            return roomNameList;
        }
        /// <summary>
        /// 保存功能数据
        /// </summary>
        public void SaveFunctionData()
        {
            var ssd = System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(this));
            FileUtils.WriteFileByBytes("FunctionData_" + this.sid, ssd);
            MainPage.Log($"Save FunctionData {this.functionType} : {this.sid}");
        }
        /// <summary>
        /// 更新时间
        /// </summary>
        public DateTime refreshTime = DateTime.MinValue;
    }
    /// <summary>
    /// 功能属性
    /// 属性字段解析:attri :属性内容,value 属性的值,max 最大值 min 最小值
@@ -22,7 +263,8 @@
        /// 属性的值列表
        /// </summary>
        [Newtonsoft.Json.JsonIgnore]
        public List<string> value_key {
        public List<string> value_key
        {
            get
            {
                return _value_key;
@@ -62,12 +304,12 @@
        {
            get
            {
                if(!string.IsNullOrEmpty( _uintString))
                if (!string.IsNullOrEmpty(_uintString))
                {
                    return _uintString;
                }
                var us = "";
                switch(name)
                switch (name)
                {
                    case "temperature":
                        us = "°C";
@@ -327,245 +569,4 @@
        public string channels;
    }
    public class Function
    {
        public Function()
        {
        }
        /// <summary>
        /// 数据存储文件名
        /// </summary>
        [Newtonsoft.Json.JsonIgnore]
        public string savePath
        {
            get
            {
                return "FunctionData_" + sid;
            }
        }
        #region base info
        /// <summary>
        /// HDL统一协议格式:14bytes
        /// 举例: 来源   厂商代码 通讯方式  产品时间戳   产品类别 物模型类  通道号   大小类别
        //       1byte    1byte    1byte      4byte        1byte    2byte   2byte   2byte
        /// 来源:00    默认原生态系统数据 、01    网关或者其他A设备、02    调试软件、03    APP应用程序、04    第三方网关或者平台
        /// 厂商代码:01    HDL
        /// 通讯方式:01    HDL Bus、02    Zigbee、03 KNX、04 Z-Wave
        /// 产品时间戳:4bytes    以2020年1月1日算出的时间戳0.1s为单位
        /// 产品类别:01    调光器、02 继电器、03    干接点模块、04    传感器、05 面板
        /// 物模型类型:
        ///     01    开关类:01 开关、02 插座、03
        ///     02    照明: 01 开关、02    调光、03    色温、04    LED
        ///     03    遮阳: 01    窗帘电机、02 百叶窗、03 开合帘、04 卷帘
        ///     04    恒温器:01 空调、02 地暖、03 毛细空调
        ///     05    新风
        ///     06    影音
        ///     07    音乐
        ///     08    能源
        ///     09    安防
        /// 大类别    1bytes    (预留)
        /// 小类别    1byte    (预留)
        /// </summary>
        public string sid = "0301011234567801012301230123";
        /// <summary>
        /// A协议功能的特性
        /// 如:是AC功能:特性:on_off,mode,fan,temperature
        /// attri
        /// </summary>
        public List<Trait> function = new List<Trait>();
        /// <summary>
        /// 房间ID列表
        /// 该功能添加到到房间列表
        /// </summary>
        public List<string> roomIdList = new List<string>();
        /// <summary>
        /// bus协议数据格式
        /// 使用A协议控制时,改属性为空
        /// </summary>
        public BusData bus_Data;
        /// <summary>
        /// 延时
        /// </summary>
        public int delay = 0;
        /// <summary>
        /// 延时显示的文本
        /// </summary>
        [Newtonsoft.Json.JsonIgnore]
        public string delayText
        {
            get
            {
                string text = "";
                switch (delay)
                {
                    case 0:
                        text = Language.StringByID(StringId.NoDelay);
                        break;
                    case 30:
                        text = "30s";
                        break;
                    case 60:
                        text = "1min";
                        break;
                    case 120:
                        text = "2min";
                        break;
                    case 300:
                        text = "5min";
                        break;
                }
                return text;
            }
        }
        #endregion
        /// <summary>
        /// 功能类别
        /// 如:空调类、灯光类、窗帘类
        /// </summary>
        public FunctionCategory functionCategory
        {
            get
            {
                try
                {
                    var _functionCategoryString = sid.Substring(16, 2);
                    var _functionCategory = Convert.ToInt32(_functionCategoryString, 16);
                    return (FunctionCategory)Enum.ToObject(typeof(FunctionCategory), _functionCategory);
                }
                catch (Exception ex)
                {
                    MainPage.Log($"get FunctionCategory error : {ex.Message}");
                    return FunctionCategory.UnKown;
                }
            }
        }
        public FunctionType functionType
        {
            get
            {
                var _functionTypeString = sid.Substring(16, 4);
                return (FunctionType)Enum.ToObject(typeof(FunctionType), Convert.ToInt32(_functionTypeString, 16));
            }
        }
        /// <summary>
        /// 备注
        /// </summary>
        public string name;
        /// <summary>
        /// 最后控制的一次状态
        /// </summary>
        [Newtonsoft.Json.JsonIgnore]
        public string lastState = "";
        Trait _trait_on_off;
        [Newtonsoft.Json.JsonIgnore]
        public Trait trait_on_off
        {
            get
            {
                if (_trait_on_off == null)
                {
                    _trait_on_off = function.Find((obj) => obj.name == "on_off");
                    //找不到属性需要声明一个,防止报错闪退
                    if (_trait_on_off == null)
                    {
                        _trait_on_off = new Trait()
                        {
                            name = "on_off",
                            value_key = new List<string> { "on", "off" },
                            max = 1,
                            min = 0,
                        };
                    }
                    _trait_on_off.value = "on";
                }
                return _trait_on_off;
            }
            //set
            //{
            //    _trait_on_off = value;
            //}
        }
        /// <summary>
        /// 是否收藏
        /// </summary>
        public bool collection = false;
        /// <summary>
        /// 使用次数
        /// </summary>
        public double usageCount = 0;
        /// <summary>
        /// 使用频率
        /// </summary>
        public double usageFrequency {
            get
            {
                return usageCount / 7;
            }
        }
        /// <summary>
        /// 固定的序号
        /// </summary>
        public int fixedSerialNumber = int.MaxValue;
        public string GetBusId ()
        {
            string busId = "";
            if (bus_Data != null)
            {
                busId = bus_Data.SubnetID + "_" + bus_Data.DeviceID + "_" + bus_Data.LoopID;
            }
            return busId;
        }
        /// <summary>
        /// 获取设备添加到房间的房间名称
        /// </summary>
        /// <returns></returns>
        public string GetRoomListName()
        {
            string roomNameList = "";
            foreach(var roomId in roomIdList)
            {
                var findRoom = DB_ResidenceData.rooms.Find(obj => obj.sid == roomId);
                if (findRoom == null)
                    continue;
                if(roomNameList != "")
                {
                    roomNameList += ",";
                }
                roomNameList += findRoom.floorName + findRoom.name;
            }
            if (roomNameList == "" && functionType == FunctionType.Scene)
            {
                roomNameList = Language.StringByID(StringId.WholeHouseScene);
            }
            return roomNameList;
        }
        /// <summary>
        /// 保存功能数据
        /// </summary>
        public void SaveFunctionData()
        {
            var ssd = System.Text.Encoding.UTF8.GetBytes(Newtonsoft.Json.JsonConvert.SerializeObject(this));
            FileUtils.WriteFileByBytes("FunctionData_" + this.sid, ssd);
            MainPage.Log($"Save FunctionData {this.functionType} : {this.sid}");
        }
        /// <summary>
        /// 更新时间
        /// </summary>
        public DateTime refreshTime = DateTime.MinValue;
    }
}
HDL_ON/Entity/FunctionList.cs
@@ -168,6 +168,8 @@
                    sidObj2.SaveFunctionData();
                    break;
                case FunctionType.Curtain:
                case FunctionType.RollingShutter:
                case FunctionType.MotorCurtain:
                    var sidObj3 =  Newtonsoft.Json.JsonConvert.DeserializeObject<Curtain>(Newtonsoft.Json.JsonConvert.SerializeObject(sidObj0));
                    DB_ResidenceData.functionList.curtains.Add(sidObj3 );
                    sidObj3.SaveFunctionData();
HDL_ON/UI/UI0-Public/PublicAssmebly.cs
@@ -276,22 +276,12 @@
            };
            contentView.AddChidren(btnCancel);
            //Button btnBottomLine = new Button()
            //{
            //    X = btnCancel.Right,
            //    Y = btnLine.Bottom,
            //    Height = Application.GetRealHeight(43),
            //    Width = Application.GetRealWidth(1),
            //    BackgroundColor = CSS_Color.DividingLineColor,
            //};
            //contentView.AddChidren(btnBottomLine);
            Button btnConfirm = new Button()
            {
                X = btnCancel.Right,
                Y = btnLine.Y,
                Width = Application.GetRealWidth(135),
                Height = Application.GetRealHeight(43 + 1),
                Height = Application.GetRealHeight(45),
                TextAlignment = TextAlignment.Center,
                //TextColor = CSS_Color.TextualColor,
                TextSize = CSS_FontSize.SubheadingFontSize,
HDL_ON/UI/UI2/2-Classification/ClassificaitionPublicBLL.cs
@@ -35,7 +35,6 @@
                            return;
                        }
                    }
                    //if(updataFunction.roomIdList.Contains(Room))
                    for (int i = 0; i < scrolView.ChildrenCount; i++)
                    {
                        if (scrolView.GetChildren(i).Tag == null || scrolView.GetChildren(i).Tag.ToString() == "")
HDL_ON/UI/UI2/2-Classification/ClassificationPageBLL.cs
@@ -10,6 +10,8 @@
    {
        /// <summary>
        /// 更新界面信息
        /// 更新功能打开数量
        /// 更新全关功能状态
        /// </summary>
        /// <param name="function"></param>
        public static void UpdataInfo(Function function)
HDL_ON/UI/UI2/2-Classification/FunctionPageBLL.cs
@@ -5,26 +5,13 @@
    public partial class FunctionPage
    {
        /// <summary>
        /// 更新功能状态
        /// 更新功能列表界面功能状态
        /// </summary>
        /// <param name="function"></param>
        public static void UpdataStates(Function function)
        {
            new ClassificaitionPublicBLL().UpdataStates(function, bodyView, functionListView);
            UpdataOnCount(function.functionType);
        }
        static void UpdataOnCount(FunctionType functionType)
        {
            switch(functionType)
            {
                case FunctionType.AC:
                    break;
                case FunctionType.Curtain:
                    break;
            }
        }
    }
}
HDL_ON/UI/UI2/4-PersonalCenter/RoomListManage/RoomEditPageBLL.cs
@@ -25,7 +25,7 @@
        /// </summary>
        void LoadEvent_Option()
        {
            btnOption.MouseUpEventHandler += (sender, e) =>
            btnOption.MouseUpEventHandler = (sender, e) =>
            {
                if (btnOption.TextID == StringId.Save)
                {
@@ -58,6 +58,7 @@
                        }
                    }
                    DB_ResidenceData.rooms.Add(room);
                    room.SaveRoomData();
                    backAction();
                    this.RemoveFromParent();
                }
HDL_ON/UI/UI2/FuntionControlView/Light/DimmerPage.cs
@@ -158,7 +158,6 @@
                TextColor = CSS_Color.FirstLevelTitleColor,
                TextSize = CSS_FontSize.PromptFontSize_SecondaryLevel,
                Text = light.brightness + "%",
                BackgroundColor = 0xFF000FFF
            };
            controlView.AddChidren(btnBrightnessText);
@@ -232,7 +231,6 @@
                UnSelectedImagePath = "Public/PowerClose.png",
                SelectedImagePath = "Public/PowerOpen.png",
                IsSelected = light.trait_on_off.value.ToString() == "on",
                //Tag =
            };
            controlView.AddChidren(btnSwitch);