forked from community/product-iots
parent
bf5fad5409
commit
e9dc4c9097
2
modules/samples/virtual_firealarm/src/org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/virtual/firealarm/service/impl/util/DeviceJSON.java → modules/samples/virtual_firealarm/src/org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/virtual/firealarm/service/impl/dao/DeviceJSON.java
2
modules/samples/virtual_firealarm/src/org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/virtual/firealarm/service/impl/util/DeviceJSON.java → modules/samples/virtual_firealarm/src/org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl/src/main/java/org/wso2/carbon/device/mgt/iot/sample/virtual/firealarm/service/impl/dao/DeviceJSON.java
@ -1,4 +1,4 @@
|
||||
package org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl.util;
|
||||
package org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl.dao;
|
||||
|
||||
import org.codehaus.jackson.annotate.JsonIgnoreProperties;
|
||||
|
@ -0,0 +1,41 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl.dao;
|
||||
|
||||
import javax.xml.bind.annotation.XmlElement;
|
||||
import javax.xml.bind.annotation.XmlRootElement;
|
||||
|
||||
@XmlRootElement
|
||||
public class TemperatureRecord {
|
||||
private double temperature;
|
||||
private long time;
|
||||
|
||||
public TemperatureRecord(double temperature, long time) {
|
||||
this.temperature = temperature;
|
||||
this.time = time;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public double getTemperature() {
|
||||
return temperature;
|
||||
}
|
||||
|
||||
@XmlElement
|
||||
public long getTime() {
|
||||
return time;
|
||||
}
|
||||
}
|
@ -0,0 +1,45 @@
|
||||
/*
|
||||
* 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.
|
||||
*/
|
||||
|
||||
package org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl.util;
|
||||
|
||||
import org.wso2.carbon.device.mgt.iot.sample.virtual.firealarm.service.impl.dao.TemperatureRecord;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class DataHolder {
|
||||
|
||||
private static DataHolder thisInstance = new DataHolder();
|
||||
private Map<String, TemperatureRecord> temperatureMap = new HashMap<>();
|
||||
|
||||
private DataHolder() {
|
||||
|
||||
}
|
||||
|
||||
public static DataHolder getThisInstance() {
|
||||
return thisInstance;
|
||||
}
|
||||
|
||||
public TemperatureRecord getTemperature(String deviceId) {
|
||||
return temperatureMap.get(deviceId);
|
||||
}
|
||||
|
||||
public void setTemperature(String deviceId, double temperature, long time){
|
||||
temperatureMap.put(deviceId, new TemperatureRecord(temperature, time));
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in new issue