|
|
@ -1,5 +1,6 @@ |
|
|
|
package org.nl.acs.device_driver.autodoor.standard_autodoor; |
|
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
|
import lombok.Data; |
|
|
|
import lombok.RequiredArgsConstructor; |
|
|
@ -13,14 +14,18 @@ import org.nl.acs.device_driver.driver.ExecutableDeviceDriver; |
|
|
|
import org.nl.acs.ext.wms.data.one.feedBackTaskStatus.FeedBackTaskStatusRequest; |
|
|
|
import org.nl.acs.ext.wms.service.AcsToWmsService; |
|
|
|
import org.nl.acs.instruction.service.InstructionService; |
|
|
|
import org.nl.acs.log.service.DeviceExecuteLogService; |
|
|
|
import org.nl.acs.route.service.RouteLineService; |
|
|
|
import org.nl.acs.task.service.TaskService; |
|
|
|
import org.nl.acs.utils.ReadUtil; |
|
|
|
import org.nl.config.SpringContextHolder; |
|
|
|
import org.nl.system.service.lucene.LuceneExecuteLogService; |
|
|
|
import org.nl.system.service.lucene.dto.LuceneLogDto; |
|
|
|
import org.openscada.opc.lib.da.Server; |
|
|
|
|
|
|
|
import java.util.Date; |
|
|
|
import java.util.HashMap; |
|
|
|
import java.util.LinkedHashMap; |
|
|
|
import java.util.Map; |
|
|
|
|
|
|
|
/** |
|
|
@ -34,6 +39,8 @@ public class StandardAutodoorDeviceDriver extends AbstractOpcDeviceDriver implem |
|
|
|
|
|
|
|
InstructionService instructionService = SpringContextHolder.getBean("instructionServiceImpl"); |
|
|
|
|
|
|
|
LuceneExecuteLogService lucene = SpringContextHolder.getBean("luceneExecuteLogServiceImpl"); |
|
|
|
|
|
|
|
DeviceService deviceservice = SpringContextHolder.getBean("deviceServiceImpl"); |
|
|
|
|
|
|
|
RouteLineService routelineserver = SpringContextHolder.getBean("routeLineServiceImpl"); |
|
|
@ -129,26 +136,70 @@ public class StandardAutodoorDeviceDriver extends AbstractOpcDeviceDriver implem |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void writing(String param, int command) { |
|
|
|
String to_command = String.format("%s.%s.%s.%s", this.getDevice().getOpc_server_code(), this.getDevice().getOpc_plc_code(), this.getDevice().getDevice_code(), param); |
|
|
|
/** |
|
|
|
* 多个信号一起下发电气 |
|
|
|
* |
|
|
|
* @param map |
|
|
|
*/ |
|
|
|
|
|
|
|
public void writing(Map<String, Object> map) { |
|
|
|
LuceneExecuteLogService lucene = SpringContextHolder.getBean(LuceneExecuteLogService.class); |
|
|
|
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl"); |
|
|
|
Map<String, Object> itemMap = new LinkedHashMap<>(); |
|
|
|
map.forEach((key, value) -> { |
|
|
|
if (ObjectUtil.isNotEmpty(value)) { |
|
|
|
itemMap.put(getToParam() + key, value); |
|
|
|
} |
|
|
|
}); |
|
|
|
if (ObjectUtil.isNotEmpty(itemMap)) { |
|
|
|
try { |
|
|
|
this.checkcontrol(itemMap); |
|
|
|
} catch (Exception e) { |
|
|
|
e.printStackTrace(); |
|
|
|
try{ |
|
|
|
this.checkcontrol(itemMap); |
|
|
|
} catch (Exception e1){ |
|
|
|
e1.printStackTrace(); |
|
|
|
} |
|
|
|
} |
|
|
|
logServer.deviceExecuteLog(this.getDevice().getDevice_code(), "", "", "下发多个电气信号:" + itemMap); |
|
|
|
lucene.deviceExecuteLog(new LuceneLogDto(this.getDeviceCode(), "下发多个电气信号:" + itemMap)); |
|
|
|
} |
|
|
|
} |
|
|
|
/** |
|
|
|
* 抽取统一下发电气信号前缀 |
|
|
|
* |
|
|
|
* @return |
|
|
|
*/ |
|
|
|
public String getToParam() { |
|
|
|
return this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() + "."; |
|
|
|
} |
|
|
|
|
|
|
|
public void writing(String param, String value) { |
|
|
|
|
|
|
|
String to_param = this.getDevice().getOpc_server_code() + "." + this.getDevice().getOpc_plc_code() + "." + this.getDevice().getDevice_code() |
|
|
|
+ "." + param; |
|
|
|
String opcservcerid = this.getDevice().getOpc_server_id(); |
|
|
|
Server server = ReadUtil.getServer(opcservcerid); |
|
|
|
Map<String, Object> itemMap = new HashMap<String, Object>(); |
|
|
|
itemMap.put(to_command, command); |
|
|
|
if (value instanceof String) { |
|
|
|
itemMap.put(to_param, value); |
|
|
|
} else { |
|
|
|
itemMap.put(to_param, value); |
|
|
|
} |
|
|
|
ReadUtil.write(itemMap, server); |
|
|
|
log.info("下发PLC信号:{},{}", to_command, command); |
|
|
|
System.out.println("设备:" + devicecode + ",下发PLC信号:" + to_command + ",value:" + command); |
|
|
|
|
|
|
|
server.disconnect(); |
|
|
|
log.info("下发PLC信号:{},{}", this.devicecode, "to_command:" + value); |
|
|
|
lucene.deviceExecuteLog(new LuceneLogDto(this.devicecode, message + param + " 写入 " + value)); |
|
|
|
} |
|
|
|
|
|
|
|
public synchronized void OpenOrClose(String type) { |
|
|
|
|
|
|
|
//开门
|
|
|
|
if (CommonFinalParam.ONE.equals(type)) { |
|
|
|
writing(ItemProtocol.item_to_command, 1); |
|
|
|
writing(ItemProtocol.item_to_command, "1"); |
|
|
|
} else { |
|
|
|
writing(ItemProtocol.item_to_command, 2); |
|
|
|
writing(ItemProtocol.item_to_command, "2"); |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|