Esempio n. 1
0
 @RequestMapping("/device_status")
 public @ResponseBody DeviceStatus[] getDeviceStatus() {
   Device devices[] = powerControlDeviceService.getDevices();
   DeviceStatus[] deviceStatus = new DeviceStatus[devices.length];
   for (int i = 0; i < devices.length; i++) {
     deviceStatus[i] = new DeviceStatus(devices[i]);
   }
   return deviceStatus;
 }
Esempio n. 2
0
 @RequestMapping("/programme_devices_status/{id}")
 public @ResponseBody DeviceStatus[] getProgrammeDeviceStatus(@PathVariable("id") long id) {
   ProgrammeDevice[] devices =
       powerControlDeviceService.getProgrammeStatus(id).getProgrammeDevices();
   DeviceStatus[] deviceStatus = new DeviceStatus[devices.length];
   for (int i = 0; i < devices.length; i++) {
     deviceStatus[i] = new DeviceStatus(devices[i].getDevice());
   }
   return deviceStatus;
 }
Esempio n. 3
0
 @RequestMapping("/secure/device_override/{id}/{on}/{duration}")
 public @ResponseBody boolean deviceOverride(
     @PathVariable("id") long id,
     @PathVariable("on") boolean on,
     @PathVariable("duration") long duration) {
   powerControlDeviceService
       .getDevice(id)
       .setOverridingMode(new OnOffMode(on), duration * 1000 * 60);
   return true;
 }
Esempio n. 4
0
 @RequestMapping("/device_status/{id}")
 public @ResponseBody DeviceStatus getDeviceStatus(@PathVariable("id") long id) {
   Device devices[] = powerControlDeviceService.getDevices();
   for (int i = 0; i < devices.length; i++) {
     if (devices[i].getId() == id) {
       return new DeviceStatus(devices[i]);
     }
   }
   return null;
 }
Esempio n. 5
0
 @RequestMapping("/secure/activate_programme/{id}")
 public String activateProgramme(@PathVariable("id") long id) {
   powerControlDeviceService.activateProgramme(id);
   return "redirect:/programmes";
 }
Esempio n. 6
0
 @RequestMapping("/programme_detail/{id}")
 public @ResponseBody ModelAndView getProgrammes(@PathVariable("id") long id) {
   ModelAndView mav = new ModelAndView("programme_detail");
   mav.addObject("programmeStatus", powerControlDeviceService.getProgrammeStatus(id));
   return mav;
 }
Esempio n. 7
0
 @RequestMapping("/programmes")
 public @ResponseBody ModelAndView getProgrammes() {
   ModelAndView mav = new ModelAndView("maintenance");
   mav.addObject("programmesStatus", powerControlDeviceService.getProgrammesStatus());
   return mav;
 }
Esempio n. 8
0
 @RequestMapping("/secure/cancel_device_override/{id}")
 public @ResponseBody boolean cancelOverride(@PathVariable("id") long id) {
   powerControlDeviceService.getDevice(id).cancelOverridingMode();
   return true;
 }
Esempio n. 9
0
 @RequestMapping("/device/{id}")
 public @ResponseBody ModelAndView getDeviceDetail(@PathVariable("id") long id) {
   ModelAndView mav = new ModelAndView("device_detail");
   mav.addObject("device", powerControlDeviceService.getDevice(id));
   return mav;
 }