console.log(1);
var xhr = new XMLHttpRequest();
var url = "tower/org";
obj = "";
xhr.open("GET", url);
xhr.onload = function () {
obj = JSON.parse(xhr.responseText);
//insertHTML();
start();
onChangeColumn1();
onChangeColumn2();
onChangeColumn3();
click_button();
};
xhr.send();
function insertHTML(data) {
var tower_select = document.getElementById('tower');
//aria.innerHTML=data[0].tower_name;
var inner = '';
for (var i = 0; i < data.length; i++) {
if (i >= 5) {
inner = inner + '';
}
else {
inner = inner + '';
}
console.log(inner);
}
tower_select.innerHTML = inner;
}
obj2 = "";
function click_button() {
//alert("click");
companySelect = document.getElementById("company-list");
factorySelect = document.getElementById("factory-list");
departmentSelect = document.getElementById("department-list");
towerGroupSelect = document.getElementById("towerGroup-list");
if (companySelect.value != 0 && factorySelect.value != 0 && departmentSelect.value != 0 && towerGroupSelect.value != 0) {
var url2 = "tower/?company=" + companySelect.value + "&factory=" + factorySelect.value + "&department=" + departmentSelect.value + "&towerGroup=" + towerGroupSelect.value;
var xhr2 = new XMLHttpRequest();
xhr2.open("GET", url2);
xhr2.onload = function () {
obj2 = JSON.parse(xhr2.responseText);
insertHTML(obj2);
console.log(obj2);
tower_info(obj2[0].tower_name);
};
xhr2.send();
}
}
function tower_info(tower_str) {
$(document).on("click", ".tower-btn", function (event) {
$(this).addClass("tower-active");
$(".tower-active").siblings().removeClass('tower-active');
});
tower = tower_str;
console.log(tower);
inner = "";
for (var i = 0; i < obj2.length; i++) {
if (obj2[i].tower_name == tower) {
// inner = '
DCS
'+
// ' 入水溫度 = '+ obj2[i].tower_data.DCS.hotTemp + '
' +
// ' 出水溫度 = '+ obj2[i].tower_data.DCS.coldTemp + '
' +
// ' 水流量 = '+ obj2[i].tower_data.DCS.waterFlow + '
' +
// ' 風扇馬達電流 = '+ obj2[i].tower_data.DCS.fanMotorCur + '
' +
// ' 風扇馬達轉速頻率 = '+ obj2[i].tower_data.DCS.fanMotorSpeedFreq + '
' +
// ' 風扇震動
'+
// ' 馬達震動 = '+ obj2[i].tower_data.Moter.ch01.Vrms + '
' +
// ' 減速機震動 = '+ obj2[i].tower_data.Fan.reducer + '
' +
// ' 靜壓機 = '+ obj2[i].tower_data.Fan.staticPressure + '
' +
// ' 水流量 = '+ obj2[i].tower_data.Fan.waterFlow + '
' +
// ' 濕求溫度 = '+ obj2[i].tower_data.Fan.wetTemp + '
' +
// ' 水冷槽溫度1 = '+ obj2[i].tower_data.Fan.coldTempData1 + '
' +
// ' 水冷槽溫度2 = '+ obj2[i].tower_data.Fan.coldTempData2 + '
' +
// ' 馬達震動
'+
// ' ch001,通道1'+ obj2[i].tower_data.Moter.ch01.Vrms + ',' + obj2[i].tower_data.Moter.ch01.CV+'
' +
// ' ch002,通道2'+ obj2[i].tower_data.Moter.ch02.Vrms + ',' + obj2[i].tower_data.Moter.ch02.CV+'
'
// ;
inner = '中控室DSC訊號
\
\
\
入水溫度
\
\
'+ obj2[i].tower_data.DCS.hotTemp + ' °C
\
\
\
\
出水溫度
\
\
'+ obj2[i].tower_data.DCS.coldTemp + ' °C
\
\
\
\
水流量
\
\
'+ obj2[i].tower_data.DCS.waterFlow + ' M³/H
\
\
\
\
風扇馬達電流
\
\
'+ obj2[i].tower_data.DCS.fanMotorCur + ' A
\
\
\
\
風扇馬達轉速頻率
\
\
'+ obj2[i].tower_data.DCS.fanMotorSpeedFreq + ' Hz
\
\
\
\
\
\
\
\
\
\
風扇震動
\
\
\
\
\
數據名稱 | \
值 | \
單位 | \
\
\
\
\
馬達震動 | \
'+ obj2[i].tower_data.Moter[0].DataValue + ' | \
mm/s | \
\
\
減速機震動 | \
'+ obj2[i].tower_data.Fan.reducer + ' | \
mm/s | \
\
\
靜壓機 | \
'+ obj2[i].tower_data.Fan.staticPressure + ' | \
pa | \
\
\
水流量 | \
'+ obj2[i].tower_data.Fan.waterFlow + ' | \
M³/H | \
\
\
濕求溫度 | \
'+ obj2[i].tower_data.Fan.wetTemp + ' | \
°C | \
\
\
水冷槽溫度1 | \
'+ obj2[i].tower_data.Fan.coldTempData1 + ' | \
°C | \
\
\
水冷槽溫度2 | \
'+ obj2[i].tower_data.Fan.coldTempData2 + ' | \
°C | \
\
\
\
\
\
\
\
\
馬達震動
\
\
\
ch001,通道1
\
\
'+ obj2[i].tower_data.Moter[0].DataValue + ',' + obj2[i].tower_data.Moter[0].CVIndex + '
\
\
\
\
ch002,通道2
\
\
'+ obj2[i].tower_data.Moter[1].DataValue + ',' + obj2[i].tower_data.Moter[1].CVIndex + '
\
\
\
\
ch003,通道3
\
\
'+ obj2[i].tower_data.Moter[2].DataValue + ',' + obj2[i].tower_data.Moter[2].CVIndex + '
\
\
\
\
ch004,通道4
\
\
'+ obj2[i].tower_data.Moter[3].DataValue + ',' + obj2[i].tower_data.Moter[3].CVIndex + '
\
\
\
\
\
\
\
\
';
console.log(obj2[i].tower_data.Moter[3].Vrms);
}
}
document.getElementById("tower_info").innerHTML = inner;
console.log(inner);
get_tower_perfrom('dev001');
}
//document就是這html文件。
//getElementById是裡面的方法,參數給"college-list"抓到這id標籤列
function start() {
companySelect = document.getElementById("company-list");
factorySelect = document.getElementById("factory-list");
departmentSelect = document.getElementById("department-list");
towerGroupSelect = document.getElementById("towerGroup-list");
var inner = '';
var company_arr = new Array();
for (var i = 0; i < obj.length; i++) {
if (company_arr.indexOf(obj[i].company) == -1 && obj[i].able == 1) {
inner = inner + '';
company_arr.push(obj[i].company);
}
}
//innerHTML 賦值inner給這element屬性
companySelect.innerHTML = inner;
}
//製造一個字串,以html的語法填入院的陣列
function onChangeColumn1() {
companySelect = document.getElementById("company-list");
factorySelect = document.getElementById("factory-list");
departmentSelect = document.getElementById("department-list");
towerGroupSelect = document.getElementById("towerGroup-list");
factorySelect.innerHTML = '';
let factory_arr = new Array();
let factory_inner = '';
for (var i = 0; i < obj.length; i++) {
if (companySelect.value == obj[i].company) {
if (factory_arr.indexOf(obj[i].factory) == -1 && obj[i].able == 1) {
factory_inner = factory_inner + '';
factory_arr.push(obj[i].factory);
}
}
//alert(companySelect.value);
}
factorySelect.innerHTML = factory_inner;
}
function onChangeColumn2() {
companySelect = document.getElementById("company-list");
factorySelect = document.getElementById("factory-list");
departmentSelect = document.getElementById("department-list");
towerGroupSelect = document.getElementById("towerGroup-list");
departmentSelect.innerHTML = '';
let department_arr = new Array();
let department_inner = '';
for (var i = 0; i < obj.length; i++) {
if (companySelect.value == obj[i].company && factorySelect.value == obj[i].factory) {
if (department_arr.indexOf(obj[i].department) == -1 && obj[i].able == 1) {
department_inner = department_inner + '';
department_arr.push(obj[i].department);
}
}
}
document.getElementById("department-list").innerHTML = department_inner;
}
function onChangeColumn3() {
companySelect = document.getElementById("company-list");
factorySelect = document.getElementById("factory-list");
departmentSelect = document.getElementById("department-list");
towerGroupSelect = document.getElementById("towerGroup-list");
towerGroupSelect.innerHTML = '';
let towerGroup_inner = '';
for (var i = 0; i < obj.length; i++) {
if (companySelect.value == obj[i].company && factorySelect.value == obj[i].factory && departmentSelect.value == obj[i].department) {
if (obj[i].able == 1) {
for (var ii = 0; ii < obj[i].group.length; ii++) {
towerGroup_inner = towerGroup_inner + '';
}
}
}
}
document.getElementById("towerGroup-list").innerHTML = towerGroup_inner;
}
function get_tower_perfrom(tower_id) {
var xhr3 = new XMLHttpRequest();
var url3 = "tower/performance/" + tower_id;
console.log("sss");
obj3 = "";
xhr3.open("GET", url3);
xhr3.onload = function () {
obj3 = JSON.parse(xhr3.responseText);
console.log(obj3);
tower_perform_show(obj3);
};
xhr3.send();
}
function tower_perform_show(obj_tmp) {
inner = "\
\
\
\
\
設計條件
\
\
\
\
\
數據名稱 | \
值 | \
單位 | \
\
\
\
\
水流量 | \
" + obj_tmp[0].designWFR + " | \
M³/H | \
\
\
風車馬力 | \
" + obj_tmp[0].designHP + " | \
mm/s | \
\
\
額定電流 | \
" + obj_tmp[0].designCurrent + " | \
A | \
\
\
入水溫度 | \
" + obj_tmp[0].designHWT + " | \
°C | \
\
\
出水溫度 | \
" + obj_tmp[0].designCWT + " | \
°C | \
\
\
濕求溫度 | \
" + obj_tmp[0].designWBT + " | \
°C | \
\
\
\
\
\
\
\
\
測試狀態
\
\
\
\
\
數據名稱 | \
值 | \
單位 | \
\
\
\
\
水流量 | \
" + obj_tmp[0].testWFR + " | \
M³/H | \
\
\
風車馬力 | \
" + obj_tmp[0].testBHP + " | \
mm/s | \
\
\
運轉電流 | \
" + obj_tmp[0].testCurrent + " | \
A | \
\
\
入水溫度 | \
" + obj_tmp[0].testHWT + " | \
°C | \
\
\
出水溫度 | \
" + obj_tmp[0].testCorrectCWT + " | \
°C | \
\
\
濕求溫度 | \
" + obj_tmp[0].testWBT + " | \
°C | \
\
\
風速 | \
" + obj_tmp[0].testWindSpeed + " | \
°C | \
\
\
補充水量 | \
" + obj_tmp[0].testMakeupWFR + " | \
°C | \
\
\
補充水溫 | \
" + obj_tmp[0].testMakeupCWT + " | \
°C | \
\
\
CORRECT CWT | \
" + obj_tmp[0].testCorrectCWT + " | \
°C | \
\
\
COLLING RANGE | \
" + obj_tmp[0].testCoolingRange + " | \
°C | \
\
\
\
\
\
\
\
\
" ;
// "測試狀態
" +
// "水流量: " + obj_tmp[0].testWFR + "
" +
// "風車馬力: " + obj_tmp[0].testBHP + "
" +
// "運轉電流: " + obj_tmp[0].testCurrent + "
" +
// "入水溫度: " + obj_tmp[0].testHWT + "
" +
// "出水溫度: " + obj_tmp[0].testCorrectCWT + "
" +
// "濕球溫度: " + obj_tmp[0].testWBT + "
" +
// "風速: " + obj_tmp[0].testWindSpeed + "
" +
// "補充水量: " + obj_tmp[0].testMakeupWFR + "
" +
// "補充水溫: " + obj_tmp[0].testMakeupCWT + "
" +
// "CORRECT CWT: " + obj_tmp[0].testCorrectCWT + "
" +
// "COLLING RANGE: " + obj_tmp[0].testCoolingRange + "
";
document.getElementById('tower_perfrom').innerHTML = inner;
}
// function tower_perform_show(obj_tmp){
// inner = "設計條件
" +
// "水流量: " + obj_tmp[0].designWFR + "
" +
// "風車馬力: " + obj_tmp[0].designHP + "
" +
// "額定電流: " + obj_tmp[0].designCurrent + "
" +
// "入水溫度: " + obj_tmp[0].designHWT + "
" +
// "出水溫度: " + obj_tmp[0].designCWT + "
" +
// "濕求溫度: " + obj_tmp[0].designWBT + "
" +
// "測試狀態
" +
// "水流量: " + obj_tmp[0].testWFR + "
" +
// "風車馬力: " + obj_tmp[0].testBHP + "
" +
// "運轉電流: " + obj_tmp[0].testCurrent + "
" +
// "入水溫度: " + obj_tmp[0].testHWT + "
" +
// "出水溫度: " + obj_tmp[0].testCorrectCWT + "
" +
// "濕球溫度: " + obj_tmp[0].testWBT + "
" +
// "風速: " + obj_tmp[0].testWindSpeed + "
" +
// "補充水量: " + obj_tmp[0].testMakeupWFR + "
" +
// "補充水溫: " + obj_tmp[0].testMakeupCWT + "
" +
// "CORRECT CWT: " + obj_tmp[0].testCorrectCWT + "
" +
// "COLLING RANGE: " + obj_tmp[0].testCoolingRange + "
" ;
// document.getElementById('tower_perfrom').innerHTML=inner;
// }
get_predict();
function get_predict() {
var xhr = new XMLHttpRequest();
var url = "channel_predict/dev001/ch01";
obj3 = "";
xhr.open("GET", url);
xhr.onload = function () {
obj3 = JSON.parse(xhr.responseText);
labels = new Array();
for (var i = 0; i < obj3.data.length; i++) {
labels.push(i);
}
console.log(obj3);
var Data = {
labels: labels, //顯示區間名稱
datasets: [{
label: "predict", // tootip 出現的名稱
lineTension: 0, // 曲線的彎度,設0 表示直線
backgroundColor: "#ea464d",
borderColor: "#ea464d",
borderWidth: 5,
data: obj3.data, // 資料
fill: false, // 是否填滿色彩
},]
};
var ctx = document.getElementById("channel_predict").getContext("2d");
drawLineCanvas(ctx, Data);
};
xhr.send();
}
function drawLineCanvas(ctx, data) {
window.myLine = new Chart(ctx, { //先建立一個 chart
type: 'line', // 型態
data: data,
showSymbol: false,
options: {
responsive: true,
legend: { //是否要顯示圖示
display: true,
},
tooltips: { //是否要顯示 tooltip
enabled: true
},
scales: { //是否要顯示 x、y 軸
xAxes: [{
display: true
}],
yAxes: [{
display: true
}]
},
}
});
};