This commit is contained in:
caixiang
2023-02-25 14:19:33 +08:00
parent cdc06bd733
commit fed8f82ff0
20 changed files with 666 additions and 1710 deletions

View File

@@ -1,17 +1,29 @@
package com.cnbm.packing.controller;
import com.cnbm.common.constant.Constant;
import com.cnbm.dispatch.enums.kuka.step1.Step1Mes2PlcVar;
import com.cnbm.dispatch.enums.kuka.step1.Step1Plc2MesVar;
import com.cnbm.dispatch.enums.kuka.step2.Step2Mes2PlcVar;
import com.cnbm.dispatch.enums.kuka.step2.Step2Plc2MesVar;
import com.cnbm.dispatch.enums.kuka.step3.Step3Mes2PlcVar;
import com.cnbm.dispatch.enums.kuka.step3.Step3Plc2MesVar;
import com.cnbm.packing.service.DynamicDataSourceService;
import com.cnbm.s7.entity.R;
import com.cnbm.s7.s7connector.enmuc.S7Client;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.cnbm.common.utils.Result;
import springfox.documentation.annotations.ApiIgnore;
import java.io.UnsupportedEncodingException;
import java.text.ParseException;
import java.util.Map;
/**
* @Author weihongyang
* @Date 2022/6/24 8:57 AM
@@ -22,8 +34,104 @@ import java.util.Map;
@Api(tags="测试接口")
public class TestController {
private static final Logger logger = LoggerFactory.getLogger(TestController.class);
@Autowired
DynamicDataSourceService service;
private Object read(S7Client s7Client,Step1Plc2MesVar var) throws UnsupportedEncodingException, ParseException {
try {
return s7Client.read(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getLength(), var.getStrSize(), var.getType());
}catch (Exception e){
e.printStackTrace();
return null;
}
}
private Object read(S7Client s7Client,Step1Mes2PlcVar var) throws UnsupportedEncodingException, ParseException {
try {
return s7Client.read(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getLength(), var.getStrSize(), var.getType());
}catch (Exception e){
e.printStackTrace();
return null;
}
}
private Object read(S7Client s7Client,Step2Plc2MesVar var) throws UnsupportedEncodingException, ParseException {
try {
return s7Client.read(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getLength(), var.getStrSize(), var.getType());
}catch (Exception e){
e.printStackTrace();
return null;
}
}
private Object read(S7Client s7Client,Step2Mes2PlcVar var) throws UnsupportedEncodingException, ParseException {
try {
return s7Client.read(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getLength(), var.getStrSize(), var.getType());
}catch (Exception e){
e.printStackTrace();
return null;
}
}
private Object read(S7Client s7Client,Step3Plc2MesVar var) throws UnsupportedEncodingException, ParseException {
try {
return s7Client.read(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getLength(), var.getStrSize(), var.getType());
}catch (Exception e){
e.printStackTrace();
return null;
}
}
private Object read(S7Client s7Client,Step3Mes2PlcVar var) throws UnsupportedEncodingException, ParseException {
try {
return s7Client.read(var.getArea(), var.getAreaNumber(), var.getByteOffset(), var.getBitOffset(), var.getLength(), var.getStrSize(), var.getType());
}catch (Exception e){
e.printStackTrace();
return null;
}
}
@PostMapping("/testReadAll")
public R testReadAll() throws UnsupportedEncodingException, ParseException {
for(Step1Plc2MesVar actual:Step1Plc2MesVar.values()){
logger.info(read(S7Client.S7_KUKA,actual).toString());
System.out.println(actual.getName().toString()+" : "+read(S7Client.S7_KUKA,actual).toString());
}
for(Step1Mes2PlcVar actual:Step1Mes2PlcVar.values()){
logger.info(read(S7Client.S7_KUKA,actual).toString());
System.out.println(actual.getName().toString()+" : "+read(S7Client.S7_KUKA,actual).toString());
}
for(Step2Plc2MesVar actual:Step2Plc2MesVar.values()){
logger.info(read(S7Client.S7_KUKA,actual).toString());
System.out.println(actual.getName().toString()+" : "+read(S7Client.S7_KUKA,actual).toString());
}
for(Step2Mes2PlcVar actual:Step2Mes2PlcVar.values()){
logger.info(read(S7Client.S7_KUKA,actual).toString());
System.out.println(actual.getName().toString()+" : "+read(S7Client.S7_KUKA,actual).toString());
}
for(Step3Plc2MesVar actual:Step3Plc2MesVar.values()){
logger.info(read(S7Client.S7_KUKA,actual).toString());
System.out.println(actual.getName().toString()+" : "+read(S7Client.S7_KUKA,actual).toString());
}
for(Step3Mes2PlcVar actual:Step3Mes2PlcVar.values()){
logger.info(read(S7Client.S7_KUKA,actual).toString());
System.out.println(actual.getName().toString()+" : "+read(S7Client.S7_KUKA,actual).toString());
}
return R.ok();
}
@PostMapping("/testlogger")
public R testlogger() {
logger.info("test logger");
System.out.println("test logger");
return R.ok();
}
@PostMapping("getPMPPBySubId")
@ApiImplicitParams({
@ApiImplicitParam(name = "subId", value = "基板ID", paramType = "query", required = true, dataTypeClass=Integer.class) ,