rev 对接工位信号写入

This commit is contained in:
USER-20220102CG\noblelift
2024-06-27 20:35:45 +08:00
parent ce1d9377d5
commit 2134dcfd33
2 changed files with 66 additions and 20 deletions

View File

@@ -42,6 +42,9 @@ import java.util.Map;
@RequiredArgsConstructor
public class ManipulatorAgvStationDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, RouteableDeviceDriver, DeviceStageMonitor, FeedLmsRealFailed {
protected ItemProtocol itemProtocol = new ItemProtocol(this);
protected ToCommandControl toCommandControl = new ToCommandControl(this);
@Autowired
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
@Autowired
@@ -99,6 +102,10 @@ public class ManipulatorAgvStationDeviceDriver extends AbstractOpcDeviceDriver i
return this.device;
}
public ToCommandControl getToCommandControl() {
return this.toCommandControl;
}
/**
* 请求成功标记
*/
@@ -210,30 +217,38 @@ public class ManipulatorAgvStationDeviceDriver extends AbstractOpcDeviceDriver i
this.setRequireSucess(false);
}
public void writing(int command) {
String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
+ "." + org.nl.acs.device_driver.two_conveyor.hongxiang_conveyor.ItemProtocol.item_to_command;
Map<String, Object> itemMap = new HashMap<String, Object>();
itemMap.put(to_command, command);
LuceneLogDto logDto = LuceneLogDto.builder()
.device_code(device_code)
.content("下发电气信号:" + itemMap)
.build();
logDto.setLog_level(3);
luceneExecuteLogService.deviceExecuteLog(logDto);
try {
this.checkcontrol(itemMap);
} catch (Exception e) {
public void writing(int command){
// String to_command = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code()
// + "." + org.nl.acs.device_driver.two_conveyor.hongxiang_conveyor.ItemProtocol.item_to_command;
// Map<String, Object> itemMap = new HashMap<String, Object>();
// itemMap.put(to_command, command);
// LuceneLogDto logDto = LuceneLogDto.builder()
// .device_code(device_code)
// .content("下发电气信号:" + itemMap)
// .build();
// logDto.setLog_level(3);
// luceneExecuteLogService.deviceExecuteLog(logDto);
// try {
// this.checkcontrol(itemMap);
// } catch (Exception e) {
// e.printStackTrace();
// try {
// this.checkcontrol(itemMap);
// } catch (Exception e1) {
// e1.printStackTrace();
// }
// }
try{
this.toCommandControl.control(command);
} catch (Exception e){
e.printStackTrace();
try {
this.checkcontrol(itemMap);
} catch (Exception e1) {
e1.printStackTrace();
}
}
}
@Override
@Override
public JSONObject getDeviceStatusName() {
JSONObject jo = new JSONObject();
String mode = "";

View File

@@ -0,0 +1,31 @@
package org.nl.acs.device_driver.two_conveyor.manipulator_agv_station;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.alibaba.fastjson.JSONObject;
import org.nl.acs.device_driver.driver.ItemValue;
import org.nl.acs.device_driver.stacker.standard_stacker.ItemProtocol;
import org.nl.acs.device_driver.stacker.standard_stacker.StandardStackerDeviceDriver;
import java.util.HashMap;
import java.util.Map;
public class ToCommandControl {
private ManipulatorAgvStationDeviceDriver driver;
public ToCommandControl(ManipulatorAgvStationDeviceDriver driver) {
this.driver = driver;
}
public void control(int command) throws Exception {
// ItemValue[] itemValues = new ItemValue[]{new ItemValue(this.driver.getItem(ItemProtocol.item_to_command), command)};
Map<String, Object> itemMap = new HashMap<String, Object>();
String to_param = this.driver.getOpcServer() + "." + this.driver.getOpcPlc() + "." + this.driver.getDevice().getDevice_code()
+ ".to_command";
Object obj = command;
itemMap.put(to_param, obj);
this.driver.checkcontrol(itemMap);
}
}