add:告警灯
This commit is contained in:
@@ -8,6 +8,7 @@ import org.nl.acs.agv.server.NDCAgvService;
|
||||
import org.nl.acs.device.domain.Device;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device_driver.basedriver.agv.ndcone.AgvNdcOneDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.guard_lamp.GuardLampDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.standard_autodoor.StandardAutodoorDeviceDriver;
|
||||
import org.nl.acs.ext.wms.service.AcsToWmsService;
|
||||
import org.nl.acs.ext.wms.service.impl.AcsToWmsServiceImpl;
|
||||
@@ -248,41 +249,45 @@ public class OneNDCSocketConnectionAutoRun extends AbstractAutoRunnable {
|
||||
}
|
||||
}
|
||||
} else if (phase == 0x50) {
|
||||
if (ObjectUtil.isEmpty(device_code)) {
|
||||
log.info(agvaddr + "对应设备号为空!");
|
||||
log.info("进入告警区域");
|
||||
if (agvaddr == 0) {
|
||||
log.info("BJD" + agvaddr + "对应设备号为空!");
|
||||
return;
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(device)) {
|
||||
if (device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) {
|
||||
standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver();
|
||||
String is_enter = standardAutodoorDeviceDriver.getExtraValue().get("is_enter").toString();
|
||||
if (StrUtil.isNotBlank(is_enter) && "false".equals(is_enter)) {
|
||||
Device bjdDevice = deviceAppService.findDeviceByCode("BJD" + agvaddr);
|
||||
if (ObjectUtil.isNotEmpty(bjdDevice)) {
|
||||
if (bjdDevice.getDeviceDriver() instanceof GuardLampDeviceDriver) {
|
||||
try {
|
||||
GuardLampDeviceDriver guardLampDeviceDriver = (GuardLampDeviceDriver) bjdDevice.getDeviceDriver();
|
||||
guardLampDeviceDriver.writing("to_open", "1");
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
|
||||
} else {
|
||||
log.info("区域已锁定,请释放后在进入");
|
||||
} catch (Exception e) {
|
||||
log.info("下发告警灯告警信号失败");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.info(agvaddr + "对应设备号为空!");
|
||||
log.info("BJD" + agvaddr + "对应设备号为空!");
|
||||
}
|
||||
|
||||
} else if (phase == 0x51) {
|
||||
if (ObjectUtil.isEmpty(device_code)) {
|
||||
log.info(agvaddr + "对应设备号为空!");
|
||||
log.info("离开告警区域");
|
||||
if (agvaddr == 0) {
|
||||
log.info("BJD" + agvaddr + "对应设备号为空!");
|
||||
return;
|
||||
}
|
||||
if (ObjectUtil.isNotEmpty(device)) {
|
||||
if (device.getDeviceDriver() instanceof StandardAutodoorDeviceDriver) {
|
||||
standardAutodoorDeviceDriver = (StandardAutodoorDeviceDriver) device.getDeviceDriver();
|
||||
String is_enter = standardAutodoorDeviceDriver.getExtraValue().get("is_enter").toString();
|
||||
if (StrUtil.isNotBlank(is_enter) && "false".equals(is_enter)) {
|
||||
Device bjdDevice = deviceAppService.findDeviceByCode("BJD" + agvaddr);
|
||||
if (ObjectUtil.isNotEmpty(bjdDevice)) {
|
||||
if (bjdDevice.getDeviceDriver() instanceof GuardLampDeviceDriver) {
|
||||
try {
|
||||
GuardLampDeviceDriver guardLampDeviceDriver = (GuardLampDeviceDriver) bjdDevice.getDeviceDriver();
|
||||
guardLampDeviceDriver.writing("to_open", "0");
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
|
||||
} else {
|
||||
log.info("区域已锁定,请释放后在进入");
|
||||
} catch (Exception e) {
|
||||
log.info("下发告警灯取消告警信号失败");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
log.info(device_code + "对应设备号为空!");
|
||||
log.info("BJD" + agvaddr + "对应设备号为空!");
|
||||
}
|
||||
} else {
|
||||
//上报异常信息
|
||||
|
||||
@@ -38,7 +38,10 @@ public enum DriverTypeEnum {
|
||||
GUHUASHI_SITE(12, "guhuashi_site", "固化室", "conveyor"),
|
||||
TIANNENG_SITE(13, "tianneng_site", "天能-检测站点", "conveyor"),
|
||||
|
||||
BAOSHIJIAN_SITE(14,"baoshijian_site","保湿间","conveyor");
|
||||
|
||||
BAOSHIJIAN_SITE(14,"baoshijian_site","保湿间","conveyor"),
|
||||
|
||||
GUARD_LAMP(15, "guard_lamp", "告警灯", "guard_lamp");
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -16,6 +16,7 @@ import org.nl.acs.auto.run.OneNDCSocketConnectionAutoRun;
|
||||
import org.nl.acs.device.domain.Device;
|
||||
import org.nl.acs.device.service.DeviceService;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.guard_lamp.GuardLampDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.plc_to_agv.PlcToAgvDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.siemens_conveyor.SiemensConveyorDeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.standard_inspect_site.StandardInspectSiteDeviceDriver;
|
||||
@@ -528,9 +529,29 @@ public class AgvNdcOneDeviceDriver extends AbstractDeviceDriver implements Devic
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
|
||||
} else if (phase == 0x50) {//进入交通灯区域
|
||||
log.info("进入告警区域");
|
||||
try {
|
||||
Device guardLamp = deviceAppService.findDeviceByCode("BJD" + agvaddr);
|
||||
if (guardLamp != null) {
|
||||
GuardLampDeviceDriver guardLampDeviceDriver = (GuardLampDeviceDriver) device.getDeviceDriver();
|
||||
guardLampDeviceDriver.writing("to_open", "1");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.info("下发告警灯告警信号失败");
|
||||
}
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
|
||||
} else if (phase == 0x51) {//离开交通灯区域
|
||||
log.info("离开告警区域");
|
||||
try {
|
||||
Device guardLamp = deviceAppService.findDeviceByCode("BJD" + agvaddr);
|
||||
if (guardLamp != null) {
|
||||
GuardLampDeviceDriver guardLampDeviceDriver = (GuardLampDeviceDriver) device.getDeviceDriver();
|
||||
guardLampDeviceDriver.writing("to_open", "0");
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.info("下发告警灯取消告警信号失败");
|
||||
}
|
||||
data = NDCAgvService.sendAgvOneModeInst(phase, index, 0, 0, 0, 0, 0);
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "agvphase:" + phase + "反馈:" + data);
|
||||
} else if (phase == 0x70) {
|
||||
|
||||
@@ -0,0 +1,63 @@
|
||||
package org.nl.acs.device_driver.basedriver.guard_lamp;
|
||||
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
|
||||
import org.nl.acs.device.domain.Device;
|
||||
import org.nl.acs.device.enums.DeviceType;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.defination.OpcDeviceDriverDefination;
|
||||
|
||||
import org.springframework.stereotype.Service;
|
||||
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* 告警灯驱动定义
|
||||
*/
|
||||
@Service
|
||||
public class GuardLampDefination implements OpcDeviceDriverDefination {
|
||||
@Override
|
||||
public String getDriverCode() {
|
||||
return "guard_lamp";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverName() {
|
||||
return "标准版-告警灯";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getDriverDescription() {
|
||||
return "标准版-告警灯";
|
||||
}
|
||||
|
||||
@Override
|
||||
public DeviceDriver getDriverInstance(Device device) {
|
||||
return (new GuardLampDeviceDriver()).setDevice(device).setDriverDefination(this);
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public Class<? extends DeviceDriver> getDeviceDriverType() {
|
||||
return GuardLampDeviceDriver.class;
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<DeviceType> getFitDeviceTypes() {
|
||||
List<DeviceType> types = new LinkedList();
|
||||
types.add(DeviceType.conveyor);
|
||||
return types;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public List<ItemDto> getReadableItemDtos() {
|
||||
return ItemProtocol.getReadableItemDtos();
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<ItemDto> getWriteableItemDtos() {
|
||||
return ItemProtocol.getWriteableItemDtos();
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,97 @@
|
||||
package org.nl.acs.device_driver.basedriver.guard_lamp;
|
||||
|
||||
import com.alibaba.fastjson.JSONObject;
|
||||
import lombok.Data;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.device.domain.Device;
|
||||
import org.nl.acs.device_driver.DeviceDriver;
|
||||
import org.nl.acs.device_driver.basedriver.guard_lamp.ItemProtocol;
|
||||
import org.nl.acs.device_driver.driver.AbstractOpcDeviceDriver;
|
||||
import org.nl.acs.device_driver.driver.ExecutableDeviceDriver;
|
||||
import org.nl.acs.log.service.DeviceExecuteLogService;
|
||||
import org.nl.acs.monitor.DeviceStageMonitor;
|
||||
import org.nl.config.SpringContextHolder;
|
||||
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
|
||||
/**
|
||||
* 告警灯驱动
|
||||
*/
|
||||
@Slf4j
|
||||
@Data
|
||||
@RequiredArgsConstructor
|
||||
public class GuardLampDeviceDriver extends AbstractOpcDeviceDriver implements DeviceDriver, ExecutableDeviceDriver, DeviceStageMonitor {
|
||||
protected org.nl.acs.device_driver.basedriver.guard_lamp.ItemProtocol itemProtocol = new ItemProtocol(this);
|
||||
DeviceExecuteLogService logServer = SpringContextHolder.getBean("deviceExecuteLogServiceImpl");
|
||||
|
||||
int open = 0;
|
||||
int last_open = 0;
|
||||
|
||||
int toOpen = 0;
|
||||
int last_toOpen = 0;
|
||||
|
||||
String device_code = null;
|
||||
|
||||
@Override
|
||||
public Device getDevice() {
|
||||
return this.device;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
String message = null;
|
||||
|
||||
device_code = this.getDevice().getDevice_code();
|
||||
open = this.itemProtocol.getOpen();
|
||||
toOpen = this.itemProtocol.getToOpen();
|
||||
if (open != last_open) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号open:" + last_open + "->" + open);
|
||||
}
|
||||
|
||||
if (toOpen != last_toOpen) {
|
||||
logServer.deviceExecuteLog(this.device_code, "", "", "信号toOpen:" + last_toOpen + "->" + toOpen);
|
||||
}
|
||||
last_open = open;
|
||||
last_toOpen = toOpen;
|
||||
}
|
||||
|
||||
|
||||
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;
|
||||
Map<String, Object> itemMap = new HashMap<String, Object>();
|
||||
itemMap.put(to_param, Integer.parseInt(value));
|
||||
|
||||
this.control(itemMap);
|
||||
logServer.deviceExecuteLog(device_code, "", "", "下发电气信号设备号:" + device_code + ",下发电气:" + to_param + ",下发电气值:" + value);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public JSONObject getDeviceStatusName() {
|
||||
JSONObject jo = new JSONObject();
|
||||
String open = "";
|
||||
if (this.getOpen() == 0) {
|
||||
open = "未警戒";
|
||||
} else if (this.getOpen() == 1) {
|
||||
open = "警戒";
|
||||
}
|
||||
jo.put("device_name", this.getDevice().getDevice_name());
|
||||
jo.put("open", open);
|
||||
jo.put("isOnline", true);
|
||||
|
||||
return jo;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setDeviceStatus(JSONObject data) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,72 @@
|
||||
package org.nl.acs.device_driver.basedriver.guard_lamp;
|
||||
|
||||
import cn.hutool.core.util.StrUtil;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.nl.acs.device.device_driver.standard_inspect.ItemDto;
|
||||
import org.nl.acs.device_driver.basedriver.standard_autodoor.StandardAutodoorDeviceDriver;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@Slf4j
|
||||
public class ItemProtocol {
|
||||
public static String item_open = "open";
|
||||
public static String item_to_open = "to_open";
|
||||
|
||||
|
||||
private GuardLampDeviceDriver driver;
|
||||
|
||||
public ItemProtocol(GuardLampDeviceDriver driver) {
|
||||
this.driver = driver;
|
||||
}
|
||||
|
||||
public int getOpen() {
|
||||
return this.getOpcIntegerValue(item_open);
|
||||
}
|
||||
|
||||
|
||||
public int getToOpen() {
|
||||
return this.getOpcIntegerValue(item_to_open);
|
||||
}
|
||||
|
||||
|
||||
public int getOpcIntegerValue(String protocol) {
|
||||
Integer value = this.driver.getIntegeregerValue(protocol);
|
||||
if (value == null) {
|
||||
// log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!");
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
||||
public String getOpcStringValue(String protocol) {
|
||||
String value = this.driver.getStringValue(protocol);
|
||||
if (StrUtil.isEmpty(value)) {
|
||||
|
||||
} else {
|
||||
return value;
|
||||
}
|
||||
return "0";
|
||||
}
|
||||
|
||||
public static List<ItemDto> getReadableItemDtos() {
|
||||
ArrayList list = new ArrayList();
|
||||
list.add(new ItemDto(item_open, "是否告警", "10001"));
|
||||
return list;
|
||||
}
|
||||
|
||||
public static List<ItemDto> getWriteableItemDtos() {
|
||||
ArrayList list = new ArrayList();
|
||||
list.add(new ItemDto(item_to_open, "下发告警", "00001"));
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user