import java.util.Set;
import javax.websocket.Endpoint;
import javax.websocket.server.ServerApplicationConfig;
import javax.websocket.server.ServerEndpointConfig;
/**
* ServerApplicationConfig这个接口的实现类,会在项目启动时,自动执行!
*
*/
public class WebSocketConfig implements ServerApplicationConfig {
/**
* 注解方式编程启动
* scaned表示由服务器扫描诸多的注解的类扫描传入进来
* 1.getAnnotatedEndpointClasses
* 2.getEndpointConfigs
* 上面的两个方法都是用来注册websocket的。 只不过注册的方式不同。
* 1方法是注解的方式
* 2方法是接口的方式
* 显然注解的方式更加的灵活简单。 接口的方式更加的传统,严谨。
* EndPoint代表一个websocket服务端程序,相当于以前的servlet
*/
public Set<Class<?>> getAnnotatedEndpointClasses(Set<Class<?>> scaned) {
//发现打印出来一个
System.out.println("正在扫描所有的websocket服务..................scaned_size: " + scaned.size());
//返回scaned,如果不反悔,服务器不会返回任何的server,起到过滤的作用.
return scaned;
}
/**
* 接口方式编程 因为我们使用注解编程,所以这个方式不关注
*/
public Set<ServerEndpointConfig> getEndpointConfigs(Set<Class<? extends Endpoint>> arg0) {
return null;
}
}
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
import javax.websocket.OnClose;
import javax.websocket.OnMessage;
import javax.websocket.OnOpen;
import javax.websocket.Session;
import javax.websocket.server.ServerEndpoint;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.context.ContextLoader;
import com.aztech.entity.AlarmDTO;
import com.aztech.entity.IDDTO;
import com.aztech.entity.InfoDTO;
import com.aztech.entity.MessageDTO;
import com.aztech.entity.UserAccount;
import com.aztech.service.CommunityDetailService;
import com.aztech.utils.UUIDUtils;
import com.google.gson.Gson;
@Controller
@ServerEndpoint("/websocket/smartControl")
public class SmartControlSocket {
@Autowired
private CommunityDetailService communityDetailService = ContextLoader.getCurrentWebApplicationContext().getBean(CommunityDetailService.class);
/**
* 每次打开一个websocket通道,都会生成一个smartControlSocket实例,而一个endpoint实例,用来应对一个通道的信息传递。
* 所以,我们的SmartControlSocket是线程安全的
*/
private static Map<String, Session> sMap = new HashMap<String, Session>();
private Gson gson = new Gson();
private String blockId;
private static List<Session> sessions = new ArrayList<Session>();
//设想的是因为到时候有很多的C程序会长连接WebSocket,到时候能不能在C程序的URL中加入一个username,就是是哪个程序访问建立长连接
private static List<String> blockIds = new ArrayList<String>();
/**
* 只有一个类去应对多个管道,也就是相当于多个线程同时访问
* 这里主要是看是单例的还是多例的,如果用成员变量保存数据的时候,会不会造成多线程冲突呢?
* 每根管道都是一个独立的对象,和struts2的action很像,每个请求都是独立的控制器,每个成员变量都是独立的
* 这个是在建立客户端和服务端每次建立连接的时候会调用构造方法,然后在执行open方法,表示新的连接已经建立
*/
public SmartControlSocket() {
System.out.println("创建一个SmartControlSocket实例!!!!");
}
/**
* 接收open的请求,就是响应,这个响应也是基于注解的,只要在方法头上加上一个注解@OnOpen
* 只要有人连我的WebSocket,这个open方法就会执行,而且会依赖注入进来一个重要的对象Session
* 有很多Session,session代表一次会话,而WebSocket一个管道就代表一个Session,一个管道可以发送接收很多信息,所以也代表一个会话
* 一个服务器端的Session代表一个通信的会话,管道结束通话也结束!!!!
* 一个sessionId唯一代表一个管道,一个WebSocket有可能很多人连,那怎么去区分谁来连呢?就是通过sessionId来区分的.
* sessionId是0开始的,10个sessionId10个管道,管道之间是不会互相干扰的.
* 但是只有一个类去应对多个管道,也就是相当于多个线程同时访问,我们去看一下是单例的还是多例的
* Open表示只要有人申请我就会打开一个通道,同时会执行服务器端open的响应事件,会传入一个Session,会把刚创建好的新的通道打开的引用给我们传进来
* 这个时候我们要告诉所有人谁进来了,我怎么知道当前这个人是谁呢?这个作用域的Session和以前的Session不一样
* 当前WebSocket的session对象,不是servlet的session!!
* 注意:SPS100项目中open方法不需要广播,因为C程序那边进来是不需要接收数据的。
*/
@OnOpen
public void open(Session session) {
//打印一个sessionId,如果打印,说明有人连接了,说明已经和服务器连接好通信了
System.out.println("已经建立一个websocket连接通道!!!! sessionId是: " + session.getId());
// 当前WebSocket的Session不是Servlet的Session!!!! 当前Socket的Session可以怎样来取呢?
//getQueryString()可以把问号后面的串可以全部打印出来,这样我们就知道是谁登陆进来了
//String queryString = session.getQueryString();
Map<String, List<String>> requestParameterMap = session.getRequestParameterMap();
System.out.println("requestParameterMap" + requestParameterMap);
List<String> list = requestParameterMap.get("blockId");
//如果是aztech开头的blockId说明是从sps100管理系统客户端建立的连接,因为UI界面没有传blockId
//this.blockId = "aztech" + (int)(Math.random()*100)+1;
this.blockId = "AZTECH" + UUIDUtils.getUUID32();
//如果传入的blockId不为null,说明是C程序连接的,这个时候要把默认生成的替换成实际的blockId,就是需要获取传过来的blockId
if(list!=null) {
this.blockId = list.get(0);
}
//username=xiaolong
//System.out.println(queryString);
//this.blockId = queryString!=null?queryString.split("=")[1]:null;
System.out.println(this.blockId);
//每次有人进来,就把访问的blockId放入blockIds里面,这样子就都进来了
//这里用List和Set是一样的,因为blockId本来就是唯一的
blockIds.add(this.blockId);
//session肯定是唯一的
sessions.add(session);
//这里用key=>value的形式去绑定,以便后面遍历获取
sMap.put(this.blockId, session);
}
/**
* 把保存的对象清空
* 这个也会自动调用,只要加注解OnClose
*/
@OnClose
public void close(Session session) {
//不能把退出去的session还保留,这里的remove是集合List里的方法
sessions.remove(session);
//不能把退出去的用户还保留
blockIds.remove(this.blockId);
sMap.remove(this.blockId);
System.out.println("session:" + session.getId() + " is already closed......");
}
/**
* 如果是control功能,就用这个方法单播发送
* @param messageDTO
* @param session
*/
public void sendControlMessage(MessageDTO messageDTO,Session session) {
List<IDDTO> idDTOList = messageDTO.getIdArr();
if(idDTOList!=null && idDTOList.size()>0) {
IDDTO idDTO = idDTOList.get(0);
Integer whatID = idDTO.getWhatId();
//whatID为1是communityId
if(whatID==1 && idDTO.getIdValues()!=null && idDTO.getIdValues().size()>0) {
//获取communityId的值
int idValue = idDTO.getIdValues().get(0);
String communityId = String.valueOf(idValue);
//通过communityId可以查询这个小区下所有的blockId
List<String> blockIdList = this.communityDetailService.selectBlockIdListByCommunityId(communityId);
System.out.println(blockIdList);
for(String blockID: blockIdList) {
//通过blockId获取对应的Session
Session s = sMap.get(blockID);
//然后单播给communityId下的每一个blockId
if(s!=null) {
singleBroadcast(s,gson.toJson(messageDTO));
}
}
//这里是希望发给指定的C程序会后还发给UI发指令的这个连接,而且发给UI之后才会关闭连接
singleBroadcast(session,gson.toJson(messageDTO));
}else if(whatID==2 && idDTO.getIdValues()!=null) {
//获取blockId的值
int idValue = idDTO.getIdValues().get(0);
String blockID = String.valueOf(idValue);
//通过blockId获取对应的Session
Session s = sMap.get(blockID);
//然后单播给communityId下的每一个blockId
if(s!=null) {
singleBroadcast(s,gson.toJson(messageDTO));
}
singleBroadcast(session,gson.toJson(messageDTO));
}else if(whatID==3 && messageDTO.getBlockIdValue()!=null) {
//如果是楼层,则先需要查询是哪栋楼
int blockIdValue = messageDTO.getBlockIdValue();
String blockID = String.valueOf(blockIdValue);
//通过blockId获取对应的Session
Session s = sMap.get(blockID);
//然后单播给communityId下的每一个blockId
if(s!=null) {
singleBroadcast(s,gson.toJson(messageDTO));
}
singleBroadcast(session,gson.toJson(messageDTO));
}else if(whatID==4 && messageDTO.getBlockIdValue()!=null) {
//如果是控制灯的,则需要知道是哪栋楼,这个是从页面就可以获取的,不需要再查数据库
int blockIdValue = messageDTO.getBlockIdValue();
String blockID = String.valueOf(blockIdValue);
//通过blockId获取对应的Session
Session s = sMap.get(blockID);
//然后单播给communityId下的每一个blockId
if(s!=null) {
singleBroadcast(s,gson.toJson(messageDTO));
}
singleBroadcast(session,gson.toJson(messageDTO));
}
}
}
/**
* 如果是refresh功能,就用这个方法单播发送
* @param messageDTO
* @param session
*/
public void sendRefreshMessage(MessageDTO messageDTO,Session session) {
List<IDDTO> idDTOList = messageDTO.getIdArr();
if(idDTOList!=null && idDTOList.size()>0) {
IDDTO idDTO = idDTOList.get(0);
Integer whatID = idDTO.getWhatId();
//我们现在只有floor这里才有refresh,所以这里现在是whatId是3,以后就不一定,根据需求修改
if(whatID==3 && messageDTO.getBlockIdValue()!=null) {
//如果是楼层,则先需要查询是哪栋楼
int blockIdValue = messageDTO.getBlockIdValue();
String blockID = String.valueOf(blockIdValue);
//通过blockId获取对应的Session
Session s = sMap.get(blockID);
//然后单播给communityId下的每一个blockId
if(s!=null) {
singleBroadcast(s,gson.toJson(messageDTO));
}
singleBroadcast(session,gson.toJson(messageDTO));
}
}
}
/**
* 封装发送短信和邮件的方法
* @param messageDTO
*/
public void sendMobileAndEmail(MessageDTO messageDTO) {
//获取lightId
List<Integer> idValues = messageDTO.getLightId();
List<Integer> arrValues = messageDTO.getArrValues();
if(idValues!=null && arrValues!=null) {
//这个数组中只有一个lightId,其实定义成int是最好的
Integer idValue = idValues.get(0);
String lightId = String.valueOf(idValue);
//通过lightId查询出CommunityName,BlockName,FloorName,LightName
StringBuilder content = new StringBuilder();
AlarmDTO alarmNames = communityDetailService.selectAlarmNamesByLightId(lightId);
if(alarmNames!=null) {
String communityName = alarmNames.getCommunityName();
if(communityName!=null) {
content.append(communityName);
content.append("-");
}
String blockName = alarmNames.getBlockName();
if(blockName!=null) {
content.append(blockName);
content.append("-");
}
String floorName = alarmNames.getFloorName();
if(floorName!=null) {
content.append(floorName);
content.append("-");
}
String lightName = alarmNames.getLightName();
if(lightName!=null) {
content.append(lightName);
}
}
content.append(" occurs ");
if(arrValues.contains(0)) {
content.append("OVP,");
}
if(arrValues.contains(1)) {
content.append("OCP,");
}
if(arrValues.contains(2)) {
content.append("PER,");
}
if(arrValues.contains(3)) {
content.append("DCO,");
}
content.append(" this message is from Aztech!");
String message = content.toString();
//String mobile = "6598373212";
if(alarmNames.getBlockId()!=null) {
String blockId = alarmNames.getBlockId();
//通过blockId可以获取该灯是属于哪栋楼哪个用户的,从而可以得到该用户的手机号码和邮箱地址
UserAccount user = communityDetailService.getPhoneNumberAndEmailByBlockId(blockId);
if(user!=null) {
String mobile = user.getUserPhoneNumber();
String email = user.getUserMailAddress();
//调用发短信的方法
communityDetailService.postNormalMessage(message,mobile);
//调用发邮件的方法
String title = "This is a alarm message from Aztech!";
communityDetailService.sendEmail(email, title, message);
}
}
}
}
/**
* 获取UI界面的参数并封装到一个新的对象中
* @param messageDTO
* @return
*/
public MessageDTO getNewMainConfigMessageDTO(MessageDTO messageDTO) {
MessageDTO msgDTO = new MessageDTO();
Long eventId = messageDTO.getEventId();
Integer messageCode = messageDTO.getMessageCode();
Integer pir = messageDTO.getPir();
Integer dimLvl = messageDTO.getDimLvl();
Integer holdTime = messageDTO.getHoldTime();
Integer pirSen = messageDTO.getPirSen();
Integer photoLvl = messageDTO.getPhotoLvl();
Integer rtc = messageDTO.getRtc();
Integer wm = messageDTO.getWm();
Integer sm = messageDTO.getSm();
String wt = messageDTO.getWt();
String st = messageDTO.getSt();
Integer userId = messageDTO.getUserId();
Integer count = messageDTO.getCount();
Integer deviceTime = messageDTO.getDeviceTime();
Integer lightIntensity = messageDTO.getLightIntensity();
msgDTO.setEventId(eventId);
msgDTO.setMessageCode(messageCode);
msgDTO.setPir(pir);
msgDTO.setDimLvl(dimLvl);
msgDTO.setHoldTime(holdTime);
msgDTO.setPirSen(pirSen);
msgDTO.setPhotoLvl(photoLvl);
msgDTO.setRtc(rtc);
msgDTO.setWm(wm);
msgDTO.setSm(sm);
msgDTO.setWt(wt);
msgDTO.setSt(st);
msgDTO.setUserId(userId);
msgDTO.setCount(count);
msgDTO.setDeviceTime(deviceTime);
msgDTO.setLightIntensity(lightIntensity);
return msgDTO;
}
/**
* 获取UI界面SPS200的参数并封装到一个新的对象中
* @param messageDTO
* @return
*/
public MessageDTO getNewSPS200ConfigMessageDTO(MessageDTO messageDTO) {
MessageDTO msgDTO = new MessageDTO();
Long eventId = messageDTO.getEventId();
Integer messageCode = messageDTO.getMessageCode();
Integer pir = messageDTO.getPir();
Integer dimLvl = messageDTO.getDimLvl();
Integer rtc = messageDTO.getRtc();
Integer wm = messageDTO.getWm();
Integer sm = messageDTO.getSm();
String wt = messageDTO.getWt();
String st = messageDTO.getSt();
Integer userId = messageDTO.getUserId();
Integer count = messageDTO.getCount();
Integer deviceTime = messageDTO.getDeviceTime();
Integer lightIntensity = messageDTO.getLightIntensity();
msgDTO.setEventId(eventId);
msgDTO.setMessageCode(messageCode);
msgDTO.setPir(pir);
msgDTO.setDimLvl(dimLvl);
msgDTO.setRtc(rtc);
msgDTO.setWm(wm);
msgDTO.setSm(sm);
msgDTO.setWt(wt);
msgDTO.setSt(st);
msgDTO.setUserId(userId);
msgDTO.setCount(count);
msgDTO.setDeviceTime(deviceTime);
msgDTO.setLightIntensity(lightIntensity);
return msgDTO;
}
/**
* 封装Photo界面配置参数到一个新对象
* @param messageDTO
* @return
*/
public MessageDTO getNewPhotoConfigMessageDTO(MessageDTO messageDTO) {
MessageDTO msgDTO = new MessageDTO();
Long eventId = messageDTO.getEventId();
Integer messageCode = messageDTO.getMessageCode();
List<IDDTO> jsonId = messageDTO.getJsonId();
Integer photo = messageDTO.getPhoto();
Integer dt = messageDTO.getDt();
Integer bt = messageDTO.getBt();
Integer userId = messageDTO.getUserId();
Integer count = messageDTO.getCount();
msgDTO.setEventId(eventId);
msgDTO.setMessageCode(messageCode);
msgDTO.setJsonId(jsonId);
msgDTO.setPhoto(photo);
msgDTO.setDt(dt);
msgDTO.setBt(bt);
msgDTO.setUserId(userId);
msgDTO.setCount(count);
return msgDTO;
}
/**
* 发送Main Config信息的方法
* @param messageDTO
*/
public void sendMainConfigMessage(MessageDTO messageDTO,Session session) {
//jsonId是一个json对象,
List<IDDTO> list = messageDTO.getJsonId();
if(list!=null && list.size()>0) {
//定义一个map
Map<String,List<IDDTO>> blockMap = new HashMap<String,List<IDDTO>>();
//下面先循环组装数据,组装之后才能统计次数
for(IDDTO idDTO: list) {
Integer whatId = idDTO.getWhatId();
Integer idValue = idDTO.getIdValue();
if(whatId!=null && idValue!=null) {
if(whatId==1) {
//如果whatId为1,说明是communityId
String communityId = String.valueOf(idValue);
//通过communityId查询该小区下的所有的block
List<String> blockIdList = communityDetailService.selectBlockIdListByCommunityId(communityId);
if(blockIdList!=null) {
for(String blockID: blockIdList) {
List<IDDTO> tempList = blockMap.get(blockID);
if(tempList!=null) {
//获取tempList里面的所有的whatId值,放入一个集合中
List<Integer> whatIdList = new ArrayList<Integer>();
for(IDDTO tempDTO: tempList) {
Integer wId = tempDTO.getWhatId();
whatIdList.add(wId);
}
//判断idValues中是否已经有wId=3的对象
if(whatIdList.contains(2)) {
for(IDDTO tempDTO: tempList) {
if(tempDTO.getWhatId()!=null && tempDTO.getWhatId()==2) {
//这里的idValues存储是blockID的值,不是idValue(communityId)
tempDTO.getIdValues().add(Integer.valueOf(blockID));
}
}
}else {
//如果没有包含floor类型的id,就直接添加到idValues数组(集合中)
IDDTO dto = new IDDTO();
List<Integer> idValues = new ArrayList<Integer>();
Integer idVal = Integer.valueOf(blockID);
idValues.add(idVal);
//这里传入的是2,因为这里whatId值是1
dto.setWhatId(2);
dto.setIdValues(idValues);
tempList.add(dto);
}
blockMap.put(blockID, tempList);
}else {
List<IDDTO> idArr = new ArrayList<IDDTO>();
IDDTO dto = new IDDTO();
List<Integer> idValues = new ArrayList<Integer>();
Integer idVal = Integer.valueOf(blockID);
//因为当前是community做判断的,所以这里不能直接传入whatID
dto.setWhatId(2);
idValues.add(idVal);
dto.setIdValues(idValues);
idArr.add(dto);
blockMap.put(blockID, idArr);
}
}
}
}else if(whatId==2) {
//如果whatId为2,说明是blockId
String blockID = String.valueOf(idValue);
List<IDDTO> tempList = blockMap.get(blockID);
if(tempList!=null) {
//获取tempList里面的所有的whatId值,放入一个集合中
List<Integer> whatIdList = new ArrayList<Integer>();
for(IDDTO tempDTO: tempList) {
Integer wId = tempDTO.getWhatId();
whatIdList.add(wId);
}
//判断idValues中是否已经有wId=3的对象
if(whatIdList.contains(2)) {
for(IDDTO tempDTO: tempList) {
if(tempDTO.getWhatId()!=null && tempDTO.getWhatId()==2) {
tempDTO.getIdValues().add(idValue);
}
}
}else {
//如果没有包含floor类型的id,就直接添加到idValues数组(集合中)
IDDTO dto = new IDDTO();
List<Integer> idValues = new ArrayList<Integer>();
idValues.add(idValue);
dto.setWhatId(whatId);
dto.setIdValues(idValues);
tempList.add(dto);
}
blockMap.put(blockID, tempList);
}else {
List<IDDTO> idArr = new ArrayList<IDDTO>();
IDDTO dto = new IDDTO();
List<Integer> idValues = new ArrayList<Integer>();
idValues.add(idValue);
dto.setWhatId(whatId);
dto.setIdValues(idValues);
idArr.add(dto);
blockMap.put(blockID, idArr);
}
}else if(whatId==3) {
//如果whatId为3,说明是floorId
//通过floorId查询是属于对应的blockID
Integer bId = communityDetailService.selectBlockIdByFloorId(idValue);
String blockID = String.valueOf(bId);
List<IDDTO> tempList = blockMap.get(blockID);
if(tempList!=null) {
//获取tempList里面的所有的whatId值,放入一个集合中
List<Integer> whatIdList = new ArrayList<Integer>();
for(IDDTO tempDTO: tempList) {
Integer wId = tempDTO.getWhatId();
whatIdList.add(wId);
}
//判断idValues中是否已经有wId=3的对象
if(whatIdList.contains(3)) {
for(IDDTO tempDTO: tempList) {
if(tempDTO.getWhatId()!=null && tempDTO.getWhatId()==3) {
tempDTO.getIdValues().add(idValue);
}
}
}else {
//如果没有包含floor类型的id,就直接添加到idValues数组(集合中)
IDDTO dto = new IDDTO();
List<Integer> idValues = new ArrayList<Integer>();
idValues.add(idValue);
dto.setWhatId(whatId);
dto.setIdValues(idValues);
tempList.add(dto);
}
blockMap.put(blockID, tempList);
}else {
//如果当前这个blockID的idValues为空,就直接新建一个添加即可
List<IDDTO> idArr = new ArrayList<IDDTO>();
IDDTO dto = new IDDTO();
List<Integer> idValues = new ArrayList<Integer>();
idValues.add(idValue);
dto.setWhatId(whatId);
dto.setIdValues(idValues);
idArr.add(dto);
blockMap.put(blockID, idArr);
}
}else if(whatId==4) {
//如果whatId为4,说明是lightId
//通过lightId查询对应的blockId
Integer bId = communityDetailService.selectBlockIdByLightId(idValue);
String blockID = String.valueOf(bId);
List<IDDTO> tempList = blockMap.get(blockID);
if(tempList!=null) {
//获取tempList里面的所有的whatId值,放入一个集合中
List<Integer> whatIdList = new ArrayList<Integer>();
for(IDDTO tempDTO: tempList) {
Integer wId = tempDTO.getWhatId();
whatIdList.add(wId);
}
//判断idValues中是否已经有wId=3的对象
if(whatIdList.contains(4)) {
for(IDDTO tempDTO: tempList) {
if(tempDTO.getWhatId()==4) {
tempDTO.getIdValues().add(idValue);
}
}
}else {
//如果没有包含floor类型的id,就直接添加到idValues数组(集合中)
IDDTO dto = new IDDTO();
List<Integer> idValues = new ArrayList<Integer>();
idValues.add(idValue);
dto.setWhatId(whatId);
dto.setIdValues(idValues);
tempList.add(dto);
}
blockMap.put(blockID, tempList);
}else {
List<IDDTO> idArr = new ArrayList<IDDTO>();
IDDTO dto = new IDDTO();
List<Integer> idValues = new ArrayList<Integer>();
idValues.add(idValue);
dto.setWhatId(whatId);
dto.setIdValues(idValues);
idArr.add(dto);
blockMap.put(blockID, idArr);
}
}
}
}
//这里已经全部循环完毕,然后可以获取不是以block或者community为单位的数据
//这里可以获取block的长度,然后传回给UI,但是这里要和连接上的blockId数组进行比对,因为没有连接的是不可能发出去的,容易导致前端无止境的等待
//通过blockId获取对应的Session
Set<String> set = blockMap.keySet();
//这里要有一个计时器count,发送之后要传入到前端判断是不是全部响应回来
int count = 0;
for(String blockID: set) {
Session s = sMap.get(blockID);
//然后单播给communityId下的每一个blockId
if(s!=null) {
//如果Session连接存在的blockId就+1
count++;
}
}
System.out.println("count:" + count);
//通知UI客户端总共需要等待几次,到时候统计次数和eventId的次数一次就停止
messageDTO.setCount(count);
//这个时候数据已经组装完成,可以带一个标识告诉UI界面
messageDTO.setFlag(1);
singleBroadcast(session,gson.toJson(messageDTO));
//下面遍历map集合,获取每个block下的
//Integer[] idArray = {1,2,115,116};
//int i = 0;
for(String blockID:set) {
MessageDTO newMessageDTO = getNewMainConfigMessageDTO(messageDTO);
List<IDDTO> idArr = blockMap.get(blockID);
newMessageDTO.setIdArr(idArr);
//通过blockId获取对应的Session
Session s = sMap.get(blockID);
//然后单播给communityId下的每一个blockId
if(s!=null) {
singleBroadcast(s,gson.toJson(newMessageDTO));
}
//这里只是测试用的(==================================生产环境要注释一下,这里只是用来测试模拟反馈的====================================================================)
//newMessageDTO.setMessageCode(100);
//封装一个临时数据用来测试
//List<Integer> ids = new ArrayList<Integer>();
//ids.add(idArray[i]);
//i++;
//ids.add(idArray[i]);
//i++;
//通过ids可以获取lightId,lightName,floorName,blockName,CommunityName
//List<InfoDTO> infoList = new ArrayList<InfoDTO>();
//for(Integer lightId: ids){
//InfoDTO info = communityDetailService.selectAllInfoByLightId(lightId);
//infoList.add(info);
//}
//newMessageDTO.setLightId(ids);
//newMessageDTO.setInfoList(infoList);
//因为有可能count为0,就是C程序没有连,如果为0,这个时候其实UI已经把连接给关闭了
if(count!=0) {
singleBroadcast(session,gson.toJson(newMessageDTO));
}
}
//2代表发送完毕,但是不代表处理成功
//messageDTO.setFlag(2);
//因为count为0,session其实已经被UI代码给关闭了
//System.out.println(session);
//System.out.println(session.getId());
//这下面的不知道是不是可以保留,因为如果C程序已经返回其实UI连接已经断开,这个就发布出去了,但是理论上不可能
//毕竟C程序接收,处理,反馈是需要时间的,所以还是先保留
//if(count!=0) {
//开发环境可以先注释(这里真的很犹豫,因为界面上不知道有没有必要提示数据已经发送给每个block)
//singleBroadcast(session,gson.toJson(messageDTO));
//}
}
}
/**
* C程序处理MainConfig返回给UI客户端界面的反馈方法
* @param messageDTO
* @param session
*/
public void sendMainConfigFeedbackMessage(MessageDTO messageDTO,Session session) {
List<Integer> ids = messageDTO.getLightId();
//通过ids可以获取lightId,lightName,floorName,blockName,CommunityName
List<InfoDTO> infoList = new ArrayList<InfoDTO>();
if(ids!=null && ids.size()>0) {
for(Integer lightId: ids){
InfoDTO info = communityDetailService.selectAllInfoByLightId(lightId);
infoList.add(info);
}
messageDTO.setInfoList(infoList);
}
//获取所有连接上websocket的UI连接,因为UI连接的blockId都是以aztech开头的
Set<String> blockIdList = sMap.keySet();
if(blockIdList!=null && blockIdList.size()>0) {
//循环遍历blockIdList
for(String blockId: blockIdList) {
//判断是不是aztech连接
if(blockId.startsWith("AZTECH")) {
//通过blockId获取Session连接
Session s = sMap.get(blockId);
if(s!=null) {
singleBroadcast(s,gson.toJson(messageDTO));
}
}
}
}
}
/**
* C程序处理SPS200 Config返回给UI客户端界面的反馈方法
* @param messageDTO
* @param session
*/
public void sendSPS200ConfigFeedbackMessage(MessageDTO messageDTO,Session session) {
List<Integer> ids = messageDTO.getLightId();
//通过ids可以获取lightId,lightName,floorName,blockName,CommunityName
List<InfoDTO> infoList = new ArrayList<InfoDTO>();
if(ids!=null && ids.size()>0) {
for(Integer lightId: ids){
InfoDTO info = communityDetailService.selectAllInfoByLightId(lightId);
infoList.add(info);
}
messageDTO.setInfoList(infoList);
}
//获取所有连接上websocket的UI连接,因为UI连接的blockId都是以aztech开头的
Set<String> blockIdList = sMap.keySet();
if(blockIdList!=null && blockIdList.size()>0) {
//循环遍历blockIdList
for(String blockId: blockIdList) {
//判断是不是aztech连接
if(blockId.startsWith("AZTECH")) {
//通过blockId获取Session连接
Session s = sMap.get(blockId);
if(s!=null) {
singleBroadcast(s,gson.toJson(messageDTO));
}
}
}
}
}
/**
* C程序返回给Photo的反馈
* @param messageDTO
* @param session
*/
public void sendPhotoConfigFeedbackMessage(MessageDTO messageDTO,Session session) {
List<Integer> ids = messageDTO.getLightId();
//通过ids可以获取lightId,lightName,floorName,blockName,CommunityName
List<InfoDTO> infoList = new ArrayList<InfoDTO>();
if(ids!=null && ids.size()>0) {
for(Integer lightId: ids){
InfoDTO info = communityDetailService.selectAllInfoByLightId(lightId);
infoList.add(info);
}
messageDTO.setInfoList(infoList);
}
//获取所有连接上websocket的UI连接,因为UI连接的blockId都是以aztech开头的
Set<String> blockIdList = sMap.keySet();
if(blockIdList!=null && blockIdList.size()>0) {
//循环遍历blockIdList
for(String blockId: blockIdList) {
//判断是不是aztech连接
if(blockId.startsWith("AZTECH")) {
//通过blockId获取Session连接
Session s = sMap.get(blockId);
if(s!=null) {
singleBroadcast(s,gson.toJson(messageDTO));
}
}
}
}
}
/**
* 发送Photo配置的方法
* @param messageDTO
* @param session
*/
public void sendPhotoConfigMessage(MessageDTO messageDTO,Session session) {
//jsonId是一个json对象,
List<IDDTO> list = messageDTO.getJsonId();
if(list!=null && list.size()>0) {
//定义一个map
Map<String,List<IDDTO>> blockMap = new HashMap<String,List<IDDTO>>();
//下面先循环组装数据,组装之后才能统计次数
for(IDDTO idDTO: list) {
Integer whatId = idDTO.getWhatId();
Integer idValue = idDTO.getIdValue();
if(whatId!=null && idValue!=null) {
if(whatId==1) {
//如果whatId为1,说明是communityId
String communityId = String.valueOf(idValue);
//通过communityId查询该小区下的所有的block
List<String> blockIdList = communityDetailService.selectBlockIdListByCommunityId(communityId);
if(blockIdList!=null) {
for(String blockID: blockIdList) {
List<IDDTO> tempList = blockMap.get(blockID);
if(tempList!=null) {
//获取tempList里面的所有的whatId值,放入一个集合中
List<Integer> whatIdList = new ArrayList<Integer>();
for(IDDTO tempDTO: tempList) {
Integer wId = tempDTO.getWhatId();
whatIdList.add(wId);
}
//判断idValues中是否已经有wId=3的对象
if(whatIdList.contains(2)) {
for(IDDTO tempDTO: tempList) {
if(tempDTO.getWhatId()!=null && tempDTO.getWhatId()==2) {
//这里的idValues存储是blockID的值,不是idValue(communityId)
tempDTO.getIdValues().add(Integer.valueOf(blockID));
}
}
}else {
//如果没有包含floor类型的id,就直接添加到idValues数组(集合中)
IDDTO dto = new IDDTO();
List<Integer> idValues = new ArrayList<Integer>();
Integer idVal = Integer.valueOf(blockID);
idValues.add(idVal);
//这里传入的是2,因为这里whatId值是1
dto.setWhatId(2);
dto.setIdValues(idValues);
tempList.add(dto);
}
blockMap.put(blockID, tempList);
}else {
List<IDDTO> idArr = new ArrayList<IDDTO>();
IDDTO dto = new IDDTO();
List<Integer> idValues = new ArrayList<Integer>();
Integer idVal = Integer.valueOf(blockID);
//因为当前是community做判断的,所以这里不能直接传入whatID
dto.setWhatId(2);
idValues.add(idVal);
dto.setIdValues(idValues);
idArr.add(dto);
blockMap.put(blockID, idArr);
}
}
}
}else if(whatId==2) {
//如果whatId为2,说明是blockId
String blockID = String.valueOf(idValue);
List<IDDTO> tempList = blockMap.get(blockID);
if(tempList!=null) {
//获取tempList里面的所有的whatId值,放入一个集合中
List<Integer> whatIdList = new ArrayList<Integer>();
for(IDDTO tempDTO: tempList) {
Integer wId = tempDTO.getWhatId();
whatIdList.add(wId);
}
//判断idValues中是否已经有wId=3的对象
if(whatIdList.contains(2)) {
for(IDDTO tempDTO: tempList) {
if(tempDTO.getWhatId()!=null && tempDTO.getWhatId()==2) {
tempDTO.getIdValues().add(idValue);
}
}
}else {
//如果没有包含floor类型的id,就直接添加到idValues数组(集合中)
IDDTO dto = new IDDTO();
List<Integer> idValues = new ArrayList<Integer>();
idValues.add(idValue);
dto.setWhatId(whatId);
dto.setIdValues(idValues);
tempList.add(dto);
}
blockMap.put(blockID, tempList);
}else {
List<IDDTO> idArr = new ArrayList<IDDTO>();
IDDTO dto = new IDDTO();
List<Integer> idValues = new ArrayList<Integer>();
idValues.add(idValue);
dto.setWhatId(whatId);
dto.setIdValues(idValues);
idArr.add(dto);
blockMap.put(blockID, idArr);
}
}else if(whatId==3) {
//如果whatId为3,说明是floorId
//通过floorId查询是属于对应的blockID
Integer bId = communityDetailService.selectBlockIdByFloorId(idValue);
String blockID = String.valueOf(bId);
List<IDDTO> tempList = blockMap.get(blockID);
if(tempList!=null) {
//获取tempList里面的所有的whatId值,放入一个集合中
List<Integer> whatIdList = new ArrayList<Integer>();
for(IDDTO tempDTO: tempList) {
Integer wId = tempDTO.getWhatId();
whatIdList.add(wId);
}
//判断idValues中是否已经有wId=3的对象
if(whatIdList.contains(3)) {
for(IDDTO tempDTO: tempList) {
if(tempDTO.getWhatId()!=null && tempDTO.getWhatId()==3) {
tempDTO.getIdValues().add(idValue);
}
}
}else {
//如果没有包含floor类型的id,就直接添加到idValues数组(集合中)
IDDTO dto = new IDDTO();
List<Integer> idValues = new ArrayList<Integer>();
idValues.add(idValue);
dto.setWhatId(whatId);
dto.setIdValues(idValues);
tempList.add(dto);
}
blockMap.put(blockID, tempList);
}else {
//如果当前这个blockID的idValues为空,就直接新建一个添加即可
List<IDDTO> idArr = new ArrayList<IDDTO>();
IDDTO dto = new IDDTO();
List<Integer> idValues = new ArrayList<Integer>();
idValues.add(idValue);
dto.setWhatId(whatId);
dto.setIdValues(idValues);
idArr.add(dto);
blockMap.put(blockID, idArr);
}
}else if(whatId==4) {
//如果whatId为4,说明是lightId
//通过lightId查询对应的blockId
Integer bId = communityDetailService.selectBlockIdByLightId(idValue);
String blockID = String.valueOf(bId);
List<IDDTO> tempList = blockMap.get(blockID);
if(tempList!=null) {
//获取tempList里面的所有的whatId值,放入一个集合中
List<Integer> whatIdList = new ArrayList<Integer>();
for(IDDTO tempDTO: tempList) {
Integer wId = tempDTO.getWhatId();
whatIdList.add(wId);
}
//判断idValues中是否已经有wId=3的对象
if(whatIdList.contains(4)) {
for(IDDTO tempDTO: tempList) {
if(tempDTO.getWhatId()==4) {
tempDTO.getIdValues().add(idValue);
}
}
}else {
//如果没有包含floor类型的id,就直接添加到idValues数组(集合中)
IDDTO dto = new IDDTO();
List<Integer> idValues = new ArrayList<Integer>();
idValues.add(idValue);
dto.setWhatId(whatId);
dto.setIdValues(idValues);
tempList.add(dto);
}
blockMap.put(blockID, tempList);
}else {
List<IDDTO> idArr = new ArrayList<IDDTO>();
IDDTO dto = new IDDTO();
List<Integer> idValues = new ArrayList<Integer>();
idValues.add(idValue);
dto.setWhatId(whatId);
dto.setIdValues(idValues);
idArr.add(dto);
blockMap.put(blockID, idArr);
}
}
}
}
//这里已经全部循环完毕,然后可以获取不是以block或者community为单位的数据
//这里可以获取block的长度,然后传回给UI,但是这里要和连接上的blockId数组进行比对,因为没有连接的是不可能发出去的,容易导致前端无止境的等待
//通过blockId获取对应的Session
Set<String> set = blockMap.keySet();
//这里要有一个计时器count,发送之后要传入到前端判断是不是全部响应回来
int count = 0;
for(String blockID: set) {
Session s = sMap.get(blockID);
//然后单播给communityId下的每一个blockId
if(s!=null) {
//如果Session连接存在的blockId就+1
count++;
}
}
System.out.println("count:" + count);
//通知UI客户端总共需要等待几次,到时候统计次数和eventId的次数一次就停止
messageDTO.setCount(count);
//这个时候数据已经组装完成,可以带一个标识告诉UI界面
messageDTO.setFlag(1);
singleBroadcast(session,gson.toJson(messageDTO));
//下面遍历map集合,获取每个block下的
Integer[] idArray = {1,2,115,116};
int i = 0;
for(String blockID:set) {
MessageDTO newMessageDTO = getNewPhotoConfigMessageDTO(messageDTO);
List<IDDTO> idArr = blockMap.get(blockID);
newMessageDTO.setIdArr(idArr);
//通过blockId获取对应的Session
Session s = sMap.get(blockID);
//然后单播给communityId下的每一个blockId
if(s!=null) {
singleBroadcast(s,gson.toJson(newMessageDTO));
}
//这里只是测试用的(==================================生产环境要注释一下,这里只是用来测试模拟反馈的====================================================================)
//newMessageDTO.setMessageCode(101);
//封装一个临时数据用来测试
List<Integer> ids = new ArrayList<Integer>();
ids.add(idArray[i]);
i++;
ids.add(idArray[i]);
i++;
//通过ids可以获取lightId,lightName,floorName,blockName,CommunityName
List<InfoDTO> infoList = new ArrayList<InfoDTO>();
for(Integer lightId: ids){
InfoDTO info = communityDetailService.selectAllInfoByLightId(lightId);
infoList.add(info);
}
//newMessageDTO.setLightId(ids);
//newMessageDTO.setInfoList(infoList);
//因为有可能count为0,就是C程序没有连,如果为0,这个时候其实UI已经把连接给关闭了
if(count!=0) {
singleBroadcast(session,gson.toJson(newMessageDTO));
}
}
}
}
/**
* 发送SPS200 Config信息的方法
* @param messageDTO
*/
public void sendSPS200ConfigMessage(MessageDTO messageDTO,Session session) {
//jsonId是一个json对象,
List<IDDTO> list = messageDTO.getJsonId();
if(list!=null && list.size()>0) {
//定义一个map
Map<String,List<IDDTO>> blockMap = new HashMap<String,List<IDDTO>>();
//下面先循环组装数据,组装之后才能统计次数
for(IDDTO idDTO: list) {
Integer whatId = idDTO.getWhatId();
Integer idValue = idDTO.getIdValue();
if(whatId!=null && idValue!=null) {
if(whatId==1) {
//如果whatId为1,说明是communityId
String communityId = String.valueOf(idValue);
//通过communityId查询该小区下的所有的block
List<String> blockIdList = communityDetailService.selectBlockIdListByCommunityId(communityId);
if(blockIdList!=null) {
for(String blockID: blockIdList) {
List<IDDTO> tempList = blockMap.get(blockID);
if(tempList!=null) {
//获取tempList里面的所有的whatId值,放入一个集合中
List<Integer> whatIdList = new ArrayList<Integer>();
for(IDDTO tempDTO: tempList) {
Integer wId = tempDTO.getWhatId();
whatIdList.add(wId);
}
//判断idValues中是否已经有wId=3的对象
if(whatIdList.contains(2)) {
for(IDDTO tempDTO: tempList) {
if(tempDTO.getWhatId()!=null && tempDTO.getWhatId()==2) {
//这里的idValues存储是blockID的值,不是idValue(communityId)
tempDTO.getIdValues().add(Integer.valueOf(blockID));
}
}
}else {
//如果没有包含floor类型的id,就直接添加到idValues数组(集合中)
IDDTO dto = new IDDTO();
List<Integer> idValues = new ArrayList<Integer>();
Integer idVal = Integer.valueOf(blockID);
idValues.add(idVal);
//这里传入的是2,因为这里whatId值是1
dto.setWhatId(2);
dto.setIdValues(idValues);
tempList.add(dto);
}
blockMap.put(blockID, tempList);
}else {
List<IDDTO> idArr = new ArrayList<IDDTO>();
IDDTO dto = new IDDTO();
List<Integer> idValues = new ArrayList<Integer>();
Integer idVal = Integer.valueOf(blockID);
//因为当前是community做判断的,所以这里不能直接传入whatID
dto.setWhatId(2);
idValues.add(idVal);
dto.setIdValues(idValues);
idArr.add(dto);
blockMap.put(blockID, idArr);
}
}
}
}else if(whatId==2) {
//如果whatId为2,说明是blockId
String blockID = String.valueOf(idValue);
List<IDDTO> tempList = blockMap.get(blockID);
if(tempList!=null) {
//获取tempList里面的所有的whatId值,放入一个集合中
List<Integer> whatIdList = new ArrayList<Integer>();
for(IDDTO tempDTO: tempList) {
Integer wId = tempDTO.getWhatId();
whatIdList.add(wId);
}
//判断idValues中是否已经有wId=3的对象
if(whatIdList.contains(2)) {
for(IDDTO tempDTO: tempList) {
if(tempDTO.getWhatId()!=null && tempDTO.getWhatId()==2) {
tempDTO.getIdValues().add(idValue);
}
}
}else {
//如果没有包含floor类型的id,就直接添加到idValues数组(集合中)
IDDTO dto = new IDDTO();
List<Integer> idValues = new ArrayList<Integer>();
idValues.add(idValue);
dto.setWhatId(whatId);
dto.setIdValues(idValues);
tempList.add(dto);
}
blockMap.put(blockID, tempList);
}else {
List<IDDTO> idArr = new ArrayList<IDDTO>();
IDDTO dto = new IDDTO();
List<Integer> idValues = new ArrayList<Integer>();
idValues.add(idValue);
dto.setWhatId(whatId);
dto.setIdValues(idValues);
idArr.add(dto);
blockMap.put(blockID, idArr);
}
}else if(whatId==3) {
//如果whatId为3,说明是floorId
//通过floorId查询是属于对应的blockID
Integer bId = communityDetailService.selectBlockIdByFloorId(idValue);
String blockID = String.valueOf(bId);
List<IDDTO> tempList = blockMap.get(blockID);
if(tempList!=null) {
//获取tempList里面的所有的whatId值,放入一个集合中
List<Integer> whatIdList = new ArrayList<Integer>();
for(IDDTO tempDTO: tempList) {
Integer wId = tempDTO.getWhatId();
whatIdList.add(wId);
}
//判断idValues中是否已经有wId=3的对象
if(whatIdList.contains(3)) {
for(IDDTO tempDTO: tempList) {
if(tempDTO.getWhatId()!=null && tempDTO.getWhatId()==3) {
tempDTO.getIdValues().add(idValue);
}
}
}else {
//如果没有包含floor类型的id,就直接添加到idValues数组(集合中)
IDDTO dto = new IDDTO();
List<Integer> idValues = new ArrayList<Integer>();
idValues.add(idValue);
dto.setWhatId(whatId);
dto.setIdValues(idValues);
tempList.add(dto);
}
blockMap.put(blockID, tempList);
}else {
//如果当前这个blockID的idValues为空,就直接新建一个添加即可
List<IDDTO> idArr = new ArrayList<IDDTO>();
IDDTO dto = new IDDTO();
List<Integer> idValues = new ArrayList<Integer>();
idValues.add(idValue);
dto.setWhatId(whatId);
dto.setIdValues(idValues);
idArr.add(dto);
blockMap.put(blockID, idArr);
}
}else if(whatId==4) {
//如果whatId为4,说明是lightId
//通过lightId查询对应的blockId
Integer bId = communityDetailService.selectBlockIdByLightId(idValue);
String blockID = String.valueOf(bId);
List<IDDTO> tempList = blockMap.get(blockID);
if(tempList!=null) {
//获取tempList里面的所有的whatId值,放入一个集合中
List<Integer> whatIdList = new ArrayList<Integer>();
for(IDDTO tempDTO: tempList) {
Integer wId = tempDTO.getWhatId();
whatIdList.add(wId);
}
//判断idValues中是否已经有wId=3的对象
if(whatIdList.contains(4)) {
for(IDDTO tempDTO: tempList) {
if(tempDTO.getWhatId()==4) {
tempDTO.getIdValues().add(idValue);
}
}
}else {
//如果没有包含floor类型的id,就直接添加到idValues数组(集合中)
IDDTO dto = new IDDTO();
List<Integer> idValues = new ArrayList<Integer>();
idValues.add(idValue);
dto.setWhatId(whatId);
dto.setIdValues(idValues);
tempList.add(dto);
}
blockMap.put(blockID, tempList);
}else {
List<IDDTO> idArr = new ArrayList<IDDTO>();
IDDTO dto = new IDDTO();
List<Integer> idValues = new ArrayList<Integer>();
idValues.add(idValue);
dto.setWhatId(whatId);
dto.setIdValues(idValues);
idArr.add(dto);
blockMap.put(blockID, idArr);
}
}
}
}
//这里已经全部循环完毕,然后可以获取不是以block或者community为单位的数据
//这里可以获取block的长度,然后传回给UI,但是这里要和连接上的blockId数组进行比对,因为没有连接的是不可能发出去的,容易导致前端无止境的等待
//通过blockId获取对应的Session
Set<String> set = blockMap.keySet();
//这里要有一个计时器count,发送之后要传入到前端判断是不是全部响应回来
int count = 0;
for(String blockID: set) {
Session s = sMap.get(blockID);
//然后单播给communityId下的每一个blockId
if(s!=null) {
//如果Session连接存在的blockId就+1
count++;
}
}
System.out.println("count:" + count);
//通知UI客户端总共需要等待几次,到时候统计次数和eventId的次数一次就停止
messageDTO.setCount(count);
//这个时候数据已经组装完成,可以带一个标识告诉UI界面
messageDTO.setFlag(1);
singleBroadcast(session,gson.toJson(messageDTO));
//下面遍历map集合,获取每个block下的
Integer[] idArray = {1,2,115,116};
int i = 0;
for(String blockID:set) {
MessageDTO newMessageDTO = getNewSPS200ConfigMessageDTO(messageDTO);
List<IDDTO> idArr = blockMap.get(blockID);
newMessageDTO.setIdArr(idArr);
//通过blockId获取对应的Session
Session s = sMap.get(blockID);
//然后单播给communityId下的每一个blockId
if(s!=null) {
singleBroadcast(s,gson.toJson(newMessageDTO));
}
//这里只是测试用的(==================================生产环境要注释一下,这里只是用来测试模拟反馈的====================================================================)
//newMessageDTO.setMessageCode(104);
//封装一个临时数据用来测试
List<Integer> ids = new ArrayList<Integer>();
ids.add(idArray[i]);
i++;
ids.add(idArray[i]);
i++;
//通过ids可以获取lightId,lightName,floorName,blockName,CommunityName
List<InfoDTO> infoList = new ArrayList<InfoDTO>();
for(Integer lightId: ids){
InfoDTO info = communityDetailService.selectAllInfoByLightId(lightId);
infoList.add(info);
}
//newMessageDTO.setLightId(ids);
//newMessageDTO.setInfoList(infoList);
//因为有可能count为0,就是C程序没有连,如果为0,这个时候其实UI已经把连接给关闭了
if(count!=0) {
singleBroadcast(session,gson.toJson(newMessageDTO));
}
}
//2代表发送完毕,但是不代表处理成功
//messageDTO.setFlag(2);
//因为count为0,session其实已经被UI代码给关闭了
//System.out.println(session);
//System.out.println(session.getId());
//这下面的不知道是不是可以保留,因为如果C程序已经返回其实UI连接已经断开,这个就发布出去了,但是理论上不可能
//毕竟C程序接收,处理,反馈是需要时间的,所以还是先保留
//if(count!=0) {
//开发环境可以先注释(这里真的很犹豫,因为界面上不知道有没有必要提示数据已经发送给每个block)
//singleBroadcast(session,gson.toJson(messageDTO));
//}
}
}
/**
* 这个方法是最重要的,因为SPS管理系统页面点击发送就是通过这个方法接收然后广播给C程序
* 服务器是通过依赖注入来接收的msg,一个通信管道要发送多次消息,消息内容不一样
* 消息一定要结构化,对消息进行分类,结构化
* @param session
* @param msg
*/
@OnMessage
public void message(Session session,String msg) {
System.out.println("收到信息啦, 来自sessionId: " + session.getId());
System.out.println("信息内容: " + msg);
//把前端组装的JSON字符串格式转成JavaBean对象格式,其实json就是字符串,然后通过工具类转成实体类MessageSocket
MessageDTO messageDTO = gson.fromJson(msg, MessageDTO.class);
if(messageDTO!=null) {
//如果MEG_CODE等于2,说明是req_ctrl
if(messageDTO.getMessageCode()!=null && messageDTO.getMessageCode()==2) {
//进到这里说明是Ctrl light功能
sendControlMessage(messageDTO,session);
}else if(messageDTO.getMessageCode()!=null && messageDTO.getMessageCode()==3) {
//如果MEG_CODE等于3,说明是Req_get_pwm的Refresh功能(因为我们是以栋为单位的,所以只有floor才有这个功能)
sendRefreshMessage(messageDTO,session);
}else if(messageDTO.getMessageCode()!=null && messageDTO.getMessageCode()==102) {
//如果MEG_CODE等于102,说明是Ind_alarm(102)
sendMobileAndEmail(messageDTO);
}else if(messageDTO.getMessageCode()!=null && messageDTO.getMessageCode()==0) {
//如果MEG_CODE等于0,说明是Req_cfg_SPS100(0)
sendMainConfigMessage(messageDTO,session);
}else if(messageDTO.getMessageCode()!=null && messageDTO.getMessageCode()==100) {
//如果MEG_CODE等于100,说明是Rsp_cfg_SPS100(100)
sendMainConfigFeedbackMessage(messageDTO,session);
}else if(messageDTO.getMessageCode()!=null && messageDTO.getMessageCode()==1) {
//如果MEG_CODE等于1,说明是Req_cfg_PHOTO(1)
sendPhotoConfigMessage(messageDTO,session);
}else if(messageDTO.getMessageCode()!=null && messageDTO.getMessageCode()==101) {
//如果MEG_CODE等于101,说明是Rsp_cfg_PHOTO(101)
sendPhotoConfigFeedbackMessage(messageDTO,session);
}else if(messageDTO.getMessageCode()!=null && messageDTO.getMessageCode()==4) {
//如果MEG_CODE等于0,说明是Req_cfg_SPS200(4)
sendSPS200ConfigMessage(messageDTO,session);
}else if(messageDTO.getMessageCode()!=null && messageDTO.getMessageCode()==104) {
//如果MEG_CODE等于100,说明是Rsp_cfg_SPS200(104)
sendSPS200ConfigFeedbackMessage(messageDTO,session);
}
}
}
/**
* 单播给每一个Session
* 把SPS100页面点击事件发送的信息广播给C程序(严格说这个方法其实是单播给指定的client,只是为了好理解可以这样描述)
* @param s 连接WebSocket的Client的Session
* @param msg 界面client发送的信息
*/
private static void singleBroadcast(Session session, String msg) {
//当客户端有人发信息的时候,就把这条信息发给每一个client,
//其实这里也包括自己manager系统,正常是给一直建立长连接websocket的C程序和浏览器js
//相当于一个Java程序客户端发送信息给C语言程序让其控制灯
try {
//这里我们要封装称一个实体类,包含id类型,id值,然后将实体类转成JSON发给C程序
session.getBasicRemote().sendText(msg);
} catch (IOException e) {
e.printStackTrace();
}
}
/**
* 把SPS100页面点击事件发送的信息广播给C程序(严格说这个方法其实是广播给所有的client,只是为了好理解可以这样描述)
* @param ss 所有连接WebSocket的Client的Session集合
* @param msg 界面client发送的信息
* 所有的人都返回消息,这就是广播
*/
/*private static void broadcast(List<Session> ss, String msg) {
//遍历循环每一个Session或者通道或者说客户端client,都是一个东西
for(Iterator<Session> iterator = ss.iterator();iterator.hasNext();) {
Session session = iterator.next();
//当客户端有人发信息的时候,就把这条信息发给每一个client,
//其实这里也包括自己manager系统,正常是给一直建立长连接websocket的C++程序的
//相当于一个Java程序客户端发送信息给C语言程序让其控制灯
try {
//这里我们要封装称一个实体类,包含id类型,id值,然后将实体类转成JSON发给C程序
session.getBasicRemote().sendText(msg);
} catch (IOException e) {
e.printStackTrace();
}
}
}*/
}
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page trimDirectiveWhitespaces="true"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="itheima" uri="http://itcast.cn/common/"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
+ path + "/";
String websocketPath = request.getServerName() + ":" + request.getServerPort() + path + "/";
String SchemeValue = request.getScheme();
%>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Aztech Smart Lighting Management System V1.0</title>
<style type="text/css">
body{
margin: 0px;
padding: 0px;
}
#container{
width: 100%;
height: 100%;
margin:auto;
background-image: url(${pageContext.request.contextPath}/img/BG2.jpg);
}
#logo{
width: 100%;
height: 60px;
background-color: #27282d;
}
#logo_left{
width: 17.939394%;
height: 58px;
float: left;
}
#logo_middle{
width: 45%;
height: 38px;
padding-top: 20px;
float: left;
}
#logo_right{
width: 36.22%;
padding-top: 24px;
height: 34px;
float: left;
}
#aztech_font{
font-size: 34.4px;
}
#smart_sys_font{
font-size: 28.5px;
}
.c7c7ca_color{
color: #c7c7ca;
font-family: Century Gothic;
font-size: 12px;
}
ul li{
display: inline;
}
#time{
display: inline;
}
#select_form{
width: 100%;
height: 60px;
padding-top: 60px;
font-family: Century Gothic;
font-size: 12px;
color: #c7c7ca;
}
.amountAndControl {
margin:0 auto;
width:950px;
height:60px;
font-family: Century Gothic;
font-size:18px;
color: #c3c4d5;
}
.lightAmount {
float:left;
}
.controlButton {
float: right;
}
.controlButton .button{
border: none;
color: white;
/* padding: 15px 32px; */
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 21px;
/* margin: 4px 2px; */
cursor: pointer;
border-radius:16px;
box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19);
}
.controlButton .button:hover {
box-shadow: 0 12px 16px 0 rgba(0,0,0,0.24),0 17px 50px 0 rgba(0,0,0,0.19);
}
.controlButton .button0 {background-color: #4CAF50;;} /* Green */
.controlButton .button1 {background-color: #555555;} /* Black */
.controlButton .button2 {background-color: #e7e7e7; color: black;} /* Gray */
.controlButton .button4 {background-color: #ffa500; color: #008000;} /* Pink */
select{
/*Chrome和Firefox里面的边框是不一样的,所以复写了一下*/
border: solid 1px #000;
width:102px;
height: 22px;
appearance:none;
-moz-appearance:none;
-webkit-appearance:none;
background: url(${pageContext.request.contextPath}/img/options_unclicked.png) no-repeat right center;
font-size: 12px;
font-family: Century Gothic;
color: #c3c4d5;
}
#lightDate{
border: solid 1px #000;
border-collapse:collapse;
width:102px;
height: 18px;
appearance:none;
-moz-appearance:none;
-webkit-appearance:none;
background: url(${pageContext.request.contextPath}/img/options_unclicked.png) no-repeat right center;
font-size: 12px;
font-family: Century Gothic;
color: #c3c4d5;
}
#page_button{
height: 40px;
text-align:right;
}
#bottom{
height: 59px;
font-family: Century Gothic;
text-align: center;
font-size: 12px;
color: #FFF;
}
.option_color{
background:#60626a;
}
.select_option{
background: url(${pageContext.request.contextPath}/img/options_unclicked.png) no-repeat right center;
}
a{
color:#c7c7ca;
text-decoration:none;
}
a:hover{
color:red;
}
a:active{
color:pink;
}
</style>
<!-- jQuery -->
<script src="${pageContext.request.contextPath}/js/jquery-1.8.3.js"></script>
<script src="${pageContext.request.contextPath}/js/My97DatePicker/WdatePicker.js"></script>
<!-- 导入easyui类库 -->
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/js/easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath}/js/easyui/themes/icon.css">
<script type="text/javascript" src="${pageContext.request.contextPath}/js/easyui/jquery.easyui.min.js"></script>
<script type="text/javascript">
function changeCommunity(){
$("#community_list_form").attr("action", "${pageContext.request.contextPath}/community/communityList.action");
$("#community_list_form").submit();
}
function changeBlock(){
$("#community_list_form").attr("action", "${pageContext.request.contextPath}/community/blockList.action");
$("#community_list_form").submit();
}
function changeFloor(){
$("#community_list_form").attr("action", "${pageContext.request.contextPath}/community/floorList.action");
$("#community_list_form").submit();
}
function changeLight(){
$("#community_list_form").attr("action", "${pageContext.request.contextPath}/community/lightDateList.action");
$("#community_list_form").submit();
}
function checkfinish(){
$("#community_list_form").attr("action", "${pageContext.request.contextPath}/community/communityList.action");
$("#community_list_form").submit();
}
function logout(){
$.messager.confirm('Confirm','Are you sure to exit this system?',function(r){
if(r){
location.href = "${pageContext.request.contextPath}/user/logout.action";
}
});
}
</script>
<script>
$(function(){
var lightNumbers = "${lightNumbers}";
//console.log("lightNumbers",lightNumbers);
if(lightNumbers==0){
lightNumbers = "";
}else{
lightNumbers = "No. of Lights:" + lightNumbers;
}
$("#lightNumbers").text(lightNumbers);
});
</script>
<script>
$(function(){
//turnon灯的方法
$("#turnOnLight").click(function(){
//1.eventID(这个是作为唯一标识)
var myData = new Date();
var eventId = myData.getTime();//当前时间的毫秒数
//console.log("eventID",eventID);
//2.ID
var communityId = ${communityId};
//console.log("communityId:",communityId);
var idArr = [{whatId:1,idValues:[communityId]}];
//console.log("idArr",idArr);
//定义一个全局的websocket对象,一个websocket对象就是一个通信管道,只要不关浏览器,不关服务器,就会始终打开
var ws;
//这里的SPS100项目路径一定要带上,否则找不到。
var protocal = '<%=SchemeValue%>'=='http'?"ws://":"wss://";
console.info("protocal:" + protocal);
<%-- var target = "wss://"+ '<%=websocketPath%>' + "websocket/smartControl"; --%>
//target就是endpoint服务器端的地址,就是你要连谁,服务器端有很多的websocket
var target = protocal+ '<%=websocketPath%>' + "websocket/smartControl";
console.log("target:" + target);
if ('WebSocket' in window) {
ws = new WebSocket(target);
} else if ('MozWebSocket' in window) {
ws = new MozWebSocket(target);
} else {
alert('WebSocket is not supported by this browser.');
return;
}
ws.onopen = function(){
sendMessage();
//这个先用输入框,后面用SPS100界面点击事件传入参数的形式
function sendMessage(){
//创建一个json对象
var params = {
eventId:eventId,
messageCode:2,
idArr:idArr,
//这个是turnon所以为1
ctrl:1
}
//把json对象转成String
var str = JSON.stringify(params);
console.info("str字符串: " + str);
//这里先演示传入一个字符串,后面会从数据库查询数,然后封装成一个json字符串对象传给后台广播给C程序
$.messager.confirm('Confirm','Are you sure to turn on the lights?',function(r){
if(r){
ws.send(str);
}else{
ws.close(); //关闭TCP连接
}
});
//这里是回调函数,websocket广播的json数据就是发送到这里
//服务端返回的是MessageEvent对象,该对象中有data属性
//这里是回调函数,websocket广播的json数据就是发送到这里
ws.onmessage = function(message){
eval("var msg = " + message.data + ";");
console.info(msg);
if(undefined!=msg.eventId && undefined!=msg.messageCode
&& undefined!=msg.idArr && undefined!=msg.ctrl){
$.messager.alert('Messager','The operation has completed successfully!','info');
ws.close(); //关闭TCP连接
}
}
}
}
});
//turnoff灯的方法
$("#turnOffLight").click(function(){
//1.eventID(这个是作为唯一标识)
var myData = new Date();
var eventId = myData.getTime();//当前时间的毫秒数
//console.log("eventID",eventID);
//2.ID
var communityId = ${communityId};
//console.log("communityId:",communityId);
var idArr = [{whatId:1,idValues:[communityId]}];
//console.log("idArr",idArr);
//定义一个全局的websocket对象
var ws;
//这里的SPS100项目路径一定要带上,否则找不到。
var protocal = '<%=SchemeValue%>'=='http'?"ws://":"wss://";
console.info("protocal:" + protocal);
<%-- var target = "wss://"+ '<%=websocketPath%>' + "websocket/smartControl"; --%>
var target = protocal+ '<%=websocketPath%>' + "websocket/smartControl";
console.log("target:" + target);
if ('WebSocket' in window) {
ws = new WebSocket(target);
} else if ('MozWebSocket' in window) {
ws = new MozWebSocket(target);
} else {
alert('WebSocket is not supported by this browser.');
return;
}
ws.onopen = function(){
sendMessage();
//这个先用输入框,后面用SPS100界面点击事件传入参数的形式
function sendMessage(){
//创建一个json对象
var params = {
eventId:eventId,
messageCode:2,
idArr:idArr,
//这个是turnoff所以为0
ctrl:0
}
//把json对象转成String
var str = JSON.stringify(params);
console.info("str字符串: " + str);
//这里先演示传入一个字符串,后面会从数据库查询数,然后封装成一个json字符串对象传给后台广播给C程序
$.messager.confirm('Confirm','Are you sure to turn off the lights?',function(r){
if(r){
ws.send(str);
}else{
ws.close(); //关闭TCP连接
}
});
//这里是回调函数,websocket广播的json数据就是发送到这里
ws.onmessage = function(message){
eval("var msg = " + message.data + ";");
console.info(msg);
if(undefined!=msg.eventId && undefined!=msg.messageCode
&& undefined!=msg.idArr && undefined!=msg.ctrl){
$.messager.alert('Messager','The operation has completed successfully!','info');
ws.close(); //关闭TCP连接
}
}
}
}
});
//turn normal
$("#turnNormalLight").click(function(){
//1.eventId(这个是作为唯一标识)
var myData = new Date();
var eventId = myData.getTime();//当前时间的毫秒数
//console.log("eventId",eventId);
//2.idValues
var communityId = ${communityId};
//console.log("communityId:",communityId);
var idArr = [{whatId:1,idValues:[communityId]}];
//console.log("idArr",idArr);
//定义一个全局的websocket对象
var ws;
//这里的SPS100项目路径一定要带上,否则找不到。
var protocal = '<%=SchemeValue%>'=='http'?"ws://":"wss://";
console.info("protocal:" + protocal);
<%-- var target = "wss://"+ '<%=websocketPath%>' + "websocket/smartControl"; --%>
var target = protocal+ '<%=websocketPath%>' + "websocket/smartControl";
console.log("target:" + target);
if ('WebSocket' in window) {
ws = new WebSocket(target);
} else if ('MozWebSocket' in window) {
ws = new MozWebSocket(target);
} else {
alert('WebSocket is not supported by this browser.');
return;
}
ws.onopen = function(){
sendMessage();
//这个先用输入框,后面用SPS100界面点击事件传入参数的形式
function sendMessage(){
//创建一个json对象
var params = {
eventId:eventId,
messageCode:2,
idArr:idArr,
//这个是turnnormal所以为2
ctrl:2
}
//把json对象转成String
var str = JSON.stringify(params);
console.info("str字符串: " + str);
//这里先演示传入一个字符串,后面会从数据库查询数,然后封装成一个json字符串对象传给后台广播给C程序
$.messager.confirm('Confirm','Are you sure to turn normal the lights?',function(r){
if(r){
ws.send(str);
}else{
ws.close(); //关闭TCP连接
}
});
//这里是回调函数,websocket广播的json数据就是发送到这里
ws.onmessage = function(message){
eval("var msg = " + message.data + ";");
console.info(msg);
if(undefined!=msg.eventId && undefined!=msg.messageCode
&& undefined!=msg.idArr && undefined!=msg.ctrl){
$.messager.alert('Messager','The operation has completed successfully!','info');
ws.close(); //关闭TCP连接
}
}
}
}
});
//跳转到Config Param页面
$("#configParam").click(function(){
$.messager.confirm('Confirm','Are you sure to the SPS100 config page?',function(r){
if(r){
location.href = "${pageContext.request.contextPath}/configParam.action";
}
});
});
//跳转到photo_sensor页面
$("#photo_sensor").click(function(){
$.messager.confirm('Confirm','Are you sure to the photosensor config page?',function(r){
if(r){
location.href = "${pageContext.request.contextPath}/photoParam.action";
}
});
});
//sps200Config
$("#sps200Config").click(function(){
$.messager.confirm('Confirm','Are you sure to the SPS200 config page?',function(r){
if(r){
location.href = "${pageContext.request.contextPath}/sps200Config.action";
}
});
});
});
</script>
</head>
<body>
<div id="container">
<!-- 1.logo部分 -->
<div id="logo">
<div id="logo_left">
</div>
<div id="logo_middle">
<font color="#FFFFFF" face="Arial" id="aztech_font"><b>Aztech</b></font>
<font color="#8a8989" face="Century Gothic" id="smart_sys_font">Smart Lighting Management System V1.0</font>
</div>
<div id="logo_right" class="c7c7ca_color">
<ul>
<li><font color="#02a0b1">${currentUser.userName}</font></li> <font color="#c7c7ca">|</font>
<c:if test="${currentUser.userName != 'admin'}">
<li>About</li> <font color="#c7c7ca">|</font>
</c:if>
<c:if test="${currentUser.userName == 'admin'}">
<li ><a href="${pageContext.request.contextPath}/user/user_register.action">Register</a></li> <font color="#c7c7ca">|</font>
<li ><a href="${pageContext.request.contextPath}/user/user_account.action">Account</a></li> <font color="#c7c7ca">|</font>
</c:if>
<%-- <li ><a href="${pageContext.request.contextPath}/user/logout.action">Logout</a></li> <font color="#c7c7ca">|</font> --%>
<li ><a onclick="logout()">Logout</a></li> <font color="#c7c7ca">|</font>
<li>
<div id="time">
<script>
updatTime();
function updatTime()
{
var date = new Date().toLocaleString();
var day = new Date().getDay();
var datetime;
if (date.indexOf("上午") != -1)
{
date = date.replace("上午", "AM ");
}
else if (date.indexOf("下午") != -1)
{
date = date.replace("下午", "PM ");
}
if (day == 0)
{
day = " Sunday";
}
else if (day == 1)
{
day = " Monday";
}
else if (day == 2)
{
day = " Tuesday";
}
else if (day == 3)
{
day = " Wednesday";
}
else if (day == 4)
{
day = " Thursday";
}
else if (day == 5)
{
day = " Friday";
}
else
{
day = " Saturday";
}
datetime = date + day;
document.getElementById('time').innerHTML = datetime;
}
setInterval("updatTime()", 1000);
</script>
</div>
</li>
</ul>
</div>
</div>
<!-- 2.select form部分 -->
<div id="select_form">
<form action="" method="post" id="community_list_form" >
<!-- 4个一行两列的表格 -->
<table border="0px" width="925px" height="29.5px" align="center" cellspacing="0" cellpadding="0">
<tr>
<td>
<table border="0px" height="29.5px" width="185px" cellspacing="0" cellpadding="0">
<tr>
<td width="45px">
<label for="communityId">Area</label>
</td>
<td width="140px">
<select id="communityId" name="communityId" onchange="changeCommunity()">
<option class="option_color" value=""> --Selection--</option>
<c:forEach items="${communityList}" var="item">
<option class="option_color" value="${item.communityId}"<c:if test="${item.communityId == communityId}"> selected</c:if>>${item.communityName}</option>
</c:forEach>
</select>
</td>
</tr>
</table>
</td>
<td>
<table border="0px" height="29.5px" width="185px" cellspacing="0" cellpadding="0">
<tr>
<td width="45px">
<label for="blockId">Block</label>
</td>
<td width="140px">
<select id="blockId" name="blockId" onchange="changeBlock()">
<option class="option_color" value=""> --Selection--</option>
<c:forEach items="${blockList}" var="item">
<option class="option_color" value="${item.blockId}"<c:if test="${item.blockId == blockId}"> selected</c:if>>${item.blockName}</option>
${blockList[0].blockName}
</c:forEach>
</select>
</td>
</tr>
</table>
</td>
<td>
<table border="0px" height="29.5px" width="185px" cellspacing="0" cellpadding="0" >
<tr>
<td width="45px">
<label for="floorId">Floor</label>
</td>
<td width="140px">
<select id="floorId" name="floorId" onchange="changeFloor()">
<option class="option_color" value=""> --Selection--</option>
<c:forEach items="${floorList}" var="item">
<option class="option_color" value="${item.floorId}"<c:if test="${item.floorId == floorId}"> selected</c:if>>${item.floorName}</option>
</c:forEach>
</select>
</td>
</tr>
</table>
</td>
<td>
<table border="0px" height="29.5px" width="185px" cellspacing="0" cellpadding="0">
<tr>
<td width="45px">
<label for="lightId">Light</label>
</td>
<td width="140px">
<select id="lightId" name="lightId" >
<option class="option_color" value=""> --Selection--</option>
<c:forEach items="${sps100List}" var="item">
<option class="option_color" value="${item.lightId}"<c:if test="${item.lightId == lightId}"> selected</c:if>>${item.lightName }</option>
</c:forEach>
</select>
</td>
</tr>
</table>
</td>
<td>
<table border="0px" height="29.5px" width="185px" cellspacing="0" cellpadding="0">
<tr>
<td width="45px">
<label for="lightDate">Date</label>
</td>
<td width="140px">
<input type="text" onClick="WdatePicker({lang:'en',onpicked:checkfinish,maxDate:new Date()})" readonly="readonly" class="Wdate" value="${lightDate}" id="lightDate" name="lightDate" />
</td>
</tr>
</table>
</td>
</tr>
</table>
</form>
</div>
<!-- Lights Amount && Control Button(Turn ON/OFF/NORMAL) -->
<div class="amountAndControl">
<div class="lightAmount">
<span id="lightNumbers"></span>
</div>
<div class="controlButton">
<button id="turnOnLight" class="button button0">Turn On</button>
<button id="turnOffLight" class="button button1">Turn Off</button>
<button id="turnNormalLight" class="button button2">Turn Normal</button>
<button id="configParam" class="button button4">SPS100 Config</button>
<button id="photo_sensor" class="button button4">Photo Config</button>
<button id="sps200Config" class="button button4">SPS200 Config</button>
</div>
</div>
<!-- currentLevelCanvas(1,2,3,4) -->
<div class="row" align="center">
<canvas id="currentLevelCanvas" width="1200" height="900" >
Your browser does not support HTML5.
</canvas>
<script type="text/javascript">
//因为只能调用一次onload,所以初始化一个方法,然后把要onload的canvas全部放入这个init方法里面
window.onload = initCanvas;
function initCanvas(){
drawCurrentLevel();
drawOVPOCPPIRFail();
}
/* usedEnergyCanvas ---------------------------------start */
function drawCurrentLevel(){
var canvas = document.getElementById("currentLevelCanvas");
var context = canvas.getContext("2d");
drawCurrentLevelHorizontalLine();
function drawCurrentLevelHorizontalLine(){
var valueOfY = 800;
//判断不能越界
while(valueOfY>80){
context.beginPath();
context.moveTo(45,valueOfY);
context.lineTo(1140,valueOfY);
context.lineWidth = 1;
context.strokeStyle = "#2e2f35";
context.stroke();
context.beginPath();
context.moveTo(45,valueOfY+1);
context.lineTo(1140,valueOfY+1);
context.lineWidth = 1;
context.strokeStyle = "#44454e";
context.stroke();
//y月往上其实值是-step
valueOfY -= 250;
}
//画y轴的坐标
context.beginPath();
context.moveTo(40,800);
context.lineTo(40,50);
context.lineWidth = 1;
context.strokeStyle = "#2e2f35";
context.stroke();
context.beginPath();
context.moveTo(41,814);
context.lineTo(41,50);
context.lineWidth = 1;
context.strokeStyle = "#44454e";
context.stroke();
}
//调用画x轴的函数
drawXMark();
//写x轴坐标单位注释方法
drawHourDayMonthConsumptionEnergy();
function drawHourDayMonthConsumptionEnergy(){
context.font = "24px Century Gothic";
context.fillStyle = "#F4381D"; //Hour & Day & Month Consumption
context.fillText("Hour", 400, 25);
context.fillStyle = "#C3C4D6";
context.fillText(" & ", 452, 25);
context.fillStyle = "#F27C1C";
context.fillText("Day & ", 485, 25);
context.fillStyle = "#C3C4D6";
context.fillText(" & ", 532, 25);
context.fillStyle = "#E1DA10";
context.fillText("Month", 564, 25);
context.fillStyle = "#C3C4D6";
context.fillText("Consumption", 645, 25);
}
//画Day的X轴的函数
drawXDayMark()
//调用画y轴的函数
drawYMark();
//画Month的x轴的函数
drawXMonthMark();
//调用画注释坐标单位描述方法
drawUnitDescription();
var communityOneDaySavedEnergy = "${communityOneDaySavedEnergy}";
communityOneDaySavedEnergy = new Number(communityOneDaySavedEnergy).toFixed(0)+"KW.H";
//console.log("communityOneDaySavedEnergy:" + communityOneDaySavedEnergy);
var communityOneMonthSavedEnergy = "${communityOneMonthSavedEnergy}";
communityOneMonthSavedEnergy = new Number(communityOneMonthSavedEnergy).toFixed(0)+"KW.H";
//console.log("communityOneMonthSavedEnergy:" + communityOneMonthSavedEnergy);
var communityOneYearSavedEnergy = "${communityOneYearSavedEnergy}";
communityOneYearSavedEnergy = new Number(communityOneYearSavedEnergy).toFixed(0)+"KW.H";
//console.log("communityOneYearSavedEnergy:" + communityOneYearSavedEnergy);
drawCurrentLevelTitleContent(communityOneDaySavedEnergy,communityOneMonthSavedEnergy,communityOneYearSavedEnergy);
function drawCurrentLevelTitleContent(communityOneDaySavedEnergy,communityOneMonthSavedEnergy,communityOneYearSavedEnergy){
context.beginPath();
context.font = "18px Century Gothic";
context.fillStyle = "#F4381D";
context.fillText("Saved Energy:", 850, 100);
context.fillText(communityOneDaySavedEnergy, 980, 100);
context.beginPath();
context.font = "18px Century Gothic";
context.fillStyle = "#F27C1C";
context.fillText("Saved Energy:", 850, 352);
context.fillText(communityOneMonthSavedEnergy, 980, 352);
context.beginPath();
context.font = "18px Century Gothic";
context.fillStyle = "#E1DA10";
context.fillText("Saved Energy:", 850, 600);
context.fillText(communityOneYearSavedEnergy, 980, 600);
}
//首先画ON
//设置strokeStyle就是画ON线的颜色
context.strokeStyle = "#008000";
context.lineWidth = 4;
//调用beginPath()方法
context.beginPath();
<c:forEach items="${currentLevelList}" var="item">
drawOnLightLine("${item.currentLevel}", "${item.currentLevelSecond}");
</c:forEach>
context.stroke();
function drawOnLightLine(currentLevel,currentLevelSecond){
if(currentLevel==4){
context.lineTo(40+ currentLevelSecond/88, 84);
}
}
//画OFF
//设置strokeStyle就是画OFF线的颜色
context.strokeStyle = "#000000";
context.lineWidth = 4;
//调用beginPath()方法
context.beginPath();
<c:forEach items="${currentLevelList}" var="item">
drawOffLightLine("${item.currentLevel}", "${item.currentLevelSecond}");
</c:forEach>
context.stroke();
function drawOffLightLine(currentLevel, currentLevelSecond){
if(currentLevel==1){
context.lineTo(40+ currentLevelSecond/88, 184);
}
}
//画DIM
//设置strokeStyle就是画DIM线的颜色
context.strokeStyle = "#FFA500";
context.lineWidth = 4;
//调用beginPath()方法
context.beginPath();
<c:forEach items="${currentLevelList}" var="item">
drawDimLightLine("${item.currentLevel}", "${item.currentLevelSecond}");
</c:forEach>
context.stroke();
function drawDimLightLine(currentLevel, currentLevelSecond){
if(currentLevel==3){
context.lineTo(40+ currentLevelSecond/88, 284);
}
}
//画OFFLINE
//设置strokeStyle就是画OFFLINE线的颜色
context.strokeStyle = "#FF0000";
context.lineWidth = 4;
//调用beginPath()方法
context.beginPath();
<c:forEach items="${currentLevelList}" var="item">
drawOffLineLightLine("${item.currentLevel}", "${item.currentLevelSecond}");
</c:forEach>
context.stroke();
function drawOffLineLightLine(currentLevel, currentLevelSecond){
if(currentLevel==2){
context.lineTo(40+ currentLevelSecond/88, 384);
}
}
//写y轴坐标单位注释方法
function drawUnitDescription(){
context.font = "12px Century Gothic";
context.fillStyle = "#C3C4D6";
context.fillText("KW.H", 25, 48);
}
function drawYMark(){
context.font = "12px Century Gothic";
context.fillStyle = "#C3C4D6";
context.fillText("Month", 1112, 812);
context.fillStyle = "#C3C4D6";
context.fillText("Day", 1112, 562);
context.fillStyle = "#C3C4D6";
context.fillText("Hours", 1112, 314);
}
drawHoursYMark();
//画Hours的Y轴mark
function drawHoursYMark(){
context.font = "12px Century Gothic";
context.fillStyle = "#C3C4D6";
//context.fillText("0", 15, 298);
context.fillText("0.5", 15, 253);
context.fillText("1", 15, 208);
context.fillText("1.5", 15, 163);
context.fillText("2", 15, 118);
}
drawHoursYMarks();
//画HoursY轴的标线
function drawHoursYMarks(){
context.beginPath();
context.moveTo(40,253-0.5);
context.lineTo(1140,253-0.5);
context.lineWidth = 1;
context.strokeStyle = "#44454e";
context.stroke();
context.beginPath();
context.moveTo(40,208-0.5);
context.lineTo(1140,208-0.5);
context.stroke();
context.beginPath();
context.moveTo(40,163-0.5);
context.lineTo(1140,163-0.5);
context.stroke();
context.beginPath();
context.moveTo(40,118-0.5);
context.lineTo(1140,118-0.5);
context.stroke();
}
drawDaysYMark();
//画Days的Y轴mark
function drawDaysYMark(){
context.font = "12px Century Gothic";
context.fillStyle = "#C3C4D6";
context.fillText("3", 15, 503);
context.fillText("6", 15, 458);
context.fillText("9", 15, 413);
context.fillText("12", 15, 368);
}
//画DaysY轴的标线
drawDaysYMarks();
function drawDaysYMarks(){
context.beginPath();
context.moveTo(40,503-0.5);
context.lineTo(1140,503-0.5);
context.lineWidth = 1;
context.strokeStyle = "#44454e";
context.stroke();
context.beginPath();
context.moveTo(40,458-0.5);
context.lineTo(1140,458-0.5);
context.stroke();
context.beginPath();
context.moveTo(40,413-0.5);
context.lineTo(1140,413-0.5);
context.stroke();
context.beginPath();
context.moveTo(40,368-0.5);
context.lineTo(1140,368-0.5);
context.stroke();
}
drawMonthsYMark();
//画Days的Y轴mark
function drawMonthsYMark(){
context.font = "12px Century Gothic";
context.fillStyle = "#C3C4D6";
context.fillText("100", 15, 753);
context.fillText("200", 15, 708);
context.fillText("300", 15, 663);
context.fillText("400", 15, 618);
}
//画MonthsY轴的标线
drawMonthsYMarks();
function drawMonthsYMarks(){
context.beginPath();
context.moveTo(40,753-0.5);
context.lineTo(1140,753-0.5);
context.lineWidth = 1;
context.strokeStyle = "#44454e";
context.stroke();
context.beginPath();
context.moveTo(40,708-0.5);
context.lineTo(1140,708-0.5);
context.stroke();
context.beginPath();
context.moveTo(40,663-0.5);
context.lineTo(1140,663-0.5);
context.stroke();
context.beginPath();
context.moveTo(40,618-0.5);
context.lineTo(1140,618-0.5);
context.stroke();
}
//画x轴的函数
function drawXMark(){
for(var i=0;i<24;i++){
//画刻度线
context.font = "12px Century Gothic";
context.fillStyle = "#C3C4D6";
context.fillText((i+1), 40+45*i, 312);
}
}
var communityDayEnergyValueArray =new Array();
//console.log("communityDayEnergyValueArray before:" + communityDayEnergyValueArray);
//console.log("communityDayEnergyValueArray before length:" + communityDayEnergyValueArray.length);
communityDayEnergyValueArray[0] = "${communityDayEnergyValueDTO.communityHourEnergy1}";
communityDayEnergyValueArray[1] = "${communityDayEnergyValueDTO.communityHourEnergy2}";
communityDayEnergyValueArray[2] = "${communityDayEnergyValueDTO.communityHourEnergy3}";
communityDayEnergyValueArray[3] = "${communityDayEnergyValueDTO.communityHourEnergy4}";
communityDayEnergyValueArray[4] = "${communityDayEnergyValueDTO.communityHourEnergy5}";
communityDayEnergyValueArray[5] = "${communityDayEnergyValueDTO.communityHourEnergy6}";
communityDayEnergyValueArray[6] = "${communityDayEnergyValueDTO.communityHourEnergy7}";
communityDayEnergyValueArray[7] = "${communityDayEnergyValueDTO.communityHourEnergy8}";
communityDayEnergyValueArray[8] = "${communityDayEnergyValueDTO.communityHourEnergy9}";
communityDayEnergyValueArray[9] = "${communityDayEnergyValueDTO.communityHourEnergy10}";
communityDayEnergyValueArray[10] = "${communityDayEnergyValueDTO.communityHourEnergy11}";
communityDayEnergyValueArray[11] = "${communityDayEnergyValueDTO.communityHourEnergy12}";
communityDayEnergyValueArray[12] = "${communityDayEnergyValueDTO.communityHourEnergy13}";
communityDayEnergyValueArray[13] = "${communityDayEnergyValueDTO.communityHourEnergy14}";
communityDayEnergyValueArray[14] = "${communityDayEnergyValueDTO.communityHourEnergy15}";
communityDayEnergyValueArray[15] = "${communityDayEnergyValueDTO.communityHourEnergy16}";
communityDayEnergyValueArray[16] = "${communityDayEnergyValueDTO.communityHourEnergy17}";
communityDayEnergyValueArray[17] = "${communityDayEnergyValueDTO.communityHourEnergy18}";
communityDayEnergyValueArray[18] = "${communityDayEnergyValueDTO.communityHourEnergy19}";
communityDayEnergyValueArray[19] = "${communityDayEnergyValueDTO.communityHourEnergy20}";
communityDayEnergyValueArray[20] = "${communityDayEnergyValueDTO.communityHourEnergy21}";
communityDayEnergyValueArray[21] = "${communityDayEnergyValueDTO.communityHourEnergy22}";
communityDayEnergyValueArray[22] = "${communityDayEnergyValueDTO.communityHourEnergy23}";
communityDayEnergyValueArray[23] = "${communityDayEnergyValueDTO.communityHourEnergy24}";
//console.log("communityDayEnergyValueArray after:" + communityDayEnergyValueArray);
//console.log("communityDayEnergyValueArray after length:" + communityDayEnergyValueArray.length);
drawHoursConsumption(communityDayEnergyValueArray);
//画Hours的X轴的Consumption
function drawHoursConsumption(communityDayEnergyValueArray){
context.lineWidth = 10;
context.strokeStyle = "#F4381D";
for(var i=1;i<=communityDayEnergyValueArray.length;i++){
var j = 90*parseFloat(communityDayEnergyValueArray[i-1]);
if(j>180){
j=180;
}else if(j<0){
j=0;
}
//console.log("j:" + j);
context.beginPath();
context.moveTo(45*i-0.5,298);
context.lineTo(45*i-0.5,298-j);
context.stroke();
}
}
var days = "${communityMonthEnergyDTO.days}";
days = parseInt(days);
//console.log(days);
drawXDayMark(days);
//画Day的X轴的函数
function drawXDayMark(days){
for(var i=1;i<=days;i++){
//画刻度线
context.font = "12px Century Gothic";
context.fillStyle = "#C3C4C6";
context.fillText(i, 40+34*(i-1), 564);
}
}
var communityDayEnergyArray =new Array();
//console.log("communityDayEnergyArray before:" + communityDayEnergyArray);
//console.log("communityDayEnergyArray before length:" + communityDayEnergyArray.length);
communityDayEnergyArray[0] = "${communityMonthEnergyDTO.communityDayEnergy1}";
communityDayEnergyArray[1] = "${communityMonthEnergyDTO.communityDayEnergy2}";
communityDayEnergyArray[2] = "${communityMonthEnergyDTO.communityDayEnergy3}";
communityDayEnergyArray[3] = "${communityMonthEnergyDTO.communityDayEnergy4}";
communityDayEnergyArray[4] = "${communityMonthEnergyDTO.communityDayEnergy5}";
communityDayEnergyArray[5] = "${communityMonthEnergyDTO.communityDayEnergy6}";
communityDayEnergyArray[6] = "${communityMonthEnergyDTO.communityDayEnergy7}";
communityDayEnergyArray[7] = "${communityMonthEnergyDTO.communityDayEnergy8}";
communityDayEnergyArray[8] = "${communityMonthEnergyDTO.communityDayEnergy9}";
communityDayEnergyArray[9] = "${communityMonthEnergyDTO.communityDayEnergy10}";
communityDayEnergyArray[10] = "${communityMonthEnergyDTO.communityDayEnergy11}";
communityDayEnergyArray[11] = "${communityMonthEnergyDTO.communityDayEnergy12}";
communityDayEnergyArray[12] = "${communityMonthEnergyDTO.communityDayEnergy13}";
communityDayEnergyArray[13] = "${communityMonthEnergyDTO.communityDayEnergy14}";
communityDayEnergyArray[14] = "${communityMonthEnergyDTO.communityDayEnergy15}";
communityDayEnergyArray[15] = "${communityMonthEnergyDTO.communityDayEnergy16}";
communityDayEnergyArray[16] = "${communityMonthEnergyDTO.communityDayEnergy17}";
communityDayEnergyArray[17] = "${communityMonthEnergyDTO.communityDayEnergy18}";
communityDayEnergyArray[18] = "${communityMonthEnergyDTO.communityDayEnergy19}";
communityDayEnergyArray[19] = "${communityMonthEnergyDTO.communityDayEnergy20}";
communityDayEnergyArray[20] = "${communityMonthEnergyDTO.communityDayEnergy21}";
communityDayEnergyArray[21] = "${communityMonthEnergyDTO.communityDayEnergy22}";
communityDayEnergyArray[22] = "${communityMonthEnergyDTO.communityDayEnergy23}";
communityDayEnergyArray[23] = "${communityMonthEnergyDTO.communityDayEnergy24}";
communityDayEnergyArray[24] = "${communityMonthEnergyDTO.communityDayEnergy25}";
communityDayEnergyArray[25] = "${communityMonthEnergyDTO.communityDayEnergy26}";
communityDayEnergyArray[26] = "${communityMonthEnergyDTO.communityDayEnergy27}";
communityDayEnergyArray[27] = "${communityMonthEnergyDTO.communityDayEnergy28}";
communityDayEnergyArray[28] = "${communityMonthEnergyDTO.communityDayEnergy29}";
communityDayEnergyArray[29] = "${communityMonthEnergyDTO.communityDayEnergy30}";
communityDayEnergyArray[30] = "${communityMonthEnergyDTO.communityDayEnergy31}";
//console.log("communityDayEnergyArray after:" + communityDayEnergyArray);
//console.log("communityDayEnergyArray after length:" + communityDayEnergyArray.length);
drawDaysConsumption(days,communityDayEnergyArray);
//画Days的X轴的Consumption
function drawDaysConsumption(days,communityDayEnergyArray){
context.lineWidth = 10;
context.strokeStyle = "#F27C1C";
for(var i=0;i<days;i++){
var j = 15*parseFloat(communityDayEnergyArray[i]);
if(j>180){
j=180;
}else if(j<0){
j=0;
}
context.beginPath();
context.moveTo(45+34*i-0.5,548);
context.lineTo(45+34*i-0.5,548-j);
context.stroke();
}
}
//画Month的x轴的函数
function drawXMonthMark(){
for(var i=0;i<12;i++){
//画刻度线
context.font = "12px Century Gothic";
context.fillStyle = "#C3C4C6";
context.fillText((i+1), 40+94*i, 814);
}
}
var communityYearEnergyArray =new Array();
//console.log("communityYearEnergyArray before:" + communityYearEnergyArray);
//console.log("communityYearEnergyArray before length:" + communityYearEnergyArray.length);
communityYearEnergyArray[0] = "${communityYearEnergyDTO.communityMonthEnergy1}";
communityYearEnergyArray[1] = "${communityYearEnergyDTO.communityMonthEnergy2}";
communityYearEnergyArray[2] = "${communityYearEnergyDTO.communityMonthEnergy3}";
communityYearEnergyArray[3] = "${communityYearEnergyDTO.communityMonthEnergy4}";
communityYearEnergyArray[4] = "${communityYearEnergyDTO.communityMonthEnergy5}";
communityYearEnergyArray[5] = "${communityYearEnergyDTO.communityMonthEnergy6}";
communityYearEnergyArray[6] = "${communityYearEnergyDTO.communityMonthEnergy7}";
communityYearEnergyArray[7] = "${communityYearEnergyDTO.communityMonthEnergy8}";
communityYearEnergyArray[8] = "${communityYearEnergyDTO.communityMonthEnergy9}";
communityYearEnergyArray[9] = "${communityYearEnergyDTO.communityMonthEnergy10}";
communityYearEnergyArray[10] = "${communityYearEnergyDTO.communityMonthEnergy11}";
communityYearEnergyArray[11] = "${communityYearEnergyDTO.communityMonthEnergy12}";
//console.log("communityYearEnergyArray after:" + communityYearEnergyArray);
//console.log("communityYearEnergyArray after length:" + communityYearEnergyArray.length);
drawYearConsumption();
//画Years的X轴的Consumption
function drawYearConsumption(){
context.lineWidth = 10;
context.strokeStyle = "#E1DA10";
for(var i=0;i<communityYearEnergyArray.length;i++){
var j = 0.45*parseFloat(communityYearEnergyArray[i]);
if(j>180){
j=180;
}else if(j<0){
j=0;
}
context.beginPath();
context.moveTo(45+94*i-0.5,798);
context.lineTo(45+94*i-0.5,798-j);
context.stroke();
}
}
}
/* usedEnergyCanvas ---------------------------------end */
/* usedOVPOCPCanvas ------------------------------------ start */
function drawOVPOCPPIRFail(){
var canvas = document.getElementById("ovpOcpPirFailCanvas");
var context = canvas.getContext("2d");
drawOVPOCPPIRFailHorizontalLine();
function drawOVPOCPPIRFailHorizontalLine(){
var valueOfY = 800;
//判断不能越界
while(valueOfY>80){
context.beginPath();
context.moveTo(45,valueOfY);
context.lineTo(1140,valueOfY);
context.lineWidth = 1;
context.strokeStyle = "#2e2f35";
context.stroke();
context.beginPath();
context.moveTo(45,valueOfY+1);
context.lineTo(1140,valueOfY+1);
context.lineWidth = 1;
context.strokeStyle = "#44454e";
context.stroke();
//y月往上其实值是-step
valueOfY -= 250;
}
//画y轴的坐标
context.beginPath();
context.moveTo(40,800);
context.lineTo(40,50);
context.lineWidth = 1;
context.strokeStyle = "#2e2f35";
context.stroke();
context.beginPath();
context.moveTo(41,814);
context.lineTo(41,50);
context.lineWidth = 1;
context.strokeStyle = "#44454e";
context.stroke();
}
//调用画x轴的函数
drawXMark();
//画Day的X轴的函数
drawXDayMark();
//写x轴坐标单位注释方法
drawOVPOCPFirfailPirdetect();
function drawOVPOCPFirfailPirdetect(){
context.font = "24px Century Gothic";
context.fillStyle = "#FF69B4"; //OVP & OCP & PIR-Fail Trigger Counter
context.fillText("OVP", 400, 25);
context.fillStyle = "#C3C4D6";
context.fillText(" & ", 450, 25);
context.fillStyle = "#228B22";
context.fillText("OCP", 486, 25);
context.fillStyle = "#C3C4D6";
context.fillText(" & ", 538, 25);
context.fillStyle = "#00BFFF";
context.fillText("PIR-Fail", 572, 25);
context.fillStyle = "#C3C4D6";
context.fillText("Trigger Amounts", 658, 25);
}
//调用画y轴的函数
drawYMark();
//画Month的x轴的函数
drawXMonthMark();
//调用画注释坐标单位描述方法
drawUnitDescription();
//写y轴坐标单位注释方法
function drawUnitDescription(){
context.font = "12px Century Gothic";
context.fillStyle = "#C3C4D6";
context.fillText("Times", 25, 48);
}
function drawYMark(){
context.font = "12px Century Gothic";
context.fillStyle = "#C3C4D6";
context.fillText("Month", 1112, 812);
context.fillStyle = "#C3C4D6";
context.fillText("Day", 1112, 562);
context.fillStyle = "#C3C4D6";
context.fillText("Hours", 1112, 314);
}
drawHoursYMark();
//画Hours的Y轴mark
function drawHoursYMark(){
context.font = "12px Century Gothic";
context.fillStyle = "#C3C4D6";
//context.fillText("0", 15, 298);
context.fillText("5", 15, 253);
context.fillText("10", 15, 208);
context.fillText("15", 15, 163);
context.fillText("20", 15, 118);
}
drawHoursYMarks();
//画HoursY轴的标线
function drawHoursYMarks(){
context.beginPath();
context.moveTo(40,253-0.5);
context.lineTo(1140,253-0.5);
context.lineWidth = 1;
context.strokeStyle = "#44454e";
context.stroke();
context.beginPath();
context.moveTo(40,208-0.5);
context.lineTo(1140,208-0.5);
context.stroke();
context.beginPath();
context.moveTo(40,163-0.5);
context.lineTo(1140,163-0.5);
context.stroke();
context.beginPath();
context.moveTo(40,118-0.5);
context.lineTo(1140,118-0.5);
context.stroke();
}
drawDaysYMark();
//画Days的Y轴mark
function drawDaysYMark(){
context.font = "12px Century Gothic";
context.fillStyle = "#C3C4D6";
context.fillText("10", 15, 503);
context.fillText("20", 15, 458);
context.fillText("30", 15, 413);
context.fillText("40", 15, 368);
}
//画DaysY轴的标线
drawDaysYMarks();
function drawDaysYMarks(){
context.beginPath();
context.moveTo(40,503-0.5);
context.lineTo(1140,503-0.5);
context.lineWidth = 1;
context.strokeStyle = "#44454e";
context.stroke();
context.beginPath();
context.moveTo(40,458-0.5);
context.lineTo(1140,458-0.5);
context.stroke();
context.beginPath();
context.moveTo(40,413-0.5);
context.lineTo(1140,413-0.5);
context.stroke();
context.beginPath();
context.moveTo(40,368-0.5);
context.lineTo(1140,368-0.5);
context.stroke();
}
drawMonthsYMark();
//画Days的Y轴mark
function drawMonthsYMark(){
context.font = "12px Century Gothic";
context.fillStyle = "#C3C4D6";
context.fillText("20", 15, 753);
context.fillText("40", 15, 708);
context.fillText("60", 15, 663);
context.fillText("80", 15, 618);
}
//画MonthsY轴的标线
drawMonthsYMarks();
function drawMonthsYMarks(){
context.beginPath();
context.moveTo(40,753-0.5);
context.lineTo(1140,753-0.5);
context.lineWidth = 1;
context.strokeStyle = "#44454e";
context.stroke();
context.beginPath();
context.moveTo(40,708-0.5);
context.lineTo(1140,708-0.5);
context.stroke();
context.beginPath();
context.moveTo(40,663-0.5);
context.lineTo(1140,663-0.5);
context.stroke();
context.beginPath();
context.moveTo(40,618-0.5);
context.lineTo(1140,618-0.5);
context.stroke();
}
//画x轴的函数
function drawXMark(){
for(var i=0;i<24;i++){
//画刻度线
context.font = "12px Century Gothic";
context.fillStyle = "#C3C4D6";
context.fillText((i+1), 40+45*i, 312);
}
}
var communityDayOVPNumberArray =new Array();
//console.log("communityDayOVPNumberArray before:" + communityDayOVPNumberArray);
//console.log("communityDayOVPNumberArray before length:" + communityDayOVPNumberArray.length);
communityDayOVPNumberArray[0] = "${communityDayOVPNumberDTO.communityHourOVPNumber1}";
communityDayOVPNumberArray[1] = "${communityDayOVPNumberDTO.communityHourOVPNumber2}";
communityDayOVPNumberArray[2] = "${communityDayOVPNumberDTO.communityHourOVPNumber3}";
communityDayOVPNumberArray[3] = "${communityDayOVPNumberDTO.communityHourOVPNumber4}";
communityDayOVPNumberArray[4] = "${communityDayOVPNumberDTO.communityHourOVPNumber5}";
communityDayOVPNumberArray[5] = "${communityDayOVPNumberDTO.communityHourOVPNumber6}";
communityDayOVPNumberArray[6] = "${communityDayOVPNumberDTO.communityHourOVPNumber7}";
communityDayOVPNumberArray[7] = "${communityDayOVPNumberDTO.communityHourOVPNumber8}";
communityDayOVPNumberArray[8] = "${communityDayOVPNumberDTO.communityHourOVPNumber9}";
communityDayOVPNumberArray[9] = "${communityDayOVPNumberDTO.communityHourOVPNumber10}";
communityDayOVPNumberArray[10] = "${communityDayOVPNumberDTO.communityHourOVPNumber11}";
communityDayOVPNumberArray[11] = "${communityDayOVPNumberDTO.communityHourOVPNumber12}";
communityDayOVPNumberArray[12] = "${communityDayOVPNumberDTO.communityHourOVPNumber13}";
communityDayOVPNumberArray[13] = "${communityDayOVPNumberDTO.communityHourOVPNumber14}";
communityDayOVPNumberArray[14] = "${communityDayOVPNumberDTO.communityHourOVPNumber15}";
communityDayOVPNumberArray[15] = "${communityDayOVPNumberDTO.communityHourOVPNumber16}";
communityDayOVPNumberArray[16] = "${communityDayOVPNumberDTO.communityHourOVPNumber17}";
communityDayOVPNumberArray[17] = "${communityDayOVPNumberDTO.communityHourOVPNumber18}";
communityDayOVPNumberArray[18] = "${communityDayOVPNumberDTO.communityHourOVPNumber19}";
communityDayOVPNumberArray[19] = "${communityDayOVPNumberDTO.communityHourOVPNumber20}";
communityDayOVPNumberArray[20] = "${communityDayOVPNumberDTO.communityHourOVPNumber21}";
communityDayOVPNumberArray[21] = "${communityDayOVPNumberDTO.communityHourOVPNumber22}";
communityDayOVPNumberArray[22] = "${communityDayOVPNumberDTO.communityHourOVPNumber23}";
communityDayOVPNumberArray[23] = "${communityDayOVPNumberDTO.communityHourOVPNumber24}";
//console.log("communityDayOVPNumberArray after:" + communityDayOVPNumberArray);
//console.log("communityDayOVPNumberArray after length:" + communityDayOVPNumberArray.length);
drawDayOVPNumber(communityDayOVPNumberArray);
//画Hours的X轴的OVP的次数
function drawDayOVPNumber(communityDayOVPNumberArray){
context.lineWidth = 5;
context.strokeStyle = "#FF69B4";
for(var i=1;i<=communityDayOVPNumberArray.length;i++){
var j = 9*parseInt(communityDayOVPNumberArray[i-1]);
if(j>180){
j=180;
}else if(j<0){
j=0;
}
//console.log("j:" + j);
context.beginPath();
context.moveTo(45*i-0.5,298);
context.lineTo(45*i-0.5,298-j);
context.stroke();
}
}
var communityDayOCPNumberArray =new Array();
//console.log("communityDayOCPNumberArray before:" + communityDayOCPNumberArray);
//console.log("communityDayOCPNumberArray before length:" + communityDayOCPNumberArray.length);
communityDayOCPNumberArray[0] = "${communityDayOCPNumberDTO.communityHourOCPNumber1}";
communityDayOCPNumberArray[1] = "${communityDayOCPNumberDTO.communityHourOCPNumber2}";
communityDayOCPNumberArray[2] = "${communityDayOCPNumberDTO.communityHourOCPNumber3}";
communityDayOCPNumberArray[3] = "${communityDayOCPNumberDTO.communityHourOCPNumber4}";
communityDayOCPNumberArray[4] = "${communityDayOCPNumberDTO.communityHourOCPNumber5}";
communityDayOCPNumberArray[5] = "${communityDayOCPNumberDTO.communityHourOCPNumber6}";
communityDayOCPNumberArray[6] = "${communityDayOCPNumberDTO.communityHourOCPNumber7}";
communityDayOCPNumberArray[7] = "${communityDayOCPNumberDTO.communityHourOCPNumber8}";
communityDayOCPNumberArray[8] = "${communityDayOCPNumberDTO.communityHourOCPNumber9}";
communityDayOCPNumberArray[9] = "${communityDayOCPNumberDTO.communityHourOCPNumber10}";
communityDayOCPNumberArray[10] = "${communityDayOCPNumberDTO.communityHourOCPNumber11}";
communityDayOCPNumberArray[11] = "${communityDayOCPNumberDTO.communityHourOCPNumber12}";
communityDayOCPNumberArray[12] = "${communityDayOCPNumberDTO.communityHourOCPNumber13}";
communityDayOCPNumberArray[13] = "${communityDayOCPNumberDTO.communityHourOCPNumber14}";
communityDayOCPNumberArray[14] = "${communityDayOCPNumberDTO.communityHourOCPNumber15}";
communityDayOCPNumberArray[15] = "${communityDayOCPNumberDTO.communityHourOCPNumber16}";
communityDayOCPNumberArray[16] = "${communityDayOCPNumberDTO.communityHourOCPNumber17}";
communityDayOCPNumberArray[17] = "${communityDayOCPNumberDTO.communityHourOCPNumber18}";
communityDayOCPNumberArray[18] = "${communityDayOCPNumberDTO.communityHourOCPNumber19}";
communityDayOCPNumberArray[19] = "${communityDayOCPNumberDTO.communityHourOCPNumber20}";
communityDayOCPNumberArray[20] = "${communityDayOCPNumberDTO.communityHourOCPNumber21}";
communityDayOCPNumberArray[21] = "${communityDayOCPNumberDTO.communityHourOCPNumber22}";
communityDayOCPNumberArray[22] = "${communityDayOCPNumberDTO.communityHourOCPNumber23}";
communityDayOCPNumberArray[23] = "${communityDayOCPNumberDTO.communityHourOCPNumber24}";
//console.log("communityDayOCPNumberArray after:" + communityDayOCPNumberArray);
//console.log("communityDayOCPNumberArray after length:" + communityDayOCPNumberArray.length);
drawDayOCPNumber(communityDayOCPNumberArray);
//画Hours的X轴的OCP的次数
function drawDayOCPNumber(communityDayOCPNumberArray){
context.lineWidth = 5;
context.strokeStyle = "#228B22";
for(var i=1;i<=communityDayOCPNumberArray.length;i++){
var j = 9*parseInt(communityDayOCPNumberArray[i-1]);
if(j>180){
j=180;
}else if(j<0){
j=0;
}
//console.log("j:" + j);
context.beginPath();
context.moveTo(45*i+5-0.5,298);
context.lineTo(45*i+5-0.5,298-j);
context.stroke();
}
}
var communityDayPIRFailNumberArray =new Array();
//console.log("communityDayPIRFailNumberArray before:" + communityDayPIRFailNumberArray);
//console.log("communityDayPIRFailNumberArray before length:" + communityDayPIRFailNumberArray.length);
communityDayPIRFailNumberArray[0] = "${communityDayPIRFailNumberDTO.communityHourPIRFailNumber1}";
communityDayPIRFailNumberArray[1] = "${communityDayPIRFailNumberDTO.communityHourPIRFailNumber2}";
communityDayPIRFailNumberArray[2] = "${communityDayPIRFailNumberDTO.communityHourPIRFailNumber3}";
communityDayPIRFailNumberArray[3] = "${communityDayPIRFailNumberDTO.communityHourPIRFailNumber4}";
communityDayPIRFailNumberArray[4] = "${communityDayPIRFailNumberDTO.communityHourPIRFailNumber5}";
communityDayPIRFailNumberArray[5] = "${communityDayPIRFailNumberDTO.communityHourPIRFailNumber6}";
communityDayPIRFailNumberArray[6] = "${communityDayPIRFailNumberDTO.communityHourPIRFailNumber7}";
communityDayPIRFailNumberArray[7] = "${communityDayPIRFailNumberDTO.communityHourPIRFailNumber8}";
communityDayPIRFailNumberArray[8] = "${communityDayPIRFailNumberDTO.communityHourPIRFailNumber9}";
communityDayPIRFailNumberArray[9] = "${communityDayPIRFailNumberDTO.communityHourPIRFailNumber10}";
communityDayPIRFailNumberArray[10] = "${communityDayPIRFailNumberDTO.communityHourPIRFailNumber11}";
communityDayPIRFailNumberArray[11] = "${communityDayPIRFailNumberDTO.communityHourPIRFailNumber12}";
communityDayPIRFailNumberArray[12] = "${communityDayPIRFailNumberDTO.communityHourPIRFailNumber13}";
communityDayPIRFailNumberArray[13] = "${communityDayPIRFailNumberDTO.communityHourPIRFailNumber14}";
communityDayPIRFailNumberArray[14] = "${communityDayPIRFailNumberDTO.communityHourPIRFailNumber15}";
communityDayPIRFailNumberArray[15] = "${communityDayPIRFailNumberDTO.communityHourPIRFailNumber16}";
communityDayPIRFailNumberArray[16] = "${communityDayPIRFailNumberDTO.communityHourPIRFailNumber17}";
communityDayPIRFailNumberArray[17] = "${communityDayPIRFailNumberDTO.communityHourPIRFailNumber18}";
communityDayPIRFailNumberArray[18] = "${communityDayPIRFailNumberDTO.communityHourPIRFailNumber19}";
communityDayPIRFailNumberArray[19] = "${communityDayPIRFailNumberDTO.communityHourPIRFailNumber20}";
communityDayPIRFailNumberArray[20] = "${communityDayPIRFailNumberDTO.communityHourPIRFailNumber21}";
communityDayPIRFailNumberArray[21] = "${communityDayPIRFailNumberDTO.communityHourPIRFailNumber22}";
communityDayPIRFailNumberArray[22] = "${communityDayPIRFailNumberDTO.communityHourPIRFailNumber23}";
communityDayPIRFailNumberArray[23] = "${communityDayPIRFailNumberDTO.communityHourPIRFailNumber24}";
//console.log("communityDayPIRFailNumberArray after:" + communityDayPIRFailNumberArray);
//console.log("communityDayPIRFailNumberArray after length:" + communityDayPIRFailNumberArray.length);
drawDayPIRFailNumber(communityDayPIRFailNumberArray);
//画Hours的X轴的OCP的次数
function drawDayPIRFailNumber(communityDayPIRFailNumberArray){
context.lineWidth = 5;
context.strokeStyle = "#00BFFF";
for(var i=1;i<=communityDayPIRFailNumberArray.length;i++){
var j = 9*parseInt(communityDayPIRFailNumberArray[i-1]);
if(j>180){
j=180;
}else if(j<0){
j=0;
}
//console.log("j:" + j);
context.beginPath();
context.moveTo(45*i+10-0.5,298);
context.lineTo(45*i+10-0.5,298-j);
context.stroke();
}
}
var monthOVPNumberArray =new Array();
//console.log("monthOVPNumberArray before:" + monthOVPNumberArray);
//console.log("monthOVPNumberArray before length:" + monthOVPNumberArray.length);
monthOVPNumberArray[0] = "${communityMonthOVPNumberDTO.comumunityDayOVPNumber1}";
monthOVPNumberArray[1] = "${communityMonthOVPNumberDTO.comumunityDayOVPNumber2}";
monthOVPNumberArray[2] = "${communityMonthOVPNumberDTO.comumunityDayOVPNumber3}";
monthOVPNumberArray[3] = "${communityMonthOVPNumberDTO.comumunityDayOVPNumber4}";
monthOVPNumberArray[4] = "${communityMonthOVPNumberDTO.comumunityDayOVPNumber5}";
monthOVPNumberArray[5] = "${communityMonthOVPNumberDTO.comumunityDayOVPNumber6}";
monthOVPNumberArray[6] = "${communityMonthOVPNumberDTO.comumunityDayOVPNumber7}";
monthOVPNumberArray[7] = "${communityMonthOVPNumberDTO.comumunityDayOVPNumber8}";
monthOVPNumberArray[8] = "${communityMonthOVPNumberDTO.comumunityDayOVPNumber9}";
monthOVPNumberArray[9] = "${communityMonthOVPNumberDTO.comumunityDayOVPNumber10}";
monthOVPNumberArray[10] = "${communityMonthOVPNumberDTO.comumunityDayOVPNumber11}";
monthOVPNumberArray[11] = "${communityMonthOVPNumberDTO.comumunityDayOVPNumber12}";
monthOVPNumberArray[12] = "${communityMonthOVPNumberDTO.comumunityDayOVPNumber13}";
monthOVPNumberArray[13] = "${communityMonthOVPNumberDTO.comumunityDayOVPNumber14}";
monthOVPNumberArray[14] = "${communityMonthOVPNumberDTO.comumunityDayOVPNumber15}";
monthOVPNumberArray[15] = "${communityMonthOVPNumberDTO.comumunityDayOVPNumber16}";
monthOVPNumberArray[16] = "${communityMonthOVPNumberDTO.comumunityDayOVPNumber17}";
monthOVPNumberArray[17] = "${communityMonthOVPNumberDTO.comumunityDayOVPNumber18}";
monthOVPNumberArray[18] = "${communityMonthOVPNumberDTO.comumunityDayOVPNumber19}";
monthOVPNumberArray[19] = "${communityMonthOVPNumberDTO.comumunityDayOVPNumber20}";
monthOVPNumberArray[20] = "${communityMonthOVPNumberDTO.comumunityDayOVPNumber21}";
monthOVPNumberArray[21] = "${communityMonthOVPNumberDTO.comumunityDayOVPNumber22}";
monthOVPNumberArray[22] = "${communityMonthOVPNumberDTO.comumunityDayOVPNumber23}";
monthOVPNumberArray[23] = "${communityMonthOVPNumberDTO.comumunityDayOVPNumber24}";
monthOVPNumberArray[24] = "${communityMonthOVPNumberDTO.comumunityDayOVPNumber25}";
monthOVPNumberArray[25] = "${communityMonthOVPNumberDTO.comumunityDayOVPNumber26}";
monthOVPNumberArray[26] = "${communityMonthOVPNumberDTO.comumunityDayOVPNumber27}";
monthOVPNumberArray[27] = "${communityMonthOVPNumberDTO.comumunityDayOVPNumber28}";
monthOVPNumberArray[28] = "${communityMonthOVPNumberDTO.comumunityDayOVPNumber29}";
monthOVPNumberArray[29] = "${communityMonthOVPNumberDTO.comumunityDayOVPNumber30}";
monthOVPNumberArray[30] = "${communityMonthOVPNumberDTO.comumunityDayOVPNumber31}";
//console.log("monthOVPNumberArray after:" + monthOVPNumberArray);
//console.log("monthOVPNumberArray after length:" + monthOVPNumberArray.length);
var monthDays = "${communityMonthOVPNumberDTO.days}";
//console.log("monthDays:" + monthDays);
//画Day的X轴的函数
drawXDayMark(monthDays);
//画Day的X轴的函数
function drawXDayMark(monthDays){
for(var i=1;i<=monthDays;i++){
//画刻度线
context.font = "12px Century Gothic";
context.fillStyle = "#C3C4C6";
context.fillText(i, 40+34*(i-1), 564);
}
}
drawMonthOVPNumber(monthOVPNumberArray,monthDays);
//画Days的X轴的Consumption
function drawMonthOVPNumber(monthOVPNumberArray,monthDays){
context.lineWidth = 5;
context.strokeStyle = "#FF69B4";
for(var i=1;i<=monthDays;i++){
var j = 4.5*parseInt(monthOVPNumberArray[i-1]);
if(j>180){
j=180;
}else if(j<0){
j=0;
}
context.beginPath();
context.moveTo(45+34*(i-1)-0.5,548);
context.lineTo(45+34*(i-1)-0.5,548-j);
context.stroke();
}
}
var communityMonthOCPNumberArray =new Array();
//console.log("communityMonthOCPNumberArray before:" + communityMonthOCPNumberArray);
//console.log("communityMonthOCPNumberArray before length:" + communityMonthOCPNumberArray.length);
communityMonthOCPNumberArray[0] = "${communityMonthOCPNumberDTO.comumunityDayOCPNumber1}";
communityMonthOCPNumberArray[1] = "${communityMonthOCPNumberDTO.comumunityDayOCPNumber2}";
communityMonthOCPNumberArray[2] = "${communityMonthOCPNumberDTO.comumunityDayOCPNumber3}";
communityMonthOCPNumberArray[3] = "${communityMonthOCPNumberDTO.comumunityDayOCPNumber4}";
communityMonthOCPNumberArray[4] = "${communityMonthOCPNumberDTO.comumunityDayOCPNumber5}";
communityMonthOCPNumberArray[5] = "${communityMonthOCPNumberDTO.comumunityDayOCPNumber6}";
communityMonthOCPNumberArray[6] = "${communityMonthOCPNumberDTO.comumunityDayOCPNumber7}";
communityMonthOCPNumberArray[7] = "${communityMonthOCPNumberDTO.comumunityDayOCPNumber8}";
communityMonthOCPNumberArray[8] = "${communityMonthOCPNumberDTO.comumunityDayOCPNumber9}";
communityMonthOCPNumberArray[9] = "${communityMonthOCPNumberDTO.comumunityDayOCPNumber10}";
communityMonthOCPNumberArray[10] = "${communityMonthOCPNumberDTO.comumunityDayOCPNumber11}";
communityMonthOCPNumberArray[11] = "${communityMonthOCPNumberDTO.comumunityDayOCPNumber12}";
communityMonthOCPNumberArray[12] = "${communityMonthOCPNumberDTO.comumunityDayOCPNumber13}";
communityMonthOCPNumberArray[13] = "${communityMonthOCPNumberDTO.comumunityDayOCPNumber14}";
communityMonthOCPNumberArray[14] = "${communityMonthOCPNumberDTO.comumunityDayOCPNumber15}";
communityMonthOCPNumberArray[15] = "${communityMonthOCPNumberDTO.comumunityDayOCPNumber16}";
communityMonthOCPNumberArray[16] = "${communityMonthOCPNumberDTO.comumunityDayOCPNumber17}";
communityMonthOCPNumberArray[17] = "${communityMonthOCPNumberDTO.comumunityDayOCPNumber18}";
communityMonthOCPNumberArray[18] = "${communityMonthOCPNumberDTO.comumunityDayOCPNumber19}";
communityMonthOCPNumberArray[19] = "${communityMonthOCPNumberDTO.comumunityDayOCPNumber20}";
communityMonthOCPNumberArray[20] = "${communityMonthOCPNumberDTO.comumunityDayOCPNumber21}";
communityMonthOCPNumberArray[21] = "${communityMonthOCPNumberDTO.comumunityDayOCPNumber22}";
communityMonthOCPNumberArray[22] = "${communityMonthOCPNumberDTO.comumunityDayOCPNumber23}";
communityMonthOCPNumberArray[23] = "${communityMonthOCPNumberDTO.comumunityDayOCPNumber24}";
communityMonthOCPNumberArray[24] = "${communityMonthOCPNumberDTO.comumunityDayOCPNumber25}";
communityMonthOCPNumberArray[25] = "${communityMonthOCPNumberDTO.comumunityDayOCPNumber26}";
communityMonthOCPNumberArray[26] = "${communityMonthOCPNumberDTO.comumunityDayOCPNumber27}";
communityMonthOCPNumberArray[27] = "${communityMonthOCPNumberDTO.comumunityDayOCPNumber28}";
communityMonthOCPNumberArray[28] = "${communityMonthOCPNumberDTO.comumunityDayOCPNumber29}";
communityMonthOCPNumberArray[29] = "${communityMonthOCPNumberDTO.comumunityDayOCPNumber30}";
communityMonthOCPNumberArray[30] = "${communityMonthOCPNumberDTO.comumunityDayOCPNumber31}";
//console.log("communityMonthOCPNumberArray after:" + communityMonthOCPNumberArray);
//console.log("communityMonthOCPNumberArray after length:" + communityMonthOCPNumberArray.length);
drawMonthOCPNumber(communityMonthOCPNumberArray,monthDays);
//画Days的X轴的Consumption
function drawMonthOCPNumber(communityMonthOCPNumberArray){
context.lineWidth = 5;
context.strokeStyle = "#228B22";
for(var i=1;i<=monthDays;i++){
var j = 4.5*parseInt(communityMonthOCPNumberArray[i-1]);
if(j>180){
j=180;
}else if(j<0){
j=0;
}
context.beginPath();
context.moveTo(45+34*(i-1)+5-0.5,548);
context.lineTo(45+34*(i-1)+5-0.5,548-j);
context.stroke();
}
}
var communityMonthPIRFailNumberArray =new Array();
//console.log("communityMonthPIRFailNumberArray before:" + communityMonthPIRFailNumberArray);
//console.log("communityMonthPIRFailNumberArray before length:" + communityMonthPIRFailNumberArray.length);
communityMonthPIRFailNumberArray[0] = "${communityMonthPIRFailNumberDTO.comumunityDayPIRFailNumber1}";
communityMonthPIRFailNumberArray[1] = "${communityMonthPIRFailNumberDTO.comumunityDayPIRFailNumber2}";
communityMonthPIRFailNumberArray[2] = "${communityMonthPIRFailNumberDTO.comumunityDayPIRFailNumber3}";
communityMonthPIRFailNumberArray[3] = "${communityMonthPIRFailNumberDTO.comumunityDayPIRFailNumber4}";
communityMonthPIRFailNumberArray[4] = "${communityMonthPIRFailNumberDTO.comumunityDayPIRFailNumber5}";
communityMonthPIRFailNumberArray[5] = "${communityMonthPIRFailNumberDTO.comumunityDayPIRFailNumber6}";
communityMonthPIRFailNumberArray[6] = "${communityMonthPIRFailNumberDTO.comumunityDayPIRFailNumber7}";
communityMonthPIRFailNumberArray[7] = "${communityMonthPIRFailNumberDTO.comumunityDayPIRFailNumber8}";
communityMonthPIRFailNumberArray[8] = "${communityMonthPIRFailNumberDTO.comumunityDayPIRFailNumber9}";
communityMonthPIRFailNumberArray[9] = "${communityMonthPIRFailNumberDTO.comumunityDayPIRFailNumber10}";
communityMonthPIRFailNumberArray[10] = "${communityMonthPIRFailNumberDTO.comumunityDayPIRFailNumber11}";
communityMonthPIRFailNumberArray[11] = "${communityMonthPIRFailNumberDTO.comumunityDayPIRFailNumber12}";
communityMonthPIRFailNumberArray[12] = "${communityMonthPIRFailNumberDTO.comumunityDayPIRFailNumber13}";
communityMonthPIRFailNumberArray[13] = "${communityMonthPIRFailNumberDTO.comumunityDayPIRFailNumber14}";
communityMonthPIRFailNumberArray[14] = "${communityMonthPIRFailNumberDTO.comumunityDayPIRFailNumber15}";
communityMonthPIRFailNumberArray[15] = "${communityMonthPIRFailNumberDTO.comumunityDayPIRFailNumber16}";
communityMonthPIRFailNumberArray[16] = "${communityMonthPIRFailNumberDTO.comumunityDayPIRFailNumber17}";
communityMonthPIRFailNumberArray[17] = "${communityMonthPIRFailNumberDTO.comumunityDayPIRFailNumber18}";
communityMonthPIRFailNumberArray[18] = "${communityMonthPIRFailNumberDTO.comumunityDayPIRFailNumber19}";
communityMonthPIRFailNumberArray[19] = "${communityMonthPIRFailNumberDTO.comumunityDayPIRFailNumber20}";
communityMonthPIRFailNumberArray[20] = "${communityMonthPIRFailNumberDTO.comumunityDayPIRFailNumber21}";
communityMonthPIRFailNumberArray[21] = "${communityMonthPIRFailNumberDTO.comumunityDayPIRFailNumber22}";
communityMonthPIRFailNumberArray[22] = "${communityMonthPIRFailNumberDTO.comumunityDayPIRFailNumber23}";
communityMonthPIRFailNumberArray[23] = "${communityMonthPIRFailNumberDTO.comumunityDayPIRFailNumber24}";
communityMonthPIRFailNumberArray[24] = "${communityMonthPIRFailNumberDTO.comumunityDayPIRFailNumber25}";
communityMonthPIRFailNumberArray[25] = "${communityMonthPIRFailNumberDTO.comumunityDayPIRFailNumber26}";
communityMonthPIRFailNumberArray[26] = "${communityMonthPIRFailNumberDTO.comumunityDayPIRFailNumber27}";
communityMonthPIRFailNumberArray[27] = "${communityMonthPIRFailNumberDTO.comumunityDayPIRFailNumber28}";
communityMonthPIRFailNumberArray[28] = "${communityMonthPIRFailNumberDTO.comumunityDayPIRFailNumber29}";
communityMonthPIRFailNumberArray[29] = "${communityMonthPIRFailNumberDTO.comumunityDayPIRFailNumber30}";
communityMonthPIRFailNumberArray[30] = "${communityMonthPIRFailNumberDTO.comumunityDayPIRFailNumber31}";
//console.log("communityMonthPIRFailNumberArray after:" + communityMonthPIRFailNumberArray);
//console.log("communityMonthPIRFailNumberArray after length:" + communityMonthPIRFailNumberArray.length);
drawMonthPIRFailNumber(communityMonthPIRFailNumberArray,monthDays);
//画Days的X轴的Consumption
function drawMonthPIRFailNumber(communityMonthPIRFailNumberArray){
context.lineWidth = 5;
context.strokeStyle = "#00BFFF";
for(var i=1;i<=monthDays;i++){
var j = 4.5*parseInt(communityMonthPIRFailNumberArray[i-1]);
if(j>180){
j=180;
}else if(j<0){
j=0;
}
context.beginPath();
context.moveTo(45+34*(i-1)+10-0.5,548);
context.lineTo(45+34*(i-1)+10-0.5,548-j);
context.stroke();
}
}
//画Month的x轴的函数
function drawXMonthMark(){
for(var i=0;i<12;i++){
//画刻度线
context.font = "12px Century Gothic";
context.fillStyle = "#C3C4C6";
context.fillText((i+1), 40+94*i, 814);
}
}
var communityYearOVPNumberArray =new Array();
//console.log("communityYearOVPNumberArray before:" + communityYearOVPNumberArray);
//console.log("communityYearOVPNumberArray before length:" + communityYearOVPNumberArray.length);
communityYearOVPNumberArray[0] = "${communityYearOVPNumberDTO.communityMonthOVPNumber1}";
communityYearOVPNumberArray[1] = "${communityYearOVPNumberDTO.communityMonthOVPNumber2}";
communityYearOVPNumberArray[2] = "${communityYearOVPNumberDTO.communityMonthOVPNumber3}";
communityYearOVPNumberArray[3] = "${communityYearOVPNumberDTO.communityMonthOVPNumber4}";
communityYearOVPNumberArray[4] = "${communityYearOVPNumberDTO.communityMonthOVPNumber5}";
communityYearOVPNumberArray[5] = "${communityYearOVPNumberDTO.communityMonthOVPNumber6}";
communityYearOVPNumberArray[6] = "${communityYearOVPNumberDTO.communityMonthOVPNumber7}";
communityYearOVPNumberArray[7] = "${communityYearOVPNumberDTO.communityMonthOVPNumber8}";
communityYearOVPNumberArray[8] = "${communityYearOVPNumberDTO.communityMonthOVPNumber9}";
communityYearOVPNumberArray[9] = "${communityYearOVPNumberDTO.communityMonthOVPNumber10}";
communityYearOVPNumberArray[10] = "${communityYearOVPNumberDTO.communityMonthOVPNumber11}";
communityYearOVPNumberArray[11] = "${communityYearOVPNumberDTO.communityMonthOVPNumber12}";
//console.log("communityYearOVPNumberArray after:" + communityYearOVPNumberArray);
//console.log("communityYearOVPNumberArray after length:" + communityYearOVPNumberArray.length);
drawYearOVPNumber(communityYearOVPNumberArray);
//画Year的X轴的OVP次数
function drawYearOVPNumber(communityYearOVPNumberArray){
context.lineWidth = 5;
context.strokeStyle = "#FF69B4";
for(var i=1;i<=monthDays;i++){
var j = 2.25*parseInt(communityYearOVPNumberArray[i-1]);
if(j>180){
j=180;
}else if(j<0){
j=0;
}
context.beginPath();
context.moveTo(45+94*(i-1)-0.5,798);
context.lineTo(45+94*(i-1)-0.5,798-j);
context.stroke();
}
}
var communityYearOCPNumberArray =new Array();
//console.log("communityYearOCPNumberArray before:" + communityYearOCPNumberArray);
//console.log("communityYearOCPNumberArray before length:" + communityYearOCPNumberArray.length);
communityYearOCPNumberArray[0] = "${communityYearOCPNumberDTO.communityMonthOCPNumber1}";
communityYearOCPNumberArray[1] = "${communityYearOCPNumberDTO.communityMonthOCPNumber2}";
communityYearOCPNumberArray[2] = "${communityYearOCPNumberDTO.communityMonthOCPNumber3}";
communityYearOCPNumberArray[3] = "${communityYearOCPNumberDTO.communityMonthOCPNumber4}";
communityYearOCPNumberArray[4] = "${communityYearOCPNumberDTO.communityMonthOCPNumber5}";
communityYearOCPNumberArray[5] = "${communityYearOCPNumberDTO.communityMonthOCPNumber6}";
communityYearOCPNumberArray[6] = "${communityYearOCPNumberDTO.communityMonthOCPNumber7}";
communityYearOCPNumberArray[7] = "${communityYearOCPNumberDTO.communityMonthOCPNumber8}";
communityYearOCPNumberArray[8] = "${communityYearOCPNumberDTO.communityMonthOCPNumber9}";
communityYearOCPNumberArray[9] = "${communityYearOCPNumberDTO.communityMonthOCPNumber10}";
communityYearOCPNumberArray[10] = "${communityYearOCPNumberDTO.communityMonthOCPNumber11}";
communityYearOCPNumberArray[11] = "${communityYearOCPNumberDTO.communityMonthOCPNumber12}";
//console.log("communityYearOCPNumberArray after:" + communityYearOCPNumberArray);
//console.log("communityYearOCPNumberArray after length:" + communityYearOCPNumberArray.length);
drawYearOCPNumber(communityYearOCPNumberArray);
//画Year的X轴的OCP次数
function drawYearOCPNumber(communityYearOCPNumberArray){
context.lineWidth = 5;
context.strokeStyle = "#228B22";
for(var i=1;i<=monthDays;i++){
var j = 2.25*parseInt(communityYearOCPNumberArray[i-1]);
if(j>180){
j=180;
}else if(j<0){
j=0;
}
context.beginPath();
context.moveTo(45+94*(i-1)+5-0.5,798);
context.lineTo(45+94*(i-1)+5-0.5,798-j);
context.stroke();
}
}
var communityYearPIRFailNumberArray =new Array();
//console.log("communityYearPIRFailNumberArray before:" + communityYearPIRFailNumberArray);
//console.log("communityYearPIRFailNumberArray before length:" + communityYearPIRFailNumberArray.length);
communityYearPIRFailNumberArray[0] = "${communityYearPIRFailNumberDTO.communityMonthPIRFailNumber1}";
communityYearPIRFailNumberArray[1] = "${communityYearPIRFailNumberDTO.communityMonthPIRFailNumber2}";
communityYearPIRFailNumberArray[2] = "${communityYearPIRFailNumberDTO.communityMonthPIRFailNumber3}";
communityYearPIRFailNumberArray[3] = "${communityYearPIRFailNumberDTO.communityMonthPIRFailNumber4}";
communityYearPIRFailNumberArray[4] = "${communityYearPIRFailNumberDTO.communityMonthPIRFailNumber5}";
communityYearPIRFailNumberArray[5] = "${communityYearPIRFailNumberDTO.communityMonthPIRFailNumber6}";
communityYearPIRFailNumberArray[6] = "${communityYearPIRFailNumberDTO.communityMonthPIRFailNumber7}";
communityYearPIRFailNumberArray[7] = "${communityYearPIRFailNumberDTO.communityMonthPIRFailNumber8}";
communityYearPIRFailNumberArray[8] = "${communityYearPIRFailNumberDTO.communityMonthPIRFailNumber9}";
communityYearPIRFailNumberArray[9] = "${communityYearPIRFailNumberDTO.communityMonthPIRFailNumber10}";
communityYearPIRFailNumberArray[10] = "${communityYearPIRFailNumberDTO.communityMonthPIRFailNumber11}";
communityYearPIRFailNumberArray[11] = "${communityYearPIRFailNumberDTO.communityMonthPIRFailNumber12}";
//console.log("communityYearPIRFailNumberArray after:" + communityYearPIRFailNumberArray);
//console.log("communityYearPIRFailNumberArray after length:" + communityYearPIRFailNumberArray.length);
drawYearPIRFailNumber(communityYearPIRFailNumberArray);
//画Year的X轴的PIRFail次数
function drawYearPIRFailNumber(communityYearPIRFailNumberArray){
context.lineWidth = 5;
context.strokeStyle = "#00BFFF";
for(var i=1;i<=monthDays;i++){
var j = 2.25*parseInt(communityYearPIRFailNumberArray[i-1]);
if(j>180){
j=180;
}else if(j<0){
j=0;
}
context.beginPath();
context.moveTo(45+94*(i-1)+10-0.5,798);
context.lineTo(45+94*(i-1)+10-0.5,798-j);
context.stroke();
}
}
}
/* usedOVPOCPCanvas ------------------------------------ end */
</script>
</div>
<!-- OVP & OCP & PIRFail -->
<div align="center">
<canvas id="ovpOcpPirFailCanvas" width="1200" height="900" >
Your browser does not support HTML5.
</canvas>
</div>
<!-- 4.first hr部分 -->
<div id="first_hr">
<div id="first_hr_left">
</div>
<div id="first_hr_right">
<hr align="center" width="800px" color="#b5b7b9">
</div>
</div>
<!-- 5.bottom copys部分 -->
<div id="bottom">
<p>
<font color="#c3c4d5">Copyright © 1986 - 2018</font>
<b>Aztech Group Ltd. All rights reserved.</b>
</p>
</div>
</div>
</body>
</html>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%@ page trimDirectiveWhitespaces="true"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="itheima" uri="http://itcast.cn/common/"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
+ path + "/";
String websocketPath = request.getServerName() + ":" + request.getServerPort() + path + "/";
String SchemeValue = request.getScheme();
%>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Config Page</title>
<style type="text/css">
html,body{
margin: 0px;
padding: 0px;
/* background-image: url(${pageContext.request.contextPath}/img/BG1.jpg); */
}
body{
background-image: url(${pageContext.request.contextPath}/img/BG1.jpg);
}
#container{
width:100%;
height:100%;
margin:auto;
}
#logo{
width:100%;
height:60px;
}
#top_left{
width:17.939394%;
height: 58px;
float: left;
}
#top_right{
width: 45%;
padding-top: 20px;
float:left;
}
#top_return{
width: 36.22%;
float: left;
}
.c7c7ca_color{
color: #FFF;
font-family: Century Gothic;
font-size: 24px;
}
/* ul li{
display: inline;
} */
#green_bar{
width:100%;
height:34.2px;
background-color: #15a2b3;
}
a{
text-decoration:none;
}
#return_to_homepage{
color:#5d5b5d;
}
/* D/E PIR Sensitivity */
.sensitivity{
width: 500px;
margin: 20px auto 40px;
height: 50px;
color: #686969;
/*border: 1px solid red;*/
}
.s_checkbox{
height: 50px;
float: left;
line-height: 50px;
font-family: Century Gothic;
color: #686969;
font-size: 18px;
/*border: 1px solid #ccc;*/
}
.s_checkbox input {
vertical-align: -2px;
}
.s_select{
margin-left: 5px;
margin-top: 5px;
float: left;
/*用div的样式代替select的样式*/
width: 100px;
height: 50px;
position: relative;
}
.s_select select{
width: 12em;
height: 2.2em;
padding: 0.2em 0.4em 0.2em 0.4em;
vertical-align : middle;
border: 1px solid #626462;
-moz-border-radius: 0.2em;
-webkit-border-radius: 0.2em;
border-radius: 0.2em;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
/* background: #F4F4F6; */
font-family: Century Gothic;
font-size: 1.1em;
color: #8D8E92;
cursor: pointer;
/* background: url(select_arrow.png) no-repeat right; */
background: #F4F4F6 url(${pageContext.request.contextPath}/img/select_arrow.png) no-repeat right;
}
.s_select select option:hover {
background-color: #f80;
color: #FFB6C1;
}
/* DIM Level */
.slide_father{
width: 559px;
height: 68px;
background-color: #E4E5E5;
margin: 0 auto;
position: relative;
border-radius: 29px;
box-shadow: 6px 6px 5px #888888;
}
.slide_son1{
width: 512px;
height: 40px;
background-color: #B3B2B3;
position: absolute;
left: 50%;
top: 14px;
margin-left: -256px;
border-radius: 22px;
box-shadow: 9px 9px 9px #999 inset;
}
.slide_son2{
width: 482px;
height: 16px;
FILTER: progid:DXImageTransform.Microsoft.Gradient(gradientType=0, startColorStr=#AC07BD, endColorStr=#f6f6f8); /*IE 6 7 8*/
background: -moz-linear-gradient(right, #545655 40%, #ffffff 100%);
background: -ms-linear-gradient(right, #545655, #ffffff);
background: -webkit-linear-gradient(right, #545655 40%,#ffffff 100%);
position: absolute;
left: 50%;
top: 26px;
margin-left: -241px;
border-radius: 12px;
/*box-shadow: -8px -8px 5px #888888;*/
box-shadow:8px 8px 8px #999 inset;
}
.slide_ball{
width: 22px;
height: 22px;
background-color: #45A265;
background: radial-gradient(circle,SeaGreen,DarkGreen,Green);
background: -ms-radial-gradient(circle,SeaGreen,DarkGreen,Green);
border-radius: 50%;
position: absolute;
left: 29px;
top: 22px;
box-shadow: 4px 4px 4px #888888;
}
.comment_father{
margin: 5px auto;
width: 526px;
height: 26px;
/*border: 1px solid red;*/
}
.comment_son1{
/*margin-left: 20px;*/
/*width: 742px;*/
height: 12px;
/*border: 1px solid green;*/
}
/* ul,li{
margin: 0;
padding: 0;
list-style: none;
} */
.comment_father ul,.comment_ps_father ul{
margin: 0;
padding: 0;
list-style: none;
}
.comment_son1 ul li{
float: left;
padding-right: 29px;
font-size: 12px;
line-height: 12px;
color: #28383A;
font-family: Century Gothic;
}
.comment_son1 ul li:first-child{
padding-left: 10px;
}
.comment_son1 ul li:last-child{
padding-right: 0;
}
.comment_son2{
margin-left: 5px;
height: 12px;
/*border: 1px solid blue;*/
}
.comment_son2 ul li{
float: left;
padding-right: 49px;
font-size: 12px;
line-height: 12px;
color: #28383A;
}
.comment_son2 ul li:first-child{
padding-left: 10px;
}
.comment_son2 ul li:last-child{
padding-right: 0;
}
.slide_title{
font-size: 14px;
font-family: Century Gothic;
color: #080;
position: absolute;
top: -19px;
left: -129px;
}
.dimLevel{
position: absolute;
font-size: 18px;
font-family: Century Gothic;
color: #f10215;
top: 24px;
left: 580px;
}
/* Photosensor Sensitivity */
.slide_photosensor_sensi{
width: 559px;
height: 68px;
background-color: #E4E5E5;
margin: 0 auto;
position: relative;
border-radius: 29px;
box-shadow: 6px 6px 5px #888888;
}
.slide_ps_son1{
width: 512px;
height: 40px;
background-color: #B3B2B3;
position: absolute;
left: 50%;
top: 14px;
margin-left: -256px;
border-radius: 22px;
box-shadow: 9px 9px 9px #999 inset;
}
.slide_ps_son2{
width: 482px;
height: 16px;
FILTER: progid:DXImageTransform.Microsoft.Gradient(gradientType=0, startColorStr=#AC07BD, endColorStr=#f6f6f8); /*IE 6 7 8*/
background: -moz-linear-gradient(right, #545655 40%, #ffffff 100%);
background: -ms-linear-gradient(right, #545655, #ffffff);
background: -webkit-linear-gradient(right, #545655 40%,#ffffff 100%);
position: absolute;
left: 50%;
top: 26px;
margin-left: -241px;
border-radius: 12px;
box-shadow:8px 8px 8px #999 inset;
}
.slide_ps_ball{
width: 22px;
height: 22px;
background-color: #45A265;
background: radial-gradient(circle,SeaGreen,DarkGreen,Green);
background: -ms-radial-gradient(circle,SeaGreen,DarkGreen,Green);
border-radius: 50%;
position: absolute;
left: 29px;
top: 22px;
box-shadow: 4px 4px 4px #888888;
}
.slide_ps_title{
font-size: 14px;
font-family: Century Gothic;
color: #080;
position: absolute;
top: -19px;
left: -195px;
}
.comment_ps_father{
margin: 40px auto 5px;
width: 640px;
height: 26px;
/*border: 1px solid red;*/
}
.comment_ps_son1{
height: 12px;
}
.comment_ps_son1 ul li{
float: left;
padding-right: 34.5px;
font-size: 12px;
line-height: 12px;
color: #28383A;
font-family: Century Gothic;
}
.comment_ps_son1 ul li:first-child{
padding-left: 69px;
}
.comment_ps_son1 ul li:last-child{
padding-right: 0;
}
.comment_ps_son2{
/*margin-left: 5px;*/
height: 12px;
/*border: 1px solid green;*/
}
.comment_ps_son2 ul li{
float: left;
padding-right: 39.5px;
font-size: 12px;
line-height: 12px;
color: #28383A;
font-family: Century Gothic;
}
.comment_ps_son2 ul li:first-child{
padding-left: 69px;
}
.comment_ps_son2 ul li:last-child{
padding-right: 0;
}
.photosensor{
position: absolute;
font-size: 18px;
font-family: Century Gothic;
color: #f10215;
top: 24px;
left: 580px;
}
/* Hold Time */
.hold_time{
margin: 40px auto 5px;
width: 600px;
height: 60px;
padding-left: 55px;
}
.hold_time .ht_input{
float: left;
text-align: center;
font-size: 18px;
font-family: Century Gothic;
color: #686969;
}
.hold_time .ht_input input{
width: 100px;
height: 40px;
border: 0 none;
outline-style: none;
border: 1px solid #D7D8DA;
font-size: 18px;
font-family: Century Gothic;
text-indent: 1.5em;
}
.hold_time .ht_input .ht_number{
font-size: 12px;
color: #f10215;
}
/* Schedule */
.schedule{
width: 600px;
margin: 0 auto 15px;
height: 50px;
/*border: 1px solid red;*/
}
.sche_checkbox{
margin-left: 26px;
height: 50px;
float: left;
line-height: 50px;
font-family: Century Gothic;
color: #686969;
font-size: 18px;
}
.sche_checkbox input {
vertical-align: -2px;
}
/* lightIntensity */
.lightIntensity{
width: 552px;
margin: 20px auto 25px;
height: 50px;
color: #686969;
/* border: 1px solid red; */
}
.title_lightIntensity{
height: 50px;
float: left;
line-height: 50px;
font-family: Century Gothic;
color: #686969;
font-size: 18px;
/*border: 1px solid #ccc;*/
}
.s_lightIntensity{
margin-left: 5px;
margin-top: 5px;
float: left;
/*用div的样式代替select的样式*/
width: 100px;
height: 50px;
position: relative;
}
.s_lightIntensity select{
width: 12em;
height: 2.2em;
padding: 0.2em 0.4em 0.2em 0.4em;
vertical-align : middle;
border: 1px solid #626462;
-moz-border-radius: 0.2em;
-webkit-border-radius: 0.2em;
border-radius: 0.2em;
-webkit-appearance: none;
-moz-appearance: none;
appearance: none;
/* background: #F4F4F6; */
font-family: Century Gothic;
font-size: 1.1em;
color: #8D8E92;
cursor: pointer;
/* background: url(select_arrow.png) no-repeat right; */
background: #F4F4F6 url(${pageContext.request.contextPath}/img/select_arrow.png) no-repeat right;
}
.s_lightIntensity select option:hover {
background-color: #f80;
color: #FFB6C1;
}
/* Month */
.month{
width: 800px;
margin: 0 auto;
height: 50px;
/*border: 1px solid red;*/
}
.month .winter_month{
width: 325px;
margin-left: 125px;
float: left;
/*text-align: center; */
font-size: 18px;
font-family: Century Gothic;
color: #686969;
/*border: 1px solid green;*/
}
.month .winter_month input{
width: 100px;
height: 40px;
border: 0 none;
outline-style: none;
border: 1px solid #D7D8DA;
font-size: 18px;
font-family: Century Gothic;
text-indent: 1.5em;
}
.month .summer_month{
width: 342px;
/*margin-left: 29px;*/
float: left;
font-size: 18px;
font-family: Century Gothic;
color: #686969;
/*border: 1px solid blue;*/
}
.month .summer_month input{
width: 100px;
height: 40px;
border: 0 none;
outline-style: none;
border: 1px solid #D7D8DA;
font-size: 18px;
font-family: Century Gothic;
text-indent: 1.5em;
}
.wm_number,.sm_number,.ws_number,.we_number{
font-size: 12px;
color: #f10215;
}
.winter_time{
width: 900px;
margin: 15px auto;
height: 50px;
/*border: 1px solid red;*/
}
.winter_time .winter_start{
width: 322px;
margin-left: 176px;
float: left;
font-size: 18px;
font-family: Century Gothic;
color: #686969;
/*border: 1px solid green;*/
}
.winter_time .winter_start input{
width: 120px;
height: 40px;
border: 0 none;
outline-style: none;
border: 1px solid #D7D8DA;
font-size: 18px;
font-family: Century Gothic;
text-indent: 0.5em;
}
.winter_time .winter_end{
width: 342px;
float: left;
font-size: 18px;
font-family: Century Gothic;
color: #686969;
/*border: 1px solid blue;*/
}
.winter_time .winter_end input{
width: 120px;
height: 40px;
border: 0 none;
outline-style: none;
border: 1px solid #D7D8DA;
font-size: 18px;
font-family: Century Gothic;
text-indent: 0.5em;
}
.summer_time{
width: 900px;
margin: 15px auto;
height: 50px;
/*border: 1px solid red;*/
}
.summer_time .summer_start{
width: 322px;
margin-left: 176px;
float: left;
font-size: 18px;
font-family: Century Gothic;
color: #686969;
/*border: 1px solid green;*/
}
.summer_time .summer_start input{
width: 110px;
height: 40px;
border: 0 none;
outline-style: none;
border: 1px solid #D7D8DA;
font-size: 18px;
font-family: Century Gothic;
/*text-indent: 0.5em;*/
}
.summer_time .summer_end{
width: 342px;
float: left;
font-size: 18px;
font-family: Century Gothic;
color: #686969;
/*border: 1px solid blue;*/
}
.summer_time .summer_end input{
width: 110px;
height: 40px;
border: 0 none;
outline-style: none;
border: 1px solid #D7D8DA;
font-size: 18px;
font-family: Century Gothic;
/*text-indent: 0.5em;*/
}
/* area_block_floor_light_info */
.area_block{
margin: 40px auto;
width: 400px;
height: 400px;
border: 1px solid #D7D8DA;
overflow: auto;
}
/* button */
.config_btn{
margin:20px auto 20px;
/* width:400px;
height:100px; */
text-align: center;
color: green;
}
.config_btn button{
width: 80px;
height: 29px;
color: green;
font-family: Century Gothic;
cursor: pointer;
text-decoration: none;
}
.feedback{
margin: 0 auto 20px;
/* width: 400px;
height: 400px; */
/*border: 1px solid red;*/
}
.feedback .info{
text-align: center;
height: 40px;
line-height: 40px;
font-family: Century Gothic;
color: #f10215;
/*border: 1px solid green;*/
}
.t_title{
margin: 0 auto;
height: 40px;
line-height: 40px;
text-align: center;
font-family: Century Gothic;
font-weight: 500;
color: #f10215;
border:1px solid #D7D8DA;
width:400px;
border-bottom: none;
}
.show_table{
margin: 0 auto;
width: 400px;
height: 250px;
/*border: 1px solid #D7D8DA;*/
overflow: auto;
border-top: none;
}
.show_table table{
/*border: 1px solid #686969;*/
border-collapse: collapse;
text-align: center;
font-family: Century Gothic;
color: #686969;
font-weight: 500;
width: 100%;
margin: 0;
border-spacing: 0;
}
.show_table td{
border: 1px solid #D7D8DA;
width: 25%;
height: 40px;
line-height: 40px;
padding: 0;
}
.show_table td.t_td{
font-size: 14px;
}
.show_table td.t_td.light span{
color: #f10215;
}
.resubmit{
margin: 20px auto;
text-align: center;
color: green;
}
.resubmit button{
width: 80px;
height: 29px;
color: green;
font-family: Century Gothic;
cursor: pointer;
text-decoration: none;
}
/* Configure Device Time */
.deviceTime{
width: 600px;
margin: 0 auto 15px;
height: 50px;
/*border: 1px solid red;*/
}
.deviceTime_checkbox{
margin-left: 26px;
height: 50px;
float: left;
line-height: 50px;
font-family: Century Gothic;
color: #686969;
font-size: 18px;
}
.deviceTime_checkbox input {
vertical-align: -2px;
}
/* Home Page */
.homePage{
position: absolute;
font-size: 18px;
font-family: Century Gothic;
color: #f10215;
top: -108px;
left: 618px;
width:250px;
height:100px;
}
.homePage .button{
border: none;
color: white;
text-align: center;
text-decoration: none;
display: inline-block;
font-size: 21px;
cursor: pointer;
border-radius:16px;
box-shadow: 0 8px 16px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19);
}
.homePage .button:hover {
box-shadow: 0 12px 16px 0 rgba(0,0,0,0.24),0 17px 50px 0 rgba(0,0,0,0.19);
}
.homePage .button4 {background-color: #ffa500; color: #008000;} /* Pink */
</style>
<!-- 导入easyui类库 -->
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/js/easyui/themes/default/easyui.css">
<link rel="stylesheet" type="text/css" href="${pageContext.request.contextPath }/js/easyui/themes/icon.css">
<script type="text/javascript" src="${pageContext.request.contextPath }/js/jquery-1.8.3.js"></script>
<script type="text/javascript" src="${pageContext.request.contextPath }/js/easyui/jquery.easyui.min.js"></script>
<link rel="stylesheet" href="${pageContext.request.contextPath}/js/ztree/zTreeStyle.css" type="text/css">
<script type="text/javascript" src="${pageContext.request.contextPath}/js/ztree/jquery.ztree.all-3.5.js"></script>
<script type="text/javascript">
// DIM Level
$(function(){
var $slide = $(".slide_father");
var $bar = $(".slide_son2");
var $ball = $(".slide_ball");
var $dimLevel = $(".dimLevel");
var ballLeft = $ball.position().left;
var startX = 29;
var width = $bar.width();
// 跃进功能
$bar.on('click',function(e){
// 获取点击的位置和进度条宽度的比例
// 通过比例去计算播放时间
// e.offsetX e.offsetY 当前点击的地方 距离坐标的左边和上边的坐标
//相对于当前元素的
var barX = e.offsetX + 20;
if(barX>=495){
barX = 495;
}
$ball.css("left",barX);
ballLeft = $ball.position().left;
if(ballLeft>=495){
ballLeft = 495;
}
//这里加10是因为从10%开始标识的
var ratio = Math.floor(((ballLeft-40)/width)*100+10);
if(ratio<=10){
ratio = 10;
}else if(ratio>=100){
ratio = 100;
}
$('.dimLevel').html(ratio);
});
//滑动:进度条拖拽
var ball = $ball.get(0);
var slide = $slide.get(0);
var bar = $bar.get(0);
ball.onmousedown = function(){
// console.log(bar.offsetWidth);
document.onmousemove = function(e){
var leftv = e.clientX - bar.offsetLeft - slide.offsetLeft;
if(leftv<=0){
leftv = 0;
}else if(leftv>=452){
leftv = 452;
}
var ratio2 = Math.floor((leftv/width)*100+10);
// console.log('ratio2',ratio2);
leftv = leftv + 29;
ball.style.left = leftv + 'px';
if(ratio2<=10){
ratio2 = 10;
}else if(ratio2>=100){
ratio2 = 100;
}
$('.dimLevel').html(ratio2);
};
document.onmouseup = function(){
document.onmousemove = null;
document.onmouseup = null;
};
};
});
// Photosensor Sensitivity
$(function(){
var $ps_slide = $(".slide_photosensor_sensi");
var $ps_bar = $(".slide_ps_son2");
var $ps_ball = $(".slide_ps_ball");
var $photosensor = $(".photosensor");
// var ballLeft = $ps_ball.position().left;
var startX = 29;
var width = $ps_bar.width();
//点击跃进功能
$ps_bar.on('click',function(e){
var barX = e.offsetX + 20;
if(barX>=500){
barX = 500;
}
$ps_ball.css("left",barX);
var ballLeft = $ps_ball.position().left;
if(ballLeft>=500){
ballLeft = 500;
}
//这里是从0开始的
var ratio = Math.floor(((ballLeft-15)/width)*100);
if(ratio<=0){
ratio = 0;
}else if(ratio>100){
ratio = 100;
}
$('.photosensor').html(ratio);
});
//滑动:进度条拖拽
var ps_ball = $ps_ball.get(0);
var ps_slide = $ps_slide.get(0);
var ps_bar = $ps_bar.get(0);
ps_ball.onmousedown = function(){
document.onmousemove = function(e){
var leftv = e.clientX - ps_bar.offsetLeft - ps_slide.offsetLeft;
if(leftv<=0){
leftv = 0;
}else if(leftv>=482){
leftv = 482;
}
var ratio2 = Math.floor((leftv/width)*100);
leftv = leftv + 29;
ps_ball.style.left = leftv + 'px';
if(ratio2<=0){
ratio2 = 0;
}else if(ratio2>=100){
ratio2 = 100;
}
$('.photosensor').html(ratio2);
};
document.onmouseup = function(){
document.onmousemove = null;
document.onmouseup = null;
};
};
});
//Hold Time
$(function(){
var ht_input = $(".hold_time .ht_input input");
ht_input.on('blur',function(){
var holdtime = ht_input.val();
if(holdtime<5 || holdtime>255){
$(".hold_time .ht_input .ht_number").html('Invalid number');
$.messager.alert('Messager','Hold Time Input Number should be between 5 and 255!','info');
}else{
$(".hold_time .ht_input .ht_number").html('');
}
});
});
//Winter Month && Summer Month
$(function(){
var $wintermonth = $("#wintermonth");
var flag = false;
$wintermonth.on('blur',function(){
var wintermonth = $wintermonth.val();
if(wintermonth<1 || wintermonth>12){
flag = false;
$(".wm_number").html('Invalid Number');
$.messager.alert('Messager','Winter Month Number should between 1 and 12!','info');
}else{
flag = true;
$(".wm_number").html('');
}
if(flag){
if(!/^\d+$/.test(wintermonth)){
$(".wm_number").html('Invalid Number');
$.messager.alert('Messager','This number must be integer!','info');
}else{
$(".wm_number").html('');
}
}
});
var $summermonth = $("#summermonth");
var flag = false;
$summermonth.on('blur',function(){
var summermonth = $summermonth.val();
if(summermonth<1 || summermonth>12){
flag = false;
$(".sm_number").html('Invalid Number');
$.messager.alert('Messager','Summer Month Number should between 1 and 12!','info');
}else{
flag = true;
$(".sm_number").html('');
}
if(flag){
if(!/^\d+$/.test(summermonth)){
$(".sm_number").html('Invalid Number');
$.messager.alert('Messager','This number must be integer!','info');
}else{
$(".sm_number").html('');
}
}
});
});
/* ztree实现层级area_block_floor_light_info */
$(function(){
//初始化输入框的值
$("#winterstart").val("08:00");
$("#winterend").val("17:30");
$("#summerstart").val("07:00");
$("#summerend").val("19:00");
var setting2 = {
data: {
simpleData: {
enable: true //使用简单json数据构造ztree节点
}
},
check: {
enable: true
},
view: {
fontCss : {color:"#000"}
},
callback:{
onCheck: zTreeOnCheck
}
};
setting2.check.chkboxType = { "Y" : "ps", "N" : "ps" };
//发送ajax请求,获取json数据
//jquery提供的ajax方法:ajax,post,get,load,getJSON,getScript
//var url = "${pageContext.request.contextPath}/json/menu.json";
var url = "${pageContext.request.contextPath}/showZtreeMenu.action";
$.post(url,{},function(data){
//console.log('data',data);
//调用API初始化ztree
$.fn.zTree.init($("#ztree2"), setting2, data);
},'json');
});
function zTreeOnCheck(){
refreshLayers();
clearCheckedOldNodes();
}
//刷新图层的显示情况
var layers;
function refreshLayers() {
var zTree = $.fn.zTree.getZTreeObj("ztree2");
var changedNodes = zTree.getChangeCheckedNodes();
for ( var i=0 ; i < changedNodes.length ; i++ ){
var treeNode = changedNodes[i];
}
}
//清理善后工作
function clearCheckedOldNodes() {
var zTree = $.fn.zTree.getZTreeObj("ztree2"),
nodes = zTree.getChangeCheckedNodes();
for (var i=0, l=nodes.length; i<l; i++) {
nodes[i].checkedOld = nodes[i].checked;
}
};
$(function(){
$("#config_param").on("click",function(){
var flag = true;
//1.eventID(这个是作为唯一标识)
var myData = new Date();
var eventId = myData.getTime();//当前时间的毫秒数
//console.log(eventID);
var treeObj = $.fn.zTree.getZTreeObj("ztree2");
var list = treeObj.getCheckedNodes(true); //获取选中的节点,如果只有部分子节点被选中了,父节点也会被选中,过滤掉父节点
if (list && list.length > 0) {
// 清空原数据
var array = new Array();
for (var i = 0; i < list.length; i++) {
if(list[i].level!=0){
// 过滤父节点,nodes[i].getCheckStatus().half===true表示是半选中
if (list[i].getCheckStatus().half != true && list[i].getParentNode().checked==true
&& list[i].getParentNode().getCheckStatus().half!=false) {
array.push(list[i].id);
}
}else if(list[i].level==0){
// 过滤父节点,nodes[i].getCheckStatus().half===true表示是半选中
if (list[i].getCheckStatus().half != true) {
array.push(list[i].id);
}
}
};
}
// console.log("array:",array);
var jsonId = [];
if(array==undefined){
flag = false;
$.messager.alert('Messager','Please select the lights you need config!','info');
return;
}else{
for (var i = 0; i < array.length; i++) {
var j = {};
var id = array[i];
//console.log("id",id);
if(id.indexOf("community")!=-1){
j.whatId = "1";
j.idValue = id.substring(9);
//console.log("community");
}else if(id.indexOf("block")!=-1){
j.whatId = "2";
j.idValue = id.substring(5);
//console.log("block");
}else if(id.indexOf("floor")!=-1){
j.whatId = "3";
j.idValue = id.substring(5);
//console.log("floor");
}else if(id.indexOf("light")!=-1){
j.whatId = "4";
j.idValue = id.substring(5);
//console.log("light");
}
jsonId.push(j);
}
}
// console.log(jsonID);
//2.PIR
var pirObj = $("#pirEnable").get(0);
if(pirObj.checked){
var pir = 1;
}else{
var pir = 0;
}
//4.dimLvl
var dimLevel = $('.dimLevel').text().trim();
dimLevel = parseInt(dimLevel);
// console.log(dimLevel);
//5.holdtime
var holdtime = $("#holdtime").val().trim();
holdtime = parseInt(holdtime);
// console.log("holdtime",holdtime);
//6.PIRSen
var pirSen = $("#s_sensitivity option:selected").val().trim();
pirSen = parseInt(pirSen);
// console.log(pirSen);
//8.photoLvl
var photoLvl = $(".photosensor").text().trim();
photoLvl = parseInt(photoLvl);
//9.RTC
var rtcObj = $("#rtc").get(0);
if(rtcObj.checked){
var rtc = 1;
}else{
var rtc = 0;
}
// console.log("RTC",rtc);
//10.wintermonth
var wintermonth = $("#wintermonth").val().trim();
wintermonth = parseInt(wintermonth);
// console.log(wintermonth);
//11.summermonth
var summermonth = $("#summermonth").val().trim();
summermonth = parseInt(summermonth);
//12.deviceTime
var deviceTimeObj = $("#deviceTime").get(0);
if(deviceTimeObj.checked){
var deviceTime = 1;
}else{
var deviceTime = 0;
}
console.log("deviceTime",deviceTime);
function getStrTime(time){
var array = time.split(':');
var hour = array[0];
var minute = array[1];
strTime = hour + minute;
return strTime;
}
//12.WT
var wst = $("#winterstart").val().trim();
wst = getStrTime(wst);
//console.log("wst",wst);
var wet = $("#winterend").val().trim();
wet = getStrTime(wet);
var wt = wst + wet;
//console.log("WT",wt);
//14.ST
var sst = $("#summerstart").val().trim();
sst = getStrTime(sst);
//console.log("sst",sst);
var set = $("#summerend").val().trim();
set = getStrTime(set);
//console.log("set",set);
var st = sst + set;
//console.log("ST",st);
//15.userId
var userId = ${currentUser.userId};
//console.log("userId",userId);
//16.lightIntensity
var lightIntensity = $("#lightIntensity option:selected").val().trim();
lightIntensity = parseInt(lightIntensity);
console.log(lightIntensity);
var ws;
//这里的SPS100项目路径一定要带上,否则找不到。
var protocal = '<%=SchemeValue%>'=='http'?"ws://":"wss://";
console.info("protocal:" + protocal);
<%-- var target = "wss://"+ '<%=websocketPath%>' + "websocket/smartControl"; --%>
var target = protocal+ '<%=websocketPath%>' + "websocket/smartControl";
console.log("target:" + target);
if ('WebSocket' in window) {
ws = new WebSocket(target);
} else if ('MozWebSocket' in window) {
ws = new MozWebSocket(target);
} else {
alert('WebSocket is not supported by this browser.');
return;
}
var params = {
eventId:eventId,
messageCode:0,
jsonId:jsonId,
pir:pir,
dimLvl:dimLevel,
holdTime:holdtime,
pirSen:pirSen,
photoLvl:photoLvl,
rtc:rtc,
wm:wintermonth,
sm:summermonth,
wt:wt,
st:st,
deviceTime:deviceTime,
lightIntensity:lightIntensity,
userId:userId
};
ws.onopen = function(){
sendMessage();
};
console.log("params",params);
function sendMessage(){
//把json对象转成String
var str = JSON.stringify(params);
//console.info("params" + str);
//这里先演示传入一个字符串,后面会从数据库查询数,然后封装成一个json字符串对象传给后台广播给C程序
$.messager.confirm('Confirm','Are you sure to submit the config parameters?',function(r){
if(r){
ws.send(str);
//发送之后提示Ready to send data....
$(".info").html("Ready to send data to server....");
//每次发送一周都要清空错误数据
$("#table tr").eq(0).siblings().remove();
//提交的时候禁用按钮
document.getElementById('config_param').disabled = true;
document.getElementById('resubmit').disabled = true;
}else{
ws.close(); //关闭TCP连接
}
});
//这里是回调函数,websocket广播的json数据就是发送到这里
//应该在外面定义一个count统计变量,否则每次进来都会被初始化成0
var count = 0;
ws.onmessage = function(message){
eval("var msg = " + message.data + ";");
//console.info("msg",msg);
if(undefined!=msg.eventId && undefined!=msg.messageCode && eventId==msg.eventId){
console.log(msg.flag);
if(msg.flag!=undefined && msg.flag==1){
$(".info").html("The data is all assembled.....");
}else if(msg.flag!=undefined && msg.flag==2){
//这个其实如果是响应很快的话这个其实是不会执行的,但是实际上实惠执行的,因为处理总需要时间,而且C程序返回传输也需要时间
$(".info").html("All data was successfully sent....");
}
//(在这里可以做填充表格数据的代码)
//只有eventId一致并且code是100才是C程序响应给SPS100的
//console.log("eventId",eventId);
//console.log("msg.eventId",msg.eventId);
//console.log("count",count);
//console.log("msg.count",msg.count);
if(msg.messageCode==100){
count++;
console.log("count",count);
//这里就需要添加表格
console.log('lightId',msg.lightId);
if(msg.lightId!=undefined && msg.infoList!=undefined){
var infoList = msg.infoList;
console.log("infoList",infoList);
//遍历并添加表格
//遍历数组 for循环
for(var i=0;i<infoList.length;i++){
var lightId = infoList[i].lightId;
var lightName = infoList[i].lightName;
var floorName = infoList[i].floorName;
var blockName = infoList[i].blockName;
var communityName = infoList[i].communityName;
$("#table").append("<tr><td class=\"t_td light\"><span id=\""+lightId+"\">"+lightName+"</span></td><td class=\"t_td\">"+floorName+"</td><td class=\"t_td\">"+blockName+"</td><td class=\"t_td\">"+communityName+"</td></tr>");
}
}
}
//只有次数一致才能关闭连接,因为如果客户端为0也会断开
if(msg.count!=0 && msg.count==count){
$(".info").html("All lights are fully configured!....");
//关闭连接之前可以通知,如果infoList为0,说明没有失败的灯,这个时候可以告诉全部配置成功
var spanObjs = $("#table span");
//如果没有lihgt的列表,说明是没有配置失败
if(spanObjs.length==0){
$(".info").html("All configured successfully!");
}else{
$(".info").html("Some lights configured failed!");
}
//如果全部处理完毕两个按钮都要解禁
document.getElementById('config_param').disabled = false;
document.getElementById('resubmit').disabled = false;
ws.close(); //关闭TCP连接
}
//如果msg.count为0说明C程序是没有block连接上websocket服务
if(msg.count==0){
$(".info").html("No device connect the websocket service....");
//如果客户端没有连接两个按钮要解禁
document.getElementById('config_param').disabled = false;
document.getElementById('resubmit').disabled = false;
ws.close();
}
}
};
}
});
});
$(function(){
//Resubmit
$("#resubmit").on("click",function(){
var flag = true;
//1.eventID(这个是作为唯一标识)
var myData = new Date();
var eventId = myData.getTime();//当前时间的毫秒数
//console.log(eventID);
//2.PIR
var pirObj = $("#pirEnable").get(0);
if(pirObj.checked){
var pir = 1;
}else{
var pir = 0;
}
//4.dimLvl
var dimLevel = $('.dimLevel').text().trim();
dimLevel = parseInt(dimLevel);
// console.log(dimLevel);
//5.holdtime
var holdtime = $("#holdtime").val().trim();
holdtime = parseInt(holdtime);
// console.log("holdtime",holdtime);
//6.PIRSen
var pirSen = $("#s_sensitivity option:selected").val().trim();
pirSen = parseInt(pirSen);
// console.log(pirSen);
//8.photoLvl
var photoLvl = $(".photosensor").text().trim();
photoLvl = parseInt(photoLvl);
//9.RTC
var rtcObj = $("#rtc").get(0);
if(rtcObj.checked){
var rtc = 1;
}else{
var rtc = 0;
}
// console.log("RTC",rtc);
//10.wintermonth
var wintermonth = $("#wintermonth").val().trim();
wintermonth = parseInt(wintermonth);
// console.log(wintermonth);
//11.summermonth
var summermonth = $("#summermonth").val().trim();
summermonth = parseInt(summermonth);
function getStrTime(time){
var array = time.split(':');
var hour = array[0];
var minute = array[1];
strTime = hour + minute;
return strTime;
}
//12.deviceTime
var deviceTimeObj = $("#deviceTime").get(0);
if(deviceTimeObj.checked){
var deviceTime = 1;
}else{
var deviceTime = 0;
}
console.log("deviceTime",deviceTime);
//12.WT
var wst = $("#winterstart").val().trim();
wst = getStrTime(wst);
//console.log("wst",wst);
var wet = $("#winterend").val().trim();
wet = getStrTime(wet);
var wt = wst + wet;
//console.log("WT",wt);
//14.ST
var sst = $("#summerstart").val().trim();
sst = getStrTime(sst);
//console.log("sst",sst);
var set = $("#summerend").val().trim();
set = getStrTime(set);
//console.log("set",set);
var st = sst + set;
//console.log("ST",st);
//15.userId
var userId = ${currentUser.userId};
//console.log("userId",userId);
//16.lightIntensity
var lightIntensity = $("#lightIntensity option:selected").val().trim();
lightIntensity = parseInt(lightIntensity);
console.log(lightIntensity);
var spans = $("#table span");
//console.log(spans);
var idArrays = new Array();
for(var i=0;i<spans.length;i++){
var spanObj = spans[i];
var idVal = spanObj.id;
idArrays.push(idVal);
}
//console.log('idArrays',idArrays);
var jsonId = [];
if(idArrays.length<1){
$.messager.alert('Messager','No failed lights are required to be configured!','info');
return;
}else{
for(var i=0;i<idArrays.length;i++){
var j = {};
j.whatId = 4;
j.idValue = idArrays[i];
jsonId.push(j);
}
}
//console.log('jsonId',jsonId);
var params = {
eventId:eventId,
messageCode:0,
jsonId:jsonId,
pir:pir,
dimLvl:dimLevel,
holdTime:holdtime,
pirSen:pirSen,
photoLvl:photoLvl,
rtc:rtc,
wm:wintermonth,
sm:summermonth,
wt:wt,
st:st,
deviceTime:deviceTime,
lightIntensity:lightIntensity,
userId:userId
};
console.log("params",params);
var ws;
//这里的SPS100项目路径一定要带上,否则找不到。
var protocal = '<%=SchemeValue%>'=='http'?"ws://":"wss://";
console.info("protocal:" + protocal);
<%-- var target = "wss://"+ '<%=websocketPath%>' + "websocket/smartControl"; --%>
var target = protocal+ '<%=websocketPath%>' + "websocket/smartControl";
console.log("target:" + target);
if ('WebSocket' in window) {
ws = new WebSocket(target);
} else if ('MozWebSocket' in window) {
ws = new MozWebSocket(target);
} else {
alert('WebSocket is not supported by this browser.');
return;
}
ws.onopen = function(){
sendMessage();
};
function sendMessage(){
//把json对象转成String
var str = JSON.stringify(params);
//console.info("params" + str);
//这里先演示传入一个字符串,后面会从数据库查询数,然后封装成一个json字符串对象传给后台广播给C程序
$.messager.confirm('Confirm','Are you sure to submit the config parameters?',function(r){
if(r){
ws.send(str);
//发送之后提示Ready to send data....
$(".info").html("Ready to send data to server....");
//每次发送一周都要清空错误数据
$("#table tr").eq(0).siblings().remove();
//重新提交的时候两个按钮要禁用
document.getElementById('config_param').disabled = true;
document.getElementById('resubmit').disabled = true;
}else{
ws.close(); //关闭TCP连接
}
});
//这里是回调函数,websocket广播的json数据就是发送到这里
//应该在外面定义一个count统计变量,否则每次进来都会被初始化成0
var count = 0;
ws.onmessage = function(message){
eval("var msg = " + message.data + ";");
//console.info("msg",msg);
if(undefined!=msg.eventId && undefined!=msg.messageCode && eventId==msg.eventId){
console.log(msg.flag);
if(msg.flag!=undefined && msg.flag==1){
$(".info").html("The data is all assembled.....");
}else if(msg.flag!=undefined && msg.flag==2){
//这个其实如果是响应很快的话这个其实是不会执行的,但是实际上实惠执行的,因为处理总需要时间,而且C程序返回传输也需要时间
$(".info").html("All data was successfully sent....");
}
//(在这里可以做填充表格数据的代码)
//只有eventId一致并且code是100才是C程序响应给SPS100的
if(msg.messageCode==100){
count++;
console.log("count",count);
//这里就需要添加表格
console.log('lightId',msg.lightId);
if(msg.lightId!=undefined && msg.infoList!=undefined){
var infoList = msg.infoList;
console.log("infoList",infoList);
//遍历并添加表格
//遍历数组 for循环
for(var i=0;i<infoList.length;i++){
var lightId = infoList[i].lightId;
var lightName = infoList[i].lightName;
var floorName = infoList[i].floorName;
var blockName = infoList[i].blockName;
var communityName = infoList[i].communityName;
$("#table").append("<tr><td class=\"t_td light\"><span id=\""+lightId+"\">"+lightName+"</span></td><td class=\"t_td\">"+floorName+"</td><td class=\"t_td\">"+blockName+"</td><td class=\"t_td\">"+communityName+"</td></tr>");
}
}
}
//只有次数一致才能关闭连接,因为如果客户端为0也会断开
if(msg.count!=0 && msg.count==count){
$(".info").html("All lights are fully configured!");
//关闭连接之前可以通知,如果infoList为0,说明没有失败的灯,这个时候可以告诉全部配置成功
var spanObjs = $("#table span");
//如果没有lihgt的列表,说明是没有配置失败
console.log("spanObjs.length",spanObjs.length);
if(spanObjs.length==0){
$(".info").html("All configured successfully!");
}else{
$(".info").html("Some lights configured failed!");
}
//如果所有的灯都配置完毕就需要解禁按钮
document.getElementById('config_param').disabled = false;
document.getElementById('resubmit').disabled = false;
ws.close(); //关闭TCP连接
}
//如果msg.count为0说明C程序是没有block连接上websocket服务
if(msg.count==0){
$(".info").html("No device connect the websocket service!");
//如果客户端没有设备连接websocket就需要解禁所有的按钮
document.getElementById('config_param').disabled = false;
document.getElementById('resubmit').disabled = false;
ws.close();
}
}
};
}
});
});
$(function(){
//Home Page
$("#homePage").click(function(){
$.messager.confirm('Confirm','Are you sure to the home page?',function(r){
if(r){
location.href = "${pageContext.request.contextPath}/community/communityList.action";
}
});
});
});
</script>
</head>
<body>
<div id="container">
<!-- 1.logo部分 -->
<div id="logo">
<div id="top_left">
</div>
<div id="top_right">
<font color="#1c6299" size="6" face="Helvetica"><b>Az</b></font><font color="#15a2b3" size="6" face="Helvetica"><b>tech</b></font>
<font color="#5d5b5d" size="5" face="Century Gothic"><a id="return_to_homepage" href="${pageContext.request.contextPath}/community/communityList.action">Smart Lighting Management System</a></font>
</div>
</div>
<!-- 2.green bar部分 -->
<div id="green_bar">
</div>
</div>
<!-- D/E PIR Sensitivity -->
<div class="sensitivity">
<div class="s_checkbox">
PIR D/E<input type="checkbox" checked="checked" id="pirEnable"> PIR Sensitivity:
</div>
<div class="s_select">
<select name="" id="s_sensitivity">
<option value="1">High</option>
<option value="2" selected="selected">Medium-High</option>
<option value="3">Medium</option>
<option value="4">Medium-Low</option>
<option value="5">Low</option>
</select>
</div>
</div>
<!-- DIM Level -->
<div class="comment_father">
<div class="comment_son1">
<ul>
<li>10%</li>
<li>20%</li>
<li>30%</li>
<li>40%</li>
<li>50%</li>
<li>60%</li>
<li>70%</li>
<li>80%</li>
<li>90%</li>
<li>100%</li>
</ul>
</div>
<div class="comment_son2">
<ul>
<li>|</li>
<li>|</li>
<li>|</li>
<li>|</li>
<li>|</li>
<li>|</li>
<li>|</li>
<li>|</li>
<li>|</li>
<li>|</li>
</ul>
</div>
</div>
<div class="slide_father">
<div class="slide_son1"></div>
<div class="slide_son2"></div>
<div class="slide_ball"></div>
<div class="slide_title">
DIM Level (10-100%)
</div>
<div class="dimLevel">10</div>
<div class="homePage">
<button id="homePage" class="button button4">Home Page</button>
</div>
</div>
<!-- Photosensor Sensitivity -->
<div class="comment_ps_father">
<div class="comment_ps_son1">
<ul>
<li>0</li>
<li>10</li>
<li>20</li>
<li>30</li>
<li>40</li>
<li>50</li>
<li>60</li>
<li>70</li>
<li>80</li>
<li>90</li>
<li>100</li>
</ul>
</div>
<div class="comment_ps_son2">
<ul>
<li>|</li>
<li>|</li>
<li>|</li>
<li>|</li>
<li>|</li>
<li>|</li>
<li>|</li>
<li>|</li>
<li>|</li>
<li>|</li>
<li>|</li>
</ul>
</div>
</div>
<div class="slide_photosensor_sensi">
<div class="slide_ps_son1"></div>
<div class="slide_ps_son2"></div>
<div class="slide_ps_ball"></div>
<div class="slide_ps_title">
Photosensor Level (0-100)
</div>
<div class="photosensor">0</div>
</div>
<!-- Hold Time -->
<div class="hold_time">
<div class="ht_input">
Hold Time: <input type="text" name="holdtime" value="15" id="holdtime"> Seconds
<span class="ht_number"></span>
</div>
</div>
<!-- Schedule -->
<div class="schedule">
<div class="sche_checkbox">
Schedule: D/E<input type="checkbox" checked="checked" id="rtc">
</div>
</div>
<!-- lightIntensity -->
<div class="lightIntensity">
<div class="title_lightIntensity">
Light Intensity:
</div>
<div class="s_lightIntensity">
<select id="lightIntensity">
<option value="1">Fast</option>
<option value="2" selected="selected">Medium</option>
<option value="3">Slow</option>
</select>
</div>
</div>
<!-- Month -->
<div class="month">
<div class="winter_month">
Group 1 Period: <input type="text" name="wintermonth" value="10" id="wintermonth">
<span class="wm_number"></span>
</div>
<div class="summer_month">
Group 2 Period: <input type="text" name="summermonth" value="5" id="summermonth">
<span class="sm_number"></span>
</div>
</div>
<div class="winter_time">
<div class="winter_start">
Group 1 start time: <input type="time" name="winterstart" id="winterstart">
<span class="ws_number"></span>
</div>
<div class="winter_end">
Group 1 end time: <input type="time" name="winterend" id="winterend">
<span class="we_number"></span>
</div>
</div>
<div class="summer_time">
<div class="summer_start">
Group 2 start time: <input type="time" name="summerstart" id="summerstart">
</div>
<div class="summer_end">
Group 2 end time: <input type="time" name="summerend" id="summerend">
</div>
</div>
<!-- Configure Device Time -->
<div class="deviceTime">
<div class="deviceTime_checkbox">
Configure Device Time: D/E<input type="checkbox" id="deviceTime">
</div>
</div>
<!-- area_block_floor_light_info -->
<div class="area_block">
<ul id="ztree2" class="ztree">
</ul>
</div>
<div class="config_btn">
<button id="config_param">Submit</button>
</div>
<div class="feedback">
<div class="info"></div>
</div>
<div class="t_title">List of Configuration failed SPS100</div>
<div class="show_table">
<table id="table" border="1">
<tr>
<td>Light</td>
<td>Floor</td>
<td>Block</td>
<td>Area</td>
</tr>
</table>
</div>
<div class="resubmit">
<button id="resubmit">resubmit</button>
</div>
</body>
</html>