Browse Source

更新

master
gengby 2 years ago
parent
commit
faef35dc85
  1. 28
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/agv/ItemProtocol.java
  2. 19
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/agv/MaGangAgvDeviceDriver.java
  3. 4
      acs/nladmin-system/src/main/java/org/nl/acs/device_driver/driver/OpcDeviceDriver.java
  4. 42
      acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryXZAgvDeviceStatus.java

28
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/agv/ItemProtocol.java

@ -32,12 +32,12 @@ public class ItemProtocol {
return this.getOpcIntegerValue(item_type);
}
public int getX_coordinate() {
return this.getOpcIntegerValue(item_x_coordinate);
public float getX_coordinate() {
return this.getOpcFloatValue(item_x_coordinate);
}
public int getY_coordinate() {
return this.getOpcIntegerValue(item_y_coordinate);
public float getY_coordinate() {
return this.getOpcFloatValue(item_y_coordinate);
}
Boolean isonline;
@ -54,12 +54,24 @@ public class ItemProtocol {
}
public Float getOpcFloatValue(String protocol) {
Float value = this.driver.getFloatValue(protocol);
if (value == null) {
log.error(this.getDriver().getDeviceCode() + ":protocol " + protocol + " 信号同步异常!");
setIsonline(false);
} else {
setIsonline(true);
return value;
}
return 0.00f;
}
public static List<ItemDto> getReadableItemDtos() {
ArrayList list = new ArrayList();
list.add(new ItemDto(item_status, "AGV状态", "DB602.W0"));
list.add(new ItemDto(item_type, "AGV任务类型", "DB602.W2"));
list.add(new ItemDto(item_x_coordinate, "AGVx坐标", "DB602.W4"));
list.add(new ItemDto(item_y_coordinate, "AGVy坐标", "DB602.W6"));
list.add(new ItemDto(item_x_coordinate, "AGVx坐标", "DB602.D4"));
list.add(new ItemDto(item_y_coordinate, "AGVy坐标", "DB602.D6"));
return list;
}
@ -67,8 +79,8 @@ public class ItemProtocol {
ArrayList list = new ArrayList();
list.add(new ItemDto(item_status, "AGV状态", "DB602.W0"));
list.add(new ItemDto(item_type, "AGV任务类型", "DB602.W2"));
list.add(new ItemDto(item_x_coordinate, "AGVx坐标", "DB602.W4"));
list.add(new ItemDto(item_y_coordinate, "AGVy坐标", "DB602.W6"));
list.add(new ItemDto(item_x_coordinate, "AGVx坐标", "DB602.D4"));
list.add(new ItemDto(item_y_coordinate, "AGVy坐标", "DB602.D6"));
return list;
}

19
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/agv/MaGangAgvDeviceDriver.java

@ -69,12 +69,12 @@ public class MaGangAgvDeviceDriver extends AbstractOpcDeviceDriver implements De
int last_type = 0;
//x坐标
int x_coordinate = 0;
int last_x_coordinate = 0;
float x_coordinate = 0;
float last_x_coordinate = 0;
//y坐标
int y_coordinate = 0;
int last_y_coordinate = 0;
float y_coordinate = 0;
float last_y_coordinate = 0;
Boolean isonline = true;
Boolean iserror = false;
@ -120,6 +120,17 @@ public class MaGangAgvDeviceDriver extends AbstractOpcDeviceDriver implements De
log.info("设备号{},kep点位名称{},下发信号{}", this.getDevice().getDevice_code(), to_command, value);
}
public void writing(String param, float value) {
String to_command = 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, value);
ReadUtil.write(itemMap, server);
log.info("设备号{},kep点位名称{},下发信号{}", this.getDevice().getDevice_code(), to_command, value);
}
@Override
public JSONObject getDeviceStatusName() {

4
acs/nladmin-system/src/main/java/org/nl/acs/device_driver/driver/OpcDeviceDriver.java

@ -65,6 +65,10 @@ public interface OpcDeviceDriver extends DeviceDriver {
return (int[]) this.getOpcValueAccessor().getValue(this.getItem(protocol));
}
default Float getFloatValue(String protocol) {
return (Float) this.getOpcValueAccessor().getValue(this.getItem(protocol));
}
default String getStringValue(String protocol) {
return (String) this.getOpcValueAccessor().getValue(this.getItem(protocol));
}

42
acs/nladmin-system/src/main/java/org/nl/modules/quartz/task/QueryXZAgvDeviceStatus.java

@ -16,6 +16,9 @@ import org.nl.acs.opc.DeviceAppService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import java.math.RoundingMode;
import java.text.DecimalFormat;
/**
* 查询先工AGV设备状态
*/
@ -54,20 +57,26 @@ public class QueryXZAgvDeviceStatus {
Boolean is_error = jo.getBoolean("is_error");
//执行运单信息
JSONObject current_order = jo.getJSONObject("current_order");
Integer connectionStatus = jo.getInteger("connection_status");
String inst_code = current_order.getString("id");
String task_type = "0";
if (StrUtil.isNotEmpty(inst_code)) {
Instruction inst = instructionService.findByCodeFromCache(inst_code);
if (ObjectUtil.isNotEmpty(inst)){
if (ObjectUtil.isNotEmpty(inst)) {
//任务类型
task_type = inst.getInstruction_type();
}
}
DecimalFormat hisFormat = new DecimalFormat("########.###");
hisFormat.setRoundingMode(RoundingMode.DOWN);
//x坐标
int x = Double.valueOf(rbk_report.getString("x")).intValue();
float x = rbk_report.getFloatValue("x");
//y坐标
int y = Double.valueOf(rbk_report.getString("y")).intValue();
float y = rbk_report.getFloatValue("y");
String status = "0";
if (connectionStatus == 0) {
status = "5";
} else {
if (procBusiness) {
//工作中
status = "1";
@ -85,20 +94,21 @@ public class QueryXZAgvDeviceStatus {
}
}
}
}
Device device = deviceAppService.findDeviceByCode(agv_code);
MaGangAgvDeviceDriver maGangAgvDeviceDriver;
if (device.getDeviceDriver() instanceof MaGangAgvDeviceDriver) {
maGangAgvDeviceDriver = (MaGangAgvDeviceDriver) device.getDeviceDriver();
String kepStatus = String.valueOf(maGangAgvDeviceDriver.getStatus());
String kepType = String.valueOf(maGangAgvDeviceDriver.getType());
if (!StrUtil.equals(kepStatus,status)){
if (!StrUtil.equals(kepStatus, status)) {
maGangAgvDeviceDriver.writing("status", status);
}
if (!StrUtil.equals(kepType,task_type)){
if (!StrUtil.equals(kepType, task_type)) {
maGangAgvDeviceDriver.writing("type", task_type);
}
maGangAgvDeviceDriver.writing("x_coordinate", String.valueOf(x));
maGangAgvDeviceDriver.writing("y_coordinate", String.valueOf(y));
maGangAgvDeviceDriver.writing("x_coordinate", hisFormat.format(x) + "");
maGangAgvDeviceDriver.writing("y_coordinate", hisFormat.format(y) + "");
}
}
}
@ -110,32 +120,32 @@ public class QueryXZAgvDeviceStatus {
try {
JSONObject map = new JSONObject();
JSONArray blocks = new JSONArray();
map.put("blockGroup",blocks);
map.put("blockGroup", blocks);
JSONArray jsonArray = agvService.blockGroupStatus(map);
if (ObjectUtil.isNotEmpty(jsonArray)){
if (ObjectUtil.isNotEmpty(jsonArray)) {
for (int i = 0; i < jsonArray.size(); i++) {
JSONObject jsonObject = jsonArray.getJSONObject(i);
Boolean status = jsonObject.getBoolean("status");
if (status){
if (status) {
String name = jsonObject.getString("name");
Device device = deviceAppService.findDeviceByCode(name);
MaGangLedDeviceDriver maGangLedDeviceDriver;
if (device.getDeviceDriver() instanceof MaGangLedDeviceDriver){
if (device.getDeviceDriver() instanceof MaGangLedDeviceDriver) {
maGangLedDeviceDriver = (MaGangLedDeviceDriver) device.getDeviceDriver();
maGangLedDeviceDriver.writing("D01","1");
maGangLedDeviceDriver.writing("D01", "1");
}
}else {
} else {
String name = jsonObject.getString("name");
Device device = deviceAppService.findDeviceByCode(name);
MaGangLedDeviceDriver maGangLedDeviceDriver;
if (device.getDeviceDriver() instanceof MaGangLedDeviceDriver){
if (device.getDeviceDriver() instanceof MaGangLedDeviceDriver) {
maGangLedDeviceDriver = (MaGangLedDeviceDriver) device.getDeviceDriver();
maGangLedDeviceDriver.writing("D01","0");
maGangLedDeviceDriver.writing("D01", "0");
}
}
}
}
}catch (Exception e){
} catch (Exception e) {
}
}

Loading…
Cancel
Save