Browse Source

fix C3's RS and HM

nate 3 years ago
parent
commit
5039153dc1
3 changed files with 52 additions and 76 deletions
  1. 50 70
      script/js/c3.js
  2. 2 5
      script/php/getChartData2.php
  3. 0 1
      script/php/getData2.php

+ 50 - 70
script/js/c3.js

@@ -105,16 +105,20 @@ function LoadPage() {
     else
         document.getElementById("displayCompareChart").style.display = 'none';
 
-    if(isLoad){
+    if (isLoad) {
         if (option == "HM" || option == "SIS" || option == "RS" || option == "VG" || option == "SID") {
+            //把B1的模型改成透明的
             myGameInstance.SendMessage("Monitor", "ChangeTransparent");
+            //把樓上的模型隱形
             myGameInstance.SendMessage("Monitor", "RemoveModel", "true");
         } else {
+            //把B1的模型改成白色
             myGameInstance.SendMessage("Monitor", "ChangeWhite");
+            //把樓上的模型變回來
             myGameInstance.SendMessage("Monitor", "RemoveModel", "false");
         }
     }
-    
+
 
     if (option != "ELP" && option != "SIS" && option != "SID") {
         document.getElementById("phase").style.display = "none";
@@ -128,11 +132,22 @@ function LoadPage() {
         dataValue = dataValue.concat(',', wellTBALocal[i]);
 
     }
-    if(isLoad){
+    if (isLoad) {
+        //dataValue = 監測儀器代號,超出警戒值的儀器名稱
+        //AddDataTable會存option:監測儀器代號(string)
+        //               abnormal:超出警戒值的儀器名稱(array)
+        //               gameObjects:所有監測儀器名稱(array)
+        //               optionGameObjects:包含監測儀器代號的所有監測儀器名稱(array)
+        //               到unity的DataTable.cs裡面
         myGameInstance.SendMessage("Monitor", "AddDataTable", dataValue);
+        //原本的模型牆被挖空,SID、RS、VG都有建各自的牆,若選擇一種監測儀器則另外兩種隱藏掉
+        //addData(DataTable.option);
+        //依照DataTable的option將所有optionGameObjects改成normal的顏色
+        //Search(DataTable.option, DataTable.abnormal); 
+        //將所有abnormal的儀器改成abnormal的顏色
         myGameInstance.SendMessage("Monitor", "Initialization");
     }
-    
+
     var wellNameList = window.localStorage.getItem("wellNameList");
     var wellNameListsLocal = wellNameList.split(",");
 
@@ -173,6 +188,10 @@ function showWell(str, changeCamera) {
     }
     strLocal = str;
 
+    if (!isLoad && str.includes("RS")) {
+        str = str.substr(0, str.length - 2);
+    }
+
     document.getElementById("monitorSelect2").innerHTML = strLocal;
     xhttp = new XMLHttpRequest();
     xhttp.onreadystatechange = function () {
@@ -180,12 +199,14 @@ function showWell(str, changeCamera) {
 
             document.getElementById("tableName").innerHTML = strLocal + "資料表";
             saveCheckCompare = strLocal + "資料表";
+
             displayChart(str, "myChart");
             reset();
-            if(isLoad){
+            if (isLoad) {
+                //把現在選擇的儀器名稱(例:OW-1)傳到unity,unity找模型名稱相同的改變模型顏色以及鏡頭置中模型
                 myGameInstance.SendMessage("MainCamera", "GetDataFromWebGL", str);
             }
-            
+
 
             if (!changeCamera) {
                 ResetCamera();
@@ -238,7 +259,6 @@ function getCheckValue() {
         })
 
         .success(function (response) {
-            console.log(response)
             dataArray = response['wellTBA'];
             for (var i = 0; i < dataArray.length; i++) {
                 dataArray[i] = dataArray[i].replace('_', '-');
@@ -254,8 +274,6 @@ function getCheckValue() {
             script.setAttribute('src', url);
             document.getElementsByTagName('head')[0].appendChild(script);
             document.getElementById("percent").innerHTML = Math.round(percent * 100) + "%";
-
-
         })
         .error(function () {
             //alert("錯誤統計未正常獲取");
@@ -407,14 +425,20 @@ function uploadCSV() {
 
 //Display chart
 function displayChart(str, elementID) {
-    var xhttp;
-    xhttp = new XMLHttpRequest();
 
-    xhttp.onreadystatechange = function () {
-        if (this.readyState == 4 && this.status == 200) {
+    $.ajax({
+            url: "/BIM-Monitor/script/php/getChartData2.php",
+            type: "GET",
+            async: false,
+            data: {
+                q: str
+            }
+        })
+        .success(function (response) {
+
             if (str.includes("ELP") || str.includes("OW") || str.includes("SM") || str.includes("SB") || str.includes("SBM") || str.includes("VG") || str.includes("HM")) {
                 //Split the response text into well name array, date array and value array
-                var v_variables = this.responseText.split("*");
+                var v_variables = response.split("*");
                 var c_wellName = v_variables[0];
                 var c_m_date = v_variables[1].split(" ");
                 var c_m_value = v_variables[2].split(" ");
@@ -428,7 +452,7 @@ function displayChart(str, elementID) {
 
 
             } else if (str.includes("TI")) {
-                var v_variables = this.responseText.split("*");
+                var v_variables = response.split("*");
                 var c_wellName = v_variables[0];
                 var c_m_date = v_variables[1].split(" ");
                 var c_m_value = v_variables[2].split(" ");
@@ -444,7 +468,7 @@ function displayChart(str, elementID) {
 
 
             } else if (str.includes("SIS") || str.includes("SID")) {
-                var v_variables = this.responseText.split("*");
+                var v_variables = response.split("*");
                 var c_m_date = v_variables[0].split(" ");
                 var c_m_depth = v_variables[1].split(" ");
                 var c_m_valueArray = v_variables[2].split("//");
@@ -458,7 +482,7 @@ function displayChart(str, elementID) {
 
                 initSISSID(c_m_date, c_m_depth, c_m_value, elementID, str);
             } else if (str.includes("RS")) {
-                var v_variables = this.responseText.split("*");
+                var v_variables = response.split("*");
 
                 var c_wellName = v_variables[0];
                 var c_m_date = v_variables[1].split(" ");
@@ -486,12 +510,11 @@ function displayChart(str, elementID) {
 
                 init6(c_wellName, c_m_date, c_m_value, c2_wellName, c2_m_value, c3_wellName, c3_m_value, c4_wellName, c4_m_value, c5_wellName, c5_m_value, c6_wellName, c6_m_value, elementID);
             }
-        }
-    };
-    xhttp.open("GET", "/BIM-Monitor/script/php/getChartData2.php?q=" + str, true);
-    xhttp.send();
-
+        })
+        .error(function (error) {
 
+        })
+        .complete(function () {});
 
 
 }
@@ -536,13 +559,12 @@ function displayCompareChart() {
 
 //Reset the camera
 function ResetCamera() {
-    if(isLoad){
+    if (isLoad) {
+        //把center、鏡頭、模型位置以及角度全部重置
         myGameInstance.SendMessage("MainCamera", "ResetCamera");
     }
 }
 
-
-
 function SetList() {
     var wellNameListsLocal = "";
     var isError = false;
@@ -561,13 +583,6 @@ function SetList() {
         wellNameListsLocal = wellNameLists[i];
         var option = document.createElement("li");
         var createA = document.createElement("a");
-        /*if(wellNameLists[i].includes("ELP")){
-        	if(wellNameLists[i].includes("A")){
-        		wellNameListsLocal = wellNameLists[i] + ',' + wellNameLists[i].replace('A','-1A');
-        	}else{
-        		wellNameListsLocal = wellNameLists[i] + ',' + wellNameLists[i] + '-1';
-        	}
-        }	*/
         var createAText = document.createTextNode(wellNameListsLocal);
         var createButton = document.createElement("button");
         var createButtonText = document.createTextNode(wellNameListsLocal);
@@ -601,7 +616,7 @@ function SetList() {
 }
 
 function UpdateGPS(GPS) {
-    if(isLoad){
+    if (isLoad) {
         myGameInstance.SendMessage("PlayerArmature", "UpdateGPS", GPS);
     }
 }
@@ -933,33 +948,6 @@ function init2(c_wellName, c_m_date, c_m_value, c2_wellName, c2_m_date, c2_m_val
         }
     });
 
-    /*if(c_wellName.includes("ELP") && phase != 2 && phase != 7){
-
-        window.chart.data.datasets.push({
-            label: "警戒值",
-            data: warning,
-            borderColor: "#FF0000",
-			pointRadius: 0
-        });
-
-        if(phase == 3 || phase == 4){
-            let warning2 = [];
-
-            for (i = 0; i < c2_m_date.length; i++) {
-                warning2.push(ELP_1warning[phase-2]);
-            }
-
-            window.chart.data.datasets.push({
-                label: "警戒值2",
-                data: warning2,
-                borderColor: "#FF0000",
-                pointRadius: 0
-            });
-        }
-
-        window.chart.update();
-    }*/
-
     //ELP does not have second warning line, so you need to update it seperately
     if (c_wellName.includes("TI")) {
 
@@ -1096,6 +1084,7 @@ function initSISSID(c_m_date, c_m_depth, c_m_value, elementID, str) {
 function init6(c_wellName, c_m_date, c_m_value, c2_wellName, c2_m_value, c3_wellName, c3_m_value, c4_wellName, c4_m_value, c5_wellName, c5_m_value, c6_wellName, c6_m_value, elementID) {
     var ctx = document.getElementById(elementID).getContext("2d");
     let warning = [];
+
     if (c_wellName.includes("RS")) {
         for (i = 0; i < c_m_date.length; i++) {
             warning.push(2000);
@@ -1241,16 +1230,7 @@ function initCompare(m_date, chart_data, index, label) {
             borderColor: randomColorBlue()
         });
     }
-    /*
-    	if(label[1].includes("ELP") && phase != 2 && phase != 7){
-    		window.chart.data.datasets.push({
-                label: "警戒值",
-                data: warning,
-                borderColor: "#FF0000",
-    			pointRadius: 0
-            });		
-    	}
-    */
+
     window.chart.update();
 
 }

+ 2 - 5
script/php/getChartData2.php

@@ -49,7 +49,7 @@
     $outputF_m_value_count = 0;
 
     if(isset($_GET['q'])){
-        $wellName = $_GET["q"];
+        $wellName = $_GET["q"]; 
         $wellNameA = str_replace("A","-1A",$wellName); 
         $sqlWellName = str_replace("-", "_", $wellName);
         $sqlWellNameA = str_replace("-", "_", $wellNameA);
@@ -123,8 +123,6 @@
         }else if(contains($wellName, "RS")){
             $sqlRS = "SELECT * FROM [C3].[dbo].[RSdata]";
             $fetchResult = sqlsrv_query($conn, $sqlRS);
-            
-            $sqlWellName = substr($sqlWellName, 0 , -2);
 
             while($row = sqlsrv_fetch_array($fetchResult)){
 
@@ -246,8 +244,7 @@
                 }
             }
         }else if(contains($wellName, "RS")){
-            $wellName = substr($wellName, 0 , -2);
-            displayRS($wellName."-A", $output_m_date, $output_m_value);
+            displayRS($sqlWellName."-A", $output_m_date, $output_m_value);
             echo "*";
             displayRS($wellName."-B", $outputB_m_date, $outputB_m_value);
             echo "*";

+ 0 - 1
script/php/getData2.php

@@ -94,7 +94,6 @@ if (isset($_GET['q'])) {
     }else if(contains($wellName, "RS")){
         $sqlRS = "SELECT * FROM [C3].[dbo].[RSdata]";
         $fetchResult = sqlsrv_query($conn, $sqlRS);
-        $wellName = substr($wellName, 0 , -2);
         echo "<thead>
                 <tr>
                     <th>測量日期</th>