123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408 |
- <!DOCTYPE html>
- <html>
- <head>
- <meta charset="utf-8">
- <title>华力机电SIMANC</title>
- <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
- <meta name="apple-mobile-web-app-capable" content="yes">
- <meta name="apple-mobile-web-app-status-bar-style" content="black">
- <!--标准mui.css-->
- <link rel="stylesheet" type="text/css" href="css/mui.min.css">
- <!--App自定义的css-->
- <link rel="stylesheet" type="text/css" href="css/app.css" />
- <link rel="stylesheet" type="text/css" href="css/iconfont.css" />
- <link rel="stylesheet" type="text/css" href="css/style.css" />
- </head>
- <body style="background: url(img/bg.png) no-repeat 0px -0px;width:99%;">
- <div id="title" style="height: 4%;text-align: center;padding-top: 10px;padding-bottom: 5px;background: url(img/title_bg.png) no-repeat 0 17px;background-size:100%;">
- <a style="color: #FFFFFF;font-size: 20px;">华力西曼克</a>
- </div>
- <div id="top" style="height: 30%;text-align: center;padding-top: 1px;background: url(img/top_bg.png) no-repeat 0 0px;background-size:100%;">
- <div class="mui-row">
- <div class="mui-col mui-col-xs-12">
- <div style="height: 10%;width: 50%;padding-top: 10px;float: left;">
- <img id="speed" src="img/speed-high.png" style="margin-left: -80px;width: 13%;">
- </div>
- <div style="height: 10%;width: 50%;padding-top: 10px;float: left;">
- <img id="battery" src="img/battery-100.png" style="margin-right: -80px;width: 23%;">
- </div>
- </div>
- <div class="mui-col mui-col-xs-12">
- <div id="tgts" style="width: 120px;height:90px;border-radius: 12px;border: 2px solid #298890;float: left;margin-left: 23px;">
- <div style="margin-left: -60px;margin-top: 15px;">
- <a style="color: #FFFFFF;font-size: 18px;">目标</a><br>
- </div>
- <div style="margin-left: -60px;margin-top: 10px;">
- <a style="color: #FFFFFF;font-size: 18px;">站点</a><br>
- </div>
- <div style="margin-left: 40px;margin-top: -40px;">
- <a id="tgtstation" style="color: #FFFFFF;font-size: 50px;"></a><br>
- </div>
- </div>
- <div id="jack" style="width: 120px;height:90px;border-radius: 12px;border: 2px solid #298890;float: right;margin-right: 20px;">
- <div style="margin-left: -60px;margin-top: 15px;">
- <a style="color: #FFFFFF;font-size: 18px;">顶升</a><br>
- </div>
- <div style="margin-left: -60px;margin-top: 10px;">
- <a style="color: #FFFFFF;font-size: 18px;">状态</a><br>
- </div>
- <div style="margin-left: 60px;margin-top: -55px;">
- <img id="liftstatus" src="img/liftstatus.png" width="60%">
- </div>
- </div>
- </div>
- <br>
- <br>
- <div style="width: 100%;height: 50px;margin-top: 100px;margin-left: 20px;">
- <div id="stop" style="width: 28%;height: 40px;line-height:40px;float: left;margin-left: 5px;background: url(img/btn4_bg.png);color: #FFFFFF;text-align: center;">停止</div>
- <div id="run" style="width: 28%;height: 40px;line-height:40px;float: left;margin-left: 5px;background: url(img/btn4_bg.png);color: #FFFFFF;text-align: center;">运行</div>
- <div id="warning" style="width: 28%;height: 40px;line-height:40px;float: left;margin-left: 5px;background: url(img/btn4_bg.png);color: #FFFFFF;text-align: center;">注意</div>
- </div>
- <div id="info" style="width: 87%;height: 30px;margin-left: 25px;color:#ccc;font-size:4px;line-height: 30px;background-color: #0b6d78;border-radius: 3px;text-align: left;padding-left: 5px;"></div>
- <div class="mui-content-padded" style="background: url(img/btlist5_bg.png) no-repeat 10px 0;margin-top: 25px;width: 100%;height: auto;">
- <div class="mui-row">
- <div class="mui-col mui-col-xs-12" id="btlist" style="padding-top:10px;min-height:285px;overflow-y:auto;max-height:285px"></div>
- <div class="mui-col mui-col-xs-12" style="text-align: center;padding-bottom: 13px;">
- <div class="mui-col mui-col-xs-3" id="gomoving">
- <button type="button" class="mui-btn mui-btn-royal mui-btn-block operation" id="moving" style="border:1px solid #4a5a6a;">移动</button>
- </div>
- <div class="mui-col mui-col-xs-3" id="gostart">
- <button type="button" class="mui-btn mui-btn-royal mui-btn-block operation" id="start" style="border:1px solid #4a5a6a;">搬运</button>
- </div>
- <div class="mui-col mui-col-xs-3">
- <button type="button" class="mui-btn mui-btn-royal mui-btn-block operation" id="cancel" style="border:1px solid #4a5a6a;">取消</button>
- </div>
- </div>
- </div>
- </div>
- <div style="height: 15px;width: 101%;background: url(img/bottom_bg.png) no-repeat -25px 0;"></div>
- </div>
- </div>
- </body>
- <script src="js/jquery.min.js"></script>
- <script src="js/mui.min.js"></script>
- <script src="js/msg.js"></script>
- <script src="js/lodash.js"></script>
- <script src="js/backbone.js"></script>
- <script src="js/rappid.min.js"></script>
- <script src="js/models/joint.shapes.smcr.js"></script>
- <script src="js/map.js"></script>
- <script src="js/models/joint.shapes.app.js"></script>
- <script type="text/javascript">
- var $btlist = $('#btlist');
- $(function() {
- //获取保存的ip、agvid、mapid等,如果没有数据,则设置为默认
- if (localStorage.getItem("ip") == "" || localStorage.getItem("ip") == null) {
- ip = "192.168.1.92:8888";
- url = "http://192.168.1.92:8888"
- } else {
- ip = localStorage.getItem("ip") + ":8888";
- url = "http://" + localStorage.getItem("ip") + ":8888";
- }
- if (localStorage.getItem("agvid") == "" || localStorage.getItem("agvid") == null) {
- agvid = 1;
- } else {
- agvid = parseInt(localStorage.getItem("agvid"))
- }
- if (localStorage.getItem("mapid") == "" || localStorage.getItem("mapid") == null) {
- mapid = "2019081410472902";
- } else {
- mapid = localStorage.getItem("mapid")
- }
- //获取按钮
- createList();
- //获取状态
- startLog();
- setInterval(function() {
- if (ws.readyState === 3) {
- startLog();
- }
- }, 1000);
- //设置操作按钮
- $("#gostart").addClass("mui-hidden");
- $("#moving").attr("disabled", true);
- $("#start").attr("disabled", true);
- //设置页面可以左滑右滑跳转页面
- var windowHeight = $(window).height(),
- $body = $("body");
- $("body").on("touchstart", function(e) {
- e.preventDefault();
- startX = e.originalEvent.changedTouches[0].pageX,
- startY = e.originalEvent.changedTouches[0].pageY;
- });
- $("body").on("touchmove", function(e) {
- e.preventDefault();
- moveEndX = e.originalEvent.changedTouches[0].pageX,
- moveEndY = e.originalEvent.changedTouches[0].pageY,
- X = moveEndX - startX,
- Y = moveEndY - startY;
- if (Math.abs(X) > Math.abs(Y) && X > 0) {
- window.location.href = "internet.html"; //right
- } else if (Math.abs(X) > Math.abs(Y) && X < 0) {
- window.location.href = "remote.html"; //left
- } else if (Math.abs(Y) > Math.abs(X) && Y > 0) {
- return //bottom
- } else if (Math.abs(Y) > Math.abs(X) && Y < 0) {
- return //top
- } else {
- return
- }
- });
- })
- //按钮点击事件
- function onSelectStation(evt) {
- var $this = $(this);
- if ($("div[id='btlist']").is(':active')) {
- $this.removeClass('active');
- } else {
- $this.addClass('active');
- }
- if ($("div[id='btlist']").find(".active").length == 1) {
- $("#moving").attr("disabled", false);
- $this.addClass('up');
- $("#start").removeAttr("disabled");
- $("#cancel").removeAttr("disabled");
- } else if ($("div[id='btlist']").find(".active").length == 2) {
- $("#gomoving").addClass("mui-hidden");
- $("#gostart").removeClass("mui-hidden");
- $this.addClass('down');
- $('#start').attr("disabled", false);
- $("#handling").removeAttr("disabled");
- }
- if ($("div[id='btlist']").find(".active").length >= 2) {
- $("button[name='stbtn']").css("pointer-events", "none")
- } else {
- $("button[name='stbtn']").css("pointer-events", "auto")
- }
- };
- //取消按钮操作
- function Reset(evt) {
- if ($("div[id='btlist']").find(".active")) {
- $("#gostart").addClass("mui-hidden");
- $("#gomoving").removeClass("mui-hidden");
- $("button[name='stbtn']").removeClass('up');
- $("button[name='stbtn']").removeClass('down');
- $("button[name='stbtn']").removeClass('active');
- $("button[name='stbtn']").css("pointer-events", "auto");
- $('#start').attr("disabled", true);
- $('#cancel').attr("disabled", true);
- $('#moving').attr("disabled", true);
- }
- }
- //移动按钮
- $("#moving").click(function() {
- let to;
- $("div[id='btlist']").find(".up").each(function(evt){
- to = parseInt(($(this).context).id);
- });
- SendCmd(AgvId, msgTypeToStation, {"Stn":to}, function(d) {
- console.log("AddTransTask", d);
- Reset()
- })
- });
- //搬运按钮
- $("#start").click(function() {
- var bt_value = [];
- $("div[id='btlist']").find(".up").each(function(evt) {
- bt_value.push($(this).val());
- });
- $("div[id='btlist']").find(".down").each(function(evt) {
- bt_value.push($(this).val());
- });
- AddTransTask(AgvId, bt_value[0], bt_value[1], function(d) {
- //console.log("AddTransTask", d);
- Reset()
- })
- });
-
- function AddTransTask(agvId, from, to, callback){
- $.post(url+"/task", {
- id:agvId,
- from: from,
- to: to
- }, callback);
- };
- function SendCmd(agvId, cmd, opt, func) {
- let param = {"t":cmd};
- opt = _.extend(param, opt);
- //console.log("param", opt);
- $.post(url+"/agv/SendString/" + agvId,
- JSON.stringify(opt),
- func
- );
- }
- //取消按钮
- $("#cancel").on("click", Reset);
- //填充按钮列表
- function createList() {
- $.get(url + "/map/getStations/" + mapid, function(data) {
- trs = "";
- for (i in data) {
- if (data[i].Name != "") {
- trs += '<div class="mui-col mui-col-xs-3" drag-id="' + data[i].Id + '">' +
- '<button type="button" class="mui-btn mui-btn-royal mui-btn-block" name="stbtn" id="' + data[i].Id +
- '" value="' + data[i].Id + '">' +
- data[i].Name + '</button></div>'
- }
- }
- $btlist.append(trs);
- //注册按钮点击事件
- $("button[name]").on("touchstart", onSelectStation);
- });
- }
- //新建ws连接,获取agv的状态
- let ws;
- function startLog() {
- ws = new WebSocket("ws://" + ip + "/ws/msg/" + agvid);
- ws.onmessage = function(e) {
- let result;
- let msg = JSON.parse(e.data);
- switch (msg.type) {
- case msgTypeStatus:
- // 每秒一次状态
- let stMap = JSON.parse(msg.data);
- //根据状态设置图标等
- showStatusValue(stMap);
- //当前站点按钮文字闪烁
- if (agvid == msg.id) {
- let stMap = JSON.parse(msg.data);
- $("#" + stMap.Station + "").toggleClass("text-success");
- }
- break;
- //读取设置状态,可以获得电池伏数
- case msgTypeGetCfg:
- //console.log(msg.type, msg.data);
- break;
- default:
- console.log(msg.type, msg.data);
- }
- };
- }
- //根据获取到的agv状态,设置速度、电量、站点、顶升、提示信息、运行按钮等的颜色和文字显示
- function showStatusValue(status) {
- for (let k in status) {
- let v = status[k];
- //速度显示
- if (k == "Speed") {
- if (v >= "30") { //SpeedHigh
- document.getElementById("speed").src = "img/speed-high.png";
- }
- if (v >= "20") { //SpeedMid
- document.getElementById("speed").src = "img/speed-medium.png";
- }
- if (v <= "10") { //SpeedLow
- document.getElementById("speed").src = "img/speed-low.png";
- }
- }
- //电量显示
- if (k == "BatteryVolt") {
- if (v >= "52") { //BatteryVoltFull
- document.getElementById("battery").src = "img/battery-100.png";
- }
- if ("52" < v >= "50") { //BatteryVoltHigh
- document.getElementById("battery").src = "img/battery-80.png";
- }
- if ("50" < v >= "48") { //BatteryVoltMid
- document.getElementById("battery").src = "img/battery-60.png";
- }
- if ("48" < v >= "47") { //BatteryVoltLow
- document.getElementById("battery").src = "img/battery-40.png";
- }
- if ("47" < v >= "45") { //BatteryVoltWarn
- document.getElementById("battery").src = "img/battery-20.png";
- }
- if (v <= "45") { //BatteryVoltStop
- document.getElementById("battery").src = "img/battery-0.png";
- }
- }
- //目标站点
- if (k == "TgtStation") {
- if (v == "65535") {
- $("#tgtstation").text("0");
- } else {
- $("#tgtstation").text(v);
- }
- }
- //顶升状态
- if (k == "liftstatus") {
- if (v == "1" || v == "3" || v == "5" || v == "7") {
- document.getElementById("liftstatus").src = "img/liftstatus-up.png";
- } else if (v == "0") {
- document.getElementById("liftstatus").src = "img/liftstatus.png";
- } else {
- document.getElementById("liftstatus").src = "img/liftstatus-down.png";
- }
- }
- //停止运行注意按钮及信息提示框
- if (k == "Status") {
- if (v == "1") {
- $("#info").text("未设置状态");
- }
- if (v == "2") {
- document.getElementById("run").style.backgroundImage = "url('img/btn2_bg.png')";
- }
- if (v == "3" || v == "4" || v == "9") {
- if (v == "3") {
- $("#info").text("停止状态");
- }
- if (v == "4") {
- $("#info").text("急停按钮急停状态");
- }
- if (v == "9") {
- $("#info").text("手动控制状态");
- }
- document.getElementById("stop").style.backgroundImage = "url('img/btn3_bg.png')";
- }
- if (v == "6") {
- $("#info").text("驱动器错误");
- }
- if (v == "7") {
- $("#info").text("导航错误");
- }
- if (v == "8") {
- $("#info").text("任务错误");
- }
- if (v == "11" || v == "22") {
- if (v == "11") {
- $("#info").text("遇到障碍物停止 或者 冲突区域");
- }
- if (v == "22") {
- $("#info").text("车辆遇到障碍物靠近");
- }
- document.getElementById("warning").style.backgroundImage = "url('img/btn1_bg.png')";
- }
- if (v == "12") {
- $("#info").text("防撞条紧急停止");
- }
- if (v == "15") {
- $("#info").text("电压低");
- }
- if (v == "21") {
- $("#info").text("车辆低电压运行");
- }
- if (v == "31") {
- $("#info").text("正方向磁导航脱线");
- }
- if (v == "32") {
- $("#info").text("反方向磁导航脱线");
- }
- if (v == "33") {
- $("#info").text("正方向磁导航脱线");
- }
- if (v == "34") {
- $("#info").text("反方向磁导航脱线");
- }
- if (v == "71" || v == "72" || v == "73") {
- $("#info").text("取货物时举升不为空");
- }
- }
- }
- }
- </script>
- </html>
|