index.html 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>华力机电SIMANC</title>
  6. <meta name="viewport" content="width=device-width, initial-scale=1,maximum-scale=1,user-scalable=no">
  7. <meta name="apple-mobile-web-app-capable" content="yes">
  8. <meta name="apple-mobile-web-app-status-bar-style" content="black">
  9. <!--标准mui.css-->
  10. <link rel="stylesheet" type="text/css" href="css/mui.min.css">
  11. <!--App自定义的css-->
  12. <link rel="stylesheet" type="text/css" href="css/app.css" />
  13. <style>
  14. .mui-btn-block {
  15. margin-bottom: 0;
  16. }
  17. .mui-content-padded {
  18. margin: 2px;
  19. }
  20. .mui-col {
  21. display: inline-block;
  22. padding: 2px;
  23. }
  24. /*滚动条样式*/
  25. ::-webkit-scrollbar {
  26. width: 10px;
  27. background-color: #F5F5F5;
  28. }
  29. /*定义滚动条轨道 内阴影+圆角*/
  30. ::-webkit-scrollbar-track {
  31. background-color: #103643;
  32. }
  33. /*定义滑块 内阴影+圆角*/
  34. ::-webkit-scrollbar-thumb {
  35. background-color: #0b6d78;
  36. }
  37. .mui-btn-royal {
  38. background-color: rgba(141, 157, 199, 0.5);
  39. border: 1px solid rgba(141, 157, 199, 0.5)
  40. }
  41. .active {
  42. background-color: #d4d4d4;
  43. color: white;
  44. }
  45. .up {
  46. background: #0087c5 url(img/top.svg) no-repeat 50% 10%;
  47. }
  48. .down {
  49. background: #0087c5 url(img/bottom.svg) no-repeat 50% 10%;
  50. }
  51. .text-success {
  52. color: #27c24c
  53. }
  54. .mui-col-xs-3 {
  55. width: 24%;
  56. }
  57. </style>
  58. </head>
  59. <body style="background: url(img/bg.png) no-repeat 0px 0px">
  60. <div class="mui-content" style="background: #2e3342;background-color: rgba(255,255,255,0)">
  61. <div class="mui-content-padded">
  62. <div class="mui-row">
  63. <div class="mui-col mui-col-xs-12">
  64. <span id="agvstatus" style="position: fixed;">·</span>
  65. <div id="title" style="text-align: center;padding-bottom: 2px;background: url(img/title_bg.png) no-repeat 0 7px;background-size:100%;">
  66. <a style="color: #FFFFFF;font-size: 20px;">华力西曼克</a>
  67. </div>
  68. </div>
  69. <div class="mui-col mui-col-xs-12" id="btt" style="min-height:480px;overflow-y:auto;max-height:480px">
  70. <div class="mui-col mui-col-xs-12" style="height: 235px;text-align: center;background: url(img/top_bg2.png) no-repeat 0 0;background-size:100%;">
  71. <div class="mui-col mui-col-xs-12" style="padding-top: 10px;height: 30px;">
  72. <div style=" width: 50%;float: left;">
  73. <img id="speed" src="" style="margin-left: -80px;width: 13%;">
  74. </div>
  75. <div style=" width: 50%;float: left;">
  76. <img id="battery" src="img/battery-100.png" style="margin-right: -80px;width: 23%;">
  77. </div>
  78. </div>
  79. <div class="mui-col mui-col-xs-12" style="margin-top: -5px;">
  80. <div id="tgts" style="width: 120px;height:90px;border-radius: 12px;border: 2px solid #298890;float: left;margin-left: 23px;">
  81. <div style="margin-left: -60px;margin-top: 15px;">
  82. <a style="color: #FFFFFF;font-size: 18px;">目标</a><br>
  83. </div>
  84. <div style="margin-left: -60px;margin-top: 10px;">
  85. <a style="color: #FFFFFF;font-size: 18px;">站点</a><br>
  86. </div>
  87. <div style="margin-left: 40px;margin-top: -35px;">
  88. <a id="tgtstation" style="color: #FFFFFF;font-size: 50px;"></a><br>
  89. </div>
  90. </div>
  91. <div id="jack" style="width: 120px;height:90px;border-radius: 12px;border: 2px solid #298890;float: right;margin-right: 20px;">
  92. <div style="margin-left: -60px;margin-top: 15px;">
  93. <a style="color: #FFFFFF;font-size: 18px;">顶升</a><br>
  94. </div>
  95. <div style="margin-left: -60px;margin-top: 10px;">
  96. <a style="color: #FFFFFF;font-size: 18px;">状态</a><br>
  97. </div>
  98. <div style="margin-left: 50px;margin-top: -53px;">
  99. <img id="liftstatus" src="img/liftstatus.png" width="60%">
  100. </div>
  101. </div>
  102. </div>
  103. <div class="mui-col mui-col-xs-12" style="height: 40px;padding-left: 15px;margin-top: -5px;">
  104. <div id="stop" style="width: 30%;height: 40px;line-height:40px;float: left;margin-left: 5px;background: url(img/btn4_bg.png);color: #FFFFFF;text-align: center;">停止</div>
  105. <div id="run" style="width: 30%;height: 40px;line-height:40px;float: left;margin-left: 5px;background: url(img/btn4_bg.png);color: #FFFFFF;text-align: center;">运行</div>
  106. <div id="warning" style="width: 30%;height: 40px;line-height:40px;float: left;margin-left: 5px;background: url(img/btn4_bg.png);color: #FFFFFF;text-align: center;">注意</div>
  107. </div>
  108. <div class="mui-col mui-col-xs-12">
  109. <div id="info" style="width: 89%;height: 35px;margin-left: 19px;color:#fff;font-size:15px;line-height: 30px;background-color: #0b6d78;border-radius: 3px;text-align: center;padding-left: 5px;"></div>
  110. </div>
  111. </div>
  112. <div class="mui-col mui-col-xs-12" style="margin-top: -5px;">
  113. <div id="btlist" style="padding-left: 15px;height:190px">
  114. </div>
  115. </div>
  116. </div>
  117. <div class="mui-col mui-col-xs-12" style="text-align:center;margin-top: 10px;">
  118. <div class="mui-col mui-col-xs-2">
  119. <a href="settings.html" style="color: #9fb3b4;"><span class="mui-icon mui-icon-settings"></span></a>
  120. </div>
  121. <!-- <div class="mui-col mui-col-xs-3" id="gomoving">
  122. <button type="button" class="mui-btn mui-btn-royal mui-btn-block operation" id="moving" style="border:1px solid #4a5a6a;">移动</button>
  123. </div> -->
  124. <div class="mui-col mui-col-xs-3" id="gostart">
  125. <button type="button" class="mui-btn mui-btn-royal mui-btn-block operation" id="start" style="border:1px solid #4a5a6a;">搬运</button>
  126. </div>
  127. <div class="mui-col mui-col-xs-3">
  128. <button type="button" class="mui-btn mui-btn-royal mui-btn-block operation" id="cancel" style="border:1px solid #4a5a6a;">取消</button>
  129. </div>
  130. <div class="mui-col mui-col-xs-2">
  131. <a href="tasklist.html" style="color: #9fb3b4;"><span class="mui-icon mui-icon-bars"></span></a>
  132. </div>
  133. </div>
  134. </div>
  135. </div>
  136. </div>
  137. </body>
  138. <script src="js/jquery.min.js"></script>
  139. <script src="js/msg.js"></script>
  140. <script src="js/Sortable.min.js"></script>
  141. <script src="js/mui.js"></script>
  142. <script src="js/jquery.min.js"></script>
  143. <script src="js/mui.min.js"></script>
  144. <script type="text/javascript">
  145. var $btlist = $('#btlist');
  146. $(function() {
  147. //获取保存的ip、agvid、mapid等,如果没有数据,则设置为默认
  148. if (localStorage.getItem("ip") == "" || localStorage.getItem("ip") == null) {
  149. ip = "192.168.1.92:8888";
  150. url = "http://192.168.1.92:8888"
  151. } else {
  152. ip = localStorage.getItem("ip") + ":8888";
  153. url = "http://" + localStorage.getItem("ip") + ":8888";
  154. }
  155. if (localStorage.getItem("agvid") == "" || localStorage.getItem("agvid") == null) {
  156. agvid = 1;
  157. } else {
  158. agvid = parseInt(localStorage.getItem("agvid"))
  159. }
  160. if (localStorage.getItem("mapid") == "" || localStorage.getItem("mapid") == null) {
  161. mapid = "2020032608412704";
  162. } else {
  163. mapid = localStorage.getItem("mapid")
  164. }
  165. //获取按钮
  166. createList();
  167. //设置操作按钮
  168. $("#gostart").addClass("mui-hidden");
  169. $("#moving").attr("disabled", true);
  170. $("#start").attr("disabled", true);
  171. $('#cancel').attr("disabled", true);
  172. /*
  173. //设置页面可以左滑右滑跳转页面
  174. var windowHeight = $(window).height(),
  175. $body = $("body");
  176. $("body").on("touchstart", function(e) {
  177. e.preventDefault();
  178. startX = e.originalEvent.changedTouches[0].pageX,
  179. startY = e.originalEvent.changedTouches[0].pageY;
  180. });
  181. $("body").on("touchmove", function(e) {
  182. e.preventDefault();
  183. moveEndX = e.originalEvent.changedTouches[0].pageX,
  184. moveEndY = e.originalEvent.changedTouches[0].pageY,
  185. X = moveEndX - startX,
  186. Y = moveEndY - startY;
  187. if (Math.abs(X) > Math.abs(Y) && X > 150) {
  188. window.location.href = "settings.html"; //right
  189. }
  190. if (Math.abs(X) > Math.abs(Y) && X < -150) {
  191. window.location.href = "tasklist.html"; //left
  192. //return
  193. }
  194. });
  195. */
  196. })
  197. //按钮点击事件
  198. function onSelectStation(evt) {
  199. var $this = $(this);
  200. if ($("div[id='btlist']").is(':active')) {
  201. $this.removeClass('active');
  202. } else {
  203. $this.addClass('active');
  204. }
  205. if ($("div[id='btlist']").find(".active").length == 1) {
  206. $("#moving").attr("disabled", false);
  207. $this.addClass('up');
  208. $("#start").removeAttr("disabled");
  209. $("#cancel").removeAttr("disabled");
  210. } else if ($("div[id='btlist']").find(".active").length == 2) {
  211. $("#gomoving").addClass("mui-hidden");
  212. $("#gostart").removeClass("mui-hidden");
  213. $this.addClass('down');
  214. $('#start').attr("disabled", false);
  215. $("#handling").removeAttr("disabled");
  216. }
  217. if ($("div[id='btlist']").find(".active").length >= 2) {
  218. $("button[name='stbtn']").css("pointer-events", "none")
  219. } else {
  220. $("button[name='stbtn']").css("pointer-events", "auto")
  221. }
  222. };
  223. //取消按钮操作
  224. function Reset(evt) {
  225. if ($("div[id='btlist']").find(".active")) {
  226. $("#gostart").addClass("mui-hidden");
  227. $("#gomoving").removeClass("mui-hidden");
  228. $("button[name='stbtn']").removeClass('up');
  229. $("button[name='stbtn']").removeClass('down');
  230. $("button[name='stbtn']").removeClass('active');
  231. $("button[name='stbtn']").css("pointer-events", "auto");
  232. $('#start').attr("disabled", true);
  233. $('#cancel').attr("disabled", true);
  234. $('#moving').attr("disabled", true);
  235. }
  236. }
  237. //移动按钮
  238. $("#moving").click(function() {
  239. let to;
  240. $("div[id='btlist']").find(".up").each(function(evt) {
  241. to = parseInt(($(this).context).id);
  242. });
  243. SendCmd(agvid, msgTypeToStation, {
  244. "Stn": to
  245. }, function(d) {
  246. console.log("AddTransTask", d);
  247. Reset()
  248. })
  249. });
  250. //搬运按钮
  251. $("#start").click(function() {
  252. var bt_value = [];
  253. $("div[id='btlist']").find(".up").each(function(evt) {
  254. bt_value.push($(this).val());
  255. });
  256. $("div[id='btlist']").find(".down").each(function(evt) {
  257. bt_value.push($(this).val());
  258. });
  259. AddTransTask(agvid, bt_value[0], bt_value[1], function(d) {
  260. if (d == "ok"){
  261. mui.toast("任务发送成功...")
  262. } else {
  263. mui.toast("任务发送失败...")
  264. }
  265. Reset()
  266. })
  267. });
  268. function AddTransTask(agvid, from, to, callback) {
  269. $.post(url + "/task", {
  270. id: agvid,
  271. from: from,
  272. to: to
  273. }, callback);
  274. };
  275. function SendCmd(agvid, cmd, opt, func) {
  276. let param = {
  277. "t": cmd
  278. };
  279. opt = _.extend(param, opt);
  280. //console.log("param", opt);
  281. $.post(url + "/agv/SendString/" + agvid,
  282. JSON.stringify(opt),
  283. func
  284. );
  285. }
  286. //取消按钮
  287. $("#cancel").on("click", Reset);
  288. //填充按钮列表
  289. function createList() {
  290. $.get(url + "/map/getStations/" + mapid, function(data) {
  291. IDARR = localStorage.getItem(mapid+agvid+"ARR");
  292. trs = "";
  293. if(IDARR == "" ||IDARR == undefined){
  294. ARRS = [];
  295. for (i in data) {
  296. if (data[i].Name != "" && data[i].Name != "rect") {
  297. var ids = data[i].Id - (agvid * 100)
  298. ARRS.push(parseInt(data[i].Id));
  299. trs += '<div class="mui-col mui-col-xs-3" drag-id="'+ids+'">' +
  300. '<button type="button" class="mui-btn mui-btn-royal mui-btn-block" name="stbtn" id="' + ids +
  301. '" value="' + ids + '">' +
  302. data[i].Name + '</button></div>'
  303. }
  304. }
  305. ARR = ARRS.join(",");
  306. localStorage.setItem(mapid + agvid + 'ARR', ARR);
  307. } else {
  308. arr = IDARR.split(",");// 在每个逗号(,)处进行分解。
  309. var id_arr = arr.sort(function(a, b){return a - b});//按从小到大排序
  310. for (x in id_arr) {
  311. for (i in data) {
  312. if((data[i].Name != "") && data[i].Name != "rect"){
  313. var ids = data[i].Id - (agvid * 100)
  314. if ((data[i].Id == id_arr[x])) {
  315. trs += '<div class="mui-col mui-col-xs-3" drag-id="'+ids+'">' +
  316. '<button type="button" class="mui-btn mui-btn-royal mui-btn-block" name="stbtn" id="' + ids +
  317. '" value="' + ids + '">' +
  318. data[i].Name + '</button></div>'
  319. }
  320. }
  321. }
  322. }
  323. }
  324. $btlist.append(trs);
  325. //注册按钮点击事件click touchstart
  326. $("button[name]").on("touchstart", onSelectStation);
  327. });
  328. }
  329. //根据获取到的agv状态,设置速度、电量、站点、顶升、提示信息、运行按钮等的颜色和文字显示
  330. function showStatusValue(status) {
  331. for (let k in status) {
  332. let v = status[k];
  333. //电量显示
  334. if (k == "BatteryVolt") {
  335. if (v >= 5200) { //BatteryVoltFull
  336. document.getElementById("battery").src = "img/battery-100.png";
  337. }
  338. if (5000 <= v && v < 5200) { //BatteryVoltHigh
  339. document.getElementById("battery").src = "img/battery-80.png";
  340. }
  341. if (4800 <= v && v < 5000) { //BatteryVoltMid
  342. document.getElementById("battery").src = "img/battery-60.png";
  343. }
  344. if (4700 <= v && v < 4800) { //BatteryVoltLow
  345. document.getElementById("battery").src = "img/battery-40.png";
  346. }
  347. if (4500 <= v && v < 4700) { //BatteryVoltWarn
  348. document.getElementById("battery").src = "img/battery-20.png";
  349. }
  350. if (v <= 4500) { //BatteryVoltStop
  351. document.getElementById("battery").src = "img/battery-0.png";
  352. }
  353. }
  354. //目标站点
  355. if (k == "TgtStation") {
  356. if (v == "65535") {
  357. $("#tgtstation").text("0");
  358. } else {
  359. $("#tgtstation").text(v);
  360. }
  361. }
  362. //顶升状态
  363. if (k == "LiftStatus") {
  364. if (v == 1 || v == 3 || v == 5 || v == 7) {
  365. document.getElementById("liftstatus").src = "img/liftstatus-up.png";
  366. } else if (v == 0) {
  367. document.getElementById("liftstatus").src = "img/liftstatus.png";
  368. } else {
  369. if (status.Status == "1") {
  370. document.getElementById("liftstatus").src = "img/liftstatus.png";
  371. } else {
  372. document.getElementById("liftstatus").src = "img/liftstatus-down.png";
  373. }
  374. }
  375. }
  376. //停止运行注意按钮及信息提示框
  377. if (k == "Status") {
  378. document.getElementById("speed").src = "";
  379. if (v == 0) {
  380. $("#info").text("未设置");
  381. }
  382. if (v == 1) {
  383. $("#info").text("就绪");
  384. }
  385. if (v == 2) {
  386. $("#info").text("运行");
  387. document.getElementById("speed").src = "img/speed-high.png";
  388. document.getElementById("run").style.backgroundImage = "url('img/btn2_bg.png')";
  389. } else {
  390. document.getElementById("run").style.backgroundImage = "url('img/btn4_bg.png')";
  391. }
  392. if (v == 3 || v == 4 ||(v == 5)) {
  393. if (v == 3) {
  394. $("#info").text("停止");
  395. }
  396. if (v == 4) {
  397. $("#info").text("急停");
  398. }
  399. if (v == 5) {
  400. $("#info").text("刹车");
  401. }
  402. document.getElementById("stop").style.backgroundImage = "url('img/btn3_bg.png')";
  403. } else {
  404. document.getElementById("stop").style.backgroundImage = "url('img/btn4_bg.png')";
  405. }
  406. if (v == 6) {
  407. $("#info").text("驱动器错误");
  408. }
  409. if (v == 7) {
  410. $("#info").text("导航错误");
  411. }
  412. if (v == 8) {
  413. $("#info").text("任务错误");
  414. }
  415. if (v == 9) {
  416. document.getElementById("speed").src = "img/speed-medium.png";
  417. $("#info").text("手动控制");
  418. }
  419. if (v == 11 || v == 22) {
  420. if (v == 11) {
  421. document.getElementById("speed").src = "img/speed-medium.png";
  422. $("#info").text("前方障碍");
  423. }
  424. if (v == 22) {
  425. document.getElementById("speed").src = "img/speed-medium.png";
  426. $("#info").text("障碍减速");
  427. }
  428. document.getElementById("warning").style.backgroundImage = "url('img/btn1_bg.png')";
  429. } else {
  430. document.getElementById("warning").style.backgroundImage = "url('img/btn4_bg.png')";
  431. }
  432. if (v == 12) {
  433. $("#info").text("防撞停止");
  434. }
  435. if (v == 15) {
  436. $("#info").text("低电压停止");
  437. }
  438. if (v == 21) {
  439. $("#info").text("低电压运行");
  440. }
  441. if (v == 31) {
  442. $("#info").text("前磁导脱线");
  443. }
  444. if (v == 32) {
  445. $("#info").text("后磁导脱线");
  446. }
  447. if (v == 33) {
  448. $("#info").text("左磁导脱线");
  449. }
  450. if (v == 34) {
  451. $("#info").text("右磁导脱线");
  452. }
  453. if (v == 71) {
  454. $("#info").text("取货失败1");
  455. }
  456. if (v == 72) {
  457. $("#info").text("取货失败2");
  458. }
  459. if (v == 73) {
  460. $("#info").text("放货失败");
  461. }
  462. }
  463. }
  464. if (status.Status == "9" && status.FWlkRpm != "0") {
  465. document.getElementById("run").style.backgroundImage = "url('img/btn2_bg.png')";
  466. document.getElementById("stop").style.backgroundImage = "url('img/btn4_bg.png')";
  467. }
  468. if (status.Status == "9" && status.FWlkRpm == "0") {
  469. document.getElementById("run").style.backgroundImage = "url('img/btn4_bg.png')";
  470. document.getElementById("stop").style.backgroundImage = "url('img/btn3_bg.png')";
  471. }
  472. };
  473. $(function() {
  474. GetTransTask(agvid, function (d) {
  475. console.log("GetTransTask: ", d)
  476. });
  477. })
  478. function GetTransTask(agvid, callback) {
  479. $.post(url + "/task/get", {
  480. id: agvid,
  481. }, callback);
  482. }
  483. </script>
  484. </html>