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[i].tower_name+'';
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);
tower_info("dev001");
};
xhr2.send();
}
}
function tower_info(tower_str){
tower = tower_str;
console.log(tower);
inner = "";
for(var i=0;i 入水溫度 = '+ 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 + '
\
\
\
\
出水溫度
\
\
'+ 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.ch01.Vrms + ' | \
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.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+'
\
\
\
\
ch002,通道3
\
\
'+ obj2[i].tower_data.Moter.ch01.Vrms + ',' + obj2[i].tower_data.Moter.ch01.CV+'
\
\
\
\
ch002,通道4
\
\
'+ obj2[i].tower_data.Moter.ch02.Vrms + ',' + obj2[i].tower_data.Moter.ch02.CV+'
\
\
\
\
\
\
\
';
}
}
document.getElementById("tower_info").innerHTML = inner;
}
//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[i].company+'';
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[i].factory+'';
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[i].department+'';
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[i].group[ii]+'';
}
}
}
}
document.getElementById("towerGroup-list").innerHTML= towerGroup_inner;
}