index.html 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475
  1. <!DOCTYPE html>
  2. <html>
  3. <head>
  4. <meta charset="utf-8">
  5. <title>森之洋</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: 23%;
  56. }
  57. .mui-col-xs-2 {
  58. width: 23%;
  59. }
  60. </style>
  61. </head>
  62. <body style="background: url(img/bg.png) no-repeat 0px 0px">
  63. <div class="mui-content" style="background: #2e3342;background-color: rgba(255,255,255,0)">
  64. <div class="mui-content-padded">
  65. <div class="mui-row">
  66. <div class="mui-col mui-col-xs-12">
  67. <span id="agvstatus" style="position: fixed;">·</span>
  68. <div id="title"
  69. style="text-align: center;padding-bottom: 2px;background: url(img/title_bg.png) no-repeat 0 7px;background-size:100%;">
  70. <a style="color: #FFFFFF;font-size: 20px;">森之洋</a>
  71. </div>
  72. </div>
  73. <div class="mui-col mui-col-xs-12" id="btt"
  74. style="min-height:490px;overflow-y:auto;max-height:490px;">
  75. <div class="mui-col mui-col-xs-12"
  76. style="height: 235px;text-align: center;background: url(img/top_bg2.png) no-repeat 0 -10px;background-size:100%;">
  77. <!-- <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%;"> -->
  78. <div class="mui-col mui-col-xs-12" style="padding-top: 10px;height: 30px;">
  79. <div style=" width: 50%;float: left;">
  80. <img id="speed" src="" style="margin-left: -80px;width: 13%;">
  81. </div>
  82. <div style=" width: 50%;float: left;">
  83. <img id="battery" src="img/battery-100.png" style="margin-right: -80px;width: 23%;">
  84. </div>
  85. </div>
  86. <div class="mui-col mui-col-xs-12" style="margin-top: -5px;">
  87. <div id="tgts"
  88. style="width: 120px;height:90px;border-radius: 12px;border: 2px solid #298890;float: left;margin-left: 23px;">
  89. <div style="margin-left: -60px;margin-top: 15px;">
  90. <a style="color: #FFFFFF;font-size: 18px;">目标</a><br>
  91. </div>
  92. <div style="margin-left: -60px;margin-top: 10px;">
  93. <a style="color: #FFFFFF;font-size: 18px;">站点</a><br>
  94. </div>
  95. <div style="margin-left: 40px;margin-top: -35px;">
  96. <a id="tgtstation" style="color: #FFFFFF;font-size: 50px;"></a><br>
  97. </div>
  98. </div>
  99. <div id="jack"
  100. style="width: 120px;height:90px;border-radius: 12px;border: 2px solid #298890;float: right;margin-right: 20px;">
  101. <div style="margin-left: -60px;margin-top: 15px;">
  102. <a style="color: #FFFFFF;font-size: 18px;">顶升</a><br>
  103. </div>
  104. <div style="margin-left: -60px;margin-top: 10px;">
  105. <a style="color: #FFFFFF;font-size: 18px;">状态</a><br>
  106. </div>
  107. <div style="margin-left: 50px;margin-top: -53px;">
  108. <img id="liftstatus" src="img/liftstatus.png" width="60%">
  109. </div>
  110. </div>
  111. </div>
  112. <div class="mui-col mui-col-xs-12"
  113. style="height: 40px;padding-left: 15px;margin-top: -5px;">
  114. <div id="stop"
  115. style="width: 30%;height: 40px;line-height:40px;float: left;margin-left: 5px;background: url(img/btn4_bg.png);color: #FFFFFF;text-align: center;">
  116. 停止</div>
  117. <div id="run"
  118. style="width: 30%;height: 40px;line-height:40px;float: left;margin-left: 5px;background: url(img/btn4_bg.png);color: #FFFFFF;text-align: center;">
  119. 运行</div>
  120. <div id="warning"
  121. style="width: 30%;height: 40px;line-height:40px;float: left;margin-left: 5px;background: url(img/btn4_bg.png);color: #FFFFFF;text-align: center;">
  122. 注意</div>
  123. </div>
  124. <div class="mui-col mui-col-xs-12">
  125. <div id="info"
  126. style="width: 89%;height: 30px;margin-left: 19px;color:#fff;font-size:15px;line-height: 30px;background-color: #0b6d78;border-radius: 3px;text-align: center;padding-left: 5px;">
  127. </div>
  128. </div>
  129. </div>
  130. <div class="mui-col mui-col-xs-12" style="margin-top: -5px;">
  131. <div class="mui-col mui-col-xs-12">
  132. <div id="workstatus"
  133. style="margin-top: -15px;width: 89%;height: 55px;line-height: 55px;margin-left: 19px;color:#fff;font-size:15px;background-color: #0b6d78;border-radius: 3px;text-align: center;padding-left: 5px;">
  134. 前序工作状态:<span id="status"></span>
  135. </div>
  136. </div>
  137. <div id="btlist" style="padding-left: 15px;padding-right: 15px;height:175px">
  138. <div class="mui-col mui-col-xs-12 client" style="padding-top:10px">
  139. <button type="button" class="mui-btn mui-btn-primary mui-btn-block mui-hidden"
  140. id="Call"></button>
  141. </div>
  142. <div class="mui-col mui-col-xs-12 client" style="padding-top:10px">
  143. <button type="button" class="mui-btn mui-btn-success mui-btn-block mui-hidden"
  144. id="Finish">完成</button>
  145. </div>
  146. </div>
  147. </div>
  148. </div>
  149. <div class="mui-col mui-col-xs-12" style="text-align:center;margin-top: 5px;">
  150. <div class="mui-col mui-col-xs-2">
  151. <a href="settings.html" style="color: #9fb3b4;"><span
  152. class="mui-icon mui-icon-settings"></span></a>
  153. </div>
  154. </div>
  155. </div>
  156. </div>
  157. </div>
  158. </body>
  159. <script src="js/jquery.min.js"></script>
  160. <script src="js/msg.js"></script>
  161. <script src="js/mui.min.js"></script>
  162. <script type="text/javascript">
  163. var $btlist = $('#btlist');
  164. let ip, url, agvid, mapid, site, AcceptId, msgAcceptId;
  165. $(function() {
  166. //获取保存的ip、agvid、mapid等,如果没有数据,则设置为默认
  167. if (localStorage.getItem("ip") == "" || localStorage.getItem("ip") == null) {
  168. ip = "192.168.111.240:8888";
  169. url = "http://192.168.111.240:8888"
  170. } else {
  171. ip = localStorage.getItem("ip") + ":8888";
  172. url = "http://" + localStorage.getItem("ip") + ":8888";
  173. }
  174. if (localStorage.getItem("agvid") == "" || localStorage.getItem("agvid") == null) {
  175. agvid = 1;
  176. } else {
  177. agvid = parseInt(localStorage.getItem("agvid"))
  178. }
  179. if (localStorage.getItem("mapid") == "" || localStorage.getItem("mapid") == null) {
  180. mapid = "2020032608412704";
  181. } else {
  182. mapid = localStorage.getItem("mapid")
  183. }
  184. if (localStorage.getItem("site") == "" || localStorage.getItem("site") == null) {
  185. site = ""
  186. $("#Call").addClass("mui-hidden");
  187. } else {
  188. site = localStorage.getItem("site");
  189. $("#Call").removeClass("mui-hidden");
  190. $("#Call").html(site);
  191. }
  192. AcceptId = localStorage.getItem("AcceptId")
  193. $("#Finish").attr("disabled", true);
  194. startLog();
  195. setInterval(function() {
  196. if (ws.readyState === 3) {
  197. startLog();
  198. }
  199. }, 1000);
  200. })
  201. //完成按钮
  202. $("#Finish").click(function() {
  203. DoneTermTask(agvid, AcceptId, function(d) {
  204. if (d == "ok") {
  205. mui.toast("任务发送成功...")
  206. } else if (d == "lock") {
  207. mui.toast("任务执行中,请稍后重试...")
  208. } else {
  209. mui.toast("请稍后重试...")
  210. }
  211. })
  212. })
  213. //上下箱工位、清扫工位、下料工位、缓存工位
  214. $("#Call").click(function() {
  215. let from, to;
  216. if (site === "上下箱工位") {
  217. from = 4;
  218. to = 1;
  219. }
  220. if (site === "清扫工位") {
  221. from = 1;
  222. to = 2;
  223. }
  224. if (site === "下料工位") {
  225. from = 2;
  226. to = 3;
  227. }
  228. if (site === "缓存工位") {
  229. from = 3;
  230. to = 4;
  231. }
  232. AddTermTask(agvid, AcceptId, from, to, function(d) {
  233. if (d == "ok") {
  234. mui.toast("任务发送成功...")
  235. } else if (d == "lock") {
  236. mui.toast("任务执行中,请稍后重试...")
  237. } else {
  238. mui.toast("请稍后重试...")
  239. }
  240. })
  241. });
  242. function DoneTermTask(agvid, AcceptId, callback) {
  243. $.post(url + "/task/term/done", {
  244. id: agvid,
  245. acceptId: AcceptId
  246. }, callback);
  247. };
  248. function AddTermTask(agvid, AcceptId, from, to, callback) {
  249. $.post(url + "/task/term/send", {
  250. id: agvid,
  251. acceptId: AcceptId,
  252. from: from,
  253. to: to
  254. }, callback);
  255. };
  256. //新建ws连接,获取agv的状态
  257. let ws;
  258. function startLog() {
  259. ws = new WebSocket("ws://" + ip + "/ws/msg/" + agvid);
  260. ws.onmessage = function(e) {
  261. let result;
  262. let msg = JSON.parse(e.data);
  263. // console.log("msg",msg)
  264. switch (msg.type) {
  265. case msgTypeStatus:
  266. // 每秒一次状态
  267. let stMap = JSON.parse(msg.data);
  268. //根据状态设置图标等
  269. showStatusValue(stMap);
  270. //当前站点按钮文字闪烁
  271. if (agvid == msg.id) {
  272. let stMap = JSON.parse(msg.data);
  273. $("#agvstatus").toggleClass("text-success");
  274. }
  275. // 当前工作站点id
  276. msgAcceptId = stMap.AcceptId;
  277. if (msgAcceptId == AcceptId) {
  278. $("#Finish").removeClass("mui-hidden");
  279. $("#Finish").attr("disabled", false);
  280. } else {
  281. $("#Finish").addClass("mui-hidden");
  282. $("#Finish").attr("disabled", true);
  283. }
  284. if ((msgAcceptId == 1 && AcceptId == 2) || (msgAcceptId == 2 && AcceptId == 3) || (msgAcceptId ==
  285. 3 && AcceptId == 4) || (msgAcceptId == 4 && AcceptId == 1)) {
  286. $("#status").html("工作中", +msgAcceptId);
  287. document.getElementById("workstatus").style.backgroundColor = "red"; // "#9C9C9C" ;
  288. } else {
  289. $("#status").html("未工作");
  290. document.getElementById("workstatus").style.backgroundColor = "green"; // "#9C9C9C" ;
  291. }
  292. break;
  293. //读取设置状态,可以获得电池伏数
  294. case msgTypeGetCfg:
  295. //console.log(msg.type, msg.data);
  296. break;
  297. default:
  298. //console.log(msg.type, msg.data);
  299. }
  300. }
  301. }
  302. //根据获取到的agv状态,设置速度、电量、站点、顶升、提示信息、运行按钮等的颜色和文字显示
  303. function showStatusValue(status) {
  304. for (let k in status) {
  305. let v = status[k];
  306. //电量显示
  307. if (k == "BatteryVolt") {
  308. if (v >= 5200) { //BatteryVoltFull
  309. document.getElementById("battery").src = "img/battery-100.png";
  310. }
  311. if (5000 <= v && v < 5200) { //BatteryVoltHigh
  312. document.getElementById("battery").src = "img/battery-80.png";
  313. }
  314. if (4800 <= v && v < 5000) { //BatteryVoltMid
  315. document.getElementById("battery").src = "img/battery-60.png";
  316. }
  317. if (4700 <= v && v < 4800) { //BatteryVoltLow
  318. document.getElementById("battery").src = "img/battery-40.png";
  319. }
  320. if (4500 <= v && v < 4700) { //BatteryVoltWarn
  321. document.getElementById("battery").src = "img/battery-20.png";
  322. }
  323. if (v <= 4500) { //BatteryVoltStop
  324. document.getElementById("battery").src = "img/battery-0.png";
  325. }
  326. }
  327. //目标站点
  328. if (k == "TgtStation") {
  329. if (v == "65535") {
  330. $("#tgtstation").text("0");
  331. } else {
  332. $("#tgtstation").text(v);
  333. }
  334. }
  335. //顶升状态
  336. if (k == "LiftStatus") {
  337. if (v == 1 || v == 3 || v == 5 || v == 7) {
  338. document.getElementById("liftstatus").src = "img/liftstatus-up.png";
  339. } else if (v == 0) {
  340. document.getElementById("liftstatus").src = "img/liftstatus.png";
  341. } else {
  342. if (status.Status == "1") {
  343. document.getElementById("liftstatus").src = "img/liftstatus.png";
  344. } else {
  345. document.getElementById("liftstatus").src = "img/liftstatus-down.png";
  346. }
  347. }
  348. }
  349. //停止运行注意按钮及信息提示框
  350. if (k == "Status") {
  351. document.getElementById("speed").src = "";
  352. if (v == 0) {
  353. $("#info").text("未设置");
  354. }
  355. if (v == 1) {
  356. $("#info").text("就绪");
  357. }
  358. if (v == 2) {
  359. $("#info").text("运行");
  360. document.getElementById("speed").src = "img/speed-high.png";
  361. document.getElementById("run").style.backgroundImage = "url('img/btn2_bg.png')";
  362. } else {
  363. document.getElementById("run").style.backgroundImage = "url('img/btn4_bg.png')";
  364. }
  365. if (v == 3 || v == 4 || (v == 5)) {
  366. if (v == 3) {
  367. $("#info").text("停止");
  368. }
  369. if (v == 4) {
  370. $("#info").text("急停");
  371. }
  372. if (v == 5) {
  373. $("#info").text("防撞停止");
  374. }
  375. document.getElementById("stop").style.backgroundImage = "url('img/btn3_bg.png')";
  376. } else {
  377. document.getElementById("stop").style.backgroundImage = "url('img/btn4_bg.png')";
  378. }
  379. if (v == 6) {
  380. $("#info").text("驱动器错误");
  381. }
  382. if (v == 7) {
  383. $("#info").text("导航错误");
  384. }
  385. if (v == 8) {
  386. $("#info").text("任务错误");
  387. }
  388. if (v == 9) {
  389. document.getElementById("speed").src = "img/speed-medium.png";
  390. $("#info").text("手动控制");
  391. }
  392. if (v == 11 || v == 22) {
  393. if (v == 11) {
  394. document.getElementById("speed").src = "img/speed-medium.png";
  395. $("#info").text("前方障碍");
  396. }
  397. if (v == 22) {
  398. document.getElementById("speed").src = "img/speed-medium.png";
  399. $("#info").text("障碍减速");
  400. }
  401. document.getElementById("warning").style.backgroundImage = "url('img/btn1_bg.png')";
  402. } else {
  403. document.getElementById("warning").style.backgroundImage = "url('img/btn4_bg.png')";
  404. }
  405. if (v == 12) {
  406. $("#info").text("防撞停止");
  407. }
  408. if (v == 15) {
  409. $("#info").text("低电压停止");
  410. }
  411. if (v == 21) {
  412. $("#info").text("低电压运行");
  413. }
  414. if (v == 31) {
  415. $("#info").text("前磁导脱线");
  416. }
  417. if (v == 32) {
  418. $("#info").text("后磁导脱线");
  419. }
  420. if (v == 33) {
  421. $("#info").text("左磁导脱线");
  422. }
  423. if (v == 34) {
  424. $("#info").text("右磁导脱线");
  425. }
  426. if (v == 71) {
  427. $("#info").text("取货失败1");
  428. }
  429. if (v == 72) {
  430. $("#info").text("取货失败2");
  431. }
  432. if (v == 73) {
  433. $("#info").text("放货失败");
  434. }
  435. }
  436. }
  437. if (status.Status == "9" && status.FWlkRpm != "0") {
  438. document.getElementById("run").style.backgroundImage = "url('img/btn2_bg.png')";
  439. document.getElementById("stop").style.backgroundImage = "url('img/btn4_bg.png')";
  440. }
  441. if (status.Status == "9" && status.FWlkRpm == "0") {
  442. document.getElementById("run").style.backgroundImage = "url('img/btn4_bg.png')";
  443. document.getElementById("stop").style.backgroundImage = "url('img/btn3_bg.png')";
  444. }
  445. };
  446. $(function() {
  447. GetTermTask(agvid, function(d) {
  448. console.log("GetTermTask: ", d)
  449. })
  450. })
  451. function GetTermTask(agvid, callback) {
  452. $.post(url + "/task/term/get", {
  453. id: agvid,
  454. }, callback);
  455. }
  456. </script>
  457. </html>