Browse Source

Merge branch '炒锅机器人_一拖多' of http://10.2.1.24:10244/fyf/AndroidSmartClient into 炒锅机器人_一拖多

炒锅机器人_一拖多
liup 2 months ago
parent
commit
b347ec1d23
3 changed files with 17 additions and 17 deletions
  1. +2
    -2
      app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java
  2. +4
    -4
      app/src/main/java/com/bonait/bnframework/modbus/ModbusCenter.java
  3. +11
    -11
      app/src/main/java/com/bonait/bnframework/modbus/Wok2ModbusTcpServer.java

+ 2
- 2
app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java View File

@@ -377,8 +377,8 @@ public class ConfigName {
put("机器人取3#空盆", 23);
put("机器人取4#空盆", 24);

put("机器人去维护位置", 31);
put("机器人去维护位置反馈", 31);
put("机器人去维护位置", 41);
put("机器人去维护位置反馈", 41);

}};



+ 4
- 4
app/src/main/java/com/bonait/bnframework/modbus/ModbusCenter.java View File

@@ -23,10 +23,10 @@ import java.util.concurrent.ConcurrentHashMap;
*/
public class ModbusCenter {
//modbus 连接
public static String wokAddress = "192.168.6.101";//炒锅地址
public static int wokPost = 505;//炒锅端口
public static String wok2Address = "192.168.6.100";//炒锅地址
public static int wok2Post = 504;//炒锅端口
public static String wokAddress = "192.168.6.100";//炒锅地址
public static int wokPost = 504;//炒锅端口
public static String wok2Address = "192.168.6.101";//炒锅地址
public static int wok2Post = 505;//炒锅端口
public static String robotAddress = "192.168.6.103";//机器人地址
public static int robotPost = 507;
public static String rackAddress = "192.168.6.102";//货架地址


+ 11
- 11
app/src/main/java/com/bonait/bnframework/modbus/Wok2ModbusTcpServer.java View File

@@ -55,7 +55,7 @@ public class Wok2ModbusTcpServer {

public void DisConnect(){
plcIsConnect = false;
WokModbusTcpHelper.get().release();
Wok2ModbusTcpHelper.get().release();
}

/**
@@ -107,7 +107,7 @@ public class Wok2ModbusTcpServer {
.setRetries(0)
.setEncapsulated(false)
.setKeepAlive(true);
WokModbusTcpHelper.get().init(param, new ModbusCallback<ModbusMaster>() {
Wok2ModbusTcpHelper.get().init(param, new ModbusCallback<ModbusMaster>() {
@Override
public void onSuccess(ModbusMaster modbusMaster) {
MessageLog.ShowInfo("炒锅设备 " + ModbusCenter.wokAddress + " 连接成功");
@@ -316,7 +316,7 @@ public class Wok2ModbusTcpServer {
int add = GetAddress(Address);
if (add < 0) return;
try {
ReadHoldingRegistersResponse res = WokModbusTcpHelper.get().syncReadHoldingRegisters(1, add, length);
ReadHoldingRegistersResponse res = Wok2ModbusTcpHelper.get().syncReadHoldingRegisters(1, add, length);
byte[] data = res.getData();
byte[] tempData = new byte[6];
tempData[0] = data[1];
@@ -334,7 +334,7 @@ public class Wok2ModbusTcpServer {
int add = GetAddress(Address);
if (add < 0) return;
try {
ReadHoldingRegistersResponse res = WokModbusTcpHelper.get().syncReadHoldingRegisters(1, add, length);
ReadHoldingRegistersResponse res = Wok2ModbusTcpHelper.get().syncReadHoldingRegisters(1, add, length);
short[] data = res.getShortData();
if (data.length == length) {
if (callback != null) callback.onSuccess(data);
@@ -351,7 +351,7 @@ public class Wok2ModbusTcpServer {
int add = GetAddress(Address);
if (add < 0) return;
try {
ReadCoilsResponse res = WokModbusTcpHelper.get().syncReadCoil(1, add, length);
ReadCoilsResponse res = Wok2ModbusTcpHelper.get().syncReadCoil(1, add, length);
boolean[] data = res.getBooleanData();
boolean[] result = Arrays.copyOfRange(data, 0, length);
if (result.length == length) {
@@ -369,7 +369,7 @@ public class Wok2ModbusTcpServer {
int add = GetAddress(Address);
if (add < 0) return;
try {
ReadHoldingRegistersResponse res = WokModbusTcpHelper.get().syncReadHoldingRegisters(1, add, length*2);
ReadHoldingRegistersResponse res = Wok2ModbusTcpHelper.get().syncReadHoldingRegisters(1, add, length*2);
byte[] data = res.getData();
float[] tempValues = new float[length];
for (int i = 0; i < length; i++) {
@@ -394,7 +394,7 @@ public class Wok2ModbusTcpServer {
int add = GetAddress(Address);
if (add < 0) return;
try {
ReadHoldingRegistersResponse res = WokModbusTcpHelper.get().syncReadHoldingRegisters(1, add, length * 2);
ReadHoldingRegistersResponse res = Wok2ModbusTcpHelper.get().syncReadHoldingRegisters(1, add, length * 2);
byte[] data = res.getData();
int[] tempValues = new int[length];
if(data.length>=4)
@@ -430,7 +430,7 @@ public class Wok2ModbusTcpServer {
short[] send = new short[1];
send[0] = Value;
try {
WokModbusTcpHelper.get().syncWriteRegisters(1, add, send);
Wok2ModbusTcpHelper.get().syncWriteRegisters(1, add, send);
if (callback != null)
callback.onSuccess();
} catch (InterruptedException | ExecutionException | ModbusTransportException |
@@ -444,7 +444,7 @@ public class Wok2ModbusTcpServer {
int add = GetAddress(Address);
if (add < 0) return;
try {
WokModbusTcpHelper.get().syncWriteCoil(1, add, Value);
Wok2ModbusTcpHelper.get().syncWriteCoil(1, add, Value);
if (callback != null)
callback.onSuccess();
} catch (InterruptedException | ExecutionException | ModbusTransportException |
@@ -462,7 +462,7 @@ public class Wok2ModbusTcpServer {
short[] send = IntToShorts(intBits);
// short[] send = new short[]{(short) ((intBits >> 16) & 0xffff), (short) (intBits & 0xffff)};
try {
WokModbusTcpHelper.get().syncWriteRegisters(1, add, send);
Wok2ModbusTcpHelper.get().syncWriteRegisters(1, add, send);

if (callback != null) callback.onSuccess();
} catch (InterruptedException | ExecutionException | ModbusTransportException |
@@ -477,7 +477,7 @@ public class Wok2ModbusTcpServer {
if (add < 0) return;
short[] send = IntToShorts(Value);
try {
WokModbusTcpHelper.get().syncWriteRegisters(1, add, send);
Wok2ModbusTcpHelper.get().syncWriteRegisters(1, add, send);
if (callback != null) callback.onSuccess();
} catch (InterruptedException | ExecutionException | ModbusTransportException |
ModbusInitException | ModbusRespException e) {


Loading…
Cancel
Save