2021-12-12 06:55:48 +00:00
|
|
|
|
@model IoTGateway.ViewModel.BasicData.DeviceVariableVMs.DeviceVariableListVM
|
|
|
|
|
@inject IStringLocalizer<Program> Localizer;
|
|
|
|
|
|
|
|
|
|
<wt:treecontainer items="AllDevices" id-field="Searcher.DeviceId" height="500">
|
|
|
|
|
<wt:searchpanel vm="@Model" reset-btn="true">
|
|
|
|
|
<wt:row items-per-row="ItemsPerRowEnum.Three">
|
|
|
|
|
<wt:combobox field="Searcher.DeviceId" items="Searcher.AllDevices" empty-text="@Localizer["Sys.All"]" />
|
|
|
|
|
<wt:textbox field="Searcher.Name" />
|
|
|
|
|
<wt:textbox field="Searcher.Method" />
|
|
|
|
|
<wt:textbox field="Searcher.DeviceAddress" />
|
|
|
|
|
<wt:combobox field="Searcher.DataType" empty-text="@Localizer["Sys.All"]" />
|
|
|
|
|
</wt:row>
|
|
|
|
|
</wt:searchpanel>
|
2021-12-21 15:56:30 +00:00
|
|
|
|
<wt:grid vm="@Model" url="/BasicData/DeviceVariable/Search" hidden-grid-index="true" done-func="inimqttclient" />
|
2021-12-12 06:55:48 +00:00
|
|
|
|
</wt:treecontainer>
|
2021-12-21 15:56:30 +00:00
|
|
|
|
<link href="~/sitecss/animate.min.css" rel="stylesheet" />
|
|
|
|
|
<script src="~/mqtt.min.js" type="text/javascript"></script>
|
|
|
|
|
|
|
|
|
|
<script type="text/javascript">
|
|
|
|
|
function inimqttclient() {
|
|
|
|
|
var options = {
|
|
|
|
|
//mqtt客户端的id,这里面应该还可以加上其他参数,具体看官方文档
|
|
|
|
|
clientId: 'mqttjs_' + (Math.random() * 10000000).toString()
|
|
|
|
|
}
|
|
|
|
|
var client = mqtt.connect('ws://' + window.location.host + '/mqtt', options);
|
|
|
|
|
client.on('connect', function () {
|
|
|
|
|
client.subscribe('internal/v1/gateway/telemetry/+/+', function (err) {
|
|
|
|
|
if (!err) {
|
|
|
|
|
console.log("订阅成功!")
|
|
|
|
|
} else {
|
|
|
|
|
console.log(err)
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
client.on('message', function (topic, message) {
|
|
|
|
|
var objmsg = $.parseJSON(message.toString());
|
2021-12-24 06:22:45 +00:00
|
|
|
|
|
|
|
|
|
//原值
|
2021-12-21 15:56:30 +00:00
|
|
|
|
$('#id' + objmsg.VarId + '_Value').text(objmsg.Value);
|
2021-12-24 06:22:45 +00:00
|
|
|
|
$('#id' + objmsg.VarId + '_Value').addClass('animated bounceIn');
|
2021-12-22 05:54:59 +00:00
|
|
|
|
setTimeout(function(){
|
2021-12-24 06:22:45 +00:00
|
|
|
|
$('#id' + objmsg.VarId + '_Value').removeClass('bounceIn');
|
|
|
|
|
}, 1500);
|
2021-12-22 05:54:59 +00:00
|
|
|
|
|
2021-12-24 06:22:45 +00:00
|
|
|
|
//加工值
|
2021-12-21 15:56:30 +00:00
|
|
|
|
$('#id' + objmsg.VarId + '_CookedValue').text(objmsg.CookedValue);
|
2021-12-24 06:22:45 +00:00
|
|
|
|
$('#id' + objmsg.VarId + '_CookedValue').addClass('animated bounceIn');
|
2021-12-22 05:54:59 +00:00
|
|
|
|
setTimeout(function(){
|
2021-12-24 06:22:45 +00:00
|
|
|
|
$('#id' + objmsg.VarId + '_CookedValue').removeClass('bounceIn');
|
|
|
|
|
}, 1500);
|
|
|
|
|
|
|
|
|
|
//状态
|
2021-12-21 15:56:30 +00:00
|
|
|
|
$('#id' + objmsg.VarId + '_StatusType').text(objmsg.StatusType);
|
2021-12-24 06:22:45 +00:00
|
|
|
|
$('#id' + objmsg.VarId + '_StatusType').addClass('animated bounceIn');
|
2021-12-22 05:54:59 +00:00
|
|
|
|
setTimeout(function(){
|
2021-12-24 06:22:45 +00:00
|
|
|
|
$('#id' + objmsg.VarId + '_StatusType').removeClass('bounceIn');
|
|
|
|
|
}, 1500);
|
2021-12-21 15:56:30 +00:00
|
|
|
|
})
|
|
|
|
|
}
|
|
|
|
|
</script>
|