Issues fixed

application-manager-new
Menaka Madushanka 9 years ago
parent 6179298d9f
commit 1ac2dc9307

@ -58,9 +58,6 @@ public class ConnectedCupControllerService {
private static final String SUPER_TENANT = "carbon.super";
private static ConnectedCupMQTTConnector connectedCupMQTTConnector;
@Context
HttpServletResponse response;
public ConnectedCupMQTTConnector connectedCupMQTTConnector() {
return ConnectedCupControllerService.connectedCupMQTTConnector;
@ -81,8 +78,11 @@ public class ConnectedCupControllerService {
* @param deviceId
* @param owner
*/
@Path("controller/cup/coffeelevel")
@Path("controller/coffeelevel")
@GET
@Produces(MediaType.APPLICATION_JSON)
@Feature(code = "coffeelevel", name="Coffeelevel", description = "read coffeelevel from this device", type =
"monitor")
public SensorRecord readCoffeeLevel(@HeaderParam("owner") String owner,
@HeaderParam("deviceId") String deviceId,
@Context HttpServletResponse response) {
@ -118,8 +118,11 @@ public class ConnectedCupControllerService {
@Path("controller/cup/temperature")
@Path("controller/temperature")
@GET
@Produces(MediaType.APPLICATION_JSON)
@Feature(code = "temperature", name="Temperature", description = "read temperature from this device", type =
"monitor")
public SensorRecord readTemperature(@HeaderParam("owner") String owner,
@HeaderParam("deviceId") String deviceId,
@Context HttpServletResponse response) {
@ -156,9 +159,9 @@ public class ConnectedCupControllerService {
@Path("controller/ordercoffee")
@POST
public HttpServletResponse orderCoffee(@QueryParam("deviceId") String deviceId, @QueryParam("deviceOwner") String
public void orderCoffee(@QueryParam("deviceId") String deviceId, @QueryParam("deviceOwner") String
deviceOwner, @Context HttpServletResponse response){
SensorRecord sensorRecord = null;
DeviceValidator deviceValidator = new DeviceValidator();
try {
if (!deviceValidator.isExist(deviceOwner, SUPER_TENANT, new DeviceIdentifier(
@ -175,6 +178,6 @@ public class ConnectedCupControllerService {
if (log.isDebugEnabled()) {
log.debug("Sending request to read liquid level value of device [" + deviceId + "] via MQTT");
}
return response;
// return response;
}
}

@ -96,7 +96,7 @@ public class ConnectedCupMQTTConnector extends MQTTTransportHandler {
MqttMessage pushMessage = new MqttMessage();
String publishTopic =
serverName + File.separator + deviceOwner + File.separator +
"wso2" + File.separator + deviceOwner + File.separator +
ConnectedCupConstants.DEVICE_TYPE + File.separator + deviceId;
try {
@ -110,7 +110,7 @@ public class ConnectedCupMQTTConnector extends MQTTTransportHandler {
publishToQueue(publishTopic, pushMessage);
} catch (Exception e) {
String errorMsg = "Preparing Secure payload failed for device - [" + deviceId + "] of owner - " +
String errorMsg = "Preparing payload failed for device - [" + deviceId + "] of owner - " +
"[" + deviceOwner + "].";
log.error(errorMsg);
throw new TransportHandlerException(errorMsg, e);
@ -122,33 +122,55 @@ public class ConnectedCupMQTTConnector extends MQTTTransportHandler {
public void processIncomingMessage(MqttMessage mqttMessage, String... strings) throws TransportHandlerException {
String topic = strings[0];
String ownerAndId = topic.replace("wso2" + File.separator + "iot" + File.separator, "");
String ownerAndId = topic.replace("wso2" + File.separator, "");
ownerAndId = ownerAndId.replace(File.separator + ConnectedCupConstants.DEVICE_TYPE + File.separator, ":");
ownerAndId = ownerAndId.replace(File.separator + "connectedcup_publisher", "");
ownerAndId = ownerAndId.replace(File.separator + "connected_publisher", "");
String owner = ownerAndId.split(":")[0];
String deviceId = ownerAndId.split(":")[1];
// String actualMessage = mqttMessage.toString();
String[] messageData = mqttMessage.toString().split(":");
Float value = Float.valueOf(messageData[1]);
switch (messageData[0]){
case "temperature":
SensorDataManager.getInstance().setSensorRecord(deviceId, ConnectedCupConstants.SENSOR_TEMPERATURE,
// if (actualMessage.contains("PUBLISHER")) {
// float temperature = Float.parseFloat(actualMessage.split(":")[2]);
//
// if (!ConnectedCupServiceUtils.publishToDAS(owner, deviceId, messageData[0], value)) {
// log.error("MQTT Subscriber: Publishing data to DAS failed.");
// }
//
// if (log.isDebugEnabled()) {
// log.debug("MQTT Subscriber: Published data to DAS successfully.");
// }
//
// } else if (actualMessage.contains("TEMPERATURE")) {
// String temperatureValue = actualMessage.split(":")[1];
// SensorDataManager.getInstance().setSensorRecord(deviceId, ConnectedCupConstants.SENSOR_TEMPERATURE,
// temperatureValue,
// Calendar.getInstance().getTimeInMillis());
// }
//
//
switch(messageData[0]) {
case "temperature": SensorDataManager.getInstance().setSensorRecord(deviceId, ConnectedCupConstants.SENSOR_TEMPERATURE,
String.valueOf(messageData[1]),
Calendar.getInstance().getTimeInMillis());
ConnectedCupServiceUtils.publishToDAS(owner, deviceId, value);
break;
case "coffeelevel":
SensorDataManager.getInstance().setSensorRecord(deviceId, ConnectedCupConstants.SENSOR_TEMPERATURE,
case "coffeelevel": SensorDataManager.getInstance().setSensorRecord(deviceId, ConnectedCupConstants.SENSOR_LEVEL,
String.valueOf(messageData[1]),
Calendar.getInstance().getTimeInMillis());
ConnectedCupServiceUtils.publishToDAS(owner, deviceId, value);
break;
}
log.info("Received MQTT message for OWNER: " + owner + " DEVICE.ID: " + deviceId + " | Command: " +
messageData[0] +" " + messageData[1] );
ConnectedCupServiceUtils.publishToDAS(owner, deviceId, messageData[0], value);
if (log.isDebugEnabled()) {
log.debug("Received MQTT message for OWNER: " + owner + " DEVICE.ID: " + deviceId + " | Command: " +
messageData[0] +" " + messageData[1] );
}
}

@ -25,7 +25,7 @@
http://cxf.apache.org/jaxrs http://cxf.apache.org/schemas/jaxrs.xsd">
<jaxrs:server id="ConnectedCupController" address="/connectedcup">
<jaxrs:server id="ConnectedCupController" address="/">
<jaxrs:serviceBeans>
<bean id="ConnectedCupControllerService"
class="org.coffeeking.controller.service.ConnectedCupControllerService">

@ -40,7 +40,7 @@
<module>plugin</module>
<module>controller</module>
<module>manager</module>
<module>connected-cup-agent</module>
</modules>
<build>

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8"?>
<artifact name="Eventreceiver_coffeelevel" version="1.0.0" type="event/receiver" serverRole="DataAnalyticsServer">
<file>Eventreceiver_coffeelevel.xml</file>
<file>EventReceiver_coffeelevel.xml</file>
</artifact>

@ -1,12 +1,12 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Analytics>
<Name>IoTServer_Sensor_Script</Name>
<Name>CoffeeLevel_Sensor_Script</Name>
<Script>
CREATE TEMPORARY TABLE DeviceCoffeeLevelData USING CarbonAnalytics OPTIONS(tableName
"ORG_WSO2_IOT_DEVICES_COFFEELEVEL");
CREATE TEMPORARY TABLE DeviceCoffeeLevelSummaryData USING CarbonAnalytics OPTIONS (tableName
"DEVICE_COFFEE_LEVEL_SUMMARY", schema "coffeelevel FLOAT, deviceType STRING -i, deviceId STRING -i, owner
"DEVICE_COFFEELEVEL_SUMMARY", schema "coffeelevel FLOAT, deviceType STRING -i, deviceId STRING -i, owner
STRING -i,
time LONG -i",primaryKeys "deviceType, deviceId, owner, time");

@ -1,6 +1,6 @@
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<Analytics>
<Name>IoTServer_Sensor_Script</Name>
<Name>Temperature_Sensor_Script</Name>
<Script>
CREATE TEMPORARY TABLE DeviceTemperatureData USING CarbonAnalytics OPTIONS(tableName "ORG_WSO2_IOT_DEVICES_TEMPERATURE");

Loading…
Cancel
Save