更新
This commit is contained in:
@@ -32,12 +32,12 @@ public class ItemProtocol {
|
|||||||
return this.getOpcIntegerValue(item_type);
|
return this.getOpcIntegerValue(item_type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getX_coordinate() {
|
public float getX_coordinate() {
|
||||||
return this.getOpcIntegerValue(item_x_coordinate);
|
return this.getOpcFloatValue(item_x_coordinate);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getY_coordinate() {
|
public float getY_coordinate() {
|
||||||
return this.getOpcIntegerValue(item_y_coordinate);
|
return this.getOpcFloatValue(item_y_coordinate);
|
||||||
}
|
}
|
||||||
|
|
||||||
Boolean isonline;
|
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() {
|
public static List<ItemDto> getReadableItemDtos() {
|
||||||
ArrayList list = new ArrayList();
|
ArrayList list = new ArrayList();
|
||||||
list.add(new ItemDto(item_status, "AGV状态", "DB602.W0"));
|
list.add(new ItemDto(item_status, "AGV状态", "DB602.W0"));
|
||||||
list.add(new ItemDto(item_type, "AGV任务类型", "DB602.W2"));
|
list.add(new ItemDto(item_type, "AGV任务类型", "DB602.W2"));
|
||||||
list.add(new ItemDto(item_x_coordinate, "AGVx坐标", "DB602.W4"));
|
list.add(new ItemDto(item_x_coordinate, "AGVx坐标", "DB602.D4"));
|
||||||
list.add(new ItemDto(item_y_coordinate, "AGVy坐标", "DB602.W6"));
|
list.add(new ItemDto(item_y_coordinate, "AGVy坐标", "DB602.D6"));
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -67,8 +79,8 @@ public class ItemProtocol {
|
|||||||
ArrayList list = new ArrayList();
|
ArrayList list = new ArrayList();
|
||||||
list.add(new ItemDto(item_status, "AGV状态", "DB602.W0"));
|
list.add(new ItemDto(item_status, "AGV状态", "DB602.W0"));
|
||||||
list.add(new ItemDto(item_type, "AGV任务类型", "DB602.W2"));
|
list.add(new ItemDto(item_type, "AGV任务类型", "DB602.W2"));
|
||||||
list.add(new ItemDto(item_x_coordinate, "AGVx坐标", "DB602.W4"));
|
list.add(new ItemDto(item_x_coordinate, "AGVx坐标", "DB602.D4"));
|
||||||
list.add(new ItemDto(item_y_coordinate, "AGVy坐标", "DB602.W6"));
|
list.add(new ItemDto(item_y_coordinate, "AGVy坐标", "DB602.D6"));
|
||||||
return list;
|
return list;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -69,12 +69,12 @@ public class MaGangAgvDeviceDriver extends AbstractOpcDeviceDriver implements De
|
|||||||
int last_type = 0;
|
int last_type = 0;
|
||||||
|
|
||||||
//x坐标
|
//x坐标
|
||||||
int x_coordinate = 0;
|
float x_coordinate = 0;
|
||||||
int last_x_coordinate = 0;
|
float last_x_coordinate = 0;
|
||||||
|
|
||||||
//y坐标
|
//y坐标
|
||||||
int y_coordinate = 0;
|
float y_coordinate = 0;
|
||||||
int last_y_coordinate = 0;
|
float last_y_coordinate = 0;
|
||||||
|
|
||||||
Boolean isonline = true;
|
Boolean isonline = true;
|
||||||
Boolean iserror = false;
|
Boolean iserror = false;
|
||||||
@@ -120,6 +120,17 @@ public class MaGangAgvDeviceDriver extends AbstractOpcDeviceDriver implements De
|
|||||||
log.info("设备号{},kep点位名称{},下发信号{}", this.getDevice().getDevice_code(), to_command, value);
|
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
|
@Override
|
||||||
public JSONObject getDeviceStatusName() {
|
public JSONObject getDeviceStatusName() {
|
||||||
|
|||||||
@@ -65,6 +65,10 @@ public interface OpcDeviceDriver extends DeviceDriver {
|
|||||||
return (int[]) this.getOpcValueAccessor().getValue(this.getItem(protocol));
|
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) {
|
default String getStringValue(String protocol) {
|
||||||
return (String) this.getOpcValueAccessor().getValue(this.getItem(protocol));
|
return (String) this.getOpcValueAccessor().getValue(this.getItem(protocol));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,9 @@ import org.nl.acs.opc.DeviceAppService;
|
|||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
|
||||||
|
import java.math.RoundingMode;
|
||||||
|
import java.text.DecimalFormat;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 查询先工AGV设备状态
|
* 查询先工AGV设备状态
|
||||||
*/
|
*/
|
||||||
@@ -54,6 +57,7 @@ public class QueryXZAgvDeviceStatus {
|
|||||||
Boolean is_error = jo.getBoolean("is_error");
|
Boolean is_error = jo.getBoolean("is_error");
|
||||||
//执行运单信息
|
//执行运单信息
|
||||||
JSONObject current_order = jo.getJSONObject("current_order");
|
JSONObject current_order = jo.getJSONObject("current_order");
|
||||||
|
Integer connectionStatus = jo.getInteger("connection_status");
|
||||||
String inst_code = current_order.getString("id");
|
String inst_code = current_order.getString("id");
|
||||||
String task_type = "0";
|
String task_type = "0";
|
||||||
if (StrUtil.isNotEmpty(inst_code)) {
|
if (StrUtil.isNotEmpty(inst_code)) {
|
||||||
@@ -63,11 +67,16 @@ public class QueryXZAgvDeviceStatus {
|
|||||||
task_type = inst.getInstruction_type();
|
task_type = inst.getInstruction_type();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
DecimalFormat hisFormat = new DecimalFormat("########.###");
|
||||||
|
hisFormat.setRoundingMode(RoundingMode.DOWN);
|
||||||
//x坐标
|
//x坐标
|
||||||
int x = Double.valueOf(rbk_report.getString("x")).intValue();
|
float x = rbk_report.getFloatValue("x");
|
||||||
//y坐标
|
//y坐标
|
||||||
int y = Double.valueOf(rbk_report.getString("y")).intValue();
|
float y = rbk_report.getFloatValue("y");
|
||||||
String status = "0";
|
String status = "0";
|
||||||
|
if (connectionStatus == 0) {
|
||||||
|
status = "5";
|
||||||
|
} else {
|
||||||
if (procBusiness) {
|
if (procBusiness) {
|
||||||
//工作中
|
//工作中
|
||||||
status = "1";
|
status = "1";
|
||||||
@@ -85,6 +94,7 @@ public class QueryXZAgvDeviceStatus {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Device device = deviceAppService.findDeviceByCode(agv_code);
|
Device device = deviceAppService.findDeviceByCode(agv_code);
|
||||||
MaGangAgvDeviceDriver maGangAgvDeviceDriver;
|
MaGangAgvDeviceDriver maGangAgvDeviceDriver;
|
||||||
if (device.getDeviceDriver() instanceof MaGangAgvDeviceDriver) {
|
if (device.getDeviceDriver() instanceof MaGangAgvDeviceDriver) {
|
||||||
@@ -97,8 +107,8 @@ public class QueryXZAgvDeviceStatus {
|
|||||||
if (!StrUtil.equals(kepType, task_type)) {
|
if (!StrUtil.equals(kepType, task_type)) {
|
||||||
maGangAgvDeviceDriver.writing("type", task_type);
|
maGangAgvDeviceDriver.writing("type", task_type);
|
||||||
}
|
}
|
||||||
maGangAgvDeviceDriver.writing("x_coordinate", String.valueOf(x));
|
maGangAgvDeviceDriver.writing("x_coordinate", hisFormat.format(x) + "");
|
||||||
maGangAgvDeviceDriver.writing("y_coordinate", String.valueOf(y));
|
maGangAgvDeviceDriver.writing("y_coordinate", hisFormat.format(y) + "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user