393 lines
11 KiB
HTML
393 lines
11 KiB
HTML
<!DOCTYPE html>
|
|
<html>
|
|
<head>
|
|
<meta charset="UTF-8">
|
|
|
|
<script src="jquery-2.1.0.min.js"></script>
|
|
<script src="jquery.cookie.js"></script>
|
|
<!--<script type="text/javascript" src="eventemitter2.min.js"></script>-->
|
|
<!--<script type="text/javascript" src="roslib.min.js"></script>-->
|
|
<!--<script type="text/javascript" src="Lu_ROS_Driver.js"></script>-->
|
|
<script type="text/javascript" src="Lu_Scroll_Driver.js"></script>
|
|
<script type="text/javascript" src="Lu_Login_Driver.js"></script>
|
|
<script type="text/javascript" type="text/javascript">
|
|
var Login_Info=$.cookie('Login_Info');
|
|
|
|
var level=Lu_Parse_Login_Info(Login_Info);
|
|
console.log("level:"+level);
|
|
|
|
function client_request(str){
|
|
$('#output').html("");
|
|
window.parent.postMessage(
|
|
{
|
|
event_id: 'client_request',
|
|
data: {
|
|
v1: str
|
|
}
|
|
},
|
|
"*" //or "www.parentpage.com"
|
|
);
|
|
}
|
|
|
|
|
|
|
|
|
|
function receiveMessage(event)
|
|
{
|
|
//console.log(event.data);
|
|
|
|
switch(event.data.event_id){
|
|
|
|
case "client_response":{
|
|
var data=event.data.data;
|
|
var result=data.v1;
|
|
var ROS_String_Output=data.v2;
|
|
var Rec_HMI_String_Input=data.v3;
|
|
|
|
var Client_Request_Cmd=Rec_HMI_String_Input.split(':');
|
|
|
|
|
|
//console.log(data);
|
|
switch(Client_Request_Cmd[0]){
|
|
case "Temperature":{
|
|
document.getElementById('output').innerText=ROS_String_Output;
|
|
}
|
|
break;
|
|
case "FullScreenNow":{
|
|
document.getElementById('output').innerText=ROS_String_Output;
|
|
}
|
|
break;
|
|
case "MappingNow":{
|
|
document.getElementById('output').innerText=ROS_String_Output;
|
|
}
|
|
break;
|
|
case "QuitNow":{
|
|
document.getElementById('output').innerText=ROS_String_Output;
|
|
}
|
|
break;
|
|
case "PowerOff":{
|
|
document.getElementById('output').innerText=ROS_String_Output;
|
|
}
|
|
break;
|
|
case "GetIP":{
|
|
document.getElementById('output').innerText=ROS_String_Output;
|
|
}
|
|
break;
|
|
case "GetLogList":{
|
|
//console.log(data);
|
|
|
|
snsArr=ROS_String_Output.split(/[(\r\n)\r\n]+/);
|
|
snsArr.forEach((item,index)=>{
|
|
if(!item){
|
|
snsArr.splice(index,1);//删除空项
|
|
}
|
|
else{
|
|
var MyDiv =document.getElementById("output");
|
|
var button = document.createElement("input");
|
|
button.setAttribute("type", "button");
|
|
button.setAttribute("value", snsArr[index]);
|
|
button.style.width = "80%";
|
|
button.style.height = "50px";
|
|
button.style.background="Cyan";
|
|
button.setAttribute("onclick", "client_request('OpenFile:'+this.value)");
|
|
MyDiv.appendChild(button);
|
|
}
|
|
});
|
|
//console.log(data);
|
|
|
|
}
|
|
break;
|
|
case "GetPCDList":{
|
|
snsArr=ROS_String_Output.split(/[(\r\n)\r\n]+/);
|
|
snsArr.forEach((item,index)=>{
|
|
if(!item){
|
|
snsArr.splice(index,1);//删除空项
|
|
}
|
|
else{
|
|
var MyDiv =document.getElementById("output");
|
|
var button = document.createElement("input");
|
|
button.setAttribute("type", "button");
|
|
button.setAttribute("value", snsArr[index]);
|
|
button.style.width = "80%";
|
|
button.style.height = "50px";
|
|
button.style.background="Cyan";
|
|
button.setAttribute("onclick", "client_request('UsePCDFile:'+this.value)");
|
|
MyDiv.appendChild(button);
|
|
}
|
|
});
|
|
}
|
|
break;
|
|
case "GetROSNodeList":{
|
|
document.getElementById('output').innerText=ROS_String_Output;
|
|
}
|
|
break;
|
|
case "OpenFile":{
|
|
//console.log(data.v2);
|
|
document.getElementById('output').innerText=ROS_String_Output;
|
|
}
|
|
break;
|
|
}
|
|
}
|
|
break;
|
|
}
|
|
|
|
}
|
|
|
|
window.addEventListener("message", receiveMessage, false);
|
|
|
|
function client(str){
|
|
$('#output').html("");
|
|
var client_HMIString=new ROSLIB.Service({
|
|
ros:ros,
|
|
name:'/Service_HMIString',
|
|
serviceType:'lu_ps20l_msgs/Srv_HMIString'
|
|
});
|
|
|
|
var request = new ROSLIB.ServiceRequest({
|
|
HMI_String_Input:str
|
|
});
|
|
|
|
client_HMIString.callService(request,function(result) {
|
|
/*
|
|
console.log('Result for service call on '
|
|
+ client_HMIString.name
|
|
+ ': '
|
|
+ result.result
|
|
+ ': '
|
|
+ result.ROS_String_Output);
|
|
*/
|
|
//client_result=result.result;
|
|
//client_ROS_String_Output=result.ROS_String_Output;
|
|
if(request.HMI_String_Input=='GetLogList'){
|
|
//document.getElementById('LogList').innerText=result.ROS_String_Output;
|
|
snsArr=result.ROS_String_Output.split(/[(\r\n)\r\n]+/);
|
|
snsArr.forEach((item,index)=>{
|
|
if(!item){
|
|
snsArr.splice(index,1);//删除空项
|
|
}
|
|
else{
|
|
var MyDiv =document.getElementById("output");
|
|
var button = document.createElement("input");
|
|
button.setAttribute("type", "button");
|
|
button.setAttribute("value", snsArr[index]);
|
|
button.style.width = "80%";
|
|
button.style.height = "50px";
|
|
button.style.background="Cyan";
|
|
button.setAttribute("onclick", "client('OpenFile:'+this.value)");
|
|
MyDiv.appendChild(button);
|
|
}
|
|
})
|
|
}
|
|
else{
|
|
snsArr=request.HMI_String_Input.split(':');
|
|
if(snsArr[0]=='OpenFile'){
|
|
document.getElementById('output').innerText=result.ROS_String_Output;
|
|
}
|
|
}
|
|
});
|
|
}
|
|
|
|
|
|
var openFile = function(event) {
|
|
|
|
var input = event.target;
|
|
var selectedFile = input.files[0];
|
|
console.log(selectedFile);
|
|
if(selectedFile.type=='text/plain'){
|
|
var reader = new FileReader();
|
|
reader.onload = function() {
|
|
if(reader.result) {
|
|
//显示文件内容
|
|
$("#output").html(reader.result.replace(/\n|\r\n/g,"<br/>"));
|
|
}
|
|
};
|
|
reader.readAsText(input.files[0]);
|
|
}
|
|
else{
|
|
alert("非HMI日志文件");
|
|
}
|
|
};
|
|
|
|
|
|
/*
|
|
function poweroff_request(){
|
|
var r = confirm("亲,您确定关机么?")
|
|
if (r == true) {
|
|
client_request("PowerOff");
|
|
} else {
|
|
|
|
}
|
|
|
|
}
|
|
*/
|
|
var fullscreen_display=false;
|
|
var monitor_display=false;
|
|
var quit_display=false;
|
|
var power_display=false;
|
|
var mapping_display=false;
|
|
var times1=0;
|
|
var times2=0;
|
|
var times3=0;
|
|
var times4=0;
|
|
var times5=0;
|
|
function fullscreen_request(){
|
|
if(fullscreen_display){
|
|
fullscreen_display=false;
|
|
}
|
|
else{
|
|
fullscreen_display=true;
|
|
}
|
|
}
|
|
function monitor_request(){
|
|
if(monitor_display){
|
|
monitor_display=false;
|
|
}
|
|
else{
|
|
monitor_display=true;
|
|
}
|
|
}
|
|
function quit_request(){
|
|
if(quit_display){
|
|
quit_display=false;
|
|
}
|
|
else{
|
|
// if(level>0) {
|
|
quit_display = true;
|
|
// }
|
|
// else{}//alert("请登录账号");
|
|
}
|
|
}
|
|
function power_request(){
|
|
if(power_display){
|
|
power_display=false;
|
|
}
|
|
else{
|
|
if(level>0) {
|
|
power_display = true;
|
|
}
|
|
else {}//alert("请登录账号");
|
|
}
|
|
}
|
|
function mapping_request(){
|
|
if(mapping_display){
|
|
mapping_display=false;
|
|
}
|
|
else{
|
|
if(level>0) {
|
|
mapping_display = true;
|
|
}
|
|
else {}//alert("请登录账号");
|
|
}
|
|
}
|
|
function Timer(){
|
|
if(power_display){
|
|
|
|
document.getElementById('PowerOff').style.display="";
|
|
document.getElementById('PowerReboot').style.display="";
|
|
}
|
|
else{
|
|
times1=0;
|
|
document.getElementById('PowerOff').style.display="none";
|
|
document.getElementById('PowerReboot').style.display="none";
|
|
}
|
|
times1=times1+1;
|
|
if(times1>20){
|
|
power_display=false;
|
|
}
|
|
|
|
if(quit_display){
|
|
document.getElementById('QuitNow').style.display="";
|
|
}
|
|
else{
|
|
times2=0;
|
|
document.getElementById('QuitNow').style.display="none";
|
|
}
|
|
times2=times2+1;
|
|
if(times2>20){
|
|
quit_display=false;
|
|
}
|
|
|
|
if(fullscreen_display){
|
|
document.getElementById('FullScreenNow').style.display="";
|
|
}
|
|
else{
|
|
times3=0;
|
|
document.getElementById('FullScreenNow').style.display="none";
|
|
}
|
|
times3=times3+1;
|
|
if(times3>20){
|
|
fullscreen_display=false;
|
|
}
|
|
|
|
if(mapping_display){
|
|
document.getElementById('MappingNow').style.display="";
|
|
}
|
|
else{
|
|
times4=0;
|
|
document.getElementById('MappingNow').style.display="none";
|
|
}
|
|
times4=times4+1;
|
|
if(times4>20){
|
|
mapping_display=false;
|
|
}
|
|
|
|
if(monitor_display){
|
|
document.getElementById('MonitorNow').style.display="";
|
|
}
|
|
else{
|
|
times5=0;
|
|
document.getElementById('MonitorNow').style.display="none";
|
|
}
|
|
times5=times5+1;
|
|
if(times5>20){
|
|
monitor_display=false;
|
|
}
|
|
}
|
|
var T1 = window.setInterval("Timer()",100);
|
|
</script>
|
|
</head>
|
|
<body>
|
|
|
|
<!--HMI_Log
|
|
<div id="abc1"></div>
|
|
<div id="abc2"></div>
|
|
<div id="abc3"></div>
|
|
-->
|
|
<!-- <input type='file' accept='text/plain' onchange='openFile(event)'><br>-->
|
|
<table>
|
|
<tr>
|
|
<!--<input type=button value="Test" onclick=client("Test")></input>-->
|
|
<!--<input type=button value="HMIRebornInit" style="width:20%;height:50px;background:yellow" onclick=client_request("HMIRebornInitNow")></input>-->
|
|
<!--<input type=button value="HMIStartCheckNow" style="width:20%;height:50px;background:yellow" onclick=client_request("HMIStartCheckNow")></input>-->
|
|
<input type=button value="Temperature" style="width:20%;height:50px;background:yellow" onclick=client_request("Temperature")></input>
|
|
<input type=button value="GetROSNodeList" style="width:20%;height:50px;background:yellow" onclick=client_request("GetROSNodeList")></input>
|
|
<input type=button value="GetLogList" style="width:20%;height:50px;background:yellow" onclick=client_request("GetLogList")></input>
|
|
<input type=button value="GetPCDList" style="width:20%;height:50px;background:yellow" onclick=client_request("GetPCDList")></input>
|
|
<input type=button value="GetIP" style="width:20%;height:50px;background:yellow" onclick=client_request("GetIP")></input>
|
|
<input type=button value="FullScreen" style="width:20%;height:50px;background:pink" onclick=fullscreen_request()></input>
|
|
<input type=button value="Monitor" style="width:20%;height:50px;background:deeppink" onclick=monitor_request()></input>
|
|
<input type=button value="Mapping" style="width:20%;height:50px;background:deeppink" onclick=mapping_request()></input>
|
|
<input type=button value="Quit" style="width:20%;height:50px;background:green" onclick=quit_request()></input>
|
|
<input type=button value="Power" style="width:20%;height:50px;background:red" onclick=power_request()></input>
|
|
|
|
<!--<input type='file' id="load" accept='text/plain' onchange='OpenFile(event)'><br>-->
|
|
</tr>
|
|
<tr>
|
|
<input type=button id="FullScreenNow" value="FullScreenNow" style="width:30%;height:50px;background:pink" onclick=client_request("FullScreenNow")></input>
|
|
<input type=button id="MappingNow" value="MappingNow" style="width:30%;height:50px;background:deeppink" onclick=client_request("MappingNow")></input>
|
|
<input type=button id="MonitorNow" value="MonitorNow" style="width:30%;height:50px;background:deeppink" onclick=client_request("MonitorNow")></input>
|
|
<input type=button id="QuitNow" value="QuitNow" style="width:30%;height:50px;background:green" onclick=client_request("QuitNow")></input>
|
|
</tr>
|
|
<tr>
|
|
<input type=button id="PowerOff" value="PowerOff" style="width:30%;height:50px;background:red" onclick=client_request("PowerOff")></input>
|
|
<input type=button id="PowerReboot" value="PowerReboot" style="width:30%;height:50px;background:red" onclick=client_request("PowerReboot")></input>
|
|
</tr>
|
|
<tr>
|
|
<div id="output"></div>
|
|
<!--<div id="LogList"></div>-->
|
|
</tr>
|
|
|
|
</table>
|
|
</body>
|
|
</html>
|