Former-commit-id: ae1372b2b197ff466da747549ff0c41028c380e9
Former-commit-id: ec30dad95dcd22d03762c1c9471a7d85b493890f
1.0
wanggang 5 years ago
parent 072dbecca4
commit 8072bf2e3e

@ -86,9 +86,6 @@ namespace IoT.Shared.Application.Models
[Display(Name = "设备数量")]
[IoTDataConfig(valueType: IoTValueType.Int)]
DeviceCount,
[IoTDataConfig(valueType:IoTValueType.Int)]
[Display(Name = "电量")]
Battery,
[IoTDataConfig(valueType: IoTValueType.Double,unit:"W")]
[Display(Name = "功率")]
Power,
@ -153,8 +150,11 @@ namespace IoT.Shared.Application.Models
[Display(Name = "PM1.0")]
PM10,
[IoTDataConfig(valueType: IoTValueType.Double)]
[Display(Name = "电池电量")]
Voltage,
[Display(Name = "电量")]
Battery,
[IoTDataConfig(valueType: IoTValueType.Int, enumValues: "正常,欠压")]
[Display(Name = "电压低")]
LowVoltage,
[Display(Name = "状态")]
[IoTDataConfig(valueType: IoTValueType.Int, enumValues: "关,开")]
PowerState,

@ -8,6 +8,7 @@ using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using System;
using System.Collections;
using System.Collections.Concurrent;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
@ -386,9 +387,9 @@ namespace IoTNode.DeviceServices.FBee
}
}
var battery = ms.ReadByte();
this.UpdateIoTData(device.Id, DataKeys.Battery, battery);
//this.UpdateIoTData(device.Id, DataKeys.Battery, battery/100f);
var epCount = ms.ReadByte();
this.UpdateIoTData(device.Id, DataKeys.EndPointCount, battery);
this.UpdateIoTData(device.Id, DataKeys.EndPointCount, epCount);
if (device.Name == "光强检测器")
{
@ -527,14 +528,11 @@ namespace IoTNode.DeviceServices.FBee
}
else if (clusterId == ClusterId.alarm)
{
var state = BitConverter.ToInt16(props[0x0080]);
this.UpdateIoTData(device.Id, DataKeys.Warning, state);
//var data2 = device.CreateData(Keys.UnderVoltage, new BitArray(props[0x0080])[3], DeviceDataType.Int, "低电量");
//device.AddorUpdateData(data2);
//var dto2 = data2.To<EditDataModel>();
//dto2.DeviceNumber = device.Number;
//dataList.Add(dto2);
var state = new BitArray(props[0x0080]);
var status = state[0] ? 1 : 0;
var voltage = state[3] ? 1 : 0;
this.UpdateIoTData(device.Id, DataKeys.Warning, status);
this.UpdateIoTData(device.Id, DataKeys.LowVoltage, voltage);
}
else if (clusterId == ClusterId.pm25)
{
@ -560,7 +558,14 @@ namespace IoTNode.DeviceServices.FBee
}
else if (clusterId == ClusterId.voltage)
{
this.UpdateIoTData(device.Id, DataKeys.Voltage, props[0x21][0] / 2f);
if (props.ContainsKey(0x0021))
{
this.UpdateIoTData(device.Id, DataKeys.Battery,Convert.ToInt32(props[0x21][0])/100f);
}
else if (props.ContainsKey(0x003e))
{
this.UpdateIoTData(device.Id, DataKeys.LowVoltage, Convert.ToInt32(props[0x003e]) == 1);
}
}
else if (clusterId == ClusterId.socket)
{
@ -1045,8 +1050,14 @@ namespace IoTNode.DeviceServices.FBee
{
this.UpdateIoTData(device.Id, DataKeys.PowerState, switchState);
}
else if(endpoint==0x0b)
{
//调色灯
this.UpdateIoTData(device.Id, DataKeys.PowerState, switchState);
}
else if (endpoint == 0x0e)
{
//窗帘电机
this.UpdateIoTData(device.Id, DataKeys.CurtainState, switchState);
}
else if (endpoint == 0x10)

@ -1,8 +1,9 @@
@{
HtmlTitle = "设备列表";
HtmlTitle = "设备列表"+ Infrastructure.Extensions.Helper.Instance.GetMacAddress();
}
<div class="row" title="@Infrastructure.Extensions.Helper.Instance.GetMacAddress()">
<button class="btn btn-info btn-sm" v-on:click="upload">上传数据</button>
<div class="row p-2">
<button class="btn btn-info btn-sm m-1" v-on:click="upload">上传数据</button>
<button class="btn btn-info btn-sm m-1" v-on:click="searchGateway">查找网关</button>
</div>
<div class="row">
<table class="table">
@ -22,7 +23,10 @@
<td>{{item.displayName}}</td>
<td>{{item.isOnline===true?"在线":"离线"}}</td>
<td>
<button v-if="item.ioTProduct.number.indexOf('fbee')!==-1" class="api ajax btn btn-info btn-sm" v-on:clikc="remove(item.gateway,number)">移除</button>
<template v-if="item.ioTProduct.number.indexOf('fbee')!==-1">
<button v-if="item.ioTProduct.number.indexOf('gateway')===-1" v-on:click="remove(item.gateway,item.number)" class="btn btn-info btn-sm">移除设备</button>
<button v-else v-on:click="searchDevice(item.number)" class="btn btn-info btn-sm">查询网关</button>
</template>
</td>
</tr>
</template>

@ -33,9 +33,23 @@
app.load();
});
},
searchGateway: function () {
if (confirm('确认查询全部网关吗?')) {
$.get(config.baseUrl + '/Gateway/Refresh', function () {
app.load();
});
};
},
searchDevice: function (number) {
if (confirm('确认查询网关吗?')) {
$.get(config.baseUrl + '/Gateway/X81?number='+number, function () {
app.load();
});
};
},
remove: function (gateway, number) {
if (confirm('确认操作编号为:' + 'number' + '的设备吗?')) {
$.get(config.baseUrl + '/Gateway/X95")' + '?gateway=' + gateway + '&number=' + number, function () {
if (confirm('确认从网关移除编号为:' + 'number' + '的设备吗?')) {
$.get(config.baseUrl + '/Gateway/X95?gateway=' + gateway + '&number=' + number, function () {
app.load();
});
};

@ -45,7 +45,7 @@
},
computed: {
status: function () {
var value = getDeviceDataValue(this.device, '状态');
var value = getIoTDataValue(this.device, '状态');
return value === '0' ? '关' :
(value === '1' ? '开' : '停');
}

@ -0,0 +1,39 @@
<template>
<div class="card device-component">
<div class="card-header">
<h3 class="card-title">
{{device.displayName}}
<i v-if="device.isOnline" class="text-success ion ion-ios-wifi"></i>
<i v-else class="text-danger ion ion-ios-wifi"></i>
</h3>
</div>
<div class="card-body">
<div class="row device-row">
<div class="col-4 align-self-center">
<img class="device-image" :src="device.ioTProduct.image" />
</div>
<div class="col-8 align-self-center">
<div class="row">
<span :class="cls">
{{status}}
</span>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
({
props: ['device'],
computed: {
status: function () {
return getIoTDataValue(this.device, '警报') === '1' ? '警报' : '正常';
},
cls: function () {
var cls = getIoTDataValue(this.device, '警报') === '0' ? 'status text-success' : 'status text-danger';
return cls;
}
}
});
</script>

@ -0,0 +1,44 @@
<template>
<div class="card device-component">
<div class="card-header">
<h3 class="card-title">
{{device.displayName}}
<i v-if="device.isOnline" class="text-success ion ion-ios-wifi"></i>
<i v-else class="text-danger ion ion-ios-wifi"></i>
</h3>
</div>
<div class="card-body">
<div class="row device-row">
<div class="col-4 align-self-center">
<img class="device-image" :src="device.ioTProduct.image" />
</div>
<div class="col-8 align-self-center">
<div class="row">
<span :class="cls">
{{status}} {{unit}} {{desc}}
</span>
</div>
</div>
</div>
</div>
</div>
</template>
<script>
({
props: ['device'],
computed: {
status: function () {
return getIoTDataValue(this.device, '光照度');
},
unit: function () {
return getIoTDataUnit(this.device, '光照度');
},
desc: function () {
return getIoTDataDescription(this.device, '光照度');
},
cls: function () {
return this.desc === '适中' ? 'status text-success' : 'status text-danger';
}
}
});
</script>

@ -14,11 +14,8 @@
</div>
<div class="col-8 align-self-center">
<div class="row">
<span>
状态:
<span class="status">
{{status}}
</span>
<span :class="cls">
{{status}}
</span>
</div>
</div>
@ -31,10 +28,11 @@
props: ['device'],
computed: {
status: function () {
return getDeviceDataValue(this.device, '状态') === '1' ? '警报' : '正常';
return getIoTDataValue(this.device, '警报') === '1' ? '警报' : '正常';
},
cls: function () {
return status === '警报' ? 'text-danger mx-2' : 'text-success';
var cls = getIoTDataValue(this.device, '警报') === '0' ? 'status text-success' : 'status text-danger';
return cls;
}
}
});

@ -58,16 +58,16 @@
},
computed: {
status: function () {
return getDeviceDataValue(this.device, '状态') === '1' ? '开' : '关';
return getIoTDataValue(this.device, '状态') === '1' ? '开' : '关';
},
isSmart: function () {
return Enumerable.from(this.device.data).any(function (o) { return o.name === "电量"; });
},
electricity: function () {
return parseFloat(getDeviceDataValue(this.device, '电量') || 0).toFixed(2);
return parseFloat(getIoTDataValue(this.device, '电量') || 0).toFixed(2);
},
power: function () {
return parseFloat(getDeviceDataValue(this.device, '功率') || 0).toFixed(2);
return parseFloat(getIoTDataValue(this.device, '功率') || 0).toFixed(2);
}
}
});

@ -90,19 +90,35 @@ router.beforeEach((to, from, next) => {
addVueComponents({
prefix: "/components/devices/",
list: [
'light',
'infrared',
'smoke',
'socket',
'curtain'
]
});
//获取设备数据
function getDeviceDataValue(device, name) {
function getIoTDataValue(device, name) {
var data = Enumerable.from(device.data).where(o => o.name === name).firstOrDefault();
if (data) {
return data['value'];
}
return null;
};
function getIoTDataUnit(device, name) {
var data = Enumerable.from(device.data).where(o => o.name === name).firstOrDefault();
if (data) {
return data['unit'];
}
return null;
}
function getIoTDataDescription(device, name) {
var data = Enumerable.from(device.data).where(o => o.name === name).firstOrDefault();
if (data) {
return data['description'];
}
return null;
}
//调用API
function execApi(number, method, query) {
loading.show();
@ -119,7 +135,7 @@ function execApi(number, method, query) {
//调用场景
function execScene(id) {
loading.show();
axios.post('/platform/api/v1/api/execScene', {id, connectionId})
axios.post('/platform/api/v1/api/execScene', { id, connectionId })
.then(function (response) {
console.log(response);
})

Loading…
Cancel
Save