function BaseDataYzd(){}
//页面初始化加载缓存数据
BaseDataYzd.init = function(){
	BaseDataYzd();
	//加载模块初始
	BaseDataYzd.initMonitorYzd();   //加载摄像头关联路段信息
	BaseDataYzd.initMonitorChoose();
	setInterval(function(){
			BaseDataYzd.initMonitorYzd(); 
		}
	,1000*60*60);//每小时更新一次预置点位信息
	
	setInterval(function(){
		if($("#monitorPreset").is(":hidden")){
			BaseDataYzd.initMonitorMoved();
			
		}
	}
	,1000*3);
	
}
//相机移位初始化告警

BaseDataYzd.initMonitorMoved = function(){
	$("#monitorPreset").hide();
	$("#monitorPreset .box ul:eq(0)").empty();
	$.ajax({
		type:'post',
		dataType : 'json',
		url:'sbtdspyzdAction!getMonitorMovedCache.do',
		success:function(data){
		 	if(data){
		 		for(var key in data){
		 			if(data[key]=="1"){
		 				var sbbh = key.split("-")[0];
		 				var tdbh = key.split("-")[1];
		 				var li='<li id="'+sbbh+'_'+tdbh+'">'
		 				+'<span class="monitorPresetMsg">'+BaseDataYzd.monitorYzdMap.get(sbbh+"-"+tdbh).tdmc+'移位已暂停告警</span>'
		 				+'<span class="monitorPresetRecovery" onclick="monitorPresetRecovery(\''+sbbh+'\',\''+tdbh+'\');">复位</span>'
		 				+'<span class="monitorPresetCancel" onclick="monitorPresetCancel(event,this);">取消</span></li>';
		 				$("#monitorPreset .box ul:eq(0)").append(li);
		 			}
		 		}
		 		$("#monitorPreset").show();
		 		if($("#monitorPreset .box ul:eq(0)").children().length<=0){
		 			$("#monitorPreset").hide();
		 		}
		 	}	
		 }
    });
}

//缓存相机移位接口选择与算法IP及端口
BaseDataYzd.initMonitorChoose = function(){
	BaseDataYzd.monitorChooseObj = {};
	$.ajax({
		type:'post',
		dataType : 'json',
		url:'sbtdspyzdAction!getMonitorChooseObj.do',
		success:function(data){
		 	if(data){
		 		BaseDataYzd.monitorChooseObj = data;
		 		console.log("相机接口信息：",BaseDataYzd.monitorChooseObj);
		 	}	
		 }
    });
}
//外挂设备当前状态
BaseDataYzd.initMonitorYzd = function(){
	BaseDataYzd.monitorYzdMap = new Map();//交通事故检测信息
	$.ajax({
		type:'post',
		dataType : 'json',
		url:'sbtdspyzdAction!getAll.do',
		success:function(data){
		 	if(data && data.length ){
		 		for(var i=0;i<data.length;i++){
		 			console.log(BaseDataYzd.monitorYzdMap)
		 			BaseDataYzd.monitorYzdMap.put(data[i].sbbh+"-"+data[i].tdbh,data[i]);
				}
		 		console.log("预置点位信息：",BaseDataYzd.monitorYzdMap);
		 	}	
		 }
    });
}