智能照明系统APP-本地串口
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
LightingSystemApp-serial/.svn/pristine/df/df62712129ff53f5dd19451e1bd...

1300 lines
35 KiB

<template>
<view class="page">
<u-navbar back-text="设备调试" />
<view class="card">
<view class="title">待操作目标设备:<span style='color:#0082FF;margin-left: 10px;font-size: 16px;'>{{this.devicename}}</span></view>
<view class="u-flex u-row-between">
<u-field v-model="subdeviceid" label-width="0" placeholder="目标设备ID" disabled />
</view>
</view>
<view class="card" v-if='this.devicetype != 3'>
<view class="title">调光设备</view>
<view class="u-flex u-row-between">
<view class="input2 u-flex">
<my-input v-model="test_dimmer1" type="number" maxlength="3" placeholder="调光值" />
<text>%</text>
</view>
<view class="input2 u-flex">
<my-input v-model="test_dimmer2" type="number" maxlength="3" placeholder="调光值" />
<text>%</text>
</view>
<u-button type="primary" shape="circle" @click="setDimmer">设置</u-button>
</view>
</view>
<view class="card" v-if='this.devicetype != 3'>
<view class="title">时间表操作</view>
<view class="table">
<view class="tr th">
<view class="th" style="width: 80rpx" />
<view class="th" style="width: 60rpx">小时</view>
<view class="th" style="width: 60rpx">分钟</view>
<view class="th" style="width: 120rpx">调光比例</view>
<view class="th" style="width: 120rpx">色温比例</view>
</view>
<view>
<u-picker v-model="show" :params="params" mode="time" @confirm = 'pickerconfirm'></u-picker>
</view>
<view v-for="item in 6" :key="item" class="tr-item">
<view class="tr">
<view class="td" style="width: 80rpx">第{{item}}段</view>
<view class="border" />
<view class="td" style="width: 60rpx">
<my-input
v-model="timetable[item - 1].hour"
type="number"
maxlength="3"
@click="timesolt(item)"
/>
</view>
<view class="border" />
<view class="td" style="width: 60rpx">
<my-input
v-model="timetable[item - 1].minute"
type="number"
maxlength="3"
@click="timesolt(item)"
/>
</view>
<view class="border" />
<view class="td" style="width: 120rpx">
<my-input
v-model="timetable[item-1].dimmer"
type="number"
maxlength="3"
@input="checknumber"
/>
</view>
<view class="border" />
<view class="td" style="width: 120rpx">
<my-input
v-model="timetable[item-1].color"
type="number"
maxlength="3"
@input="checknumber"
/>
</view>
</view>
<view class="border" />
</view>
</view>
<view class="u-flex u-row-between" style="margin-top: 24rpx">
<view style="width: 300rpx" />
<u-button type="primary" shape="circle" @click="setTimetable">设置</u-button>
<u-button shape="circle" @click="getTimetable">读取</u-button>
</view>
</view>
<view class="card">
<view class="title">状态读取</view>
<u-checkbox-group
icon-size="32"
shape="circle"
style="justify-content: space-between;margin-bottom: 32rpx"
disabled
>
<u-checkbox v-if='this.devicetype == 1' v-model="status.test_error_checked1">
灯具故障</u-checkbox>
<u-checkbox v-if='this.devicetype == 1' v-model="status.test_error_checked2">
温度故障</u-checkbox>
</u-checkbox-group>
<view class="u-flex u-row-between" v-if='this.devicetype == 1 || (this.devicetype == 2 && this.deviceobj > 2)'>
<u-field v-model="status.test_dimmer1_read" label-width="0" placeholder="调光值1" disabled>
<text slot="right"></text>
</u-field>
<u-field v-model="status.test_dimmer2_read" label-width="0" placeholder="调光值2" disabled>
<text slot="right"></text>
</u-field>
</view>
<view class="u-flex u-row-between" style="margin-top: 20rpx" v-if='this.devicetype == 1|| (this.devicetype == 2 &&this.deviceobj == 1)'>
<u-field v-model="status.test_voltage" label-width="0" placeholder="电压" disabled>
<text slot="right"></text>
</u-field>
<u-field v-model="status.test_current" label-width="0" placeholder="电流" disabled>
<text slot="right"></text>
</u-field>
</view>
<view class="u-flex u-row-between" style="margin-top: 20rpx" v-if='this.devicetype == 2 && this.deviceobj == 2'>
<u-field v-model="status.test_voltageA" label-width="0" placeholder="A相电压" disabled>
<text slot="right">V</text>
</u-field>
<u-field v-model="status.test_currentA" label-width="0" placeholder="A相电流" disabled>
<text slot="right">A</text>
</u-field>
</view>
<view class="u-flex u-row-between" style="margin-top: 20rpx" v-if='this.devicetype == 2 && this.deviceobj == 2'>
<u-field v-model="status.test_voltageB" label-width="0" placeholder="B相电压" disabled>
<text slot="right">V</text>
</u-field>
<u-field v-model="status.test_currentB" label-width="0" placeholder="B相电流" disabled>
<text slot="right">A</text>
</u-field>
</view>
<view class="u-flex u-row-between" style="margin-top: 20rpx" v-if='this.devicetype == 2 && this.deviceobj == 2'>
<u-field v-model="status.test_voltageC" label-width="0" placeholder="C相电压" disabled>
<text slot="right">V</text>
</u-field>
<u-field v-model="status.test_currentC" label-width="0" placeholder="C相电流" disabled>
<text slot="right">A</text>
</u-field>
</view>
<view class="u-flex u-row-between" style="margin-top: 20rpx" v-if='this.devicetype == 2 &&(this.deviceobj == 3 || this.deviceobj == 4)'>
<u-field v-model="status.test_voltage" label-width="0" placeholder="输出电压" disabled>
<text slot="right">mV</text>
</u-field>
<u-field v-model="status.test_current" label-width="0" placeholder="输出电流" disabled>
<text slot="right">mA</text>
</u-field>
</view>
<view class="u-flex u-row-between" style="margin-top: 20rpx" v-if='this.devicetype == 2 &&(this.deviceobj == 3 || this.deviceobj == 4)'>
<u-field v-model="status.test_absorb_current" label-width="0" placeholder="吸收电流" disabled>
<text slot="right">mA</text>
</u-field>
</view>
<view class="u-flex u-row-between" style="margin-top: 20rpx" v-if='this.devicetype == 1|| (this.devicetype == 2 && (this.deviceobj == 1||this.deviceobj == 2))'>
<u-field v-model="status.test_active_power" label-width="0" placeholder="有功功率" disabled>
<text slot="right"></text>
</u-field>
<u-field v-model="status.test_temperature" label-width="0" placeholder="温度" disabled v-if='this.devicetype == 1'>
<text slot="right"></text>
</u-field>
</view>
<view class="u-flex u-row-between" v-if='this.devicetype == 3'>
<u-field v-if='this.deviceobj == 1' v-model="status.test_lluminancievalue_read" label-width="0" placeholder="照度值" disabled>
<text slot="right">lux</text>
</u-field>
<u-field v-if='this.deviceobj == 2' v-model="status.test_brightnessvalue_read" label-width="0" placeholder="亮度值" disabled>
<text slot="right">cd/m2</text>
</u-field>
<u-field v-if='this.deviceobj == 3' v-model="status.test_trafficvalue_read" label-width="0" placeholder="车流量值" disabled>
<text slot="right">辆/分</text>
</u-field>
</view>
<view class="u-flex u-row-between" style="margin-top: 20rpx;margin-left: 240px">
<u-button v-if='this.devicetype == 1' shape="circle" @click="getStatus">读取</u-button>
<u-button v-if='this.devicetype == 2' shape="circle" @click="getStatus">读取</u-button>
<u-button v-if='this.devicetype == 3' shape="circle" @click="getSensorvalue">读取</u-button>
</view>
</view>
<u-toast ref="uToast" />
<u-mask :show="commandmaskshow">
<view class="warp">
<view class="rect">
<view class="position">
<u-circle-progress active-color="#2979ff" :percent= progress>
<view class="u-progress-content">
<view class="u-progress-dot"></view>
<text class='u-progress-info'>执行中...</text>
</view>
</u-circle-progress>
</view>
<view class="readbtn">
<u-button type="warning" @click="stopcommand">终止执行</u-button>
</view>
</view>
</view>
</u-mask>
</view>
</template>
<script>
import myInput from "@/components/myInput";
import {
sendReadlampstatus,
receiveReadlampstatus,
sendReadloopstatus,
receiveReadloopstatus,
sendLampdimmer,
receiveLampdimmer,
setDeviceTimetable,
receivesetDeviceTimetable,
readDeviceTimetable,
receivereadDeviceTimetable,
readSensorvalue,
receivereadSensorvalue,
} from "@/common/network/equipment/protocol.js";
export default {
components: { myInput },
data() {
return {
show: false,
params: {
hour: true,
minute: true,
},
progress: 0,
commandmaskshow: false,
device: {},
subdeviceid: "",
devicetype:"",
devicename:'',
deviceobj:{},
test_dimmer1: "",
test_dimmer2: "",
intervalID: {
commandReceive: undefined,
commandOvertime: undefined,
},
timetablenum: 1,
timetable: [
{
time:'00:00',
hour:'',
minute:'',
dimmer: "",
color: "",
},
{
time:'00:00',
hour:'',
minute:'',
dimmer: "",
color: "",
},
{
time:'00:00',
hour:'',
minute:'',
dimmer: "",
color: "",
},
{
time:'00:00',
hour:'',
minute:'',
dimmer: "",
color: "",
},
{
time:'00:00',
hour:'',
minute:'',
dimmer: "",
color: "",
},
{
time:'00:00',
hour:'',
minute:'',
dimmer: "",
color: "",
}
],
timetable_list: [
{
time:'00:00',
dimmer: "0",
color: "0",
},
{
time:'00:00',
dimmer: "0",
color: "0",
},
{
time:'00:00',
dimmer: "0",
color: "0",
},
{
time:'00:00',
dimmer: "0",
color: "0",
},
{
time:'00:00',
dimmer: "0",
color: "0",
},
{
time:'00:00',
dimmer: "0",
color: "0",
}
],
test_version: "",
test_bps: 1,
test_direction: 1,
test_voltage: 1,
status: {
test_dimmer1_read: "",
test_dimmer2_read: "",
test_active_power: "",
test_voltage: "",
test_current: "",
test_absorb_current: "",
test_temperature: "",
test_switch: "",
test_voltageA: "",
test_currentA: "",
test_voltageB: "",
test_currentB: "",
test_voltageC: "",
test_currentC: "",
test_lluminancievalue_read: "",
test_brightnessvalue_read: "",
test_trafficvalue_read: "",
test_error_checked1: false,
test_error_checked2: false,
test_error_checked3: false,
},
lampstate:{
worktype:'',
controllstatus:'',
requeststatus:'',
temperature:'',
current:'',
voltage:'',
activepower:'',
dimmingvalue:'',
dimmingvalue1:'',
state:'',
lamperror:'',
temperatureerror:'',
clockerror:'',
},
};
},
created() {},
mounted() {},
methods: {
checknumber(e){
},
pickerconfirm(e){
if(this.timetablenum > 0 && this.timetablenum <= 6)
{
this.timetable[this.timetablenum - 1].hour = e.hour;
this.timetable[this.timetablenum - 1].minute = e.minute;
this.timetable[this.timetablenum - 1].time = e.hour+':'+e.minute;
}
},
timesolt(num){
this.timetablenum = num;
this.show = true;
},
setDimmer() {
if (
parseInt(this.test_dimmer1) >= 0 &&
parseInt(this.test_dimmer1) <= 100 &&
parseInt(this.test_dimmer2) >= 0 &&
parseInt(this.test_dimmer2) <= 100
)
{
let data = {
controlid: this.subdeviceccid,
comid: this.subdeviceid,
dimming1: parseInt(this.test_dimmer1),
dimming2: parseInt(this.test_dimmer2),
};
var that = this;
this.commandmaskshow = true;
this.intervalID.commandReceive = null;
this.intervalID.commandOvertime = null;
this.progress = 0;
sendLampdimmer(data)
.then((res) => {
//命令下发成功
if(res.successed == true)
{
that.commandid = res.data.commandid;
data.commandid = that.commandid;
if(that.intervalID.commandOvertime == null) {
that.intervalID.commandOvertime = setTimeout(() => {
that.$refs.uToast.show({
title: "命令超时",
type: "error",
icon: false,
});
clearInterval(that.intervalID.commandReceive);
that.intervalID.commandReceive = null;
that.intervalID.commandOvertime == null
that.commandmaskshow = false;
that.progress = 0;
}, 20000);
}
if(that.intervalID.commandReceive == null) {
that.intervalID.commandReceive = setInterval(() => {
that.progress += 5;
receiveLampdimmer(data)
.then((res) => {
debugger
if(res.successed == true)
{
this.$refs.uToast.show({
title: "调光值设置成功",
type: "success",
});
clearInterval(that.intervalID.commandOvertime);
clearInterval(that.intervalID.commandReceive);
that.intervalID.commandOvertime = null;
that.intervalID.commandReceive = null;
that.commandmaskshow = false;
that.progress = 0;
}
else{
if(res.message.indexOf('无应答') == -1){
this.$refs.uToast.show({
title: res.message,
type: "error",
icon: false,
});
clearInterval(that.intervalID.commandOvertime);
clearInterval(that.intervalID.commandReceive);
that.intervalID.dimmercommandOvertime = null;
that.intervalID.dimmercommandReceive = null;
that.commandmaskshow = false;
that.progress = 0;
}
}
})
.catch((err) => {
console.log(err);
this.$refs.uToast.show({
title: res.message,
type: "error",
icon: false,
});
clearInterval(that.intervalID.commandOvertime);
clearInterval(that.intervalID.commandReceive);
that.intervalID.commandOvertime = null;
that.intervalID.commandReceive = null;
that.commandmaskshow = false;
that.progress = 0;
});
}, 1000);
}
}
else{
var msg = res.message
that.commandmaskshow = false;
that.progress = 0;
that.$refs.uToast.show({
title: msg,
type: "error",
icon: false,
});
}
})
.catch((err) => {
console.log(err);
});
}
else
{
this.$refs.uToast.show({
title: "请输入0-100范围内的数字",
type: "warning",
icon: false,
});
}
},
getSensorvalue() {
debugger
let data = {
sensorid: this.subdeviceccid,
operation: '',
commandid: '',
};
if(this.deviceobj == '0001')//照度
{
data.operation = 'readsensorofillumination'
}
else if(this.deviceobj == '0002')//亮度
{
data.operation = 'readsensoroflight'
}
else//车流量
{
data.operation = 'readsensorofcar'
}
var that = this;
this.commandmaskshow = true;
this.intervalID.commandReceive = null;
this.intervalID.commandOvertime = null;
this.progress = 0;
readSensorvalue(data)
.then((res) => {
//命令下发成功
if(res.successed == true)
{
that.commandid = res.data.commandid;
data.commandid = that.commandid;
if(that.intervalID.commandOvertime == null) {
that.intervalID.commandOvertime = setTimeout(() => {
that.$refs.uToast.show({
title: "命令超时",
type: "error",
icon: false,
});
clearInterval(that.intervalID.commandReceive);
that.intervalID.commandReceive = null;
that.intervalID.commandOvertime == null
that.commandmaskshow = false;
that.progress = 0;
}, 20000);
}
if(that.intervalID.commandReceive == null) {
that.intervalID.commandReceive = setInterval(() => {
that.progress += 5;
receivereadSensorvalue(data)
.then((res) => {
if(res.successed == true)
{
let sensorvalue = res.data.value;
if(this.deviceobj == 1)//照度传感器
{
that.status.test_lluminancievalue_read = sensorvalue
}
else if(this.deviceobj == 2)//亮度传感器
{
that.status.test_brightnessvalue_read = sensorvalue
}
else//车流量传感器
{
that.status.test_trafficvalue_read = sensorvalue
}
clearInterval(that.intervalID.commandOvertime);
clearInterval(that.intervalID.commandReceive);
that.intervalID.commandOvertime = null;
that.intervalID.commandReceive = null;
that.commandmaskshow = false;
that.progress = 0;
}
})
.catch((err) => {
console.log(err);
clearInterval(that.intervalID.commandOvertime);
clearInterval(that.intervalID.commandReceive);
that.intervalID.commandOvertime = null;
that.intervalID.commandReceive = null;
that.commandmaskshow = false;
that.progress = 0;
});
}, 1000);
}
}
else{
that.commandmaskshow = false;
that.progress = 0;
that.$refs.uToast.show({
title: res.message,
type: "error",
icon: false,
});
}
})
.catch((err) => {
console.log(err);
});
},
getTimetable() {
let data = {
controlid: this.subdeviceccid,
type:'control',
commandid: '',
};
if(this.devicetype == '1')//灯杆
{
data.type = 'control'
}
else if(this.devicetype == '2')//回路
{
data.type = 'mcontrol'
}
var that = this;
this.commandmaskshow = true;
this.intervalID.commandReceive = null;
this.intervalID.commandOvertime = null;
this.progress = 0;
readDeviceTimetable(data)
.then((res) => {
debugger
//命令下发成功
if(res.successed == true)
{
that.commandid = res.data.commandid;
data.commandid = that.commandid;
if(that.intervalID.commandOvertime == null) {
that.intervalID.commandOvertime = setTimeout(() => {
that.$refs.uToast.show({
title: "命令超时",
type: "error",
icon: false,
});
clearInterval(that.intervalID.commandReceive);
that.intervalID.commandReceive = null;
that.intervalID.commandOvertime == null
that.commandmaskshow = false;
that.progress = 0;
}, 20000);
}
if(that.intervalID.commandReceive == null) {
that.intervalID.commandReceive = setInterval(() => {
that.progress += 5;
receivereadDeviceTimetable(data)
.then((res) => {
debugger
if(res.successed == true)
{
if (res.data.length > 0) {
if(res.data.length == 6)
{
for(var i = 0; i < 6;i ++)
{
this.timetable[i].color = res.data[i].color
this.timetable[i].dimmer = res.data[i].dimmer
this.timetable[i].hour = res.data[i].hour
this.timetable[i].minute = res.data[i].minute
}
}
}
else {
that.$refs.uToast.show({
title: "数据为空",
type: "error",
icon: false,
});
}
clearInterval(that.intervalID.commandOvertime);
clearInterval(that.intervalID.commandReceive);
that.intervalID.commandOvertime = null;
that.intervalID.commandReceive = null;
that.commandmaskshow = false;
that.progress = 0;
}
})
.catch((err) => {
console.log(err);
clearInterval(that.intervalID.commandOvertime);
clearInterval(that.intervalID.commandReceive);
that.intervalID.commandOvertime = null;
that.intervalID.commandReceive = null;
that.commandmaskshow = false;
that.progress = 0;
});
}, 1000);
}
}
else{
var indexstart = res.indexOf("info")
var indexend = res.indexOf("!")
var msg1 = res.substring(indexstart+6,indexend+1)
that.commandmaskshow = false;
that.progress = 0;
that.$refs.uToast.show({
title: msg1,
type: "error",
icon: false,
});
}
})
.catch((err) => {
console.log(err);
});
},
setTimetable() {
let isNumber = true;
for (var i=0; i<6; i++) {
if ((this.timetable[i].dimmer <= 100) &&(this.timetable[i].color <= 100)) {
if(this.timetable[i].dimmer == '')
{
this.timetable_list[i].dimmer = 0;
}
else
{
this.timetable_list[i].dimmer = this.timetable[i].dimmer;
}
if(this.timetable[i].color == '')
{
this.timetable_list[i].color = 0;
}
else
{
this.timetable_list[i].color = this.timetable[i].color;
}
;
this.timetable_list[i].time = this.timetable[i].time;
}
else{
isNumber = false;
}
}
if (isNumber) {
let data = {
controlid: "",
type: "control",
timeList: [],
};
data.timeList = JSON.stringify(this.timetable_list);
if(this.devicetype == '1')//灯杆
{
data.controlid = this.subdeviceccid
data.type = 'control'
}
else if(this.devicetype == '2')//回路
{
data.controlid = this.subdeviceccid
data.type = 'mcontrol'
}
var that = this;
this.commandmaskshow = true;
this.intervalID.commandReceive = null;
this.intervalID.commandOvertime = null;
this.progress = 0;
setDeviceTimetable(data)
.then((res) => {
//命令下发成功
if(res.successed == true)
{
that.commandid = res.data.commandid;
data.commandid = that.commandid;
if(that.intervalID.commandOvertime == null) {
that.intervalID.commandOvertime = setTimeout(() => {
that.$refs.uToast.show({
title: "命令超时",
type: "error",
icon: false,
});
clearInterval(that.intervalID.commandReceive);
that.intervalID.commandReceive = null;
that.intervalID.commandOvertime == null
that.commandmaskshow = false;
that.progress = 0;
}, 20000);
}
if(that.intervalID.commandReceive == null) {
that.intervalID.commandReceive = setInterval(() => {
that.progress += 5;
receivesetDeviceTimetable(data)
.then((res) => {
if(res.successed == true)
{
that.$refs.uToast.show({
title: "时间表设置成功",
type: "success",
});
clearInterval(that.intervalID.commandOvertime);
clearInterval(that.intervalID.commandReceive);
that.intervalID.commandOvertime = null;
that.intervalID.commandReceive = null;
that.commandmaskshow = false;
that.progress = 0;
}
})
.catch((err) => {
console.log(err);
clearInterval(that.intervalID.commandOvertime);
clearInterval(that.intervalID.commandReceive);
that.intervalID.commandOvertime = null;
that.intervalID.commandReceive = null;
that.commandmaskshow = false;
that.progress = 0;
});
}, 1000);
}
}
else{
that.commandmaskshow = false;
that.progress = 0;
that.$refs.uToast.show({
title: res.message,
type: "error",
icon: false,
});
}
})
.catch((err) => {
console.log(err);
});
} else {
this.$refs.uToast.show({
title: "调光和色温比例请输入0至100范围的整数!",
type: "warning",
});
}
},
stopcommand(){
clearInterval(this.intervalID.commandOvertime);
clearInterval(this.intervalID.commandReceive);
this.intervalID.commandOvertime = null;
this.intervalID.commandReceive = null;
this.commandmaskshow = false;
},
getStatus() {
this.device.terminalid = this.terminalid;
this.device.lampid = this.subdeviceccid;
var that = this;
this.lampstate = [];
this.commandmaskshow = true;
this.intervalID.commandReceive = null;
this.intervalID.commandOvertime = null;
this.status.test_error_checked1 = false;
this.status.test_error_checked2 = false;
this.status.test_error_checked3 = false;
this.progress = 0;
if(this.devicetype == 1)//灯杆状态读取
{
let data = {
controlid: this.device.lampid,
id: this.device.terminalid,
commandid: '',
};
sendReadlampstatus(data)
.then((res) => {
//命令下发成功
if(res.successed == true)
{
that.commandid = res.data.commandid;
data.commandid = that.commandid;
if(that.intervalID.commandOvertime == null) {
that.intervalID.commandOvertime = setTimeout(() => {
that.$refs.uToast.show({
title: "命令超时",
type: "error",
icon: false,
});
clearInterval(that.intervalID.commandReceive);
that.intervalID.commandReceive = null;
that.intervalID.commandOvertime = null
that.commandmaskshow = false;
that.progress = 0;
}, 20000);
}
if(that.intervalID.commandReceive == null) {
that.intervalID.commandReceive = setInterval(() => {
that.progress += 5;
receiveReadlampstatus(data)
.then((res) => {
if(res.successed == true)
{
that.lampstate.worktype = res.data.worktype;
that.lampstate.controllstatus = res.data.controlState;
that.lampstate.requeststatus = res.data.requestTimeCheckStatus;
that.lampstate.temperature = res.data.temperature;
that.status.test_temperature = that.lampstate.temperature;
that.lampstate.current = res.data.current;
that.status.test_current = that.lampstate.current;
that.lampstate.voltage = res.data.voltage;
that.status.test_voltage = that.lampstate.voltage;
that.lampstate.activepower = res.data.activePower;
that.status.test_active_power = that.lampstate.activepower;
that.lampstate.dimmingvalue = res.data.Dimming;
that.status.test_dimmer1_read = that.lampstate.dimmingvalue;
that.lampstate.dimmingvalue1 = res.data.Dimming2;
that.status.test_dimmer2_read = that.lampstate.dimmingvalue1;
if(res.data.lampsFailure != '无'){
that.status.test_error_checked1 = true;
}
if(res.data.temperatureFailure != '无'){
that.status.test_error_checked2 = true;
}
clearInterval(that.intervalID.commandOvertime);
clearInterval(that.intervalID.commandReceive);
that.intervalID.commandOvertime = null;
that.intervalID.commandReceive = null;
that.commandmaskshow = false;
that.progress = 0;
}
})
.catch((err) => {
console.log(err);
clearInterval(that.intervalID.commandOvertime);
clearInterval(that.intervalID.commandReceive);
that.intervalID.commandOvertime = null;
that.intervalID.commandReceive = null;
that.commandmaskshow = false;
that.progress = 0;
});
}, 1000);
}
}
else{
var msg = res.message
that.commandmaskshow = false;
that.progress = 0;
that.$refs.uToast.show({
title: msg,
type: "error",
icon: false,
});
}
})
.catch((err) => {
console.log(err);
});
}
else if(this.devicetype == 2)//回路状态读取
{
let data = {
mcontrolid: this.device.lampid,
id: this.device.terminalid,
commandid: '',
};
debugger
sendReadloopstatus(data)
.then((res) => {
//命令下发成功
if(res.successed == true)
{
that.commandid = res.data.commandid;
data.commandid = that.commandid;
if(that.intervalID.commandOvertime == null) {
that.intervalID.commandOvertime = setTimeout(() => {
that.$refs.uToast.show({
title: "命令超时",
type: "error",
icon: false,
});
clearInterval(that.intervalID.commandReceive);
that.intervalID.commandReceive = null;
that.intervalID.commandOvertime = null
that.commandmaskshow = false;
that.progress = 0;
}, 20000);
}
if(that.intervalID.commandReceive == null) {
that.intervalID.commandReceive = setInterval(() => {
that.progress += 5;
receiveReadloopstatus(data)
.then((res) => {
debugger
if(res.successed == true)
{
if(that.deviceobj == '0003' || that.deviceobj == '0004')//单回路调光和色温
{
that.status.test_dimmer1_read = res.data.dimming;
that.status.test_dimmer2_read = res.data.dimming2;
that.status.test_voltage = res.data.outputvoltage;
that.status.test_current = res.data.outputelectricity;
that.status.test_absorb_current = res.data.soakelectricity;
}
else if(that.deviceobj == '0001' )//单回路开关
{
that.status.test_dimmer1_read = res.data.dimming;
that.status.test_dimmer2_read = res.data.dimming2;
that.status.test_active_power = res.data.activepower;
that.status.test_voltage = res.data.voltage;
that.status.test_current = res.data.electricity;
}
else//三相回路开关
{
debugger
that.status.test_active_power = res.data.activepower;
that.status.test_voltageA = res.data.voltageA;
that.status.test_currentA = res.data.electricityA;
that.status.test_voltageB = res.data.voltageB;
that.status.test_currentB = res.data.electricityB;
that.status.test_voltageC = res.data.voltageC;
that.status.test_currentC = res.data.electricityC;
if(res.data.switch >='0')
{
that.status.test_switch = '开'
}
else{
that.status.test_switch = '关'
}
}
clearInterval(that.intervalID.commandOvertime);
clearInterval(that.intervalID.commandReceive);
that.intervalID.commandOvertime = null;
that.intervalID.commandReceive = null;
that.commandmaskshow = false;
that.progress = 0;
}
})
.catch((err) => {
console.log(err);
clearInterval(that.intervalID.commandOvertime);
clearInterval(that.intervalID.commandReceive);
that.intervalID.commandOvertime = null;
that.intervalID.commandReceive = null;
that.commandmaskshow = false;
that.progress = 0;
});
}, 1000);
}
}
else{
var msg = res.message
that.commandmaskshow = false;
that.progress = 0;
that.$refs.uToast.show({
title: msg,
type: "error",
icon: false,
});
}
})
.catch((err) => {
console.log(err);
});
}
},
},
onLoad(option) {
this.device = option;
this.subdeviceid = this.device.subdeviceid;
this.subdeviceccid = this.device.subdeviceccid;
this.rtuid = this.device.rtuid;
this.terminalid = this.device.terminalId;
this.devicetype = this.device.subdevicetype;
this.devicename = this.device.subdevicename;
this.deviceobj = this.device.subdevice;
},
};
</script>
<style scoped>
.page {
padding: 28rpx 0 1px;
background: linear-gradient(
180deg,
rgba(235, 241, 255, 0.5) 0%,
#e4ebff 100%
);
}
.card {
margin: 0 32rpx 28rpx;
padding: 28rpx;
background-color: #ffffff;
border-radius: 10rpx;
}
.title {
margin-bottom: 24rpx;
font-size: 36rpx;
font-weight: bold;
line-height: 50rpx;
}
.u-field {
padding: 0;
}
.u-field::after {
border-bottom-width: 0;
}
.u-field >>> .fild-body {
width: 170rpx;
height: 70rpx;
padding: 16rpx;
border: 1px solid rgba(141, 146, 166, 0.51);
border-radius: 35rpx;
}
.u-field >>> .uni-input-placeholder,
.input2 >>> .uni-input-placeholder,
.myInput >>> .uni-input-placeholder {
font-size: 28rpx;
color: #8d92a6;
}
.input2 {
width: 250rpx;
padding-right: 16rpx;
border: 1px solid rgba(141, 146, 166, 0.51);
border-radius: 35rpx;
margin: 5px 5px;
font-size: 28rpx;
}
.input2 > :first-child {
padding: 14rpx 16rpx 14rpx 22rpx;
font-size: 28rpx;
}
.myInput {
width: 253rpx;
padding: 14rpx 22rpx;
border: 1px solid rgba(141, 146, 166, 0.51);
border-radius: 35rpx;
font-size: 28rpx;
}
.u-checkbox-group {
justify-content: center;
width: 100%;
font-size: 28rpx;
line-height: 1.8;
}
.u-checkbox-group >>> .u-checkbox__icon--checked {
background-color: #2979ff;
border-color: #2979ff;
}
.u-checkbox-group >>> .u-checkbox__label {
font-size: 28rpx;
}
.card:last-child .u-checkbox-group::after {
display: none;
}
.card:last-child .u-checkbox-group >>> .u-checkbox__label {
margin-right: 0;
}
.u-checkbox-group >>> .u-checkbox__icon-wrap--disabled--checked {
color: #ff0000 !important;
}
.table {
margin: 28rpx 0;
font-size: 28rpx;
border: 1px solid rgba(78, 115, 223, 0.4);
border-radius: 5px;
}
.table .u-field {
font-size: 28rpx;
}
.tr {
display: flex;
justify-content: space-around;
align-items: center;
height: 68rpx;
text-align: center;
}
.tr.th {
background: rgba(78, 115, 223, 0.4);
}
.tr > .border {
width: 1px;
height: 100%;
background: rgba(78, 115, 223, 0.4);
}
.tr + .border {
height: 1px;
background: rgba(78, 115, 223, 0.4);
}
.table .tr-item:last-child > .border {
height: 0;
}
.u-btn {
width: 150rpx;
height: 56rpx;
margin: 0;
}
.u-btn--default {
color: #2979ff;
}
.u-btn--default::after {
border: 2px solid #2979ff;
}
.u-btn--default.u-default-hover {
color: #ffffff !important;
}
.u-btn--default.u-default-hover {
background-color: #2979ff !important;
}
.warp {
display: flex;
align-items: center;
justify-content: center;
height: 100%;
}
.rect {
width: 145px;
height: 145px;
background-color: #fff;
}
.u-progress-content {
display: flex;
align-items: center;
justify-content: center;
}
.u-progress-dot {
width: 16rpx;
height: 16rpx;
border-radius: 50%;
background-color: #fb9126;
}
.u-progress-info {
font-size: 28rpx;
padding-left: 16rpx;
letter-spacing: 2rpx
}
.position{
margin: 5px 20px;
}
.readbtn{
margin: 2px 36px;
}
.tr>>>.u-mask-show{
opacity: 0.2;
}
</style>