|
|
|
@ -8,7 +8,7 @@
|
|
|
|
|
</div>
|
|
|
|
|
<div class="card-body" style="padding:0;">
|
|
|
|
|
<div class="button-sp-area cell" style="width:100%;height:450px;overflow:auto;">
|
|
|
|
|
<button v-for="button in getCustomButtons()" type="button" class="weui-btn weui-btn_mini weui-btn_default px-2 m-2" :value="button.value" v-on:click="send($event.target.value,5)">{{button.name}}</button>
|
|
|
|
|
<button v-for="button in getCustomButtons()" type="button" class="weui-btn weui-btn_mini weui-btn_default px-2 m-2" :value="button.name" v-on:click="send($event.target.value)">{{button.name}}</button>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
@ -21,7 +21,7 @@
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="card-body">
|
|
|
|
|
<div class="weui-cells weui-cells_form" v-for="button in getCustomButtons()">
|
|
|
|
|
<div class="weui-cells weui-cells_form item" v-for="button in getCustomButtons()">
|
|
|
|
|
<div class="weui-cell">
|
|
|
|
|
<div class="weui-cell__hd"><label class="weui-label">名称</label></div>
|
|
|
|
|
<div class="weui-cell__bd">
|
|
|
|
@ -71,7 +71,7 @@
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
|
<div class="text-center">
|
|
|
|
|
<a href="javascript:;" class="weui-btn weui-btn_mini weui-btn_default" v-on:click="test(button.value)">测试</a>
|
|
|
|
|
<a href="javascript:;" class="weui-btn weui-btn_mini weui-btn_default" v-on:click="test(button.name)">测试</a>
|
|
|
|
|
<a href="javascript:;" class="weui-btn weui-btn_mini weui-btn_default" v-on:click="remove(button.name)">移除</a>
|
|
|
|
|
</div>
|
|
|
|
|
</div>
|
|
|
|
@ -86,54 +86,8 @@
|
|
|
|
|
weui.tab('.weui-tab');
|
|
|
|
|
},
|
|
|
|
|
methods: {
|
|
|
|
|
changePattern: function (v) {
|
|
|
|
|
this.change(v, 0, 480, 120);
|
|
|
|
|
},
|
|
|
|
|
changeDirection(v) {
|
|
|
|
|
this.change(v, 0, 60, 60);
|
|
|
|
|
},
|
|
|
|
|
changeWind(v) {
|
|
|
|
|
this.change(v, 0, 45, 15);
|
|
|
|
|
},
|
|
|
|
|
changePower: function (v) {
|
|
|
|
|
var oldValue = parseInt(v);
|
|
|
|
|
if (oldValue === 1) {
|
|
|
|
|
this.send(3, 1);
|
|
|
|
|
getData(this.device, '按键').value = 3;
|
|
|
|
|
}
|
|
|
|
|
else if (oldValue === 2) {
|
|
|
|
|
this.send(1, 1);
|
|
|
|
|
getData(this.device, '按键').value = 1;
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
changeTemperature: function (v, step) {
|
|
|
|
|
var oldValue = parseInt(v);
|
|
|
|
|
var min = 1;
|
|
|
|
|
var max = 15;
|
|
|
|
|
var newValue = oldValue + step;
|
|
|
|
|
if (step > 0 && newValue > max) {
|
|
|
|
|
newValue = max;
|
|
|
|
|
}
|
|
|
|
|
else if (step < 0 && newValue < min) {
|
|
|
|
|
newValue = min;
|
|
|
|
|
}
|
|
|
|
|
var newCode = this.code - oldValue + newValue;
|
|
|
|
|
this.send(newCode, 1);
|
|
|
|
|
getData(this.device, '按键').value = newCode;
|
|
|
|
|
},
|
|
|
|
|
change: function (v, min, max, step) {
|
|
|
|
|
alert(v);
|
|
|
|
|
var oldValue = parseInt(v);
|
|
|
|
|
var newValue = oldValue + step;
|
|
|
|
|
if (newValue > max) {
|
|
|
|
|
newValue = min;
|
|
|
|
|
}
|
|
|
|
|
var newCode = this.code - oldValue + newValue;
|
|
|
|
|
this.send(newCode, 1);
|
|
|
|
|
getData(this.device, '按键').value = newCode;
|
|
|
|
|
},
|
|
|
|
|
send: function (value, type) {
|
|
|
|
|
execApi(this.device.number, '/Ir/Send', 'type=' + type + '&code=' + value);
|
|
|
|
|
send: function (name) {
|
|
|
|
|
execApi(this.device.number, '/SerialPort/Send', 'type=' + type + '&code=' + value);
|
|
|
|
|
},
|
|
|
|
|
getCustomButtons: function () {
|
|
|
|
|
return Enumerable.from(JSON.parse(getDeviceDataValue(this.device, "指令")))
|
|
|
|
@ -145,7 +99,7 @@
|
|
|
|
|
.where(function (o) { return o.name === "指令"; })
|
|
|
|
|
.firstOrDefault();
|
|
|
|
|
var buttons = this.getCustomButtons();
|
|
|
|
|
var newBtn = { name: "测试", value: "603", order: 100 };
|
|
|
|
|
var newBtn = { "name": "测试", "portName": "/dev/ttyS0", "baudRate": 9600, "parity": 0, "dataBits": 8, "stopBits": 1, "message": "0123456789ABCDEF", "order": 100 };
|
|
|
|
|
buttons.push(newBtn);
|
|
|
|
|
data.value = JSON.stringify(buttons);
|
|
|
|
|
},
|
|
|
|
@ -162,83 +116,32 @@
|
|
|
|
|
}
|
|
|
|
|
data.value = JSON.stringify(buttons);
|
|
|
|
|
},
|
|
|
|
|
study: function (code) {
|
|
|
|
|
execApi(this.device.number, '/Ir/Study', 'type=' + 5 + '&code=' + code);
|
|
|
|
|
},
|
|
|
|
|
test: function (code) {
|
|
|
|
|
execApi(this.device.number, '/Ir/Send', 'type=' + 5 + '&code=' + code);
|
|
|
|
|
test: function (name) {
|
|
|
|
|
var button = Enumerable.from(this.getCustomButtons()).where(function (o) { return o.name === name; }).firstOrDefault();
|
|
|
|
|
var query = 'port=' + button.portName;
|
|
|
|
|
query += '&baud=' + button.baudRate;
|
|
|
|
|
query += '&parity=' + button.parity;
|
|
|
|
|
query += '&dataBits=' + button.dataBits;
|
|
|
|
|
query += '&stopBits=' + button.stopBits;
|
|
|
|
|
query += '&message=' + button.message;
|
|
|
|
|
execApi(this.device.number, '/SerialPort/Test',query);
|
|
|
|
|
},
|
|
|
|
|
save: function (e) {
|
|
|
|
|
var buttons = [];
|
|
|
|
|
$(e.target).parents('.card').find('.row').each(function () {
|
|
|
|
|
$(e.target).parents('.card').find('.item').each(function () {
|
|
|
|
|
buttons.push({
|
|
|
|
|
name: $(this).find("input[name='name']").val(),
|
|
|
|
|
value: $(this).find("input[name='value']").val(),
|
|
|
|
|
portName: $(this).find("input[name='portName']").val(),
|
|
|
|
|
baudRate: $(this).find("input[name='baudRate']").val(),
|
|
|
|
|
parity: $(this).find("input[name='parity']").val(),
|
|
|
|
|
dataBits: $(this).find("input[name='dataBits']").val(),
|
|
|
|
|
stopBits: $(this).find("input[name='stopBits']").val(),
|
|
|
|
|
message: $(this).find("input[name='message']").val(),
|
|
|
|
|
order: $(this).find("input[name='order']").val()
|
|
|
|
|
});
|
|
|
|
|
});
|
|
|
|
|
var value = JSON.stringify(buttons);
|
|
|
|
|
execApi(this.device.number, '/Ir/Buttons', 'buttons=' + value);
|
|
|
|
|
}
|
|
|
|
|
},
|
|
|
|
|
computed: {
|
|
|
|
|
code: function () {
|
|
|
|
|
return getDeviceDataValue(this.device, '按键');
|
|
|
|
|
},
|
|
|
|
|
pattern: function () {
|
|
|
|
|
var code = this.code;
|
|
|
|
|
var pattern = { name: '制冷', value: 0 };
|
|
|
|
|
if (code > 480 + 2) {
|
|
|
|
|
pattern = { name: '通风', value: 480 };
|
|
|
|
|
}
|
|
|
|
|
else if (code > 360 + 2) {
|
|
|
|
|
pattern = { name: '抽湿', value: 360 };
|
|
|
|
|
}
|
|
|
|
|
else if (code > 240 + 2) {
|
|
|
|
|
pattern = { name: '制热', value: 240 };
|
|
|
|
|
}
|
|
|
|
|
else if (code > 120 + 2) {
|
|
|
|
|
pattern = { name: '自动', value: 120 };
|
|
|
|
|
}
|
|
|
|
|
return pattern;
|
|
|
|
|
},
|
|
|
|
|
direction: function () {
|
|
|
|
|
var code = this.code - this.pattern.value;
|
|
|
|
|
var direction = { name: '自动', value: 0 };;
|
|
|
|
|
if (code > 60 + 2) {
|
|
|
|
|
direction = { name: '手动', value: 60 };
|
|
|
|
|
}
|
|
|
|
|
return direction;
|
|
|
|
|
},
|
|
|
|
|
wind: function () {
|
|
|
|
|
var code = this.code - this.pattern.value - this.direction.value;
|
|
|
|
|
var wind = { name: '自动', value: 0 };
|
|
|
|
|
if (code > 45 + 2) {
|
|
|
|
|
wind = { name: '低', value: 45 };
|
|
|
|
|
}
|
|
|
|
|
else if (code > 30 + 2) {
|
|
|
|
|
wind = { name: '中', value: 30 };
|
|
|
|
|
}
|
|
|
|
|
else if (code > 15 + 2) {
|
|
|
|
|
wind = { name: '高', value: 15 };
|
|
|
|
|
}
|
|
|
|
|
return wind;
|
|
|
|
|
},
|
|
|
|
|
power: function () {
|
|
|
|
|
var code = this.code - this.pattern.value - this.direction.value - this.wind.value;
|
|
|
|
|
var power = { name: '关', value: 1 };
|
|
|
|
|
if (code > 1) {
|
|
|
|
|
power = { name: '开', value: 2 };
|
|
|
|
|
}
|
|
|
|
|
return power;
|
|
|
|
|
},
|
|
|
|
|
temperature: function () {
|
|
|
|
|
var code = this.code - this.pattern.value - this.direction.value - this.wind.value - this.power.value;
|
|
|
|
|
var temperature = { name: '16℃', value: 1 };
|
|
|
|
|
if (code > 1) {
|
|
|
|
|
temperature = { name: parseInt(code + 15) + '℃', value: code };
|
|
|
|
|
}
|
|
|
|
|
return temperature;
|
|
|
|
|
execApi(this.device.number, '/SerialPort/Buttons', 'buttons=' + value);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|