using System;
|
using System.Collections.Generic;
|
using Shared;
|
using Shared.SimpleControl;
|
using Shared.SimpleControl.R;
|
using SmartHome;
|
|
namespace SuperGateWay
|
{
|
public class SelectedLogic : FrameLayout
|
{
|
public void Show (GateWay superGateWay, Logic logicedit)
|
{
|
MainPage.MainFrameLayout.RemoveViewByTag ("Logic");
|
Tag = "Logic";
|
|
|
this.AddChidren (new Button {
|
Height = Application.GetRealHeight (30),
|
BackgroundColor = 0xFF1f1f1f,
|
});
|
|
var topFrameLayout = new FrameLayout {
|
Height = Application.GetRealHeight (100),
|
Y = Application.GetRealHeight (30),
|
BackgroundColor = 0xFF1F1F1F,
|
};
|
AddChidren (topFrameLayout);
|
|
var hdl = new Button {
|
Width = Application.GetRealWidth (104),
|
Height = Application.GetRealHeight (32),
|
X = Application.GetRealWidth (530),
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = "Logo/Logo.png",
|
};
|
//if (superGateWay.Tag != "LogicEdit") {
|
// topFrameLayout.AddChidren (hdl);
|
//}
|
|
var titleName = new Button {
|
//Text = "时间条件",
|
TextID = MyInternationalizationString.Timecondition,
|
TextSize = 17,
|
};
|
topFrameLayout.AddChidren (titleName);
|
|
var back = new Button {
|
Width = Application.GetRealWidth (82),
|
Height = Application.GetRealHeight (89),
|
X = Application.GetRealWidth (10),
|
Gravity = Gravity.CenterVertical,
|
UnSelectedImagePath = "MusicIcon/HomepageBack.png",
|
};
|
if (logicedit.Tag == "true") {
|
topFrameLayout.AddChidren (back);
|
}
|
back.MouseDownEventHandler += (sender, e) => {
|
RemoveFromParent ();
|
|
};
|
|
var middle = new VerticalScrolViewLayout ();
|
middle.Y = topFrameLayout.Bottom;
|
middle.Height = Application.GetRealHeight (Application.DesignHeight - 130 - 80);
|
middle.BackgroundColor = 0xff2F2F2F;
|
this.AddChidren (middle);
|
|
var conditionRowLayout = new RowLayout {
|
Height = Application.GetRealHeight (100),
|
BackgroundColor = 0xff323232,
|
};
|
middle.AddChidren (conditionRowLayout);
|
///条件VerticalScrolViewLayout
|
var inputVerticalScrolViewLayout = new VerticalScrolViewLayout {
|
Height = 0,
|
BackgroundColor = 0xffffffff,
|
};
|
middle.AddChidren (inputVerticalScrolViewLayout);
|
conditionRowLayout.AddChidren (new Button {
|
Width = Application.GetRealWidth (200),
|
//Text = "条件",
|
TextID = MyInternationalizationString.condition,
|
TextSize = 16,
|
TextAlignment = TextAlignment.CenterLeft,
|
X = Application.GetRealWidth (40),
|
Gravity = Gravity.CenterVertical,
|
});
|
|
var conditionadd = new Button {
|
Width = Application.GetRealWidth (72),
|
Height = Application.GetRealHeight (58),
|
UnSelectedImagePath = "MusicIcon/add.png",
|
X = Application.GetRealWidth (525),
|
Gravity = Gravity.CenterVertical,
|
};
|
conditionRowLayout.AddChidren (conditionadd);
|
|
#region -----显示逻辑条件-----
|
inputVerticalScrolViewLayout.Height = Application.GetRealHeight (100 * (logicedit.input.Count + logicedit.time.Count));
|
for (int i = 0; i < logicedit.time.Count; i++) {
|
var s = logicedit.time [i];
|
var timerowLayout = new RowLayout {
|
Height = Application.GetRealHeight (100),
|
BackgroundColor = 0xff505050,
|
};
|
inputVerticalScrolViewLayout.AddChidren (timerowLayout);
|
|
///显示时间
|
var timevalue = new Button {
|
X = Application.GetRealWidth (40),
|
Width = Application.GetRealWidth (300),
|
TextAlignment = TextAlignment.CenterLeft,
|
Gravity = Gravity.CenterVertical,
|
Text = s,
|
//TextColor = 0xff121212,
|
};
|
timerowLayout.AddChidren (timevalue);
|
|
}
|
|
foreach (var deviceinput in logicedit.input) {
|
if (deviceinput.sid == null || deviceinput.sid == "") {
|
continue;
|
}
|
var tempSid = deviceinput.sid;
|
//判断SID是否有效的,如果不是有效的当前这个场景数据就不处理
|
Convert.ToUInt64 (tempSid, 16);
|
var sidUlong = Convert.ToUInt64 (tempSid, 16);
|
///1:设备;2:场景;3:逻辑;
|
var type = (byte)((sidUlong >> 60) & 0xF);
|
var statevalue = deviceinput.value.ToString ();
|
|
var inputrowLayout = new RowLayout {
|
Height = Application.GetRealHeight (100),
|
BackgroundColor = 0xff505050,
|
};
|
inputVerticalScrolViewLayout.AddChidren (inputrowLayout);
|
|
///显示设备名称
|
var devicename = new Button {
|
X = Application.GetRealWidth (40),
|
Width = Application.GetRealWidth (300),
|
TextAlignment = TextAlignment.CenterLeft,
|
Gravity = Gravity.CenterVertical,
|
//TextColor = 0xff121212,
|
};
|
inputrowLayout.AddChidren (devicename);
|
|
///显示设备条件状态控件
|
var devicestatus = new Button {
|
Width = Application.GetRealWidth (130),
|
Height = Application.GetRealHeight (100),
|
Gravity = Gravity.CenterVertical,
|
//TextColor = 0xff121212,
|
X = Application.GetRealWidth (500),
|
};
|
inputrowLayout.AddChidren (devicestatus);
|
|
switch (type) {
|
case 1: {
|
var subnetId = (byte)((sidUlong >> 40) & 0xFF);
|
var deviceId = (byte)((sidUlong >> 32) & 0xFF);
|
var targetType = (byte)((sidUlong >> 24) & 0xFF);
|
var property = (byte)((sidUlong >> 16) & 0xFF);
|
var targetNumber = (uint)((sidUlong >> 0) & 0xFFFF);
|
///用来判断为条件,查找当前设备;
|
var commonLoopID = subnetId + "_" + deviceId + "_" + targetNumber;
|
var Type = Logic.devicetype (targetType, property);
|
|
var commonDevice = superGateWay.Commons.Find ((obj) => obj.Type.ToString () == Type && obj.CommonLoopID == commonLoopID);
|
if (commonDevice == null) {
|
continue;
|
}
|
devicename.Text = commonDevice.Name;
|
|
try {
|
switch (commonDevice.Type) {
|
case DeviceType.CurtainModel: {
|
if (statevalue == "1") {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.open);
|
} else {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.close);
|
}
|
}
|
break;
|
case DeviceType.CurtainRoller: {
|
devicestatus.Text = statevalue + "%";
|
}
|
break;
|
case DeviceType.LightDimming: {
|
devicestatus.Text = statevalue + "%";
|
}
|
break;
|
case DeviceType.LightSwitch: {
|
if (statevalue == "1") {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.open);
|
} else {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.close);
|
}
|
|
}
|
break;
|
case DeviceType.HVAC: {
|
|
if (property == 0) {
|
|
if (statevalue == "1") {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.open);
|
} else {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.close);
|
}
|
|
} else if (property == 1) {
|
if (statevalue == "0") {
|
//制冷
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.Cool);
|
} else if (statevalue == "1") {
|
//制热
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.Heating);
|
} else if (statevalue == "2") {
|
//通风
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.Ventila);
|
} else if (statevalue == "3") {
|
//自动
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.Auto);
|
} else if (statevalue == "4") {
|
//抽湿
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.Dehumidify);
|
}
|
} else if (property == 3) {
|
//空调温度
|
devicestatus.Text = statevalue + "%";
|
} else if (property == 5) {
|
//环境温度
|
devicestatus.Text = statevalue + "%";
|
}
|
}
|
break;
|
case DeviceType.FoolHeat: {
|
if (property == 0) {
|
if (statevalue == "1") {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.open);
|
} else {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.close);
|
}
|
} else if (property == 2) {
|
devicestatus.Text = statevalue + "℃";
|
}
|
}
|
break;
|
case DeviceType.FreshAir: {
|
if (property == 0) {
|
if (statevalue == "1") {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.open);
|
} else {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.close);
|
}
|
} else if (property == 1) {
|
if (statevalue == "0") {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.Smart);
|
} else if (statevalue == "1") {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.FreshAir);
|
} else if (statevalue == "2") {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.InternalCirculation);
|
} else if (statevalue == "3") {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.ConstantTemp);
|
}
|
}
|
}
|
break;
|
case DeviceType.MechanicalSwitch: {
|
if (property == 0) {
|
if (statevalue == "1") {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.open);
|
} else {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.close);
|
}
|
}
|
}
|
break;
|
case DeviceType.AutomaticSwitch: {
|
if (property == 1) {
|
if (statevalue == "1") {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.singleclick);
|
} else if (statevalue == "2") {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.longpress);
|
} else if (statevalue == "3") {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.longpressrelease);
|
} else if (statevalue == "4") {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.doubleclick);
|
}
|
}
|
}
|
break;
|
case DeviceType.DryContact: {
|
if (property == 0) {
|
if (statevalue == "1") {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.open);
|
} else {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.close);
|
}
|
}
|
}
|
break;
|
case DeviceType.MusicModel: {
|
if (property == 0) {
|
if (statevalue == "1") {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.play);
|
} else if (statevalue == "2") {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.pause);
|
}
|
} else if (property == 1) {
|
//devicestatus.Text = Language.StringByID (MyInternationalizationString.close);
|
devicestatus.Text = statevalue + "%";
|
}
|
}
|
break;
|
case DeviceType.DoorLock: {
|
if (property == 0) {
|
if (statevalue == "1") {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.open);
|
} else {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.close);
|
}
|
} else if (property == 1) {
|
if (statevalue == "1") {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.low);
|
} else {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.normal);
|
}
|
} else if (property == 2) {
|
if (statevalue == "1") {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.trigger);
|
} else {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.nontrigger);
|
}
|
}
|
}
|
break;
|
case DeviceType.DoorLockID: {
|
if (property == 0) {
|
if (statevalue == "1") {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.trigger);
|
} else {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.nontrigger);
|
}
|
}
|
}
|
break;
|
case DeviceType.Sensor: {
|
if (property == 0) {
|
devicestatus.Text = statevalue + "℃";
|
} else if (property == 1) {
|
devicestatus.Text = statevalue + "%";
|
} else if (property == 5) {
|
int intvalue = 90;
|
intvalue = int.Parse (statevalue);
|
if (0 <= intvalue && intvalue < 60) {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.difference);
|
} else if (60 <= intvalue && intvalue < 75) {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.middle);
|
} else if (75 <= intvalue && intvalue <= 100) {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.excellent);
|
}
|
} else if (property == 10) {
|
int intvalue = 90;
|
intvalue = int.Parse (statevalue);
|
if (0 <= intvalue && intvalue < 60) {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.difference);
|
} else if (60 <= intvalue && intvalue < 75) {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.middle);
|
} else if (75 <= intvalue && intvalue <= 100) {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.excellent);
|
}
|
}
|
}
|
break;
|
}
|
} catch { }
|
|
}
|
break;
|
case 3: {
|
var logic = superGateWay.Logics.Find ((obj) => obj.sid == tempSid);
|
if (logic == null) {
|
continue;
|
}
|
devicename.Text = logic.name;
|
if (statevalue == "1") {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.open1);
|
} else {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.disable);
|
}
|
|
}
|
break;
|
|
}
|
|
}
|
#endregion
|
|
var targetRowLayout = new RowLayout {
|
Height = Application.GetRealHeight (100),
|
BackgroundColor = 0xff323232,
|
};
|
middle.AddChidren (targetRowLayout);
|
///目标targetVerticalScrolViewLayout
|
var targetVerticalScrolViewLayout = new VerticalScrolViewLayout {
|
Height = 0,
|
BackgroundColor = 0xffffffff,
|
};
|
middle.AddChidren (targetVerticalScrolViewLayout);
|
|
var btntargettitle = new Button {
|
// Text = "执行目标",
|
TextSize = 16,
|
TextAlignment = TextAlignment.CenterLeft,
|
X = Application.GetRealWidth (40),
|
Gravity = Gravity.CenterVertical,
|
TextID = MyInternationalizationString.Implementationgoals,
|
};
|
targetRowLayout.AddChidren (btntargettitle);
|
|
var btntargetadd = new Button {
|
Width = Application.GetRealWidth (72),
|
Height = Application.GetRealHeight (58),
|
UnSelectedImagePath = "MusicIcon/add.png",
|
X = Application.GetRealWidth (525),
|
Gravity = Gravity.CenterVertical,
|
};
|
targetRowLayout.AddChidren (btntargetadd);
|
|
#region ----显示执行目标----
|
foreach (var deviceoutput in logicedit.output) {
|
targetVerticalScrolViewLayout.Height = Application.GetRealHeight (100 * deviceoutput.objects.Count);
|
foreach (var device in deviceoutput.objects) {
|
if (!device.ContainsKey ("sid")) {
|
continue;
|
}
|
var tempSid = device ["sid"]?.ToString ();
|
if (tempSid == "") {
|
continue;
|
}
|
//判断SID是否有效的,如果不是有效的当前这个场景数据就不处理
|
Convert.ToUInt64 (tempSid, 16);
|
var sidUlong = Convert.ToUInt64 (tempSid, 16);
|
///1:设备;2:场景;3:逻辑;
|
var type = (byte)((sidUlong >> 60) & 0xF);
|
string delay = "";
|
string statevalue = "";
|
if (device.ContainsKey ("value")) {
|
statevalue = device ["value"]?.ToString ();
|
}
|
if (device.ContainsKey ("delay")) {
|
delay = device ["delay"]?.ToString ();
|
}
|
|
var inputrowLayout = new RowLayout {
|
Height = Application.GetRealHeight (100),
|
BackgroundColor = 0xff505050,
|
};
|
targetVerticalScrolViewLayout.AddChidren (inputrowLayout);
|
|
var devicename = new Button {
|
// Text = device.Name,
|
X = Application.GetRealWidth (40),
|
Width = Application.GetRealWidth (300),
|
TextAlignment = TextAlignment.CenterLeft,
|
Gravity = Gravity.CenterVertical,
|
//TextColor = 0xff121212,
|
};
|
inputrowLayout.AddChidren (devicename);
|
|
var btndelay = new Button {
|
Width = Application.GetRealWidth (150),
|
Height = Application.GetRealHeight (50),
|
X = Application.GetRealWidth (300),
|
Y = Application.GetRealHeight (25),
|
TextAlignment = TextAlignment.Center,
|
TextColor = 0xffcccccc,
|
};
|
inputrowLayout.AddChidren (btndelay);
|
|
|
|
|
if (delay != "" && delay != "0") {
|
var l = int.Parse (delay) / 10;
|
btndelay.Text = l.ToString () + "s";
|
}
|
|
///显示设备状态控件
|
var devicestatus = new Button {
|
Width = Application.GetRealWidth (130),
|
Height = Application.GetRealHeight (100),
|
Gravity = Gravity.CenterVertical,
|
//TextColor = 0xff121212,
|
X = Application.GetRealWidth (500),
|
};
|
inputrowLayout.AddChidren (devicestatus);
|
|
|
|
switch (type) {
|
case 1: {
|
var subnetId = (byte)((sidUlong >> 40) & 0xFF);
|
var deviceId = (byte)((sidUlong >> 32) & 0xFF);
|
var targetType = (byte)((sidUlong >> 24) & 0xFF);
|
var property = (byte)((sidUlong >> 16) & 0xFF);
|
var targetNumber = (uint)((sidUlong >> 0) & 0xFFFF);
|
///用来判断为条件,查找当前设备;
|
var commonLoopID = subnetId + "_" + deviceId + "_" + targetNumber;
|
var Type = Logic.devicetype (targetType, property);
|
|
var commonDevice = superGateWay.Commons.Find ((obj) => obj.Type.ToString () == Type && obj.CommonLoopID == commonLoopID);
|
if (commonDevice == null) {
|
continue;
|
}
|
devicename.Text = commonDevice.Name;
|
|
try {
|
switch (commonDevice.Type) {
|
case DeviceType.CurtainModel: {
|
if (statevalue == "1") {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.open);
|
} else {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.close);
|
}
|
}
|
break;
|
case DeviceType.CurtainRoller: {
|
devicestatus.Text = statevalue + "%";
|
}
|
break;
|
case DeviceType.LightDimming: {
|
devicestatus.Text = statevalue + "%";
|
}
|
break;
|
case DeviceType.LightSwitch: {
|
if (statevalue == "1") {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.open);
|
} else {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.close);
|
}
|
|
}
|
break;
|
case DeviceType.HVAC: {
|
|
if (property == 0) {
|
|
if (statevalue == "1") {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.open);
|
} else {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.close);
|
}
|
|
} else if (property == 1) {
|
if (statevalue == "0") {
|
//制冷
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.Cool);
|
} else if (statevalue == "1") {
|
//制热
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.Heating);
|
} else if (statevalue == "2") {
|
//通风
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.Ventila);
|
} else if (statevalue == "3") {
|
//自动
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.Auto);
|
} else if (statevalue == "4") {
|
//抽湿
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.Dehumidify);
|
}
|
} else if (property == 3) {
|
//空调温度
|
devicestatus.Text = statevalue + "%";
|
} else if (property == 5) {
|
//环境温度
|
devicestatus.Text = statevalue + "%";
|
}
|
}
|
break;
|
case DeviceType.FoolHeat: {
|
if (property == 0) {
|
if (statevalue == "1") {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.open);
|
} else {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.close);
|
}
|
} else if (property == 2) {
|
devicestatus.Text = statevalue + "℃";
|
}
|
}
|
break;
|
case DeviceType.FreshAir: {
|
if (property == 0) {
|
if (statevalue == "1") {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.open);
|
} else {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.close);
|
}
|
} else if (property == 1) {
|
if (statevalue == "0") {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.Smart);
|
} else if (statevalue == "1") {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.FreshAir);
|
} else if (statevalue == "2") {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.InternalCirculation);
|
} else if (statevalue == "3") {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.ConstantTemp);
|
}
|
}
|
}
|
break;
|
case DeviceType.MechanicalSwitch: {
|
if (property == 0) {
|
if (statevalue == "1") {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.open);
|
} else {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.close);
|
}
|
}
|
}
|
break;
|
case DeviceType.AutomaticSwitch: {
|
if (property == 1) {
|
if (statevalue == "1") {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.singleclick);
|
} else if (statevalue == "2") {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.longpress);
|
} else if (statevalue == "3") {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.longpressrelease);
|
} else if (statevalue == "4") {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.doubleclick);
|
}
|
}
|
}
|
break;
|
case DeviceType.DryContact: {
|
if (property == 0) {
|
if (statevalue == "1") {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.open);
|
} else {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.close);
|
}
|
}
|
}
|
break;
|
case DeviceType.MusicModel: {
|
if (property == 0) {
|
if (statevalue == "1") {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.play);
|
} else if (statevalue == "2") {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.pause);
|
}
|
} else if (property == 1) {
|
//devicestatus.Text = Language.StringByID (MyInternationalizationString.close);
|
devicestatus.Text = statevalue + "%";
|
}
|
}
|
break;
|
case DeviceType.DoorLock: {
|
if (property == 0) {
|
if (statevalue == "1") {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.open);
|
} else {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.close);
|
}
|
} else if (property == 1) {
|
if (statevalue == "1") {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.low);
|
} else {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.normal);
|
}
|
} else if (property == 2) {
|
if (statevalue == "1") {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.trigger);
|
} else {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.nontrigger);
|
}
|
}
|
}
|
break;
|
case DeviceType.DoorLockID: {
|
if (property == 0) {
|
if (statevalue == "1") {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.trigger);
|
} else {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.nontrigger);
|
}
|
}
|
}
|
break;
|
case DeviceType.Sensor: {
|
if (property == 0) {
|
devicestatus.Text = statevalue + "℃";
|
} else if (property == 1) {
|
devicestatus.Text = statevalue + "%";
|
} else if (property == 5) {
|
int intvalue = 90;
|
intvalue = int.Parse (statevalue);
|
if (0 <= intvalue && intvalue < 60) {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.difference);
|
} else if (60 <= intvalue && intvalue < 75) {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.middle);
|
} else if (75 <= intvalue && intvalue <= 100) {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.excellent);
|
}
|
} else if (property == 10) {
|
int intvalue = 90;
|
intvalue = int.Parse (statevalue);
|
if (0 <= intvalue && intvalue < 60) {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.difference);
|
} else if (60 <= intvalue && intvalue < 75) {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.middle);
|
} else if (75 <= intvalue && intvalue <= 100) {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.excellent);
|
}
|
}
|
}
|
break;
|
}
|
} catch { }
|
|
}
|
break;
|
case 2: {
|
var scene = superGateWay.Scenes.Find ((obj) => obj.sid == tempSid);
|
if (scene == null) {
|
continue;
|
}
|
devicename.Text = scene.name;
|
|
}
|
break;
|
case 3: {
|
var logic = superGateWay.Logics.Find ((obj) => obj.sid == tempSid);
|
if (logic == null) {
|
continue;
|
}
|
devicename.Text = logic.name;
|
if (statevalue == "1") {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.open1);
|
} else {
|
devicestatus.Text = Language.StringByID (MyInternationalizationString.disable);
|
}
|
|
|
}
|
break;
|
}
|
|
}
|
|
}
|
#endregion
|
|
var cyclerowlayout = new RowLayout {
|
Height = Application.GetRealHeight (100),
|
BackgroundColor = 0xff323232,
|
};
|
middle.AddChidren (cyclerowlayout);
|
///执行周期
|
var btncycle = new Button {
|
TextSize = 16,
|
//Text = "执行周期",
|
TextAlignment = TextAlignment.CenterLeft,
|
X = Application.GetRealWidth (40),
|
Width = Application.GetRealWidth (210),
|
Gravity = Gravity.CenterVertical,
|
TextID = MyInternationalizationString.cycle
|
};
|
cyclerowlayout.AddChidren (btncycle);
|
///显示周期时间
|
var btndisplaycycle = new Button {
|
TextAlignment = TextAlignment.CenterLeft,
|
X = Application.GetRealWidth (250),
|
Width = Application.GetRealWidth (300),
|
Gravity = Gravity.CenterVertical,
|
};
|
cyclerowlayout.AddChidren (btndisplaycycle);
|
///更新周期的方法
|
updateweek (btndisplaycycle,logicedit);
|
|
var btncycleback = new Button {
|
Width = Application.GetRealWidth (87),
|
Height = Application.GetRealHeight (100),
|
UnSelectedImagePath = "MusicIcon/Next.png",
|
SelectedImagePath = "MusicIcon/NextSelecte.png",
|
X = Application.GetRealWidth (525),//550
|
};
|
cyclerowlayout.AddChidren (btncycleback);
|
|
var btncomplete = new Button {
|
Height = Application.GetRealHeight (80),
|
Y = middle.Bottom,
|
TextID = MyInternationalizationString.complete,
|
TextSize = 16,
|
BackgroundColor = 0xff1f1f1f,
|
};
|
AddChidren (btncomplete);
|
btncomplete.MouseUpEventHandler += (sender, e) => {
|
var logicCommunalPage = new LogicCommunalPage ();
|
MainPage.MainFrameLayout.AddChidren (logicCommunalPage);
|
logicCommunalPage.Show (superGateWay, () => { });
|
|
};
|
|
}
|
|
void updateweek (Button btndisplaycycle, Logic logicedit)
|
{
|
btndisplaycycle.Text = "";
|
if (logicedit.date.ContainsKey ("type")) {
|
var type = logicedit.date ["type"]?.ToString ();
|
switch (type) {
|
case "week": {
|
//var weekvalue =Newtonsoft.Json.JsonConvert.DeserializeObject<List<int>>(Newtonsoft.Json.JsonConvert.SerializeObject(Logic.CurrentLogic.date ["week"]));
|
var weekvalue = Newtonsoft.Json.JsonConvert.DeserializeObject<int []> (Newtonsoft.Json.JsonConvert.SerializeObject (Logic.CurrentLogic.date ["week"]));
|
if (weekvalue != null) {
|
int a0 = Array.IndexOf (weekvalue, 0);
|
int a1 = Array.IndexOf (weekvalue, 1);
|
int a2 = Array.IndexOf (weekvalue, 2);
|
int a3 = Array.IndexOf (weekvalue, 3);
|
int a4 = Array.IndexOf (weekvalue, 4);
|
int a5 = Array.IndexOf (weekvalue, 5);
|
int a6 = Array.IndexOf (weekvalue, 6);
|
if (weekvalue.Length == 2 && a0 != -1 && a6 != -1) {
|
///周未
|
btndisplaycycle.Text = Language.StringByID (MyInternationalizationString.weekend);
|
} else if (weekvalue.Length == 5 && a1 != -1 && a2 != -1 && a3 != -1 && a4 != -1 && a5 != -1) {
|
///工作日
|
btndisplaycycle.Text = Language.StringByID (MyInternationalizationString.workingday);
|
} else {
|
for (int i = 0; i < 7; i++) {
|
int a = Array.IndexOf (weekvalue, i);
|
if (a != -1) {
|
if (i == 1) {
|
btndisplaycycle.Text += Language.StringByID (MyInternationalizationString.mon) + ",";
|
} else if (i == 2) {
|
btndisplaycycle.Text += Language.StringByID (MyInternationalizationString.tue) + ",";
|
} else if (i == 3) {
|
btndisplaycycle.Text += Language.StringByID (MyInternationalizationString.wed) + ",";
|
} else if (i == 4) {
|
btndisplaycycle.Text += Language.StringByID (MyInternationalizationString.thu) + ",";
|
} else if (i == 5) {
|
btndisplaycycle.Text += Language.StringByID (MyInternationalizationString.frl) + ",";
|
} else if (i == 6) {
|
btndisplaycycle.Text += Language.StringByID (MyInternationalizationString.sat) + ",";
|
} else if (i == 0) {
|
btndisplaycycle.Text += Language.StringByID (MyInternationalizationString.sun) + ",";
|
}
|
}
|
}
|
///排列星期顺序(1,2,3......)
|
//int b = Array.IndexOf (weekvalue, 0);
|
//if (b != -1) {
|
// btndisplaycycle.Text += Language.StringByID (MyInternationalizationString.sat) + ",";
|
//}
|
|
///去掉字符串最后符号
|
btndisplaycycle.Text = btndisplaycycle.Text.TrimEnd (',');
|
}
|
|
}
|
|
|
}
|
break;
|
case "day": {
|
var weekvalue = logicedit.date ["date"]?.ToString ();
|
btndisplaycycle.Text = weekvalue;
|
}
|
break;
|
case "every_day": {
|
btndisplaycycle.Text = Language.StringByID (MyInternationalizationString.everyday);
|
}
|
break;
|
case "every_month": {
|
var weekvalue =logicedit.date ["date"]?.ToString ();
|
var startvalue = weekvalue.Split ('-') [0].Split ('/') [2];
|
var endtvalue = weekvalue.Split ('-') [1].Split ('/') [2];
|
btndisplaycycle.Text = Language.StringByID (MyInternationalizationString.monthly) + startvalue + Language.StringByID (MyInternationalizationString.Number) + "-" + Language.StringByID (MyInternationalizationString.monthly) + endtvalue + Language.StringByID (MyInternationalizationString.Number);
|
}
|
break;
|
case "every_year": {
|
var weekvalue =logicedit.date ["date"]?.ToString ();
|
var startvalue = weekvalue.Split ('-') [0].Split ('/') [1] + "/" + weekvalue.Split ('-') [0].Split ('/') [2];
|
var endtvalue = weekvalue.Split ('-') [1].Split ('/') [1] + "/" + weekvalue.Split ('-') [1].Split ('/') [2];
|
btndisplaycycle.Text = startvalue + "-" + endtvalue;
|
|
}
|
break;
|
}
|
}
|
|
}
|
|
}
|
}
|