123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277 |
- @*
- For more information on enabling MVC for empty projects, visit http://go.microsoft.com/fwlink/?LinkID=397860
- *@
- @{
- Layout = null;
- }
- @{
- int screenWidth = 1280;
- int mainviewHeight = 570;
- int marginLeft = 42;
- int marginTop = 20;
- int dataDescriptionWidth = (screenWidth - 2 * marginLeft) * 50 / 100;
- int dataDescriptionHeight = mainviewHeight - marginTop - marginTop / 2;
- int dataDescriptionTableHeight = dataDescriptionHeight * 95 / 100;
- int dataDescriptionTableHeadHeight = dataDescriptionTableHeight / 5;
- int dataDescriptionTableBodyRowHeight = (dataDescriptionTableHeight - dataDescriptionTableHeight / 5) / 8;
- int dataDescriptionTableBodyHeight = dataDescriptionTableHeight - dataDescriptionTableHeight / 5;
- int dataHistoryWidth = (screenWidth - 2 * marginLeft) * 50 / 100;
- int stationInfoHeigth = dataDescriptionHeight - dataDescriptionTableHeight;
- //int dataDescriptionHeaderHeight = dataDescriptionHeight - dataDescriptionTableHeight;
- }
- <style type="text/css">
- .table{
- border-collapse:collapse;
- }
- .table tr td{
-
- color: #000000;
- font-size: 30px;
-
- text-align: left;
- font-weight: bold;
- }
- .table>thead {
- display: table;
- width: 100%;
- height:@(dataDescriptionTableHeadHeight)px;
- table-layout:fixed;
- }
- .table>tbody>tr{
- display: table;
- width: 100%;
- height:@(dataDescriptionTableBodyRowHeight)px;
- table-layout:fixed;
- }
- .table>tbody{
- height:@(dataDescriptionTableBodyHeight)px;
- overflow: hidden;
- display: block;
- overflow: hidden;
- overflow-y:auto;
- }
- </style>
- <script src="~/js/mqtt.min.js"></script>
- @*<script src="~/js/jquery-3.4.1.min.js"></script>*@
- @*@{
- await Html.RenderPartialAsync("OnlineMonitorHeader");
- }*@
- <div id="dataupload" style="position: relative; width:@(screenWidth-2)px; height:@(mainviewHeight-2)px;">
- @*<span id="testmqqt" style="position: relative">数据上传</span>
- <input type="button" onclick="Onmqtttest()" value="Test MQQT" />*@
- <div id="dataupload_description" style="position: relative;float: left;margin-left: @(marginLeft)px; margin-top: @(marginTop)px;width:@(dataDescriptionWidth)px; height:@(dataDescriptionHeight)px;">
- @*<span id="dataupload_description_header" style="position: relative; width: 100%; height: 40px; line-height: 40px; font-size: 22px; text-align: left; font-weight: bold;">
- 北京环保局上传(测试)
- </span>*@
- <table id="dataupload_description_table" class="table">
- <thead>
- <tr style="font-weight: bold; font-size: 40px;">
- <td style="height: @(dataDescriptionTableHeadHeight)px;">北京环保局上传(测试)</td>
- </tr>
- </thead>
- <tbody>
- @for (int i = 0; i < 4; i++)
- {
- <tr style="font-size: 30px;">
- <td style="text-align: left; height: @(dataDescriptionTableBodyRowHeight-2)px;">2020-04-16</td>
- </tr>
- <tr style="font-size: 30px;">
- <td style="padding-left: 20%; height: @(dataDescriptionTableBodyRowHeight)px;">加油数据首次上传</td>
- </tr>
- }
- </tbody>
- </table>
- <div id="dataupload_stationInfo" style="position: relative; float: left;width:@(dataDescriptionWidth)px; height:@(stationInfoHeigth-2)px;font-size: 22px;">站点编号:1234567890</div>
- </div>
- <div id="dataupload_history" style="position: relative;float: left;margin-top: @(marginTop)px;width:@(dataHistoryWidth)px; height:@(dataDescriptionHeight)px;">
- <table id="dataupload_history_table" class="table">
- <thead>
- <tr style="font-weight: bold; font-size: 30px;">
- <td style="height: @(dataDescriptionTableHeadHeight)px;">上传历史</td>
- </tr>
- </thead>
- <tbody>
- @for (int i = 0; i < 15; i++)
- {
- <tr style="font-size: 30px;font-weight: bold;">
- <td style="width: 33%;">2020-04-16</td>
- <td style="width: 41%;">加油数据上传</td>
- <td style="width: 25%;">成功</td>
- </tr>
- }
- </tbody>
- </table>
- </div>
- </div>
- @*<img id="dataupload_img" src="/image/online/筛选图标.png" style="position: absolute; left: @(screenWidth-63)px;top: 55px;"/>*@
- <script>
- var textSpan = document.getElementById("head_left_text");
- if (textSpan != null)
- textSpan.innerHTML = "数据上传";
- </script>
- <script type="text/javascript">
- var hostname = 'localhost',
- port = 8384,
- clientId = 'mqttjs_' + (Math.random() * 1000000).toString(),
- timeout = 5000,
- keepAlive = 100,
- cleanSession = false,
- mqttVersion = 3,
- ssl = false;
-
-
-
- var options = {
-
- clientId: 'mqttjs_' + (Math.random() * 1000000).toString(),
-
-
-
-
-
-
-
-
- timeout: timeout,
-
-
- useSSL: false
-
-
- }
-
- var client = mqtt.connect("ws://localhost:8384/mqtt", options);
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- client.on('connect',
- function () {
- var a = document.getElementById("testmqqt");
- if (a != null) a.innerHTML = "connected";
-
- client.subscribe('/sys/Vapor_Recovery_App/Application.VaporRecoveryApp.App/thing/service/GetConfigAsync_reply',
- function (err) {
- if (!err) {
- if (a != null) a.innerHTML = "subscribe GetConfigAsync_reply successfully";
- client.publish('/sys/Vapor_Recovery_App/Application.VaporRecoveryApp.App/thing/service/GetConfigAsync', 'Hello mqtt ');
- } else {
-
- if (a != null) a.innerHTML = err;
- }
- });
- client.subscribe('/sys/Vapor_Recovery_App/Application.VaporRecoveryApp.App/thing/service/GetNozzlesData_reply',
- function (err) {
- if (!err) {
- client.publish('/sys/Vapor_Recovery_App/Application.VaporRecoveryApp.App/thing/service/GetNozzlesData', "Hello mqtt");
- };
- });
- client.subscribe('/sys/Vapor_Recovery_App/Application.VaporRecoveryApp.App/thing/service/GetNozzlesFlowData_reply',
- function (err) {
- if (!err) {
- if (a != null) a.innerHTML = "subscribe nozzleFlowData successfully";
- } else {
-
- if (a != null) a.innerHTML = err;
- }
- });
- });
-
- client.on('error',
- function (err) {
- var a = document.getElementById("testmqqt");
- if (a != null) a.innerHTML = err;
- client.end();
- });
-
- client.on('message',
- function (topic, message) {
-
-
- var a = document.getElementById("testmqqt");
- if (a != null) a.innerHTML = topic;
- if (topic === "/sys/Vapor_Recovery_App/Application.VaporRecoveryApp.App/thing/service/GetConfigAsync_reply") {
- processConfigData(JSON.parse(message.toString()));
- return;
- }
- if (topic === "/sys/Vapor_Recovery_App/Application.VaporRecoveryApp.App/thing/service/GetNozzlesData_reply") {
- var nozzles = processNozzlesData(JSON.parse(message.toString()));
- return;
- }
- });
- function processConfigData(message) {
- var WarningValueMin = message.onlineWatchConfig.WarningValueMin;
- var WarningValueMax = message.onlineWatchConfig.WarningValueMax;
- var a = document.getElementById("testmqqt");
- if (a != null) a.innerHTML = WarningValueMin;
- }
- function processNozzlesData(message) {
- var data = message.data;
- var pumpMap = new Map();
- var currentDispenserId = 0;
- var nozzlesArray = new Array();
- data.forEach(function (d) {
- if (currentDispenserId === 0) {
- currentDispenserId = d.SiteLevelDispenserId;
- nozzlesArray.push(d);
- } else if (currentDispenserId !== d.SiteLevelDispenserId) {
- pumpMap.set(currentDispenserId, new Array().concat(nozzlesArray));
- currentDispenserId = d.SiteLevelDispenserId;
- nozzlesArray.splice(0, nozzlesArray.length);
- nozzlesArray.push(d);
- } else {
- currentDispenserId = d.SiteLevelDispenserId;
-
- nozzlesArray.push(d);
- }
- });
- if (nozzlesArray.length > 0) {
- pumpMap.set(currentDispenserId, new Array().concat(nozzlesArray));
- nozzlesArray.splice(0, nozzlesArray.length);
- }
- pumpMap.forEach(function (value, key) {
- var dispenserId = key;
- var nozzleCount = value.length;
- });
- }
-
- function Onmqtttest() {
- var message = "message from browser with websocket";
- var nozzleId = 1;
- var temp = { "Parameters": [{ "Name": "nozzleid", "Value": nozzleId }, { "Name": "starttime", "Value": "20200422000000" }, { "Name": "endtime", "Value": "20200422235959" }] };
- message = JSON.stringify(temp);
-
- client.publish('/sys/Vapor_Recovery_App/Application.VaporRecoveryApp.App/thing/service/GetNozzlesFlowData', message);
-
-
- var a = document.getElementById("testmqqt");
- if (a != null) a.innerHTML = message;
- }
- </script>
|