¶Ô±ÈÐÂÎļþ |
| | |
| | | package org.jeecg.modules.dry.controller; |
| | | |
| | | import com.kangaroohy.milo.model.ReadWriteEntity; |
| | | import com.kangaroohy.milo.service.MiloService; |
| | | import io.swagger.annotations.Api; |
| | | import io.swagger.annotations.ApiOperation; |
| | | import lombok.extern.slf4j.Slf4j; |
| | | import org.eclipse.milo.opcua.sdk.client.OpcUaClient; |
| | | import org.eclipse.milo.opcua.stack.core.types.builtin.DataValue; |
| | | import org.eclipse.milo.opcua.stack.core.types.builtin.NodeId; |
| | | import org.eclipse.milo.opcua.stack.core.types.builtin.StatusCode; |
| | | import org.eclipse.milo.opcua.stack.core.types.builtin.Variant; |
| | | import org.jeecg.common.api.vo.Result; |
| | | import org.jeecg.modules.dry.entity.DryOpcDevice; |
| | | import org.jeecg.modules.dry.service.IDryOpcDeviceService; |
| | | import org.jeecg.modules.dry.vo.CommandMessageVo; |
| | | import org.springframework.beans.factory.annotation.Autowired; |
| | | import org.springframework.web.bind.annotation.PostMapping; |
| | | import org.springframework.web.bind.annotation.RequestBody; |
| | | import org.springframework.web.bind.annotation.RequestMapping; |
| | | import org.springframework.web.bind.annotation.RestController; |
| | | |
| | | import java.util.List; |
| | | import java.util.concurrent.ExecutionException; |
| | | |
| | | /** |
| | | * opcæ§å¶å¨ï¼ç¨äºæ§å¶ç°åºæåå¤´çµæºï¼ç¯çå¼å
³ |
| | | */ |
| | | |
| | | @Api(tags="OPCæ§å¶å¨") |
| | | @RestController |
| | | @RequestMapping("/dry/opc") |
| | | @Slf4j |
| | | public class OpcController { |
| | | |
| | | @Autowired |
| | | private MiloService miloService; |
| | | |
| | | @Autowired |
| | | private IDryOpcDeviceService opcDeviceService; |
| | | |
| | | |
| | | @ApiOperation(value="å鿧嶿令", notes="åæå¡ç«¯å鿧嶿令ï¼ç±æå¡ç«¯è½¬åç»æ§å¶æ¨¡å") |
| | | @PostMapping("/sendWriteCommand") |
| | | public Result<?> sendWriteCommand(@RequestBody CommandMessageVo msgVo) throws Exception { |
| | | |
| | | miloService.writeToOpcUa(ReadWriteEntity.builder() |
| | | .identifier(msgVo.getCode()) |
| | | //Kep䏿¯Booleanç±»å |
| | | .value(Boolean.valueOf(msgVo.getMsg())) |
| | | .build()); |
| | | return Result.OK(); |
| | | } |
| | | |
| | | @ApiOperation(value="å鿧嶿令", notes="åæå¡ç«¯å鿧嶿令ï¼ç±æå¡ç«¯è½¬åç»æ§å¶æ¨¡å") |
| | | @PostMapping("/initDevice") |
| | | public Result<?> initDevice() throws Exception { |
| | | List<DryOpcDevice> list = opcDeviceService.list(); |
| | | |
| | | list.forEach(item -> { |
| | | |
| | | }); |
| | | |
| | | return Result.OK(); |
| | | } |
| | | } |