function aqmgjPushlet(){}
aqmgjPushlet.init = function(){
	aqmgjPushlet.initData();
}

//gdwdaqmxx.js 中开启 aqmgjPushlet.init
//pushlet加载
aqmgjPushlet.initData = function (){
	try {
//		console.log("***安全帽检测事件pushlet初始化!***");
		PL._init();
		PL.join();
		PL.listen();
		PL.subscribe('/aqmgjPushletData'); //安全帽检测事
//		console.log("***安全帽检测事件pushlet开启!***");
	} catch(e) {
		$.showMsg('Pushlet监听【aqmgjPushlet】初始化失败! ');
		setTimeout("PushletData.initData()",10000);
	}
}

aqmgjPushlet.leave = function () {
	try {
		PL.leave();
		console.log('pushlet关闭');
	} catch(e) {
		console.log("Pushlet关闭失败!");
	}
}

//接收数据
function onData(data) {
//	console.log('安全帽检测事件pushlet接收数据 = ',data);
	var event = data.get("p_subject");
	var sid = data.get("p_sid");
	var text = data.get("json");
	if(text==""||text==null||text==undefined){
		return;
	}
	if(event == "/aqmgjPushletData") {
//		console.log('安全帽检测事件pushlet接收数据1111=== ',text);
		pushStatMsg(eval(text));
		return;
	}
}


//接收安全帽检测事件，并加载至页面告警台
function pushStatMsg(data){
	//console.log('安全帽检测事件pushlet2222=',data);
	if(data.length){   //如果返回数据大于0
		var li = "";
		$("#monitorPreset").show();
		data.forEach(function(item){
	//		console.log('有最新告警事件*********',item)
			li +='<li >'
					+'<span class="monitorPresetMsg">'+item.fwdsdksbjsj+' '+item.bjzwmc+' 产生告警</span>'
					/*+'<span class="monitorPresetRecovery" >复位</span>'
					+'<span class="monitorPresetCancel" >取消</span>'*/
				+'</li>';
		})

		$("#monitorPreset .box ul:eq(0)").html(li);
		
	}
	
}

//错误重载
function onError(){
	console.log('安全帽告警事件pushlet--onError！');
	setTimeout("alarmPushlet.init()",60000);
}

