Pārlūkot izejas kodu

调试

调味吧台(白底)
fyf pirms 1 gada
vecāks
revīzija
9a201717a4
3 mainītis faili ar 54 papildinājumiem un 7 dzēšanām
  1. +33
    -2
      app/src/main/java/com/example/bpa/helper/ModbusTcpServer.java
  2. +11
    -5
      app/src/main/java/com/example/bpa/service/DeviceData.java
  3. +10
    -0
      app/src/main/java/com/example/bpa/service/ScanCodeServer.java

+ 33
- 2
app/src/main/java/com/example/bpa/helper/ModbusTcpServer.java Parādīt failu

@@ -295,10 +295,11 @@ public class ModbusTcpServer {
try {
ReadHoldingRegistersResponse res = ModbusTcpHelper.get().syncReadHoldingRegisters(1, add, length);
byte[] data = res.getData();

byte[] data1= Arrays.copyOfRange(data, 0, 36);
//36 GUID 18 Number
String id="";
try {
id = new String(data, "UTF-8");
id = new String(data1, "UTF-8").trim();
} catch (UnsupportedEncodingException ex) {
}
if(callback!=null) callback.onSuccess(id);
@@ -314,6 +315,36 @@ public class ModbusTcpServer {
MessageLog.ShowError("ReadShort onFailure,Address=" + Address + ",length=" + length + ",msg:" + e.toString());
}
}

public void WriteString(String Address, int length, IWriteCallBack callback) {
int add = GetAddress(Address);
if (add < 0) return;
short[] send = new short[length];
for (short item:send)
{
item=0;
}
try {
ModbusTcpHelper.get().syncWriteRegisters(1, add, send);
if(callback!=null)
callback.onSuccess();
} catch (InterruptedException e) {
MessageLog.ShowError("WriteShort onFailure,Address=" + Address + ",length=" + length + ",msg:" + e.toString());
if(callback!=null)callback.onFailure(e.toString());
} catch (ExecutionException e) {
MessageLog.ShowError("WriteShort onFailure,Address=" + Address + ",length=" + length + ",msg:" + e.toString());
if(callback!=null)callback.onFailure(e.toString());
} catch (ModbusTransportException e) {
MessageLog.ShowError("WriteShort onFailure,Address=" + Address + ",length=" + length + ",msg:" + e.toString());
if(callback!=null)callback.onFailure(e.toString());
} catch (ModbusInitException e) {
MessageLog.ShowError("WriteShort onFailure,Address=" + Address + ",length=" + length + ",msg:" + e.toString());
if(callback!=null)callback.onFailure(e.toString());
} catch (ModbusRespException e) {
MessageLog.ShowError("WriteShort onFailure,Address=" + Address + ",length=" + length + ",msg:" + e.toString());
if(callback!=null)callback.onFailure(e.toString());
}
}
public void ReadShort(String Address, int length, IReadCallBack<short[]> callback) {
int add = GetAddress(Address);
if (add < 0) return;


+ 11
- 5
app/src/main/java/com/example/bpa/service/DeviceData.java Parādīt failu

@@ -120,14 +120,15 @@ public class DeviceData {

//读取当前扫码信息
ModbusTcpServer.get().ReadString("VW342", 20, (data) -> {
MessageLog.ShowInfo("当前扫码信息:"+data);
if(!Code.equals(data))
{
Code=data;
if(OnScanTheCodeInformationT!=null)
if(!data.isEmpty() && OnScanTheCodeInformationT!=null)
{
OnScanTheCodeInformationT.Run(Code);
MessageLog.ShowInfo("当前扫码信息:"+data);
OnScanTheCodeInformationT.Run(data);
}
Code=data;
}
//1.查询订单信息
//2.展示订单界面
@@ -875,5 +876,10 @@ public class DeviceData {
ModbusTcpServer.get().WriteShort("VW254", value, callback);
}


/**
* 扫码清零
*/
public void setCodeClear(IWriteCallBack callback) {
ModbusTcpServer.get().WriteString("VW342", 20, callback);
}
}

+ 10
- 0
app/src/main/java/com/example/bpa/service/ScanCodeServer.java Parādīt failu

@@ -3,6 +3,7 @@ package com.example.bpa.service;
import com.example.bpa.Model.IRun;
import com.example.bpa.Model.IRunT;
import com.example.bpa.Model.IThread;
import com.example.bpa.Model.IWriteCallBack;
import com.example.bpa.app.Main;
import com.example.bpa.helper.MessageLog;
import com.example.bpa.helper.ModbusTcpServer;
@@ -46,6 +47,15 @@ public class ScanCodeServer {
//4.回馈订单信息
Code=s;
Main.getInstance().GetOrder(Code);
DeviceData.Get().setCodeClear(new IWriteCallBack() {
@Override
public void onSuccess() {
}
@Override
public void onFailure(String ErrorMsg) {
}
});

}
};
}


Notiek ielāde…
Atcelt
Saglabāt