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.
259 lines
9.6 KiB
259 lines
9.6 KiB
<!doctype html>
|
|
<html>
|
|
|
|
<head>
|
|
<meta charset="utf-8">
|
|
<script src="http://ajax.aspnetcdn.com/ajax/jQuery/jquery-1.8.0.js"></script>
|
|
<script src="../js/zcmd.js"></script>
|
|
<meta name="viewport" content="width=device-width,initial-scale=1">
|
|
<title>日志配置</title>
|
|
<style>
|
|
</style>
|
|
<script>
|
|
</script>
|
|
</head>
|
|
|
|
<body>
|
|
<script>
|
|
var zcmd = new ZCommand();
|
|
zcmd.set_onSendraw(function (data) {
|
|
console.log("zcmd send:" + JSON.stringify(data, null, 0));
|
|
});
|
|
zcmd.set_onReceipt(function (tx, rx) {
|
|
console.log("zcmd receipt:" + JSON.stringify(rx, null, 0));
|
|
});
|
|
</script>
|
|
<!--
|
|
/*******************************************************************************************************************
|
|
* =================================================deviceStates================================================== *
|
|
*******************************************************************************************************************/
|
|
-->
|
|
<div>
|
|
<h1>deviceStates</h1>
|
|
<select id="RefreshPeriod">
|
|
<option value=1000>1s</option>
|
|
<option value=2000>2s</option>
|
|
<option value=3000>3s</option>
|
|
<option value=4000>4s</option>
|
|
<option value=5000>5s</option>
|
|
</select>
|
|
<!-- 开始刷新 -->
|
|
<button id="startRefresh">Start Refresh</button>
|
|
<!-- 停止刷新 -->
|
|
<button id="stopRefresh">Stop Refresh</button>
|
|
<table id="deviceStates">
|
|
<tr>
|
|
<td>Key</td>
|
|
<td>Value</td>
|
|
<td>单位</td>
|
|
</tr>
|
|
<tr>
|
|
<td>----</td>
|
|
<td>----</td>
|
|
<td>----</td>
|
|
</tr>
|
|
</table>
|
|
|
|
<script>
|
|
zcmd.set_onConnect(function () {
|
|
alert("connect to server");
|
|
});
|
|
var refreshId;
|
|
$("#startRefresh").click(function () {
|
|
if (refreshId)
|
|
clearInterval(refreshId);
|
|
refreshId = setInterval(function () {
|
|
zcmd.send_message({
|
|
"command": "getDeviceState",
|
|
"need_receipt": true,
|
|
}, 4000).then((data) => {
|
|
console.log(data);
|
|
var html = "";
|
|
html += "<tr>";
|
|
html += "<td>Key</td>";
|
|
html += "<td>Value</td>";
|
|
html += "<td>单位</td>";
|
|
html += "</tr>";
|
|
for (var i = 0; i < data.deviceState.length; i++) {
|
|
html += "<tr>";
|
|
html += "<td>" + data.deviceState[i].id + "</td>";
|
|
html += "<td>" + data.deviceState[i].value + "</td>";
|
|
html += "<td>" + data.deviceState[i].unit + "</td>";
|
|
html += "</tr>";
|
|
}
|
|
$("#deviceStates").html(html);
|
|
});
|
|
}, $("#RefreshPeriod").val());
|
|
});
|
|
|
|
$("#stopRefresh").click(function () {
|
|
clearInterval(refreshId);
|
|
});
|
|
</script>
|
|
</div>
|
|
|
|
|
|
<!--
|
|
/*******************************************************************************************************************
|
|
* ==================================================测试按键=================================================== *
|
|
*******************************************************************************************************************/
|
|
-->
|
|
<!--
|
|
type(option),value(false,true),relayControl
|
|
type->option:
|
|
0,kRouterPower,
|
|
1,kTouchScreenPower,
|
|
2,kUsbChargerPower,
|
|
3,kCameraPower,
|
|
4,kLightPower,
|
|
-->
|
|
<div>
|
|
<h1>测试</h1>
|
|
<table>
|
|
<tr>
|
|
<td>relayControl type value</td>
|
|
<td>
|
|
<select id="relayControl_type">
|
|
<option value=0>0</option>
|
|
<option value=1>1</option>
|
|
<option value=2>2</option>
|
|
<option value=3>3</option>
|
|
<option value=4>4</option>
|
|
<option value=5>5</option>
|
|
<option value=6>6</option>
|
|
<option value=7>7</option>
|
|
<option value=8>8</option>
|
|
<option value=9>9</option>
|
|
<option value=10>10</option>
|
|
<option value=11>11</option>
|
|
<option value=12>12</option>
|
|
<option value=13>13</option>
|
|
<option value=14>14</option>
|
|
<option value=15>15</option>
|
|
|
|
</select>
|
|
<select id="relayControl_value">
|
|
<option value=0>false</option>
|
|
<option value=1>true</option>
|
|
</select>
|
|
</td>
|
|
<td> <button id="relayControl">Trigger</button> </td>
|
|
<script>
|
|
$("#relayControl").click(function () {
|
|
zcmd.send_message({
|
|
"command": "relayControl",
|
|
"need_receipt": true,
|
|
"type": Number($("#relayControl_type").val()),
|
|
"value": ($("#relayControl_value").val() == '1'),
|
|
}, 4000).then((data) => { alert(JSON.stringify(data, null, 2)) });
|
|
});
|
|
</script>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>relayStateGet</td>
|
|
<td>-</td>
|
|
<td><button
|
|
onclick='zcmd.send_message({"command": "relayStateGet"},1000).then((data) => {alert(JSON.stringify(data,null,2))})'>Trigger</button>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>fanSetState id value</td>
|
|
<td>
|
|
<select id="fanSetState_id">
|
|
<option value=0>0</option>
|
|
<option value=1>1</option>
|
|
</select>
|
|
<select id="fanSetState_power">
|
|
<option value=0>0</option>
|
|
<option value=10>10</option>
|
|
<option value=20>20</option>
|
|
<option value=30>30</option>
|
|
<option value=40>40</option>
|
|
<option value=50>50</option>
|
|
<option value=60>60</option>
|
|
<option value=70>70</option>
|
|
<option value=80>80</option>
|
|
<option value=90>90</option>
|
|
<option value=100>100</option>
|
|
</select>
|
|
</td>
|
|
<td> <button id="fanSetState">Trigger</button> </td>
|
|
|
|
<script>
|
|
$("#fanSetState").click(function () {
|
|
zcmd.send_message({
|
|
"command": "fanSetState",
|
|
"need_receipt": true,
|
|
"id": Number($("#fanSetState_id").val()),
|
|
"power": Number($("#fanSetState_power").val()),
|
|
}, 4000).then((data) => {
|
|
// console.log(data);
|
|
});
|
|
});
|
|
</script>
|
|
</tr>
|
|
|
|
|
|
<tr>
|
|
<td>inputStateGet</td>
|
|
<td>-</td>
|
|
<td><button
|
|
onclick='zcmd.send_message({"command": "inputStateGet"},1000).then((data) => {alert(JSON.stringify(data,null,2))})'>Trigger</button>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>idcardread</td>
|
|
<td>-</td>
|
|
<td><button
|
|
onclick='zcmd.send_message({"command": "idcardread"},1000).then((data) => {alert(JSON.stringify(data,null,2))})'>Trigger</button>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>getInterTemperature</td>
|
|
<td>-</td>
|
|
<td><button
|
|
onclick='zcmd.send_message({"command": "getInterTemperature"},1000).then((data) => {alert(JSON.stringify(data,null,2))})'>Trigger</button>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>getExterTemperature</td>
|
|
<td>-</td>
|
|
<td><button
|
|
onclick='zcmd.send_message({"command": "getExterTemperature"},1000).then((data) => {alert(JSON.stringify(data,null,2))})'>Trigger</button>
|
|
</td>
|
|
</tr>
|
|
<tr>
|
|
<td>fanGetState</td>
|
|
<td>-</td>
|
|
<td><button
|
|
onclick='zcmd.send_message({"command": "fanGetState"},1000).then((data) => {alert(JSON.stringify(data,null,2))})'>Trigger</button>
|
|
</td>
|
|
</tr>
|
|
|
|
<tr>
|
|
<td>getDeviceState</td>
|
|
<td>-</td>
|
|
<td><button
|
|
onclick='zcmd.send_message({"command": "getDeviceState"},2000).then((data) => {alert(JSON.stringify(data,null,2))})'>Trigger</button>
|
|
</td>
|
|
</tr>
|
|
</table>
|
|
</div>
|
|
|
|
|
|
|
|
<script>
|
|
$(function () {
|
|
// ZWSURL = "ws://127.0.0.1:19000";
|
|
zcmd.start_auto_connect(ZWSURL);
|
|
});
|
|
</script>
|
|
|
|
</body>
|
|
|
|
</html>
|