<%@ page contentType="text/html;charset=UTF-8"%>
|
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
|
<%@page import="com.northglass.Globel.mes"%>
|
<%@page import="com.northglass.SqlHelper.*"%>
|
<%@ page contentType="text/html;charset=UTF-8"%>
|
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
|
<html>
|
<head>
|
<script src="/gmms2/static/js/ng/msgencoder.js"></script>
|
</head>
|
<body>
|
<div class="content-wrapper" >
|
<div>
|
<span>输入设备号:</span>
|
<select id="sel">
|
</select>
|
<button onclick="clk();">确定</button>
|
|
<h4 id="hd"></h4>
|
</div>
|
|
<div id="base">
|
</div>
|
|
|
|
</div>
|
<script>
|
|
<%
|
out.print("var devs="+DBHelper.getTableToJson("SELECT id,machine_name from gmms_machine",true)+";");
|
|
%>
|
function init(){
|
var sl=document.getElementById("sel");
|
for(var i=0;i<devs.length;i++){
|
var d=devs[i];
|
var opt=document.createElement("option");
|
opt.value=d.id;
|
opt.innerText=d.machine_name;
|
sl.appendChild(opt);
|
}
|
}
|
init();
|
|
var mobian_config={};
|
|
function makeDefaultConfig(){
|
var data={
|
header:{
|
name:"默认",
|
baseOffset:9
|
} ,
|
body:[
|
|
]
|
|
}
|
|
var b=data.body;
|
for(var j=0;j<5;j++){
|
var p={
|
name:"---------------------------------------------------------------------------------------------------------------------------------",
|
baseOffset:0,
|
fields:[]
|
}
|
b.push(p);
|
for(var i=0;i<10;i++){
|
var f={
|
name:"变量"+(j*10+i+1),
|
offset:(j*10+i)*2,
|
type:"short"
|
};
|
p.fields.push(f);
|
}
|
}
|
return data;
|
}
|
|
|
var jia_su_tai = {
|
header: {
|
name: "默认",
|
baseOffset: 9,
|
file: "加速台",
|
},
|
body: [
|
{
|
name: "PLC--------------------",
|
baseOffset: 0,
|
fields: [
|
{ name: '任务请求字', offset: 0, type: "short" },
|
{ name: '任务请求ID', offset: 2, type: "short" },
|
{ name: '备用0', offset: 4, type: "short" },
|
{ name: '备用1', offset: 6, type: "short" },
|
{ name: '备用2', offset: 8, type: "short" },
|
{ name: '备用3', offset: 10, type: "short" },
|
{ name: '备用4', offset: 12, type: "short" },
|
{ name: '备用5', offset: 14, type: "short" },
|
{ name: '备用6', offset: 16, type: "short" },
|
{ name: '备用7', offset: 18, type: "short" }
|
]
|
},
|
{
|
name: "MES--------------------",
|
baseOffset: 0,
|
fields: [
|
{ name: '任务发送字', offset: 20, type: "short" },
|
{ name: '任务发送ID', offset: 22, type: "short" },
|
{ name: '长', offset: 24, type: "short" },
|
{ name: '宽', offset: 26, type: "short" },
|
{ name: '厚', offset: 28, type: "short" },
|
|
{ name: '玻璃落架第几片', offset: 30, type: "short" },
|
{ name: '备用', offset: 32, type: "short" },
|
{ name: '备用1', offset: 34, type: "short" },
|
{ name: '备用2', offset: 36, type: "short" },
|
{ name: '备用3', offset: 38, type: "short" },
|
|
{ name: '备用4', offset: 40, type: "short" },
|
{ name: '备用5', offset: 42, type: "short" },
|
{ name: '备用6', offset: 44, type: "short" },
|
{ name: '备用7', offset: 46, type: "short" },
|
{ name: '备用8', offset: 48, type: "short" },
|
|
{ name: '备用9', offset: 50, type: "short" },
|
{ name: '备用10', offset: 52, type: "short" },
|
{ name: '备用11', offset: 54, type: "short" },
|
{ name: '备用12', offset: 56, type: "short" },
|
{ name: '备用13', offset: 58, type: "short" }
|
]
|
},
|
{
|
|
name: "PLC-警报字-------------------",
|
baseOffset: 0,
|
fields: [
|
|
{ name: '报警状态', offset: 60, type: "short" },
|
{ name: '报警1', offset: 62, type: "short" },
|
{ name: '报警2', offset: 64, type: "short" },
|
{ name: '报警3', offset: 66, type: "short" },
|
{ name: '报警4', offset: 68, type: "short" }
|
]
|
|
},
|
{
|
|
name: "PLC-状态字-------------------",
|
baseOffset: 0,
|
fields: [
|
{ name: '设备状态字', offset: 70, type: "short" },
|
{ name: '输入输出1', offset: 72, type: "short" },
|
{ name: '输入输出2', offset: 74, type: "short" },
|
{ name: '输入输出3', offset: 76, type: "short" },
|
{ name: '输入输出4', offset: 78, type: "short" },
|
|
{ name: '输入输出5', offset: 80, type: "short" },
|
{ name: '输入输出6', offset: 82, type: "short" },
|
{ name: '输入输出7', offset: 84, type: "short" },
|
{ name: '所有普通电机运行状态', offset: 86, type: "short" },
|
{ name: '主程序控制字', offset: 88, type: "short" },
|
|
|
{ name: 'X输送轴位置', offset: 90, type: "short" },
|
{ name: 'Y输送轴位置', offset: 92, type: "short" },
|
{ name: 'Y测量轴位置', offset: 94, type: "short" }
|
]
|
|
}
|
]
|
}
|
|
|
|
var dic=[
|
{
|
id:10,
|
config:jia_su_tai
|
},
|
{
|
id:20,
|
config:jia_su_tai
|
},
|
{
|
id:32,
|
config:jia_su_tai
|
}
|
|
];
|
|
var current_id=0;
|
var auto_flag=false;
|
var encoder=null;
|
function createEncoder(cfg,id){
|
document.getElementById("base").innerHTML="";
|
encoder= createMessageDecoder(cfg,document.getElementById("base"));
|
if(encoder!=null){
|
auto_flag=true;
|
current_id=id;
|
}
|
}
|
function create(id){
|
for(var i=0;i<dic.length;i++){
|
if(dic[i].id==id){
|
current_id=id;
|
createEncoder(dic[i].config,id);
|
auto_flag=true;
|
return;
|
}
|
}
|
|
createEncoder(makeDefaultConfig(),id);
|
for(var i=0;i<devs.length;i++){
|
if(devs[i].id==id){
|
|
document.getElementById("hd").innerText=devs[i].machine_name;
|
return;
|
}
|
}
|
}
|
|
function end(data,ok){
|
|
setTimeout(autoproc,1000);
|
if(ok){
|
var data=JSON.parse(data);
|
encoder.update(data.data.message);
|
}
|
}
|
|
function autoproc(){
|
if(auto_flag && current_id>0){
|
$.ajax({
|
url:"/gmms2/mesview/data/_msgpeek",
|
type:"post",
|
data:{id:current_id},
|
async:true,
|
success:function(data){
|
end(data,true);
|
},
|
error:function(data){
|
end(data,false);
|
}
|
}
|
);
|
return;
|
}
|
setTimeout(autoproc,1000);
|
}
|
autoproc();
|
function clk(){
|
var id=parseInt( document.getElementById("sel").value);
|
if(id>0)
|
create(id);
|
|
}
|
|
</script>
|
</body>
|
</html>
|