|
|
@@ -13,6 +13,7 @@ import io.swagger.annotations.ApiOperation;
|
|
|
import io.swagger.annotations.ApiParam;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
+import org.springframework.web.bind.annotation.PostMapping;
|
|
|
import org.springframework.web.bind.annotation.RequestMapping;
|
|
|
import org.springframework.web.bind.annotation.RestController;
|
|
|
|
|
|
@@ -41,7 +42,7 @@ public class ProtocolController {
|
|
|
@ApiOperation(value = "统一获取数据接口")
|
|
|
public AjaxResult getValues(@ApiParam(name = "modbus请求参数", value = "modbus请求参数", required = true) DeviceRequest request) throws ModbusProtocolException, ModbusNumberException, ModbusIOException {
|
|
|
List<Object> values = null;
|
|
|
- switch (request.getProtocol()){
|
|
|
+ switch (request.getProtocol()){
|
|
|
case ProtocolConstants.MODBUS_TCP:
|
|
|
modbusTcpService.getValues(request);
|
|
|
break;
|
|
|
@@ -57,6 +58,22 @@ public class ProtocolController {
|
|
|
return success(values);
|
|
|
}
|
|
|
|
|
|
+ @PostMapping("/setValues")
|
|
|
+ @ApiOperation(value = "统一设置数据接口")
|
|
|
+ public AjaxResult setValues(@ApiParam(name = "modbus请求参数", value = "modbus请求参数", required = true) DeviceRequest request) throws ModbusProtocolException, ModbusNumberException, ModbusIOException {
|
|
|
+ switch (request.getProtocol()){
|
|
|
+ case ProtocolConstants.MODBUS_TCP:
|
|
|
+ modbusTcpService.setValue(request);
|
|
|
+ break;
|
|
|
+ case ProtocolConstants.OPC_UA:
|
|
|
+ break;
|
|
|
+ case ProtocolConstants.MQTT:
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ }
|
|
|
+ return success();
|
|
|
+ }
|
|
|
+
|
|
|
// @PostMapping("/setCoils")
|
|
|
// @ApiOperation(value = "modbus tcp 设置多个线圈数据")
|
|
|
// public void setCoils(@ApiParam(name = "modbus请求参数", value = "modbus请求参数", required = true) DeviceRequest request) throws ModbusProtocolException, ModbusNumberException, ModbusIOException {
|