| | |
| | | <th>故障状态</th> |
| | | <th>故障码</th> |
| | | <th>管制状态</th> |
| | | <th>低电量</th> |
| | | </tr> |
| | | </thead> |
| | | <tbody> |
| | |
| | | <div> |
| | | <label><input type="radio" name="moveType" value="0"> 跑轨道</label> |
| | | <label><input type="radio" name="moveType" value="1"> 跑库位</label> |
| | | <label><input type="radio" name="moveType" value="2"> 母轨道循环跑</label> |
| | | <label><input type="radio" name="moveType" value="3"> 子轨道循环跑</label> |
| | | </div> |
| | | <div style="margin-top: 10px;"> |
| | | <button class="item" onclick="moveLoc()">跑库</button> |
| | |
| | | var shuttleMsgTableFullRows = 0; |
| | | // 初始化 |
| | | var shuttleOutputDom = document.getElementById("shuttle-output"); |
| | | |
| | | var ws = new WebSocket("ws://" + window.location.host + baseUrl + "/shuttle/websocket"); |
| | | |
| | | //当WebSocket创建成功时,触发onopen事件 |
| | | ws.onopen = function(){ |
| | | console.log("open"); |
| | | } |
| | | |
| | | //当客户端收到服务端发来的消息时,触发onmessage事件 |
| | | ws.onmessage = function(e){ |
| | | const result = JSON.parse(e.data); |
| | | if (result.url == "/shuttle/table/shuttle/state") { |
| | | setShuttleStateInfo(JSON.parse(result.data)) |
| | | setShuttleMsgInfo(JSON.parse(result.data)) |
| | | }else if (result.url == "/shuttle/output/shuttle") { |
| | | setShuttleOutput(JSON.parse(result.data)) |
| | | } |
| | | // console.log(e.data,result); |
| | | } |
| | | |
| | | //当客户端收到服务端发送的关闭连接请求时,触发onclose事件 |
| | | ws.onclose = function(e){ |
| | | console.log("close"); |
| | | } |
| | | |
| | | //如果出现连接、处理、接收、发送数据失败的时候触发onerror事件 |
| | | ws.onerror = function(e) { |
| | | console.log(e); |
| | | } |
| | | |
| | | $(document).ready(function() { |
| | | initShuttleStateTable(); |
| | | getShuttleStateInfo(); |
| | | initShuttleMsgTable(); |
| | | getShuttleMsgInfo(); |
| | | operatorBlockShow(); |
| | | setShuttleRadio(); |
| | | }); |
| | | |
| | | setInterval(function () { |
| | | getShuttleStateInfo() |
| | | getShuttleMsgInfo(); |
| | | getShuttleStateInfo(); |
| | | },1000) |
| | | setInterval(function () { |
| | | getShuttleOutput(); |
| | |
| | | |
| | | // 四向穿梭车信息表获取 ---- 表一 |
| | | function getShuttleStateInfo() { |
| | | sendWs(JSON.stringify({ |
| | | "url": "/shuttle/table/shuttle/state", |
| | | "data": {} |
| | | })) |
| | | } |
| | | |
| | | // 四向穿梭车信息表设置 ---- 表一 |
| | | function setShuttleStateInfo(res) { |
| | | let tableEl = $('#shuttle-state-table'); |
| | | $.ajax({ |
| | | url: baseUrl+ "/shuttle/table/shuttle/state", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | method: 'POST', |
| | | success: function (res) { |
| | | if (res.code === 200){ |
| | | let table = res.data; |
| | | if (table.length > shuttleStateTableBlankRows && table.length !== shuttleStateTableFullRows) { |
| | | initShuttleStateTable(table.length-shuttleStateTableBlankRows); |
| | | shuttleStateTableFullRows = table.length; |
| | | } |
| | | for (let i=1;i<=table.length;i++){ |
| | | // $("#mode-"+table[i-1].shuttleNo).html(table[i-1].statusVal===0?'联机':'脱机'); |
| | | let tr = tableEl.find("tr").eq(i); |
| | | setVal(tr.children("td").eq(0), table[i-1].shuttleNo); |
| | | setVal(tr.children("td").eq(1), table[i-1].protocolStatus$); |
| | | setVal(tr.children("td").eq(2), table[i-1].free$); |
| | | setVal(tr.children("td").eq(3), table[i-1].workingMode$); |
| | | setVal(tr.children("td").eq(4), table[i-1].point$); |
| | | setVal(tr.children("td").eq(5), table[i-1].point$$); |
| | | setVal(tr.children("td").eq(6), table[i-1].powerPercent$); |
| | | setVal(tr.children("td").eq(7), table[i-1].speed); |
| | | setVal(tr.children("td").eq(8), table[i-1].loadState$); |
| | | setVal(tr.children("td").eq(9), table[i-1].liftPosition$); |
| | | setVal(tr.children("td").eq(10), table[i-1].runDir$); |
| | | setVal(tr.children("td").eq(11), table[i-1].runDir2$); |
| | | setVal(tr.children("td").eq(12), table[i-1].chargState$); |
| | | setVal(tr.children("td").eq(13), table[i-1].errState$); |
| | | setVal(tr.children("td").eq(14), table[i-1].errCode$); |
| | | setVal(tr.children("td").eq(15), table[i-1].suspendState$); |
| | | } |
| | | } else if (res.code === 403){ |
| | | window.location.href = baseUrl+"/login"; |
| | | } else { |
| | | console.log(res.msg); |
| | | } |
| | | if (res.code === 200){ |
| | | let table = res.data; |
| | | if (table.length > shuttleStateTableBlankRows && table.length !== shuttleStateTableFullRows) { |
| | | initShuttleStateTable(table.length-shuttleStateTableBlankRows); |
| | | shuttleStateTableFullRows = table.length; |
| | | } |
| | | }); |
| | | for (let i=1;i<=table.length;i++){ |
| | | // $("#mode-"+table[i-1].shuttleNo).html(table[i-1].statusVal===0?'联机':'脱机'); |
| | | let tr = tableEl.find("tr").eq(i); |
| | | setVal(tr.children("td").eq(0), table[i-1].shuttleNo); |
| | | setVal(tr.children("td").eq(1), table[i-1].protocolStatus$); |
| | | setVal(tr.children("td").eq(2), table[i-1].free$); |
| | | setVal(tr.children("td").eq(3), table[i-1].workingMode$); |
| | | setVal(tr.children("td").eq(4), table[i-1].point$); |
| | | setVal(tr.children("td").eq(5), table[i-1].point$$); |
| | | setVal(tr.children("td").eq(6), table[i-1].powerPercent$); |
| | | setVal(tr.children("td").eq(7), table[i-1].speed); |
| | | setVal(tr.children("td").eq(8), table[i-1].loadState$); |
| | | setVal(tr.children("td").eq(9), table[i-1].liftPosition$); |
| | | setVal(tr.children("td").eq(10), table[i-1].runDir$); |
| | | setVal(tr.children("td").eq(11), table[i-1].runDir2$); |
| | | setVal(tr.children("td").eq(12), table[i-1].chargState$); |
| | | setVal(tr.children("td").eq(13), table[i-1].errState$); |
| | | setVal(tr.children("td").eq(14), table[i-1].errCode$); |
| | | setVal(tr.children("td").eq(15), table[i-1].suspendState$); |
| | | setVal(tr.children("td").eq(16), table[i-1].lowerPower); |
| | | } |
| | | } else if (res.code === 403){ |
| | | window.location.href = baseUrl+"/login"; |
| | | } else { |
| | | console.log(res.msg); |
| | | } |
| | | } |
| | | |
| | | // 四向穿梭车数据表获取 ---- 表二 |
| | | function getShuttleMsgInfo() { |
| | | function setShuttleMsgInfo(res) { |
| | | let tableEl = $('#shuttle-msg-table'); |
| | | $.ajax({ |
| | | url: baseUrl+ "/shuttle/table/shuttle/state", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | method: 'POST', |
| | | success: function (res) { |
| | | if (res.code === 200){ |
| | | var table = res.data; |
| | | if (table.length > shuttleMsgTableBlankRows && table.length !== shuttleMsgTableFullRows) { |
| | | initShuttleMsgTable(table.length-shuttleMsgTableBlankRows); |
| | | shuttleMsgTableFullRows = table.length; |
| | | } |
| | | for (var i=1;i<=table.length;i++){ |
| | | var tr = tableEl.find("tr").eq(i); |
| | | setVal(tr.children("td").eq(0), table[i-1].shuttleNo); |
| | | setVal(tr.children("td").eq(1), table[i-1].taskNo); |
| | | setVal(tr.children("td").eq(2), table[i-1].sourceLocNo); |
| | | setVal(tr.children("td").eq(3), table[i-1].locNo); |
| | | setVal(tr.children("td").eq(4), table[i-1].maxCellVoltage$); |
| | | setVal(tr.children("td").eq(5), table[i-1].minCellVoltage$); |
| | | setVal(tr.children("td").eq(6), table[i-1].voltage$); |
| | | setVal(tr.children("td").eq(7), table[i-1].chargeCycleTimes); |
| | | setVal(tr.children("td").eq(8), table[i-1].surplusQuantity); |
| | | setVal(tr.children("td").eq(9), table[i-1].countQuantity); |
| | | setVal(tr.children("td").eq(10), table[i-1].statusSum ? table[i - 1].statusSum.mileage : ''); |
| | | setVal(tr.children("td").eq(11), table[i-1].pakMk$); |
| | | setVal(tr.children("td").eq(12), table[i-1].currentLocNo); |
| | | setVal(tr.children("td").eq(13), table[i-1].token); |
| | | if (table[i-1].shuttleNo == parseInt($('input[name="shuttleSelect"]:checked').val())) { |
| | | $("#runSpeedText").text(table[i-1].runSpeed) |
| | | $("#chargeLineText").text(table[i-1].chargeLine + "%") |
| | | } |
| | | } |
| | | } else if (res.code === 403){ |
| | | window.location.href = baseUrl+"/login"; |
| | | } else { |
| | | console.log(res.msg); |
| | | if (res.code === 200){ |
| | | var table = res.data; |
| | | if (table.length > shuttleMsgTableBlankRows && table.length !== shuttleMsgTableFullRows) { |
| | | initShuttleMsgTable(table.length-shuttleMsgTableBlankRows); |
| | | shuttleMsgTableFullRows = table.length; |
| | | } |
| | | for (var i=1;i<=table.length;i++){ |
| | | var tr = tableEl.find("tr").eq(i); |
| | | setVal(tr.children("td").eq(0), table[i-1].shuttleNo); |
| | | setVal(tr.children("td").eq(1), table[i-1].taskNo); |
| | | setVal(tr.children("td").eq(2), table[i-1].sourceLocNo); |
| | | setVal(tr.children("td").eq(3), table[i-1].locNo); |
| | | setVal(tr.children("td").eq(4), table[i-1].maxCellVoltage$); |
| | | setVal(tr.children("td").eq(5), table[i-1].minCellVoltage$); |
| | | setVal(tr.children("td").eq(6), table[i-1].voltage$); |
| | | setVal(tr.children("td").eq(7), table[i-1].chargeCycleTimes); |
| | | setVal(tr.children("td").eq(8), table[i-1].surplusQuantity); |
| | | setVal(tr.children("td").eq(9), table[i-1].countQuantity); |
| | | setVal(tr.children("td").eq(10), table[i-1].statusSum ? table[i - 1].statusSum.mileage : ''); |
| | | setVal(tr.children("td").eq(11), table[i-1].pakMk$); |
| | | setVal(tr.children("td").eq(12), table[i-1].currentLocNo); |
| | | setVal(tr.children("td").eq(13), table[i-1].token); |
| | | if (table[i-1].shuttleNo == parseInt($('input[name="shuttleSelect"]:checked').val())) { |
| | | $("#runSpeedText").text(table[i-1].runSpeed) |
| | | $("#chargeLineText").text(table[i-1].chargeLine + "%") |
| | | } |
| | | } |
| | | }); |
| | | } else if (res.code === 403){ |
| | | window.location.href = baseUrl+"/login"; |
| | | } else { |
| | | console.log(res.msg); |
| | | } |
| | | } |
| | | |
| | | // 穿梭车日志输出 ----------------------------------------------------------------------- |
| | | function getShuttleOutput() { |
| | | $.ajax({ |
| | | url: baseUrl + "/shuttle/output/shuttle", |
| | | headers: {'token': localStorage.getItem('token')}, |
| | | method: 'POST', |
| | | success: function (res) { |
| | | if (res.code === 200) { |
| | | shuttleOutput(res.data); |
| | | } else if (res.code === 403) { |
| | | window.location.href = baseUrl + "/login"; |
| | | } else { |
| | | console.log(res.msg); |
| | | } |
| | | } |
| | | }) |
| | | sendWs(JSON.stringify({ |
| | | "url": "/shuttle/output/shuttle", |
| | | "data": {} |
| | | })) |
| | | } |
| | | |
| | | function setShuttleOutput(res) { |
| | | if (res.code === 200) { |
| | | shuttleOutput(res.data); |
| | | } else if (res.code === 403) { |
| | | window.location.href = baseUrl + "/login"; |
| | | } else { |
| | | console.log(res.msg); |
| | | } |
| | | } |
| | | |
| | | // 任务指令下发 |
| | |
| | | layer.close(layerDetl); |
| | | }) |
| | | |
| | | function sendWs(message) { |
| | | if (ws.readyState == WebSocket.OPEN) { |
| | | ws.send(message) |
| | | } |
| | | } |
| | | |
| | | </script> |