Skip to content

Commit

Permalink
Merge pull request #329 from pahnjy/develop
Browse files Browse the repository at this point in the history
Log 수정 #320
  • Loading branch information
pahnjy authored Jan 16, 2017
2 parents e891208 + 95d6df2 commit 00758a0
Show file tree
Hide file tree
Showing 4 changed files with 75 additions and 20 deletions.
Original file line number Diff line number Diff line change
@@ -1,28 +1,33 @@
package com.pineone.icbms.so.device.entity;

import java.util.List;

public class DeviceTransFormObject {

private String id;
private String id;
private String deviceName;
private String deviceLocation;
private String deviceUri;
private String deviceCommand;
private String deviceServices;
private String deviceStatus;
private List<String> deviceCommand;
private List<String> deviceServices;
private long deviceCreateTime;
private long deviceExfiredTime;
private String deviceStatus;
private String sessionId;

public DeviceTransFormObject() {
}

public DeviceTransFormObject(String id, String deviceName, String deviceLocation, String deviceUri, String deviceCommand, String deviceServices, String deviceStatus, String sessionId) {
public DeviceTransFormObject(String id, String deviceName, String deviceLocation, String deviceUri, List<String> deviceCommand, List<String> deviceServices, long deviceCreateTime, long deviceExfiredTime, String deviceStatus) {
this.id = id;
this.deviceName = deviceName;
this.deviceLocation = deviceLocation;
this.deviceUri = deviceUri;
this.deviceCommand = deviceCommand;
this.deviceServices = deviceServices;
this.deviceCreateTime = deviceCreateTime;
this.deviceExfiredTime = deviceExfiredTime;
this.deviceStatus = deviceStatus;
this.sessionId = sessionId;
}

public String getId() {
Expand Down Expand Up @@ -57,22 +62,38 @@ public void setDeviceUri(String deviceUri) {
this.deviceUri = deviceUri;
}

public String getDeviceCommand() {
public List<String> getDeviceCommand() {
return deviceCommand;
}

public void setDeviceCommand(String deviceCommand) {
public void setDeviceCommand(List<String> deviceCommand) {
this.deviceCommand = deviceCommand;
}

public String getDeviceServices() {
public List<String> getDeviceServices() {
return deviceServices;
}

public void setDeviceServices(String deviceServices) {
public void setDeviceServices(List<String> deviceServices) {
this.deviceServices = deviceServices;
}

public long getDeviceCreateTime() {
return deviceCreateTime;
}

public void setDeviceCreateTime(long deviceCreateTime) {
this.deviceCreateTime = deviceCreateTime;
}

public long getDeviceExfiredTime() {
return deviceExfiredTime;
}

public void setDeviceExfiredTime(long deviceExfiredTime) {
this.deviceExfiredTime = deviceExfiredTime;
}

public String getDeviceStatus() {
return deviceStatus;
}
Expand All @@ -81,6 +102,10 @@ public void setDeviceStatus(String deviceStatus) {
this.deviceStatus = deviceStatus;
}

public boolean checkStatus(String status){
return this.deviceStatus.equals(status);
}

public String getSessionId() {
return sessionId;
}
Expand All @@ -91,15 +116,16 @@ public void setSessionId(String sessionId) {

@Override
public String toString() {
return "DeviceTransFormObject{" +
return "Device{" +
"id='" + id + '\'' +
", deviceName='" + deviceName + '\'' +
", deviceLocation='" + deviceLocation + '\'' +
", deviceUri='" + deviceUri + '\'' +
", deviceCommand='" + deviceCommand + '\'' +
", deviceServices='" + deviceServices + '\'' +
", deviceCommand=" + deviceCommand +
", deviceServices=" + deviceServices +
", deviceCreateTime='" + deviceCreateTime + '\'' +
", deviceExfiredTime='" + deviceExfiredTime + '\'' +
", deviceStatus='" + deviceStatus + '\'' +
", sessionId='" + sessionId + '\'' +
'}';
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,10 @@ public interface DeviceManager {
Device deviceSearchById(String deviceId);
List<Device> deviceSearchByLocation(String location);
List<String> requestDeviceServiceList(String location);
String searchOperation(String de, String deviceService);
String searchOperation(String deviceId, String deviceService);
List<Device> searchDeviceList();
void deviceUpdate(DeviceStatusData deviceStatusData);
String deviceSubscription(String uri, String commandId);
String deviceSubscriptionRelease(String uri);
void produceDevice(Device device);
}
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,11 @@ public String deviceSubscriptionRelease(String uri) {
return deviceControlProxy.deviceSubscriptionReleaseRequest(uri);
}

@Override
public void produceDevice(Device device) {
deviceCreate(device);
}

private DeviceControlMessage deviceDataConversion(String deviceId, String commandId, String deviceCommand){
DeviceControlMessage deviceControlMessage = new DeviceControlMessage();

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@
package com.pineone.icbms.so.device.pr;

import com.pineone.icbms.so.device.entity.*;
import com.pineone.icbms.so.device.entity.Device;
import com.pineone.icbms.so.device.entity.DeviceStatusData;
import com.pineone.icbms.so.device.entity.DeviceTransFormObject;
import com.pineone.icbms.so.device.entity.deviceReleaseMessage;
import com.pineone.icbms.so.device.logic.DeviceManager;
import com.pineone.icbms.so.util.logprint.LogPrint;
import org.slf4j.Logger;
Expand All @@ -9,6 +12,7 @@
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.List;


Expand Down Expand Up @@ -45,12 +49,24 @@ public String deviceControl(@RequestBody DeviceTransFormObject deviceTransFormOb
logger.info("<================ Device Control Start ================>");
logger.debug(LogPrint.LogMethodNamePrint() + " | Device ID = " + deviceTransFormObject.getId() + " , DeviceCommand = " + deviceTransFormObject.getDeviceCommand() + " , Session ID = " + deviceTransFormObject.getSessionId());

String result = deviceManager.deviceExecute(deviceTransFormObject.getId(), deviceTransFormObject.getDeviceCommand(), deviceTransFormObject.getSessionId());
String result = deviceManager.deviceExecute(deviceTransFormObject.getId(), deviceTransFormObject.getDeviceCommand().get(0), deviceTransFormObject.getSessionId());
logger.debug(LogPrint.LogMethodNamePrint() + " | Result = " + result);
logger.info("<================ Device Control End ================>");
return result;
}

/**
* Device 등록 요청
*/
@RequestMapping(value = "",method = RequestMethod.POST)
@ResponseStatus(value = HttpStatus.OK)
public void deviceCreate(@RequestBody DeviceTransFormObject deviceTransFormObject){
logger.debug(LogPrint.LogMethodNamePrint() + " | Device = " + deviceTransFormObject.toString());
deviceManager.produceDevice(DeviceMapping(deviceTransFormObject));
}



/**
* Device List 검색.
*/
Expand Down Expand Up @@ -140,7 +156,7 @@ public void deviceDisableNotification(@RequestBody deviceReleaseMessage message)
public String findDeviceOperation(@RequestBody DeviceTransFormObject deviceTransFormObject){
logger.info(LogPrint.inputInfoLogPrint() + "Device ID = " + deviceTransFormObject.getId());
logger.debug("Device = " + deviceTransFormObject.toString());
return deviceManager.searchOperation(deviceTransFormObject.getId(), deviceTransFormObject.getDeviceServices());
return deviceManager.searchOperation(deviceTransFormObject.getId(), deviceTransFormObject.getDeviceServices().get(0));
}

/**
Expand All @@ -158,13 +174,20 @@ public void updateDeviceStatus(@RequestBody DeviceStatusData deviceStatusData){
public DeviceTransFormObject settingDeviceRequestData(String deviceid, String command, String sessionId){
DeviceTransFormObject object = new DeviceTransFormObject();
object.setId(deviceid);
object.setDeviceCommand(command);
object.setDeviceCommand(Arrays.asList(new String[]{command}));
object.setSessionId(sessionId);
return object;
}



private Device DeviceMapping(DeviceTransFormObject deviceTransFormObject)
{
if(deviceTransFormObject == null){
return null;
}
Device device = new Device(deviceTransFormObject.getId(),deviceTransFormObject.getDeviceName(),deviceTransFormObject.getDeviceLocation(),deviceTransFormObject.getDeviceUri(),deviceTransFormObject.getDeviceCommand(),deviceTransFormObject.getDeviceServices(),deviceTransFormObject.getDeviceCreateTime(),deviceTransFormObject.getDeviceExfiredTime(),deviceTransFormObject.getDeviceStatus());
return device;
}


}

0 comments on commit 00758a0

Please sign in to comment.