ALNozzles.cshtml 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370
  1. <div id="alNozzlesPage" style="position: relative; width:100%; height:100%;">
  2. <div id="alNozzles" style="position: absolute;top:2.4%; width:100%; height:88.516%;">
  3. <div v-for="n in Nozzles" class="NozzleDiv">
  4. <div class="ALDatas" style="height:55%">
  5. <div class="NozzleId">{{n.SiteLevelNozzleId}}</div>
  6. @*<img v-show="n.FuelingState ==='IDLE'" src="/WebConsole/images/smartFuel/idleStatic.png" class="FuelingState" />*@
  7. @*<img v-show="n.FuelingState ==='FUELING'" src="/WebConsole/images/smartFuel/fuelling.gif" class="FuelingState"/>*@
  8. <img :src="n.imgsource" class="FuelingState" />
  9. <img v-show="n.HealthState === 'NORMAL' && n.FuelingState !=='FUELING'" src="~/WebConsole/images/onlineMonitor/nozzleView/NozzleALNormal.png" class="HealthState" />
  10. <img v-show="n.HealthState === 'WARNING' && n.FuelingState !=='FUELING'" src="~/WebConsole/images/onlineMonitor/nozzleView/NozzleALWarning.png" class="HealthState" />
  11. <img v-show="(n.HealthState === 'DISCONNETED'||n.HealthState === 'NOT_SET'||n.HealthState === 'NO_VR') && n.FuelingState !=='FUELING'" src="~/WebConsole/images/onlineMonitor/nozzleView/NozzleALDisconnect.png" class="HealthState" />
  12. <img v-show="n.HealthState === 'ALARM' && n.FuelingState !=='FUELING'" src="~/WebConsole/images/onlineMonitor/nozzleView/NozzleALAlarm.png" class="HealthState" />
  13. </div>
  14. <div class="ALDatas">
  15. <div class="ALLable">氣</div>
  16. <div class="ALLableData">{{n.VaporVolumeWithDecimal}}</div>
  17. </div>
  18. <div class="ALDatas">
  19. <div class="ALLable">油</div>
  20. <div class="ALLableData">{{n.LiquidVolumeWithDecimal}}</div>
  21. </div>
  22. <div class="ALDatas">
  23. <div class="ALLable" style="width:33%;">氣液比</div>
  24. <div v-if="n.ALIsNormal === true" class="ALLableData" style="width:35%;">{{n.VaporLiquidRatio}}</div>
  25. <div v-else class="ALLableData" style="width: 35%;color: deeppink;">{{n.VaporLiquidRatio}}</div>
  26. </div>
  27. </div>
  28. </div>
  29. <div class="tank_filter_div" v-show="smartFuelEnabled" id="toggleSmartFuel" onclick="ToggleSmartFuel()" style="top:0%;bottom:90%;left:95%;background-image: url(/WebConsole/images/onlineMonitor/nozzleView/SmartFuel.png)">
  30. </div>
  31. </div>
  32. <script>
  33. var currentPage = 1;
  34. var oldPage = currentPage;
  35. var totalPage = 1;
  36. var maxNozzleNumberInOnePage = 12;
  37. var alIntervalId = -1;
  38. //切换至气液比油枪界面
  39. function ToggleSmartFuel() {
  40. RenderDiv("/OnlineMonitor/Nozzles", contentDiv, null, null);
  41. }
  42. var vm = new Vue({
  43. el: '#alNozzlesPage',
  44. data: {
  45. totalPage: 1,
  46. Nozzles: [/*{ "SiteLevelNozzleId": 1, "HealthState": "NORMAL", "LatestTrxFlowData": null, "FuelingState": "IDLE" }*/],
  47. smartFuelEnabled: false,
  48. },
  49. methods: {
  50. },
  51. mouted() {
  52. }
  53. });
  54. $(document).ready(function () {
  55. if (vm === undefined) {
  56. return;
  57. }
  58. if (apis.has("GetPumpsLayout")) {
  59. vm.smartFuelEnabled = true;
  60. }
  61. alIntervalId = setInterval(function () {
  62. console.log("time interval");
  63. if (vm && vm.Nozzles.length === 0) {
  64. ALNozzlesSubscribeEvents();
  65. }
  66. }, 5000);
  67. if (apis.size > 0 && apis.has("GetVRBoardNozzles")) {
  68. ALNozzlesSubscribeEvents();
  69. return;
  70. }
  71. //var requestData = ["localMqtt", ["在线监测"]];
  72. ShowMeAPIS(["localMqtt", ["OnlineWatch"]], function () {
  73. ALNozzlesSubscribeEvents();
  74. });
  75. //var serviceUrl = basicUrl + "/u/?apitype=service&an=ShowMeApi&pn=ProcessorsDispatcher&en=Edge.Core.Processor.Dispatcher.DefaultDispatcher";
  76. //$.ajax({
  77. // url: serviceUrl,
  78. // datatype: "application/json",
  79. // type: 'post',
  80. // contentType: "application/json;charset=utf-8;",
  81. // data: JSON.stringify(requestData),
  82. // beforeSend: function () {
  83. // },
  84. // success: function (data) {
  85. // console.log(data);
  86. // data.forEach(function (d) {
  87. // if (apis.has(d.ApiName)) {
  88. // apis.delete(d.ApiName);
  89. // }
  90. // apis.set(d.ApiName, d.Path.slice(d.Path.length - 1) === "+" ? d.Path.slice(0, d.Path.length - 1) : d.Path);
  91. // });
  92. // ALNozzlesSubscribeEvents();
  93. // },
  94. // error: function (err) {
  95. // console.log(err);
  96. // }
  97. //});
  98. }
  99. );
  100. mqttclient.on('connect', function () {
  101. ALNozzlesSubscribeEvents();
  102. });
  103. //mqttclient.on('message', function (topic, message) {
  104. // if (apis.size > 0 && apis.has("GetVRBoardNozzles_Reply") && topic === apis.get("GetVRBoardNozzles_Reply")) {
  105. // vm.Nozzles = JSON.parse(message.toString());
  106. // }
  107. //});
  108. function OnReply(apis, topic, jsonObj) {
  109. if (apis.size > 0 && apis.has("GetVRBoardNozzles_Reply") && topic === apis.get("GetVRBoardNozzles_Reply")) {
  110. //vm.Nozzles = jsonObj;
  111. if (!Array.isArray(jsonObj)) {
  112. console.log("Invalid response GetVRBoardNozzles_Reply");
  113. return;
  114. }
  115. //stop the interval if can receive message from mqtt
  116. if (alIntervalId !== -1) {
  117. console.log("stop the interval:" + alIntervalId);
  118. clearInterval(alIntervalId);
  119. }
  120. jsonObj.forEach(function (d) {
  121. console.log("GetVRBoardNozzles_Reply:" + d.SiteLevelNozzleId + "-" + d.FuelingState);
  122. d.VaporVolumeWithDecimal = d.LatestTrxFlowData === null ? "" : d.LatestTrxFlowData.VaporVolumeWithDecimal;
  123. d.LiquidVolumeWithDecimal = d.LatestTrxFlowData === null ? "" : d.LatestTrxFlowData.LiquidVolumeWithDecimal;
  124. d.VaporLiquidRatio = d.LatestTrxFlowData === null ? "" : d.LatestTrxFlowData.VaporLiquidRatio;
  125. d.ALIsNormal = d.LatestTrxFlowData === null ? "" : d.LatestTrxFlowData.气液比值是否正常;
  126. d.imgsource = d.FuelingState === "FUELING" ? "/WebConsole/images/smartFuel/fuelling.gif?a=" + d.SiteLevelNozzleId : (d.FuelingState === "IDLE" ? "/WebConsole/images/smartFuel/idleStatic.png" :"/WebConsole/images/smartFuel/disconnect.png");
  127. })
  128. totalPage = Math.ceil(jsonObj.length / maxNozzleNumberInOnePage);
  129. var dataLength =
  130. (jsonObj.length - maxNozzleNumberInOnePage * (currentPage - 1)) > maxNozzleNumberInOnePage
  131. ? maxNozzleNumberInOnePage
  132. : (jsonObj.length - maxNozzleNumberInOnePage * (currentPage - 1));
  133. vm.Nozzles = jsonObj.sort(sortBySiteLevelNozzleId).slice((currentPage - 1) * maxNozzleNumberInOnePage, (currentPage - 1) * maxNozzleNumberInOnePage + dataLength)
  134. if (currentPage > totalPage) {
  135. currentPage = totalPage;
  136. }
  137. UpdateFooterPage();
  138. } else if (apis.size > 0 && apis.has("OnVaporRecoveryDataCollectorBoardNozzleFlowDataRead") && topic === apis.get("OnVaporRecoveryDataCollectorBoardNozzleFlowDataRead")) {
  139. if (vm.Nozzles.length > 0) {
  140. vm.Nozzles.forEach(function (n) {
  141. if (n.SiteLevelNozzleId === jsonObj.SiteLevelNozzleId) {
  142. n.VaporVolumeWithDecimal = jsonObj.VaporVolumeWithDecimal;
  143. n.LiquidVolumeWithDecimal = jsonObj.LiquidVolumeWithDecimal;
  144. n.VaporLiquidRatio = jsonObj.VaporLiquidRatio;
  145. //n.FuelingState = jsonObj.FuellingStartTime === null ? "FUELING" : "IDLE";
  146. //n.HealthState = jsonObj.气液比值是否正常 === true ? "NORMAL" : "WARNING";
  147. n.ALIsNormal = jsonObj.气液比值是否正常;
  148. console.log("OnVaporRecoveryDataCollectorBoardNozzleFlowDataRead-VaporLiquidRatio:" + jsonObj.VaporLiquidRatio);
  149. }
  150. })
  151. }
  152. } else if (apis.size > 0 && apis.has("OnVaporRecoveryDataCollectorBoardNozzleStateChange") && topic === apis.get("OnVaporRecoveryDataCollectorBoardNozzleStateChange")) {
  153. if (vm.Nozzles.length > 0) {
  154. vm.Nozzles.forEach(function (n) {
  155. if (n.SiteLevelNozzleId === jsonObj.SiteLevelNozzleId) {
  156. console.log("CollectorBoardNozzleStateChange:" + jsonObj.SiteLevelNozzleId + "-" + jsonObj.FuelingState);
  157. n.imgsource = jsonObj.FuelingState === "IDLE" ? ((n.imgsource === "/WebConsole/images/smartFuel/fuelling.gif?a=" + n.SiteLevelNozzleId) ?
  158. "/WebConsole/images/smartFuel/Idle.gif?a=" + n.SiteLevelNozzleId : "/WebConsole/images/smartFuel/idleStatic.png") :
  159. "/WebConsole/images/smartFuel/fuelling.gif?a=" + n.SiteLevelNozzleId;
  160. n.FuelingState = jsonObj.FuelingState;
  161. n.HealthState = jsonObj.HealthState;
  162. }
  163. })
  164. }
  165. } else if (apis.size > 0 && apis.has("OnVaporRecoveryDataCollectorBoardStateChange") && topic === apis.get("OnVaporRecoveryDataCollectorBoardStateChange")) {
  166. if (vm.Nozzles.length > 0 && jsonObj !== null) {
  167. if (jsonObj.State === "UnInit") {
  168. jsonObj.Nozzles.forEach(function (bn) {
  169. var tempNozzle = vm.Nozzles.find(n => n.SiteLevelNozzleId === bn.SiteLevelNozzleId);
  170. if (tempNozzle !== undefined)
  171. tempNozzle.imgsource = "/WebConsole/images/smartFuel/disconnect.png";
  172. });
  173. } else if (jsonObj.State === "Initialized") {
  174. jsonObj.Nozzles.forEach(function (bn) {
  175. var tempNozzle = vm.Nozzles.find(n => n.SiteLevelNozzleId === bn.SiteLevelNozzleId);
  176. //tempNozzle.imgsource = "/WebConsole/images/smartFuel/disconnect.png";
  177. if (tempNozzle !== undefined && tempNozzle.imgsource === "/WebConsole/images/smartFuel/disconnect.png")
  178. tempNozzle.imgsource = "/WebConsole/images/smartFuel/idleStatic.png";
  179. });
  180. }
  181. }
  182. }
  183. }
  184. //In ascending order of site level nozzle Id
  185. function sortBySiteLevelNozzleId(n1, n2) {
  186. if (n1.SiteLevelNozzleId < n2.SiteLevelNozzleId)
  187. return -1;
  188. else
  189. return 1;
  190. }
  191. function ALNozzlesSubscribeEvents() {
  192. if (!mqttclient.connected || apis.size === 0) {
  193. console.log("ALNozzlesSubscribeEvents:client is not connected or haven't got APIS");
  194. return;
  195. }
  196. if (apis.has("GetVRBoardNozzles_Reply")) {
  197. mqttclient.subscribe(apis.get("GetVRBoardNozzles_Reply"), function (err) {
  198. if (!err) {
  199. mqttclient.publish(apis.get("GetVRBoardNozzles"));
  200. }
  201. });
  202. }
  203. if (apis.has("OnVaporRecoveryDataCollectorBoardNozzleFlowDataRead")) {
  204. mqttclient.subscribe(apis.get("OnVaporRecoveryDataCollectorBoardNozzleFlowDataRead"), function (err) {
  205. if (!err) {
  206. console.log("subscribe OnVaporRecoveryDataCollectorBoardNozzleFlowDataRead successfully");
  207. }
  208. });
  209. }
  210. if (apis.has("OnVaporRecoveryDataCollectorBoardNozzleStateChange")) {
  211. mqttclient.subscribe(apis.get("OnVaporRecoveryDataCollectorBoardNozzleStateChange"), function (err) {
  212. if (!err) {
  213. console.log("subscribe OnVaporRecoveryDataCollectorBoardNozzleStateChange successfully");
  214. }
  215. });
  216. }
  217. if (apis.has("OnVaporRecoveryDataCollectorBoardStateChange")) {
  218. mqttclient.subscribe(apis.get("OnVaporRecoveryDataCollectorBoardStateChange"), function (err) {
  219. if (!err) {
  220. console.log("subscribe OnVaporRecoveryDataCollectorBoardStateChange successfully");
  221. }
  222. });
  223. }
  224. }
  225. function UpdateFooterPage() {
  226. if (document.getElementById("PumpsPage_Bottom_pages") != null) {
  227. for (var p = 1; p < 6; p++) {
  228. var imgCurrentPageIdStr = "PumpsPage_Bottom_pages_img_" + p;
  229. var imgCurrentPageNotShowedIdStr = "PumpsPage_Bottom_pages_notshowed_img_" + p;
  230. if (p > totalPage) {
  231. if (document.getElementById(imgCurrentPageIdStr) != null)
  232. document.getElementById(imgCurrentPageIdStr).style.visibility = "hidden";
  233. if (document.getElementById(imgCurrentPageNotShowedIdStr) != null)
  234. document.getElementById(imgCurrentPageNotShowedIdStr).style.visibility = "hidden";
  235. } else if (p === currentPage || (p === 5 && currentPage > p)) {
  236. if (document.getElementById(imgCurrentPageIdStr) != null)
  237. document.getElementById(imgCurrentPageIdStr).style.visibility = "visible";
  238. if (document.getElementById(imgCurrentPageNotShowedIdStr) != null)
  239. document.getElementById(imgCurrentPageNotShowedIdStr).style.visibility = "hidden";
  240. } else {
  241. if (document.getElementById(imgCurrentPageIdStr) != null)
  242. document.getElementById(imgCurrentPageIdStr).style.visibility = "hidden";
  243. if (document.getElementById(imgCurrentPageNotShowedIdStr) != null)
  244. document.getElementById(imgCurrentPageNotShowedIdStr).style.visibility = "visible";
  245. }
  246. }
  247. //update next page img position
  248. var nextPageImg = document.getElementById("PumpsPage_Bottom_pages_img_next_page");
  249. var previousPageImg = document.getElementById("PumpsPage_Bottom_pages_img_previous_page");
  250. if (previousPageImg != null) {
  251. //previousPageImg.style.visibility = (totalPage === 1 || currentPage === 1) ? "hidden" : "visible";
  252. previousPageImg.style.visibility = "visible";
  253. }
  254. if (nextPageImg != null) {
  255. //if (totalPage < 5)
  256. nextPageImg.style.left = (16.5 * totalPage + 5).toString() + "%";
  257. nextPageImg.style.visibility = "visible";
  258. //nextPageImg.style.visibility = (totalPage === 1 || currentPage === totalPage) ? "hidden" : "visible";
  259. }
  260. }
  261. }
  262. //显示前一页
  263. function ShowPreviousPage() {
  264. if (currentPage === 1) {
  265. //alert("已经是第一页!");
  266. dialogBox("提示信息", "已經是第一頁",null,null);
  267. return;
  268. }
  269. currentPage--;
  270. if (apis.has("GetVRBoardNozzles_Reply")) {
  271. mqttclient.subscribe(apis.get("GetVRBoardNozzles_Reply"), function (err) {
  272. if (!err) {
  273. mqttclient.publish(apis.get("GetVRBoardNozzles"));
  274. }
  275. });
  276. }
  277. }
  278. //显示下一页
  279. function ShowNextPage() {
  280. if (currentPage === totalPage) {
  281. //alert("已经是最后一页!");
  282. dialogBox("提示信息", "已經是最後一頁",null,null);
  283. return;
  284. }
  285. currentPage++;
  286. if (apis.has("GetVRBoardNozzles_Reply")) {
  287. mqttclient.subscribe(apis.get("GetVRBoardNozzles_Reply"), function (err) {
  288. if (!err) {
  289. mqttclient.publish(apis.get("GetVRBoardNozzles"));
  290. }
  291. });
  292. }
  293. }
  294. </script>
  295. <style scoped>
  296. .HealthState {
  297. position: absolute;
  298. right: 2%;
  299. bottom: 4%;
  300. width: 20%;
  301. height: 25%;
  302. }
  303. .FuelingState {
  304. position: absolute;
  305. top: 0%;
  306. left: 0%;
  307. width: 100%;
  308. height: 100%;
  309. }
  310. .NozzleId {
  311. position: absolute;
  312. top: 0%;
  313. left: 0%;
  314. width: 100%;
  315. height: 15%;
  316. text-align: left;
  317. font-size: 1.375rem;
  318. font-weight: bold;
  319. /*border: 1px solid#ff0000*/
  320. }
  321. .NozzleDiv {
  322. position: relative;
  323. float: left;
  324. margin: 1%;
  325. width: 14.66%;
  326. height: 48%;
  327. /*border: 1px solid#ff0000;*/
  328. }
  329. .ALLable {
  330. position: relative;
  331. float: left;
  332. /*width: 15%;*/
  333. margin-left:12%;
  334. width: 33%;
  335. height: 100%;
  336. text-align: left;
  337. font-size: 1.1rem;
  338. font-weight: bold;
  339. /*border: 1px solid#ff0000;*/
  340. }
  341. .ALLableData {
  342. position: relative;
  343. float: left;
  344. /*width: 85%;*/
  345. width: 35%;
  346. height: 100%;
  347. text-align: right;
  348. font-size: 1.1rem;
  349. font-weight: bold;
  350. /*color:#808080;*/
  351. /*border: 1px solid#ff0000;*/
  352. }
  353. .ALDatas {
  354. position: relative;
  355. width: 100%;
  356. height: 15%;
  357. /*border: 1px solid#ff0000;*/
  358. }
  359. </style>