Browse Source

修改允许机器人投料

鸿鹄中学一拖二
liup 2 months ago
parent
commit
024bc6fe5a
4 changed files with 20 additions and 24 deletions
  1. +0
    -3
      app/src/main/java/com/bonait/bnframework/business/ControlBase.java
  2. +17
    -0
      app/src/main/java/com/bonait/bnframework/business/FryingpanModbusBase.java
  3. +1
    -19
      app/src/main/java/com/bonait/bnframework/common/modbus/ModbusMaster.java
  4. +2
    -2
      build.gradle

+ 0
- 3
app/src/main/java/com/bonait/bnframework/business/ControlBase.java View File

@@ -1,17 +1,14 @@
package com.bonait.bnframework.business;

import com.bonait.bnframework.HBL.NotifyPropVar;
import com.bonait.bnframework.HBL.Task;
import com.bonait.bnframework.common.ModbusSlave.ModbusTcpSlave;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.db.res.UserLogEnum;
import com.bonait.bnframework.common.helper.I.IThread;
import com.bonait.bnframework.common.helper.MessageLog;
import com.bonait.bnframework.common.helper.RTrig;
import com.bonait.bnframework.common.helper.TTrig;
import com.bonait.bnframework.common.helper.ThreadManager;
import com.bonait.bnframework.common.modbus.IOperateResult;
import com.bonait.bnframework.common.modbus.ModbusMaster;

import java.util.ArrayList;
import java.util.LinkedHashMap;


+ 17
- 0
app/src/main/java/com/bonait/bnframework/business/FryingpanModbusBase.java View File

@@ -4,6 +4,7 @@ import android.os.Handler;
import android.os.Looper;

import com.bonait.bnframework.HBL.NotifyPropVar;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.helper.I.IThread;
import com.bonait.bnframework.common.helper.MessageLog;
import com.bonait.bnframework.common.helper.ThreadManager;
@@ -20,6 +21,16 @@ public class FryingpanModbusBase extends ModbusMaster {
ThreadManager.Get().StartLong(Name, true, new IThread() {
@Override
public void Run() throws Exception {
if(TempIp.contains(ConfigName.getInstance().F1Address)){
ReadBool("M40.2",1,1,(s)->{
RobotModbus.getInstance().WriteBool(GetRobotAdd(1,0).toString(),s,1,null);//写入机器人允许放料信号
});
}else if(TempIp.contains(ConfigName.getInstance().F2Address)){
ReadBool("M40.2",1,1,(s)->{
RobotModbus.getInstance().WriteBool(GetRobotAdd(2,0).toString(),s,1,null);//写入机器人允许放料信号
});
}

ReadBool("M40.3",1,1,(s)->{MaterialLocFeedback =s[0];});

ReadBool("M10.3",1,1,(s)->{StirFeedback =s[0];});
@@ -39,6 +50,12 @@ public class FryingpanModbusBase extends ModbusMaster {
});
}

public Integer GetRobotAdd(int num,int offset){
//M500--4596
// return "M"+ 500+offset+(num-1)*10;
return 4596+offset+(num-1)*10;
}

public void Close(){
ThreadManager.Get().Stop(Name);
release();


+ 1
- 19
app/src/main/java/com/bonait/bnframework/common/modbus/ModbusMaster.java View File

@@ -3,29 +3,19 @@ package com.bonait.bnframework.common.modbus;
import static com.bonait.bnframework.common.modbus.DataConvertLib.ByteToShort;
import static com.bonait.bnframework.common.modbus.DataConvertLib.BytesToFloat;
import static com.bonait.bnframework.common.modbus.DataConvertLib.BytesToInt;
import static com.bonait.bnframework.common.modbus.DataConvertLib.GetAddress;
import static com.bonait.bnframework.common.modbus.DataConvertLib.IntToShorts;

import android.util.Log;

import com.bonait.bnframework.HBL.NotifyPropVar;
import com.bonait.bnframework.business.ConfigData;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.helper.DataFormat;
import com.bonait.bnframework.common.helper.I.IReadCallBack;
import com.bonait.bnframework.common.helper.I.IRun;
import com.bonait.bnframework.common.helper.I.IThread;
import com.bonait.bnframework.common.helper.I.IWriteCallBack;
import com.bonait.bnframework.common.helper.MessageLog;
import com.bonait.bnframework.common.helper.ThreadManager;
import com.bonait.bnframework.common.utils.ToastUtils;
import com.licheedev.modbus4android.ModbusCallback;
import com.licheedev.modbus4android.ModbusParam;
import com.licheedev.modbus4android.ModbusRespException;
import com.licheedev.modbus4android.ModbusWorker;
import com.licheedev.modbus4android.param.SerialParam;
import com.licheedev.modbus4android.param.TcpParam;
import com.serotonin.modbus4j.ModbusFactory;
import com.serotonin.modbus4j.exception.ModbusInitException;
import com.serotonin.modbus4j.exception.ModbusTransportException;
import com.serotonin.modbus4j.msg.ReadCoilsResponse;
@@ -35,16 +25,8 @@ import java.io.IOException;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.io.UnsupportedEncodingException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedList;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.concurrent.atomic.AtomicReference;

import kotlin.UInt;
import kotlin.UShort;

public class ModbusMaster implements IRead,IWrite,IModbusMaster {
//https://blog.csdn.net/zgkxzx/article/details/71630301
@@ -94,7 +76,7 @@ public class ModbusMaster implements IRead,IWrite,IModbusMaster {

}
public boolean IsConnected=false;
private String TempIp;
public String TempIp;
private int TempPort;
private String TempCom;
private int TempBaudRate;


+ 2
- 2
build.gradle View File

@@ -35,8 +35,8 @@ task clean(type: Delete) {

ext { // 统一版本入口
//App版本号
versionCode = 1
versionName = "1.0.0"
versionCode = 101
versionName = "1.0.1"

// 支持Android版本
buildToolsVersion = "33.0.0"


Loading…
Cancel
Save