Merge pull request #169 from GPrathap/IoTS-1.0.0-M3

changed the way server address is taken
Ruwan 9 years ago
commit bd341c85b9

@ -20,7 +20,6 @@ package org.wso2.carbon.device.mgt.iot.droneanalyzer.controller.api.impl;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.apimgt.annotations.api.API; import org.wso2.carbon.apimgt.annotations.api.API;
import org.wso2.carbon.apimgt.annotations.device.DeviceType; import org.wso2.carbon.apimgt.annotations.device.DeviceType;
import org.wso2.carbon.apimgt.annotations.device.feature.Feature;
import org.wso2.carbon.device.mgt.common.DeviceIdentifier; import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.iot.DeviceValidator; import org.wso2.carbon.device.mgt.iot.DeviceValidator;
@ -29,13 +28,8 @@ import org.wso2.carbon.device.mgt.iot.droneanalyzer.plugin.constants.DroneConsta
import org.wso2.carbon.device.mgt.iot.droneanalyzer.plugin.controller.DroneController; import org.wso2.carbon.device.mgt.iot.droneanalyzer.plugin.controller.DroneController;
import org.wso2.carbon.device.mgt.iot.droneanalyzer.plugin.controller.impl.DroneControllerImpl; import org.wso2.carbon.device.mgt.iot.droneanalyzer.plugin.controller.impl.DroneControllerImpl;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.HeaderParam; import javax.ws.rs.*;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.QueryParam;
import javax.ws.rs.core.Context; import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
@ -57,11 +51,10 @@ public class DroneControllerService {
--------------------------------------------------------------------------------------- */ --------------------------------------------------------------------------------------- */
@Path("controller/register/{owner}/{deviceId}/{ip}/{port}") @Path("controller/register/{owner}/{deviceId}/{ip}/{port}")
@POST @POST
public String registerDeviceIP(@PathParam("owner") String owner, @PathParam("deviceId") String deviceId, public Response registerDeviceIP(@PathParam("owner") String owner, @PathParam("deviceId") String deviceId,
@PathParam("ip") String deviceIP, @PathParam("ip") String deviceIP,
@PathParam("port") String devicePort, @PathParam("port") String devicePort,
@Context HttpServletResponse response, @Context HttpServletResponse response) {
@Context HttpServletRequest request) {
String result; String result;
log.info("Got register call from IP: " + deviceIP + " for Device ID: " + deviceId + " of owner: " + owner); log.info("Got register call from IP: " + deviceIP + " for Device ID: " + deviceId + " of owner: " + owner);
String deviceHttpEndpoint = deviceIP + ":" + devicePort; String deviceHttpEndpoint = deviceIP + ":" + devicePort;
@ -72,17 +65,16 @@ public class DroneControllerService {
log.debug(result); log.debug(result);
} }
log.info(owner + deviceId + deviceIP + devicePort ); log.info(owner + deviceId + deviceIP + devicePort );
return result; return Response.ok(Response.Status.OK.getStatusCode()).build();
} }
@Path("controller/send_command") @Path("controller/send_command")
@POST @POST
@Feature( code="send_command", name="Send Command", type="operation", /*@Feature( code="send_command", name="Send Command", type="operation",
description="Send Commands to Drone") description="Send Commands to Drone")*/
public Response droneController(@HeaderParam("owner") String owner, @HeaderParam("deviceId") String deviceId, public Response droneController(@HeaderParam("owner") String owner, @HeaderParam("deviceId") String deviceId,
@QueryParam("action") String action, @QueryParam("duration") String duration, @FormParam("action") String action, @FormParam("duration") String duration,
@QueryParam("speed") String speed){ @FormParam("speed") String speed){
try { try {
DeviceValidator deviceValidator = new DeviceValidator(); DeviceValidator deviceValidator = new DeviceValidator();
if (!deviceValidator.isExist(owner, SUPER_TENANT, new DeviceIdentifier(deviceId, if (!deviceValidator.isExist(owner, SUPER_TENANT, new DeviceIdentifier(deviceId,

@ -38,8 +38,7 @@ public class DroneRealTimeService {
public DroneRealTimeService() { public DroneRealTimeService() {
messageController = new MessageTransformer(); messageController = new MessageTransformer();
xmppConnector = new DroneAnalyzerXMPPConnector(messageController); xmppConnector = new DroneAnalyzerXMPPConnector(messageController);
if (!XmppConfig.getInstance().isEnabled()){
if (XmppConfig.getInstance().isEnabled()){
xmppConnector.connect(); xmppConnector.connect();
} else { } else {
log.warn("XMPP disabled in 'devicemgt-config.xml'. Hence, DroneAnalyzerXMPPConnector not started."); log.warn("XMPP disabled in 'devicemgt-config.xml'. Hence, DroneAnalyzerXMPPConnector not started.");
@ -58,24 +57,23 @@ public class DroneRealTimeService {
@OnMessage @OnMessage
public void onMessage(String message, Session session){ public void onMessage(String message, Session session){
try {
while(true){ while(true){
if((messageController !=null) && (!messageController.isEmptyQueue())){ try{
String message1 = messageController.getMessage(); if((messageController !=null) && (!messageController.isEmptyQueue())){
session.getBasicRemote().sendText(message1); String message1 = messageController.getMessage();
session.getBasicRemote().sendText(message1);
}
Thread.sleep(DroneConstants.MINIMUM_TIME_DURATION);
} catch (IOException ex) {
log.error(ex.getMessage() + "\n" + ex);
} catch (InterruptedException e) {
log.error(e.getMessage(), e);
} }
Thread.sleep(DroneConstants.MINIMUM_TIME_DURATION);
} }
} catch (IOException ex) {
log.error(ex.getMessage() + "\n" + ex);
} catch (InterruptedException e) {
log.error(e.getMessage(), e);
}
} }
@OnClose @OnClose
public void onClose(Session session){ public void onClose(Session session){
try { try {
xmppConnector.disconnect(); xmppConnector.disconnect();
log.info("XMPP connection is disconnected"); log.info("XMPP connection is disconnected");

@ -35,33 +35,29 @@ public class DroneAnalyzerXMPPConnector extends XMPPTransportHandler {
private static Log log = LogFactory.getLog(DroneAnalyzerXMPPConnector.class); private static Log log = LogFactory.getLog(DroneAnalyzerXMPPConnector.class);
private static String xmppServerIP; private static String xmppServerIP;
private static int xmppServerPort;
private static String xmppAdminUsername; private static String xmppAdminUsername;
private static String xmppAdminPassword; private static String xmppAdminPassword;
private static String xmppAdminAccountJID; private static String xmppAdminAccountJID;
private MessageTransformer messageTransformer; private MessageTransformer messageTransformer;
private ScheduledFuture<?> connectorServiceHandler; private ScheduledFuture<?> connectorServiceHandler;
private ScheduledExecutorService service = Executors.newSingleThreadScheduledExecutor(); private ScheduledExecutorService service = Executors.newSingleThreadScheduledExecutor();
public DroneAnalyzerXMPPConnector(MessageTransformer messageTransformer) { public DroneAnalyzerXMPPConnector(MessageTransformer messageTransformer) {
super(XmppConfig.getInstance().getXmppServerIP(), super(XmppConfig.getInstance().getXmppServerIP(),XmppConfig.getInstance().getSERVER_CONNECTION_PORT());
XmppConfig.getInstance().getSERVER_CONNECTION_PORT());
this.messageTransformer = messageTransformer; this.messageTransformer = messageTransformer;
} }
@Override @Override
public void connect() { public void connect() {
Runnable connector = new Runnable() { Runnable connector = new Runnable() {
@Override
public void run() { public void run() {
if (!isConnected()) { if (!isConnected()) {
try { try {
initConnector(); initConnector();
connectToServer(); connectToServer();
loginToServer(xmppAdminUsername, xmppAdminPassword, null); loginToServer(xmppAdminUsername, xmppAdminPassword, null);
setFilterOnReceiver(DroneConstants.DEVICE_ID+ "@" + xmppServerIP); setFilterOnReceiver(xmppAdminAccountJID);
} catch (TransportHandlerException e) { } catch (TransportHandlerException e) {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.warn("Connection/Login to XMPP server at: " + server + " as " + log.warn("Connection/Login to XMPP server at: " + server + " as " +
@ -84,18 +80,28 @@ public class DroneAnalyzerXMPPConnector extends XMPPTransportHandler {
@Override @Override
public void processIncomingMessage(Message message) throws TransportHandlerException { public void processIncomingMessage(Message message) throws TransportHandlerException {
String from = message.getFrom(); try{
String subject = message.getSubject(); String from = message.getFrom();
String inbound_message = message.getBody(); String inbound_message = message.getBody();
int indexOfAt = from.indexOf("@"); int indexOfSlash = from.indexOf("/");
int indexOfSlash = from.indexOf("/"); if(indexOfSlash==0){
String deviceId = from.substring(0, indexOfAt); if(log.isDebugEnabled()){
String resource = from.substring(indexOfSlash + 1, from.length()); log.debug("Required resource not available.");
}
if ((inbound_message != null)&&(resource.equals(DroneConstants.MESSAGE_RESOURCE)) ){ }else{
messageTransformer.messageTranslater(inbound_message); String resource = from.substring(indexOfSlash + 1, from.length());
} else { if ((inbound_message != null)&&(resource.equals(DroneConstants.MESSAGE_RESOURCE)) ){
log.error("Message is empty or it is not belongs to "+ DroneConstants.DEVICE_ID); messageTransformer.messageTranslater(inbound_message);
} else {
if(log.isDebugEnabled()){
log.debug("Message is empty or it is not belongs to " + xmppAdminUsername);
}
}
}
}catch(ArrayIndexOutOfBoundsException e){
log.error("Wrong message format: input message", e);
}catch(RuntimeException e){
log.error("Unexpected error has been occurred, ", e);
} }
} }
@ -117,18 +123,15 @@ public class DroneAnalyzerXMPPConnector extends XMPPTransportHandler {
log.warn("Unable to 'STOP' connection to XMPP server at: " + server + log.warn("Unable to 'STOP' connection to XMPP server at: " + server +
" for user - " + xmppAdminUsername); " for user - " + xmppAdminUsername);
} }
try { try {
Thread.sleep(timeoutInterval); Thread.sleep(timeoutInterval);
} catch (InterruptedException e1) { } catch (InterruptedException e1) {
log.error("XMPP-Terminator: Thread Sleep Interrupt Exception for " log.error("XMPP-Terminator: Thread Sleep Interrupt Exception for "
+ DroneConstants.DEVICE_TYPE + " type.", e1); + DroneConstants.DEVICE_TYPE + " type.", e1);
} }
} }
} }
}; };
Thread terminatorThread = new Thread(stopConnection); Thread terminatorThread = new Thread(stopConnection);
terminatorThread.setDaemon(true); terminatorThread.setDaemon(true);
terminatorThread.start(); terminatorThread.start();

@ -35,11 +35,11 @@ public class MessageTransformer {
private Log log = LogFactory.getLog(MessageTransformer.class); private Log log = LogFactory.getLog(MessageTransformer.class);
private CircularFifoQueue<String> sharedQueue; private CircularFifoQueue<String> sharedQueue;
private String outbound_message_format_for_simulator = "{\"quatanium_val\":[%f, %f, %f, %f]," + private String outboundMessageFormatForSimulator = "{\"quatanium_val\":[%f, %f, %f, %f]," +
"\"basicParam\":{\"velocity\":[%f, %f, %f], \"global_location\":[%f, %f, %f]},\"battery_level\":%f, \"device_type\":\"IRIS_DRONE\"}"; "\"basicParam\":{\"velocity\":[%f, %f, %f], \"global_location\":[%f, %f, %f]},\"battery_level\":%f, \"device_type\":\"SIMULATOR\"}";
private String outbound_message_format_for_iris_drone = "{\"quatanium_val\":[%f, %f, %f]," + private String outboundMessageFormatForIrisDrone = "{\"quatanium_val\":[%f, %f, %f]," +
"\"basicParam\":{\"velocity\":[%f, %f, %f], \"global_location\":[%f, %f, %f]},\"battery_level\":%f," + "\"basicParam\":{\"velocity\":[%f, %f, %f], \"global_location\":[%f, %f, %f]},\"battery_level\":%f," +
"\"device_type\":\"SIMULATOR\"}"; "\"device_type\":\"IRIS_DRONE\"}";
public MessageTransformer(){ public MessageTransformer(){
sharedQueue = new CircularFifoQueue<String>(DroneConstants.MAXIMUM_BUFFERE_SIZE_OF_SHARED_QUEUE); sharedQueue = new CircularFifoQueue<String>(DroneConstants.MAXIMUM_BUFFERE_SIZE_OF_SHARED_QUEUE);
@ -47,19 +47,18 @@ public class MessageTransformer {
private void messageTranslaterForSimulator(JsonNode inbound_message){ private void messageTranslaterForSimulator(JsonNode inbound_message){
JsonNode node = inbound_message; JsonNode node = inbound_message;
String outbound_message; String outboundMessage;
try { try {
JsonNode velocity = node.get(MessageConfig.OUT_BASIC_PARAM_VAL).get(MessageConfig.OUT_BASIC_PARAM_VELOCITY); JsonNode velocity = node.get(MessageConfig.OUT_BASIC_PARAM_VAL).get(MessageConfig.OUT_BASIC_PARAM_VELOCITY);
JsonNode global_location = node.get(MessageConfig.OUT_BASIC_PARAM_VAL).get( JsonNode globalLocation = node.get(MessageConfig.OUT_BASIC_PARAM_VAL).get(
MessageConfig.OUT_BASIC_PARAM_GLOBAL_LOCATION); MessageConfig.OUT_BASIC_PARAM_GLOBAL_LOCATION);
JsonNode quatanium_vals = node.get(MessageConfig.OUT_QUATANNIM_VAL); JsonNode quataniumVals = node.get(MessageConfig.OUT_QUATANNIM_VAL);
JsonNode battery_level = node.get(MessageConfig.OUT_BATTERY_LEVEL); JsonNode batteryLevel = node.get(MessageConfig.OUT_BATTERY_LEVEL);
outbound_message = String.format(outbound_message_format_for_simulator, sTd(quatanium_vals.get(0)), outboundMessage = String.format(outboundMessageFormatForSimulator, sTd(quataniumVals.get(0)),
sTd(quatanium_vals.get(1)), sTd(quatanium_vals.get(2)), sTd(quatanium_vals.get(0)), sTd(quataniumVals.get(1)), sTd(quataniumVals.get(2)), sTd(quataniumVals.get(0)),
sTd(velocity.get(0)), sTd(velocity.get(1)), sTd(velocity.get(2)), sTd(global_location.get(0)), sTd(velocity.get(0)), sTd(velocity.get(1)), sTd(velocity.get(2)), sTd(globalLocation.get(0)),
sTd(global_location.get(1)), sTd(global_location.get(2)), sTd(battery_level)); sTd(globalLocation.get(1)), sTd(globalLocation.get(2)), sTd(batteryLevel));
sharedQueue.add(outbound_message); sharedQueue.add(outboundMessage);
} catch (Exception e) { } catch (Exception e) {
log.error(e.getMessage()+",\n"+ e); log.error(e.getMessage()+",\n"+ e);
} }
@ -67,19 +66,19 @@ public class MessageTransformer {
private void messageTranslaterForIRISDrone(JsonNode inbound_message){ private void messageTranslaterForIRISDrone(JsonNode inbound_message){
JsonNode node = inbound_message; JsonNode node = inbound_message;
String outbound_message; String outboundMessage;
try { try {
JsonNode velocity = node.get(MessageConfig.OUT_BASIC_PARAM_VAL).get(MessageConfig.OUT_BASIC_PARAM_VELOCITY); JsonNode velocity = node.get(MessageConfig.OUT_BASIC_PARAM_VAL).get(MessageConfig.OUT_BASIC_PARAM_VELOCITY);
JsonNode global_location = node.get(MessageConfig.OUT_BASIC_PARAM_VAL).get( JsonNode globalLocation = node.get(MessageConfig.OUT_BASIC_PARAM_VAL).get(
MessageConfig.OUT_BASIC_PARAM_GLOBAL_LOCATION); MessageConfig.OUT_BASIC_PARAM_GLOBAL_LOCATION);
JsonNode quatanium_vals = node.get(MessageConfig.OUT_QUATANNIM_VAL); JsonNode quataniumVals = node.get(MessageConfig.OUT_QUATANNIM_VAL);
JsonNode battery_level = node.get(MessageConfig.OUT_BATTERY_LEVEL); JsonNode batteryLevel = node.get(MessageConfig.OUT_BATTERY_LEVEL);
outbound_message = String.format(outbound_message_format_for_iris_drone, sTd(quatanium_vals.get(0)), outboundMessage = String.format(outboundMessageFormatForIrisDrone, sTd(quataniumVals.get(0)),
sTd(quatanium_vals.get(1)), sTd(quatanium_vals.get(2)), sTd(velocity.get(0)), sTd(quataniumVals.get(1)), sTd(quataniumVals.get(2)), sTd(velocity.get(0)),
sTd(velocity.get(1)), sTd(velocity.get(2)), sTd(global_location.get(0)), sTd(velocity.get(1)), sTd(velocity.get(2)), sTd(globalLocation.get(0)),
sTd(global_location.get(1)), sTd(global_location.get(2)), sTd(battery_level)); sTd(globalLocation.get(1)), sTd(globalLocation.get(2)), sTd(batteryLevel));
sharedQueue.add(outbound_message); sharedQueue.add(outboundMessage);
}catch (Exception e) { }catch (Exception e) {
log.error(e.getMessage()+",\n"+ e); log.error(e.getMessage()+",\n"+ e);
@ -87,20 +86,22 @@ public class MessageTransformer {
} }
public void messageTranslater(String inbound_message){ public void messageTranslater(String inbound_message){
JsonNode actualMessage = null; JsonNode actualMessage;
ObjectMapper objectMapper = new ObjectMapper(); ObjectMapper objectMapper = new ObjectMapper();
try { try {
actualMessage = objectMapper.readValue(inbound_message, JsonNode.class); actualMessage = objectMapper.readValue(inbound_message, JsonNode.class);
JsonNode deviceType = actualMessage.get(MessageConfig.IN_DEVICE_TYPE); JsonNode deviceType = actualMessage.get(MessageConfig.IN_DEVICE_TYPE);
switch (deviceType.getTextValue()) { switch (deviceType.getTextValue()) {
case MessageConfig.IN_IRIS_DRONE: case MessageConfig.IN_IRIS_DRONE:
messageTranslaterForIRISDrone(actualMessage); messageTranslaterForIRISDrone(actualMessage);
break; break;
case MessageConfig.IN_SIMULATOR: case MessageConfig.IN_SIMULATOR:
messageTranslaterForSimulator(actualMessage); messageTranslaterForSimulator(actualMessage);
break; break;
default:
if(log.isDebugEnabled()){
log.debug("Wrong message format");
}
} }
} catch (JsonProcessingException e) { } catch (JsonProcessingException e) {
log.error("Incoming message might be corrupted, "+ e); log.error("Incoming message might be corrupted, "+ e);

@ -19,16 +19,11 @@
package org.wso2.carbon.device.mgt.iot.droneanalyzer.controller.api.impl.util; package org.wso2.carbon.device.mgt.iot.droneanalyzer.controller.api.impl.util;
import org.apache.commons.logging.LogFactory; import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.certificate.mgt.core.service.CertificateManagementService;
import org.wso2.carbon.context.PrivilegedCarbonContext;
import org.wso2.carbon.device.mgt.analytics.exception.DataPublisherConfigurationException;
import org.wso2.carbon.device.mgt.analytics.service.DeviceAnalyticsService;
import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.iot.controlqueue.xmpp.XmppConfig; import org.wso2.carbon.device.mgt.iot.controlqueue.xmpp.XmppConfig;
import org.wso2.carbon.device.mgt.iot.droneanalyzer.controller.api.impl.transport.DroneAnalyzerXMPPConnector;
import org.wso2.carbon.device.mgt.iot.droneanalyzer.plugin.constants.DroneConstants; import org.wso2.carbon.device.mgt.iot.droneanalyzer.plugin.constants.DroneConstants;
import org.wso2.carbon.device.mgt.iot.droneanalyzer.plugin.controller.DroneController; import org.wso2.carbon.device.mgt.iot.droneanalyzer.plugin.controller.DroneController;
import org.wso2.carbon.device.mgt.iot.droneanalyzer.controller.api.impl.exception.DroneAnalyzerException;
import org.wso2.carbon.device.mgt.iot.droneanalyzer.controller.api.impl.transport.DroneAnalyzerXMPPConnector;
import org.wso2.carbon.device.mgt.iot.transport.TransportHandlerException; import org.wso2.carbon.device.mgt.iot.transport.TransportHandlerException;
import java.io.File; import java.io.File;
@ -36,7 +31,6 @@ import java.io.File;
public class DroneAnalyzerServiceUtils { public class DroneAnalyzerServiceUtils {
private static final String SUPER_TENANT = "carbon.super"; private static final String SUPER_TENANT = "carbon.super";
private static final String TEMPERATURE_STREAM_DEFINITION = "org.wso2.iot.devices.temperature";
private static org.apache.commons.logging.Log log = LogFactory.getLog(DroneAnalyzerServiceUtils.class); private static org.apache.commons.logging.Log log = LogFactory.getLog(DroneAnalyzerServiceUtils.class);
public static void sendCommandViaXMPP(String deviceOwner, String deviceId, String resource, public static void sendCommandViaXMPP(String deviceOwner, String deviceId, String resource,
@ -46,8 +40,7 @@ public class DroneAnalyzerServiceUtils {
String xmppServerDomain = XmppConfig.getInstance().getXmppEndpoint(); String xmppServerDomain = XmppConfig.getInstance().getXmppEndpoint();
int indexOfChar = xmppServerDomain.lastIndexOf(File.separator); int indexOfChar = xmppServerDomain.lastIndexOf(File.separator);
if (indexOfChar != -1) { if (indexOfChar != -1) {
xmppServerDomain = xmppServerDomain.substring((indexOfChar + 1), xmppServerDomain = xmppServerDomain.substring((indexOfChar + 1), xmppServerDomain.length());
xmppServerDomain.length());
} }
indexOfChar = xmppServerDomain.indexOf(":"); indexOfChar = xmppServerDomain.indexOf(":");
if (indexOfChar != -1) { if (indexOfChar != -1) {
@ -58,80 +51,46 @@ public class DroneAnalyzerServiceUtils {
droneXMPPConnector.publishDeviceData(clientToConnect, message, "CONTROL-REQUEST"); droneXMPPConnector.publishDeviceData(clientToConnect, message, "CONTROL-REQUEST");
} }
public static boolean sendControlCommand(DroneController controller, String deviceId, String action, double speed, double duration) public static boolean sendControlCommand(DroneController controller, String deviceId, String action,
double speed, double duration)
throws DeviceManagementException { throws DeviceManagementException {
boolean control_state = false; boolean controlState = false;
try{ try{
switch (action){ switch (action){
case DroneConstants.TAKE_OFF: case DroneConstants.TAKE_OFF:
control_state = controller.takeoff(); controlState = controller.takeoff();
break; break;
case DroneConstants.LAND: case DroneConstants.LAND:
control_state = controller.land(); controlState = controller.land();
break; break;
case DroneConstants.BACK: case DroneConstants.BACK:
control_state = controller.back(speed, duration); controlState = controller.back(speed, duration);
break; break;
case DroneConstants.CLOCK_WISE: case DroneConstants.CLOCK_WISE:
control_state = controller.clockwise(speed, duration); controlState = controller.clockwise(speed, duration);
break; break;
case DroneConstants.COUNTER_CLOCKWISE: case DroneConstants.COUNTER_CLOCKWISE:
control_state = controller.conterClockwise(speed, duration); controlState = controller.conterClockwise(speed, duration);
break; break;
case DroneConstants.DOWN: case DroneConstants.DOWN:
control_state = controller.down(speed, duration); controlState = controller.down(speed, duration);
break; break;
case DroneConstants.FRONT: case DroneConstants.FRONT:
control_state = controller.back(speed, duration); controlState = controller.back(speed, duration);
break; break;
case DroneConstants.FORWARD: case DroneConstants.FORWARD:
control_state = controller.clockwise(speed, duration); controlState = controller.clockwise(speed, duration);
break; break;
case DroneConstants.UP: case DroneConstants.UP:
control_state = controller.up(speed, duration); controlState = controller.up(speed, duration);
break;
default:
log.error("Invalid command");
break; break;
} }
}catch(Exception e){ }catch(Exception e){
log.error(e.getMessage()+ "\n"+ e); log.error(e.getMessage()+ "\n"+ e);
} }
return control_state; return controlState;
}
public static boolean publishToDAS(String owner, String deviceId, float temperature) {
PrivilegedCarbonContext.startTenantFlow();
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
ctx.setTenantDomain(SUPER_TENANT, true);
DeviceAnalyticsService deviceAnalyticsService = (DeviceAnalyticsService) ctx.getOSGiService(
DeviceAnalyticsService.class, null);
Object metdaData[] = {owner, DroneConstants.DEVICE_TYPE, deviceId,
System.currentTimeMillis()};
Object payloadData[] = {temperature};
try {
deviceAnalyticsService.publishEvent(TEMPERATURE_STREAM_DEFINITION, "1.0.0", metdaData,
new Object[0], payloadData);
} catch (DataPublisherConfigurationException e) {
return false;
} finally {
PrivilegedCarbonContext.endTenantFlow();
}
return true;
} }
public static CertificateManagementService getCertificateManagementService() throws
DroneAnalyzerException {
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
CertificateManagementService certificateManagementService = (CertificateManagementService)
ctx.getOSGiService(CertificateManagementService.class, null);
if (certificateManagementService == null) {
String msg = "EnrollmentService is not initialized";
log.error(msg);
throw new DroneAnalyzerException(msg);
}
return certificateManagementService;
}
} }

@ -27,8 +27,6 @@ import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
import org.wso2.carbon.device.mgt.iot.droneanalyzer.plugin.impl.DroneAnalyzerManagerService; import org.wso2.carbon.device.mgt.iot.droneanalyzer.plugin.impl.DroneAnalyzerManagerService;
import org.wso2.carbon.device.mgt.iot.service.DeviceTypeService; import org.wso2.carbon.device.mgt.iot.service.DeviceTypeService;
/** /**
* @scr.component name="org.wso2.carbon.device.mgt.iot.droneanalyzer.plugin.internal * @scr.component name="org.wso2.carbon.device.mgt.iot.droneanalyzer.plugin.internal
* .DroneAnalyzerManagementServiceComponent" * .DroneAnalyzerManagementServiceComponent"

@ -33,6 +33,7 @@ DEVICE_OWNER = configParser.get('Device-Configurations', 'owner')
DEVICE_ID = configParser.get('Device-Configurations', 'deviceId') DEVICE_ID = configParser.get('Device-Configurations', 'deviceId')
XMPP_EP = configParser.get('Device-Configurations', 'xmpp-ep') XMPP_EP = configParser.get('Device-Configurations', 'xmpp-ep')
AUTH_TOKEN = configParser.get('Device-Configurations', 'auth-token') AUTH_TOKEN = configParser.get('Device-Configurations', 'auth-token')
DEVICE_PASSWORD = configParser.get('Device-Configurations', 'auth-token')
CONTROLLER_CONTEXT = configParser.get('Device-Configurations', 'controller-context') CONTROLLER_CONTEXT = configParser.get('Device-Configurations', 'controller-context')
HTTPS_EP = configParser.get('Device-Configurations', 'https-ep') HTTPS_EP = configParser.get('Device-Configurations', 'https-ep')
HTTP_EP = configParser.get('Device-Configurations', 'http-ep') HTTP_EP = configParser.get('Device-Configurations', 'http-ep')

@ -23,9 +23,9 @@ import util
XMPP_ENDPOINT = util.XMPP_EP.split(":") XMPP_ENDPOINT = util.XMPP_EP.split(":")
XMPP_IP = XMPP_ENDPOINT[1].replace('//', '') XMPP_IP = XMPP_ENDPOINT[1].replace('//', '')
XMPP_PORT = int(XMPP_ENDPOINT[2]) XMPP_PORT = int(XMPP_ENDPOINT[2])
MESSAGE_TO = "admin" MESSAGE_TO = util.DEVICE_OWNER
XMPP_OWN = util.DEVICE_OWNER XMPP_PWD = util.DEVICE_PASSWORD
XMPP_PWD = util.DEVICE_ID XMPP_OWN = util.DEVICE_ID
XMPP_RESOURCE = "drone_current_status" XMPP_RESOURCE = "drone_current_status"
XMPP_JID = MESSAGE_TO + "@" + XMPP_IP + "/" + XMPP_RESOURCE XMPP_JID = MESSAGE_TO + "@" + XMPP_IP + "/" + XMPP_RESOURCE

@ -66,7 +66,7 @@ while true; do
done done
cp deviceConfig.properties ./src cp deviceConfig.properties ./src
./src/IRIS+DroneStatistics.py -i $push_interval -b $baud -c $connection_target python ./src/IRIS+DroneStatistics.py -i $push_interval -b $baud -c $connection_target
if [ $? -ne 0 ]; then if [ $? -ne 0 ]; then
echo "Could not start the service..." echo "Could not start the service..."

@ -169,3 +169,52 @@
.navbar { .navbar {
border-radius: 0; border-radius: 0;
} }
.circle {
background: none repeat scroll 0 0 #191919;
border-radius: 50px;
height: 50px;
padding: 10px;
width: 50px;
color: #fff;
}
.padding-top-double {
padding-top: 20px;
}
.padding-double {
padding: 20px;
}
.grey {
color: #333;
}
hr {
display: block;
height: 1px;
border: 0;
border-top: 1px solid #7f7f7f;
margin: 1em 0;
padding: 0;
opacity: 0.2;
}
.light-grey {
color: #7c7c7c;
}
.uppercase {
text-transform: uppercase;
}
.grey-bg {
background-color: #f6f4f4;
}
path {
stroke: black;
stroke-width: 2;
fill: none;
}
.axis path, .axis line {
fill: none;
stroke: #ccc;
stroke-width: 2;
shape-rendering: crispEdges;
}

@ -15,21 +15,19 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
//TODO this needs to a private resource
var config_api = function () { var config_api = function () {
var config_api = this; var config_api = this;
var domain = "localhost"; var context_controller = "/drone_analyzer/controller/send_command";
var port = "9793";
var context_controller = "/drone_analyzer/DroneAnalyzerServiceUnitManager/controller/send_command";
config_api.config_3dobject_holder = "#virtualDrone"; config_api.config_3dobject_holder = "#virtualDrone";
config_api.realtime_plotting_update_interval = 30; config_api.realtime_plotting_update_interval = 30;
config_api.realtime_plotting_totalPoints = 30; config_api.realtime_plotting_totalPoints = 30;
config_api.realtime_plotting_data_window = {}; config_api.realtime_plotting_data_window = {};
config_api.effectController = {uy: 70.0, uz: 15.0, ux: 10.0, fx: 2.0, fz: 15.0, Tmax: 1}; config_api.effectController = {uy: 70.0, uz: 15.0, ux: 10.0, fx: 2.0, fz: 15.0, Tmax: 1};
config_api.drone_control = "http://" + domain + ":" + port + "/" + context_controller; config_api.drone_control = context_controller;
config_api.drone_controlType = "POST"; config_api.drone_controlType = "POST";
config_api.drone_controlDataType = "json"; config_api.drone_controlDataType = "json";
config_api.web_socket_endpoint = "ws://localhost:9763/drone_analyzer/datastream/drone_status"; config_api.web_socket_endpoint = "/drone_analyzer/datastream/drone_status";
config_api.modules_status = { config_api.modules_status = {
"realtimePlotting": false, "realtimePlotting": false,
"sensorReadings": false, "sensorReadings": false,

@ -16,7 +16,7 @@
* under the License. * under the License.
*/ */
object_maker.init(config_api.config_3dobject_holder, $("#objectHolder").width(), $("#objectHolder").width()/2); object_maker.init(config_api.config_3dobject_holder, $("#objectHolder").width(), $("#objectHolder").width()/1.5);
object_maker.animate(); object_maker.animate();
var flight_dynamics = new flight_dynamics(); var flight_dynamics = new flight_dynamics();
$("#window_size").slider({ $("#window_size").slider({
@ -58,7 +58,6 @@ $('.btn-minimize').click(function (e) {
if ($target.is(':visible')) { if ($target.is(':visible')) {
if ($(this).parent().attr('id') === "RealtimePlotting") { if ($(this).parent().attr('id') === "RealtimePlotting") {
plotting.forceToRedraw(function (status) { plotting.forceToRedraw(function (status) {
d3.select("#realtimechart").select("svg").remove(); d3.select("#realtimechart").select("svg").remove();
plotting.realtime_plotting("#realtimechart", "#range_min", "#range_max", "#window_update_value", plotting.realtime_plotting("#realtimechart", "#range_min", "#range_max", "#window_update_value",
600, $("#realtimechart").height(), "#window_size_current_value", 600, $("#realtimechart").height(), "#window_size_current_value",
@ -71,33 +70,40 @@ $('.btn-minimize').click(function (e) {
$('#connectionOpen').on('click', function () { $('#connectionOpen').on('click', function () {
$('#connectionOpen').toggleClass('active'); $('#connectionOpen').toggleClass('active');
}); });
$("#xmppConnectionOpen").on('click', function () { $("#xmppConnectionOpen").on('click', function () {
$('#xmppConnectionOpen').toggleClass('active'); $('#xmppConnectionOpen').toggleClass('active');
if ($('#xmppConnectionOpen').html() === "Start") { if ($('#xmppConnectionOpen').html() === "Start") {
sendMessage(); sendMessage("Start the process", function(state){
$('#xmppConnectionOpen').html("Stop"); console.log("sending message to server..."+ state);
if(state<2){
$('#xmppConnectionOpen').html("Stop");
}else{
$('#xmppConnectionOpen').html("Start");
}
});
} else if ($('#xmppConnectionOpen').html() === "Stop") { } else if ($('#xmppConnectionOpen').html() === "Stop") {
closeSocket(); closeSocket(function(state){
$('#xmppConnectionOpen').html("Start"); console.log("closing WebSocket..."+ state);
$("#connectionOpen").html("Connect to server").removeClass("btn btn-info").addClass("btn btn-primary"); if(state<2){
$('#xmppConnectionOpen').html("Stop");
}else{
$('#xmppConnectionOpen').html("Start");
}
});
$("#connectionOpen").html("Connect to XMPP Server").removeClass("btn btn-info").addClass("btn btn-primary");
} }
}); });
$('.btn-minimize').parent().parent().next('.box-content').hide(); $('.btn-minimize').parent().parent().next('.box-content').hide();
var webSocket; var webSocket;
config_api.realtime_plotting_data_window["attitude"] = new Queue(); config_api.realtime_plotting_data_window["attitude"] = new Queue();
var current_status = {}; var current_status = {};
function openSocket(wssAddress) {
function openSocket() { if (webSocket !== undefined && webSocket.readyState == 1) {
if (webSocket !== undefined && webSocket.readyState !== WebSocket.CLOSED) {
writeResponse("WebSocket is already opened."); writeResponse("WebSocket is already opened.");
} else { } else {
webSocket = new WebSocket(config_api.web_socket_endpoint); webSocket = new WebSocket(wssAddress+config_api.web_socket_endpoint);
} }
webSocket.onopen = function (event) { webSocket.onopen = function (event) {
if (event === undefined) { if (event === undefined) {
@ -121,15 +127,20 @@ function openSocket() {
writeResponse("Message has been corrupted."); writeResponse("Message has been corrupted.");
} }
}; };
} }
function sendMessage(message) { function sendMessage(message, callback) {
webSocket.send(message); if(webSocket.readyState<2){
webSocket.send(message);
}
callback(webSocket.readyState);
} }
function closeSocket() { function closeSocket(callback) {
webSocket.close(); if(webSocket.readyState<2){
webSocket.close();
}
callback(webSocket.readyState);
} }
function writeResponse(text) { function writeResponse(text) {
@ -137,8 +148,6 @@ function writeResponse(text) {
} }
window.onbeforeunload = function () { window.onbeforeunload = function () {
webSocket.onclose = function () { webSocket.close();
};
webSocket.close()
}; };

@ -17,7 +17,7 @@
*/ */
$("#module_control button").click(function (index) { $("#module_control button").click(function (index) {
console.log("Asking Server to send the " + $(this).attr('id') + " command to Ar Drone"); console.log("Asking Server to send the " + $(this).attr('id') + " command to Ar Drone");
var url = config_api.drone_control + "?action=" + $(this).attr('id') + "&speed=6&duration=7"; var url = config_api.drone_control;
ajax_handler.ajaxRequest(url, config_api.drone_controlType, {action: $(this).attr('id'), speed: 7, duration: 7}, ajax_handler.ajaxRequest(url, config_api.drone_controlType, {action: $(this).attr('id'), speed: 7, duration: 7},
config_api.drone_controlDataType, function (data, status) { config_api.drone_controlDataType, function (data, status) {
console.log(JSON.stringify(data)); console.log(JSON.stringify(data));

@ -15,32 +15,30 @@
* specific language governing permissions and limitations * specific language governing permissions and limitations
* under the License. * under the License.
*/ */
var flight_dynamics = function () { var flight_dynamics = function () {
var api = this; var api = this;
api.processingMessage = function (sender_message) { api.processingMessage = function (sender_message) {
if(sender_message.battery_level!= undefined){
JSON.stringify(sender_message); $("#battery_level_holder").width( parseInt(sender_message.battery_level)+"%" );
$("#battery_level").html(sender_message.battery_level+"%");
}
if (sender_message.quatanium_val != undefined) { if (sender_message.quatanium_val != undefined) {
current_status = object_maker.get_heading_attitude_bank(sender_message.quatanium_val); current_status = object_maker.get_heading_attitude_bank(sender_message.quatanium_val);
object_maker.set_heading_attitude_bank(current_status); object_maker.set_heading_attitude_bank(current_status);
$("#imageTop").animate({rotate: '' + (180 / Math.PI) * 2.890456 + 'deg'}, 2); $("#imageTop").animate({rotate: '' + (180 / Math.PI) * 2.890456 + 'deg'}, 2);
} }
$("#imageTop").delay(2).animate({rotate: '45deg'}, 2);
if (config_api.modules_status.angleOfRotation_2 || config_api.modules_status.angleOfRotation_1) { if (config_api.modules_status.angleOfRotation_2 || config_api.modules_status.angleOfRotation_1) {
console.log(JSON.stringify(current_status)); console.log(JSON.stringify(current_status));
object_maker.set_bank("#imageTop", current_status.bank); object_maker.set_bank("#imageTop", current_status.bank);
object_maker.set_heading("#imageBackSecond", current_status.heading); object_maker.set_heading("#imageBackSecond", current_status.heading);
} }
if (config_api.modules_status.realtimePlotting) { if (config_api.modules_status.realtimePlotting) {
if (current_status[$('#plotting_attribute').val()] != undefined) { if (current_status[$('#plotting_attribute').val()] != undefined) {
plotting.pushData(current_status[$('#plotting_attribute').val()]); plotting.pushData(current_status[$('#plotting_attribute').val()]);
} }
} }
if (sender_message.basicParam != undefined) { if (sender_message.basicParam != undefined) {
if (sender_message.basicParam.velocity != undefined) { if (sender_message.basicParam.velocity != undefined) {
var velocity = sender_message.basicParam.velocity; var velocity = sender_message.basicParam.velocity;

@ -1,64 +1,12 @@
{{#zone "topCss"}} {{#zone "topCss"}}
{{css "css/main-app.css" }} {{css "css/main-app.css" }}
<style type="text/css">
.circle {
background: none repeat scroll 0 0 #191919;
border-radius: 50px;
height: 50px;
padding: 10px;
width: 50px;
color: #fff;
}
.padding-top-double {
padding-top: 20px;
}
.padding-double {
padding: 20px;
}
.grey {
color: #333;
}
hr {
display: block;
height: 1px;
border: 0;
border-top: 1px solid #7f7f7f;
margin: 1em 0;
padding: 0;
opacity: 0.2;
}
.light-grey {
color: #7c7c7c;
}
.uppercase {
text-transform: uppercase;
}
.grey-bg {
background-color: #f6f4f4;
}
path {
stroke: black;
stroke-width: 2;
fill: none;
}
.axis path, .axis line {
fill: none;
stroke: #ccc;
stroke-width: 2;
shape-rendering: crispEdges;
}
</style>
{{/zone}} {{/zone}}
<div class=" row"> <div class=" row">
<div class="box col-md-12"> <div class="box col-md-12">
<div> <div>
<div class="col-md-2 col-sm-2 col-xs-1"> <div class="col-md-2 col-sm-2 col-xs-1">
<button class="btn btn-primary" data-dismiss="modal" id="connectionOpen" <button class="btn btn-primary" data-dismiss="modal" id="connectionOpen"
onclick="openSocket();">Connect to server</button> onclick="openSocket('{{wssAddress}}');">Connect to XMPP Server</button>
</div> </div>
<div class="col-md-2 col-sm-2 col-xs-1"> <div class="col-md-2 col-sm-2 col-xs-1">
<button class="btn btn-primary" data-dismiss="modal" id="xmppConnectionOpen">Start</button> <button class="btn btn-primary" data-dismiss="modal" id="xmppConnectionOpen">Start</button>
@ -69,27 +17,23 @@
<div class="col-md-4 col-sm-2 col-xs-2"> <div class="col-md-4 col-sm-2 col-xs-2">
<div class="progress"> <div class="progress">
<div class="progress-bar" role="progressbar" aria-valuenow="60" aria-valuemin="0" <div class="progress-bar" role="progressbar" aria-valuenow="60" aria-valuemin="0"
aria-valuemax="100" style="width: 0%;"> aria-valuemax="100" style="width: 0%;" id="battery_level_holder">
0% <p id="battery_level">0%</p>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
</div> </div>
<div class="row"> <!-- <div class="row">
<div class="box col-md-12"> <div class="box col-md-12">
<div class="box-inner"> <div class="box-inner">
<div class="box-header well"> <div class="box-header well">
<h2><i class="glyphicon glyphicon-info-sign"></i> Controller </h2> <h2><i class="glyphicon glyphicon-info-sign"></i> Controller </h2>
<div class="box-icon"> <div class="box-icon">
<a href="#" class="btn btn-setting btn-round btn-default"><i
class="glyphicon glyphicon-cog"></i></a>
<a href="#" class="btn btn-minimize btn-round btn-default"><i <a href="#" class="btn btn-minimize btn-round btn-default"><i
class="glyphicon glyphicon-chevron-up" ></i></a> class="glyphicon glyphicon-chevron-up" ></i></a>
<a href="#" class="btn btn-close btn-round btn-default"><i
class="glyphicon glyphicon-remove"></i></a>
</div> </div>
</div> </div>
<div class="box-content row" id="module_control"> <div class="box-content row" id="module_control">
@ -141,7 +85,7 @@
</div> </div>
</div> </div>
</div> </div>
</div> </div>-->
<div class="row"> <div class="row">
<div class="box col-md-12"> <div class="box col-md-12">
<div class="box col-md-4"> <div class="box col-md-4">
@ -150,12 +94,8 @@
<h2><i class="glyphicon glyphicon-list"></i> Angle of Rotation</h2> <h2><i class="glyphicon glyphicon-list"></i> Angle of Rotation</h2>
<div class="box-icon" id="AngleOfRotation_1"> <div class="box-icon" id="AngleOfRotation_1">
<a href="#" class="btn btn-setting btn-round btn-default"><i
class="glyphicon glyphicon-cog"></i></a>
<a href="#" class="btn btn-minimize btn-round btn-default"><i <a href="#" class="btn btn-minimize btn-round btn-default"><i
class="glyphicon glyphicon-chevron-up"></i></a> class="glyphicon glyphicon-chevron-up"></i></a>
<a href="#" class="btn btn-close btn-round btn-default"><i
class="glyphicon glyphicon-remove"></i></a>
</div> </div>
</div> </div>
<div class="box-content" style="position: relative;" id="objectHolder"> <div class="box-content" style="position: relative;" id="objectHolder">
@ -170,12 +110,8 @@
<div class="box-header well" data-original-title="" > <div class="box-header well" data-original-title="" >
<div class="box-icon" id="AngleOfRotation_2"> <div class="box-icon" id="AngleOfRotation_2">
<a href="#" class="btn btn-setting btn-round btn-default"><i
class="glyphicon glyphicon-cog"></i></a>
<a href="#" class="btn btn-minimize btn-round btn-default"><i <a href="#" class="btn btn-minimize btn-round btn-default"><i
class="glyphicon glyphicon-chevron-up"></i></a> class="glyphicon glyphicon-chevron-up"></i></a>
<a href="#" class="btn btn-close btn-round btn-default"><i
class="glyphicon glyphicon-remove"></i></a>
</div> </div>
</div> </div>
<div class="box-content" > <div class="box-content" >
@ -196,12 +132,8 @@
<div class="box-header well" data-original-title="" > <div class="box-header well" data-original-title="" >
<div class="box-icon" id="AngleOfRotation_3"> <div class="box-icon" id="AngleOfRotation_3">
<a href="#" class="btn btn-setting btn-round btn-default"><i
class="glyphicon glyphicon-cog"></i></a>
<a href="#" class="btn btn-minimize btn-round btn-default"><i <a href="#" class="btn btn-minimize btn-round btn-default"><i
class="glyphicon glyphicon-chevron-up"></i></a> class="glyphicon glyphicon-chevron-up"></i></a>
<a href="#" class="btn btn-close btn-round btn-default"><i
class="glyphicon glyphicon-remove"></i></a>
</div> </div>
</div> </div>
<div class="box-content" > <div class="box-content" >
@ -224,12 +156,8 @@
<h2><i class="glyphicon glyphicon-list"></i>Live Video Stream</h2> <h2><i class="glyphicon glyphicon-list"></i>Live Video Stream</h2>
<div class="box-icon" id="LiveVideoStream"> <div class="box-icon" id="LiveVideoStream">
<a href="#" class="btn btn-setting btn-round btn-default"><i
class="glyphicon glyphicon-cog"></i></a>
<a href="#" class="btn btn-minimize btn-round btn-default"><i <a href="#" class="btn btn-minimize btn-round btn-default"><i
class="glyphicon glyphicon-chevron-up"></i></a> class="glyphicon glyphicon-chevron-up"></i></a>
<a href="#" class="btn btn-close btn-round btn-default"><i
class="glyphicon glyphicon-remove"></i></a>
</div> </div>
</div> </div>
<div class="box-content"> <div class="box-content">
@ -248,20 +176,16 @@
<div class="box-header well" data-original-title="" > <div class="box-header well" data-original-title="" >
<h2><i class="glyphicon glyphicon-list"></i>Sensor Readings</h2> <h2><i class="glyphicon glyphicon-list"></i>Sensor Readings</h2>
<div class="box-icon" id="SensorReadings"> <div class="box-icon" id="SensorReadings">
<a href="#" class="btn btn-setting btn-round btn-default"><i
class="glyphicon glyphicon-cog"></i></a>
<a href="#" class="btn btn-minimize btn-round btn-default"><i <a href="#" class="btn btn-minimize btn-round btn-default"><i
class="glyphicon glyphicon-chevron-up"></i></a> class="glyphicon glyphicon-chevron-up"></i></a>
<a href="#" class="btn btn-close btn-round btn-default"><i
class="glyphicon glyphicon-remove"></i></a>
</div> </div>
</div> </div>
<div class="box-content" id="basicSensoReading"> <div class="box-content" id="basicSensoReading">
<div> <div>
<p>Location latitude: <label id="locationLat"></label></br> <p>Location</br> latitude: <label id="locationLat"></label></br>
longitude: <label id="locationLog"></label></br> longitude: <label id="locationLog"></label></br>
altitudes: <label id="locationAlt"></label></p> altitudes: <label id="locationAlt"></label></p>
<p> Velocity: x :<label id="velocityx"></label></br> <p> Velocity:</br> x :<label id="velocityx"></label></br>
y : <label id="velocityy"></label></br> y : <label id="velocityy"></label></br>
z : <label id="velocityz"></label></p> z : <label id="velocityz"></label></p>
<p> Battery Voltage:<label id="battery_voltage"></label></p> <p> Battery Voltage:<label id="battery_voltage"></label></p>
@ -275,12 +199,8 @@
<h2><i class="glyphicon glyphicon-list-alt"></i>Realtime Plotting</h2> <h2><i class="glyphicon glyphicon-list-alt"></i>Realtime Plotting</h2>
<div class="box-icon" id="RealtimePlotting"> <div class="box-icon" id="RealtimePlotting">
<a href="#" class="btn btn-setting btn-round btn-default"><i
class="glyphicon glyphicon-cog"></i></a>
<a href="#" class="btn btn-minimize btn-round btn-default"><i <a href="#" class="btn btn-minimize btn-round btn-default"><i
class="glyphicon glyphicon-chevron-up"></i></a> class="glyphicon glyphicon-chevron-up"></i></a>
<a href="#" class="btn btn-close btn-round btn-default"><i
class="glyphicon glyphicon-remove"></i></a>
</div> </div>
</div> </div>
<div class="box-content"> <div class="box-content">
@ -310,8 +230,6 @@
</div> </div>
</div> </div>
</div> </div>
{{#zone "bottomJs"}} {{#zone "bottomJs"}}
{{js "/js/d3.min.js" }} {{js "/js/d3.min.js" }}
{{js "/js/3dobject_controller/three.min.js" }} {{js "/js/3dobject_controller/three.min.js" }}

@ -16,27 +16,10 @@
* under the License. * under the License.
*/ */
function onRequest (context) { function onRequest (context) {
/*var log = new Log("detail.js"); var log = new Log("statistics.js");
var deviceType = request.getParameter("type"); var serverAddress = require("/app/modules/serverAddress.js").serverAddress;
var deviceId = request.getParameter("id"); var wssAddress = serverAddress.getWSSAddress();
var httpsAddress = serverAddress.getHPPSTSAddress();
if (deviceType != null && deviceType != undefined && deviceId != null && deviceId != undefined) { var device = context.unit.params.device;
var deviceModule = require("/modules/device.js").deviceModule; return { "device": device, "wssAddress": wssAddress, "httpsAddress": httpsAddress};
var device = deviceModule.viewDevice(deviceType, deviceId);
if (device) {
var viewModel = {};
var deviceInfo = device.properties.DEVICE_INFO;
if (deviceInfo != undefined && String(deviceInfo.toString()).length > 0) {
deviceInfo = parse(stringify(deviceInfo));
viewModel.system = device.properties.IMEI;
viewModel.machine = "Virtual Firealarm";
viewModel.vendor = device.properties.VENDOR;
}
device.viewModel = viewModel;
}
context.device = device;
return context;
}*/
} }
Loading…
Cancel
Save