var i = 1; var j = 1; // 页面对象 //输送线 function Cline(task_no, task_state, address, tray_nbr, number, fromaddress) { this.task_no = task_no;//任务号 this.task_state = task_state;//任务类型 this.address = address;//目的地址 this.tray_nbr = tray_nbr;//托盘条码 this.number = number; this.fromaddress = fromaddress; } //AGV到位 function AGV_Arrive(arrive, run, leave) { this.arrive = arrive;//AGV到位 this.run = run;//接货运行 this.leave = leave;//允许离开 } //堆垛机 function Stacker(switch_online, switch_manual, task_no, row, col, layer, fault_code, state, number) { this.switch_online = switch_online;//开关在线 this.switch_manual = switch_manual;//开关手动 this.task_no = task_no;//任务序列号 this.row = row;//排 this.col = col;//列 this.layer = layer;//层 this.fault_code = fault_code;//故障码 this.state = state; this.number = number; } //穿梭板 function STV(power, online_state, running_state, unusual_state, standby, task_no, row, rol, layer, current_face, change_track_begin, change_track_begin_complete, change_track_end, chage_track_end_complete) { this.power = power;//电量 this.online_state = online_state;//联机状态 this.running_state = running_state;//运行状态 this.unusual_state = unusual_state;//异常状态 this.standby = standby;//待机状态 this.task_no = task_no;//任务号 this.row = row;//当前列(行) this.rol = rol;//当前层 this.layer = layer;//轨道顺序号(列) this.current_face = current_face;//当前面 this.change_track_begin = change_track_begin;//换轨开始 this.change_track_begin_complete = change_track_begin_complete;//换轨开始完成 this.change_track_end = change_track_end;//换轨结束 this.chage_track_end_complete = chage_track_end_complete;//换轨结束完成 } //输送线 var cline_1001 = new Cline();//输送线1001 var cline_1002 = new Cline();//输送线1002 var cline_1005 = new Cline();//输送线1005 var cline_1006 = new Cline();//输送线1006 var cline_1010 = new Cline();//输送线1010 //AGV到位 var agv_arrive_1 = new AGV_Arrive(); var agv_arrive_2 = new AGV_Arrive(); //堆垛机 var stacker_1 = new Stacker();//堆垛机_1 var stacker_2 = new Stacker();//堆垛机_2 //穿梭板 var stv_3 = new STV(); var stv_4 = new STV(); var stv_5 = new STV(); // 页面对象 var interval = null; $(function () { $('#ConveyorLine_1001').click(function () { $.ajax({ type: "post", url: "/AJAX/OPCServiceOperation.ashx", data: { action: "StartProcess" }, async: false, success: function (msg) { } }); }); //$('[data-toggle="popover"]').popover(); }); $(function () { $('#start-system').click(function () { if (i % 2 == 0) { // 关闭服务 //$(".monitoring-area ul li").css("background", "#DADADA"); //$("#conveyerline_1001").css("background", "#DADADA"); $('#start-system').html("开启服务"); $("#start-system").css("background", "#00FF90"); //clearInterval(interval); CloseOpcServer() } else { // 开启服务 //$(".monitoring-area ul li").css("background", "#90EE90"); //$("#conveyerline_1001").css("background", "#90EE90"); $('#start-system').html("关闭服务"); $("#start-system").css("background", "#FF6A00"); StartOpcServer(); //interval = setInterval(GetData, 2000); } i++; }); //$('[data-toggle="popover"]').popover(); }); function MouseUp() { __doPostBack('Button_Query', ""); } function __doPostBack(eventTarget, eventArgument) { if (!theForm.onsubmit || (theForm.onsubmit() != false)) { theForm.__EVENTTARGET.value = eventTarget; theForm.__EVENTARGUMENT.value = eventArgument; theForm.submit(); } } function AddNewOpcDetail() { openDlg("WebForm_ADDOPCDetails.aspx", { title: "新增", width: 850, height: 400 }, function (result) { if (!result) { // document.location = document.location return; } }); } function AddNewOpcSCDetail() { openDlg("WebForm_ADDOPCSCDetails.aspx", { title: "新增", width: 850, height: 400 }, function (result) { if (!result) { // document.location = document.location return; } }); } //重置穿梭板 function ResetSTV() { var stvno = $('#STVNO').val(); var hang = $('#hang').val(); var ceng = $('#ceng').val(); alert(stvno + " " + hang + " " + ceng); } //开启OPC服务 function StartOpcServer() { $.ajax({ type: "post", url: "/AJAX/OPCServiceOperation.ashx", data: { action: "StartOrCloseOpcServer", q0: 1 }, async: false, success: function (msg) { if (msg.length > 0) { ShowMessage("开始服务失败:" + msg); } else { ShowMessage("开始服务成功!"); interval = setInterval(GetPLCData, 1000); } } }); } //获取PLC数据 function GetPLCData() { GetLineInfo(); GetStackInfo(); } //获取输送线数据 function GetLineInfo() { $.ajax({ type: "post", url: "/AJAX/GetConveyorLineInfo.ashx", data: { action: "GetConveyorLineProcess" }, async: false, success: function (msg) { var json = JSON.parse(msg); for (var i = 0; i < json.length; i++) { var clineCon = new Cline(); var controlNmae = "ConveyorLine_"; var controlTableNmae = "ShowTable_"; clineCon.number = json[i].Number; clineCon.task_no = json[i].TaskNumber; clineCon.tray_nbr = json[i].PalletNo; clineCon.address = json[i].ToAdresss; clineCon.fromaddress = json[i].FromAddress; controlNmae += clineCon.number; controlTableNmae += clineCon.number; $('#' + controlNmae).html(clineCon.task_no); if (clineCon.task_no > 0) { $('#' + controlNmae).css("background", "#FFFF00"); } else { $('#' + controlNmae).css("background", "#FFFFFF"); } $('#' + controlNmae).popover({ trigger: 'click', //触发方式 title: "输送机:" + clineCon.number,//设置 弹出框 的标题 html: true, // 为true的话,data-content里就能放html代码了 placement: 'top', content: ContentMethod(controlTableNmae, clineCon),//这里可以直接写字符串,也可以 是一个函数,该函数返回一个字符串 container: 'body' }); $('#' + controlTableNmae + " tr:nth-child(2) td:nth-child(1)").html(clineCon.task_no); $('#' + controlTableNmae + " tr:nth-child(2) td:nth-child(2)").html(clineCon.number); $('#' + controlTableNmae + " tr:nth-child(2) td:nth-child(3)").html(clineCon.address); $('#' + controlTableNmae + " tr:nth-child(2) td:nth-child(4)").html(clineCon.tray_nbr); } } }); } //获取堆垛机数据 function GetStackInfo() { for (var i = 1; i <= 4; i++) { for (var p = 1; p <= 8; p++) { var controlNmae = "Stack_line"; controlNmae += i + "_" + p; $('#' + controlNmae).css("background", "#FFFFFF"); $('#' + controlNmae).html(p); } } $.ajax({ type: "post", url: "/AJAX/GetStackInfo.ashx", data: { action: "GetStackInfoProcess" }, async: false, success: function (msg) { var json = JSON.parse(msg); for (var i = 0; i < json.length; i++) { var stack = new Stacker(); var controlNmae = "Stack_line"; var controlTableNmae = "ShowTable"; stack.task_no = json[i].StackTaskNo; stack.row = json[i].StackLine; stack.col = json[i].StackColumn; stack.layer = json[i].StackLayer; stack.state = json[i].StackState_Execution; stack.number = json[i].SCNumber; controlNmae += stack.row + "_" + stack.col; controlTableNmae += stack.row + "_" + stack.col; $('#' + controlNmae).html(stack.task_no); $('#' + controlNmae).css("background", "#FFFF00"); if (stack.state == "0") { $('#Stack_State_' + stack.number).html("已完成"); } else $('#Stack_State_' + stack.number).html("正在执行"); $('#Stack_TaskNo_' + stack.number).html(stack.task_no); $('#Stack_Line_' + stack.number).html(stack.row); $('#Stack_Column_' + stack.number).html(stack.col); $('#Stack_Layer_' + stack.number).html(stack.layer); $('#Stack_Number_' + stack.number).html(stack.number); $('#' + controlNmae).popover({ trigger: 'click', //触发方式 title: "堆垛机:" + stack.task_no,//设置 弹出框 的标题 html: true, // 为true的话,data-content里就能放html代码了 placement: 'top', content: ContentMethod(controlTableNmae, stack),//这里可以直接写字符串,也可以 是一个函数,该函数返回一个字符串 container: 'body' }); $('#' + controlTableNmae + " tr:nth-child(2) td:nth-child(1)").html(stack.task_no); $('#' + controlTableNmae + " tr:nth-child(2) td:nth-child(2)").html(stack.row); $('#' + controlTableNmae + " tr:nth-child(2) td:nth-child(3)").html(stack.col); $('#' + controlTableNmae + " tr:nth-child(2) td:nth-child(4)").html(stack.layer); } } }); } //关闭OPC服务 function CloseOpcServer() { $.ajax({ type: "post", url: "/AJAX/OPCServiceOperation.ashx", data: { action: "StartOrCloseOpcServer", q0: 0 }, async: false, success: function (msg) { if (msg.length > 0) { ShowMessage("关闭服务失败:" + msg); } } }); } function GetData() { $.ajax({ type: "post", url: "/AJAX/RequestOperation/RequestOperation_2.ashx", data: { action: "GetData" }, async: false, success: function (msg) { if (msg.length > 0) { var json = JSON.parse(msg); for (var i = 0; i < json.length; i++) { if (json[i].GroupName == "Cn0") { // 巷道1001 if (json[i].ItemNo == "Item01") { cline_1001.task_no = json[i].ItemValue; } if (json[i].ItemNo == "Item02") { cline_1001.task_state = json[i].ItemValue; } if (json[i].ItemNo == "Item04") { cline_1001.address = json[i].ItemValue; } if (json[i].ItemNo == "Item05") { cline_1001.tray_nbr = json[i].ItemValue; } // 巷道1002 if (json[i].ItemNo == "Item07") { cline_1002.task_no = json[i].ItemValue; } if (json[i].ItemNo == "Item08") { cline_1002.task_state = json[i].ItemValue; } if (json[i].ItemNo == "Item10") { cline_1002.address = json[i].ItemValue; } if (json[i].ItemNo == "Item11") { cline_1002.tray_nbr = json[i].ItemValue; } // 巷道1005 if (json[i].ItemNo == "Item13") { cline_1005.task_no = json[i].ItemValue; } if (json[i].ItemNo == "Item14") { cline_1005.task_state = json[i].ItemValue; } if (json[i].ItemNo == "Item16") { cline_1005.address = json[i].ItemValue; } if (json[i].ItemNo == "Item17") { cline_1005.tray_nbr = json[i].ItemValue; } // 巷道1006 if (json[i].ItemNo == "Item19") { cline_1006.task_no = json[i].ItemValue; } if (json[i].ItemNo == "Item20") { cline_1006.task_state = json[i].ItemValue; } if (json[i].ItemNo == "Item22") { cline_1006.address = json[i].ItemValue; } if (json[i].ItemNo == "Item23") { cline_1006.tray_nbr = json[i].ItemValue; } // 巷道1010 if (json[i].ItemNo == "Item25") { cline_1010.task_no = json[i].ItemValue; } if (json[i].ItemNo == "Item26") { cline_1010.task_state = json[i].ItemValue; } if (json[i].ItemNo == "Item28") { cline_1010.address = json[i].ItemValue; } if (json[i].ItemNo == "Item29") { cline_1010.tray_nbr = json[i].ItemValue; } // 1001 AGV到位 if (json[i].ItemNo == "Item34") { agv_arrive_1.arrive = json[i].ItemValue; } if (json[i].ItemNo == "Item36") { agv_arrive_1.run = json[i].ItemValue; } if (json[i].ItemNo == "Item37") { agv_arrive_1.leave = json[i].ItemValue; } // 1002 AGV到位 if (json[i].ItemNo == "Item35") { agv_arrive_2.arrive = json[i].ItemValue; } if (json[i].ItemNo == "Item38") { agv_arrive_2.run = json[i].ItemValue; } if (json[i].ItemNo == "Item39") { agv_arrive_2.leave = json[i].ItemValue; } } if (json[i].GroupName == "Cn1") { //堆垛机_1 if (json[i].ItemNo == "Item04") { stacker_1.switch_online = json[i].ItemValue; } if (json[i].ItemNo == "Item06") { stacker_1.switch_manual = json[i].ItemValue; } if (json[i].ItemNo == "Item29") { stacker_1.task_no = json[i].ItemValue; } if (json[i].ItemNo == "Item11") { stacker_1.row = json[i].ItemValue; } if (json[i].ItemNo == "Item09") { stacker_1.col = json[i].ItemValue; } if (json[i].ItemNo == "Item10") { stacker_1.layer = json[i].ItemValue; } if (json[i].ItemNo == "Item12") { stacker_1.fault_code = json[i].ItemValue; } } if (json[i].GroupName == "Cn2") { //堆垛机_2 if (json[i].ItemNo == "Item04") { stacker_2.switch_online = json[i].ItemValue; } if (json[i].ItemNo == "Item06") { stacker_2.switch_manual = json[i].ItemValue; } if (json[i].ItemNo == "Item29") { stacker_2.task_no = json[i].ItemValue; } if (json[i].ItemNo == "Item11") { stacker_2.row = json[i].ItemValue; } if (json[i].ItemNo == "Item09") { stacker_2.col = json[i].ItemValue; } if (json[i].ItemNo == "Item10") { stacker_2.layer = json[i].ItemValue; } if (json[i].ItemNo == "Item12") { stacker_2.fault_code = json[i].ItemValue; } } if (json[i].GroupName == "Cn3") { //3号穿梭板 if (json[i].ItemNo == "Item30") { stv_3.power = json[i].ItemValue; } if (json[i].ItemNo == "Item15") { stv_3.online_state = json[i].ItemValue; } if (json[i].ItemNo == "Item23") { stv_3.running_state = json[i].ItemValue; } if (json[i].ItemNo == "Item25") { stv_3.unusual_state = json[i].ItemValue; } if (json[i].ItemNo == "Item33") { stv_3.standby = json[i].ItemValue; } if (json[i].ItemNo == "Item34") { stv_3.task_no = json[i].ItemValue; } if (json[i].ItemNo == "Item28") { stv_3.row = json[i].ItemValue; } if (json[i].ItemNo == "Item29") { stv_3.rol = json[i].ItemValue; } if (json[i].ItemNo == "Item04") { stv_3.layer = json[i].ItemValue; } if (json[i].ItemNo == "Item31") { stv_3.current_face = json[i].ItemValue; } if (json[i].ItemNo == "Item10") { stv_3.change_track_begin = json[i].ItemValue; } if (json[i].ItemNo == "Item19") { stv_3.change_track_begin_complete = json[i].ItemValue; } if (json[i].ItemNo == "Item11") { stv_3.change_track_end = json[i].ItemValue; } if (json[i].ItemNo == "Item20") { stv_3.chage_track_end_complete = json[i].ItemValue; } } if (json[i].GroupName == "Cn4") { //4号穿梭板 if (json[i].ItemNo == "Item30") { stv_4.power = json[i].ItemValue; } if (json[i].ItemNo == "Item15") { stv_4.online_state = json[i].ItemValue; } if (json[i].ItemNo == "Item23") { stv_4.running_state = json[i].ItemValue; } if (json[i].ItemNo == "Item25") { stv_4.unusual_state = json[i].ItemValue; } if (json[i].ItemNo == "Item33") { stv_4.standby = json[i].ItemValue; } if (json[i].ItemNo == "Item34") { stv_4.task_no = json[i].ItemValue; } if (json[i].ItemNo == "Item28") { stv_4.row = json[i].ItemValue; } if (json[i].ItemNo == "Item29") { stv_4.rol = json[i].ItemValue; } if (json[i].ItemNo == "Item04") { stv_4.layer = json[i].ItemValue; } if (json[i].ItemNo == "Item31") { stv_4.current_face = json[i].ItemValue; } if (json[i].ItemNo == "Item10") { stv_4.change_track_begin = json[i].ItemValue; } if (json[i].ItemNo == "Item19") { stv_4.change_track_begin_complete = json[i].ItemValue; } if (json[i].ItemNo == "Item11") { stv_4.change_track_end = json[i].ItemValue; } if (json[i].ItemNo == "Item20") { stv_4.chage_track_end_complete = json[i].ItemValue; } } if (json[i].GroupName == "Cn5") { //5号穿梭板 if (json[i].ItemNo == "Item30") { stv_5.power = json[i].ItemValue; } if (json[i].ItemNo == "Item15") { stv_5.online_state = json[i].ItemValue; } if (json[i].ItemNo == "Item23") { stv_5.running_state = json[i].ItemValue; } if (json[i].ItemNo == "Item25") { stv_5.unusual_state = json[i].ItemValue; } if (json[i].ItemNo == "Item33") { stv_5.standby = json[i].ItemValue; } if (json[i].ItemNo == "Item34") { stv_5.task_no = json[i].ItemValue; } if (json[i].ItemNo == "Item28") { stv_5.row = json[i].ItemValue; } if (json[i].ItemNo == "Item29") { stv_5.rol = json[i].ItemValue; } if (json[i].ItemNo == "Item04") { stv_5.layer = json[i].ItemValue; } if (json[i].ItemNo == "Item31") { stv_5.current_face = json[i].ItemValue; } if (json[i].ItemNo == "Item10") { stv_5.change_track_begin = json[i].ItemValue; } if (json[i].ItemNo == "Item19") { stv_5.change_track_begin_complete = json[i].ItemValue; } if (json[i].ItemNo == "Item11") { stv_5.change_track_end = json[i].ItemValue; } if (json[i].ItemNo == "Item20") { stv_5.chage_track_end_complete = json[i].ItemValue; } } } // 输送线监控 monitoringConveyerLineInfo("#conveyerline_1001", cline_1001); monitoringConveyerLineInfo("#conveyerline_1002", cline_1002); monitoringConveyerLineInfo("#conveyerline_1005", cline_1005); monitoringConveyerLineInfo("#conveyerline_1006", cline_1006); monitoringConveyerLineInfo("#conveyerline_1010", cline_1010); // 堆垛机监控 $('#stacker_1 li').eq(0).css("background", "red"); j++; if (j >= 10000) { j = 2; } } } }); } //判断当前输送节点上的情况 function monitoringConveyerLineInfo(equipment_id, obj) { var str = equipment_id.substring(equipment_id.length - 4); if ("0" != obj.task_no && "" != obj.task_no && null != obj.task_no) { $(equipment_id).css("background", "yellow"); if (j == 1) { $(equipment_id).popover({ trigger: 'click', //触发方式 title: "输送机:" + str,//设置 弹出框 的标题 html: true, // 为true的话,data-content里就能放html代码了 placement: 'top', content: ContentMethod(obj),//这里可以直接写字符串,也可以 是一个函数,该函数返回一个字符串 container: 'body' }); } } else { $(equipment_id).css("background", "#90EE90"); } //$("#popover973027 table").remove(); //$("#popover973027 .popover-content").html("11111"); } // 弹出框返回函数 function ContentMethod(tableID, obj) { return '' + '' + '' + //'' + '
任务号任务类型目的地址托盘条码
' + obj.task_no + '' + obj.row + '' + obj.col + '' + obj.layer + '
' + 0 + '' + 0 + '' + 0 + '' + 0 + '
'; } function ShowMessage(msg) { alertMsg({ style: 'info', text: '' + msg, title: 'Tip', callback: function () { } }).init() }