@ -1,281 +0,0 @@
|
||||
<!--
|
||||
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
~
|
||||
~ WSO2 Inc. licenses this file to you under the Apache License,
|
||||
~ Version 2.0 (the "License"); you may not use this file except
|
||||
~ in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing,
|
||||
~ software distributed under the License is distributed on an
|
||||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
~ KIND, either express or implied. See the License for the
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<parent>
|
||||
<groupId>org.homeautomation</groupId>
|
||||
<artifactId>droneanalyzer-component</artifactId>
|
||||
<version>2.1.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<artifactId>${groupId}.droneanalyzer.api</artifactId>
|
||||
<version>2.1.0-SNAPSHOT</version>
|
||||
<packaging>war</packaging>
|
||||
<name>${groupId}.droneanalyzer API</name>
|
||||
<url>http://wso2.com</url>
|
||||
|
||||
<dependencies>
|
||||
<!-- CDM -->
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.core</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.apache.axis2.wso2</groupId>
|
||||
<artifactId>axis2-client</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.analytics.data.publisher</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.apache.axis2.wso2</groupId>
|
||||
<artifactId>axis2-client</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.certificate.mgt.core</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>commons-codec.wso2</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-collections4</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--CXF -->
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-frontend-jaxws</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-transports-http</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--MQTT -->
|
||||
<dependency>
|
||||
<groupId>org.eclipse.paho</groupId>
|
||||
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
|
||||
</dependency>
|
||||
|
||||
<!--IOT -->
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpasyncclient</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.iot</artifactId>
|
||||
</dependency>
|
||||
<!--
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl</artifactId>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
-->
|
||||
|
||||
<!--JAX-RS -->
|
||||
<dependency>
|
||||
<groupId>org.codehaus.jackson</groupId>
|
||||
<artifactId>jackson-core-asl</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.jackson</groupId>
|
||||
<artifactId>jackson-jaxrs</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax</groupId>
|
||||
<artifactId>javaee-web-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.ws.rs</groupId>
|
||||
<artifactId>jsr311-api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-httpclient.wso2</groupId>
|
||||
<artifactId>commons-httpclient</artifactId>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.utils</artifactId>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.bouncycastle.wso2</groupId>
|
||||
<artifactId>bcprov-jdk15on</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.user.api</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.queuing</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.base</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.apache.axis2.wso2</groupId>
|
||||
<artifactId>axis2</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.igniterealtime.smack.wso2</groupId>
|
||||
<artifactId>smack</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.igniterealtime.smack.wso2</groupId>
|
||||
<artifactId>smackx</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>jaxen</groupId>
|
||||
<artifactId>jaxen</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>commons-fileupload.wso2</groupId>
|
||||
<artifactId>commons-fileupload</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.apache.ant.wso2</groupId>
|
||||
<artifactId>ant</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.apache.ant.wso2</groupId>
|
||||
<artifactId>ant</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>commons-httpclient.wso2</groupId>
|
||||
<artifactId>commons-httpclient</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.eclipse.equinox</groupId>
|
||||
<artifactId>javax.servlet</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.registry.api</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.igniterealtime.smack.wso2</groupId>
|
||||
<artifactId>smack</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.igniterealtime.smack.wso2</groupId>
|
||||
<artifactId>smackx</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.apimgt.annotations</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.apimgt.webapp.publisher</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.homeautomation</groupId>
|
||||
<artifactId>org.homeautomation.droneanalyzer.plugin</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.extensions</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.apimgt.application.extension</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.identity.jwt.client.extension</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.user.api</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.json</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.websocket</groupId>
|
||||
<artifactId>javax.websocket-api</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
<build>
|
||||
<sourceDirectory>${basedir}/src/main/java</sourceDirectory>
|
||||
<plugins>
|
||||
<!--plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<encoding>UTF-8</encoding>
|
||||
<source>${wso2.maven.compiler.source}</source>
|
||||
<target>${wso2.maven.compiler.target}</target>
|
||||
</configuration>
|
||||
</plugin-->
|
||||
|
||||
<plugin>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<source>1.7</source>
|
||||
<target>1.7</target>
|
||||
</configuration>
|
||||
<version>2.3.2</version>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<artifactId>maven-war-plugin</artifactId>
|
||||
<configuration>
|
||||
<warName>drone_analyzer</warName>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
@ -1,46 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.homeautomation.droneanalyzer.api;
|
||||
|
||||
import org.wso2.carbon.apimgt.annotations.api.API;
|
||||
import org.wso2.carbon.device.mgt.extensions.feature.mgt.annotations.DeviceType;
|
||||
|
||||
import javax.ws.rs.FormParam;
|
||||
import javax.ws.rs.POST;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
@API(name = "drone_analyzer", version = "1.0.0", context = "/drone_analyzer", tags = {"drone_analyzer"})
|
||||
@DeviceType(value = "drone_analyzer")
|
||||
public interface DroneControllerService {
|
||||
|
||||
@Path("device/register/{deviceId}/{ip}/{port}")
|
||||
@POST
|
||||
Response registerDeviceIP(@PathParam("deviceId") String deviceId, @PathParam("ip") String deviceIP,
|
||||
@PathParam("port") String devicePort);
|
||||
|
||||
@Path("device/{deviceId}/send_command")
|
||||
@POST
|
||||
/*@Feature( code="send_command", name="Send Command", type="operation",
|
||||
description="Send Commands to Drone")*/
|
||||
Response droneController(@PathParam("deviceId") String deviceId, @FormParam("action") String action,
|
||||
@FormParam("duration") String duration, @FormParam("speed") String speed);
|
||||
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.homeautomation.droneanalyzer.api;
|
||||
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.homeautomation.droneanalyzer.api.util.DroneAnalyzerServiceUtils;
|
||||
import org.homeautomation.droneanalyzer.plugin.controller.DroneController;
|
||||
import org.homeautomation.droneanalyzer.plugin.controller.impl.DroneControllerImpl;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
public class DroneControllerServiceImpl implements DroneControllerService {
|
||||
|
||||
private static org.apache.commons.logging.Log log = LogFactory.getLog(DroneControllerServiceImpl.class);
|
||||
private ConcurrentHashMap<String, String> deviceToIpMap = new ConcurrentHashMap<>();
|
||||
private DroneController droneController = new DroneControllerImpl();
|
||||
|
||||
public Response registerDeviceIP(String deviceId, String deviceIP, String devicePort) {
|
||||
String result;
|
||||
String deviceHttpEndpoint = deviceIP + ":" + devicePort;
|
||||
deviceToIpMap.put(deviceId, deviceHttpEndpoint);
|
||||
result = "Device-IP Registered";
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug(result);
|
||||
}
|
||||
return Response.ok(Response.Status.OK.getStatusCode()).build();
|
||||
}
|
||||
|
||||
public Response droneController(String deviceId, String action, String duration, String speed) {
|
||||
try {
|
||||
DroneAnalyzerServiceUtils.sendControlCommand(droneController, deviceId, action, Double.valueOf(speed),
|
||||
Double.valueOf(duration));
|
||||
return Response.status(Response.Status.ACCEPTED).build();
|
||||
} catch (DeviceManagementException e) {
|
||||
log.error("Drone command didn't success. Try again, \n" + e);
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR).build();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,69 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.homeautomation.droneanalyzer.api;
|
||||
|
||||
import org.wso2.carbon.apimgt.annotations.api.API;
|
||||
import org.wso2.carbon.device.mgt.extensions.feature.mgt.annotations.DeviceType;
|
||||
|
||||
import javax.ws.rs.Consumes;
|
||||
import javax.ws.rs.DELETE;
|
||||
import javax.ws.rs.GET;
|
||||
import javax.ws.rs.PUT;
|
||||
import javax.ws.rs.Path;
|
||||
import javax.ws.rs.PathParam;
|
||||
import javax.ws.rs.Produces;
|
||||
import javax.ws.rs.QueryParam;
|
||||
import javax.ws.rs.core.Response;
|
||||
|
||||
@API(name = "drone_analyzer_mgt", version = "1.0.0", context = "/drone_analyzer_mgt", tags = {"drone_analyzer"})
|
||||
@DeviceType(value = "drone_analyzer")
|
||||
public interface DroneManagerService {
|
||||
|
||||
@Path("devices/{device_id}")
|
||||
@DELETE
|
||||
Response removeDevice(@PathParam("device_id") String deviceId);
|
||||
|
||||
@Path("devices/{device_id}")
|
||||
@PUT
|
||||
Response updateDevice(@PathParam("device_id") String deviceId, @QueryParam("name") String name);
|
||||
|
||||
@Path("devices/{device_id}")
|
||||
@GET
|
||||
@Consumes("application/json")
|
||||
@Produces("application/json")
|
||||
Response getDevice(@PathParam("device_id") String deviceId);
|
||||
|
||||
@Path("devices")
|
||||
@GET
|
||||
@Consumes("application/json")
|
||||
@Produces("application/json")
|
||||
Response getDroneDevices();
|
||||
|
||||
@Path("devices/{sketch_type}/download")
|
||||
@GET
|
||||
@Produces("application/octet-stream")
|
||||
Response downloadSketch(@QueryParam("deviceName") String deviceName, @PathParam("sketch_type") String sketchType);
|
||||
|
||||
@Path("devices/{sketch_type}/generate_link")
|
||||
@GET
|
||||
Response generateSketchLink(@QueryParam("deviceName") String deviceName,
|
||||
@PathParam("sketch_type") String sketchType);
|
||||
|
||||
}
|
||||
|
@ -1,259 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.homeautomation.droneanalyzer.api;
|
||||
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.homeautomation.droneanalyzer.api.util.APIUtil;
|
||||
import org.homeautomation.droneanalyzer.plugin.constants.DroneConstants;
|
||||
import org.wso2.carbon.apimgt.application.extension.APIManagementProviderService;
|
||||
import org.wso2.carbon.apimgt.application.extension.dto.ApiApplicationKey;
|
||||
import org.wso2.carbon.apimgt.application.extension.exception.APIManagerException;
|
||||
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||
import org.wso2.carbon.device.mgt.common.Device;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
|
||||
import org.wso2.carbon.device.mgt.iot.controlqueue.xmpp.XmppAccount;
|
||||
import org.wso2.carbon.device.mgt.iot.controlqueue.xmpp.XmppConfig;
|
||||
import org.wso2.carbon.device.mgt.iot.controlqueue.xmpp.XmppServerClient;
|
||||
import org.wso2.carbon.device.mgt.iot.exception.DeviceControllerException;
|
||||
import org.wso2.carbon.device.mgt.iot.util.ZipArchive;
|
||||
import org.wso2.carbon.device.mgt.iot.util.ZipUtil;
|
||||
import org.wso2.carbon.identity.jwt.client.extension.JWTClient;
|
||||
import org.wso2.carbon.identity.jwt.client.extension.JWTClientManager;
|
||||
import org.wso2.carbon.identity.jwt.client.extension.dto.AccessTokenInfo;
|
||||
import org.wso2.carbon.identity.jwt.client.extension.exception.JWTClientException;
|
||||
import org.wso2.carbon.user.api.UserStoreException;
|
||||
|
||||
import javax.ws.rs.core.Response;
|
||||
import java.nio.ByteBuffer;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
|
||||
public class DroneManagerServiceImpl implements DroneManagerService {
|
||||
|
||||
private static org.apache.commons.logging.Log log = LogFactory.getLog(DroneManagerServiceImpl.class);
|
||||
private static final String KEY_TYPE = "PRODUCTION";
|
||||
private static ApiApplicationKey apiApplicationKey;
|
||||
|
||||
private boolean register(String deviceId, String name) {
|
||||
try {
|
||||
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
|
||||
deviceIdentifier.setId(deviceId);
|
||||
deviceIdentifier.setType(DroneConstants.DEVICE_TYPE);
|
||||
if (APIUtil.getDeviceManagementService().isEnrolled(deviceIdentifier)) {
|
||||
return false;
|
||||
}
|
||||
Device device = new Device();
|
||||
device.setDeviceIdentifier(deviceId);
|
||||
EnrolmentInfo enrolmentInfo = new EnrolmentInfo();
|
||||
enrolmentInfo.setDateOfEnrolment(new Date().getTime());
|
||||
enrolmentInfo.setDateOfLastUpdate(new Date().getTime());
|
||||
enrolmentInfo.setStatus(EnrolmentInfo.Status.ACTIVE);
|
||||
enrolmentInfo.setOwnership(EnrolmentInfo.OwnerShip.BYOD);
|
||||
device.setName(name);
|
||||
device.setType(DroneConstants.DEVICE_TYPE);
|
||||
enrolmentInfo.setOwner(APIUtil.getAuthenticatedUser());
|
||||
device.setEnrolmentInfo(enrolmentInfo);
|
||||
boolean added = APIUtil.getDeviceManagementService().enrollDevice(device);
|
||||
return added;
|
||||
} catch (DeviceManagementException e) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
public Response removeDevice(String deviceId) {
|
||||
try {
|
||||
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
|
||||
deviceIdentifier.setId(deviceId);
|
||||
deviceIdentifier.setType(DroneConstants.DEVICE_TYPE);
|
||||
boolean removed = APIUtil.getDeviceManagementService().disenrollDevice(deviceIdentifier);
|
||||
if (removed) {
|
||||
return Response.ok().build();
|
||||
} else {
|
||||
return Response.status(Response.Status.NOT_ACCEPTABLE.getStatusCode()).build();
|
||||
}
|
||||
} catch (DeviceManagementException e) {
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).build();
|
||||
}
|
||||
}
|
||||
|
||||
public Response updateDevice(String deviceId, String name) {
|
||||
try {
|
||||
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
|
||||
deviceIdentifier.setId(deviceId);
|
||||
deviceIdentifier.setType(DroneConstants.DEVICE_TYPE);
|
||||
Device device = APIUtil.getDeviceManagementService().getDevice(deviceIdentifier);
|
||||
device.setDeviceIdentifier(deviceId);
|
||||
device.getEnrolmentInfo().setDateOfLastUpdate(new Date().getTime());
|
||||
device.setName(name);
|
||||
device.setType(DroneConstants.DEVICE_TYPE);
|
||||
boolean updated = APIUtil.getDeviceManagementService().modifyEnrollment(device);
|
||||
if (updated) {
|
||||
return Response.ok().build();
|
||||
} else {
|
||||
return Response.status(Response.Status.NOT_ACCEPTABLE.getStatusCode()).build();
|
||||
}
|
||||
} catch (DeviceManagementException e) {
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).build();
|
||||
}
|
||||
}
|
||||
|
||||
public Response getDevice(String deviceId) {
|
||||
try {
|
||||
DeviceIdentifier deviceIdentifier = new DeviceIdentifier();
|
||||
deviceIdentifier.setId(deviceId);
|
||||
deviceIdentifier.setType(DroneConstants.DEVICE_TYPE);
|
||||
Device device = APIUtil.getDeviceManagementService().getDevice(deviceIdentifier);
|
||||
return Response.ok().entity(device).build();
|
||||
} catch (DeviceManagementException e) {
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).build();
|
||||
}
|
||||
}
|
||||
|
||||
public Response getDroneDevices() {
|
||||
try {
|
||||
List<Device> userDevices = APIUtil.getDeviceManagementService().getDevicesOfUser(APIUtil.getAuthenticatedUser());
|
||||
ArrayList<Device> userDevicesforDrone = new ArrayList<>();
|
||||
for (Device device : userDevices) {
|
||||
if (device.getType().equals(DroneConstants.DEVICE_TYPE) &&
|
||||
device.getEnrolmentInfo().getStatus().equals(
|
||||
EnrolmentInfo.Status.ACTIVE)) {
|
||||
userDevicesforDrone.add(device);
|
||||
}
|
||||
}
|
||||
Device[] devices = userDevicesforDrone.toArray(new Device[]{});
|
||||
return Response.ok().entity(devices).build();
|
||||
} catch (DeviceManagementException e) {
|
||||
return Response.status(Response.Status.INTERNAL_SERVER_ERROR.getStatusCode()).build();
|
||||
}
|
||||
}
|
||||
|
||||
public Response downloadSketch(String deviceName, String sketchType) {
|
||||
|
||||
//create new device id
|
||||
String deviceId = shortUUID();
|
||||
//create token
|
||||
String token = UUID.randomUUID().toString();
|
||||
String refreshToken = UUID.randomUUID().toString();
|
||||
//adding registering data
|
||||
boolean status = register(deviceId, deviceName);
|
||||
if (!status) {
|
||||
return Response.status(500).entity(
|
||||
"Error occurred while registering the device with " + "id: " + deviceId + " owner:" +
|
||||
APIUtil.getAuthenticatedUser()).build();
|
||||
|
||||
}
|
||||
ZipUtil ziputil = new ZipUtil();
|
||||
ZipArchive zipFile;
|
||||
try {
|
||||
zipFile = ziputil.createZipFile(APIUtil.getAuthenticatedUser(), APIUtil.getTenantDomainOftheUser(),
|
||||
sketchType, deviceId, deviceName, token, refreshToken);
|
||||
} catch (DeviceManagementException ex) {
|
||||
return Response.status(500).entity("Error occurred while creating zip file").build();
|
||||
}
|
||||
Response.ResponseBuilder rb = Response.ok(zipFile.getZipFile());
|
||||
rb.header("Content-Disposition", "attachment; filename=\"" + zipFile.getFileName() + "\"");
|
||||
return rb.build();
|
||||
|
||||
}
|
||||
|
||||
public Response generateSketchLink(String deviceName, String sketchType) {
|
||||
try {
|
||||
ZipArchive zipFile = createDownloadFile(deviceName, sketchType);
|
||||
Response.ResponseBuilder rb = Response.ok(zipFile.getDeviceId());
|
||||
return rb.build();
|
||||
} catch (IllegalArgumentException ex) {
|
||||
return Response.status(400).entity(ex.getMessage()).build();
|
||||
} catch (DeviceManagementException ex) {
|
||||
return Response.status(500).entity(ex.getMessage()).build();
|
||||
} catch (JWTClientException ex) {
|
||||
return Response.status(500).entity(ex.getMessage()).build();
|
||||
} catch (DeviceControllerException ex) {
|
||||
return Response.status(500).entity(ex.getMessage()).build();
|
||||
} catch (APIManagerException ex) {
|
||||
return Response.status(500).entity(ex.getMessage()).build();
|
||||
} catch (UserStoreException ex) {
|
||||
return Response.status(500).entity(ex.getMessage()).build();
|
||||
}
|
||||
}
|
||||
|
||||
private ZipArchive createDownloadFile(String deviceName, String sketchType)
|
||||
throws DeviceManagementException, JWTClientException, APIManagerException, DeviceControllerException,
|
||||
UserStoreException {
|
||||
//create new device id
|
||||
String deviceId = shortUUID();
|
||||
if (apiApplicationKey == null) {
|
||||
String applicationUsername = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUserRealm().getRealmConfiguration()
|
||||
.getAdminUserName();
|
||||
APIManagementProviderService apiManagementProviderService = APIUtil.getAPIManagementProviderService();
|
||||
String[] tags = {DroneConstants.DEVICE_TYPE};
|
||||
apiApplicationKey = apiManagementProviderService.generateAndRetrieveApplicationKeys(
|
||||
DroneConstants.DEVICE_TYPE, tags, KEY_TYPE, applicationUsername, true);
|
||||
}
|
||||
JWTClient jwtClient = JWTClientManager.getInstance().getJWTClient();
|
||||
String owner = PrivilegedCarbonContext.getThreadLocalCarbonContext().getUsername();
|
||||
String scopes = "device_type_" + DroneConstants.DEVICE_TYPE + " device_" + deviceId;
|
||||
AccessTokenInfo accessTokenInfo = jwtClient.getAccessToken(apiApplicationKey.getConsumerKey(),
|
||||
apiApplicationKey.getConsumerSecret(), owner, scopes);
|
||||
//create token
|
||||
String accessToken = accessTokenInfo.getAccess_token();
|
||||
String refreshToken = accessTokenInfo.getRefresh_token();
|
||||
//adding registering data
|
||||
XmppAccount newXmppAccount = new XmppAccount();
|
||||
newXmppAccount.setAccountName(APIUtil.getAuthenticatedUser() + "_" + deviceId);
|
||||
newXmppAccount.setUsername(deviceId);
|
||||
newXmppAccount.setPassword(accessToken);
|
||||
newXmppAccount.setEmail(deviceId + "@wso2.com");
|
||||
XmppServerClient xmppServerClient = new XmppServerClient();
|
||||
xmppServerClient.initControlQueue();
|
||||
boolean status;
|
||||
if (XmppConfig.getInstance().isEnabled()) {
|
||||
status = xmppServerClient.createXMPPAccount(newXmppAccount);
|
||||
if (!status) {
|
||||
String msg = "XMPP Account was not created for device - " + deviceId + " of owner - " +
|
||||
APIUtil.getAuthenticatedUser() + ".XMPP might have been disabled in " +
|
||||
"org.wso2.carbon.device.mgt.iot.common.config.server.configs";
|
||||
log.warn(msg);
|
||||
throw new DeviceManagementException(msg);
|
||||
}
|
||||
}
|
||||
//Register the device with CDMF
|
||||
status = register(deviceId, deviceName);
|
||||
if (!status) {
|
||||
String msg = "Error occurred while registering the device with " + "id: " + deviceId
|
||||
+ " owner:" + APIUtil.getAuthenticatedUser();
|
||||
throw new DeviceManagementException(msg);
|
||||
}
|
||||
ZipUtil ziputil = new ZipUtil();
|
||||
ZipArchive zipFile = ziputil.createZipFile(APIUtil.getAuthenticatedUser(), APIUtil.getTenantDomainOftheUser(),
|
||||
sketchType, deviceId, deviceName, accessToken, refreshToken);
|
||||
zipFile.setDeviceId(deviceId);
|
||||
return zipFile;
|
||||
}
|
||||
|
||||
private static String shortUUID() {
|
||||
UUID uuid = UUID.randomUUID();
|
||||
long l = ByteBuffer.wrap(uuid.toString().getBytes(StandardCharsets.UTF_8)).getLong();
|
||||
return Long.toString(l, Character.MAX_RADIX);
|
||||
}
|
||||
}
|
@ -1,125 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.homeautomation.droneanalyzer.api;
|
||||
|
||||
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.homeautomation.droneanalyzer.api.transport.DroneAnalyzerXMPPConnector;
|
||||
import org.homeautomation.droneanalyzer.api.trasformer.MessageTransformer;
|
||||
import org.homeautomation.droneanalyzer.plugin.constants.DroneConstants;
|
||||
import org.wso2.carbon.device.mgt.iot.controlqueue.xmpp.XmppConfig;
|
||||
import org.wso2.carbon.device.mgt.iot.service.IoTServerStartupListener;
|
||||
|
||||
import javax.websocket.OnClose;
|
||||
import javax.websocket.OnError;
|
||||
import javax.websocket.OnMessage;
|
||||
import javax.websocket.OnOpen;
|
||||
import javax.websocket.Session;
|
||||
import javax.websocket.server.ServerEndpoint;
|
||||
import java.io.IOException;
|
||||
|
||||
@ServerEndpoint("/datastream/drone_status")
|
||||
public class DroneRealTimeService {
|
||||
|
||||
private static org.apache.commons.logging.Log log = LogFactory.getLog(DroneRealTimeService.class);
|
||||
private MessageTransformer messageController;
|
||||
private DroneAnalyzerXMPPConnector xmppConnector;
|
||||
|
||||
public DroneRealTimeService() {
|
||||
Runnable connector = new Runnable() {
|
||||
public void run() {
|
||||
if (waitForServerStartup()) {
|
||||
return;
|
||||
}
|
||||
messageController = new MessageTransformer();
|
||||
xmppConnector = new DroneAnalyzerXMPPConnector(messageController);
|
||||
if (XmppConfig.getInstance().isEnabled()){
|
||||
xmppConnector.connect();
|
||||
} else {
|
||||
log.warn("XMPP disabled in 'devicemgt-config.xml'. Hence, DroneAnalyzerXMPPConnector not started.");
|
||||
}
|
||||
}
|
||||
};
|
||||
Thread connectorThread = new Thread(connector);
|
||||
connectorThread.setDaemon(true);
|
||||
connectorThread.start();
|
||||
}
|
||||
|
||||
private boolean waitForServerStartup() {
|
||||
while (!IoTServerStartupListener.isServerReady()) {
|
||||
try {
|
||||
Thread.sleep(1000);
|
||||
} catch (InterruptedException e) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@OnOpen
|
||||
public void onOpen(Session session){
|
||||
log.info(session.getId() + " has opened a connection");
|
||||
try {
|
||||
session.getBasicRemote().sendText("Connection Established");
|
||||
} catch (IOException e) {
|
||||
log.error( e.getMessage()+"\n"+ e);
|
||||
}
|
||||
}
|
||||
|
||||
@OnMessage
|
||||
public void onMessage(String message, Session session){
|
||||
while (true) {
|
||||
try {
|
||||
if (messageController != null && !messageController.isEmptyQueue()) {
|
||||
String messageControllerMessage = messageController.getMessage();
|
||||
session.getBasicRemote().sendText(messageControllerMessage);
|
||||
break;
|
||||
}
|
||||
Thread.sleep(DroneConstants.MINIMUM_TIME_DURATION);
|
||||
} catch (IOException | InterruptedException ex) {
|
||||
log.error(ex.getMessage(), ex);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@OnClose
|
||||
public void onClose(Session session){
|
||||
try {
|
||||
xmppConnector.disconnect();
|
||||
log.info("XMPP connection is disconnected");
|
||||
}
|
||||
catch (Exception e) {
|
||||
log.error(e.getMessage() + "\n" + e);
|
||||
}
|
||||
log.info("Session " + session.getId() + " has ended");
|
||||
}
|
||||
|
||||
@OnError
|
||||
public void onError(Session session, Throwable t) {
|
||||
try {
|
||||
session.getBasicRemote().sendText("Connection closed");
|
||||
xmppConnector.disconnect();
|
||||
log.info("XMPP connection is disconnected");
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage()+"\n"+ e);
|
||||
}
|
||||
log.info("Session " + session.getId() + " has ended");
|
||||
}
|
||||
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.homeautomation.droneanalyzer.api.exception;
|
||||
|
||||
public class DroneAnalyzerException extends Exception {
|
||||
|
||||
private static final long serialVersionUID = 118512086958330189L;
|
||||
|
||||
public DroneAnalyzerException(String errorMessage) {
|
||||
super(errorMessage);
|
||||
}
|
||||
|
||||
public DroneAnalyzerException(String errorMessage, Throwable throwable) {
|
||||
super(errorMessage, throwable);
|
||||
}
|
||||
}
|
@ -1,160 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.homeautomation.droneanalyzer.api.transport;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.homeautomation.droneanalyzer.api.trasformer.MessageTransformer;
|
||||
import org.homeautomation.droneanalyzer.plugin.constants.DroneConstants;
|
||||
import org.jivesoftware.smack.packet.Message;
|
||||
import org.wso2.carbon.device.mgt.iot.controlqueue.xmpp.XmppConfig;
|
||||
import org.wso2.carbon.device.mgt.iot.transport.TransportHandlerException;
|
||||
import org.wso2.carbon.device.mgt.iot.transport.xmpp.XMPPTransportHandler;
|
||||
|
||||
import java.util.concurrent.Executors;
|
||||
import java.util.concurrent.ScheduledExecutorService;
|
||||
import java.util.concurrent.ScheduledFuture;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
public class DroneAnalyzerXMPPConnector extends XMPPTransportHandler {
|
||||
private static Log log = LogFactory.getLog(DroneAnalyzerXMPPConnector.class);
|
||||
|
||||
private static String xmppServerIP;
|
||||
private static String xmppAdminUsername;
|
||||
private static String xmppAdminPassword;
|
||||
private static String xmppAdminAccountJID;
|
||||
private MessageTransformer messageTransformer;
|
||||
private ScheduledFuture<?> connectorServiceHandler;
|
||||
private ScheduledExecutorService service = Executors.newSingleThreadScheduledExecutor();
|
||||
|
||||
public DroneAnalyzerXMPPConnector(MessageTransformer messageTransformer) {
|
||||
super(XmppConfig.getInstance().getXmppServerIP(), XmppConfig.getInstance().getSERVER_CONNECTION_PORT());
|
||||
this.messageTransformer = messageTransformer;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void connect() {
|
||||
Runnable connector = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
if (!isConnected()) {
|
||||
try {
|
||||
initConnector();
|
||||
connectToServer();
|
||||
loginToServer(xmppAdminUsername, xmppAdminPassword, null);
|
||||
setFilterOnReceiver(xmppAdminAccountJID);
|
||||
} catch (TransportHandlerException e) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.warn("Connection/Login to XMPP server at: " + server + " as " +
|
||||
xmppAdminUsername + " failed for device-type [" +
|
||||
DroneConstants.DEVICE_TYPE + "].", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
connectorServiceHandler = service.scheduleAtFixedRate(connector, 0, timeoutInterval, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
public void initConnector() {
|
||||
xmppServerIP = XmppConfig.getInstance().getXmppServerIP();
|
||||
xmppAdminUsername = XmppConfig.getInstance().getXmppUsername();
|
||||
xmppAdminPassword = XmppConfig.getInstance().getXmppPassword();
|
||||
xmppAdminAccountJID = xmppAdminUsername + "@" + xmppServerIP;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processIncomingMessage(Message message) throws TransportHandlerException {
|
||||
try {
|
||||
String from = message.getFrom();
|
||||
String inboundMessage = message.getBody();
|
||||
int indexOfSlash = from.indexOf("/");
|
||||
if (indexOfSlash == 0) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Required resource not available.");
|
||||
}
|
||||
} else {
|
||||
String resource = from.substring(indexOfSlash + 1, from.length());
|
||||
if ((inboundMessage != null) && (resource.equals(DroneConstants.MESSAGE_RESOURCE))) {
|
||||
messageTransformer.messageTranslater(inboundMessage);
|
||||
} 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);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void publishDeviceData(String... publishData) throws TransportHandlerException {
|
||||
String xmppJID = publishData[0];
|
||||
String xmppMessage = publishData[1];
|
||||
String xmppSubject = publishData[2];
|
||||
sendXMPPMessage(xmppJID, xmppMessage, xmppSubject);
|
||||
}
|
||||
|
||||
public void disconnect() {
|
||||
Runnable stopConnection = new Runnable() {
|
||||
public void run() {
|
||||
while (isConnected()) {
|
||||
connectorServiceHandler.cancel(true);
|
||||
closeConnection();
|
||||
if (log.isDebugEnabled()) {
|
||||
log.warn("Unable to 'STOP' connection to XMPP server at: " + server +
|
||||
" for user - " + xmppAdminUsername);
|
||||
}
|
||||
try {
|
||||
Thread.sleep(timeoutInterval);
|
||||
} catch (InterruptedException e1) {
|
||||
log.error("XMPP-Terminator: Thread Sleep Interrupt Exception for "
|
||||
+ DroneConstants.DEVICE_TYPE + " type.", e1);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
Thread terminatorThread = new Thread(stopConnection);
|
||||
terminatorThread.setDaemon(true);
|
||||
terminatorThread.start();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processIncomingMessage() throws TransportHandlerException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void processIncomingMessage(Message message, String... messageParams) throws TransportHandlerException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void publishDeviceData() throws TransportHandlerException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void publishDeviceData(Message publishData) throws TransportHandlerException {
|
||||
|
||||
}
|
||||
}
|
@ -1,134 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.homeautomation.droneanalyzer.api.trasformer;
|
||||
|
||||
|
||||
import org.apache.commons.collections4.queue.CircularFifoQueue;
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.codehaus.jackson.JsonNode;
|
||||
import org.codehaus.jackson.JsonProcessingException;
|
||||
import org.codehaus.jackson.map.ObjectMapper;
|
||||
import org.homeautomation.droneanalyzer.plugin.constants.DroneConstants;
|
||||
import org.homeautomation.droneanalyzer.plugin.constants.MessageConfig;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
|
||||
public class MessageTransformer {
|
||||
|
||||
private Log log = LogFactory.getLog(MessageTransformer.class);
|
||||
private CircularFifoQueue<String> sharedQueue;
|
||||
|
||||
private String outboundMessageFormatForSimulator = "{\"quatanium_val\":[%f, %f, %f, %f]," +
|
||||
"\"basicParam\":{\"velocity\":[%f, %f, %f], \"global_location\":[%f, %f, %f]},\"battery_level\":%f, \"device_type\":\"SIMULATOR\"}";
|
||||
private String outboundMessageFormatForIrisDrone = "{\"quatanium_val\":[%f, %f, %f]," +
|
||||
"\"basicParam\":{\"velocity\":[%f, %f, %f], \"global_location\":[%f, %f, %f]},\"battery_level\":%f," +
|
||||
"\"device_type\":\"IRIS_DRONE\"}";
|
||||
|
||||
public MessageTransformer(){
|
||||
sharedQueue = new CircularFifoQueue<String>(DroneConstants.MAXIMUM_BUFFERE_SIZE_OF_SHARED_QUEUE);
|
||||
}
|
||||
|
||||
private void messageTranslaterForSimulator(JsonNode inbound_message){
|
||||
JsonNode node = inbound_message;
|
||||
String outboundMessage;
|
||||
try {
|
||||
JsonNode velocity = node.get(MessageConfig.OUT_BASIC_PARAM_VAL).get(MessageConfig.OUT_BASIC_PARAM_VELOCITY);
|
||||
JsonNode globalLocation = node.get(MessageConfig.OUT_BASIC_PARAM_VAL).get(
|
||||
MessageConfig.OUT_BASIC_PARAM_GLOBAL_LOCATION);
|
||||
JsonNode quataniumVals = node.get(MessageConfig.OUT_QUATANNIM_VAL);
|
||||
JsonNode batteryLevel = node.get(MessageConfig.OUT_BATTERY_LEVEL);
|
||||
outboundMessage = String.format(outboundMessageFormatForSimulator, sTd(quataniumVals.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(globalLocation.get(0)),
|
||||
sTd(globalLocation.get(1)), sTd(globalLocation.get(2)), sTd(batteryLevel));
|
||||
sharedQueue.add(outboundMessage);
|
||||
} catch (Exception e) {
|
||||
log.error(e.getMessage()+",\n"+ e);
|
||||
}
|
||||
}
|
||||
|
||||
private void messageTranslaterForIRISDrone(JsonNode inbound_message){
|
||||
JsonNode node = inbound_message;
|
||||
String outboundMessage;
|
||||
try {
|
||||
|
||||
JsonNode velocity = node.get(MessageConfig.OUT_BASIC_PARAM_VAL).get(MessageConfig.OUT_BASIC_PARAM_VELOCITY);
|
||||
JsonNode globalLocation = node.get(MessageConfig.OUT_BASIC_PARAM_VAL).get(
|
||||
MessageConfig.OUT_BASIC_PARAM_GLOBAL_LOCATION);
|
||||
JsonNode quataniumVals = node.get(MessageConfig.OUT_QUATANNIM_VAL);
|
||||
JsonNode batteryLevel = node.get(MessageConfig.OUT_BATTERY_LEVEL);
|
||||
outboundMessage = String.format(outboundMessageFormatForIrisDrone, sTd(quataniumVals.get(0)),
|
||||
sTd(quataniumVals.get(1)), sTd(quataniumVals.get(2)), sTd(velocity.get(0)),
|
||||
sTd(velocity.get(1)), sTd(velocity.get(2)), sTd(globalLocation.get(0)),
|
||||
sTd(globalLocation.get(1)), sTd(globalLocation.get(2)), sTd(batteryLevel));
|
||||
sharedQueue.add(outboundMessage);
|
||||
|
||||
}catch (Exception e) {
|
||||
log.error(e.getMessage()+",\n"+ e);
|
||||
}
|
||||
}
|
||||
|
||||
public void messageTranslater(String inbound_message){
|
||||
JsonNode actualMessage;
|
||||
ObjectMapper objectMapper = new ObjectMapper();
|
||||
try {
|
||||
actualMessage = objectMapper.readValue(inbound_message, JsonNode.class);
|
||||
JsonNode deviceType = actualMessage.get(MessageConfig.IN_DEVICE_TYPE);
|
||||
switch (deviceType.getTextValue()) {
|
||||
case MessageConfig.IN_IRIS_DRONE:
|
||||
messageTranslaterForIRISDrone(actualMessage);
|
||||
break;
|
||||
case MessageConfig.IN_SIMULATOR:
|
||||
messageTranslaterForSimulator(actualMessage);
|
||||
break;
|
||||
default:
|
||||
if(log.isDebugEnabled()){
|
||||
log.debug("Wrong message format");
|
||||
}
|
||||
}
|
||||
} catch (JsonProcessingException e) {
|
||||
log.error("Incoming message might be corrupted, "+ e);
|
||||
} catch (IOException e) {
|
||||
log.error(e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
private double sTd(JsonNode s)
|
||||
{
|
||||
return Double.parseDouble(s.toString());
|
||||
}
|
||||
|
||||
public String getMessage() {
|
||||
try{
|
||||
if(sharedQueue.isEmpty() || sharedQueue == null){
|
||||
return "";
|
||||
}
|
||||
return sharedQueue.remove();
|
||||
}catch(Exception e) {
|
||||
log.error("There is no more messages to send or internal server error has been occurred, \n"+ e );
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isEmptyQueue(){
|
||||
return sharedQueue != null? sharedQueue.isEmpty():false;
|
||||
}
|
||||
|
||||
}
|
@ -1,55 +0,0 @@
|
||||
package org.homeautomation.droneanalyzer.api.util;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.apimgt.application.extension.APIManagementProviderService;
|
||||
import org.wso2.carbon.context.PrivilegedCarbonContext;
|
||||
import org.wso2.carbon.device.mgt.core.service.DeviceManagementProviderService;
|
||||
|
||||
/**
|
||||
* This class provides utility functions used by REST-API.
|
||||
*/
|
||||
public class APIUtil {
|
||||
|
||||
private static Log log = LogFactory.getLog(APIUtil.class);
|
||||
|
||||
public static String getAuthenticatedUser() {
|
||||
PrivilegedCarbonContext threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||
String username = threadLocalCarbonContext.getUsername();
|
||||
String tenantDomain = threadLocalCarbonContext.getTenantDomain();
|
||||
if (username.endsWith(tenantDomain)) {
|
||||
return username.substring(0, username.lastIndexOf("@"));
|
||||
}
|
||||
return username;
|
||||
}
|
||||
|
||||
public static String getTenantDomainOftheUser() {
|
||||
PrivilegedCarbonContext threadLocalCarbonContext = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||
String tenantDomain = threadLocalCarbonContext.getTenantDomain();
|
||||
return tenantDomain;
|
||||
}
|
||||
|
||||
public static DeviceManagementProviderService getDeviceManagementService() {
|
||||
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||
DeviceManagementProviderService deviceManagementProviderService =
|
||||
(DeviceManagementProviderService) ctx.getOSGiService(DeviceManagementProviderService.class, null);
|
||||
if (deviceManagementProviderService == null) {
|
||||
String msg = "Device Management service has not initialized.";
|
||||
log.error(msg);
|
||||
throw new IllegalStateException(msg);
|
||||
}
|
||||
return deviceManagementProviderService;
|
||||
}
|
||||
|
||||
public static APIManagementProviderService getAPIManagementProviderService() {
|
||||
PrivilegedCarbonContext ctx = PrivilegedCarbonContext.getThreadLocalCarbonContext();
|
||||
APIManagementProviderService apiManagementProviderService =
|
||||
(APIManagementProviderService) ctx.getOSGiService(APIManagementProviderService.class, null);
|
||||
if (apiManagementProviderService == null) {
|
||||
String msg = "API management provider service has not initialized.";
|
||||
log.error(msg);
|
||||
throw new IllegalStateException(msg);
|
||||
}
|
||||
return apiManagementProviderService;
|
||||
}
|
||||
}
|
@ -1,95 +0,0 @@
|
||||
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.homeautomation.droneanalyzer.api.util;
|
||||
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.homeautomation.droneanalyzer.api.transport.DroneAnalyzerXMPPConnector;
|
||||
import org.homeautomation.droneanalyzer.plugin.constants.DroneConstants;
|
||||
import org.homeautomation.droneanalyzer.plugin.controller.DroneController;
|
||||
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.transport.TransportHandlerException;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
public class DroneAnalyzerServiceUtils {
|
||||
|
||||
private static org.apache.commons.logging.Log log = LogFactory.getLog(DroneAnalyzerServiceUtils.class);
|
||||
|
||||
public static void sendCommandViaXMPP(String deviceOwner, String deviceId, String resource,
|
||||
String state, DroneAnalyzerXMPPConnector droneXMPPConnector)
|
||||
throws DeviceManagementException, TransportHandlerException {
|
||||
|
||||
String xmppServerDomain = XmppConfig.getInstance().getXmppEndpoint();
|
||||
int indexOfChar = xmppServerDomain.lastIndexOf(File.separator);
|
||||
if (indexOfChar != -1) {
|
||||
xmppServerDomain = xmppServerDomain.substring((indexOfChar + 1), xmppServerDomain.length());
|
||||
}
|
||||
indexOfChar = xmppServerDomain.indexOf(":");
|
||||
if (indexOfChar != -1) {
|
||||
xmppServerDomain = xmppServerDomain.substring(0, indexOfChar);
|
||||
}
|
||||
String clientToConnect = deviceId + "@" + xmppServerDomain + File.separator + deviceOwner;
|
||||
String message = resource.replace("/", "") + ":" + state;
|
||||
droneXMPPConnector.publishDeviceData(clientToConnect, message, "CONTROL-REQUEST");
|
||||
}
|
||||
|
||||
public static boolean sendControlCommand(DroneController controller, String deviceId, String action,
|
||||
double speed, double duration)
|
||||
throws DeviceManagementException {
|
||||
boolean controlState = false;
|
||||
try{
|
||||
switch (action){
|
||||
case DroneConstants.TAKE_OFF:
|
||||
controlState = controller.takeoff();
|
||||
break;
|
||||
case DroneConstants.LAND:
|
||||
controlState = controller.land();
|
||||
break;
|
||||
case DroneConstants.BACK:
|
||||
controlState = controller.back(speed, duration);
|
||||
break;
|
||||
case DroneConstants.CLOCK_WISE:
|
||||
controlState = controller.clockwise(speed, duration);
|
||||
break;
|
||||
case DroneConstants.COUNTER_CLOCKWISE:
|
||||
controlState = controller.conterClockwise(speed, duration);
|
||||
break;
|
||||
case DroneConstants.DOWN:
|
||||
controlState = controller.down(speed, duration);
|
||||
break;
|
||||
case DroneConstants.FRONT:
|
||||
controlState = controller.back(speed, duration);
|
||||
break;
|
||||
case DroneConstants.FORWARD:
|
||||
controlState = controller.clockwise(speed, duration);
|
||||
break;
|
||||
case DroneConstants.UP:
|
||||
controlState = controller.up(speed, duration);
|
||||
break;
|
||||
default:
|
||||
log.error("Invalid command");
|
||||
break;
|
||||
}
|
||||
}catch(Exception e){
|
||||
log.error(e.getMessage()+ "\n"+ e);
|
||||
}
|
||||
return controlState;
|
||||
}
|
||||
}
|
@ -1,89 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
~
|
||||
~ WSO2 Inc. licenses this file to you under the Apache License,
|
||||
~ Version 2.0 (the "License"); you may not use this file except
|
||||
~ in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing,
|
||||
~ software distributed under the License is distributed on an
|
||||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
~ KIND, either express or implied. See the License for the
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.
|
||||
-->
|
||||
|
||||
<!-- This file contains the list of permissions that are associated with URL end points
|
||||
of the web app. Each permission should contain the name, permission path ,API path
|
||||
(URL) , HTTP method and OAUTH2 authorization scope (not-required).
|
||||
When defining dynamic paths for APIs, path variables are denoted by '*' notation.
|
||||
NOTE: All the endpoints of the web app should be available in this file. Otherwise
|
||||
it will result 403 error at the runtime.
|
||||
-->
|
||||
<PermissionConfiguration>
|
||||
|
||||
<APIVersion></APIVersion>
|
||||
<!-- Device related APIs -->
|
||||
<Permission>
|
||||
<name>Get device</name>
|
||||
<path>/device-mgt/user/devices/list</path>
|
||||
<url>/devices/*</url>
|
||||
<method>GET</method>
|
||||
<scope>drone_analyzer_user</scope>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>Remove device</name>
|
||||
<path>/device-mgt/user/devices/remove</path>
|
||||
<url>/devices/*</url>
|
||||
<method>DELETE</method>
|
||||
<scope>drone_analyzer_user</scope>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>Download device</name>
|
||||
<path>/device-mgt/user/devices/add</path>
|
||||
<url>/devices/*/download</url>
|
||||
<method>GET</method>
|
||||
<scope>drone_analyzer_user</scope>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>Update device</name>
|
||||
<path>/device-mgt/user/devices/update</path>
|
||||
<url>/devices/*</url>
|
||||
<method>POST</method>
|
||||
<scope>drone_analyzer_user</scope>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>Get Devices</name>
|
||||
<path>/device-mgt/user/devices</path>
|
||||
<url>/devices</url>
|
||||
<method>GET</method>
|
||||
<scope>drone_analyzer_user</scope>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>Generate Link</name>
|
||||
<path>/device-mgt/user/devices/generate_link</path>
|
||||
<url>/devices/*/generate_link</url>
|
||||
<method>GET</method>
|
||||
<scope>drone_analyzer_user</scope>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>Register Device</name>
|
||||
<path>/device-mgt/user/device/register</path>
|
||||
<url>/device/register/*/*/*</url>
|
||||
<method>POST</method>
|
||||
<scope>drone_analyzer_device</scope>
|
||||
</Permission>
|
||||
<Permission>
|
||||
<name>Send Command</name>
|
||||
<path>/device-mgt/user/device/send_command</path>
|
||||
<url>/device/*/send_command</url>
|
||||
<method>POST</method>
|
||||
<scope>drone_analyzer_user</scope>
|
||||
</Permission>
|
||||
|
||||
</PermissionConfiguration>
|
@ -1,33 +0,0 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1"?>
|
||||
|
||||
<!--
|
||||
~ Copyright 2005-2013 WSO2, Inc. (http://wso2.com)
|
||||
~
|
||||
~ Licensed under the Apache License, Version 2.0 (the "License");
|
||||
~ you may not use this file except in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing, software
|
||||
~ distributed under the License is distributed on an "AS IS" BASIS,
|
||||
~ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
~ See the License for the specific language governing permissions and
|
||||
~ limitations under the License.
|
||||
-->
|
||||
|
||||
<!--
|
||||
This file defines class loading policy of the whole container. But this behaviour can be overridden by individual webapps by putting this file into the META-INF/ directory.
|
||||
-->
|
||||
<Classloading xmlns="http://wso2.org/projects/as/classloading">
|
||||
|
||||
<!-- Parent-first or child-first. Default behaviour is child-first.-->
|
||||
<ParentFirst>false</ParentFirst>
|
||||
|
||||
<!--
|
||||
Default environments that contains provides to all the webapps. This can be overridden by individual webapps by specifing required environments
|
||||
Tomcat environment is the default and every webapps gets it even if they didn't specify it.
|
||||
e.g. If a webapps requires CXF, they will get both Tomcat and CXF.
|
||||
-->
|
||||
<Environments>CXF,Carbon</Environments>
|
||||
</Classloading>
|
@ -1,44 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!--
|
||||
~ Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
~
|
||||
~ WSO2 Inc. licenses this file to you under the Apache License,
|
||||
~ Version 2.0 (the "License"); you may not use this file except
|
||||
~ in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing,
|
||||
~ software distributed under the License is distributed on an
|
||||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
~ KIND, either express or implied. See the License for the
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.
|
||||
-->
|
||||
|
||||
<beans xmlns="http://www.springframework.org/schema/beans"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xmlns:jaxrs="http://cxf.apache.org/jaxrs" xmlns:cxf="http://cxf.apache.org/core"
|
||||
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd
|
||||
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd">
|
||||
<jaxrs:server id="DroneAnalyzer" address="/">
|
||||
<jaxrs:features>
|
||||
<cxf:logging/>
|
||||
</jaxrs:features>
|
||||
<jaxrs:serviceBeans>
|
||||
<bean id="DroneControllerService"
|
||||
class="org.homeautomation.droneanalyzer.api.DroneControllerServiceImpl">
|
||||
<!--<property name="DroneXMPPConnector" ref="xmppConnectorBean"/>-->
|
||||
</bean>
|
||||
<bean id="DroneManagerService"
|
||||
class="org.homeautomation.droneanalyzer.api.DroneManagerServiceImpl">
|
||||
</bean>
|
||||
</jaxrs:serviceBeans>
|
||||
<jaxrs:providers>
|
||||
<bean class="org.codehaus.jackson.jaxrs.JacksonJsonProvider"/>
|
||||
</jaxrs:providers>
|
||||
</jaxrs:server>
|
||||
</beans>
|
||||
|
@ -1,49 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<web-app version="2.5"
|
||||
xmlns="http://java.sun.com/xml/ns/javaee"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
|
||||
metadata-complete="true">
|
||||
<display-name>WSO2 IoT Server</display-name>
|
||||
<description>WSO2 IoT Server</description>
|
||||
<servlet>
|
||||
<servlet-name>CXFServlet</servlet-name>
|
||||
<servlet-class>org.apache.cxf.transport.servlet.CXFServlet</servlet-class>
|
||||
<load-on-startup>1</load-on-startup>
|
||||
</servlet>
|
||||
<servlet-mapping>
|
||||
<servlet-name>CXFServlet</servlet-name>
|
||||
<url-pattern>/*</url-pattern>
|
||||
</servlet-mapping>
|
||||
|
||||
<context-param>
|
||||
<param-name>isAdminService</param-name>
|
||||
<param-value>false</param-value>
|
||||
</context-param>
|
||||
<context-param>
|
||||
<param-name>doAuthentication</param-name>
|
||||
<param-value>false</param-value>
|
||||
</context-param>
|
||||
|
||||
<!--publish to apim-->
|
||||
<context-param>
|
||||
<param-name>managed-api-enabled</param-name>
|
||||
<param-value>true</param-value>
|
||||
</context-param>
|
||||
<context-param>
|
||||
<param-name>managed-api-owner</param-name>
|
||||
<param-value>admin</param-value>
|
||||
</context-param>
|
||||
<context-param>
|
||||
<param-name>managed-api-context-template</param-name>
|
||||
<param-value>/drone_analyzer/{version}</param-value>
|
||||
</context-param>
|
||||
<context-param>
|
||||
<param-name>managed-api-application</param-name>
|
||||
<param-value>drone_analyzer</param-value>
|
||||
</context-param>
|
||||
<context-param>
|
||||
<param-name>managed-api-isSecured</param-name>
|
||||
<param-value>true</param-value>
|
||||
</context-param>
|
||||
</web-app>
|
@ -1,120 +0,0 @@
|
||||
<!--
|
||||
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
~
|
||||
~ WSO2 Inc. licenses this file to you under the Apache License,
|
||||
~ Version 2.0 (the "License"); you may not use this file except
|
||||
~ in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing,
|
||||
~ software distributed under the License is distributed on an
|
||||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
~ KIND, either express or implied. See the License for the
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<parent>
|
||||
<groupId>org.homeautomation</groupId>
|
||||
<artifactId>droneanalyzer-component</artifactId>
|
||||
<version>2.1.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<version>2.1.0-SNAPSHOT</version>
|
||||
<artifactId>${groupId}.droneanalyzer.plugin</artifactId>
|
||||
<packaging>bundle</packaging>
|
||||
<name>${groupId}.droneanalyzer.plugin for CDMF </name>
|
||||
<url>http://wso2.org</url>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-scr-plugin</artifactId>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-compiler-plugin</artifactId>
|
||||
<configuration>
|
||||
<encoding>UTF-8</encoding>
|
||||
<source>${wso2.maven.compiler.source}</source>
|
||||
<target>${wso2.maven.compiler.target}</target>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-bundle-plugin</artifactId>
|
||||
<version>${org.apache.felix.version}</version>
|
||||
<extensions>true</extensions>
|
||||
<configuration>
|
||||
<instructions>
|
||||
<Bundle-SymbolicName>${groupId}.droneanalyzer.plugin</Bundle-SymbolicName>
|
||||
<Bundle-Name>${groupId}.droneanalyzer.plugin</Bundle-Name>
|
||||
<Bundle-Version>2.1.0-SNAPSHOT</Bundle-Version>
|
||||
<Bundle-Description>IoT Server Impl Bundle</Bundle-Description>
|
||||
<Private-Package>org.homeautomation.droneanalyzer.plugin.internal</Private-Package>
|
||||
<Import-Package>
|
||||
org.osgi.framework,
|
||||
org.osgi.service.component,
|
||||
org.apache.commons.logging,
|
||||
javax.naming;resolution:=optional,
|
||||
javax.sql;resolution:=optional,
|
||||
org.wso2.carbon.device.mgt.common.*,
|
||||
org.wso2.carbon.device.mgt.common,
|
||||
org.wso2.carbon.device.mgt.iot.*,
|
||||
org.wso2.carbon.device.mgt.extensions.feature.mgt.*,
|
||||
org.wso2.carbon.utils.*
|
||||
</Import-Package>
|
||||
<Export-Package>
|
||||
!org.homeautomation.droneanalyzer.plugin.internal,
|
||||
org.homeautomation.droneanalyzer.plugin.*
|
||||
</Export-Package>
|
||||
</instructions>
|
||||
</configuration>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.osgi</groupId>
|
||||
<artifactId>org.eclipse.osgi</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.osgi</groupId>
|
||||
<artifactId>org.eclipse.osgi.services</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.logging</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.common</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.ndatasource.core</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.iot</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.utils</artifactId>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.extensions</artifactId>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
</project>
|
@ -1,41 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.homeautomation.droneanalyzer.plugin.constants;
|
||||
|
||||
public class DroneConstants {
|
||||
|
||||
public final static String DEVICE_PLUGIN_DEVICE_NAME = "DEVICE_NAME";
|
||||
public final static String DEVICE_PLUGIN_DEVICE_ID = "DRONE_DEVICE_ID";
|
||||
public final static String MESSAGE_RESOURCE = "drone_current_status";
|
||||
public static final String DEVICE_TYPE = "drone_analyzer";
|
||||
public static final int MINIMUM_TIME_DURATION = 150;
|
||||
public static final int MAXIMUM_BUFFERE_SIZE_OF_SHARED_QUEUE = 10;
|
||||
public static final String DEVICE_ID = "drone_type1";
|
||||
public final static String TAKE_OFF = "takeoff";
|
||||
public final static String LAND = "land";
|
||||
public final static String UP = "up";
|
||||
public final static String DOWN = "down";
|
||||
public final static String BACK = "back";
|
||||
public final static String FORWARD = "forward";
|
||||
public final static String FRONT = "front";
|
||||
public final static String CLOCK_WISE = "clockwise";
|
||||
public final static String COUNTER_CLOCKWISE = "counterClockwise";
|
||||
public static final String DATA_SOURCE_NAME = "jdbc/DroneAnalyzerDM_DB";
|
||||
|
||||
}
|
@ -1,40 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.homeautomation.droneanalyzer.plugin.constants;
|
||||
|
||||
public class MessageConfig {
|
||||
|
||||
public static final String IN_QUATANNIM_VAL = "quatanium_val";
|
||||
public static final String IN_DEVICE_TYPE = "device_type";
|
||||
public static final String IN_IRIS_DRONE = "IRIS_DRONE";
|
||||
public static final String IN_SIMULATOR = "SIMULATOR";
|
||||
public static final String OUT_QUATANNIM_VAL = "quatanium_val";
|
||||
public static final String IN_ACCELETOMETER_VAL = "accelerometer";
|
||||
public static final String OUT_ACCELETOMETER_VAL = "accelerometer";
|
||||
public static final String IN_GYROSCOPE_VAL = "gyroscope";
|
||||
public static final String OUT_GYROSCOPE_VAL = "gyroscope";
|
||||
public static final String IN_MAGNETOMETER_VAL = "magnetometer";
|
||||
public static final String OUT_MAGNETOMETER_VAL = "magnetometer";
|
||||
public static final String IN_BASIC_PARAM_VAL = "basicParam";
|
||||
public static final String OUT_BASIC_PARAM_VAL = "basicParam";
|
||||
public static final String OUT_BASIC_PARAM_VELOCITY = "velocity";
|
||||
public static final String OUT_BASIC_PARAM_GLOBAL_LOCATION = "global_location";
|
||||
public static final String OUT_BATTERY_LEVEL = "battery_level";
|
||||
|
||||
}
|
@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.homeautomation.droneanalyzer.plugin.controller;
|
||||
|
||||
public interface DroneController {
|
||||
|
||||
boolean takeoff();
|
||||
boolean land();
|
||||
boolean up(double speed, double duration);
|
||||
boolean down(double speed, double duration);
|
||||
boolean left(double speed, double duration);
|
||||
boolean right(double speed, double duration);
|
||||
boolean front(double speed, double duration);
|
||||
boolean back(double speed, double duration);
|
||||
boolean clockwise(double speed, double duration);
|
||||
boolean conterClockwise(double speed, double duration);
|
||||
|
||||
}
|
@ -1,74 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.homeautomation.droneanalyzer.plugin.controller.impl;
|
||||
|
||||
|
||||
import org.homeautomation.droneanalyzer.plugin.controller.DroneController;
|
||||
|
||||
public class DroneControllerImpl implements DroneController {
|
||||
|
||||
@Override
|
||||
public boolean takeoff() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean land() {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean up(double speed, double duration) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean down(double speed, double duration) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean left(double speed, double duration) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean right(double speed, double duration) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean front(double speed, double duration) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean back(double speed, double duration) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean clockwise(double speed, double duration) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean conterClockwise(double speed, double duration) {
|
||||
return false;
|
||||
}
|
||||
}
|
@ -1,56 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.homeautomation.droneanalyzer.plugin.exception;
|
||||
|
||||
|
||||
public class DroneAnalyzerDeviceMgtPluginException extends Exception{
|
||||
|
||||
private String errorMessage;
|
||||
|
||||
public String getErrorMessage() {
|
||||
return errorMessage;
|
||||
}
|
||||
|
||||
public void setErrorMessage(String errorMessage) {
|
||||
this.errorMessage = errorMessage;
|
||||
}
|
||||
|
||||
public DroneAnalyzerDeviceMgtPluginException(String msg, Exception nestedEx) {
|
||||
super(msg, nestedEx);
|
||||
setErrorMessage(msg);
|
||||
}
|
||||
|
||||
public DroneAnalyzerDeviceMgtPluginException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
setErrorMessage(message);
|
||||
}
|
||||
|
||||
public DroneAnalyzerDeviceMgtPluginException(String msg) {
|
||||
super(msg);
|
||||
setErrorMessage(msg);
|
||||
}
|
||||
|
||||
public DroneAnalyzerDeviceMgtPluginException() {
|
||||
super();
|
||||
}
|
||||
|
||||
public DroneAnalyzerDeviceMgtPluginException(Throwable cause) {
|
||||
super(cause);
|
||||
}
|
||||
|
||||
}
|
@ -1,256 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.homeautomation.droneanalyzer.plugin.impl;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.homeautomation.droneanalyzer.plugin.exception.DroneAnalyzerDeviceMgtPluginException;
|
||||
import org.homeautomation.droneanalyzer.plugin.impl.dao.DroneAnalyzerDAO;
|
||||
import org.homeautomation.droneanalyzer.plugin.impl.feature.DroneAnalyzerFeatureManager;
|
||||
import org.wso2.carbon.device.mgt.common.Device;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManager;
|
||||
import org.wso2.carbon.device.mgt.common.EnrolmentInfo;
|
||||
import org.wso2.carbon.device.mgt.common.FeatureManager;
|
||||
import org.wso2.carbon.device.mgt.common.configuration.mgt.TenantConfiguration;
|
||||
import org.wso2.carbon.device.mgt.common.license.mgt.License;
|
||||
import org.wso2.carbon.device.mgt.common.license.mgt.LicenseManagementException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* This represents the Drone Analyzer service implementation of DeviceManagerService.
|
||||
*/
|
||||
public class DroneAnalyzerManager implements DeviceManager {
|
||||
|
||||
private static final DroneAnalyzerDAO droneAnalyzerDAO = new DroneAnalyzerDAO();
|
||||
private static final Log log = LogFactory.getLog(DroneAnalyzerManager.class);
|
||||
private FeatureManager droneFeatureManager = new DroneAnalyzerFeatureManager();
|
||||
@Override
|
||||
public FeatureManager getFeatureManager() {
|
||||
return droneFeatureManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean saveConfiguration(TenantConfiguration tenantConfiguration)
|
||||
throws DeviceManagementException {
|
||||
//TODO implement this
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public TenantConfiguration getConfiguration() throws DeviceManagementException {
|
||||
//TODO implement this
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean enrollDevice(Device device) throws DeviceManagementException {
|
||||
boolean status;
|
||||
try {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Enrolling a new drone device : " + device.getDeviceIdentifier());
|
||||
}
|
||||
DroneAnalyzerDAO.beginTransaction();
|
||||
status = droneAnalyzerDAO.getDeviceDAO().addDevice(device);
|
||||
DroneAnalyzerDAO.commitTransaction();
|
||||
} catch (DroneAnalyzerDeviceMgtPluginException e) {
|
||||
try {
|
||||
DroneAnalyzerDAO.rollbackTransaction();
|
||||
} catch (DroneAnalyzerDeviceMgtPluginException iotDAOEx) {
|
||||
String msg = "Error occurred while roll back the device enrol transaction :" + device.toString();
|
||||
log.warn(msg, iotDAOEx);
|
||||
}
|
||||
String msg = "Error while enrolling the drone device : " + device.getDeviceIdentifier();
|
||||
log.error(msg, e);
|
||||
throw new DeviceManagementException(msg, e);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean modifyEnrollment(Device device) throws DeviceManagementException {
|
||||
boolean status;
|
||||
try {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Modifying the Virtual Firealarm device enrollment data");
|
||||
}
|
||||
DroneAnalyzerDAO.beginTransaction();
|
||||
status = droneAnalyzerDAO.getDeviceDAO().updateDevice(device);
|
||||
DroneAnalyzerDAO.commitTransaction();
|
||||
} catch (DroneAnalyzerDeviceMgtPluginException e) {
|
||||
try {
|
||||
DroneAnalyzerDAO.rollbackTransaction();
|
||||
} catch (DroneAnalyzerDeviceMgtPluginException iotDAOEx) {
|
||||
String msg = "Error occurred while roll back the update device transaction :" + device.toString();
|
||||
log.warn(msg, iotDAOEx);
|
||||
}
|
||||
String msg = "Error while updating the enrollment of the drone device : " +
|
||||
device.getDeviceIdentifier();
|
||||
log.error(msg, e);
|
||||
throw new DeviceManagementException(msg, e);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean disenrollDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
|
||||
boolean status;
|
||||
try {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Dis-enrolling drone device : " + deviceId);
|
||||
}
|
||||
DroneAnalyzerDAO.beginTransaction();
|
||||
status = droneAnalyzerDAO.getDeviceDAO().deleteIotDevice(deviceId.getId());
|
||||
DroneAnalyzerDAO.commitTransaction();
|
||||
} catch (DroneAnalyzerDeviceMgtPluginException e) {
|
||||
try {
|
||||
DroneAnalyzerDAO.rollbackTransaction();
|
||||
} catch (DroneAnalyzerDeviceMgtPluginException iotDAOEx) {
|
||||
String msg = "Error occurred while roll back the device dis enrol transaction :" + deviceId.toString();
|
||||
log.warn(msg, iotDAOEx);
|
||||
}
|
||||
String msg = "Error while removing the drone device : " + deviceId.getId();
|
||||
log.error(msg, e);
|
||||
throw new DeviceManagementException(msg, e);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isEnrolled(DeviceIdentifier deviceId) throws DeviceManagementException {
|
||||
boolean isEnrolled = false;
|
||||
try {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Checking the enrollment of Drone device : " + deviceId.getId());
|
||||
}
|
||||
Device iotDevice = droneAnalyzerDAO.getDeviceDAO().getDevice(deviceId.getId());
|
||||
if (iotDevice != null) {
|
||||
isEnrolled = true;
|
||||
}
|
||||
} catch (DroneAnalyzerDeviceMgtPluginException e) {
|
||||
String msg = "Error while checking the enrollment status of Drone device : " +
|
||||
deviceId.getId();
|
||||
log.error(msg, e);
|
||||
throw new DeviceManagementException(msg, e);
|
||||
}
|
||||
return isEnrolled;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isActive(DeviceIdentifier deviceId) throws DeviceManagementException {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setActive(DeviceIdentifier deviceId, boolean status)
|
||||
throws DeviceManagementException {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Device getDevice(DeviceIdentifier deviceId) throws DeviceManagementException {
|
||||
Device device;
|
||||
try {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Getting the details of Drone device : " + deviceId.getId());
|
||||
}
|
||||
device = droneAnalyzerDAO.getDeviceDAO().getDevice(deviceId.getId());
|
||||
} catch (DroneAnalyzerDeviceMgtPluginException e) {
|
||||
String msg = "Error while fetching the Drone device : " + deviceId.getId();
|
||||
log.error(msg, e);
|
||||
throw new DeviceManagementException(msg, e);
|
||||
}
|
||||
return device;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setOwnership(DeviceIdentifier deviceId, String ownershipType)
|
||||
throws DeviceManagementException {
|
||||
return true;
|
||||
}
|
||||
|
||||
public boolean isClaimable(DeviceIdentifier deviceIdentifier) throws DeviceManagementException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean setStatus(DeviceIdentifier deviceId, String currentOwner,
|
||||
EnrolmentInfo.Status status) throws DeviceManagementException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public License getLicense(String s) throws LicenseManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void addLicense(License license) throws LicenseManagementException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean updateDeviceInfo(DeviceIdentifier deviceIdentifier, Device device) throws DeviceManagementException {
|
||||
boolean status;
|
||||
try {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug(
|
||||
"updating the details of Drone device : " + deviceIdentifier);
|
||||
}
|
||||
DroneAnalyzerDAO.beginTransaction();
|
||||
status = droneAnalyzerDAO.getDeviceDAO().updateDevice(device);
|
||||
DroneAnalyzerDAO.commitTransaction();
|
||||
} catch (DroneAnalyzerDeviceMgtPluginException e) {
|
||||
try {
|
||||
DroneAnalyzerDAO.rollbackTransaction();
|
||||
} catch (DroneAnalyzerDeviceMgtPluginException iotDAOEx) {
|
||||
String msg = "Error occurred while roll back the update device info transaction :" + device.toString();
|
||||
log.warn(msg, iotDAOEx);
|
||||
}
|
||||
String msg =
|
||||
"Error while updating the Drone device : " + deviceIdentifier;
|
||||
log.error(msg, e);
|
||||
throw new DeviceManagementException(msg, e);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Device> getAllDevices() throws DeviceManagementException {
|
||||
List<Device> devices = null;
|
||||
try {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Fetching the details of all Drone devices");
|
||||
}
|
||||
devices = droneAnalyzerDAO.getDeviceDAO().getAllDevices();
|
||||
} catch (DroneAnalyzerDeviceMgtPluginException e) {
|
||||
String msg = "Error while fetching all Drone devices.";
|
||||
log.error(msg, e);
|
||||
throw new DeviceManagementException(msg, e);
|
||||
}
|
||||
return devices;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean requireDeviceAuthorization() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -1,106 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.homeautomation.droneanalyzer.plugin.impl;
|
||||
|
||||
import org.homeautomation.droneanalyzer.plugin.constants.DroneConstants;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceIdentifier;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManager;
|
||||
import org.wso2.carbon.device.mgt.common.app.mgt.Application;
|
||||
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager;
|
||||
import org.wso2.carbon.device.mgt.common.operation.mgt.Operation;
|
||||
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
|
||||
import java.util.List;
|
||||
|
||||
public class DroneAnalyzerManagerService implements DeviceManagementService {
|
||||
private DeviceManager deviceManager;
|
||||
private final static String DEVICE_TYPE_PROVIDER_DOMAIN = "carbon.super";
|
||||
|
||||
@Override
|
||||
public String getType() {
|
||||
return DroneConstants.DEVICE_TYPE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void init() throws DeviceManagementException {
|
||||
this.deviceManager = new DroneAnalyzerManager();
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceManager getDeviceManager() {
|
||||
return deviceManager;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ApplicationManager getApplicationManager() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void notifyOperationToDevices(Operation operation, List<DeviceIdentifier> list)
|
||||
throws DeviceManagementException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Application[] getApplications(String s, int i, int i1) throws ApplicationManagementException {
|
||||
return new Application[0];
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateApplicationStatus(DeviceIdentifier deviceIdentifier, Application application, String s)
|
||||
throws ApplicationManagementException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getApplicationStatus(DeviceIdentifier deviceIdentifier, Application application)
|
||||
throws ApplicationManagementException {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void installApplicationForDevices(Operation operation, List<DeviceIdentifier> list)
|
||||
throws ApplicationManagementException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void installApplicationForUsers(Operation operation, List<String> list)
|
||||
throws ApplicationManagementException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void installApplicationForUserRoles(Operation operation, List<String> list)
|
||||
throws ApplicationManagementException {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getProviderTenantDomain() {
|
||||
return DEVICE_TYPE_PROVIDER_DOMAIN;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isSharedWithAllTenants() {
|
||||
return true;
|
||||
}
|
||||
|
||||
}
|
@ -1,127 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.homeautomation.droneanalyzer.plugin.impl.dao;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.homeautomation.droneanalyzer.plugin.constants.DroneConstants;
|
||||
import org.homeautomation.droneanalyzer.plugin.exception.DroneAnalyzerDeviceMgtPluginException;
|
||||
import org.homeautomation.droneanalyzer.plugin.impl.dao.impl.DroneAnalyzerDeviceDAOImpl;
|
||||
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
import javax.naming.NamingException;
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
|
||||
|
||||
public class DroneAnalyzerDAO {
|
||||
|
||||
private static final Log log = LogFactory.getLog(DroneAnalyzerDAO.class);
|
||||
static DataSource dataSource;
|
||||
private static ThreadLocal<Connection> currentConnection = new ThreadLocal<Connection>();
|
||||
|
||||
public DroneAnalyzerDAO() {
|
||||
initDroneAnalyzerDAO();
|
||||
}
|
||||
|
||||
public static void initDroneAnalyzerDAO() {
|
||||
try {
|
||||
Context ctx = new InitialContext();
|
||||
dataSource = (DataSource) ctx.lookup(DroneConstants.DATA_SOURCE_NAME);
|
||||
} catch (NamingException e) {
|
||||
log.error("Error while looking up the data source: " + DroneConstants.DATA_SOURCE_NAME);
|
||||
}
|
||||
}
|
||||
|
||||
public DroneAnalyzerDeviceDAOImpl getDeviceDAO() {
|
||||
return new DroneAnalyzerDeviceDAOImpl();
|
||||
}
|
||||
|
||||
public static void beginTransaction() throws DroneAnalyzerDeviceMgtPluginException {
|
||||
try {
|
||||
Connection conn = dataSource.getConnection();
|
||||
conn.setAutoCommit(false);
|
||||
currentConnection.set(conn);
|
||||
} catch (SQLException e) {
|
||||
throw new DroneAnalyzerDeviceMgtPluginException("Error occurred while retrieving datasource connection", e);
|
||||
}
|
||||
}
|
||||
|
||||
public static Connection getConnection() throws DroneAnalyzerDeviceMgtPluginException {
|
||||
|
||||
if (currentConnection != null && currentConnection.get() == null) {
|
||||
try {
|
||||
currentConnection.set(dataSource.getConnection());
|
||||
} catch (SQLException e) {
|
||||
throw new DroneAnalyzerDeviceMgtPluginException("Error occurred while retrieving data source connection", e);
|
||||
}
|
||||
}
|
||||
return currentConnection.get();
|
||||
}
|
||||
|
||||
public static void commitTransaction() throws DroneAnalyzerDeviceMgtPluginException {
|
||||
try {
|
||||
Connection conn = currentConnection.get();
|
||||
if (conn != null) {
|
||||
conn.commit();
|
||||
} else {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Datasource connection associated with the current thread is null, hence commit "
|
||||
+ "has not been attempted");
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw new DroneAnalyzerDeviceMgtPluginException("Error occurred while committing the transaction", e);
|
||||
} finally {
|
||||
closeConnection();
|
||||
}
|
||||
}
|
||||
|
||||
public static void closeConnection() throws DroneAnalyzerDeviceMgtPluginException {
|
||||
Connection con = currentConnection.get();
|
||||
if (con != null) {
|
||||
try {
|
||||
con.close();
|
||||
} catch (SQLException e) {
|
||||
log.error("Error occurred while close the connection");
|
||||
}
|
||||
}
|
||||
currentConnection.remove();
|
||||
}
|
||||
|
||||
public static void rollbackTransaction() throws DroneAnalyzerDeviceMgtPluginException {
|
||||
try {
|
||||
Connection conn = currentConnection.get();
|
||||
if (conn != null) {
|
||||
conn.rollback();
|
||||
} else {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Datasource connection associated with the current thread is null, hence rollback "
|
||||
+ "has not been attempted");
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
throw new DroneAnalyzerDeviceMgtPluginException("Error occurred while rollback the transaction", e);
|
||||
} finally {
|
||||
closeConnection();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,195 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.homeautomation.droneanalyzer.plugin.impl.dao.impl;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.homeautomation.droneanalyzer.plugin.constants.DroneConstants;
|
||||
import org.homeautomation.droneanalyzer.plugin.exception.DroneAnalyzerDeviceMgtPluginException;
|
||||
import org.homeautomation.droneanalyzer.plugin.impl.dao.DroneAnalyzerDAO;
|
||||
import org.homeautomation.droneanalyzer.plugin.impl.util.DroneAnalyzerUtils;
|
||||
import org.wso2.carbon.device.mgt.common.Device;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Implements CRUD for drone analyzer.
|
||||
*/
|
||||
public class DroneAnalyzerDeviceDAOImpl {
|
||||
|
||||
private static final Log log = LogFactory.getLog(DroneAnalyzerDeviceDAOImpl.class);
|
||||
|
||||
public Device getDevice(String deviceId) throws DroneAnalyzerDeviceMgtPluginException {
|
||||
Connection conn = null;
|
||||
PreparedStatement stmt = null;
|
||||
Device device = null;
|
||||
ResultSet resultSet = null;
|
||||
try {
|
||||
conn = DroneAnalyzerDAO.getConnection();
|
||||
if(conn == null){
|
||||
log.error("Database connection hasn't been created");
|
||||
}
|
||||
String selectDBQuery =
|
||||
"SELECT DRONE_DEVICE_ID, DEVICE_NAME FROM DRONE_DEVICE WHERE DRONE_DEVICE_ID = ?";
|
||||
stmt = conn.prepareStatement(selectDBQuery);
|
||||
stmt.setString(1, deviceId);
|
||||
resultSet = stmt.executeQuery();
|
||||
|
||||
if (resultSet.next()) {
|
||||
device = new Device();
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Drone device " + deviceId + " data has been fetched from " +
|
||||
"Drone database.");
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
String msg = "Error occurred while fetching drone device : '" + deviceId + "'";
|
||||
log.error(msg, e);
|
||||
throw new DroneAnalyzerDeviceMgtPluginException(msg, e);
|
||||
} finally {
|
||||
DroneAnalyzerUtils.cleanupResources(stmt, resultSet);
|
||||
DroneAnalyzerDAO.closeConnection();
|
||||
}
|
||||
return device;
|
||||
}
|
||||
|
||||
public boolean addDevice(Device device) throws DroneAnalyzerDeviceMgtPluginException {
|
||||
boolean status = false;
|
||||
Connection conn = null;
|
||||
PreparedStatement stmt = null;
|
||||
try {
|
||||
conn = DroneAnalyzerDAO.getConnection();
|
||||
String createDBQuery =
|
||||
"INSERT INTO DRONE_DEVICE(DRONE_DEVICE_ID, DEVICE_NAME) VALUES (?, ?)";
|
||||
stmt = conn.prepareStatement(createDBQuery);
|
||||
stmt.setString(1, device.getDeviceIdentifier());
|
||||
stmt.setString(2, device.getName());
|
||||
int rows = stmt.executeUpdate();
|
||||
if (rows > 0) {
|
||||
status = true;
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("drone device " + device.getDeviceIdentifier() + " data has been" +
|
||||
" added to the drone database.");
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
String msg = "Error occurred while adding the drone device '" +
|
||||
device.getDeviceIdentifier() + "' to the drone db.";
|
||||
log.error(msg, e);
|
||||
throw new DroneAnalyzerDeviceMgtPluginException(msg, e);
|
||||
} finally {
|
||||
DroneAnalyzerUtils.cleanupResources(stmt, null);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
public boolean updateDevice(Device device) throws DroneAnalyzerDeviceMgtPluginException {
|
||||
boolean status = false;
|
||||
Connection conn = null;
|
||||
PreparedStatement stmt = null;
|
||||
try {
|
||||
conn = DroneAnalyzerDAO.getConnection();
|
||||
String updateDBQuery =
|
||||
"UPDATE DRONE_DEVICE SET DEVICE_NAME = ? WHERE DRONE_DEVICE_ID = ?";
|
||||
stmt = conn.prepareStatement(updateDBQuery);
|
||||
stmt.setString(1, device.getName());
|
||||
stmt.setString(2, device.getDeviceIdentifier());
|
||||
int rows = stmt.executeUpdate();
|
||||
if (rows > 0) {
|
||||
status = true;
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Drone device " + device.getDeviceIdentifier() + " data has been" +
|
||||
" modified.");
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
String msg = "Error occurred while modifying the Drone device '" + device.getDeviceIdentifier() + "' data.";
|
||||
log.error(msg, e);
|
||||
throw new DroneAnalyzerDeviceMgtPluginException(msg, e);
|
||||
} finally {
|
||||
DroneAnalyzerUtils.cleanupResources(stmt, null);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
public boolean deleteIotDevice(String iotDeviceId) throws DroneAnalyzerDeviceMgtPluginException {
|
||||
boolean status = false;
|
||||
Connection conn = null;
|
||||
PreparedStatement stmt = null;
|
||||
try {
|
||||
conn = DroneAnalyzerDAO.getConnection();
|
||||
System.out.println("delete device ");
|
||||
String deleteDBQuery =
|
||||
"DELETE FROM DRONE_DEVICE WHERE DRONE_DEVICE_ID = ?";
|
||||
stmt = conn.prepareStatement(deleteDBQuery);
|
||||
stmt.setString(1, iotDeviceId);
|
||||
int rows = stmt.executeUpdate();
|
||||
if (rows > 0) {
|
||||
status = true;
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Drone device " + iotDeviceId + " data has deleted" +
|
||||
" from the drone database.");
|
||||
}
|
||||
}
|
||||
} catch (SQLException e) {
|
||||
String msg = "Error occurred while deleting drone device " + iotDeviceId;
|
||||
log.error(msg, e);
|
||||
throw new DroneAnalyzerDeviceMgtPluginException(msg, e);
|
||||
} finally {
|
||||
DroneAnalyzerUtils.cleanupResources(stmt, null);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
public List<Device> getAllDevices() throws DroneAnalyzerDeviceMgtPluginException {
|
||||
Connection conn = null;
|
||||
PreparedStatement stmt = null;
|
||||
ResultSet resultSet = null;
|
||||
Device iotDevice;
|
||||
List<Device> iotDevices = new ArrayList<Device>();
|
||||
try {
|
||||
conn = DroneAnalyzerDAO.getConnection();
|
||||
String selectDBQuery =
|
||||
"SELECT DRONE_DEVICE_ID, DEVICE_NAME " +
|
||||
"FROM DRONE_DEVICE";
|
||||
stmt = conn.prepareStatement(selectDBQuery);
|
||||
resultSet = stmt.executeQuery();
|
||||
while (resultSet.next()) {
|
||||
iotDevice = new Device();
|
||||
iotDevice.setDeviceIdentifier(resultSet.getString(DroneConstants.DEVICE_PLUGIN_DEVICE_ID));
|
||||
iotDevice.setName(resultSet.getString(DroneConstants.DEVICE_PLUGIN_DEVICE_NAME));
|
||||
}
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("All drone device details have fetched from drone database.");
|
||||
}
|
||||
return iotDevices;
|
||||
} catch (SQLException e) {
|
||||
String msg = "Error occurred while fetching all drone device data'";
|
||||
log.error(msg, e);
|
||||
throw new DroneAnalyzerDeviceMgtPluginException(msg, e);
|
||||
} finally {
|
||||
DroneAnalyzerUtils.cleanupResources(stmt, resultSet);
|
||||
DroneAnalyzerDAO.closeConnection();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,58 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
package org.homeautomation.droneanalyzer.plugin.impl.feature;
|
||||
|
||||
import org.homeautomation.droneanalyzer.plugin.constants.DroneConstants;
|
||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||
import org.wso2.carbon.device.mgt.common.Feature;
|
||||
import org.wso2.carbon.device.mgt.common.FeatureManager;
|
||||
import org.wso2.carbon.device.mgt.extensions.feature.mgt.GenericFeatureManager;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class DroneAnalyzerFeatureManager implements FeatureManager {
|
||||
@Override
|
||||
public boolean addFeature(Feature feature) throws DeviceManagementException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addFeatures(List<Feature> features) throws DeviceManagementException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Feature getFeature(String name) throws DeviceManagementException {
|
||||
GenericFeatureManager genericFeatureManager = GenericFeatureManager.getInstance();
|
||||
return genericFeatureManager.getFeature(DroneConstants.DEVICE_TYPE, name);
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<Feature> getFeatures() throws DeviceManagementException {
|
||||
GenericFeatureManager genericFeatureManager = GenericFeatureManager.getInstance();
|
||||
return genericFeatureManager.getFeatures(DroneConstants.DEVICE_TYPE);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean removeFeature(String name) throws DeviceManagementException {
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean addSupportedFeaturesToDB() throws DeviceManagementException {
|
||||
return false;
|
||||
}
|
||||
}
|
@ -1,50 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* you may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.homeautomation.droneanalyzer.plugin.impl.util;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.wso2.carbon.utils.CarbonUtils;
|
||||
import org.wso2.carbon.utils.dbcreator.DatabaseCreator;
|
||||
|
||||
import javax.sql.DataSource;
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* Provides methods for initializing the database script.
|
||||
*/
|
||||
public class DeviceSchemaInitializer extends DatabaseCreator {
|
||||
|
||||
private static final Log log = LogFactory.getLog(DeviceSchemaInitializer.class);
|
||||
private static final String setupSQLScriptBaseLocation = CarbonUtils.getCarbonHome() + File.separator + "dbscripts"
|
||||
+ File.separator + "cdm" + File.separator + "plugins" + File.separator;
|
||||
|
||||
public DeviceSchemaInitializer(DataSource dataSource) {
|
||||
super(dataSource);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected String getDbScriptLocation(String databaseType) {
|
||||
String scriptName = databaseType + ".sql";
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Loading database script from :" + scriptName);
|
||||
}
|
||||
return setupSQLScriptBaseLocation.replaceFirst("DBTYPE", databaseType) + scriptName;
|
||||
}
|
||||
}
|
@ -1,109 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
package org.homeautomation.droneanalyzer.plugin.impl.util;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.homeautomation.droneanalyzer.plugin.constants.DroneConstants;
|
||||
import org.homeautomation.droneanalyzer.plugin.exception.DroneAnalyzerDeviceMgtPluginException;
|
||||
import org.wso2.carbon.device.mgt.common.Device;
|
||||
import javax.naming.Context;
|
||||
import javax.naming.InitialContext;
|
||||
import javax.naming.NamingException;
|
||||
import javax.sql.DataSource;
|
||||
import java.sql.Connection;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Contains utility methods used by Drone Analyzer plugin.
|
||||
*/
|
||||
public class DroneAnalyzerUtils {
|
||||
private static Log log = LogFactory.getLog(DroneAnalyzerUtils.class);
|
||||
|
||||
public static String getDeviceProperty(List<Device.Property> deviceProperties, String propertyKey) {
|
||||
String deviceProperty = "";
|
||||
for(Device.Property property :deviceProperties){
|
||||
if(propertyKey.equals(property.getName())){
|
||||
deviceProperty = property.getValue();
|
||||
}
|
||||
}
|
||||
return deviceProperty;
|
||||
}
|
||||
|
||||
public static Device.Property getProperty(String property, String value) {
|
||||
if (property != null) {
|
||||
Device.Property prop = new Device.Property();
|
||||
prop.setName(property);
|
||||
prop.setValue(value);
|
||||
return prop;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
public static void cleanupResources(Connection conn, PreparedStatement stmt, ResultSet rs) {
|
||||
if (rs != null) {
|
||||
try {
|
||||
rs.close();
|
||||
} catch (SQLException e) {
|
||||
log.warn("Error occurred while closing result set", e);
|
||||
}
|
||||
}
|
||||
if (stmt != null) {
|
||||
try {
|
||||
stmt.close();
|
||||
} catch (SQLException e) {
|
||||
log.warn("Error occurred while closing prepared statement", e);
|
||||
}
|
||||
}
|
||||
if (conn != null) {
|
||||
try {
|
||||
conn.close();
|
||||
} catch (SQLException e) {
|
||||
log.warn("Error occurred while closing database connection", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void cleanupResources(PreparedStatement stmt, ResultSet rs) {
|
||||
cleanupResources(null, stmt, rs);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates the device management schema.
|
||||
*/
|
||||
public static void setupDeviceManagementSchema() throws DroneAnalyzerDeviceMgtPluginException {
|
||||
try {
|
||||
Context ctx = new InitialContext();
|
||||
DataSource dataSource = (DataSource) ctx.lookup(DroneConstants.DATA_SOURCE_NAME);
|
||||
DeviceSchemaInitializer initializer =
|
||||
new DeviceSchemaInitializer(dataSource);
|
||||
log.info("Initializing device management repository database schema");
|
||||
initializer.createRegistryDatabase();
|
||||
|
||||
} catch (NamingException e) {
|
||||
log.error("Error while looking up the data source: " + DroneConstants.DATA_SOURCE_NAME);
|
||||
} catch (Exception e) {
|
||||
throw new DroneAnalyzerDeviceMgtPluginException("Error occurred while initializing Iot Device " +
|
||||
"Management database schema", e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,89 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
package org.homeautomation.droneanalyzer.plugin.internal;
|
||||
|
||||
import org.apache.commons.logging.Log;
|
||||
import org.apache.commons.logging.LogFactory;
|
||||
import org.homeautomation.droneanalyzer.plugin.impl.DroneAnalyzerManagerService;
|
||||
import org.homeautomation.droneanalyzer.plugin.impl.util.DroneAnalyzerUtils;
|
||||
import org.homeautomation.droneanalyzer.plugin.exception.DroneAnalyzerDeviceMgtPluginException;
|
||||
import org.osgi.framework.BundleContext;
|
||||
import org.osgi.framework.ServiceRegistration;
|
||||
import org.osgi.service.component.ComponentContext;
|
||||
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
|
||||
|
||||
/**
|
||||
* @scr.component name="org.homeautomation.droneanalyzer.plugin.DroneAnalyzerManagementServiceComponent
|
||||
* immediate="true"
|
||||
*/
|
||||
public class DroneAnalyzerManagementServiceComponent {
|
||||
private ServiceRegistration firealarmServiceRegRef;
|
||||
|
||||
private static final Log log = LogFactory.getLog(
|
||||
DroneAnalyzerManagementServiceComponent.class);
|
||||
|
||||
protected void activate(ComponentContext ctx) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Activating Drone Analyzer Management Service Component");
|
||||
}
|
||||
try {
|
||||
BundleContext bundleContext = ctx.getBundleContext();
|
||||
firealarmServiceRegRef =
|
||||
bundleContext.registerService(DeviceManagementService.class.getName(),
|
||||
new DroneAnalyzerManagerService(), null);
|
||||
String setupOption = System.getProperty("setup");
|
||||
if (setupOption != null) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug(
|
||||
"-Dsetup is enabled. Iot Device management repository schema initialization is about " +
|
||||
"to begin");
|
||||
}
|
||||
try {
|
||||
DroneAnalyzerUtils.setupDeviceManagementSchema();
|
||||
} catch (DroneAnalyzerDeviceMgtPluginException e) {
|
||||
log.error("Exception occurred while initializing device management database schema", e);
|
||||
}
|
||||
}
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug(
|
||||
"Drone Analyzer Device Management Service Component has been successfully activated");
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
log.error("Error occurred while activating Drone Analyzer Device Management Service Component", e);
|
||||
}
|
||||
}
|
||||
|
||||
protected void deactivate(ComponentContext ctx) {
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("De-activating Drone Analyzer Device Management Service Component");
|
||||
}
|
||||
try {
|
||||
if (firealarmServiceRegRef != null) {
|
||||
firealarmServiceRegRef.unregister();
|
||||
}
|
||||
if (log.isDebugEnabled()) {
|
||||
log.debug("Drone Analyzer Device Management Service Component has been successfully de-activated");
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
log.error(
|
||||
"Error occurred while de-activating Drone Analyzer Device Management bundle",e);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
@ -1,59 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
~
|
||||
~ WSO2 Inc. licenses this file to you under the Apache License,
|
||||
~ Version 2.0 (the "License"); you may not use this file except
|
||||
~ in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing,
|
||||
~ software distributed under the License is distributed on an
|
||||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
~ KIND, either express or implied. See the License for the
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>org.homeautomation</groupId>
|
||||
<artifactId>droneanalyzer</artifactId>
|
||||
<version>2.1.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<version>2.1.0-SNAPSHOT</version>
|
||||
<artifactId>droneanalyzer-component</artifactId>
|
||||
<name>WSO2 IoTS(Device Types) - Drone Analyzer Component</name>
|
||||
<packaging>pom</packaging>
|
||||
<build>
|
||||
<pluginManagement>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<groupId>org.apache.felix</groupId>
|
||||
<artifactId>maven-scr-plugin</artifactId>
|
||||
<version>${maven-scr-plugin.version}</version>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>generate-scr-scrdescriptor</id>
|
||||
<goals>
|
||||
<goal>scr</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</pluginManagement>
|
||||
</build>
|
||||
|
||||
<modules>
|
||||
<module>plugin</module>
|
||||
<module>api</module>
|
||||
<module>ui</module>
|
||||
</modules>
|
||||
|
||||
</project>
|
@ -1,64 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
|
||||
<!--
|
||||
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
~
|
||||
~ WSO2 Inc. licenses this file to you under the Apache License,
|
||||
~ Version 2.0 (the "License"); you may not use this file except
|
||||
~ in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing,
|
||||
~ software distributed under the License is distributed on an
|
||||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
~ KIND, either express or implied. See the License for the
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
|
||||
|
||||
<parent>
|
||||
<groupId>org.homeautomation</groupId>
|
||||
<artifactId>droneanalyzer-component</artifactId>
|
||||
<version>2.1.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<version>2.1.0-SNAPSHOT</version>
|
||||
<artifactId>${groupId}.droneanalyzer.ui</artifactId>
|
||||
<name>${groupId}.droneanalyzer.ui</name>
|
||||
<packaging>pom</packaging>
|
||||
<url>http://wso2.org</url>
|
||||
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-assembly-plugin</artifactId>
|
||||
<version>2.5.5</version>
|
||||
<configuration>
|
||||
<finalName>${project.artifactId}-${carbon.device.mgt.version}</finalName>
|
||||
<appendAssemblyId>false</appendAssemblyId>
|
||||
<descriptors>
|
||||
<descriptor>src/assembly/src.xml</descriptor>
|
||||
</descriptors>
|
||||
</configuration>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>create-archive</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>single</goal>
|
||||
</goals>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
|
||||
</project>
|
@ -1,36 +0,0 @@
|
||||
<!--
|
||||
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
~
|
||||
~ WSO2 Inc. licenses this file to you under the Apache License,
|
||||
~ Version 2.0 (the "License"); you may not use this file except
|
||||
~ in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing,
|
||||
~ software distributed under the License is distributed on an
|
||||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
~ KIND, either express or implied. See the License for the
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.
|
||||
-->
|
||||
|
||||
<assembly
|
||||
xmlns="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/plugins/maven-assembly-plugin/assembly/1.1.0 http://maven.apache.org/xsd/assembly-1.1.0.xsd">
|
||||
<id>src</id>
|
||||
<formats>
|
||||
<format>zip</format>
|
||||
</formats>
|
||||
<includeBaseDirectory>false</includeBaseDirectory>
|
||||
<baseDirectory>${basedir}/src</baseDirectory>
|
||||
<fileSets>
|
||||
<fileSet>
|
||||
<directory>${basedir}/src/main/resources/jaggeryapps/devicemgt</directory>
|
||||
<outputDirectory>/</outputDirectory>
|
||||
<useDefaultExcludes>true</useDefaultExcludes>
|
||||
</fileSet>
|
||||
</fileSets>
|
||||
</assembly>
|
@ -1,52 +0,0 @@
|
||||
{{#zone "device-thumbnail"}}
|
||||
<img src="{{@unit.publicUri}}/images/drone-icon.png"/>
|
||||
{{/zone}}
|
||||
{{#zone "device-opetations"}}
|
||||
<div class="add-margin-top-4x">
|
||||
{{unit "iot.unit.device.operation-bar" device=device}}
|
||||
</div>
|
||||
<div class="panel panel-default tab-pane active"
|
||||
id="device_statistics" role="tabpanel" aria-labelledby="device_statistics">
|
||||
<div class="panel-heading">Device Statistics</div>
|
||||
{{unit "iot.unit.device.droneanalyzer.statistics" device=device}}
|
||||
</div>
|
||||
|
||||
{{/zone}}
|
||||
{{#zone "device-detail-properties"}}
|
||||
<div class="media">
|
||||
<div class="media-left col-xs-12 col-sm-2 col-md-2 col-lg-2">
|
||||
<ul class="list-group" role="tablist">
|
||||
<li><a class="list-group-item" href="#event_log" role="tab" data-toggle="tab"
|
||||
aria-controls="event_log">Operations Log</a></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="media-body add-padding-left-5x remove-padding-xs tab-content">
|
||||
|
||||
<div class="panel-group tab-content">
|
||||
<div class="panel panel-default tab-pane" id="event_log" role="tabpanel"
|
||||
aria-labelledby="event_log">
|
||||
<div class="panel-heading">Operations Log <span><a href="#"
|
||||
id="refresh-operations"><i
|
||||
class="fw fw-refresh"></i></a></span></div>
|
||||
<div class="panel-body">
|
||||
<div id="operations-spinner" class="wr-advance-operations-init hidden">
|
||||
<br>
|
||||
|
||||
<i class="fw fw-settings fw-spin fw-2x"></i>
|
||||
|
||||
Loading Operations Log . . .
|
||||
<br>
|
||||
<br>
|
||||
</div>
|
||||
<div id="operations-log-container">
|
||||
<div class="panel-body">
|
||||
Not available yet
|
||||
</div>
|
||||
<br class="c-both"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{/zone}}
|
@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
function onRequest(context) {
|
||||
var log = new Log("device-view.js");
|
||||
var deviceType = context.uriParams.deviceType;
|
||||
var deviceId = request.getParameter("id");
|
||||
|
||||
if (deviceType != null && deviceType != undefined && deviceId != null && deviceId != undefined) {
|
||||
var deviceModule = require("/app/modules/device.js").deviceModule;
|
||||
var device = deviceModule.viewDevice(deviceType, deviceId);
|
||||
|
||||
if (device && device.status != "error") {
|
||||
return {"device": device};
|
||||
} else {
|
||||
response.sendError(404, "Device Id " + deviceId + "of type " + deviceType + " cannot be found!");
|
||||
exit();
|
||||
}
|
||||
}
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
{
|
||||
"version": "1.0.0"
|
||||
}
|
Before Width: | Height: | Size: 46 KiB |
Before Width: | Height: | Size: 46 KiB |
Before Width: | Height: | Size: 112 KiB |
Before Width: | Height: | Size: 46 KiB |
Before Width: | Height: | Size: 148 KiB |
Before Width: | Height: | Size: 48 KiB |
@ -1,184 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
var modalPopup = ".wr-modalpopup";
|
||||
var modalPopupContainer = modalPopup + " .modalpopup-container";
|
||||
var modalPopupContent = modalPopup + " .modalpopup-content";
|
||||
var body = "body";
|
||||
|
||||
/*
|
||||
* set popup maximum height function.
|
||||
*/
|
||||
function setPopupMaxHeight() {
|
||||
$(modalPopupContent).css('max-height', ($(body).height() - ($(body).height() / 100 * 30)));
|
||||
$(modalPopupContainer).css('margin-top', (-($(modalPopupContainer).height() / 2)));
|
||||
}
|
||||
|
||||
/*
|
||||
* show popup function.
|
||||
*/
|
||||
function showPopup() {
|
||||
$(modalPopup).show();
|
||||
setPopupMaxHeight();
|
||||
$('#downloadForm').validate({
|
||||
rules: {
|
||||
deviceName: {
|
||||
minlength: 4,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
highlight: function (element) {
|
||||
$(element).closest('.control-group').removeClass('success').addClass('error');
|
||||
},
|
||||
success: function (element) {
|
||||
$(element).closest('.control-group').removeClass('error').addClass('success');
|
||||
$('label[for=deviceName]').remove();
|
||||
}
|
||||
});
|
||||
var deviceType = "";
|
||||
$('.deviceType').each(function () {
|
||||
if (this.value != "") {
|
||||
deviceType = this.value;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* hide popup function.
|
||||
*/
|
||||
function hidePopup() {
|
||||
$('label[for=deviceName]').remove();
|
||||
$('.control-group').removeClass('success').removeClass('error');
|
||||
$(modalPopupContent).html('');
|
||||
$(modalPopup).hide();
|
||||
}
|
||||
|
||||
/*
|
||||
* DOM ready functions.
|
||||
*/
|
||||
$(document).ready(function () {
|
||||
attachEvents();
|
||||
});
|
||||
|
||||
function attachEvents() {
|
||||
/**
|
||||
* Following click function would execute
|
||||
* when a user clicks on "Download" link
|
||||
* on Device Management page in WSO2 DC Console.
|
||||
*/
|
||||
$("a.download-link").click(function () {
|
||||
var sketchType = $(this).data("sketchtype");
|
||||
var deviceType = $(this).data("devicetype");
|
||||
var downloadDeviceAPI = "/devicemgt/api/devices/sketch/generate_link";
|
||||
var payload = {"sketchType": sketchType, "deviceType": deviceType};
|
||||
$(modalPopupContent).html($('#download-device-modal-content').html());
|
||||
showPopup();
|
||||
var deviceName;
|
||||
$("a#download-device-download-link").click(function () {
|
||||
$('.new-device-name').each(function () {
|
||||
if (this.value != "") {
|
||||
deviceName = this.value;
|
||||
}
|
||||
});
|
||||
$('label[for=deviceName]').remove();
|
||||
if (deviceName && deviceName.length >= 4) {
|
||||
payload.deviceName = deviceName;
|
||||
invokerUtil.post(
|
||||
downloadDeviceAPI,
|
||||
payload,
|
||||
function (data, textStatus, jqxhr) {
|
||||
doAction(data);
|
||||
},
|
||||
function (data) {
|
||||
doAction(data);
|
||||
}
|
||||
);
|
||||
}else if(deviceName){
|
||||
$('.controls').append('<label for="deviceName" generated="true" class="error" ' +
|
||||
'style="display: inline-block;">Please enter at least 4 ' +
|
||||
'characters.</label>');
|
||||
$('.control-group').removeClass('success').addClass('error');
|
||||
} else {
|
||||
$('.controls').append('<label for="deviceName" generated="true" class="error" ' +
|
||||
'style="display: inline-block;">This field is required.' +
|
||||
'</label>');
|
||||
$('.control-group').removeClass('success').addClass('error');
|
||||
}
|
||||
});
|
||||
|
||||
$("a#download-device-cancel-link").click(function () {
|
||||
hidePopup();
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function downloadAgent() {
|
||||
var deviceName;
|
||||
$('.new-device-name').each(function () {
|
||||
if (this.value != "") {
|
||||
deviceName = this.value;
|
||||
}
|
||||
});
|
||||
var deviceNameFormat = /^[^~?!#$:;%^*`+={}\[\]\\()|<>,'"]{1,30}$/;
|
||||
if (deviceName && deviceNameFormat.test(deviceName)) {
|
||||
$('#downloadForm').submit();
|
||||
hidePopup();
|
||||
$(modalPopupContent).html($('#device-agent-downloading-content').html());
|
||||
showPopup();
|
||||
setTimeout(function () {
|
||||
hidePopup();
|
||||
}, 1000);
|
||||
}else {
|
||||
$("#invalid-username-error-msg span").text("Invalid device name");
|
||||
$("#invalid-username-error-msg").removeClass("hidden");
|
||||
}
|
||||
}
|
||||
|
||||
function doAction(data) {
|
||||
//if it is saml redirection response
|
||||
if (data.status == null) {
|
||||
document.write(data);
|
||||
}
|
||||
|
||||
if (data.status == "200") {
|
||||
$(modalPopupContent).html($('#download-device-modal-content-links').html());
|
||||
$("input#download-device-url").val(data.responseText);
|
||||
$("input#download-device-url").focus(function () {
|
||||
$(this).select();
|
||||
});
|
||||
showPopup();
|
||||
} else if (data.status == "401") {
|
||||
$(modalPopupContent).html($('#device-401-content').html());
|
||||
$("#device-401-link").click(function () {
|
||||
window.location = "/devicemgt/login";
|
||||
});
|
||||
showPopup();
|
||||
} else if (data == "403") {
|
||||
$(modalPopupContent).html($('#device-403-content').html());
|
||||
$("#device-403-link").click(function () {
|
||||
window.location = "/devicemgt/login";
|
||||
});
|
||||
showPopup();
|
||||
} else {
|
||||
$(modalPopupContent).html($('#device-unexpected-error-content').html());
|
||||
$("a#device-unexpected-error-link").click(function () {
|
||||
hidePopup();
|
||||
});
|
||||
}
|
||||
}
|
@ -1,315 +0,0 @@
|
||||
<div class="col-lg-12 margin-top-double">
|
||||
<h1 class="grey ">Drone Analyzer</h1>
|
||||
<hr>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-4 col-md-4 col-lg-4 padding-top">
|
||||
<img src="{{@unit.publicUri}}/images/drone-icon.png" class="img-responsive">
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-8 col-md-8 col-lg-8 padding-top">
|
||||
<h4 class="doc-link">Click <a href="https://docs.wso2.com/pages/viewpage.action?pageId=48289181"
|
||||
target="_blank">[ here ]</a> for latest instructions and
|
||||
troubleshooting.</h4>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-8 col-md-8 col-lg-8 padding-top">
|
||||
<h3 class="uppercase">What it Does</h3>
|
||||
<hr>
|
||||
<p class="grey margin-top">Connect an
|
||||
<a href="https://store.3drobotics.com/products/iris" target="_blank">[IRIS+]</a> Drone to
|
||||
WSO2 IoT Server and visualize statistics.
|
||||
</p>
|
||||
<br>
|
||||
|
||||
<h3 class="uppercase">What You Need</h3>
|
||||
<hr>
|
||||
<ul class="list-unstyled">
|
||||
<li class="padding-top-double">
|
||||
<span class="circle">ITEM 01</span>
|
||||
IRIS+ Drone.
|
||||
</li>
|
||||
<li class="padding-top-double">
|
||||
<span class="circle">ITEM 02</span>
|
||||
USB to Micro USB cable or Telemetry Radio receiver.
|
||||
</li>
|
||||
<li class="padding-top-double">
|
||||
<span class="circle">STEP 03</span>
|
||||
Proceed to [Prepare] section.
|
||||
</ul>
|
||||
<br>
|
||||
<a href="/api-store/apis/info?name={{@uriParams.deviceType}}&version=1.0.0&provider=admin"
|
||||
class="btn-operations"
|
||||
target="_blank"><i class="fw fw-api"></i> View API</i> </a>
|
||||
<a href="#" class="download-link btn-operations">
|
||||
<i class="fw fw-download"></i>Download Agent
|
||||
</a>
|
||||
<div id="download-device-modal-content" class="hide">
|
||||
<div class="modal-content">
|
||||
<div class="row">
|
||||
<div class="col-md-7 center-container">
|
||||
<h3>Name your device and download the agent from following link.</h3>
|
||||
<br/>
|
||||
<form id="downloadForm" method="GET"
|
||||
action="{{@app.context}}/api/devices/sketch/download">
|
||||
<div id="invalid-username-error-msg" class="alert alert-danger hidden"
|
||||
role="alert">
|
||||
<i class="icon fw fw-error"></i><span></span>
|
||||
</div>
|
||||
<div class="control-group">
|
||||
<div class="controls">
|
||||
<input class="new-device-name" style="color:#3f3f3f;padding:5px"
|
||||
type="text"
|
||||
placeholder="Ex. drone"
|
||||
name="deviceName" size="60" required>
|
||||
<br/>
|
||||
<input type="hidden" class="deviceType" name="deviceType"
|
||||
value="drone_analyzer"/>
|
||||
<input type="hidden" class="sketchType" name="sketchType"
|
||||
value="drone_analyzer"/>
|
||||
</div>
|
||||
</div>
|
||||
<br/>
|
||||
<div class="buttons">
|
||||
<a class="btn-operations" onclick="downloadAgent()">Download Now</a>
|
||||
</div>
|
||||
</form>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="device-agent-downloading-content" class="hide">
|
||||
<div class="modal-content">
|
||||
<div class="row">
|
||||
<div class="col-md-7 col-centered center-container">
|
||||
<h3>Device Agent will downloading shortly.</h3>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="device-400-content" class="hide">
|
||||
<div class="modal-content">
|
||||
<div class="row">
|
||||
<div class="col-md-7 col-centered center-container">
|
||||
<h3>Exception at backend. Try Later.</h3>
|
||||
<div class="buttons">
|
||||
<a href="#" id="device-400-link" class="btn-operations">
|
||||
OK
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="device-401-content" class="hide">
|
||||
<div class="modal-content">
|
||||
<div class="row">
|
||||
<div class="col-md-7 col-centered center-container">
|
||||
<h3>You have to log in first.</h3><br/>
|
||||
<div class="buttons">
|
||||
<a href="#" id="device-401-link" class="blue-button">
|
||||
Goto Login Page
|
||||
</a>
|
||||
<a href="#" onclick="hidePopup();" class="btn-operations">
|
||||
Cancel
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="device-403-content" class="hide">
|
||||
<div class="modal-content">
|
||||
<div class="row">
|
||||
<div class="col-md-7 col-centered center-container">
|
||||
<h3>Action not permitted.</h3><br/>
|
||||
<div class="buttons">
|
||||
<a href="#" id="device-403-link" class="btn-operations">
|
||||
OK
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="device-409-content" class="hide">
|
||||
<div class="modal-content">
|
||||
<div class="row">
|
||||
<div class="col-md-7 col-centered center-container">
|
||||
<h3>Device Sketch does not exist.</h3><br/>
|
||||
<div class="buttons">
|
||||
<a href="#" id="device-409-link" class="btn-operations">
|
||||
OK
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div id="device-unexpected-error-content" class="hide">
|
||||
<div class="modal-content">
|
||||
<div class="row">
|
||||
<div class="col-md-7 col-centered center-container">
|
||||
<h3>Unexpected error.</h3><br/>
|
||||
<div class="buttons">
|
||||
<a href="#" id="device-unexpected-error-link" class="btn-operations">
|
||||
OK
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<br/><br/>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-12 col-md-12 col-lg-12 padding-double grey-bg">
|
||||
<h3 class="uppercase">Prepare</h3>
|
||||
<hr>
|
||||
<ul class="list-unstyled">
|
||||
<li class="padding-top-double">
|
||||
<span class="circle">01</span>
|
||||
Connect your IRIS+ Drone to your computer using either USB to Micro
|
||||
USB cable or Telemetry Radio receiver.
|
||||
</li>
|
||||
<li class="padding-top-double">
|
||||
<span class="circle">02</span>
|
||||
Click on [Download Agent] button above to get IRIS+ Drone agent.
|
||||
</li>
|
||||
<li class="padding-top-double">
|
||||
<span class="circle">03</span>
|
||||
Once you have downloaded the agent please run
|
||||
<i>"[startService.sh]"</i> script with root privileges.
|
||||
</li>
|
||||
<li class="padding-top-double">
|
||||
<span class="circle">04</span>
|
||||
Then you will be prompted to enter time interval (in seconds) between
|
||||
successive Data-Pushes to the XMPP server, connection target and communication speed. So
|
||||
below table will help you to find what is the correct connection target and
|
||||
communication speed.
|
||||
</li>
|
||||
<div class="padding-top-double">
|
||||
<table class="table table-bordered ">
|
||||
<thead>
|
||||
<tr>
|
||||
<th>
|
||||
<center><i>CONNECTION-TYPE</i></center>
|
||||
</th>
|
||||
<th>
|
||||
<center><i>CONNECTION-STRING</i></center>
|
||||
</th>
|
||||
</tr>
|
||||
</thead>
|
||||
<tbody>
|
||||
<tr>
|
||||
<td>Linux computer connected to the vehicle via USB</td>
|
||||
<td> e.g. /dev/ttyUSB0</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Linux computer connected to the drone via Serial port</td>
|
||||
<td> e.g. /dev/ttyAMA0 <i>(also set baud=57600)</i></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>OSX computer connected to the drone via USB</td>
|
||||
<td>e.g. dev/cu.usbmodem1</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Windows computer connected to the drone via USB (in this case on COM14)</td>
|
||||
<td>e.g. com14</td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Windows computer connected to the drone using a 3DR Telemetry Radio on
|
||||
COM14
|
||||
</td>
|
||||
<td>e.g. com14 <i>(also set baud=57600)</i></td>
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
</ul>
|
||||
<br>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6 padding-double">
|
||||
<h3 class="uppercase">IRIS+ Drone Connected to a computer</h3>
|
||||
<hr>
|
||||
<p class="grey margin-top">Click on the image to zoom</p>
|
||||
<center>
|
||||
<a href="{{@unit.publicUri}}/images/schematicsGuide.png" target="_blank">
|
||||
<img src="{{@unit.publicUri}}/images/schematicsGuide.png" class="img-responsive">
|
||||
</a>
|
||||
</center>
|
||||
<br/>
|
||||
</div>
|
||||
<div class="col-xs-12 col-sm-6 col-md-6 col-lg-6 padding-double">
|
||||
<h3 class="uppercase">Try Out</h3>
|
||||
<hr>
|
||||
<ul class="list-unstyled">
|
||||
<li class="padding-top-double">
|
||||
<span class="circle">01</span>
|
||||
You can view all your connected devices at
|
||||
<a href="{{@app.context}}/devices">[Device Management]</a> page.
|
||||
</li>
|
||||
<li class="padding-top-double">
|
||||
<span class="circle">02</span>
|
||||
Select one of connected devices and view stats which are published by
|
||||
the device.
|
||||
</li>
|
||||
</ul>
|
||||
<br/>
|
||||
<p class="grey margin-top">Click on the image to zoom</p>
|
||||
<center>
|
||||
<a href="{{@unit.publicUri}}/images/devices_analytics.png" target="_blank">
|
||||
<img src="{{@unit.publicUri}}/images/devices_analytics.png" class="img-responsive">
|
||||
</a>
|
||||
</center>
|
||||
</div>
|
||||
|
||||
{{#zone "topCss"}}
|
||||
<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;
|
||||
}
|
||||
.doc-link {
|
||||
background: #11375B;
|
||||
padding: 20px;
|
||||
color: white;
|
||||
margin-top: 0;
|
||||
}
|
||||
.doc-link a {
|
||||
color: white;
|
||||
}
|
||||
</style>
|
||||
{{/zone}}
|
||||
|
||||
{{#zone "bottomJs"}}
|
||||
{{js "/js/download.js"}}
|
||||
{{js "/js/jquery.validate.js"}}
|
||||
{{/zone}}
|
@ -1,3 +0,0 @@
|
||||
{
|
||||
"version": "1.0.0"
|
||||
}
|
@ -1,220 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
.box {
|
||||
margin-top: 10px;
|
||||
margin-bottom: 10px;
|
||||
}
|
||||
|
||||
.box-inner {
|
||||
border: 1px solid #DEDEDE;
|
||||
border-radius: 3px;
|
||||
-webkit-border-radius: 3px;
|
||||
-moz-border-radius: 3px;
|
||||
box-shadow: 0 0 10px rgba(189, 189, 189, 0.4);
|
||||
-webkit-box-shadow: 0 0 10px rgba(189, 189, 189, 0.4);
|
||||
-moz-box-shadow: 0 0 10px rgba(189, 189, 189, 0.4);
|
||||
}
|
||||
|
||||
.box-header {
|
||||
border: none;
|
||||
padding-top: 5px;
|
||||
border-bottom: 1px solid #DEDEDE;
|
||||
border-radius: 3px 3px 0 0;
|
||||
-webkit-border-radius: 3px 3px 0 0;
|
||||
-moz-border-radius: 3px 3px 0 0;
|
||||
height: 35px;
|
||||
min-height: 35px !important;
|
||||
margin-bottom: 0;
|
||||
font-weight: bold;
|
||||
font-size: 16px;
|
||||
background: -moz-linear-gradient(top, rgba(255, 255, 255, 0) 0%, rgba(0, 0, 0, 0.1) 100%);
|
||||
background: -webkit-gradient(linear, left top, left bottom, color-stop(0%, rgba(255, 255, 255, 0)), color-stop(100%, rgba(0, 0, 0, 0.1)));
|
||||
background: -webkit-linear-gradient(top, rgba(255, 255, 255, 0) 0%, rgba(0, 0, 0, 0.1) 100%);
|
||||
background: -o-linear-gradient(top, rgba(255, 255, 255, 0) 0%, rgba(0, 0, 0, 0.1) 100%);
|
||||
background: -ms-linear-gradient(top, rgba(255, 255, 255, 0) 0%, rgba(0, 0, 0, 0.1) 100%);
|
||||
background: linear-gradient(to bottom, rgba(255, 255, 255, 0) 0%, rgba(0, 0, 0, 0.1) 100%);
|
||||
filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#00ffffff', endColorstr='#1a000000', GradientType=0);
|
||||
|
||||
}
|
||||
|
||||
.box-header h2 {
|
||||
font-size: 15px;
|
||||
width: auto;
|
||||
clear: none;
|
||||
float: left;
|
||||
line-height: 25px;
|
||||
white-space: nowrap;
|
||||
font-weight: bold;
|
||||
margin-top: 0;
|
||||
margin-bottom: 0;
|
||||
}
|
||||
|
||||
.box-header h3 {
|
||||
font-size: 13px;
|
||||
width: auto;
|
||||
clear: none;
|
||||
float: left;
|
||||
line-height: 25px;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.box-header h2 > i {
|
||||
margin-top: 1px;
|
||||
}
|
||||
|
||||
.box-icon {
|
||||
float: right;
|
||||
}
|
||||
|
||||
.box-icon a {
|
||||
clear: none;
|
||||
float: left;
|
||||
margin: 0 2px;
|
||||
height: 20px;
|
||||
width: 5px;
|
||||
margin-top: 1px;
|
||||
}
|
||||
|
||||
.box-icon a i {
|
||||
margin-left: -6px;
|
||||
top: -1px;
|
||||
}
|
||||
|
||||
.box-content {
|
||||
padding: 10px;
|
||||
}
|
||||
|
||||
.btn-round {
|
||||
border-radius: 40px;
|
||||
-webkit-border-radius: 40px;
|
||||
-moz-border-radius: 40px;
|
||||
font-size: 12px;
|
||||
padding-top: 4px;
|
||||
}
|
||||
|
||||
.navbar-brand {
|
||||
font-family: 'Shojumaru', cursive, Arial, serif;
|
||||
letter-spacing: 2px;
|
||||
text-shadow: 1px 1px 5px rgba(0, 0, 0, 0.5);
|
||||
width: 183px;
|
||||
font-size: 17px;
|
||||
}
|
||||
|
||||
.navbar-brand img {
|
||||
float: left;
|
||||
height: 20px;
|
||||
width: 20px;
|
||||
margin-right: 5px;
|
||||
}
|
||||
|
||||
.navbar-brand span {
|
||||
float: left;
|
||||
}
|
||||
|
||||
.navbar-search {
|
||||
margin-left: 10px;
|
||||
margin-top: 7px;
|
||||
}
|
||||
|
||||
.navbar-inner {
|
||||
padding-top: 5px;
|
||||
padding-bottom: 5px;
|
||||
line-height: 30px;
|
||||
height: 60px;
|
||||
}
|
||||
|
||||
.navbar-inner .btn-group {
|
||||
margin: 7px 5px 0 5px;
|
||||
}
|
||||
|
||||
.bs-icons li {
|
||||
list-style: none;
|
||||
}
|
||||
|
||||
.box-content .nav-tabs {
|
||||
margin-right: -10px;
|
||||
margin-left: -10px;
|
||||
}
|
||||
|
||||
.box-content.buttons {
|
||||
min-height: 297px;
|
||||
}
|
||||
|
||||
.sidebar-nav .nav-header {
|
||||
display: block;
|
||||
padding: 3px 15px;
|
||||
font-size: 11px;
|
||||
font-weight: bold;
|
||||
line-height: 18px;
|
||||
color: #999999;
|
||||
text-shadow: 0 1px 0 rgba(255, 255, 255, 0.5);
|
||||
text-transform: uppercase;
|
||||
}
|
||||
|
||||
.navbar {
|
||||
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;
|
||||
}
|
Before Width: | Height: | Size: 26 KiB |
Before Width: | Height: | Size: 11 KiB |
Before Width: | Height: | Size: 20 KiB |
Before Width: | Height: | Size: 2.1 KiB |
@ -1,206 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
var camera, scene, renderer;
|
||||
var cameraControls;
|
||||
var clock = new THREE.Clock();
|
||||
|
||||
var ground = true;
|
||||
var circle1, plate1;
|
||||
|
||||
var object_maker = function () {
|
||||
var make_object = this;
|
||||
make_object.fillScene = function () {
|
||||
scene = new THREE.Scene();
|
||||
scene.fog = new THREE.Fog(0x808080, 2000, 4000);
|
||||
|
||||
|
||||
var ambientLight = new THREE.AmbientLight(0x222222);
|
||||
var light = new THREE.DirectionalLight(0xFFFFFF, 1.0);
|
||||
light.position.set(200, 400, 500);
|
||||
|
||||
var light2 = new THREE.DirectionalLight(0xFFFFFF, 1.0);
|
||||
light2.position.set(-500, 250, -200);
|
||||
|
||||
scene.add(ambientLight);
|
||||
scene.add(light);
|
||||
scene.add(light2);
|
||||
|
||||
if (ground) {
|
||||
Coordinates.drawGround({size: 10000});
|
||||
}
|
||||
|
||||
|
||||
var robotBaseMaterial = new THREE.MeshPhongMaterial({color: 0x6E23BB, specular: 0x6E23BB, shininess: 20});
|
||||
var robotForearmMaterial = new THREE.MeshPhongMaterial({color: 0xF4C154, specular: 0xF4C154, shininess: 100});
|
||||
|
||||
circle1 = new THREE.Object3D();
|
||||
var circleLength = 40;
|
||||
make_object.addCircles(circle1, circleLength, robotBaseMaterial);
|
||||
circle1.position.y = circleLength * 2;
|
||||
scene.add(circle1);
|
||||
|
||||
plate1 = new THREE.Object3D();
|
||||
var plateLength = 40;
|
||||
make_object.addPlates(plate1, plateLength, robotForearmMaterial);
|
||||
plate1.position.y = circleLength / 8;
|
||||
circle1.add(plate1);
|
||||
|
||||
},
|
||||
|
||||
make_object.addPlates = function (part, plateLength, material) {
|
||||
|
||||
var cylinder = new THREE.Mesh(
|
||||
new THREE.CylinderGeometry(5, 5, 40, 32), material);
|
||||
cylinder.rotation.x = 90 * Math.PI / 180;
|
||||
cylinder.position.x = plateLength + 15;
|
||||
part.add(cylinder);
|
||||
cylinder = new THREE.Mesh(
|
||||
new THREE.CylinderGeometry(5, 5, 40, 32), material);
|
||||
cylinder.rotation.x = 90 * Math.PI / 180;
|
||||
cylinder.rotation.z = 90 * Math.PI / 180;
|
||||
cylinder.position.x = plateLength + 15;
|
||||
part.add(cylinder);
|
||||
|
||||
cylinder = new THREE.Mesh(
|
||||
new THREE.CylinderGeometry(5, 5, 40, 32), material);
|
||||
cylinder.rotation.x = 90 * Math.PI / 180;
|
||||
cylinder.position.x = -plateLength - 15;
|
||||
part.add(cylinder);
|
||||
cylinder = new THREE.Mesh(
|
||||
new THREE.CylinderGeometry(5, 5, 40, 32), material);
|
||||
cylinder.rotation.x = 90 * Math.PI / 180;
|
||||
cylinder.rotation.z = 90 * Math.PI / 180;
|
||||
cylinder.position.x = -plateLength - 15;
|
||||
part.add(cylinder);
|
||||
|
||||
cylinder = new THREE.Mesh(
|
||||
new THREE.CylinderGeometry(5, 5, 40, 32), material);
|
||||
cylinder.rotation.x = 90 * Math.PI / 180;
|
||||
cylinder.position.z = -plateLength - 15;
|
||||
part.add(cylinder);
|
||||
cylinder = new THREE.Mesh(
|
||||
new THREE.CylinderGeometry(5, 5, 40, 32), material);
|
||||
cylinder.rotation.x = 90 * Math.PI / 180;
|
||||
cylinder.rotation.z = 90 * Math.PI / 180;
|
||||
cylinder.position.z = -plateLength - 15;
|
||||
part.add(cylinder);
|
||||
//
|
||||
cylinder = new THREE.Mesh(
|
||||
new THREE.CylinderGeometry(5, 5, 40, 32), material);
|
||||
cylinder.rotation.x = 90 * Math.PI / 180;
|
||||
cylinder.position.z = plateLength + 15;
|
||||
part.add(cylinder);
|
||||
cylinder = new THREE.Mesh(
|
||||
new THREE.CylinderGeometry(5, 5, 40, 32), material);
|
||||
cylinder.rotation.x = 90 * Math.PI / 180;
|
||||
cylinder.rotation.z = 90 * Math.PI / 180;
|
||||
cylinder.position.z = plateLength + 15;
|
||||
part.add(cylinder);
|
||||
|
||||
},
|
||||
|
||||
make_object.addCircles = function (part, circleLength, material) {
|
||||
var circle = new THREE.Mesh(
|
||||
new THREE.TorusGeometry(40, 10, 40, 20, 6.3), material);
|
||||
circle.position.x = circleLength + 10;
|
||||
circle.rotation.x = 90 * Math.PI / 180;
|
||||
part.add(circle);
|
||||
circle = new THREE.Mesh(
|
||||
new THREE.TorusGeometry(40, 10, 40, 20, 6.3), material);
|
||||
circle.position.x = -circleLength - 10;
|
||||
circle.rotation.x = 90 * Math.PI / 180;
|
||||
part.add(circle);
|
||||
circle = new THREE.Mesh(
|
||||
new THREE.TorusGeometry(40, 10, 40, 20, 6.3), material);
|
||||
circle.position.z = -circleLength - 10;
|
||||
circle.rotation.x = 90 * Math.PI / 180;
|
||||
part.add(circle);
|
||||
circle = new THREE.Mesh(
|
||||
new THREE.TorusGeometry(40, 10, 40, 20, 6.3), material);
|
||||
circle.position.z = circleLength + 10;
|
||||
circle.rotation.x = 90 * Math.PI / 180;
|
||||
part.add(circle);
|
||||
},
|
||||
|
||||
make_object.init = function (holder, object_width, object_height) {
|
||||
var canvasRatio = 1;
|
||||
renderer = new THREE.WebGLRenderer({antialias: true});
|
||||
renderer.gammaInput = true;
|
||||
renderer.gammaOutput = true;
|
||||
renderer.setSize(object_width, object_height);
|
||||
renderer.setClearColorHex(0xAAAAAA, 1.0);
|
||||
|
||||
$(holder).append(renderer.domElement);
|
||||
camera = new THREE.PerspectiveCamera(30, canvasRatio, 1, 10000);
|
||||
camera.position.set(-510, 240, 100);
|
||||
cameraControls = new THREE.OrbitAndPanControls(camera, renderer.domElement);
|
||||
cameraControls.target.set(0, 100, 0);
|
||||
make_object.fillScene();
|
||||
|
||||
},
|
||||
make_object.animate = function () {
|
||||
window.requestAnimationFrame(make_object.animate);
|
||||
make_object.render();
|
||||
},
|
||||
make_object.render = function () {
|
||||
var delta = clock.getDelta();
|
||||
cameraControls.update(delta);
|
||||
circle1.rotation.z = config_api.effectController.uz;
|
||||
circle1.rotation.y = config_api.effectController.uy; // yaw
|
||||
circle1.rotation.x = config_api.effectController.ux; // roll
|
||||
circle1.position.z = config_api.effectController.fz;
|
||||
circle1.position.x = config_api.effectController.fx;
|
||||
renderer.render(scene, camera);
|
||||
},
|
||||
make_object.get_heading_attitude_bank = function (data) {
|
||||
if (data.length < 4) {
|
||||
return {"heading": data[0], "attitude": data[1], "bank": data[2]};
|
||||
} else {
|
||||
|
||||
var heading = Math.atan2(2 * data[1] * data[3] - 2 * data[0] * data[1], 1 - 2 * data[1] * data[1]
|
||||
- 2 * data[2] * data[2]);
|
||||
var bank = Math.atan2(2 * data[0] * data[3] - 2 * data[1] * data[2], 1 - 2 * data[0] * data[0]
|
||||
- 2 * data[2] * data[2]);
|
||||
var attitude = Math.asin(2 * data[0] * data[1] + 2 * data[2] * data[3]);
|
||||
|
||||
return {
|
||||
"heading": isNaN(heading) ? 0 : heading,
|
||||
"bank": isNaN(bank) ? 0 : bank,
|
||||
"attitude": isNaN(attitude) ? 0 : attitude
|
||||
};
|
||||
}
|
||||
},
|
||||
make_object.set_heading_attitude_bank = function (data) {
|
||||
config_api.effectController.uy = data.heading;
|
||||
config_api.effectController.uz = data.attitude;
|
||||
config_api.effectController.ux = data.bank;
|
||||
},
|
||||
make_object.set_heading = function (holder, heading) {
|
||||
var r = (180 / Math.PI) * parseFloat(heading);
|
||||
$(holder).rotate(r);
|
||||
|
||||
},
|
||||
make_object.set_bank = function (holder, bank) {
|
||||
var r = (180 / Math.PI) * parseFloat(bank);
|
||||
$(holder).rotate(r);
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
@ -1,166 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
/*global THREE, scene*/
|
||||
var Coordinates = {
|
||||
drawGrid:function(params) {
|
||||
params = params || {};
|
||||
var size = params.size !== undefined ? params.size:100;
|
||||
var scale = params.scale !== undefined ? params.scale:0.1;
|
||||
var orientation = params.orientation !== undefined ? params.orientation:"x";
|
||||
var grid = new THREE.Mesh(
|
||||
new THREE.PlaneGeometry(size, size, size * scale, size * scale),
|
||||
new THREE.MeshBasicMaterial({ color: 0x555555, wireframe: true })
|
||||
);
|
||||
// Yes, these are poorly labeled! It would be a mess to fix.
|
||||
// What's really going on here:
|
||||
// "x" means "rotate 90 degrees around x", etc.
|
||||
// So "x" really means "show a grid with a normal of Y"
|
||||
// "y" means "show a grid with a normal of X"
|
||||
// "z" means (logically enough) "show a grid with a normal of Z"
|
||||
if (orientation === "x") {
|
||||
grid.rotation.x = - Math.PI / 2;
|
||||
} else if (orientation === "y") {
|
||||
grid.rotation.y = - Math.PI / 2;
|
||||
} else if (orientation === "z") {
|
||||
grid.rotation.z = - Math.PI / 2;
|
||||
}
|
||||
|
||||
scene.add(grid);
|
||||
},
|
||||
drawGround:function(params) {
|
||||
params = params || {};
|
||||
var size = params.size !== undefined ? params.size:100;
|
||||
var color = params.color !== undefined ? params.color:0xFFFFFF;
|
||||
var ground = new THREE.Mesh(
|
||||
new THREE.PlaneGeometry(size, size),
|
||||
// When we use a ground plane we use directional lights, so illuminating
|
||||
// just the corners is sufficient.
|
||||
// Use MeshPhongMaterial if you want to capture per-pixel lighting:
|
||||
// new THREE.MeshPhongMaterial({ color: color, specular: 0x000000,
|
||||
new THREE.MeshLambertMaterial({ color: color,
|
||||
// polygonOffset moves the plane back from the eye a bit, so that the lines on top of
|
||||
// the grid do not have z-fighting with the grid:
|
||||
// Factor == 1 moves it back relative to the slope (more on-edge means move back farther)
|
||||
// Units == 4 is a fixed amount to move back, and 4 is usually a good value
|
||||
polygonOffset: true, polygonOffsetFactor: 1.0, polygonOffsetUnits: 4.0
|
||||
}));
|
||||
ground.rotation.x = - Math.PI / 2;
|
||||
scene.add(ground);
|
||||
},
|
||||
drawAxes:function(params) {
|
||||
// x = red, y = green, z = blue (RGB = xyz)
|
||||
params = params || {};
|
||||
var axisRadius = params.axisRadius !== undefined ? params.axisRadius:0.04;
|
||||
var axisLength = params.axisLength !== undefined ? params.axisLength:11;
|
||||
var axisTess = params.axisTess !== undefined ? params.axisTess:48;
|
||||
var axisOrientation = params.axisOrientation !== undefined ? params.axisOrientation:"x";
|
||||
|
||||
var axisMaterial = new THREE.MeshLambertMaterial({ color: 0x000000, side: THREE.DoubleSide });
|
||||
var axis = new THREE.Mesh(
|
||||
new THREE.CylinderGeometry(axisRadius, axisRadius, axisLength, axisTess, 1, true),
|
||||
axisMaterial
|
||||
);
|
||||
if (axisOrientation === "x") {
|
||||
axis.rotation.z = - Math.PI / 2;
|
||||
axis.position.x = axisLength/2-1;
|
||||
} else if (axisOrientation === "y") {
|
||||
axis.position.y = axisLength/2-1;
|
||||
}
|
||||
|
||||
scene.add( axis );
|
||||
|
||||
var arrow = new THREE.Mesh(
|
||||
new THREE.CylinderGeometry(0, 4*axisRadius, 8*axisRadius, axisTess, 1, true),
|
||||
axisMaterial
|
||||
);
|
||||
if (axisOrientation === "x") {
|
||||
arrow.rotation.z = - Math.PI / 2;
|
||||
arrow.position.x = axisLength - 1 + axisRadius*4/2;
|
||||
} else if (axisOrientation === "y") {
|
||||
arrow.position.y = axisLength - 1 + axisRadius*4/2;
|
||||
}
|
||||
|
||||
scene.add( arrow );
|
||||
|
||||
},
|
||||
drawAllAxes:function(params) {
|
||||
params = params || {};
|
||||
var axisRadius = params.axisRadius !== undefined ? params.axisRadius:0.04;
|
||||
var axisLength = params.axisLength !== undefined ? params.axisLength:11;
|
||||
var axisTess = params.axisTess !== undefined ? params.axisTess:48;
|
||||
|
||||
var axisXMaterial = new THREE.MeshLambertMaterial({ color: 0xFF0000 });
|
||||
var axisYMaterial = new THREE.MeshLambertMaterial({ color: 0x00FF00 });
|
||||
var axisZMaterial = new THREE.MeshLambertMaterial({ color: 0x0000FF });
|
||||
axisXMaterial.side = THREE.DoubleSide;
|
||||
axisYMaterial.side = THREE.DoubleSide;
|
||||
axisZMaterial.side = THREE.DoubleSide;
|
||||
var axisX = new THREE.Mesh(
|
||||
new THREE.CylinderGeometry(axisRadius, axisRadius, axisLength, axisTess, 1, true),
|
||||
axisXMaterial
|
||||
);
|
||||
var axisY = new THREE.Mesh(
|
||||
new THREE.CylinderGeometry(axisRadius, axisRadius, axisLength, axisTess, 1, true),
|
||||
axisYMaterial
|
||||
);
|
||||
var axisZ = new THREE.Mesh(
|
||||
new THREE.CylinderGeometry(axisRadius, axisRadius, axisLength, axisTess, 1, true),
|
||||
axisZMaterial
|
||||
);
|
||||
axisX.rotation.z = - Math.PI / 2;
|
||||
axisX.position.x = axisLength/2-1;
|
||||
|
||||
axisY.position.y = axisLength/2-1;
|
||||
|
||||
axisZ.rotation.y = - Math.PI / 2;
|
||||
axisZ.rotation.z = - Math.PI / 2;
|
||||
axisZ.position.z = axisLength/2-1;
|
||||
|
||||
scene.add( axisX );
|
||||
scene.add( axisY );
|
||||
scene.add( axisZ );
|
||||
|
||||
var arrowX = new THREE.Mesh(
|
||||
new THREE.CylinderGeometry(0, 4*axisRadius, 4*axisRadius, axisTess, 1, true),
|
||||
axisXMaterial
|
||||
);
|
||||
var arrowY = new THREE.Mesh(
|
||||
new THREE.CylinderGeometry(0, 4*axisRadius, 4*axisRadius, axisTess, 1, true),
|
||||
axisYMaterial
|
||||
);
|
||||
var arrowZ = new THREE.Mesh(
|
||||
new THREE.CylinderGeometry(0, 4*axisRadius, 4*axisRadius, axisTess, 1, true),
|
||||
axisZMaterial
|
||||
);
|
||||
arrowX.rotation.z = - Math.PI / 2;
|
||||
arrowX.position.x = axisLength - 1 + axisRadius*4/2;
|
||||
|
||||
arrowY.position.y = axisLength - 1 + axisRadius*4/2;
|
||||
|
||||
arrowZ.rotation.z = - Math.PI / 2;
|
||||
arrowZ.rotation.y = - Math.PI / 2;
|
||||
arrowZ.position.z = axisLength - 1 + axisRadius*4/2;
|
||||
|
||||
scene.add( arrowX );
|
||||
scene.add( arrowY );
|
||||
scene.add( arrowZ );
|
||||
|
||||
}
|
||||
|
||||
};
|
@ -1,549 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
/**
|
||||
* @author qiao / https://github.com/qiao
|
||||
* @author mrdoob / http://mrdoob.com
|
||||
* @author alteredq / http://alteredqualia.com/
|
||||
* @author WestLangley / http://github.com/WestLangley
|
||||
* @author erich666 / http://erichaines.com
|
||||
*/
|
||||
/*global THREE, console */
|
||||
|
||||
THREE.OrbitAndPanControls = function ( object, domElement ) {
|
||||
|
||||
THREE.EventDispatcher.call( this );
|
||||
|
||||
this.enabled = true;
|
||||
|
||||
this.object = object;
|
||||
this.domElement = ( domElement !== undefined ) ? domElement : document;
|
||||
|
||||
// API
|
||||
|
||||
this.enabled = true;
|
||||
|
||||
this.target = new THREE.Vector3();
|
||||
// center is old, deprecated; use "target" instead
|
||||
this.center = this.target;
|
||||
|
||||
// This option actually enables dollying in and out
|
||||
this.noZoom = false;
|
||||
this.zoomSpeed = 1.0;
|
||||
|
||||
this.noRotate = false;
|
||||
this.rotateSpeed = 1.0;
|
||||
|
||||
this.noPan = false;
|
||||
|
||||
this.autoRotate = false;
|
||||
this.autoRotateSpeed = 2.0; // 30 seconds per round when fps is 60
|
||||
|
||||
this.minPolarAngle = 0; // radians
|
||||
this.maxPolarAngle = Math.PI; // radians
|
||||
|
||||
this.minDistance = 0;
|
||||
this.maxDistance = Infinity;
|
||||
|
||||
this.noKeys = false;
|
||||
this.keys = { LEFT: 37, UP: 38, RIGHT: 39, BOTTOM: 40 };
|
||||
|
||||
// internals
|
||||
|
||||
var scope = this;
|
||||
|
||||
var EPS = 0.000001;
|
||||
|
||||
var rotateStart = new THREE.Vector2();
|
||||
var rotateEnd = new THREE.Vector2();
|
||||
var rotateDelta = new THREE.Vector2();
|
||||
|
||||
var panStart = new THREE.Vector2();
|
||||
var panEnd = new THREE.Vector2();
|
||||
var panDelta = new THREE.Vector2();
|
||||
|
||||
var dollyStart = new THREE.Vector2();
|
||||
var dollyEnd = new THREE.Vector2();
|
||||
var dollyDelta = new THREE.Vector2();
|
||||
|
||||
var phiDelta = 0;
|
||||
var thetaDelta = 0;
|
||||
var scale = 1;
|
||||
var pan = new THREE.Vector3();
|
||||
|
||||
var lastPosition = new THREE.Vector3();
|
||||
|
||||
var STATE = { NONE : -1, ROTATE : 0, DOLLY : 1, PAN : 2, TOUCH_ROTATE : 3, TOUCH_DOLLY : 4, TOUCH_PAN : 5 };
|
||||
var state = STATE.NONE;
|
||||
|
||||
// events
|
||||
|
||||
var changeEvent = { type: 'change' };
|
||||
|
||||
|
||||
this.rotateLeft = function ( angle ) {
|
||||
|
||||
if ( angle === undefined ) {
|
||||
|
||||
angle = getAutoRotationAngle();
|
||||
|
||||
}
|
||||
|
||||
thetaDelta -= angle;
|
||||
|
||||
};
|
||||
|
||||
this.rotateUp = function ( angle ) {
|
||||
|
||||
if ( angle === undefined ) {
|
||||
|
||||
angle = getAutoRotationAngle();
|
||||
|
||||
}
|
||||
|
||||
phiDelta -= angle;
|
||||
|
||||
};
|
||||
|
||||
// pass in distance in world space to move left
|
||||
this.panLeft = function ( distance ) {
|
||||
|
||||
var panOffset = new THREE.Vector3();
|
||||
var te = this.object.matrix.elements;
|
||||
// get X column of matrix
|
||||
panOffset.set( te[0], te[1], te[2] );
|
||||
panOffset.multiplyScalar(-distance);
|
||||
|
||||
pan.add( panOffset );
|
||||
|
||||
};
|
||||
|
||||
// pass in distance in world space to move up
|
||||
this.panUp = function ( distance ) {
|
||||
|
||||
var panOffset = new THREE.Vector3();
|
||||
var te = this.object.matrix.elements;
|
||||
// get Y column of matrix
|
||||
panOffset.set( te[4], te[5], te[6] );
|
||||
panOffset.multiplyScalar(distance);
|
||||
|
||||
pan.add( panOffset );
|
||||
};
|
||||
|
||||
// main entry point; pass in Vector2 of change desired in pixel space,
|
||||
// right and down are positive
|
||||
this.pan = function ( delta ) {
|
||||
|
||||
if ( scope.object.fov !== undefined )
|
||||
{
|
||||
// perspective
|
||||
var position = scope.object.position;
|
||||
var offset = position.clone().sub( scope.target );
|
||||
var targetDistance = offset.length();
|
||||
|
||||
// half of the fov is center to top of screen
|
||||
targetDistance *= Math.tan( (scope.object.fov/2) * Math.PI / 180.0 );
|
||||
// we actually don't use screenWidth, since perspective camera is fixed to screen height
|
||||
scope.panLeft( 2 * delta.x * targetDistance / scope.domElement.height );
|
||||
scope.panUp( 2 * delta.y * targetDistance / scope.domElement.height );
|
||||
}
|
||||
else if ( scope.object.top !== undefined )
|
||||
{
|
||||
// orthographic
|
||||
scope.panLeft( delta.x * (scope.object.right - scope.object.left) / scope.domElement.width );
|
||||
scope.panUp( delta.y * (scope.object.top - scope.object.bottom) / scope.domElement.height );
|
||||
}
|
||||
else
|
||||
{
|
||||
// camera neither orthographic or perspective - warn user
|
||||
console.warn( 'WARNING: OrbitControls.js encountered an unknown camera type - pan disabled.' );
|
||||
}
|
||||
};
|
||||
|
||||
this.dollyIn = function ( dollyScale ) {
|
||||
|
||||
if ( dollyScale === undefined ) {
|
||||
|
||||
dollyScale = getZoomScale();
|
||||
|
||||
}
|
||||
|
||||
scale /= dollyScale;
|
||||
|
||||
};
|
||||
|
||||
this.dollyOut = function ( dollyScale ) {
|
||||
|
||||
if ( dollyScale === undefined ) {
|
||||
|
||||
dollyScale = getZoomScale();
|
||||
|
||||
}
|
||||
|
||||
scale *= dollyScale;
|
||||
|
||||
};
|
||||
|
||||
this.update = function () {
|
||||
|
||||
var position = this.object.position;
|
||||
var offset = position.clone().sub( this.target );
|
||||
|
||||
// angle from z-axis around y-axis
|
||||
|
||||
var theta = Math.atan2( offset.x, offset.z );
|
||||
|
||||
// angle from y-axis
|
||||
|
||||
var phi = Math.atan2( Math.sqrt( offset.x * offset.x + offset.z * offset.z ), offset.y );
|
||||
|
||||
if ( this.autoRotate ) {
|
||||
|
||||
this.rotateLeft( getAutoRotationAngle() );
|
||||
|
||||
}
|
||||
|
||||
theta += thetaDelta;
|
||||
phi += phiDelta;
|
||||
|
||||
// restrict phi to be between desired limits
|
||||
phi = Math.max( this.minPolarAngle, Math.min( this.maxPolarAngle, phi ) );
|
||||
|
||||
// restrict phi to be betwee EPS and PI-EPS
|
||||
phi = Math.max( EPS, Math.min( Math.PI - EPS, phi ) );
|
||||
|
||||
var radius = offset.length() * scale;
|
||||
|
||||
// restrict radius to be between desired limits
|
||||
radius = Math.max( this.minDistance, Math.min( this.maxDistance, radius ) );
|
||||
|
||||
// move target to panned location
|
||||
this.target.add( pan );
|
||||
|
||||
offset.x = radius * Math.sin( phi ) * Math.sin( theta );
|
||||
offset.y = radius * Math.cos( phi );
|
||||
offset.z = radius * Math.sin( phi ) * Math.cos( theta );
|
||||
|
||||
position.copy( this.target ).add( offset );
|
||||
|
||||
this.object.lookAt( this.target );
|
||||
|
||||
thetaDelta = 0;
|
||||
phiDelta = 0;
|
||||
scale = 1;
|
||||
pan.set(0,0,0);
|
||||
|
||||
if ( lastPosition.distanceTo( this.object.position ) > 0 ) {
|
||||
|
||||
this.dispatchEvent( changeEvent );
|
||||
|
||||
lastPosition.copy( this.object.position );
|
||||
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
||||
function getAutoRotationAngle() {
|
||||
|
||||
return 2 * Math.PI / 60 / 60 * scope.autoRotateSpeed;
|
||||
|
||||
}
|
||||
|
||||
function getZoomScale() {
|
||||
|
||||
return Math.pow( 0.95, scope.zoomSpeed );
|
||||
|
||||
}
|
||||
|
||||
function onMouseDown( event ) {
|
||||
|
||||
if ( scope.enabled === false ) { return; }
|
||||
event.preventDefault();
|
||||
|
||||
if ( event.button === 0 ) {
|
||||
if ( scope.noRotate === true ) { return; }
|
||||
|
||||
state = STATE.ROTATE;
|
||||
|
||||
rotateStart.set( event.clientX, event.clientY );
|
||||
|
||||
} else if ( event.button === 1 ) {
|
||||
if ( scope.noZoom === true ) { return; }
|
||||
|
||||
state = STATE.DOLLY;
|
||||
|
||||
dollyStart.set( event.clientX, event.clientY );
|
||||
|
||||
} else if ( event.button === 2 ) {
|
||||
if ( scope.noPan === true ) { return; }
|
||||
|
||||
state = STATE.PAN;
|
||||
|
||||
panStart.set( event.clientX, event.clientY );
|
||||
|
||||
}
|
||||
|
||||
document.addEventListener( 'mousemove', onMouseMove, false );
|
||||
document.addEventListener( 'mouseup', onMouseUp, false );
|
||||
|
||||
}
|
||||
|
||||
function onMouseMove( event ) {
|
||||
|
||||
if ( scope.enabled === false ) { return; }
|
||||
|
||||
event.preventDefault();
|
||||
|
||||
if ( state === STATE.ROTATE ) {
|
||||
if ( scope.noRotate === true ) { return; }
|
||||
|
||||
rotateEnd.set( event.clientX, event.clientY );
|
||||
rotateDelta.subVectors( rotateEnd, rotateStart );
|
||||
|
||||
// rotating across whole screen goes 360 degrees around
|
||||
scope.rotateLeft( 2 * Math.PI * rotateDelta.x / scope.domElement.width * scope.rotateSpeed );
|
||||
// rotating up and down along whole screen attempts to go 360, but limited to 180
|
||||
scope.rotateUp( 2 * Math.PI * rotateDelta.y / scope.domElement.height * scope.rotateSpeed );
|
||||
|
||||
rotateStart.copy( rotateEnd );
|
||||
|
||||
} else if ( state === STATE.DOLLY ) {
|
||||
if ( scope.noZoom === true ) { return; }
|
||||
|
||||
dollyEnd.set( event.clientX, event.clientY );
|
||||
dollyDelta.subVectors( dollyEnd, dollyStart );
|
||||
|
||||
if ( dollyDelta.y > 0 ) {
|
||||
|
||||
scope.dollyIn();
|
||||
|
||||
} else {
|
||||
|
||||
scope.dollyOut();
|
||||
|
||||
}
|
||||
|
||||
dollyStart.copy( dollyEnd );
|
||||
|
||||
} else if ( state === STATE.PAN ) {
|
||||
if ( scope.noPan === true ) { return; }
|
||||
|
||||
panEnd.set( event.clientX, event.clientY );
|
||||
panDelta.subVectors( panEnd, panStart );
|
||||
|
||||
scope.pan( panDelta );
|
||||
|
||||
panStart.copy( panEnd );
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function onMouseUp( /* event */ ) {
|
||||
|
||||
if ( scope.enabled === false ) { return; }
|
||||
|
||||
document.removeEventListener( 'mousemove', onMouseMove, false );
|
||||
document.removeEventListener( 'mouseup', onMouseUp, false );
|
||||
|
||||
state = STATE.NONE;
|
||||
|
||||
}
|
||||
|
||||
function onMouseWheel( event ) {
|
||||
// this is needed when the program is inside an iframe
|
||||
// to prevent scrolling the whole page
|
||||
event.preventDefault();
|
||||
if ( scope.enabled === false ) { return; }
|
||||
if ( scope.noZoom === true ) { return; }
|
||||
|
||||
var delta = 0;
|
||||
|
||||
if ( event.wheelDelta ) { // WebKit / Opera / Explorer 9
|
||||
|
||||
delta = event.wheelDelta;
|
||||
|
||||
} else if ( event.detail ) { // Firefox
|
||||
|
||||
delta = - event.detail;
|
||||
|
||||
}
|
||||
|
||||
if ( delta > 0 ) {
|
||||
|
||||
scope.dollyOut();
|
||||
|
||||
} else {
|
||||
|
||||
scope.dollyIn();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function onKeyDown( event ) {
|
||||
|
||||
if ( scope.enabled === false ) { return; }
|
||||
if ( scope.noKeys === true ) { return; }
|
||||
if ( scope.noPan === true ) { return; }
|
||||
|
||||
// pan a pixel - I guess for precise positioning?
|
||||
switch ( event.keyCode ) {
|
||||
|
||||
case scope.keys.UP:
|
||||
scope.pan( new THREE.Vector2( 0, 1 ) );
|
||||
break;
|
||||
case scope.keys.BOTTOM:
|
||||
scope.pan( new THREE.Vector2( 0, -1 ) );
|
||||
break;
|
||||
case scope.keys.LEFT:
|
||||
scope.pan( new THREE.Vector2( 1, 0 ) );
|
||||
break;
|
||||
case scope.keys.RIGHT:
|
||||
scope.pan( new THREE.Vector2( -1, 0 ) );
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function touchstart( event ) {
|
||||
|
||||
if ( scope.enabled === false ) { return; }
|
||||
|
||||
switch ( event.touches.length ) {
|
||||
|
||||
case 1: // one-fingered touch: rotate
|
||||
if ( scope.noRotate === true ) { return; }
|
||||
|
||||
state = STATE.TOUCH_ROTATE;
|
||||
|
||||
rotateStart.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
|
||||
break;
|
||||
|
||||
case 2: // two-fingered touch: dolly
|
||||
if ( scope.noZoom === true ) { return; }
|
||||
|
||||
state = STATE.TOUCH_DOLLY;
|
||||
|
||||
var dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX;
|
||||
var dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY;
|
||||
var distance = Math.sqrt( dx * dx + dy * dy );
|
||||
dollyStart.set( 0, distance );
|
||||
break;
|
||||
|
||||
case 3: // three-fingered touch: pan
|
||||
if ( scope.noPan === true ) { return; }
|
||||
|
||||
state = STATE.TOUCH_PAN;
|
||||
|
||||
panStart.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
|
||||
break;
|
||||
|
||||
default:
|
||||
state = STATE.NONE;
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function touchmove( event ) {
|
||||
|
||||
if ( scope.enabled === false ) { return; }
|
||||
|
||||
event.preventDefault();
|
||||
event.stopPropagation();
|
||||
|
||||
switch ( event.touches.length ) {
|
||||
|
||||
case 1: // one-fingered touch: rotate
|
||||
if ( scope.noRotate === true ) { return; }
|
||||
if ( state !== STATE.TOUCH_ROTATE ) { return; }
|
||||
|
||||
rotateEnd.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
|
||||
rotateDelta.subVectors( rotateEnd, rotateStart );
|
||||
|
||||
// rotating across whole screen goes 360 degrees around
|
||||
scope.rotateLeft( 2 * Math.PI * rotateDelta.x / scope.domElement.width * scope.rotateSpeed );
|
||||
// rotating up and down along whole screen attempts to go 360, but limited to 180
|
||||
scope.rotateUp( 2 * Math.PI * rotateDelta.y / scope.domElement.height * scope.rotateSpeed );
|
||||
|
||||
rotateStart.copy( rotateEnd );
|
||||
break;
|
||||
|
||||
case 2: // two-fingered touch: dolly
|
||||
if ( scope.noZoom === true ) { return; }
|
||||
if ( state !== STATE.TOUCH_DOLLY ) { return; }
|
||||
|
||||
var dx = event.touches[ 0 ].pageX - event.touches[ 1 ].pageX;
|
||||
var dy = event.touches[ 0 ].pageY - event.touches[ 1 ].pageY;
|
||||
var distance = Math.sqrt( dx * dx + dy * dy );
|
||||
|
||||
dollyEnd.set( 0, distance );
|
||||
dollyDelta.subVectors( dollyEnd, dollyStart );
|
||||
|
||||
if ( dollyDelta.y > 0 ) {
|
||||
|
||||
scope.dollyOut();
|
||||
|
||||
} else {
|
||||
|
||||
scope.dollyIn();
|
||||
|
||||
}
|
||||
|
||||
dollyStart.copy( dollyEnd );
|
||||
break;
|
||||
|
||||
case 3: // three-fingered touch: pan
|
||||
if ( scope.noPan === true ) { return; }
|
||||
if ( state !== STATE.TOUCH_PAN ) { return; }
|
||||
|
||||
panEnd.set( event.touches[ 0 ].pageX, event.touches[ 0 ].pageY );
|
||||
panDelta.subVectors( panEnd, panStart );
|
||||
|
||||
scope.pan( panDelta );
|
||||
|
||||
panStart.copy( panEnd );
|
||||
break;
|
||||
|
||||
default:
|
||||
state = STATE.NONE;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
function touchend( /* event */ ) {
|
||||
|
||||
if ( scope.enabled === false ) { return; }
|
||||
|
||||
state = STATE.NONE;
|
||||
}
|
||||
|
||||
this.domElement.addEventListener( 'contextmenu', function ( event ) { event.preventDefault(); }, false );
|
||||
this.domElement.addEventListener( 'mousedown', onMouseDown, false );
|
||||
this.domElement.addEventListener( 'mousewheel', onMouseWheel, false );
|
||||
this.domElement.addEventListener( 'DOMMouseScroll', onMouseWheel, false ); // firefox
|
||||
|
||||
this.domElement.addEventListener( 'keydown', onKeyDown, false );
|
||||
|
||||
this.domElement.addEventListener( 'touchstart', touchstart, false );
|
||||
this.domElement.addEventListener( 'touchend', touchend, false );
|
||||
this.domElement.addEventListener( 'touchmove', touchmove, false );
|
||||
|
||||
};
|
@ -1,50 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
var ajax_handler = function () {
|
||||
var api = this;
|
||||
api.response = "v";
|
||||
api.ajaxRequest = function (url, type, data, dataType, callback) {
|
||||
var response;
|
||||
$.ajax({
|
||||
url: url,
|
||||
type: type,
|
||||
dataType: dataType,
|
||||
success: function (data, success) {
|
||||
api.response = data;
|
||||
console.log(" success " + JSON.stringify(success));
|
||||
console.log(" data " + JSON.stringify(data));
|
||||
callback(data, success);
|
||||
},
|
||||
error: function (jqxhr, textStatus, error) {
|
||||
var err = textStatus + ', ' + error;
|
||||
console.log("Request Failed: " + err);
|
||||
callback(data, error);
|
||||
api.response = data;
|
||||
},
|
||||
data: data
|
||||
});
|
||||
return api.response;
|
||||
};
|
||||
api.makeJSONObject = function () {
|
||||
var object = {};
|
||||
for (var i = 0; i < arguments.length - 1; i = i + 2) {
|
||||
object[arguments[i]] = arguments[i + 1];
|
||||
}
|
||||
return object;
|
||||
}
|
||||
};
|
@ -1,101 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
$('.btn-minimize').click(function (e) {
|
||||
e.preventDefault();
|
||||
var $target = $(this).parent().parent().next('.box-content');
|
||||
if ($target.is(':visible')) {
|
||||
$('i', $(this)).removeClass('glyphicon-chevron-up').addClass('glyphicon-chevron-down');
|
||||
checkAndDisable($(this).parent().attr('id'));
|
||||
|
||||
}
|
||||
else {
|
||||
$('i', $(this)).removeClass('glyphicon-chevron-down').addClass('glyphicon-chevron-up');
|
||||
checkAndEnable($(this).parent().attr('id'));
|
||||
}
|
||||
$target.slideToggle();
|
||||
});
|
||||
|
||||
function checkAndEnable(id) {
|
||||
|
||||
//console.log("enable: " + id);
|
||||
if (id === "RealtimePlotting") {
|
||||
config_api.modules_status.realtimePlotting = true;
|
||||
}
|
||||
else if (id === "SensorReadings") {
|
||||
config_api.modules_status.sensorReadings = true;
|
||||
} else if (id === "AngleOfRotation_2") {
|
||||
config_api.modules_status.angleOfRotation_2 = true;
|
||||
} else if (id === "AngleOfRotation_1") {
|
||||
config_api.modules_status.angleOfRotation_1 = true;
|
||||
}
|
||||
}
|
||||
|
||||
function checkAndDisable(id) {
|
||||
//console.log("disable: " + id);
|
||||
if (id === "RealtimePlotting") {
|
||||
config_api.modules_status.realtimePlotting = false;
|
||||
}
|
||||
else if (id === "SensorReadings") {
|
||||
config_api.modules_status.sensorReadings = false;
|
||||
} else if (id === "AngleOfRotation_2") {
|
||||
config_api.modules_status.angleOfRotation_2 = false;
|
||||
} else if (id === "AngleOfRotation_1") {
|
||||
config_api.modules_status.angleOfRotation_1 = false;
|
||||
}
|
||||
}
|
||||
|
||||
function isJSON(data) {
|
||||
try {
|
||||
return JSON.parse(data);
|
||||
}
|
||||
catch (error) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
function Queue() {
|
||||
var a = [], b = '';
|
||||
this.enqueue = function (b) {
|
||||
a.push([this.getLength() - 1 <= 0 ? 0 : this.getLength() - 1, b]);
|
||||
};
|
||||
this.dequeue = function () {
|
||||
if (0 != a.length) {
|
||||
var c = a[b];
|
||||
2 * ++b >= a.length && (a = a.slice(b), b = 0);
|
||||
return c
|
||||
}
|
||||
};
|
||||
this.getLength = function () {
|
||||
return a.length - b;
|
||||
};
|
||||
this.isEmpty = function () {
|
||||
return 0 == a.length;
|
||||
};
|
||||
|
||||
this.peek = function () {
|
||||
return 0 < a.length ? a[b] : void 0
|
||||
};
|
||||
this.getData = function () {
|
||||
return a;
|
||||
};
|
||||
this.make_fixed_size = function (start, end) {
|
||||
a = a.slice(start, end);
|
||||
}
|
||||
}
|
||||
|
@ -1,60 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
|
||||
var webSocket_api = function () {
|
||||
var api = this;
|
||||
api.wekSocket;
|
||||
api.message = function (holder) {
|
||||
return $("#" + holder + "");
|
||||
},
|
||||
api.openSocket = function (url, callback) {
|
||||
if (api.wekSocket !== undefined && api.wekSocket.readyState !== WebSocket.CLOSED) {
|
||||
console.log("WebSocket is already opened.");
|
||||
|
||||
} else {
|
||||
api.wekSocket = new WebSocket(url);
|
||||
}
|
||||
api.wekSocket.onopen = function (event) {
|
||||
if (event.data === undefined)
|
||||
return;
|
||||
api.writeResponse(event.data);
|
||||
callback(event.data);
|
||||
};
|
||||
api.wekSocket.onmessage = function (event) {
|
||||
api.writeResponse(event.data);
|
||||
};
|
||||
|
||||
api.wekSocket.onclose = function (event) {
|
||||
api.writeResponse(event.data);
|
||||
};
|
||||
},
|
||||
api.send = function (message) {
|
||||
api.wekSocket.send(message);
|
||||
},
|
||||
|
||||
api.closeSocket = function () {
|
||||
api.wekSocket.close();
|
||||
},
|
||||
|
||||
api.writeResponse = function (arg) {
|
||||
console.log(arg);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1,37 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
var config_api = function () {
|
||||
var config_api = this;
|
||||
var context_controller = "/drone_analyzer/controller/send_command";
|
||||
config_api.config_3dobject_holder = "#virtualDrone";
|
||||
config_api.realtime_plotting_update_interval = 30;
|
||||
config_api.realtime_plotting_totalPoints = 30;
|
||||
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.drone_control = context_controller;
|
||||
config_api.drone_controlType = "POST";
|
||||
config_api.drone_controlDataType = "json";
|
||||
config_api.web_socket_endpoint = "/drone_analyzer/datastream/drone_status";
|
||||
config_api.modules_status = {
|
||||
"realtimePlotting": false,
|
||||
"sensorReadings": false,
|
||||
"angleOfRotation_2": false,
|
||||
"angleOfRotation_1": false
|
||||
};
|
||||
};
|
@ -1,174 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
var modalPopup = ".wr-modalpopup";
|
||||
var modalPopupContainer = modalPopup + " .modalpopup-container";
|
||||
var modalPopupContent = modalPopup + " .modalpopup-content";
|
||||
var body = "body";
|
||||
|
||||
/*
|
||||
* set popup maximum height function.
|
||||
*/
|
||||
function setPopupMaxHeight() {
|
||||
$(modalPopupContent).css('max-height', ($(body).height() - ($(body).height() / 100 * 30)));
|
||||
$(modalPopupContainer).css('margin-top', (-($(modalPopupContainer).height() / 2)));
|
||||
}
|
||||
|
||||
/*
|
||||
* show popup function.
|
||||
*/
|
||||
function showPopup() {
|
||||
$(modalPopup).show();
|
||||
setPopupMaxHeight();
|
||||
$('#downloadForm').validate({
|
||||
rules: {
|
||||
deviceName: {
|
||||
minlength: 4,
|
||||
required: true
|
||||
}
|
||||
},
|
||||
highlight: function (element) {
|
||||
$(element).closest('.control-group').removeClass('success').addClass('error');
|
||||
},
|
||||
success: function (element) {
|
||||
$(element).closest('.control-group').removeClass('error').addClass('success');
|
||||
$('label[for=deviceName]').remove();
|
||||
}
|
||||
});
|
||||
var deviceType = "";
|
||||
$('.deviceType').each(function () {
|
||||
if (this.value != "") {
|
||||
deviceType = this.value;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/*
|
||||
* hide popup function.
|
||||
*/
|
||||
function hidePopup() {
|
||||
$('label[for=deviceName]').remove();
|
||||
$('.control-group').removeClass('success').removeClass('error');
|
||||
$(modalPopupContent).html('');
|
||||
$(modalPopup).hide();
|
||||
}
|
||||
|
||||
/*
|
||||
* DOM ready functions.
|
||||
*/
|
||||
$(document).ready(function () {
|
||||
attachEvents();
|
||||
});
|
||||
|
||||
function attachEvents() {
|
||||
/**
|
||||
* Following click function would execute
|
||||
* when a user clicks on "Download" link
|
||||
* on Device Management page in WSO2 DC Console.
|
||||
*/
|
||||
$("a.download-link").click(function () {
|
||||
var sketchType = $(this).data("sketchtype");
|
||||
var deviceType = $(this).data("devicetype");
|
||||
var downloadDeviceAPI = "/devicemgt/api/devices/sketch/generate_link";
|
||||
var payload = {"sketchType": sketchType, "deviceType": deviceType};
|
||||
$(modalPopupContent).html($('#download-device-modal-content').html());
|
||||
showPopup();
|
||||
var deviceName;
|
||||
$("a#download-device-download-link").click(function () {
|
||||
$('.new-device-name').each(function () {
|
||||
if (this.value != "") {
|
||||
deviceName = this.value;
|
||||
}
|
||||
});
|
||||
$('label[for=deviceName]').remove();
|
||||
if (deviceName && deviceName.length >= 4) {
|
||||
payload.deviceName = deviceName;
|
||||
invokerUtil.post(
|
||||
downloadDeviceAPI,
|
||||
payload,
|
||||
function (data, textStatus, jqxhr) {
|
||||
doAction(data);
|
||||
},
|
||||
function (data) {
|
||||
doAction(data);
|
||||
}
|
||||
);
|
||||
}else if(deviceName){
|
||||
$('.controls').append('<label for="deviceName" generated="true" class="error" style="display: inline-block;">Please enter at least 4 characters.</label>');
|
||||
$('.control-group').removeClass('success').addClass('error');
|
||||
} else {
|
||||
$('.controls').append('<label for="deviceName" generated="true" class="error" style="display: inline-block;">This field is required.</label>');
|
||||
$('.control-group').removeClass('success').addClass('error');
|
||||
}
|
||||
});
|
||||
|
||||
$("a#download-device-cancel-link").click(function () {
|
||||
hidePopup();
|
||||
});
|
||||
|
||||
});
|
||||
}
|
||||
|
||||
function downloadAgent() {
|
||||
$('#downloadForm').submit();
|
||||
|
||||
var deviceName;
|
||||
$('.new-device-name').each(function () {
|
||||
if (this.value != "") {
|
||||
deviceName = this.value;
|
||||
}
|
||||
});
|
||||
if (deviceName && deviceName.length >= 4) {
|
||||
setTimeout(function () {
|
||||
hidePopup();
|
||||
}, 1000);
|
||||
}
|
||||
}
|
||||
|
||||
function doAction(data) {
|
||||
//if it is saml redirection response
|
||||
if (data.status == null) {
|
||||
document.write(data);
|
||||
}
|
||||
|
||||
if (data.status == "200") {
|
||||
$(modalPopupContent).html($('#download-device-modal-content-links').html());
|
||||
$("input#download-device-url").val(data.responseText);
|
||||
$("input#download-device-url").focus(function () {
|
||||
$(this).select();
|
||||
});
|
||||
showPopup();
|
||||
} else if (data.status == "401") {
|
||||
$(modalPopupContent).html($('#device-401-content').html());
|
||||
$("#device-401-link").click(function () {
|
||||
window.location = "/devicemgt/login";
|
||||
});
|
||||
showPopup();
|
||||
} else if (data == "403") {
|
||||
$(modalPopupContent).html($('#device-403-content').html());
|
||||
$("#device-403-link").click(function () {
|
||||
window.location = "/devicemgt/login";
|
||||
});
|
||||
showPopup();
|
||||
} else {
|
||||
$(modalPopupContent).html($('#device-unexpected-error-content').html());
|
||||
$("a#device-unexpected-error-link").click(function () {
|
||||
hidePopup();
|
||||
});
|
||||
}
|
||||
}
|
@ -1,21 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
var ajax_handler = new ajax_handler();
|
||||
var config_api = new config_api();
|
||||
var plotting = new plotting();
|
||||
var object_maker = new object_maker();
|
@ -1,357 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
// VERSION: 2.3 LAST UPDATE: 11.07.2013
|
||||
/*
|
||||
* Licensed under the MIT license: http://www.opensource.org/licenses/mit-license.php
|
||||
*
|
||||
* Made by Wilq32, wilq32@gmail.com, Wroclaw, Poland, 01.2009
|
||||
* Website: http://jqueryrotate.com
|
||||
*/
|
||||
|
||||
(function($) {
|
||||
var supportedCSS,supportedCSSOrigin, styles=document.getElementsByTagName("head")[0].style,toCheck="transformProperty WebkitTransform OTransform msTransform MozTransform".split(" ");
|
||||
for (var a = 0; a < toCheck.length; a++) if (styles[toCheck[a]] !== undefined) { supportedCSS = toCheck[a]; }
|
||||
if (supportedCSS) {
|
||||
supportedCSSOrigin = supportedCSS.replace(/[tT]ransform/,"TransformOrigin");
|
||||
if (supportedCSSOrigin[0] == "T") supportedCSSOrigin[0] = "t";
|
||||
}
|
||||
|
||||
// Bad eval to preven google closure to remove it from code o_O
|
||||
eval('IE = "v"=="\v"');
|
||||
|
||||
jQuery.fn.extend({
|
||||
rotate:function(parameters)
|
||||
{
|
||||
if (this.length===0||typeof parameters=="undefined") return;
|
||||
if (typeof parameters=="number") parameters={angle:parameters};
|
||||
var returned=[];
|
||||
for (var i=0,i0=this.length;i<i0;i++)
|
||||
{
|
||||
var element=this.get(i);
|
||||
if (!element.Wilq32 || !element.Wilq32.PhotoEffect) {
|
||||
|
||||
var paramClone = $.extend(true, {}, parameters);
|
||||
var newRotObject = new Wilq32.PhotoEffect(element,paramClone)._rootObj;
|
||||
|
||||
returned.push($(newRotObject));
|
||||
}
|
||||
else {
|
||||
element.Wilq32.PhotoEffect._handleRotation(parameters);
|
||||
}
|
||||
}
|
||||
return returned;
|
||||
},
|
||||
getRotateAngle: function(){
|
||||
var ret = [];
|
||||
for (var i=0,i0=this.length;i<i0;i++)
|
||||
{
|
||||
var element=this.get(i);
|
||||
if (element.Wilq32 && element.Wilq32.PhotoEffect) {
|
||||
ret[i] = element.Wilq32.PhotoEffect._angle;
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
},
|
||||
stopRotate: function(){
|
||||
for (var i=0,i0=this.length;i<i0;i++)
|
||||
{
|
||||
var element=this.get(i);
|
||||
if (element.Wilq32 && element.Wilq32.PhotoEffect) {
|
||||
clearTimeout(element.Wilq32.PhotoEffect._timer);
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
// Library agnostic interface
|
||||
|
||||
Wilq32=window.Wilq32||{};
|
||||
Wilq32.PhotoEffect=(function(){
|
||||
|
||||
if (supportedCSS) {
|
||||
return function(img,parameters){
|
||||
img.Wilq32 = {
|
||||
PhotoEffect: this
|
||||
};
|
||||
|
||||
this._img = this._rootObj = this._eventObj = img;
|
||||
this._handleRotation(parameters);
|
||||
}
|
||||
} else {
|
||||
return function(img,parameters) {
|
||||
this._img = img;
|
||||
this._onLoadDelegate = [parameters];
|
||||
|
||||
this._rootObj=document.createElement('span');
|
||||
this._rootObj.style.display="inline-block";
|
||||
this._rootObj.Wilq32 =
|
||||
{
|
||||
PhotoEffect: this
|
||||
};
|
||||
img.parentNode.insertBefore(this._rootObj,img);
|
||||
|
||||
if (img.complete) {
|
||||
this._Loader();
|
||||
} else {
|
||||
var self=this;
|
||||
// TODO: Remove jQuery dependency
|
||||
jQuery(this._img).bind("load", function(){ self._Loader(); });
|
||||
}
|
||||
}
|
||||
}
|
||||
})();
|
||||
|
||||
Wilq32.PhotoEffect.prototype = {
|
||||
_setupParameters : function (parameters){
|
||||
this._parameters = this._parameters || {};
|
||||
if (typeof this._angle !== "number") { this._angle = 0 ; }
|
||||
if (typeof parameters.angle==="number") { this._angle = parameters.angle; }
|
||||
this._parameters.animateTo = (typeof parameters.animateTo === "number") ? (parameters.animateTo) : (this._angle);
|
||||
|
||||
this._parameters.step = parameters.step || this._parameters.step || null;
|
||||
this._parameters.easing = parameters.easing || this._parameters.easing || this._defaultEasing;
|
||||
this._parameters.duration = 'duration' in parameters ? parameters.duration : parameters.duration || this._parameters.duration || 1000;
|
||||
this._parameters.callback = parameters.callback || this._parameters.callback || this._emptyFunction;
|
||||
this._parameters.center = parameters.center || this._parameters.center || ["50%","50%"];
|
||||
if (typeof this._parameters.center[0] == "string") {
|
||||
this._rotationCenterX = (parseInt(this._parameters.center[0],10) / 100) * this._imgWidth * this._aspectW;
|
||||
} else {
|
||||
this._rotationCenterX = this._parameters.center[0];
|
||||
}
|
||||
if (typeof this._parameters.center[1] == "string") {
|
||||
this._rotationCenterY = (parseInt(this._parameters.center[1],10) / 100) * this._imgHeight * this._aspectH;
|
||||
} else {
|
||||
this._rotationCenterY = this._parameters.center[1];
|
||||
}
|
||||
|
||||
if (parameters.bind && parameters.bind != this._parameters.bind) { this._BindEvents(parameters.bind); }
|
||||
},
|
||||
_emptyFunction: function(){},
|
||||
_defaultEasing: function (x, t, b, c, d) { return -c * ((t=t/d-1)*t*t*t - 1) + b },
|
||||
_handleRotation : function(parameters, dontcheck){
|
||||
if (!supportedCSS && !this._img.complete && !dontcheck) {
|
||||
this._onLoadDelegate.push(parameters);
|
||||
return;
|
||||
}
|
||||
this._setupParameters(parameters);
|
||||
if (this._angle==this._parameters.animateTo) {
|
||||
this._rotate(this._angle);
|
||||
}
|
||||
else {
|
||||
this._animateStart();
|
||||
}
|
||||
},
|
||||
|
||||
_BindEvents:function(events){
|
||||
if (events && this._eventObj)
|
||||
{
|
||||
// Unbinding previous Events
|
||||
if (this._parameters.bind){
|
||||
var oldEvents = this._parameters.bind;
|
||||
for (var a in oldEvents) if (oldEvents.hasOwnProperty(a))
|
||||
// TODO: Remove jQuery dependency
|
||||
jQuery(this._eventObj).unbind(a,oldEvents[a]);
|
||||
}
|
||||
|
||||
this._parameters.bind = events;
|
||||
for (var a in events) if (events.hasOwnProperty(a))
|
||||
// TODO: Remove jQuery dependency
|
||||
jQuery(this._eventObj).bind(a,events[a]);
|
||||
}
|
||||
},
|
||||
|
||||
_Loader:(function()
|
||||
{
|
||||
if (IE)
|
||||
return function() {
|
||||
var width=this._img.width;
|
||||
var height=this._img.height;
|
||||
this._imgWidth = width;
|
||||
this._imgHeight = height;
|
||||
this._img.parentNode.removeChild(this._img);
|
||||
|
||||
this._vimage = this.createVMLNode('image');
|
||||
this._vimage.src=this._img.src;
|
||||
this._vimage.style.height=height+"px";
|
||||
this._vimage.style.width=width+"px";
|
||||
this._vimage.style.position="absolute"; // FIXES IE PROBLEM - its only rendered if its on absolute position!
|
||||
this._vimage.style.top = "0px";
|
||||
this._vimage.style.left = "0px";
|
||||
this._aspectW = this._aspectH = 1;
|
||||
|
||||
/* Group minifying a small 1px precision problem when rotating object */
|
||||
this._container = this.createVMLNode('group');
|
||||
this._container.style.width=width;
|
||||
this._container.style.height=height;
|
||||
this._container.style.position="absolute";
|
||||
this._container.style.top="0px";
|
||||
this._container.style.left="0px";
|
||||
this._container.setAttribute('coordsize',width-1+','+(height-1)); // This -1, -1 trying to fix ugly problem with small displacement on IE
|
||||
this._container.appendChild(this._vimage);
|
||||
|
||||
this._rootObj.appendChild(this._container);
|
||||
this._rootObj.style.position="relative"; // FIXES IE PROBLEM
|
||||
this._rootObj.style.width=width+"px";
|
||||
this._rootObj.style.height=height+"px";
|
||||
this._rootObj.setAttribute('id',this._img.getAttribute('id'));
|
||||
this._rootObj.className=this._img.className;
|
||||
this._eventObj = this._rootObj;
|
||||
var parameters;
|
||||
while (parameters = this._onLoadDelegate.shift()) {
|
||||
this._handleRotation(parameters, true);
|
||||
}
|
||||
}
|
||||
else return function () {
|
||||
this._rootObj.setAttribute('id',this._img.getAttribute('id'));
|
||||
this._rootObj.className=this._img.className;
|
||||
|
||||
this._imgWidth=this._img.naturalWidth;
|
||||
this._imgHeight=this._img.naturalHeight;
|
||||
var _widthMax=Math.sqrt((this._imgHeight)*(this._imgHeight) + (this._imgWidth) * (this._imgWidth));
|
||||
this._width = _widthMax * 3;
|
||||
this._height = _widthMax * 3;
|
||||
|
||||
this._aspectW = this._img.offsetWidth/this._img.naturalWidth;
|
||||
this._aspectH = this._img.offsetHeight/this._img.naturalHeight;
|
||||
|
||||
this._img.parentNode.removeChild(this._img);
|
||||
|
||||
|
||||
this._canvas=document.createElement('canvas');
|
||||
this._canvas.setAttribute('width',this._width);
|
||||
this._canvas.style.position="relative";
|
||||
this._canvas.style.left = -this._img.height * this._aspectW + "px";
|
||||
this._canvas.style.top = -this._img.width * this._aspectH + "px";
|
||||
this._canvas.Wilq32 = this._rootObj.Wilq32;
|
||||
|
||||
this._rootObj.appendChild(this._canvas);
|
||||
this._rootObj.style.width=this._img.width*this._aspectW+"px";
|
||||
this._rootObj.style.height=this._img.height*this._aspectH+"px";
|
||||
this._eventObj = this._canvas;
|
||||
|
||||
this._cnv=this._canvas.getContext('2d');
|
||||
var parameters;
|
||||
while (parameters = this._onLoadDelegate.shift()) {
|
||||
this._handleRotation(parameters, true);
|
||||
}
|
||||
}
|
||||
})(),
|
||||
|
||||
_animateStart:function()
|
||||
{
|
||||
if (this._timer) {
|
||||
clearTimeout(this._timer);
|
||||
}
|
||||
this._animateStartTime = +new Date;
|
||||
this._animateStartAngle = this._angle;
|
||||
this._animate();
|
||||
},
|
||||
_animate:function()
|
||||
{
|
||||
var actualTime = +new Date;
|
||||
var checkEnd = actualTime - this._animateStartTime > this._parameters.duration;
|
||||
|
||||
// TODO: Bug for animatedGif for static rotation ? (to test)
|
||||
if (checkEnd && !this._parameters.animatedGif)
|
||||
{
|
||||
clearTimeout(this._timer);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (this._canvas||this._vimage||this._img) {
|
||||
var angle = this._parameters.easing(0, actualTime - this._animateStartTime, this._animateStartAngle, this._parameters.animateTo - this._animateStartAngle, this._parameters.duration);
|
||||
this._rotate((~~(angle*10))/10);
|
||||
}
|
||||
if (this._parameters.step) {
|
||||
this._parameters.step(this._angle);
|
||||
}
|
||||
var self = this;
|
||||
this._timer = setTimeout(function()
|
||||
{
|
||||
self._animate.call(self);
|
||||
}, 10);
|
||||
}
|
||||
|
||||
// To fix Bug that prevents using recursive function in callback I moved this function to back
|
||||
if (this._parameters.callback && checkEnd){
|
||||
this._angle = this._parameters.animateTo;
|
||||
this._rotate(this._angle);
|
||||
this._parameters.callback.call(this._rootObj);
|
||||
}
|
||||
},
|
||||
|
||||
_rotate : (function()
|
||||
{
|
||||
var rad = Math.PI/180;
|
||||
if (IE)
|
||||
return function(angle)
|
||||
{
|
||||
this._angle = angle;
|
||||
this._container.style.rotation=(angle%360)+"deg";
|
||||
this._vimage.style.top = -(this._rotationCenterY - this._imgHeight/2) + "px";
|
||||
this._vimage.style.left = -(this._rotationCenterX - this._imgWidth/2) + "px";
|
||||
this._container.style.top = this._rotationCenterY - this._imgHeight/2 + "px";
|
||||
this._container.style.left = this._rotationCenterX - this._imgWidth/2 + "px";
|
||||
|
||||
}
|
||||
else if (supportedCSS)
|
||||
return function(angle){
|
||||
this._angle = angle;
|
||||
this._img.style[supportedCSS]="rotate("+(angle%360)+"deg)";
|
||||
this._img.style[supportedCSSOrigin]=this._parameters.center.join(" ");
|
||||
}
|
||||
else
|
||||
return function(angle)
|
||||
{
|
||||
this._angle = angle;
|
||||
angle=(angle%360)* rad;
|
||||
// clear canvas
|
||||
this._canvas.width = this._width;//+this._widthAdd;
|
||||
this._canvas.height = this._height;//+this._heightAdd;
|
||||
|
||||
// REMEMBER: all drawings are read from backwards.. so first function is translate, then rotate, then translate, translate..
|
||||
this._cnv.translate(this._imgWidth*this._aspectW,this._imgHeight*this._aspectH); // at least center image on screen
|
||||
this._cnv.translate(this._rotationCenterX,this._rotationCenterY); // we move image back to its orginal
|
||||
this._cnv.rotate(angle); // rotate image
|
||||
this._cnv.translate(-this._rotationCenterX,-this._rotationCenterY); // move image to its center, so we can rotate around its center
|
||||
this._cnv.scale(this._aspectW,this._aspectH); // SCALE - if needed ;)
|
||||
this._cnv.drawImage(this._img, 0, 0); // First - we draw image
|
||||
}
|
||||
|
||||
})()
|
||||
}
|
||||
|
||||
if (IE)
|
||||
{
|
||||
Wilq32.PhotoEffect.prototype.createVMLNode=(function(){
|
||||
document.createStyleSheet().addRule(".rvml", "behavior:url(#default#VML)");
|
||||
try {
|
||||
!document.namespaces.rvml && document.namespaces.add("rvml", "urn:schemas-microsoft-com:vml");
|
||||
return function (tagName) {
|
||||
return document.createElement('<rvml:' + tagName + ' class="rvml">');
|
||||
};
|
||||
} catch (e) {
|
||||
return function (tagName) {
|
||||
return document.createElement('<' + tagName + ' xmlns="urn:schemas-microsoft.com:vml" class="rvml">');
|
||||
};
|
||||
}
|
||||
})();
|
||||
}
|
||||
|
||||
})(jQuery);
|
@ -1,153 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
object_maker.init(config_api.config_3dobject_holder, $("#objectHolder").width(), $("#objectHolder").width()/1.5);
|
||||
object_maker.animate();
|
||||
var flight_dynamics = new flight_dynamics();
|
||||
$("#window_size").slider({
|
||||
range: "min",
|
||||
value: 37,
|
||||
min: 10,
|
||||
max: 300,
|
||||
slide: function (event, ui) {
|
||||
$("#window_size_current_value").html($("#window_size").slider("value"));
|
||||
|
||||
}
|
||||
});
|
||||
$("#window_update").slider({
|
||||
range: "min",
|
||||
value: 234,
|
||||
min: 100,
|
||||
max: 1000,
|
||||
slide: function (event, ui) {
|
||||
$("#window_update_value").html($("#window_update").slider("value"));
|
||||
}
|
||||
});
|
||||
$("#replotting").click(function () {
|
||||
plotting.finishPlotting(function (status) {
|
||||
if (status) {
|
||||
plotting.initPlotting(function (status) {
|
||||
d3.select("#realtimechart").select("svg").remove();
|
||||
plotting.realtime_plotting("#realtimechart", "#range_min", "#range_max", "#window_update_value",
|
||||
600, $("#realtimechart").height(), "#window_size_current_value",
|
||||
'#plotting_attribute');
|
||||
});
|
||||
} else {
|
||||
$("#realtimechart").html("There is no data to plot");
|
||||
}
|
||||
});
|
||||
});
|
||||
$('.btn-minimize').click(function (e) {
|
||||
e.preventDefault();
|
||||
var $target = $(this).parent().parent().next('.box-content');
|
||||
if ($target.is(':visible')) {
|
||||
if ($(this).parent().attr('id') === "RealtimePlotting") {
|
||||
plotting.forceToRedraw(function (status) {
|
||||
d3.select("#realtimechart").select("svg").remove();
|
||||
plotting.realtime_plotting("#realtimechart", "#range_min", "#range_max", "#window_update_value",
|
||||
600, $("#realtimechart").height(), "#window_size_current_value",
|
||||
'#plotting_attribute');
|
||||
});
|
||||
}
|
||||
} else {
|
||||
}
|
||||
});
|
||||
$('#connectionOpen').on('click', function () {
|
||||
$('#connectionOpen').toggleClass('active');
|
||||
});
|
||||
$("#xmppConnectionOpen").on('click', function () {
|
||||
$('#xmppConnectionOpen').toggleClass('active');
|
||||
if ($('#xmppConnectionOpen').html() === "Start") {
|
||||
sendMessage("Start the process", function(state){
|
||||
console.log("sending message to server..."+ state);
|
||||
if(state<2){
|
||||
$('#xmppConnectionOpen').html("Stop");
|
||||
}else{
|
||||
$('#xmppConnectionOpen').html("Start");
|
||||
}
|
||||
});
|
||||
|
||||
} else if ($('#xmppConnectionOpen').html() === "Stop") {
|
||||
closeSocket(function(state){
|
||||
console.log("closing WebSocket..."+ state);
|
||||
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();
|
||||
var webSocket;
|
||||
config_api.realtime_plotting_data_window["attitude"] = new Queue();
|
||||
var current_status = {};
|
||||
function openSocket(wssAddress) {
|
||||
if (webSocket !== undefined && webSocket.readyState == 1) {
|
||||
writeResponse("WebSocket is already opened.");
|
||||
} else {
|
||||
webSocket = new WebSocket(wssAddress+config_api.web_socket_endpoint);
|
||||
}
|
||||
webSocket.onopen = function (event) {
|
||||
if (event === undefined) {
|
||||
writeResponse("WebSocket cant open " + event);
|
||||
$("#connectionOpen").html("Connect to server").removeClass("btn btn-info").addClass("btn btn-primary");
|
||||
} else {
|
||||
|
||||
if (event["isTrusted"] == true) {
|
||||
$("#connectionOpen").html("Connected").removeClass("btn btn-primary").addClass("btn btn-info");
|
||||
}
|
||||
writeResponse(JSON.stringify(event));
|
||||
|
||||
}
|
||||
};
|
||||
webSocket.onmessage = function (event) {
|
||||
var sender_message = event.data;
|
||||
sender_message = isJSON(sender_message);
|
||||
if (sender_message != null) {
|
||||
flight_dynamics.processingMessage(sender_message);
|
||||
} else {
|
||||
writeResponse("Message has been corrupted.");
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function sendMessage(message, callback) {
|
||||
if(webSocket.readyState<2){
|
||||
webSocket.send(message);
|
||||
}
|
||||
callback(webSocket.readyState);
|
||||
}
|
||||
|
||||
function closeSocket(callback) {
|
||||
if(webSocket.readyState<2){
|
||||
webSocket.close();
|
||||
}
|
||||
callback(webSocket.readyState);
|
||||
}
|
||||
|
||||
function writeResponse(text) {
|
||||
console.log(text);
|
||||
}
|
||||
|
||||
window.onbeforeunload = function () {
|
||||
webSocket.close();
|
||||
};
|
||||
|
@ -1,29 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
$("#module_control button").click(function (index) {
|
||||
console.log("Asking Server to send the " + $(this).attr('id') + " command to Ar Drone");
|
||||
var url = config_api.drone_control;
|
||||
ajax_handler.ajaxRequest(url, config_api.drone_controlType, {action: $(this).attr('id'), speed: 7, duration: 7},
|
||||
config_api.drone_controlDataType, function (data, status) {
|
||||
console.log(JSON.stringify(data));
|
||||
}
|
||||
);
|
||||
});
|
||||
|
||||
|
||||
|
@ -1,77 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
|
||||
var flight_dynamics = function () {
|
||||
var api = this;
|
||||
api.processingMessage = function (sender_message) {
|
||||
if(sender_message.battery_level!= undefined){
|
||||
$("#battery_level_holder").width( parseInt(sender_message.battery_level)+"%" );
|
||||
$("#battery_level").html(sender_message.battery_level+"%");
|
||||
}
|
||||
if (sender_message.quatanium_val != undefined) {
|
||||
current_status = object_maker.get_heading_attitude_bank(sender_message.quatanium_val);
|
||||
object_maker.set_heading_attitude_bank(current_status);
|
||||
$("#imageTop").animate({rotate: '' + (180 / Math.PI) * 2.890456 + 'deg'}, 2);
|
||||
}
|
||||
if (config_api.modules_status.angleOfRotation_2 || config_api.modules_status.angleOfRotation_1) {
|
||||
console.log(JSON.stringify(current_status));
|
||||
object_maker.set_bank("#imageTop", current_status.bank);
|
||||
object_maker.set_heading("#imageBackSecond", current_status.heading);
|
||||
|
||||
}
|
||||
if (config_api.modules_status.realtimePlotting) {
|
||||
if (current_status[$('#plotting_attribute').val()] != undefined) {
|
||||
plotting.pushData(current_status[$('#plotting_attribute').val()]);
|
||||
}
|
||||
}
|
||||
if (sender_message.basicParam != undefined) {
|
||||
if (sender_message.basicParam.velocity != undefined) {
|
||||
var velocity = sender_message.basicParam.velocity;
|
||||
if (velocity.length == 3) {
|
||||
$("#velocityx").html(velocity[0]);
|
||||
$("#velocityy").html(velocity[1]);
|
||||
$("#velocityz").html(velocity[2]);
|
||||
}
|
||||
} else {
|
||||
$("#velocityx").html(NaN);
|
||||
$("#velocityy").html(NaN);
|
||||
$("#velocityz").html(NaN);
|
||||
}
|
||||
if (sender_message.basicParam.global_location != undefined) {
|
||||
var location = sender_message.basicParam.global_location;
|
||||
if (location.length == 3) {
|
||||
$("#locationLog").html(location[0]);
|
||||
$("#locationAlt").html(location[1]);
|
||||
$("#locationLat").html(location[2]);
|
||||
}
|
||||
} else {
|
||||
$("#locationLog").html(NaN);
|
||||
$("#locationAlt").html(NaN);
|
||||
$("#locationLat").html(NaN);
|
||||
}
|
||||
}
|
||||
if (sender_message.battery_voltage != undefined) {
|
||||
$("#battery_voltage").html(sender_message.battery_voltage);
|
||||
} else {
|
||||
$("#battery_voltage").html(NaN);
|
||||
}
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
|
@ -1,148 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
var plotting = function () {
|
||||
var api = this;
|
||||
api.isDone = false;
|
||||
api.current_value = 0;
|
||||
api.finishPlotting = function (callBack) {
|
||||
api.isDone = true;
|
||||
callBack(true);
|
||||
},
|
||||
api.initPlotting = function (callback) {
|
||||
api.isDone = false;
|
||||
callback(true);
|
||||
},
|
||||
api.forceToRedraw = function (callback) {
|
||||
api.isDone == true;
|
||||
callback(true);
|
||||
},
|
||||
api.pushData = function (new_value) {
|
||||
console.log(new_value);
|
||||
api.current_value = new_value;
|
||||
},
|
||||
api.realtime_plotting = function (holder, y_min_hollder, y_max_holder, update_interval_holder, holder_width,
|
||||
holder_height, window_size_holder, title) {
|
||||
$(holder).html();
|
||||
var init_window = function () {
|
||||
return 0;
|
||||
}
|
||||
api.data = d3.range(parseInt($(window_size_holder).html())).map(init_window);
|
||||
var margin = {top: 20, right: 20, bottom: 20, left: 40},
|
||||
width = holder_width - margin.left - margin.right,
|
||||
height = holder_height - margin.top - margin.bottom;
|
||||
var x = d3.scale.linear()
|
||||
.domain([1, parseInt($(window_size_holder).html()) - 2])
|
||||
.range([0, width]);
|
||||
|
||||
var y = d3.scale.linear()
|
||||
.domain([parseInt($(y_min_hollder).val()), parseInt($(y_max_holder).val())])
|
||||
.range([height, 0]);
|
||||
var line = d3.svg.line()
|
||||
.interpolate("basis")
|
||||
.x(function (d, i) {
|
||||
return x(i);
|
||||
})
|
||||
.y(function (d, i) {
|
||||
return y(d);
|
||||
});
|
||||
|
||||
var svg = d3.select(holder).append("svg")
|
||||
.attr("width", width + margin.left + margin.right)
|
||||
.attr("height", height + margin.top + margin.bottom)
|
||||
.append("g")
|
||||
.attr("transform", "translate(" + margin.left + "," + margin.top + ")");
|
||||
svg.append("defs").append("clipPath")
|
||||
.attr("id", "clip")
|
||||
.append("rect")
|
||||
.attr("width", width)
|
||||
.attr("height", height);
|
||||
var axis_x = svg.append("g")
|
||||
.attr("class", "x_axis")
|
||||
.attr("transform", "translate(0," + y(0) + ")")
|
||||
.call(d3.svg.axis().scale(x).orient("bottom"));
|
||||
var axis_y = svg.append("g")
|
||||
.attr("class", "y_axis")
|
||||
.call(d3.svg.axis().scale(y).orient("left"));
|
||||
var path = svg.append("g")
|
||||
.attr("clip-path", "url(#clip)")
|
||||
.append("path")
|
||||
.datum(api.data)
|
||||
.attr("class", "line")
|
||||
.attr("d", line);
|
||||
svg.append("text")
|
||||
.attr("class", "yaxis_label")
|
||||
.attr("transform", "rotate(-90)")
|
||||
.attr("y", 0 - margin.left - 4)
|
||||
.attr("x", (0 - (height / 2)))
|
||||
.attr("dy", "1em")
|
||||
.style("text-anchor", "middle")
|
||||
.text($(title).val());
|
||||
svg.append("text")
|
||||
.attr("class", "xaixs_label")
|
||||
.attr("transform",
|
||||
"translate(" + (width / 2) + " ," +
|
||||
(height + margin.bottom) + ")")
|
||||
.style("text-anchor", "middle")
|
||||
.text("Window Size");
|
||||
svg.append("text")
|
||||
.attr("class", "title_label")
|
||||
.attr("x", (width / 2))
|
||||
.attr("y", 0 - (margin.top / 4))
|
||||
.attr("text-anchor", "middle")
|
||||
.style("font-size", "16px")
|
||||
.style("text-decoration", "underline")
|
||||
.text($(title).val() + " variation within last " + $(window_size_holder).html() + " frames");
|
||||
|
||||
updateAgain();
|
||||
|
||||
function updateAgain() {
|
||||
if (api.isDone)return;
|
||||
api.data.push(api.current_value);
|
||||
path
|
||||
.attr("d", line)
|
||||
.attr("transform", null)
|
||||
.transition()
|
||||
.duration($(update_interval_holder).html())
|
||||
.ease("linear")
|
||||
.attr("transform", "translate(" + x(0) + ",0)")
|
||||
.each("end", updateAgain);
|
||||
api.data.shift();
|
||||
}
|
||||
|
||||
function rescale() {
|
||||
y.domain([parseInt($(y_min_hollder).val()), parseInt($(y_max_holder).val())])
|
||||
|
||||
svg.select(".title_label")
|
||||
.text($(title).val() + " variation within last " + $(window_size_holder).html() + " frames");
|
||||
svg.select(".yaxis_label")
|
||||
.text($(title).val());
|
||||
|
||||
}
|
||||
|
||||
function rescale_x() {
|
||||
x.domain([1, parseInt($(window_size_holder).html()) - 2]).range([0, width])
|
||||
svg.select(".x_axis").transition().call(axis_x);
|
||||
}
|
||||
|
||||
$("#plotting_attribute").change(function () {
|
||||
rescale();
|
||||
});
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -1,250 +0,0 @@
|
||||
{{#zone "topCss"}}
|
||||
{{css "css/main-app.css" }}
|
||||
{{/zone}}
|
||||
<div class=" row">
|
||||
<div class="box col-md-12">
|
||||
<div>
|
||||
<div class="col-md-2 col-sm-2 col-xs-1">
|
||||
<button class="btn btn-primary" data-dismiss="modal" id="connectionOpen"
|
||||
onclick="openSocket('{{wssAddress}}');">Connect to XMPP Server</button>
|
||||
</div>
|
||||
<div class="col-md-2 col-sm-2 col-xs-1">
|
||||
<button class="btn btn-primary" data-dismiss="modal" id="xmppConnectionOpen">Start</button>
|
||||
</div>
|
||||
<div class="col-md-0.5 col-sm-1 col-xs-2">
|
||||
<p>Battery Level </p>
|
||||
</div>
|
||||
<div class="col-md-4 col-sm-2 col-xs-2">
|
||||
<div class="progress">
|
||||
<div class="progress-bar" role="progressbar" aria-valuenow="60" aria-valuemin="0"
|
||||
aria-valuemax="100" style="width: 0%;" id="battery_level_holder">
|
||||
<p id="battery_level">0%</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<!-- <div class="row">
|
||||
<div class="box col-md-12">
|
||||
<div class="box-inner">
|
||||
<div class="box-header well">
|
||||
<h2><i class="glyphicon glyphicon-info-sign"></i> Controller </h2>
|
||||
|
||||
<div class="box-icon">
|
||||
<a href="#" class="btn btn-minimize btn-round btn-default"><i
|
||||
class="glyphicon glyphicon-chevron-up" ></i></a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-content row" id="module_control">
|
||||
|
||||
<div class="col-lg-1 col-md-12 hidden-xs center-text">
|
||||
<button class="btn btn-default btn-sm" id="takeoff">
|
||||
<i class="glyphicon glyphicon-play"></i> Takeoff</button>
|
||||
</div>
|
||||
<div class="col-lg-1 col-md-12 hidden-xs center-text">
|
||||
<button class="btn btn-default btn-sm" id="land">
|
||||
<i class="glyphicon glyphicon-stop"></i> Land</button>
|
||||
</div>
|
||||
<div class="col-lg-1 col-md-12 hidden-xs center-text">
|
||||
<button class="btn btn-default btn-sm" id="up">
|
||||
<i class="glyphicon glyphicon-arrow-up"></i> Up</button>
|
||||
</div>
|
||||
<div class="col-lg-1 col-md-12 hidden-xs center-text">
|
||||
<button class="btn btn-default btn-sm" id="down">
|
||||
<i class="glyphicon glyphicon-arrow-down"></i> Down</button>
|
||||
</div>
|
||||
<div class="col-lg-1 col-md-12 hidden-xs center-text">
|
||||
<button class="btn btn-default btn-sm" id="left">
|
||||
<i class="glyphicon glyphicon-arrow-left"></i> Left</button>
|
||||
</div>
|
||||
<div class="col-lg-1 col-md-12 hidden-xs center-text">
|
||||
<button class="btn btn-default btn-sm" id="right">
|
||||
<i class="glyphicon glyphicon-arrow-right"></i> Right</button>
|
||||
</div>
|
||||
<div class="col-lg-1 col-md-12 hidden-xs center-text">
|
||||
<button class="btn btn-default btn-sm" id="front">
|
||||
<i class="glyphicon glyphicon-chevron-up"></i> Front</button>
|
||||
</div>
|
||||
<div class="col-lg-1 col-md-12 hidden-xs center-text">
|
||||
<button class="btn btn-default btn-sm" id="back">
|
||||
<i class="glyphicon glyphicon-chevron-down"></i> Back</button>
|
||||
</div>
|
||||
<div class="col-lg-1 col-md-12 hidden-xs center-text">
|
||||
<button class="btn btn-default btn-sm" id="clockwise">
|
||||
<i class="glyphicon glyphicon-resize-vertical"></i> Clockwise</button>
|
||||
</div>
|
||||
<div class="col-lg-1 col-md-12 hidden-xs center-text">
|
||||
<button class="btn btn-default btn-sm" id="counter_clockwise">
|
||||
<i class="glyphicon glyphicon-resize-horizontal"></i> Conter-clockwise</button>
|
||||
</div>
|
||||
<div class="col-lg-2 col-md-12 hidden-xs center-text">
|
||||
<button class="btn btn-default btn-sm" id="stop">
|
||||
<i class="glyphicon glyphicon-ban-circle"></i> Stop</button>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>-->
|
||||
<div class="row">
|
||||
<div class="box col-md-12">
|
||||
<div class="box col-md-4">
|
||||
<div class="box-inner">
|
||||
<div class="box-header well" data-original-title="" >
|
||||
<h2><i class="glyphicon glyphicon-list"></i> Angle of Rotation</h2>
|
||||
|
||||
<div class="box-icon" id="AngleOfRotation_1">
|
||||
<a href="#" class="btn btn-minimize btn-round btn-default"><i
|
||||
class="glyphicon glyphicon-chevron-up"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-content" style="position: relative;" id="objectHolder">
|
||||
<div class="grayscale" border-radius="2" id="virtualDrone" >
|
||||
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box col-md-2">
|
||||
<div class="box-inner" style="max-height: 280px;">
|
||||
<div class="box-header well" data-original-title="" >
|
||||
|
||||
<div class="box-icon" id="AngleOfRotation_2">
|
||||
<a href="#" class="btn btn-minimize btn-round btn-default"><i
|
||||
class="glyphicon glyphicon-chevron-up"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-content" >
|
||||
<div style="position: relative;">
|
||||
|
||||
<img class="grayscale" id="imageTop"
|
||||
src="{{@unit.publicUri}}/images/drone_position_controller/direction_drone.png"
|
||||
style="width: 100%;"/>
|
||||
<img class="grayscale" id="imageBack"
|
||||
src="{{@unit.publicUri}}/images/drone_position_controller/background_drone.png"
|
||||
style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box col-md-2">
|
||||
<div class="box-inner" style="max-height: 280px;">
|
||||
<div class="box-header well" data-original-title="" >
|
||||
|
||||
<div class="box-icon" id="AngleOfRotation_3">
|
||||
<a href="#" class="btn btn-minimize btn-round btn-default"><i
|
||||
class="glyphicon glyphicon-chevron-up"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-content" >
|
||||
<div style="position: relative;">
|
||||
|
||||
<img id="imageBackSecond"
|
||||
src="{{@unit.publicUri}}/images/drone_position_controller/pitch_drone.png"
|
||||
style="width: 100%;"/>
|
||||
<img id="imageTopSecond"
|
||||
src="{{@unit.publicUri}}/images/drone_position_controller/background_drone.png"
|
||||
style="position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%);"/>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="box col-md-4">
|
||||
<div class="box-inner">
|
||||
<div class="box-header well" data-original-title="" >
|
||||
<h2><i class="glyphicon glyphicon-list"></i>Live Video Stream</h2>
|
||||
|
||||
<div class="box-icon" id="LiveVideoStream">
|
||||
<a href="#" class="btn btn-minimize btn-round btn-default"><i
|
||||
class="glyphicon glyphicon-chevron-up"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-content">
|
||||
<img class="grayscale" src="{{@unit.publicUri}}/images/no_video_preview.gif"
|
||||
alt="video stream" style="display: block; height:225px; margin: auto;">
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="row">
|
||||
<div class="box col-md-12">
|
||||
<div class="box col-md-4">
|
||||
<div class="box-inner">
|
||||
<div class="box-header well" data-original-title="" >
|
||||
<h2><i class="glyphicon glyphicon-list"></i>Sensor Readings</h2>
|
||||
<div class="box-icon" id="SensorReadings">
|
||||
<a href="#" class="btn btn-minimize btn-round btn-default"><i
|
||||
class="glyphicon glyphicon-chevron-up"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-content" id="basicSensoReading">
|
||||
<div>
|
||||
<p>Location</br> latitude: <label id="locationLat"></label></br>
|
||||
longitude: <label id="locationLog"></label></br>
|
||||
altitudes: <label id="locationAlt"></label></p>
|
||||
<p> Velocity:</br> x :<label id="velocityx"></label></br>
|
||||
y : <label id="velocityy"></label></br>
|
||||
z : <label id="velocityz"></label></p>
|
||||
<p> Battery Voltage:<label id="battery_voltage"></label></p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box col-md-8">
|
||||
<div class="box-inner">
|
||||
<div class="box-header well" data-original-title="" >
|
||||
<h2><i class="glyphicon glyphicon-list-alt"></i>Realtime Plotting</h2>
|
||||
|
||||
<div class="box-icon" id="RealtimePlotting">
|
||||
<a href="#" class="btn btn-minimize btn-round btn-default"><i
|
||||
class="glyphicon glyphicon-chevron-up"></i></a>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box-content">
|
||||
<div class="row">
|
||||
<div class="box col-md-4" id="plottingMetadata" style="margin-left: 5%">
|
||||
<div>
|
||||
Window size : <label id="window_size_current_value" >30</label>
|
||||
<div id="window_size" style="width: 100%;" ></div><br>
|
||||
Update period : <label id="window_update_value" >300</label>
|
||||
</div>
|
||||
<div id="window_update" style="width: 100%;"></div></br>
|
||||
<div style="width:100%;">Y-axis: <label>Min: <input id="range_min" type="text" value="-4" size="3"></label>
|
||||
<label>Max: <input id="range_max" value="4" type="text" size="3"></label></div>
|
||||
<div style="width:100%;"><select ng-model='discussionsSelect' class='form-control' id="plotting_attribute">
|
||||
<option value='heading' selected>Heading</option>
|
||||
<option value='bank'>Bank</option>
|
||||
<option value='attitude'>Attitude</option>
|
||||
</select></div></br>
|
||||
<div>
|
||||
<button class="btn btn-primary" id="replotting" >Replot</button>
|
||||
</div>
|
||||
</div>
|
||||
<div class="box col-md-8" id="realtimechart" style="width:20%; height: 250px;"></div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
{{#zone "bottomJs"}}
|
||||
{{js "/js/d3.min.js" }}
|
||||
{{js "/js/3dobject_controller/three.min.js" }}
|
||||
{{js "/js/3dobject_controller/Coordinates.js" }}
|
||||
{{js "/js/3dobject_controller/OrbitAndPanControls.js" }}
|
||||
{{js "/js/3dobject_controller/3dObjectControler.js" }}
|
||||
{{js "/js/jQueryRotate.js" }}
|
||||
{{js "/js/config/config.js" }}
|
||||
{{js "/js/common/ajax_handler.js" }}
|
||||
{{js "/js/modules/realtime_plotting" }}
|
||||
{{js "/js/initJs" }}
|
||||
{{js "/js/common/general_handler" }}
|
||||
{{js "/js/common/websocket_api" }}
|
||||
{{js "/js/modules/controller.js" }}
|
||||
{{js "/js/modules/flight_dynamics.js" }}
|
||||
{{js "/js/mainHandler" }}
|
||||
{{/zone}}
|
||||
|
@ -1,25 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
*/
|
||||
function onRequest (context) {
|
||||
var log = new Log("statistics.js");
|
||||
var serverAddress = require("/app/modules/serverAddress.js").serverAddress;
|
||||
var wssAddress = serverAddress.getWSSAddress();
|
||||
var httpsAddress = serverAddress.getHPPSTSAddress();
|
||||
var device = context.unit.params.device;
|
||||
return { "device": device, "wssAddress": wssAddress, "httpsAddress": httpsAddress};
|
||||
}
|
@ -1,3 +0,0 @@
|
||||
{
|
||||
"version": "1.0.0"
|
||||
}
|
@ -1,213 +0,0 @@
|
||||
<!--
|
||||
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
~
|
||||
~ WSO2 Inc. licenses this file to you under the Apache License,
|
||||
~ Version 2.0 (the "License"); you may not use this file except
|
||||
~ in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing,
|
||||
~ software distributed under the License is distributed on an
|
||||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
~ KIND, either express or implied. See the License for the
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<parent>
|
||||
<groupId>org.homeautomation</groupId>
|
||||
<artifactId>droneanalyzer-feature</artifactId>
|
||||
<version>2.1.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<version>2.1.0-SNAPSHOT</version>
|
||||
<artifactId>${groupId}.droneanalyzer.feature</artifactId>
|
||||
<packaging>pom</packaging>
|
||||
<name>${project.artifactId}</name>
|
||||
<url>http://wso2.org</url>
|
||||
|
||||
|
||||
<properties>
|
||||
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
|
||||
</properties>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.homeautomation</groupId>
|
||||
<artifactId>org.homeautomation.droneanalyzer.plugin</artifactId>
|
||||
<version>${carbon.device.mgt.plugin.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.homeautomation</groupId>
|
||||
<artifactId>org.homeautomation.droneanalyzer.api</artifactId>
|
||||
<version>${carbon.device.mgt.plugin.version}</version>
|
||||
<type>war</type>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.h2database.wso2</groupId>
|
||||
<artifactId>h2-database-engine</artifactId>
|
||||
<version>1.2.140.wso2v3</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
<build>
|
||||
<plugins>
|
||||
<plugin>
|
||||
<artifactId>maven-resources-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>copy-resources</id>
|
||||
<phase>generate-resources</phase>
|
||||
<goals>
|
||||
<goal>copy-resources</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<outputDirectory>src/main/resources</outputDirectory>
|
||||
<resources>
|
||||
<resource>
|
||||
<directory>resources</directory>
|
||||
<includes>
|
||||
<include>build.properties</include>
|
||||
<include>p2.inf</include>
|
||||
</includes>
|
||||
</resource>
|
||||
</resources>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-dependency-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>unpack</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>unpack</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<artifactItems>
|
||||
<artifactItem>
|
||||
<groupId>org.homeautomation</groupId>
|
||||
<artifactId>org.homeautomation.droneanalyzer.ui
|
||||
</artifactId>
|
||||
<version>${project.version}</version>
|
||||
<type>zip</type>
|
||||
<overWrite>true</overWrite>
|
||||
<outputDirectory>
|
||||
${project.build.directory}/maven-shared-archive-resources/jaggeryapps/devicemgt
|
||||
</outputDirectory>
|
||||
<includes>**/*</includes>
|
||||
</artifactItem>
|
||||
</artifactItems>
|
||||
</configuration>
|
||||
</execution>
|
||||
<execution>
|
||||
<id>copy-jaxrs-war</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>copy</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<artifactItems>
|
||||
<artifactItem>
|
||||
<groupId>org.homeautomation</groupId>
|
||||
<artifactId>org.homeautomation.droneanalyzer.api
|
||||
</artifactId>
|
||||
<type>war</type>
|
||||
<overWrite>true</overWrite>
|
||||
<outputDirectory>
|
||||
${project.build.directory}/maven-shared-archive-resources/webapps/
|
||||
</outputDirectory>
|
||||
<destFileName>drone_analyzer.war</destFileName>
|
||||
</artifactItem>
|
||||
</artifactItems>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.apache.maven.plugins</groupId>
|
||||
<artifactId>maven-antrun-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<!-- Creating Drone Analyser Plugin Management schema -->
|
||||
<id>create-drone-analyzer-plugin-mgt-schema</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>run</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<tasks>
|
||||
<echo message="########### Create Drone Analyser plugin Management H2 Schema ###########"/>
|
||||
<property name="db.dir"
|
||||
value="target/maven-shared-archive-resources/database"/>
|
||||
<property name="userid" value="wso2carbon"/>
|
||||
<property name="password" value="wso2carbon"/>
|
||||
<property name="dbURL"
|
||||
value="jdbc:h2:file:${basedir}/${db.dir}/DroneAnalyzerDM_DB;DB_CLOSE_ON_EXIT=FALSE"/>
|
||||
|
||||
<mkdir dir="${basedir}/${db.dir}"/>
|
||||
|
||||
<sql driver="org.h2.Driver" url="${dbURL}" userid="${userid}"
|
||||
password="${password}"
|
||||
autocommit="true" onerror="continue">
|
||||
<classpath refid="maven.dependency.classpath"/>
|
||||
<classpath refid="maven.compile.classpath"/>
|
||||
<classpath refid="maven.runtime.classpath"/>
|
||||
|
||||
<fileset file="${basedir}/src/main/resources/dbscripts/h2.sql"/>
|
||||
</sql>
|
||||
<echo message="##################### END ####################"/>
|
||||
</tasks>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
|
||||
<plugin>
|
||||
<groupId>org.wso2.maven</groupId>
|
||||
<artifactId>carbon-p2-plugin</artifactId>
|
||||
<executions>
|
||||
<execution>
|
||||
<id>p2-feature-generation</id>
|
||||
<phase>package</phase>
|
||||
<goals>
|
||||
<goal>p2-feature-gen</goal>
|
||||
</goals>
|
||||
<configuration>
|
||||
<id>org.homeautomation.droneanalyzer</id>
|
||||
<propertiesFile>../../../features/etc/feature.properties</propertiesFile>
|
||||
<adviceFile>
|
||||
<properties>
|
||||
<propertyDef>org.wso2.carbon.p2.category.type:server</propertyDef>
|
||||
<propertyDef>org.eclipse.equinox.p2.type.group:true</propertyDef>
|
||||
</properties>
|
||||
</adviceFile>
|
||||
<bundles>
|
||||
<bundleDef>
|
||||
org.homeautomation:org.homeautomation.droneanalyzer.plugin:${carbon.device.mgt.plugin.version}
|
||||
</bundleDef>
|
||||
</bundles>
|
||||
<importFeatures>
|
||||
<importFeatureDef>org.wso2.carbon.core.server:${carbon.kernel.version}
|
||||
</importFeatureDef>
|
||||
<importFeatureDef>org.wso2.carbon.device.mgt.server:${carbon.device.mgt.version}
|
||||
</importFeatureDef>
|
||||
</importFeatures>
|
||||
</configuration>
|
||||
</execution>
|
||||
</executions>
|
||||
</plugin>
|
||||
</plugins>
|
||||
</build>
|
||||
</project>
|
@ -1,33 +0,0 @@
|
||||
#
|
||||
# Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
#
|
||||
# Licensed under the Apache License, Version 2.0 (the "License");
|
||||
# you may not use this file except in compliance with the License.
|
||||
# You may obtain a copy of the License at
|
||||
#
|
||||
# http://www.apache.org/licenses/LICENSE-2.0
|
||||
#
|
||||
# Unless required by applicable law or agreed to in writing, software
|
||||
# distributed under the License is distributed on an "AS IS" BASIS,
|
||||
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
# See the License for the specific language governing permissions and
|
||||
# limitations under the License.
|
||||
#
|
||||
#
|
||||
|
||||
[Device-Configurations]
|
||||
owner=${DEVICE_OWNER}
|
||||
deviceId=${DEVICE_ID}
|
||||
device-name=${DEVICE_NAME}
|
||||
controller-context=/drone_analyzer/controller
|
||||
https-ep=${HTTPS_EP}
|
||||
http-ep=${HTTP_EP}
|
||||
apim-ep=${APIM_EP}
|
||||
mqtt-ep=${MQTT_EP}
|
||||
xmpp-ep=${XMPP_EP}
|
||||
auth-method=token
|
||||
auth-token=${DEVICE_TOKEN}
|
||||
refresh-token=${DEVICE_REFRESH_TOKEN}
|
||||
push-interval=15
|
||||
|
||||
|
@ -1,2 +0,0 @@
|
||||
templates=deviceConfig.properties
|
||||
zipfilename=drone_analyzer.zip
|
@ -1,73 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
"""
|
||||
/**
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
**/
|
||||
"""
|
||||
|
||||
#This script can be used to observe drone attribute (state) changes and push those status changes to xmpp server.
|
||||
|
||||
import argparse
|
||||
import time
|
||||
|
||||
from dronekit import connect, VehicleMode
|
||||
import xmppClient
|
||||
|
||||
CONNECTION_TARGET = "/dev/ttyACM0"
|
||||
PUSH_INTERVAL = 1
|
||||
BAUD = 57600
|
||||
|
||||
|
||||
parser = argparse.ArgumentParser(description='Connects to drone on ')
|
||||
parser.add_argument("-c", "--connect", default='/dev/ttyACM0',help="vehicle connection target. Default '/dev/ttyACM0'")
|
||||
parser.add_argument("-b", '--baud', type=int ,default=57600,help="Serial communication speed. Default 57600")
|
||||
parser.add_argument("-i", "--push_interval", type=int, default=1,help="This is the interval which is used to push drone"
|
||||
" status to xmpp server")
|
||||
args = parser.parse_args()
|
||||
|
||||
if args.connect:
|
||||
CONNECTION_TARGET = args.connect
|
||||
|
||||
if args.push_interval:
|
||||
PUSH_INTERVAL = args.push_interval
|
||||
|
||||
if args.baud:
|
||||
BAUD = args.baud
|
||||
|
||||
isConnected = xmppClient.connectToXMPPServer()
|
||||
if isConnected:
|
||||
print "\nConnecting to vehicle on: %s" % CONNECTION_TARGET
|
||||
print "----------------------------------------------------------------------"
|
||||
vehicle = connect(CONNECTION_TARGET, wait_ready=True, baud=BAUD)
|
||||
while (True):
|
||||
print " Attitude: %s" % vehicle.attitude.yaw
|
||||
current_state = "{\"quatanium_val\":["+str(vehicle.attitude.yaw)+","+str(vehicle.attitude.pitch)+ \
|
||||
", "+str(vehicle.attitude.roll)+"],\"basicParam\":{\"velocity\":["+str(vehicle.velocity[0])+"," \
|
||||
+str(vehicle.velocity[1])+","+str(vehicle.velocity[2])+"],\"global_location\":["+ \
|
||||
str(vehicle.location.global_relative_frame.alt)+","+str(vehicle.location.global_relative_frame.lat)+ \
|
||||
","+str(vehicle.location.global_relative_frame.lon)+"]},\"battery_level\":"+ \
|
||||
str(vehicle.battery.level)+",\"battery_voltage\":"+str(vehicle.battery.voltage)+ \
|
||||
",\"device_type\":\"IRIS_DRONE\"}";
|
||||
#current_state = "{\"quatanium_val\":[0.345, 0.567, 0.456, 0.6345],\"basicParam\":{\"velocity\":[3, 2, 1], " \
|
||||
#"\"global_location\":[0.567, 2.345, 0.456]},\"battery_level\":56,\"battery_voltage\":34,\"device_type\":\"SIMULATOR\"}";
|
||||
xmppClient.sendMessage(current_state)
|
||||
time.sleep(PUSH_INTERVAL)
|
||||
print "-------------------------------------------------------------------------------------------------"
|
||||
|
||||
print "\nClose vehicle object"
|
||||
vehicle.close()
|
||||
print("Completed")
|
@ -1,40 +0,0 @@
|
||||
#!/usr/bin/env python
|
||||
|
||||
"""
|
||||
/**
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
**/
|
||||
"""
|
||||
import ConfigParser, os
|
||||
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
# Device specific info when pushing data to server
|
||||
# Read from a file "deviceConfig.properties" in the same folder level
|
||||
# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
configParser = ConfigParser.RawConfigParser()
|
||||
configFilePath = r'./deviceConfig.properties'
|
||||
configParser.read(configFilePath)
|
||||
|
||||
DEVICE_OWNER = configParser.get('Device-Configurations', 'owner')
|
||||
DEVICE_ID = configParser.get('Device-Configurations', 'deviceId')
|
||||
XMPP_EP = configParser.get('Device-Configurations', 'xmpp-ep')
|
||||
AUTH_TOKEN = configParser.get('Device-Configurations', 'auth-token')
|
||||
DEVICE_PASSWORD = configParser.get('Device-Configurations', 'auth-token')
|
||||
CONTROLLER_CONTEXT = configParser.get('Device-Configurations', 'controller-context')
|
||||
HTTPS_EP = configParser.get('Device-Configurations', 'https-ep')
|
||||
HTTP_EP = configParser.get('Device-Configurations', 'http-ep')
|
||||
### ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
@ -1,66 +0,0 @@
|
||||
"""
|
||||
/**
|
||||
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
*
|
||||
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
* Version 2.0 (the "License"); you may not use this file except
|
||||
* in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing,
|
||||
* software distributed under the License is distributed on an
|
||||
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
* KIND, either express or implied. See the License for the
|
||||
* specific language governing permissions and limitations
|
||||
* under the License.
|
||||
**/
|
||||
"""
|
||||
import xmpp
|
||||
import util
|
||||
|
||||
XMPP_ENDPOINT = util.XMPP_EP.split(":")
|
||||
XMPP_IP = XMPP_ENDPOINT[1].replace('//', '')
|
||||
XMPP_PORT = int(XMPP_ENDPOINT[2])
|
||||
MESSAGE_TO = util.DEVICE_OWNER
|
||||
XMPP_PWD = util.DEVICE_PASSWORD
|
||||
XMPP_OWN = util.DEVICE_ID
|
||||
|
||||
XMPP_RESOURCE = "drone_current_status"
|
||||
XMPP_JID = MESSAGE_TO + "@" + XMPP_IP + "/" + XMPP_RESOURCE
|
||||
|
||||
|
||||
global droneClient
|
||||
droneClient = xmpp.Client(XMPP_IP, debug=[])
|
||||
|
||||
def loginToXMPPServer():
|
||||
auth = droneClient.auth(XMPP_OWN, XMPP_PWD, resource=XMPP_RESOURCE)
|
||||
if not auth:
|
||||
print 'could not authenticate!'
|
||||
return 0
|
||||
print 'authenticated using', auth
|
||||
droneClient.sendInitPresence()
|
||||
return 1
|
||||
|
||||
|
||||
def connectToXMPPServer():
|
||||
connection = droneClient.connect(server=(XMPP_IP, XMPP_PORT))
|
||||
if not connection:
|
||||
print 'could not connect to xmpp server at ' + str(XMPP_IP)
|
||||
return 0
|
||||
|
||||
print 'connected with', connection
|
||||
response = loginToXMPPServer()
|
||||
if response:
|
||||
return 1
|
||||
else:
|
||||
return 0
|
||||
|
||||
|
||||
def sendMessage(message):
|
||||
xmpp_message = xmpp.Message(XMPP_JID, message)
|
||||
xmpp_message.setAttr('type', 'chat')
|
||||
droneClient.send(xmpp_message)
|
||||
print message
|
||||
|
@ -1,83 +0,0 @@
|
||||
|
||||
#/**
|
||||
#* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
#*
|
||||
#* WSO2 Inc. licenses this file to you under the Apache License,
|
||||
#* Version 2.0 (the "License"); you may not use this file except
|
||||
#* in compliance with the License.
|
||||
#* You may obtain a copy of the License at
|
||||
#*
|
||||
#* http://www.apache.org/licenses/LICENSE-2.0
|
||||
#*
|
||||
#* Unless required by applicable law or agreed to in writing,
|
||||
#* software distributed under the License is distributed on an
|
||||
#* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
#* KIND, either express or implied. See the License for the
|
||||
#* specific language governing permissions and limitations
|
||||
#* under the License.
|
||||
#**/
|
||||
|
||||
#!/bin/bash
|
||||
|
||||
echo "----------------------------------------------------------------"
|
||||
echo "| WSO2 IOT Sample "
|
||||
echo "| Drone Analyzer "
|
||||
echo "| ---------------- "
|
||||
echo "| ....initializing startup-script "
|
||||
echo "----------------------------------------------------------------"
|
||||
|
||||
currentDir=$PWD
|
||||
|
||||
|
||||
while true; do
|
||||
read -p "Do you wish to run 'apt-get update' and continue? [Yes/No] " yn
|
||||
case $yn in
|
||||
[Yy]* ) sudo apt-get update;
|
||||
break;;
|
||||
[Nn]* ) echo "Continuing without apt-get update...";
|
||||
break;;
|
||||
* ) echo "Please answer yes or no.";
|
||||
esac
|
||||
done
|
||||
|
||||
for f in ./deviceConfig.properties; do
|
||||
if [ -e "$f" ]; then
|
||||
echo "Configuration file found......"
|
||||
else
|
||||
echo "'deviceConfig.properties' file does not exist in current path. \nExiting installation...";
|
||||
exit;
|
||||
fi
|
||||
break
|
||||
done
|
||||
|
||||
#installing dependencies
|
||||
sudo apt-get install python-pip python-dev
|
||||
sudo pip install dronekit
|
||||
sudo apt-get install python-xmpp
|
||||
|
||||
while true; do
|
||||
read -p "Whats the time-interval (in seconds) between successive Data-Pushes to the XMPP server (ex: '60' indicates 1 minute) > " push_interval
|
||||
read -p "Vehicle connection target. Default '/dev/ttyACM0' :" connection_target
|
||||
read -p "Serial communication speed. Default 57600 :" baud
|
||||
|
||||
if [ $input -eq $input 2>/dev/null ]
|
||||
then
|
||||
echo "Setting data-push interval to $push_interval seconds."
|
||||
break
|
||||
else
|
||||
echo "Input needs to be an integer indicating the number seconds between successive data-pushes."
|
||||
fi
|
||||
|
||||
done
|
||||
|
||||
cp deviceConfig.properties ./src
|
||||
python ./src/IRIS+DroneStatistics.py -i $push_interval -b $baud -c $connection_target
|
||||
|
||||
if [ $? -ne 0 ]; then
|
||||
echo "Could not start the service..."
|
||||
exit;
|
||||
fi
|
||||
|
||||
echo "--------------------------------------------------------------------------"
|
||||
echo "| Successfully Started "
|
||||
echo "---------------------------------------------------------------------------"
|
@ -1 +0,0 @@
|
||||
custom = true
|
@ -1,6 +0,0 @@
|
||||
{
|
||||
"deviceType": {
|
||||
"label": "Drone Analyzer",
|
||||
"category": "iot"
|
||||
}
|
||||
}
|
@ -1,24 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<!--
|
||||
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
~
|
||||
~ WSO2 Inc. licenses this file to you under the Apache License,
|
||||
~ Version 2.0 (the "License"); you may not use this file except
|
||||
~ in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing,
|
||||
~ software distributed under the License is distributed on an
|
||||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
~ KIND, either express or implied. See the License for the
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.
|
||||
-->
|
||||
|
||||
<DeviceTypeConfigurations>
|
||||
<DeviceTypeConfig type="drone_analyzer">
|
||||
<DatasourceName>jdbc/DroneAnalyzerDM_DB</DatasourceName>
|
||||
</DeviceTypeConfig>
|
||||
</DeviceTypeConfigurations>
|
@ -1,50 +0,0 @@
|
||||
<!--
|
||||
~ Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
~
|
||||
~ WSO2 Inc. licenses this file to you under the Apache License,
|
||||
~ Version 2.0 (the "License"); you may not use this file except
|
||||
~ in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing,
|
||||
~ software distributed under the License is distributed on an
|
||||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
~ KIND, either express or implied. See the License for the
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.
|
||||
-->
|
||||
|
||||
<datasources-configuration xmlns:svns="http://org.wso2.securevault/configuration">
|
||||
<providers>
|
||||
<provider>org.wso2.carbon.ndatasource.rdbms.RDBMSDataSourceReader</provider>
|
||||
</providers>
|
||||
|
||||
<datasources>
|
||||
<datasource>
|
||||
<name>DroneAnalyzerDM_DB</name>
|
||||
<description>The datasource used for the Drone Analyzer database</description>
|
||||
<jndiConfig>
|
||||
<name>jdbc/DroneAnalyzerDM_DB</name>
|
||||
</jndiConfig>
|
||||
<definition type="RDBMS">
|
||||
<configuration>
|
||||
<url>jdbc:h2:repository/database/DroneAnalyzerDM_DB;DB_CLOSE_ON_EXIT=FALSE
|
||||
</url>
|
||||
<username>wso2carbon</username>
|
||||
<password>wso2carbon</password>
|
||||
<driverClassName>org.h2.Driver</driverClassName>
|
||||
<maxActive>50</maxActive>
|
||||
<maxWait>60000</maxWait>
|
||||
<testOnBorrow>true</testOnBorrow>
|
||||
<validationQuery>SELECT 1</validationQuery>
|
||||
<validationInterval>30000</validationInterval>
|
||||
</configuration>
|
||||
</definition>
|
||||
</datasource>
|
||||
</datasources>
|
||||
</datasources-configuration>
|
||||
|
||||
|
||||
|
@ -1,11 +0,0 @@
|
||||
|
||||
-- -----------------------------------------------------
|
||||
-- Table `DRONE_DEVICE`
|
||||
-- -----------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `DRONE_DEVICE` (
|
||||
`DRONE_DEVICE_ID` VARCHAR(45) NOT NULL ,
|
||||
`DEVICE_NAME` VARCHAR(100) NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`DRONE_DEVICE_ID`) );
|
||||
|
||||
|
||||
|
@ -1,12 +0,0 @@
|
||||
-- -----------------------------------------------------
|
||||
-- Table `DRONE_DEVICE`
|
||||
-- -----------------------------------------------------
|
||||
CREATE TABLE IF NOT EXISTS `DRONE_DEVICE` (
|
||||
`DRONE_DEVICE_ID` VARCHAR(45) NOT NULL ,
|
||||
`DEVICE_NAME` VARCHAR(100) NULL DEFAULT NULL,
|
||||
PRIMARY KEY (`DRONE_DEVICE_ID`) )
|
||||
ENGINE = InnoDB;
|
||||
|
||||
|
||||
|
||||
|
@ -1,26 +0,0 @@
|
||||
instructions.configure = \
|
||||
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../conf/device-types/);\
|
||||
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.homeautomation.droneanalyzer_${feature.version}/configs/,target:${installFolder}/../../conf/device-types/,overwrite:true);\
|
||||
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/webapps/);\
|
||||
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.homeautomation.droneanalyzer_${feature.version}/webapps/,target:${installFolder}/../../deployment/server/webapps/,overwrite:true);\
|
||||
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/sketches/);\
|
||||
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../resources/sketches/drone_analyzer/);\
|
||||
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.homeautomation.droneanalyzer_${feature.version}/agent/,target:${installFolder}/../../resources/sketches/drone_analyzer/,overwrite:true);\
|
||||
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.homeautomation.droneanalyzer_${feature.version}/dbscripts/,target:${installFolder}/../../../dbscripts/cdm/plugins/drone_analyzer,overwrite:true);\
|
||||
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../deployment/server/jaggeryapps/);\
|
||||
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.homeautomation.droneanalyzer_${feature.version}/jaggeryapps/,target:${installFolder}/../../deployment/server/jaggeryapps/,overwrite:true);\
|
||||
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.homeautomation.droneanalyzer_${feature.version}/datasources/,target:${installFolder}/../../conf/datasources/,overwrite:true);\
|
||||
org.eclipse.equinox.p2.touchpoint.natives.mkdir(path:${installFolder}/../../database/);\
|
||||
org.eclipse.equinox.p2.touchpoint.natives.copy(source:${installFolder}/../features/org.homeautomation.droneanalyzer_${feature.version}/database/,target:${installFolder}/../../database/,overwrite:true);\
|
||||
|
||||
instructions.unconfigure = \
|
||||
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../conf/device-types/drone_analyzer.json);\
|
||||
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../conf/device-types/drone_analyzer.xml);\
|
||||
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/webapps/drone_analyzer.war);\
|
||||
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/webapps/drone_analyzer);\
|
||||
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../../dbscripts/cdm/plugins/drone_analyzer);\
|
||||
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../resources/sketches/drone_analyzer);\
|
||||
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../conf/datasources/drone_analyzer-datasources.xml);\
|
||||
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../database/DroneAnalyzerDM_DB.h2.db);\
|
||||
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.drone_analyzer.device-view);\
|
||||
org.eclipse.equinox.p2.touchpoint.natives.remove(path:${installFolder}/../../deployment/server/jaggeryapps/devicemgt/app/units/cdmf.unit.device.type.drone_analyzer.type-view);\
|
@ -1,39 +0,0 @@
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<!--
|
||||
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
~
|
||||
~ WSO2 Inc. licenses this file to you under the Apache License,
|
||||
~ Version 2.0 (the "License"); you may not use this file except
|
||||
~ in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing,
|
||||
~ software distributed under the License is distributed on an
|
||||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
~ KIND, either express or implied. See the License for the
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
<parent>
|
||||
<groupId>org.homeautomation</groupId>
|
||||
<artifactId>droneanalyzer</artifactId>
|
||||
<version>2.1.0-SNAPSHOT</version>
|
||||
<relativePath>../pom.xml</relativePath>
|
||||
</parent>
|
||||
|
||||
<artifactId>droneanalyzer-feature</artifactId>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<packaging>pom</packaging>
|
||||
<version>2.1.0-SNAPSHOT</version>
|
||||
|
||||
<modules>
|
||||
<module>feature</module>
|
||||
</modules>
|
||||
</project>
|
@ -1,501 +0,0 @@
|
||||
<!--
|
||||
~ Copyright (c) 2016, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||
~
|
||||
~ WSO2 Inc. licenses this file to you under the Apache License,
|
||||
~ Version 2.0 (the "License"); you may not use this file except
|
||||
~ in compliance with the License.
|
||||
~ You may obtain a copy of the License at
|
||||
~
|
||||
~ http://www.apache.org/licenses/LICENSE-2.0
|
||||
~
|
||||
~ Unless required by applicable law or agreed to in writing,
|
||||
~ software distributed under the License is distributed on an
|
||||
~ "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||
~ KIND, either express or implied. See the License for the
|
||||
~ specific language governing permissions and limitations
|
||||
~ under the License.
|
||||
-->
|
||||
|
||||
<project xmlns="http://maven.apache.org/POM/4.0.0"
|
||||
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
|
||||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
|
||||
|
||||
<parent>
|
||||
<groupId>org.wso2</groupId>
|
||||
<artifactId>wso2</artifactId>
|
||||
<version>1</version>
|
||||
</parent>
|
||||
|
||||
<groupId>org.homeautomation</groupId>
|
||||
<artifactId>droneanalyzer</artifactId>
|
||||
<version>2.1.0-SNAPSHOT</version>
|
||||
<packaging>pom</packaging>
|
||||
<modelVersion>4.0.0</modelVersion>
|
||||
<url>http://wso2.com</url>
|
||||
|
||||
<modules>
|
||||
<module>component</module>
|
||||
<module>feature</module>
|
||||
</modules>
|
||||
|
||||
<dependencyManagement>
|
||||
<dependencies>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.osgi</groupId>
|
||||
<artifactId>org.eclipse.osgi</artifactId>
|
||||
<version>${eclipse.osgi.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.equinox</groupId>
|
||||
<artifactId>org.eclipse.equinox.common</artifactId>
|
||||
<version>${eclipse.equinox.common.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.testng</groupId>
|
||||
<artifactId>testng</artifactId>
|
||||
<version>${testng.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>junit</groupId>
|
||||
<artifactId>junit</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.beanshell</groupId>
|
||||
<artifactId>bsh</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.yaml</groupId>
|
||||
<artifactId>snakeyaml</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.osgi</groupId>
|
||||
<artifactId>org.eclipse.osgi.services</artifactId>
|
||||
<version>3.3.100.v20120522-1822</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.logging</artifactId>
|
||||
<version>${carbon.kernel.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.apache.log4j.wso2</groupId>
|
||||
<artifactId>log4j</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>commons-logging</groupId>
|
||||
<artifactId>commons-logging</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.bootstrap</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<!-- CXF dependencies -->
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-frontend-jaxws</artifactId>
|
||||
<version>${cxf.version}</version>
|
||||
<!--<scope>provided</scope>-->
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
|
||||
<version>${cxf.version}</version>
|
||||
<!--<scope>provided</scope>-->
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.cxf</groupId>
|
||||
<artifactId>cxf-rt-transports-http</artifactId>
|
||||
<version>${cxf.version}</version>
|
||||
<!--<scope>provided</scope>-->
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.eclipse.paho</groupId>
|
||||
<artifactId>org.eclipse.paho.client.mqttv3</artifactId>
|
||||
<version>${paho.mqtt.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.jackson</groupId>
|
||||
<artifactId>jackson-core-asl</artifactId>
|
||||
<version>${jackson.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.codehaus.jackson</groupId>
|
||||
<artifactId>jackson-jaxrs</artifactId>
|
||||
<version>${jackson.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax</groupId>
|
||||
<artifactId>javaee-web-api</artifactId>
|
||||
<version>6.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.ws.rs</groupId>
|
||||
<artifactId>jsr311-api</artifactId>
|
||||
<version>${javax.ws.rs.version}</version>
|
||||
<!--<scope>provided</scope>-->
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.httpcomponents</groupId>
|
||||
<artifactId>httpasyncclient</artifactId>
|
||||
<version>4.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.json</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
<version>20140107</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>javax.websocket</groupId>
|
||||
<artifactId>javax.websocket-api</artifactId>
|
||||
<version>1.1</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-collections4</artifactId>
|
||||
<version>4.0</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.homeautomation</groupId>
|
||||
<artifactId>org.homeautomation.droneanalyzer.plugin</artifactId>
|
||||
<version>${carbon.device.mgt.plugin.version}</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.apimgt.webapp.publisher</artifactId>
|
||||
<version>${carbon.device.mgt.version}</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>
|
||||
${basedir}/../../../../repository/components/plugins/org.wso2.carbon.apimgt.webapp.publisher_${carbon.device.mgt.jar.version}.jar
|
||||
</systemPath>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.ndatasource.core</artifactId>
|
||||
<version>${carbon.kernel.version}</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>
|
||||
${basedir}/../../../../repository/components/plugins/org.wso2.carbon.ndatasource.core_${carbon.kernel.version}.jar
|
||||
</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt-plugins</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.iot</artifactId>
|
||||
<version>${carbon.device.mgt.plugin.version}</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>
|
||||
${basedir}/../../../../repository/components/plugins/org.wso2.carbon.device.mgt.iot_${carbon.iot.device.mgt.jar.version}.jar
|
||||
</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.core</artifactId>
|
||||
<version>${carbon.device.mgt.version}</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>
|
||||
${basedir}/../../../../repository/components/plugins/org.wso2.carbon.device.mgt.core_${carbon.device.mgt.jar.version}.jar
|
||||
</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.common</artifactId>
|
||||
<version>${carbon.device.mgt.version}</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>
|
||||
${basedir}/../../../../repository/components/plugins/org.wso2.carbon.device.mgt.common_${carbon.device.mgt.jar.version}.jar
|
||||
</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.certificate.mgt.core</artifactId>
|
||||
<version>${carbon.device.mgt.version}</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>
|
||||
${basedir}/../../../../repository/components/plugins/org.wso2.carbon.certificate.mgt.core_${carbon.device.mgt.jar.version}.jar
|
||||
</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.apimgt.annotations</artifactId>
|
||||
<version>${carbon.device.mgt.version}</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>
|
||||
${basedir}/../../../../repository/components/plugins/org.wso2.carbon.apimgt.annotations_${carbon.device.mgt.jar.version}.jar
|
||||
</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.analytics.data.publisher</artifactId>
|
||||
<version>${carbon.device.mgt.version}</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>
|
||||
${basedir}/../../../../repository/components/plugins/org.wso2.carbon.device.mgt.analytics.data.publisher_${carbon.device.mgt.jar.version}.jar
|
||||
</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-httpclient.wso2</groupId>
|
||||
<artifactId>commons-httpclient</artifactId>
|
||||
<version>${commons-httpclient.orbit.version}</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>
|
||||
${basedir}/../../../../repository/components/plugins/commons-httpclient_3.1.0.wso2v2.jar
|
||||
</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.utils</artifactId>
|
||||
<version>${carbon.kernel.version}</version>
|
||||
<exclusions>
|
||||
<exclusion>
|
||||
<groupId>org.bouncycastle.wso2</groupId>
|
||||
<artifactId>bcprov-jdk15on</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.user.api</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.queuing</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.base</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.apache.axis2.wso2</groupId>
|
||||
<artifactId>axis2</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.igniterealtime.smack.wso2</groupId>
|
||||
<artifactId>smack</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.igniterealtime.smack.wso2</groupId>
|
||||
<artifactId>smackx</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>jaxen</groupId>
|
||||
<artifactId>jaxen</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>commons-fileupload.wso2</groupId>
|
||||
<artifactId>commons-fileupload</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.apache.ant.wso2</groupId>
|
||||
<artifactId>ant</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.apache.ant.wso2</groupId>
|
||||
<artifactId>ant</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>commons-httpclient.wso2</groupId>
|
||||
<artifactId>commons-httpclient</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.eclipse.equinox</groupId>
|
||||
<artifactId>javax.servlet</artifactId>
|
||||
</exclusion>
|
||||
<exclusion>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.registry.api</artifactId>
|
||||
</exclusion>
|
||||
</exclusions>
|
||||
<scope>system</scope>
|
||||
<systemPath>
|
||||
${basedir}/../../../../repository/components/plugins/org.wso2.carbon.utils_${carbon.kernel.version}.jar
|
||||
</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.igniterealtime.smack.wso2</groupId>
|
||||
<artifactId>smack</artifactId>
|
||||
<version>${smack.wso2.version}</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>
|
||||
${basedir}/../../../../repository/components/plugins/smack_3.0.4.wso2v1.jar
|
||||
</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.igniterealtime.smack.wso2</groupId>
|
||||
<artifactId>smackx</artifactId>
|
||||
<version>${smackx.wso2.version}</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>
|
||||
${basedir}/../../../../repository/components/plugins/smackx_3.0.4.wso2v1.jar
|
||||
</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.json.wso2</groupId>
|
||||
<artifactId>json</artifactId>
|
||||
<version>${commons-json.version}</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>
|
||||
${basedir}/../../../../repository/components/plugins/json_3.0.0.wso2v1.jar
|
||||
</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>commons-codec</groupId>
|
||||
<artifactId>commons-codec</artifactId>
|
||||
<version>1.4.0.wso2v1</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>
|
||||
${basedir}/../../../../repository/components/plugins/commons-codec_1.4.0.wso2v1.jar
|
||||
</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.device.mgt.extensions</artifactId>
|
||||
<version>${carbon.device.mgt.version}</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>
|
||||
${basedir}/../../../../repository/components/plugins/org.wso2.carbon.device.mgt.extensions_${carbon.device.mgt.jar.version}.jar
|
||||
</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.apimgt.application.extension</artifactId>
|
||||
<version>${carbon.device.mgt.version}</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>
|
||||
${basedir}/../../../../repository/components/plugins/org.wso2.carbon.apimgt.application.extension_${carbon.device.mgt.jar.version}.jar
|
||||
</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon.devicemgt</groupId>
|
||||
<artifactId>org.wso2.carbon.identity.jwt.client.extension</artifactId>
|
||||
<version>${carbon.device.mgt.jar.version}</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>
|
||||
${basedir}/../../../../repository/components/plugins/org.wso2.carbon.identity.jwt.client.extension_${carbon.device.mgt.jar.version}.jar
|
||||
</systemPath>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.wso2.carbon</groupId>
|
||||
<artifactId>org.wso2.carbon.user.api</artifactId>
|
||||
<version>${carbon.kernel.version}</version>
|
||||
<scope>system</scope>
|
||||
<systemPath>
|
||||
${basedir}/../../../../repository/components/plugins/org.wso2.carbon.user.api_${carbon.kernel.version}.jar
|
||||
</systemPath>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
</dependencyManagement>
|
||||
|
||||
<pluginRepositories>
|
||||
<pluginRepository>
|
||||
<id>wso2.releases</id>
|
||||
<name>WSO2 internal Repository</name>
|
||||
<url>http://maven.wso2.org/nexus/content/repositories/releases/</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
<updatePolicy>daily</updatePolicy>
|
||||
<checksumPolicy>ignore</checksumPolicy>
|
||||
</releases>
|
||||
</pluginRepository>
|
||||
|
||||
<pluginRepository>
|
||||
<id>wso2.snapshots</id>
|
||||
<name>Apache Snapshot Repository</name>
|
||||
<url>http://maven.wso2.org/nexus/content/repositories/snapshots/</url>
|
||||
<snapshots>
|
||||
<enabled>true</enabled>
|
||||
<updatePolicy>daily</updatePolicy>
|
||||
</snapshots>
|
||||
<releases>
|
||||
<enabled>false</enabled>
|
||||
</releases>
|
||||
</pluginRepository>
|
||||
<pluginRepository>
|
||||
<id>wso2-nexus</id>
|
||||
<name>WSO2 internal Repository</name>
|
||||
<url>http://maven.wso2.org/nexus/content/groups/wso2-public/</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
<updatePolicy>daily</updatePolicy>
|
||||
<checksumPolicy>ignore</checksumPolicy>
|
||||
</releases>
|
||||
</pluginRepository>
|
||||
</pluginRepositories>
|
||||
|
||||
<repositories>
|
||||
<!-- Before adding ANYTHING in here, please start a discussion on the dev list.
|
||||
Ideally the Axis2 build should only use Maven central (which is available
|
||||
by default) and nothing else. We had troubles with other repositories in
|
||||
the past. Therefore configuring additional repositories here should be
|
||||
considered very carefully. -->
|
||||
<repository>
|
||||
<id>wso2-nexus</id>
|
||||
<name>WSO2 internal Repository</name>
|
||||
<url>http://maven.wso2.org/nexus/content/groups/wso2-public/</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
<updatePolicy>daily</updatePolicy>
|
||||
<checksumPolicy>ignore</checksumPolicy>
|
||||
</releases>
|
||||
</repository>
|
||||
<repository>
|
||||
<id>wso2.releases</id>
|
||||
<name>WSO2 internal Repository</name>
|
||||
<url>http://maven.wso2.org/nexus/content/repositories/releases/</url>
|
||||
<releases>
|
||||
<enabled>true</enabled>
|
||||
<updatePolicy>daily</updatePolicy>
|
||||
<checksumPolicy>ignore</checksumPolicy>
|
||||
</releases>
|
||||
</repository>
|
||||
</repositories>
|
||||
|
||||
|
||||
<properties>
|
||||
<carbon.kernel.version>4.4.3</carbon.kernel.version>
|
||||
<carbon.device.mgt.version>1.1.0-SNAPSHOT</carbon.device.mgt.version>
|
||||
<carbon.device.mgt.jar.version>1.1.0.SNAPSHOT</carbon.device.mgt.jar.version>
|
||||
<paho.mqtt.version>1.0.2</paho.mqtt.version>
|
||||
<commons-json.version>3.0.0.wso2v1</commons-json.version>
|
||||
<eclipse.osgi.version>3.8.1.v20120830-144521</eclipse.osgi.version>
|
||||
<carbon.device.mgt.plugin.version>2.1.0-SNAPSHOT</carbon.device.mgt.plugin.version>
|
||||
<carbon.iot.device.mgt.jar.version>2.1.0.SNAPSHOT</carbon.iot.device.mgt.jar.version>
|
||||
<javax.ws.rs.version>1.1.1</javax.ws.rs.version>
|
||||
|
||||
<!--XMPP/MQTT Version-->
|
||||
<smack.wso2.version>3.0.4.wso2v1</smack.wso2.version>
|
||||
<smackx.wso2.version>3.0.4.wso2v1</smackx.wso2.version>
|
||||
<cxf.version>2.6.1</cxf.version>
|
||||
<jackson.version>1.9.0</jackson.version>
|
||||
<commons-httpclient.orbit.version>3.1.0.wso2v2</commons-httpclient.orbit.version>
|
||||
<commons-json.version>3.0.0.wso2v1</commons-json.version>
|
||||
<eclipse.equinox.common.version>3.6.100.v20120522-1841</eclipse.equinox.common.version>
|
||||
|
||||
|
||||
<wso2.maven.compiler.source>1.7</wso2.maven.compiler.source>
|
||||
<wso2.maven.compiler.target>1.7</wso2.maven.compiler.target>
|
||||
<project-base-package>org.homeautomation.droneanalyzer</project-base-package>
|
||||
<junit.version>3.8.1</junit.version>
|
||||
<org.apache.felix.version>1.4.0</org.apache.felix.version>
|
||||
<maven-clean-plugin.version>2.4.1</maven-clean-plugin.version>
|
||||
<maven-compiler-plugin.version>2.3.2</maven-compiler-plugin.version>
|
||||
<maven-war-plugin.version>2.6</maven-war-plugin.version>
|
||||
<maven-antrun-plugin.version>1.8</maven-antrun-plugin.version>
|
||||
<maven-scr-plugin.version>1.7.2</maven-scr-plugin.version>
|
||||
|
||||
</properties>
|
||||
|
||||
</project>
|