diff --git a/projects/IoT.Shared/Application/Models/ButtonModel.cs b/projects/IoT.Shared/Application/Models/ButtonModel.cs new file mode 100644 index 00000000..15fb209a --- /dev/null +++ b/projects/IoT.Shared/Application/Models/ButtonModel.cs @@ -0,0 +1,9 @@ +namespace Application.Models +{ + public class ButtonModel + { + public string Name { get; set; } + public string Value { get; set; } + public int Order { get; set; } + } +} \ No newline at end of file diff --git a/projects/IoTCenter/Views/Home/Device.cshtml b/projects/IoTCenter/Views/Home/Device.cshtml index 5487b8a4..86baef8b 100644 --- a/projects/IoTCenter/Views/Home/Device.cshtml +++ b/projects/IoTCenter/Views/Home/Device.cshtml @@ -343,10 +343,10 @@
-
+
温度:{{getCode1(GetDataValue('按键')).temperature+15}}℃
-
+
@@ -451,7 +451,7 @@
- +
@@ -473,15 +473,19 @@
- -
- + +
+
- -
+ +
+
+ +
+
diff --git a/projects/IoTCenter/Views/Home/Node.cshtml b/projects/IoTCenter/Views/Home/Node.cshtml index d5581c87..817e1654 100644 --- a/projects/IoTCenter/Views/Home/Node.cshtml +++ b/projects/IoTCenter/Views/Home/Node.cshtml @@ -404,18 +404,6 @@ -
-
-
-
- 温度 -
-
- -
-
-
-
风向 @@ -427,6 +415,14 @@
+
+
+ 温度:{{getCode1(GetDataValue(device.Number,'按键')).temperature+15}}℃ +
+
+ +
+
@@ -448,10 +444,6 @@ -
-
-
-
@@ -462,20 +454,12 @@ -
-
-
-
-
-
-
-
@@ -506,10 +490,6 @@ -
-
-
-
@@ -520,20 +500,12 @@ -
-
-
-
-
-
-
-
@@ -546,6 +518,16 @@
+
+ + + +
+
+ +
+
+
diff --git a/projects/IoTClient/Assets/StreamingAssets/wwwroot/js/device.js b/projects/IoTClient/Assets/StreamingAssets/wwwroot/js/device.js index 61b4191a..e1ab4f35 100644 --- a/projects/IoTClient/Assets/StreamingAssets/wwwroot/js/device.js +++ b/projects/IoTClient/Assets/StreamingAssets/wwwroot/js/device.js @@ -72,7 +72,7 @@ methods = { }, GetButtons() { return Enumerable.from(JSON.parse(this.GetDataValue("指令"))) - //.orderBy(function (o) { return o.Value; }) + .orderBy(function (o) { return o.Order; }) .toArray(); }, Study(code) { @@ -83,17 +83,17 @@ methods = { .where(function (o) { return o.Name === "指令" }) .firstOrDefault(); var buttons = this.GetButtons(); - var newBtn = { Key:"测试", Value:603}; + var newBtn = { Name:"测试", Value:"603",Order:1}; buttons.push(newBtn); data.Value = JSON.stringify(buttons); }, - RemoveButton(key) { + RemoveButton(name) { var data = Enumerable.from(this.model.Data) .where(function (o) { return o.Name === "指令" }) .firstOrDefault(); var buttons = this.GetButtons(); for (var i = buttons.length - 1; i >= 0; i--) { - if (buttons[i].Key == key) { + if (buttons[i].Name == name) { buttons.splice(i, 1); break; } @@ -104,8 +104,9 @@ methods = { var buttons = []; $('#irbuttons').find('.irbtn').each(function () { buttons.push({ - Key: $(this).find("input[name='key']").val(), - Value: $(this).find("input[name='value']").val() + Name: $(this).find("input[name='name']").val(), + Value: $(this).find("input[name='value']").val(), + Order: $(this).find("input[name='order']").val() }); }); var value = JSON.stringify(buttons); diff --git a/projects/IoTClient/Assets/StreamingAssets/wwwroot/js/node.js b/projects/IoTClient/Assets/StreamingAssets/wwwroot/js/node.js index 00c31628..d17f2598 100644 --- a/projects/IoTClient/Assets/StreamingAssets/wwwroot/js/node.js +++ b/projects/IoTClient/Assets/StreamingAssets/wwwroot/js/node.js @@ -69,6 +69,11 @@ methods = { ajax(url, null, 'get'); }); }, + GetButtons(deviceNumber) { + return Enumerable.from(JSON.parse(this.GetDataValue(deviceNumber,"指令"))) + .orderBy(function (o) { return o.Order; }) + .toArray(); + }, SendCode1(event) { console.log(event.target + ',' + event.type + ',' + event.target.checked); var form = $(event.target).parents('form'); diff --git a/projects/IoTClient/Assets/StreamingAssets/wwwroot/node.html b/projects/IoTClient/Assets/StreamingAssets/wwwroot/node.html index 109e4d19..d87c3068 100644 --- a/projects/IoTClient/Assets/StreamingAssets/wwwroot/node.html +++ b/projects/IoTClient/Assets/StreamingAssets/wwwroot/node.html @@ -485,6 +485,16 @@ +
+ + + +
+
+ +
+
+
diff --git a/projects/IoTNode/DeviceServices/FBee/FBeeService.cs b/projects/IoTNode/DeviceServices/FBee/FBeeService.cs index f3e109a2..3c447cca 100644 --- a/projects/IoTNode/DeviceServices/FBee/FBeeService.cs +++ b/projects/IoTNode/DeviceServices/FBee/FBeeService.cs @@ -66,7 +66,7 @@ namespace IoTNode.DeviceServices.FBee var data = device.Data.FirstOrDefault(o => o.Key == Keys.Buttons); if (data != null) { - data.Value = buttons.FromJson>>().ToJson(); + data.Value = buttons.FromJson>().ToJson(); if (deviceRepo.SaveChanges() > 0) { this.SendDataToServer(data); @@ -519,7 +519,7 @@ namespace IoTNode.DeviceServices.FBee this.UpdateDevice(deviceRepo, device); if (device.Name == "红外转发器") { - var buttons = new List>() { new KeyValuePair("测试", 603) }.ToJson(); + var buttons = new List() { new ButtonModel { Name = "测试", Value = "603", Order = 0 } }.ToJson(); this.UpdateData(deviceRepo, device, device.CreateData(Keys.Buttons, buttons, DeviceDataType.String, "指令", timestamp: timestamp)); } }