Browse Source

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	app/src/main/AndroidManifest.xml
#	app/src/main/java/com/example/bpa/app/ICSApp.java
#	app/src/main/res/layout/datatab/values/strings.xml
master
NXX 1 year ago
parent
commit
f442ec5258
51 changed files with 2789 additions and 643 deletions
  1. +2
    -0
      .idea/gradle.xml
  2. +4
    -5
      app/build.gradle
  3. BIN
     
  4. BIN
     
  5. +8
    -2
      app/src/main/AndroidManifest.xml
  6. +9
    -0
      app/src/main/java/com/example/bpa/Model/IMessageLogNotify.java
  7. +7
    -0
      app/src/main/java/com/example/bpa/Model/IThread.java
  8. +7
    -0
      app/src/main/java/com/example/bpa/Model/ThreadModel.java
  9. +8
    -0
      app/src/main/java/com/example/bpa/app/DataFormat.java
  10. +354
    -0
      app/src/main/java/com/example/bpa/app/DeviceData.java
  11. +5
    -0
      app/src/main/java/com/example/bpa/app/IReadCallBack.java
  12. +2
    -2
      app/src/main/java/com/example/bpa/app/Main.java
  13. +35
    -0
      app/src/main/java/com/example/bpa/app/ModbusTcpHelper.java
  14. +287
    -0
      app/src/main/java/com/example/bpa/app/ModbusTcpServer.java
  15. +0
    -138
      app/src/main/java/com/example/bpa/app/PLC.java
  16. +245
    -23
      app/src/main/java/com/example/bpa/db/QueryDB.java
  17. +31
    -0
      app/src/main/java/com/example/bpa/helper/MessageLog.java
  18. +3
    -1
      app/src/main/java/com/example/bpa/helper/SdCart.java
  19. +75
    -0
      app/src/main/java/com/example/bpa/helper/ThreadManager.java
  20. +0
    -52
      app/src/main/java/com/example/bpa/modbus4j/ModbusParam.java
  21. +0
    -364
      app/src/main/java/com/example/bpa/modbus4j/ModbusReq.java
  22. +0
    -6
      app/src/main/java/com/example/bpa/modbus4j/OnRequestBack.java
  23. +69
    -0
      app/src/main/java/com/example/bpa/view/adapter/lsjy_adapter.java
  24. +95
    -0
      app/src/main/java/com/example/bpa/view/adapter/pf_adapter.java
  25. +106
    -0
      app/src/main/java/com/example/bpa/view/adapter/sp_adapter.java
  26. +0
    -5
      app/src/main/java/com/example/bpa/view/fragment/SystemCapabilitiesFragment.java
  27. +126
    -2
      app/src/main/java/com/example/bpa/view/fragment/SystemSetFragment.java
  28. +227
    -0
      app/src/main/java/com/example/bpa/view/from/add_pf_activity.java
  29. +54
    -1
      app/src/main/java/com/example/bpa/view/from/dzcjy_activity.java
  30. +52
    -3
      app/src/main/java/com/example/bpa/view/from/lsjy_activity.java
  31. +3
    -3
      app/src/main/java/com/example/bpa/view/from/wlgl_activity.java
  32. +104
    -4
      app/src/main/java/com/example/bpa/view/from/yfpf_activity.java
  33. +11
    -0
      app/src/main/java/com/example/bpa/view/mode/ResGoodsRecipe.java
  34. +14
    -0
      app/src/main/java/com/example/bpa/view/mode/ResSilosMode.java
  35. +97
    -0
      app/src/main/res/layout/datatab/layout/lsjy_item.xml
  36. +102
    -0
      app/src/main/res/layout/datatab/layout/pf_item.xml
  37. +120
    -0
      app/src/main/res/layout/datatab/layout/sp_item.xml
  38. +1
    -4
      app/src/main/res/layout/datatab/values/strings.xml
  39. +250
    -0
      app/src/main/res/layout/from/layout/activity_add_pf.xml
  40. +4
    -7
      app/src/main/res/layout/from/layout/activity_dzcjy.xml
  41. +121
    -7
      app/src/main/res/layout/from/layout/activity_lsjy.xml
  42. +130
    -7
      app/src/main/res/layout/from/layout/activity_yfpf.xml
  43. +17
    -5
      app/src/main/res/layout/from/layout/fragment_system_set.xml
  44. BIN
     
  45. BIN
     
  46. BIN
     
  47. BIN
     
  48. BIN
     
  49. BIN
     
  50. +3
    -2
      build.gradle
  51. +1
    -0
      settings.gradle

+ 2
- 0
.idea/gradle.xml View File

@@ -7,6 +7,8 @@
<option name="testRunner" value="GRADLE" />
<option name="distributionType" value="DEFAULT_WRAPPED" />
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleHome" value="D:/gradle-8.0.2-all/gradle-8.0.2" />
<option name="gradleJvm" value="Android Studio default JDK" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />


+ 4
- 5
app/build.gradle View File

@@ -43,14 +43,13 @@ android {

}
}

}

dependencies {
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.github.licheedev:Modbus4Android:2.0.2'
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
@@ -60,5 +59,5 @@ dependencies {
implementation files('libs\\gson-2.2.2.jar')
implementation files('libs\\sdkapi.jar')
compileOnly files('libs/sdkapi.jar')
implementation files('libs/modbus4J.jar')
implementation files('libs/modbus4Android-1.2.jar')
}

BIN
View File


BIN
View File


+ 8
- 2
app/src/main/AndroidManifest.xml View File

@@ -6,19 +6,25 @@
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.VIBRATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />


<application
android:name=".app.ICSApp"
android:allowBackup="true"
android:icon="@mipmap/ncd"
android:label="@string/app_name"
android:supportsRtl="false"
android:supportsRtl="true"
android:theme="@style/AppTheme"
android:requestLegacyExternalStorage="true"
tools:targetApi="31">
<activity
android:name=".view.from.add_pf_activity"
android:exported="false" />
<activity
android:name=".view.from.wlgl_activity"
android:exported="false"
android:configChanges="keyboard|keyboardHidden"/>
android:windowSoftInputMode="adjustPan|stateHidden" />
<activity
android:name=".view.from.yfpf_activity"
android:exported="false" />


+ 9
- 0
app/src/main/java/com/example/bpa/Model/IMessageLogNotify.java View File

@@ -0,0 +1,9 @@
package com.example.bpa.Model;

public interface IMessageLogNotify {
void ErrorMsg(String msg);

void InfoMsg(String msg);

void WarnMsg(String msg);
}

+ 7
- 0
app/src/main/java/com/example/bpa/Model/IThread.java View File

@@ -0,0 +1,7 @@
package com.example.bpa.Model;

public interface IThread {
void Run() throws InterruptedException;

void RunComplete() throws InterruptedException;
}

+ 7
- 0
app/src/main/java/com/example/bpa/Model/ThreadModel.java View File

@@ -0,0 +1,7 @@
package com.example.bpa.Model;

public class ThreadModel {
public IThread RunThread;
public boolean IsCancel;
public Thread ThreadObj;
}

+ 8
- 0
app/src/main/java/com/example/bpa/app/DataFormat.java View File

@@ -0,0 +1,8 @@
package com.example.bpa.app;

public enum DataFormat {
ABCD,
CDAB,
BADC,
DCBA
}

+ 354
- 0
app/src/main/java/com/example/bpa/app/DeviceData.java View File

@@ -0,0 +1,354 @@
package com.example.bpa.app;

import android.renderscript.Sampler;

import com.example.bpa.Model.IThread;
import com.example.bpa.helper.ThreadManager;

import java.util.concurrent.ConcurrentHashMap;

public class DeviceData {
private static volatile DeviceData _instance;

public static DeviceData Get() {
if (_instance == null)
_instance = new DeviceData();
return _instance;
}

public void Init() {
ThreadManager.Get().StartLong("Plc设备数据监听", true, new IThread() {
@Override
public void Run() throws InterruptedException {


Thread.sleep(10);
}

@Override
public void RunComplete() throws InterruptedException {

}
});
}

/**
* 称当前重量
*/
ConcurrentHashMap<Integer, Float> CallCurrentWeight = new ConcurrentHashMap<Integer, Float>();
/**
* 手自动模式
*/
boolean HandOrAutoMode;

/**
* 清洗模式
*/
boolean CleaningMode;

/**
* 清洗完成
*/
boolean CleaningComplete;

/**
* 一键去皮完成状态
*/
boolean OneClickPeelingComplete;

/**
* 校准模式
*/
boolean CalibrationMode;

/**
* 校准值写入
* ,PLC 地址VW100--VW118
*
* @param value 需要写入的值
* @param ch 需要写入的通道编号,1--10
*/
public void setCalibrationValue(short value, int ch) {
if (ch >= 1 && ch <= 10) {
String add = "VW" + (98 + ch * 2);
ModbusTcpServer.get().WriteShort(add, value);
}
}

/**
* 需求值写入
* ,PLC 地址 VW200--VW218
*
* @param value 需要写入的值
* @param ch 需要写入的通道编号,1--10
*/
public void setDemandValue(short value, int ch) {
if (ch >= 1 && ch <= 10) {
String add = "VW" + (198 + ch * 2);
ModbusTcpServer.get().WriteShort(add, value);
}
}

/**
* 设置通道校准开关
* ,PLC 地址 M2.0--M3.1
*
* @param value 需要写入的值
* @param ch 需要写入的通道编号,1--10
*/
public void setChCalibrationSwitch(boolean value, int ch) {
if (ch >= 1 && ch <= 10) {
String add = ModbusTcpServer.get().getBitSingleAdd("M", 2, ch);
if (add.length() > 0)
ModbusTcpServer.get().WriteBool(add, value);
}
}

/**
* 称去皮校准
*
* @param value
* @param ch 设置称的通道号,ch1-ch8
*/
public void setRemovePeelCalibration(boolean value, int ch) {
if (ch >= 1 && ch <= 8) {
String add = ModbusTcpServer.get().getBitSingleAdd("M", 5, ch);
if (add.length() > 0)
ModbusTcpServer.get().WriteBool(add, value);
}
}

/**
* 砝码值写入
*
* @param value
* @param ch 设置称的砝码通道号,ch1-ch8
*/
public void setWeightValue(boolean value, int ch) {
if (ch >= 1 && ch <= 8) {
String add = ModbusTcpServer.get().getBitSingleAdd("M", 15, ch);
if (add.length() > 0)
ModbusTcpServer.get().WriteBool(add, value);
}
}

/**
* 重量清零
*/
public void setWeightClear() {
ModbusTcpServer.get().WriteBool("M6.0", true);
}

/**
* 关闭写保护
*/
public void setCloseWriteProtect() {
ModbusTcpServer.get().WriteBool("M6.1", true);
}

/**
* 打开写保护
*/
public void setOpenWriteProtect() {
ModbusTcpServer.get().WriteBool("M6.4", true);
}

/**
* 零点校准
*/
public void setZeroPointCalibration() {
ModbusTcpServer.get().WriteBool("M6.2", true);
}

/**
* 砝码值写入
*/
public void setWeightValueWrite() {
ModbusTcpServer.get().WriteBool("M6.3", true);
}

/**
* 砝码校准模式
*/
public void setWeightCalibrationMode() {
ModbusTcpServer.get().WriteBool("M6.5", true);
}

/**
* 启动通道校准
*/
public void setChStartCalibration() {
ModbusTcpServer.get().WriteBool("M0.0", true);
}

/**
* 启动配料
*/
public void setChargeMixtureStart() {
ModbusTcpServer.get().WriteBool("M0.1", true);
}

/**
* 手自动切换
*
* @param value true:自动模式,flase:手动模式
*/
public void setHandOrAutoSwitch(boolean value) {
ModbusTcpServer.get().WriteBool("M0.2", value);
}

/**
* 获取手自动模式的状态
*
* @return true:自动模式,flase:手动模式
*/
public boolean getHandOrAutoSwitch() {
return HandOrAutoMode;
}

/**
* 设置清洗模式
*
* @param value true:清洗模式,false:配料模式
*/
public void setCleaningMode(boolean value) {
ModbusTcpServer.get().WriteBool("M0.4", value);
}

/**
* 获取清洗模式
*
* @return true:清洗模式,false:配料模式
*/
public boolean getCleaningMode() {
return CleaningMode;
}

/**
* 设置开始清洗
*/
public void setStartCleaning() {
ModbusTcpServer.get().WriteBool("M0.5", true);
}

/**
* 设置一键去皮
*/
public void setOneClickPeeling() {
ModbusTcpServer.get().WriteBool("M1.2", true);
}

/**
* 设置一键去皮完成状态
*
* @param value
*/
public void setOneClickPeelingComplete(boolean value) {
OneClickPeelingComplete = value;
}

/**
* 获取清洗完成的状态
*
* @return
*/
public boolean getCleaningComplete() {
return CleaningComplete;
}

/**
* 设置校准模式
*
* @param value true:零点校准模式,false:清零去皮模式
*/
public void setCalibrationMode(boolean value) {
ModbusTcpServer.get().WriteBool("M1.4", value);
}

/**
* 获取校准模式
*
* @return true:零点校准模式,false:清零去皮模式
*/
public boolean getCalibrationMode() {
return CalibrationMode;
}

/**
* 获取指定称的当前重量
*
* @param ch 需要获取的通道号,称1--称9
* @return
*/
public float getCallCurrentWeight(int ch) {
if (!CallCurrentWeight.containsKey(ch)) {
return 0.0f;
}
return CallCurrentWeight.get(ch);
}

/**
* 设置校准基准时间
*
* @param value 需要写入的值
*/
public void setCalibrationReferenceTime(float value) {
ModbusTcpServer.get().WriteFloat("VD124", value);
}

/**
* 设置排水时间
*
* @param value
*/
public void setDrainageTime(short value) {
ModbusTcpServer.get().WriteShort("VW140", value);
}

/**
* 设置清洗剂添加时间
*
* @param value
*/
public void setAddCleaningAgentTime(short value) {
ModbusTcpServer.get().WriteShort("VW142", value);
}

/**
* 设置进水时间
*
* @param value
*/
public void setInletTime(short value) {
ModbusTcpServer.get().WriteShort("VW144", value);
}

/**
* 设置循环清洗时间
*
* @param value
*/
public void setCyclicCleaningTime(short value) {
ModbusTcpServer.get().WriteShort("VW146", value);
}

/**
* 设置8路称校准砝码重量
*
* @param value
*/
public void setCalibrationWeight(short value) {
ModbusTcpServer.get().WriteShort("250", value);
}

/**
* 设置称重9校准砝码重量
*
* @param value
*/
public void setCalibrationWeight9(short value) {
ModbusTcpServer.get().WriteShort("254", value);
}


}

+ 5
- 0
app/src/main/java/com/example/bpa/app/IReadCallBack.java View File

@@ -0,0 +1,5 @@
package com.example.bpa.app;

public interface IReadCallBack <T>{
void onSuccess(T t);
}

+ 2
- 2
app/src/main/java/com/example/bpa/app/Main.java View File

@@ -35,9 +35,9 @@ public class Main {
//1.加载配置
LoadingPZ();
//2.初始化PLC
PLC.getInstance().InitMobus();
// PLC.getInstance().InitMobus();
//3.初始化业务
//4.初始化日志上报
//4.初始化日志上报adad
}




+ 35
- 0
app/src/main/java/com/example/bpa/app/ModbusTcpHelper.java View File

@@ -0,0 +1,35 @@
package com.example.bpa.app;

import com.licheedev.modbus4android.ModbusWorker;


public class ModbusTcpHelper extends ModbusWorker {
private static volatile ModbusTcpHelper instance = null;

public static ModbusTcpHelper get() {
ModbusTcpHelper manager = instance;
if (manager == null) {
synchronized (ModbusTcpHelper.class) {
manager = instance;
if (manager == null) {
manager = new ModbusTcpHelper();
instance = manager;
}
}
}
return manager;
}

private ModbusTcpHelper() {
}

/**
* 释放整个ModbusManager,单例会被置null
*/
public synchronized void release() {
super.release();
instance = null;
}


}

+ 287
- 0
app/src/main/java/com/example/bpa/app/ModbusTcpServer.java View File

@@ -0,0 +1,287 @@
package com.example.bpa.app;


import android.util.Log;

import com.example.bpa.helper.MessageLog;
import com.licheedev.modbus4android.ModbusCallback;
import com.licheedev.modbus4android.ModbusParam;
import com.licheedev.modbus4android.param.TcpParam;
import com.serotonin.modbus4j.ModbusMaster;
import com.serotonin.modbus4j.msg.ReadCoilsResponse;
import com.serotonin.modbus4j.msg.ReadHoldingRegistersResponse;
import com.serotonin.modbus4j.msg.WriteCoilResponse;
import com.serotonin.modbus4j.msg.WriteRegistersResponse;

import java.lang.reflect.Type;
import java.nio.ByteBuffer;
import java.nio.FloatBuffer;
import java.nio.ShortBuffer;
import java.util.Arrays;
import java.util.LinkedList;

import io.reactivex.SingleConverter;


public class ModbusTcpServer {
private static volatile ModbusTcpServer instance = null;

public static ModbusTcpServer get() {
ModbusTcpServer manager = instance;
if (manager == null) {
synchronized (ModbusTcpServer.class) {
manager = instance;
if (manager == null) {
manager = new ModbusTcpServer();
instance = manager;
}
}
}
return manager;
}

private ModbusTcpServer() {
}

ModbusParam param;

private int GetAddress(String address) {
if (address == null) return -1;
if (address.length() > 0) {
address = address.trim();
if (address.toUpperCase().contains("M") && address.length() >= 4) {
String[] res = address.substring(1).split(".");
if (res != null && res.length == 2) {
try {
int firstAdd = Integer.parseInt(res[0]);
int endAdd = Integer.parseInt(res[1]);
if (endAdd >= 0 && endAdd <= 7) {
return (firstAdd * 8) + 320 + endAdd;
}
} catch (NumberFormatException e) {
return -1;
}
}
} else if ((address.toUpperCase().contains("VW") || address.toUpperCase().contains("VD")) && address.length() >= 3) {
String res = address.substring(2);
if (res != null) {
try {
int tempAdd = Integer.parseInt(res);
return (tempAdd / 2) + 100;
} catch (NumberFormatException e) {
return -1;
}
}
} else {
try {
return Integer.parseInt(address);
} catch (NumberFormatException e) {
return -1;
}
}
}
return -1;
}

/**
* 获取布尔位地址信息
* 列:M2.5 = getBitSingleAdd("M",2,5);
*
* @param Prefix 地址标头
* @param startAdd 起始地址编号
* @param num 要获取的第几位数量
* @return
*/
public String getBitSingleAdd(String Prefix, int startAdd, int num) {
if (num > 0) {
int FirstAdd = num / 8;
int EndAdd = num % 8;
if (EndAdd == 0) {
FirstAdd--;
EndAdd = 7;
} else {
EndAdd--;
}
return Prefix + FirstAdd + startAdd + "." + EndAdd;
}
return "";
}

/***
* Modbus 连接
* @param host 设备IP
* @param port 设备端口号
*/
public void Connect(String host, int port) {
param = TcpParam.create(host, port)
.setTimeout(1000)
.setRetries(0)
.setEncapsulated(false)
.setKeepAlive(true);
ModbusTcpHelper.get().init(param, new ModbusCallback<ModbusMaster>() {
@Override
public void onSuccess(ModbusMaster modbusMaster) {
MessageLog.ShowInfo("设备 " + host + " 连接成功");
}

@Override
public void onFailure(Throwable tr) {
MessageLog.ShowError("设备 " + host + " 连接失败:" + tr.getMessage());
}

@Override
public void onFinally() {

}
});
}

/***
*读取整形数据
* @param Address the address
* @param length 读取的长度
* @param callback 读取成功的回调
*/

public void ReadShort(String Address, int length, IReadCallBack<short[]> callback) {
int add = GetAddress(Address);
if (add < 0) return;
ModbusTcpHelper.get().readHoldingRegisters(1, add, length, new ModbusCallback<ReadHoldingRegistersResponse>() {
@Override
public void onSuccess(ReadHoldingRegistersResponse readHoldingRegistersResponse) {
short[] data = readHoldingRegistersResponse.getShortData();
callback.onSuccess(data);
}

@Override
public void onFailure(Throwable tr) {
MessageLog.ShowError("ReadShort onFailure,Address=" + Address + ",length=" + length + ",msg:" + tr.getMessage());
}

@Override
public void onFinally() {
}
});
}

public void ReadBool(String Address, int length, IReadCallBack<boolean[]> callback) {
int add = GetAddress(Address);
if (add < 0) return;
ModbusTcpHelper.get().readCoil(1, add, length, new ModbusCallback<ReadCoilsResponse>() {
@Override
public void onSuccess(ReadCoilsResponse readCoilsResponse) {
boolean[] data = readCoilsResponse.getBooleanData();
boolean[] result = Arrays.copyOfRange(data, 0, length);
callback.onSuccess(result);
}

@Override
public void onFailure(Throwable tr) {
MessageLog.ShowError("ReadBool onFailure,Address=" + Address + ",length=" + length + ",msg:" + tr.getMessage());
}

@Override
public void onFinally() {
}
});
}

public void ReadFloat(String Address, int length, IReadCallBack<float[]> callback) {
int add = GetAddress(Address);
if (add < 0) return;
ModbusTcpHelper.get().readHoldingRegisters(1, add, length * 2, new ModbusCallback<ReadHoldingRegistersResponse>() {
@Override
public void onSuccess(ReadHoldingRegistersResponse readHoldingRegistersResponse) {
byte[] data = readHoldingRegistersResponse.getData();
float[] tempValues = new float[length];
for (int i = 0; i < length; i++) {
byte[] tempData = new byte[4];
for (int m = 0; m < 4; m++) {
tempData[m] = data[i * 4 + m];
}
tempValues[i] = ByteBuffer.wrap(tempData).getFloat();
}
callback.onSuccess(tempValues);
}

@Override
public void onFailure(Throwable tr) {
MessageLog.ShowError("ReadFloat onFailure,Address=" + Address + ",length=" + length + ",msg:" + tr.getMessage());
}

@Override
public void onFinally() {

}
});

}

public void WriteShort(String Address, short Value) {
int add = GetAddress(Address);
if (add < 0) return;
short[] send = new short[1];
send[0] = Value;
ModbusTcpHelper.get().writeRegisters(1, add, send, new ModbusCallback<WriteRegistersResponse>() {
@Override
public void onSuccess(WriteRegistersResponse writeRegistersResponse) {
MessageLog.ShowInfo("WriteShort onSuccess,Address=" + Address + ",Value=" + Value);
}

@Override
public void onFailure(Throwable tr) {
MessageLog.ShowError("WriteShort onFailure,Address=" + Address + ",Value=" + Value + ",msg:" + tr.getMessage());
}

@Override
public void onFinally() {

}
});
}

public void WriteBool(String Address, boolean Value) {
int add = GetAddress(Address);
if (add < 0) return;
ModbusTcpHelper.get().writeCoil(1, add, Value, new ModbusCallback<WriteCoilResponse>() {
@Override
public void onSuccess(WriteCoilResponse writeCoilResponse) {
MessageLog.ShowInfo("WriteBool onSuccess,Address=" + Address + ",Value=" + Value);
}

@Override
public void onFailure(Throwable tr) {
MessageLog.ShowError("WriteBool onFailure,Address=" + Address + ",Value=" + Value + ",msg:" + tr.getMessage());
}

@Override
public void onFinally() {

}
});
}

public void WriteFloat(String Address, float Value) {
int add = GetAddress(Address);
if (add < 0) return;
int intBits = Float.floatToRawIntBits(Value);
short[] send = new short[]{(short) ((intBits >> 16) & 0xffff), (short) (intBits & 0xffff)};
ModbusTcpHelper.get().writeRegisters(1, add, send, new ModbusCallback<WriteRegistersResponse>() {
@Override
public void onSuccess(WriteRegistersResponse writeRegistersResponse) {
MessageLog.ShowInfo("WriteFloat onSuccess,Address=" + Address + ",Value=" + Value);
}

@Override
public void onFailure(Throwable tr) {
MessageLog.ShowError("WriteFloat onFailure,Address=" + Address + ",Value=" + Value + ",msg:" + tr.getMessage());
}

@Override
public void onFinally() {

}
});
}

}

+ 0
- 138
app/src/main/java/com/example/bpa/app/PLC.java View File

@@ -1,138 +0,0 @@
package com.example.bpa.app;

import com.example.bpa.config.ConfigName;
import com.example.bpa.helper.MY;
import com.example.bpa.helper.T;
import com.example.bpa.modbus4j.ModbusParam;
import com.example.bpa.modbus4j.ModbusReq;
import com.example.bpa.modbus4j.OnRequestBack;

import java.text.SimpleDateFormat;
import java.util.Date;

/**
* PLC 控制
* add fengyoufu 20230414
*/
public class PLC {

//region 变量
/**
* Ip地址
*/
public String Host = "192.168.0.104";
/**
* 端口
*/
public int Post = 502;
/**
* 是否已连接
*/
public boolean IsConnect = false;
//endregion

//region 私有
private static PLC mInstance; //实例变量设置私有,防止直接通过类名访问

public static synchronized PLC getInstance() { //静态同步方法作为唯一的实例对象获取方式
if (mInstance == null) {
mInstance = new PLC();
}
return mInstance;
}

private PLC() { //默认构造函数私有,防止类外直接new创建对象

}
//endregion

//region 外部调用事件
/**
* 初始化Modbus
*/
public void InitMobus() {
/**
ModbusReq.getInstance().setParam(new ModbusParam()
.setHost(Host)//TCP PLC_IP地址
.setPort(Post)//端口默认502
.setEncapsulated(false)
.setKeepAlive(true)
.setTimeout(2000)
.setRetries(0))
.init(new OnRequestBack<String>() {
@Override
public void onSuccess(String s) {
T.show(ConfigName.getInstance().dishesCon, new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) + ":PLC连接成功!");
}

@Override
public void onFailed(String msg) {
T.show(ConfigName.getInstance().dishesCon, new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()) + ":PLC连接失败!" + msg);
}
});
**/
}

/**
* 写PLC
*
* @param address
* @param value
*/
public void WritePlcData(String address, Object value) {
byte slaveAddress = 1;
int startAddress = 200;//起始地址
//startAddress=address;

short[] shorts = new short[2];
shorts[0] = 100;
shorts[1] = 200;
//32位的float 拆成两个16位的short
// float value = 1000000.52f;
// int intBits = Float.floatToRawIntBits(value);
// int[] send = new int[]{(intBits >>> 16) & 0xFFFF, intBits & 0xFFFF};
//
// //注意高位低位处理
// short[] shorts = new short[2];
// shorts[0]=(short) send[1];
// shorts[1]=(short) send[0];
try {


ModbusReq.getInstance().writeRegisters(new OnRequestBack<String>() {
@Override
public void onSuccess(String s) {
}

@Override
public void onFailed(String msg) {
}
}, slaveAddress, startAddress, shorts);
} catch (Exception e) {
T.show(ConfigName.getInstance().dishesCon, "与PLC通信失败");
}
}

/**
* 读PLC数据
* @param address
*/
public void ReadPlcData(String address) {
byte slaveAddress = 1;
int startAddress = 200;//起始地址
try {
ModbusReq.getInstance().readInputRegisters(new OnRequestBack<short[]>() {
@Override
public void onSuccess(short[] var1) {
}
@Override
public void onFailed(String var1) {
}
}, slaveAddress, startAddress, 2);

} catch (Exception e) {
T.show(ConfigName.getInstance().dishesCon, "与PLC通信失败");
}
}
//endregion
}

+ 245
- 23
app/src/main/java/com/example/bpa/db/QueryDB.java View File

@@ -24,6 +24,8 @@ import com.example.bpa.db.mode.BPA_SYSTEMSET;
import com.example.bpa.db.mode.BPA_USER;
import com.example.bpa.db.mode.ModeBase;
import com.example.bpa.helper.Tools;
import com.example.bpa.view.mode.ResGoodsRecipe;
import com.example.bpa.view.mode.ResSilosMode;

import java.lang.reflect.Field;
import java.text.SimpleDateFormat;
@@ -134,6 +136,26 @@ public class QueryDB {
}
return data.size()>0;
}

/**
* 物料ID查询物料信息
* @param id
* @return
*/
public static BPA_MATERIAL GetMaterialID(String id)
{
BPA_MATERIAL bpa_material=null;
boolean isSucess=false;
String orderby=Desc_Time_Up;//出料顺序
String where="isDelete=? and id=?";
String[] args=new String[] { "0" ,id};
ArrayList<BPA_MATERIAL> data=new ArrayList<>();
ArrayList<Object> obj=Get(BPA_MATERIAL.class,where,args,orderby);
for (Object k:obj) {
bpa_material=(BPA_MATERIAL)k;
}
return bpa_material;
}
//endregion

//region BPA_SILOS 料仓管理表
@@ -182,6 +204,98 @@ public class QueryDB {
}
return data;
}
/**
* 获取料仓数据
* @return
*/
public static ArrayList<ResSilosMode> GetSilos()
{
ArrayList<ResSilosMode> data=new ArrayList<>();
//1.获取料仓数据
ArrayList<BPA_SILOS> silos=GetSilosALL();
//2.获取物料
ArrayList<BPA_MATERIAL> materials= GetMaterialALL();
//3.获取返回数据
for (BPA_SILOS k:silos) {
ResSilosMode par=new ResSilosMode();
par.id=k.id;
par.createTime=k.createTime;
par.updateTime=k.updateTime;
par.deleteTime=k.deleteTime;
par.deviceID=k.deviceID;
par.userID=k.userID;
par.isDelete=k.isDelete;
par.exp=k.exp;

par.num=k.num;
par.name=k.name;
par.warningValue=k.warningValue;
par.thrsoleValue=k.thrsoleValue;
par.plcValue=k.plcValue;
par.bValue=k.bValue;
par.jValue=k.jValue;
par.status=k.status;
par.Sort=k.Sort;

ArrayList<String> gx= GetMaterialList(k.id);
if(!gx.isEmpty() && gx.size()>0)
{
String wlid= gx.get(0);
if(!wlid.isEmpty())
{
BPA_MATERIAL wl=null;
for (BPA_MATERIAL m:materials) {
if(m.id.equals(wlid))
{
wl=m;
break;
}
}
if(wl!=null)
{
par.materialID=wl.id;
par.materialimgUrl=wl.imgUrl;
par.materialname=wl.name;
}
}
}

par.dvalue=0;
data.add(par);
}
return data;
}
/**
* 根据ID查询料仓管理
* @return
*/
public static BPA_SILOS GetSilosID(String id)
{
BPA_SILOS data=null;
String orderby=Desc_Sort_Up+','+Desc_Time_Up;//先按排序 创建时间倒序
String where="isDelete=? and id=?";
String[] args=new String[] { "0",id };
ArrayList<Object> obj=Get(BPA_SILOS.class,where,args,orderby);
for (Object k:obj) {
data=(BPA_SILOS)k;
}
return data;
}

/**
* 修改校准值
* @param id
* @param data
*/
public static void UpdateJYZ(String id, int data)
{
BPA_SILOS silos= GetSilosID(id);
if(silos!=null)
{
silos.jValue=data;
Update(BPA_SILOS.class,silos);
}
}
//endregion

//region BPA_SILOSANDMATERIAL 料仓物料关联表
@@ -312,6 +426,77 @@ public class QueryDB {
}
return data;
}
/**
* 判断商品数据是否存在
* @param name
* @return
*/
public static boolean GetGoodsIs(String name)
{
boolean isSucess=false;
String orderby=Desc_Time_Up;//出料顺序
String where="isDelete=? and name=?";
String[] args=new String[] { "0" ,name};
ArrayList<BPA_GOODS> data=new ArrayList<>();
ArrayList<Object> obj=Get(BPA_GOODS.class,where,args,orderby);
for (Object k:obj) {
data.add((BPA_GOODS)k);
}
return data.size()>0;
}

/**
* 根据排序查询商品
* @param sort
* @return
*/
public static BPA_GOODS GetGoodsSortIs(int sort)
{
boolean isSucess=false;
String orderby=Desc_Time_Up;//出料顺序
String where="isDelete=? and sort=?";
String[] args=new String[] { "0" ,sort+""};
BPA_GOODS data=null;
ArrayList<Object> obj=Get(BPA_GOODS.class,where,args,orderby);
for (Object k:obj) {
data=(BPA_GOODS)k;
}
return data;
}

/**
* 商品数据排序
* @param data 数据
* @param type 0 下移动 1 上移动
* @return
*/
public static void GetGoodsSort(BPA_GOODS data,int type)
{
if(type==0)
{
BPA_GOODS q_data= data;
BPA_GOODS h_data= GetGoodsSortIs(data.sort+1);
if(h_data!=null)
{
h_data.sort=h_data.sort-1;
UpdateGoods(h_data);
}
q_data.sort=q_data.sort+1;
UpdateGoods(q_data);

}else
{
BPA_GOODS q_data= GetGoodsSortIs(data.sort-1);
BPA_GOODS h_data= data;
if(q_data!=null)
{
q_data.sort=q_data.sort+1;
UpdateGoods(q_data);
}
h_data.sort=h_data.sort-1;
UpdateGoods(h_data);
}
}
//endregion

//region BPA_GOODSRECIPE 商品配方明细表
@@ -366,18 +551,53 @@ public class QueryDB {
* @param id
* @return
*/
public static ArrayList<BPA_GOODSRECIPE> GetGoodsSrecipeList(String id)
public static ArrayList<ResGoodsRecipe> GetGoodsSrecipeList(String id)
{
String orderby=Desc_Sort_Up+','+Desc_Time_Up;//先按排序 创建时间倒序
String where="isDelete=? and goodsID=?";
String[] args=new String[] { "0",id };
ArrayList<BPA_GOODSRECIPE> data=new ArrayList<>();
ArrayList<ResGoodsRecipe> data=new ArrayList<>();
ArrayList<Object> obj=Get(BPA_GOODSRECIPE.class,where,args,orderby);
for (Object k:obj) {
data.add(((BPA_GOODSRECIPE)k));
for (Object item:obj) {
BPA_GOODSRECIPE k=(BPA_GOODSRECIPE)item;
BPA_MATERIAL ma= GetMaterialID(k.materialID);
if(ma!=null)
{
ResGoodsRecipe par=new ResGoodsRecipe();
par.id=k.id;
par.createTime=k.createTime;
par.updateTime=k.updateTime;
par.deleteTime=k.deleteTime;
par.deviceID=k.deviceID;
par.userID=k.userID;
par.isDelete=k.isDelete;
par.exp=k.exp;
par.materialName=ma.name;

par.goodsID=k.goodsID;
par.materialID=k.materialID;
par.value=k.value;
par.sort=k.sort;
data.add(par);
}
}
return data;
}
/**
* 根据商品id删除配料信息
* @param id
* @return
*/
public static Boolean DeleteGoodsSrecipeList(String id)
{
if (id.isEmpty())
return false;
SQLiteDatabase db = helper.getWritableDatabase();
long delete=db.delete(BPA_GOODSRECIPE.class.getSimpleName(), "goodsID=?",
new String[] { id });
db.close();
return delete>0;
}
//endregion

//region BPA_ORDER 订单表
@@ -1022,25 +1242,28 @@ public class QueryDB {
if (id.isEmpty())
return false;
for (String key : map.keySet()) {
Object value = map.get(key);
if(value instanceof String)
{
cv.put(key, (String) value);
}else if (value instanceof Integer)
{
cv.put(key, ((Integer) value).intValue());
}else if (value instanceof Double)
if(!key.equals("id"))
{
cv.put(key, ((Double) value).doubleValue());
}else if (value instanceof Float)
{
cv.put(key, ((Float) value).floatValue());
}else if (value instanceof Long)
{
cv.put(key, ((Long) value).longValue());
}else if (value instanceof Boolean)
{
cv.put(key, ((Boolean) value).booleanValue());
Object value = map.get(key);
if(value instanceof String)
{
cv.put(key, (String) value);
}else if (value instanceof Integer)
{
cv.put(key, ((Integer) value).intValue());
}else if (value instanceof Double)
{
cv.put(key, ((Double) value).doubleValue());
}else if (value instanceof Float)
{
cv.put(key, ((Float) value).floatValue());
}else if (value instanceof Long)
{
cv.put(key, ((Long) value).longValue());
}else if (value instanceof Boolean)
{
cv.put(key, ((Boolean) value).booleanValue());
}
}
// else if (value instanceof Date)
// {
@@ -1048,7 +1271,6 @@ public class QueryDB {
// }
}
SQLiteDatabase db = helper.getWritableDatabase();
long insert = db.insert(c.getSimpleName(), null, cv);
db.update(c.getSimpleName(),cv,"id = ?", new String[] { id });
db.close();
return true;


+ 31
- 0
app/src/main/java/com/example/bpa/helper/MessageLog.java View File

@@ -0,0 +1,31 @@
package com.example.bpa.helper;

import com.example.bpa.Model.IMessageLogNotify;

import java.text.SimpleDateFormat;
import java.util.Date;

public class MessageLog {
public static IMessageLogNotify MsgNotify;

public static void ShowInfo(String msg) {
SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
Date date = new Date();
if (MsgNotify != null)
MsgNotify.InfoMsg(formatter.format(date) + ":" + msg);
}

public static void ShowWarning(String msg) {
SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
Date date = new Date();
if (MsgNotify != null)
MsgNotify.WarnMsg(formatter.format(date) + ":" + msg);
}

public static void ShowError(String msg) {
SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
Date date = new Date();
if (MsgNotify != null)
MsgNotify.ErrorMsg(formatter.format(date) + ":" + msg);
}
}

+ 3
- 1
app/src/main/java/com/example/bpa/helper/SdCart.java View File

@@ -27,6 +27,8 @@ public class SdCart {
}
return mInstance;
}


//endregion
/**
* 初始化数据库到SD卡
@@ -44,7 +46,7 @@ public class SdCart {
ConfigName.getInstance().dbPath = ConfigName.getInstance().appResRoot + "/hbl.db";
File rootFile = new File(ConfigName.getInstance().appResRoot);
if (!rootFile.exists()) //创建目录
{
{ Log.i("日志",ConfigName.getInstance().sdCardPath);
rootFile.mkdirs();
}
File file = new File(ConfigName.getInstance().dbPath);


+ 75
- 0
app/src/main/java/com/example/bpa/helper/ThreadManager.java View File

@@ -0,0 +1,75 @@
package com.example.bpa.helper;

import com.example.bpa.Model.IThread;
import com.example.bpa.Model.ThreadModel;

import java.util.concurrent.ConcurrentHashMap;

public class ThreadManager {
private static volatile ThreadManager _Instance;

public static ThreadManager Get() {
if (_Instance == null)
_Instance = new ThreadManager();
return _Instance;
}

private ThreadManager() {

}

public long RestartInterval = 2000;
ConcurrentHashMap<String, ThreadModel> ts = new ConcurrentHashMap<>();

public void StartLong(String Key, boolean IsRestart, IThread _thread) {
if (!ts.containsKey(Key)) {
ts.put(Key, new ThreadModel());
ts.get(Key).RunThread = _thread;
ts.get(Key).ThreadObj = new Thread(new Runnable() {
@Override
public void run() {
MessageLog.ShowInfo("启动线程:" + Key);
while (!ts.get(Key).IsCancel) {
if (IsRestart) {
try {
ts.get(Key).RunThread.Run();
} catch (Exception ex) {
MessageLog.ShowError("多线程:" + Key + "运行发生异常,已重启,errorMsg:" + ex.toString());
try {
Thread.sleep(RestartInterval);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
} else {
try {
ts.get(Key).RunThread.Run();
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}
MessageLog.ShowInfo("线程:[" + Key + "]--执行完成");
try {
ts.get(Key).RunThread.RunComplete();
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
ts.remove(Key);
}
});
ts.get(Key).ThreadObj.setName(Key);
ts.get(Key).ThreadObj.start();
} else {
MessageLog.ShowWarning("任务-[" + Key + "]-已存在");
}
}


public void Stop(String Key) {
if (ts.containsKey(Key)) {
ts.get(Key).IsCancel = true;
}
}

}

+ 0
- 52
app/src/main/java/com/example/bpa/modbus4j/ModbusParam.java View File

@@ -1,52 +0,0 @@
package com.example.bpa.modbus4j;

/**
* Modebus 链接参数
*/
public class ModbusParam {
public String host;
public int port = 502;
public boolean encapsulated;
public int timeout = 500;
public int retries = 2;
public boolean keepAlive = true;
public boolean connected = false;

public ModbusParam() {
}

public ModbusParam setHost(String host) {
this.host = host;
return this;
}

public ModbusParam setPort(int port) {
this.port = port;
return this;
}

public ModbusParam setEncapsulated(boolean encapsulated) {
this.encapsulated = encapsulated;
return this;
}

public ModbusParam setTimeout(int timeout) {
this.timeout = timeout;
return this;
}

public ModbusParam setRetries(int retries) {
this.retries = retries;
return this;
}

public ModbusParam setConnected(boolean connected) {
this.connected = connected;
return this;
}

public ModbusParam setKeepAlive(boolean keepAlive) {
this.keepAlive = keepAlive;
return this;
}
}

+ 0
- 364
app/src/main/java/com/example/bpa/modbus4j/ModbusReq.java View File

@@ -1,364 +0,0 @@
package com.example.bpa.modbus4j;

import android.util.Log;

import com.serotonin.modbus4j.ModbusFactory;
import com.serotonin.modbus4j.ModbusMaster;
import com.serotonin.modbus4j.exception.ModbusInitException;
import com.serotonin.modbus4j.exception.ModbusTransportException;
import com.serotonin.modbus4j.ip.IpParameters;
import com.serotonin.modbus4j.msg.ReadCoilsRequest;
import com.serotonin.modbus4j.msg.ReadCoilsResponse;
import com.serotonin.modbus4j.msg.ReadDiscreteInputsRequest;
import com.serotonin.modbus4j.msg.ReadDiscreteInputsResponse;
import com.serotonin.modbus4j.msg.ReadExceptionStatusRequest;
import com.serotonin.modbus4j.msg.ReadExceptionStatusResponse;
import com.serotonin.modbus4j.msg.ReadHoldingRegistersRequest;
import com.serotonin.modbus4j.msg.ReadHoldingRegistersResponse;
import com.serotonin.modbus4j.msg.ReadInputRegistersRequest;
import com.serotonin.modbus4j.msg.ReadInputRegistersResponse;
import com.serotonin.modbus4j.msg.ReportSlaveIdRequest;
import com.serotonin.modbus4j.msg.ReportSlaveIdResponse;
import com.serotonin.modbus4j.msg.WriteCoilRequest;
import com.serotonin.modbus4j.msg.WriteCoilResponse;
import com.serotonin.modbus4j.msg.WriteCoilsRequest;
import com.serotonin.modbus4j.msg.WriteCoilsResponse;
import com.serotonin.modbus4j.msg.WriteMaskRegisterRequest;
import com.serotonin.modbus4j.msg.WriteMaskRegisterResponse;
import com.serotonin.modbus4j.msg.WriteRegisterRequest;
import com.serotonin.modbus4j.msg.WriteRegisterResponse;
import com.serotonin.modbus4j.msg.WriteRegistersRequest;
import com.serotonin.modbus4j.msg.WriteRegistersResponse;

import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

public class ModbusReq {
private static final String TAG = ModbusReq.class.getSimpleName();
private static ModbusReq modbusReq;
private ModbusMaster mModbusMaster;
private ModbusParam modbusParam = new ModbusParam();
ExecutorService executorService = Executors.newFixedThreadPool(1);
private boolean isInit = false;

private ModbusReq() {
}

public static synchronized ModbusReq getInstance() {
if (modbusReq == null) {
modbusReq = new ModbusReq();
}

return modbusReq;
}

public ModbusReq setParam(ModbusParam modbusParam) {
this.modbusParam = modbusParam;
return modbusReq;
}

public void init(final OnRequestBack<String> onRequestBack) {
ModbusFactory mModbusFactory = new ModbusFactory();
IpParameters params = new IpParameters();
params.setHost(this.modbusParam.host);
params.setPort(this.modbusParam.port);
params.setEncapsulated(this.modbusParam.encapsulated);
this.mModbusMaster = mModbusFactory.createTcpMaster(params, this.modbusParam.keepAlive);
this.mModbusMaster.setRetries(this.modbusParam.retries);
this.mModbusMaster.setTimeout(this.modbusParam.timeout);
this.executorService.submit(new Runnable() {
public void run() {
try {
ModbusReq.this.mModbusMaster.init();
} catch (ModbusInitException var2) {
ModbusReq.this.mModbusMaster.destroy();
ModbusReq.this.isInit = false;
Log.d(ModbusReq.TAG, "Modbus4Android init failed " + var2);
onRequestBack.onFailed("Modbus4Android init failed ");
return;
}

Log.d(ModbusReq.TAG, "Modbus4Android init success");
ModbusReq.this.isInit = true;
onRequestBack.onSuccess("Modbus4Android init success");
}
});
}

public void destory() {
modbusReq = null;
this.mModbusMaster.destroy();
this.isInit = false;
}

public void readCoil(final OnRequestBack<boolean[]> onRequestBack, final int slaveId, final int start, final int len) {
if (!this.isInit) {
onRequestBack.onFailed("Modbus master is not inited successfully...");
} else {
this.executorService.submit(new Runnable() {
public void run() {
try {
ReadCoilsRequest request = new ReadCoilsRequest(slaveId, start, len);
ReadCoilsResponse response = (ReadCoilsResponse)ModbusReq.this.mModbusMaster.send(request);
if (response.isException()) {
onRequestBack.onFailed(response.getExceptionMessage());
} else {
boolean[] booleanData = response.getBooleanData();
boolean[] resultByte = new boolean[len];
System.arraycopy(booleanData, 0, resultByte, 0, len);
onRequestBack.onSuccess(resultByte);
}
} catch (ModbusTransportException var5) {
var5.printStackTrace();
onRequestBack.onFailed(var5.toString());
}

}
});
}
}

public void readDiscreteInput(final OnRequestBack<boolean[]> onRequestBack, final int slaveId, final int start, final int len) {
if (!this.isInit) {
onRequestBack.onFailed("Modbus master is not inited successfully...");
} else {
this.executorService.submit(new Runnable() {
public void run() {
try {
ReadDiscreteInputsRequest request = new ReadDiscreteInputsRequest(slaveId, start, len);
ReadDiscreteInputsResponse response = (ReadDiscreteInputsResponse)ModbusReq.this.mModbusMaster.send(request);
if (response.isException()) {
onRequestBack.onFailed(response.getExceptionMessage());
} else {
boolean[] booleanData = response.getBooleanData();
boolean[] resultByte = new boolean[len];
System.arraycopy(booleanData, 0, resultByte, 0, len);
onRequestBack.onSuccess(resultByte);
}
} catch (ModbusTransportException var5) {
var5.printStackTrace();
onRequestBack.onFailed(var5.toString());
}

}
});
}
}

public void readHoldingRegisters(final OnRequestBack<short[]> onRequestBack, final int slaveId, final int start, final int len) {
if (!this.isInit) {
onRequestBack.onFailed("Modbus master is not inited successfully...");
} else {
this.executorService.submit(new Runnable() {
public void run() {
try {
ReadHoldingRegistersRequest request = new ReadHoldingRegistersRequest(slaveId, start, len);
ReadHoldingRegistersResponse response = (ReadHoldingRegistersResponse)ModbusReq.this.mModbusMaster.send(request);
if (response.isException()) {
onRequestBack.onFailed(response.getExceptionMessage());
} else {
onRequestBack.onSuccess(response.getShortData());
}
} catch (ModbusTransportException var3) {
var3.printStackTrace();
onRequestBack.onFailed(var3.toString());
}

}
});
}
}

public void readInputRegisters(final OnRequestBack<short[]> onRequestBack, final int slaveId, final int start, final int len) {
if (!this.isInit) {
onRequestBack.onFailed("Modbus master is not inited successfully...");
} else {
this.executorService.submit(new Runnable() {
public void run() {
try {
ReadInputRegistersRequest request = new ReadInputRegistersRequest(slaveId, start, len);
ReadInputRegistersResponse response = (ReadInputRegistersResponse)ModbusReq.this.mModbusMaster.send(request);
if (response.isException()) {
onRequestBack.onFailed(response.getExceptionMessage());
} else {
onRequestBack.onSuccess(response.getShortData());
}
} catch (ModbusTransportException var3) {
var3.printStackTrace();
onRequestBack.onFailed(var3.toString());
}

}
});
}
}

public void writeCoil(final OnRequestBack<String> onRequestBack, final int slaveId, final int offset, final boolean value) {
if (!this.isInit) {
onRequestBack.onFailed("Modbus master is not inited successfully...");
} else {
this.executorService.submit(new Runnable() {
public void run() {
try {
WriteCoilRequest request = new WriteCoilRequest(slaveId, offset, value);
WriteCoilResponse response = (WriteCoilResponse)ModbusReq.this.mModbusMaster.send(request);
if (response.isException()) {
onRequestBack.onFailed(response.getExceptionMessage());
} else {
onRequestBack.onSuccess("Success");
}
} catch (ModbusTransportException var3) {
var3.printStackTrace();
onRequestBack.onFailed(var3.toString());
}

}
});
}
}

public void writeCoils(final OnRequestBack<String> onRequestBack, final int slaveId, final int start, final boolean[] values) {
if (!this.isInit) {
onRequestBack.onFailed("Modbus master is not inited successfully...");
} else {
this.executorService.submit(new Runnable() {
public void run() {
try {
WriteCoilsRequest request = new WriteCoilsRequest(slaveId, start, values);
WriteCoilsResponse response = (WriteCoilsResponse)ModbusReq.this.mModbusMaster.send(request);
if (response.isException()) {
onRequestBack.onFailed(response.getExceptionMessage());
} else {
onRequestBack.onSuccess("Success");
}
} catch (ModbusTransportException var3) {
var3.printStackTrace();
onRequestBack.onFailed(var3.toString());
}

}
});
}
}

public void writeRegister(final OnRequestBack<String> onRequestBack, final int slaveId, final int offset, final int value) {
if (!this.isInit) {
onRequestBack.onFailed("Modbus master is not inited successfully...");
} else {
this.executorService.submit(new Runnable() {
public void run() {
try {
WriteRegisterRequest request = new WriteRegisterRequest(slaveId, offset, value);
WriteRegisterResponse response = (WriteRegisterResponse)ModbusReq.this.mModbusMaster.send(request);
if (response.isException()) {
onRequestBack.onFailed(response.getExceptionMessage());
} else {
onRequestBack.onSuccess("Success");
}
} catch (ModbusTransportException var3) {
var3.printStackTrace();
onRequestBack.onFailed(var3.toString());
}

}
});
}
}

public void writeRegisters(final OnRequestBack<String> onRequestBack, final int slaveId, final int start, final short[] values) {
if (!this.isInit) {
onRequestBack.onFailed("Modbus master is not inited successfully...");
} else {
this.executorService.submit(new Runnable() {
public void run() {
try {
WriteRegistersRequest request = new WriteRegistersRequest(slaveId, start, values);
WriteRegistersResponse response = (WriteRegistersResponse)ModbusReq.this.mModbusMaster.send(request);
if (response.isException()) {
onRequestBack.onFailed(response.getExceptionMessage());
} else {
onRequestBack.onSuccess("Success");
}
} catch (ModbusTransportException var3) {
var3.printStackTrace();
onRequestBack.onFailed(var3.toString());
}

}
});
}
}


public void readExceptionStatus(final OnRequestBack<Byte> onRequestBack, final int slaveId) {
if (!this.isInit) {
onRequestBack.onFailed("Modbus master is not inited successfully...");
} else {
this.executorService.submit(new Runnable() {
public void run() {
try {
ReadExceptionStatusRequest request = new ReadExceptionStatusRequest(slaveId);
ReadExceptionStatusResponse response = (ReadExceptionStatusResponse)ModbusReq.this.mModbusMaster.send(request);
if (response.isException()) {
onRequestBack.onFailed(response.getExceptionMessage());
} else {
onRequestBack.onSuccess(response.getExceptionStatus());
}
} catch (ModbusTransportException var3) {
var3.printStackTrace();
onRequestBack.onFailed(var3.toString());
}

}
});
}
}

public void reportSlaveId(final OnRequestBack<byte[]> onRequestBack, final int slaveId) {
if (!this.isInit) {
onRequestBack.onFailed("Modbus master is not inited successfully...");
} else {
this.executorService.submit(new Runnable() {
public void run() {
try {
ReportSlaveIdRequest request = new ReportSlaveIdRequest(slaveId);
ReportSlaveIdResponse response = (ReportSlaveIdResponse)ModbusReq.this.mModbusMaster.send(request);
if (response.isException()) {
onRequestBack.onFailed(response.getExceptionMessage());
} else {
onRequestBack.onSuccess(response.getData());
}
} catch (ModbusTransportException var3) {
var3.printStackTrace();
onRequestBack.onFailed(var3.toString());
}

}
});
}
}

public void writeMaskRegister(final OnRequestBack<String> onRequestBack, final int slaveId, final int offset, final int and, final int or) {
if (!this.isInit) {
onRequestBack.onFailed("Modbus master is not inited successfully...");
} else {
this.executorService.submit(new Runnable() {
public void run() {
try {
WriteMaskRegisterRequest request = new WriteMaskRegisterRequest(slaveId, offset, and, or);
WriteMaskRegisterResponse response = (WriteMaskRegisterResponse)ModbusReq.this.mModbusMaster.send(request);
if (response.isException()) {
onRequestBack.onFailed(response.getExceptionMessage());
} else {
onRequestBack.onSuccess("Success");
}
} catch (ModbusTransportException var3) {
var3.printStackTrace();
onRequestBack.onFailed(var3.toString());
}

}
});
}
}
}

+ 0
- 6
app/src/main/java/com/example/bpa/modbus4j/OnRequestBack.java View File

@@ -1,6 +0,0 @@
package com.example.bpa.modbus4j;

public interface OnRequestBack<T> {
void onSuccess(T var1);
void onFailed(String var1);
}

+ 69
- 0
app/src/main/java/com/example/bpa/view/adapter/lsjy_adapter.java View File

@@ -0,0 +1,69 @@
package com.example.bpa.view.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.example.bpa.R;
import com.example.bpa.db.mode.BPA_MATERIAL;
import com.example.bpa.helper.T;
import com.example.bpa.view.inteface.MyClickListener;
import com.example.bpa.view.mode.ResSilosMode;

import java.util.List;

/**
* 流速校验DataTab
*/
public class lsjy_adapter extends ArrayAdapter<ResSilosMode> {
/**
* 内部点击事件
*/
private MyClickListener mListener;
private List<ResSilosMode> datas;
public lsjy_adapter(@NonNull Context context, int resource, @NonNull List<ResSilosMode> objects, MyClickListener listener) {
super(context, resource, objects);
mListener = listener;
datas=objects;
}
//每个子项被滚动到屏幕内的时候会被调用
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
ResSilosMode resSilosMode = (ResSilosMode) getItem(position);//得到当前项选中item实例
//为每一个子项加载设定的布局
View view = LayoutInflater.from(getContext()).inflate(R.layout.lsjy_item, parent, false);
//分别获取 image view 和 textview 的实例
TextView name = view.findViewById(R.id.name);
TextView lc_num = view.findViewById(R.id.lc_num);
TextView lc_bzls = view.findViewById(R.id.lc_bzls);
TextView lc_xyls = view.findViewById(R.id.lc_xyls);
Button button = view.findViewById(R.id.button_item);
// 设置要显示的图片和文字
name.setText(resSilosMode.materialname);
lc_num.setText(""+resSilosMode.num);
lc_bzls.setText(""+resSilosMode.bValue);
lc_xyls.setText(""+resSilosMode.jValue);

button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
try
{
mListener.clickListener(view,resSilosMode);
} catch (Exception e)
{
T.show(view.getContext(),"校验流速出错:"+e.getMessage());
}
}
});
return view;
}
}

+ 95
- 0
app/src/main/java/com/example/bpa/view/adapter/pf_adapter.java View File

@@ -0,0 +1,95 @@
package com.example.bpa.view.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.Spinner;
import android.widget.SpinnerAdapter;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.example.bpa.R;
import com.example.bpa.db.mode.BPA_MATERIAL;
import com.example.bpa.helper.T;
import com.example.bpa.view.inteface.MyClickListener;
import com.example.bpa.view.mode.ResGoodsRecipe;

import java.util.ArrayList;
import java.util.List;

/**
* 配料数据表格
*/
public class pf_adapter extends ArrayAdapter<ResGoodsRecipe> {
/**
* 内部点击事件
*/
private MyClickListener mListener;
private List<ResGoodsRecipe> datas;

ArrayList<String> wuliao=new ArrayList<>();

public pf_adapter(@NonNull Context context, int resource, @NonNull List<ResGoodsRecipe> objects, ArrayList<BPA_MATERIAL> wl, MyClickListener listener) {
super(context, resource, objects);
mListener = listener;
datas=objects;
if(wuliao.size()<=0)
{
wuliao=new ArrayList<>();
for (BPA_MATERIAL me:wl)
{
wuliao.add(me.name);
}
}
}
//每个子项被滚动到屏幕内的时候会被调用
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
ResGoodsRecipe resGoodsRecipe = (ResGoodsRecipe) getItem(position);//得到当前项选中item实例
//为每一个子项加载设定的布局
View view = LayoutInflater.from(getContext()).inflate(R.layout.pf_item, parent, false);
//分别获取 image view 和 textview 的实例
Spinner name = view.findViewById(R.id.name);
TextView sort = view.findViewById(R.id.sort);
TextView value = view.findViewById(R.id.value);
Button button = view.findViewById(R.id.button_item);
// 设置要显示的图片和文字
ArrayAdapter mAdapter = new android.widget.ArrayAdapter<String>(view.getContext(),
android.R.layout.simple_spinner_item);
mAdapter.addAll(wuliao);
name.setAdapter(mAdapter);

if(resGoodsRecipe.materialName!=null && !resGoodsRecipe.materialName.isEmpty())
{
SpinnerAdapter apsAdapter= name.getAdapter();
int k= apsAdapter.getCount();
for(int i=0;i<k;i++){
if(resGoodsRecipe.materialName.equals(apsAdapter.getItem(i).toString())){
name.setSelection(i,true);
break;
}
}
}
value.setText(resGoodsRecipe.value+"");
sort.setText(resGoodsRecipe.sort+"");
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
try
{
mListener.clickListener(view,resGoodsRecipe);
} catch (Exception e)
{
T.show(view.getContext(),"删除配方出错:"+e.getMessage());
}
}
});
return view;
}
}

+ 106
- 0
app/src/main/java/com/example/bpa/view/adapter/sp_adapter.java View File

@@ -0,0 +1,106 @@
package com.example.bpa.view.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.example.bpa.R;
import com.example.bpa.db.mode.BPA_GOODS;
import com.example.bpa.helper.T;
import com.example.bpa.view.inteface.MyClickListener;

import java.util.List;

/**
* 商品数据表格
*/
public class sp_adapter extends ArrayAdapter<BPA_GOODS> {
/**
* 内部点击事件
*/
private MyClickListener mListener;
private List<BPA_GOODS> datas;
public sp_adapter(@NonNull Context context, int resource, @NonNull List<BPA_GOODS> objects, MyClickListener listener) {
super(context, resource, objects);
mListener = listener;
datas=objects;
}
//每个子项被滚动到屏幕内的时候会被调用
@NonNull
@Override
public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
BPA_GOODS bpa_goods = (BPA_GOODS) getItem(position);//得到当前项选中item实例
//为每一个子项加载设定的布局
View view = LayoutInflater.from(getContext()).inflate(R.layout.sp_item, parent, false);
//分别获取 image view 和 textview 的实例
TextView name = view.findViewById(R.id.name);
TextView sort = view.findViewById(R.id.sort);
TextView time = view.findViewById(R.id.time);

Button button = view.findViewById(R.id.button_item);
Button button_up = view.findViewById(R.id.button_item_Up);
Button button_down = view.findViewById(R.id.button_item_Down);
Button button_update = view.findViewById(R.id.button_item_update);

// 设置要显示的图片和文字
name.setText(bpa_goods.name);
time.setText(bpa_goods.createTime);
sort.setText(bpa_goods.sort+"");
button.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
try
{
mListener.clickListener(view,bpa_goods);
} catch (Exception e)
{
T.show(view.getContext(),"删除商品出错:"+e.getMessage());
}
}
});
button_up.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
try
{
mListener.clickListener(view,bpa_goods);
} catch (Exception e)
{
T.show(view.getContext(),"商品排序出错:"+e.getMessage());
}
}
});
button_down.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
try
{
mListener.clickListener(view,bpa_goods);
} catch (Exception e)
{
T.show(view.getContext(),"商品排序出错:"+e.getMessage());
}
}
});
button_update.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
try
{
mListener.clickListener(view,bpa_goods);
} catch (Exception e)
{
T.show(view.getContext(),"商品修改出错:"+e.getMessage());
}
}
});
return view;
}
}

+ 0
- 5
app/src/main/java/com/example/bpa/view/fragment/SystemCapabilitiesFragment.java View File

@@ -2,7 +2,6 @@ package com.example.bpa.view.fragment;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.recyclerview.widget.RecyclerView;

@@ -11,14 +10,10 @@ import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import com.example.bpa.LoginActivity;
import com.example.bpa.MainActivity;
import com.example.bpa.R;
import com.example.bpa.config.ConfigName;
import com.example.bpa.helper.T;
import com.example.bpa.view.control.ItemClickListener;
import com.example.bpa.view.control.MainMeunAdapter;


+ 126
- 2
app/src/main/java/com/example/bpa/view/fragment/SystemSetFragment.java View File

@@ -2,24 +2,148 @@ package com.example.bpa.view.fragment;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;

import android.os.Bundle;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;

import com.example.bpa.Model.IMessageLogNotify;
import com.example.bpa.Model.IThread;
import com.example.bpa.Model.ThreadModel;
import com.example.bpa.R;
import com.example.bpa.app.IReadCallBack;
import com.example.bpa.app.ModbusTcpServer;
import com.example.bpa.helper.MessageLog;
import com.example.bpa.helper.ThreadManager;

/**
* 系统设置界面
*/
public class SystemSetFragment extends Fragment {

private Button ConBut;
private Button ReadBut;
private Button WriteBut;

@Nullable
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
View view = inflater.inflate(R.layout.fragment_system_set, container,false);
View view = inflater.inflate(R.layout.fragment_system_set, container, false);
Init(view);
return view;
}

private void Init(View tempView) {
ConBut = tempView.findViewById(R.id.ConnectDevice);
ReadBut = tempView.findViewById(R.id.ReadData);
WriteBut = tempView.findViewById(R.id.WriteData);

MessageLog.MsgNotify = new IMessageLogNotify() {
@Override
public void ErrorMsg(String msg) {
Log.e("Error", msg);
}

@Override
public void InfoMsg(String msg) {
Log.i("Info", msg);
}

@Override
public void WarnMsg(String msg) {
Log.w("Warn", msg);
}
};

ConBut.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
new Thread(new Runnable() {
@Override
public void run() {
ModbusTcpServer.get().Connect("192.168.1.14", 502);
}
}).start();
}
});

ReadBut.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {

ThreadManager.Get().StartLong("数据读取监听", true, new IThread() {
@Override
public void Run() throws InterruptedException {
// ModbusTcpServer.get().ReadShort(0, 3, new IReadCallBack<short[]>() {
// @Override
// public void onSuccess(short[] shorts) {
// for (int i = 0; i < shorts.length; i++) {
// MessageLog.ShowInfo("Shorts[" + i + "]=" + shorts[i]);
// }
// }
// });
//
// ModbusTcpServer.get().ReadFloat(10, 3, new IReadCallBack<float[]>() {
// @Override
// public void onSuccess(float[] floats) {
// for (int i = 0; i < floats.length; i++) {
// MessageLog.ShowInfo("Floats[" + i + "]=" + floats[i]);
// }
// }
// });
//
// ModbusTcpServer.get().ReadBool(0, 3, new IReadCallBack<boolean[]>() {
// @Override
// public void onSuccess(boolean[] booleans) {
// for (int i = 0; i < booleans.length; i++) {
// MessageLog.ShowInfo("Booleans[" + i + "]=" + booleans[i]);
// }
// }
// });

MessageLog.ShowInfo("开始执行");
boolean[] bools = new boolean[10];
for (int i = 0; i < 20; i++) {
bools[i] = true;
}

Thread.sleep(3000);

}

@Override
public void RunComplete() throws InterruptedException {
MessageLog.ShowInfo("线程执行完成");
}
});


}
});

WriteBut.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View view) {
ThreadManager.Get().Stop("数据读取监听");
ModbusTcpServer.get().WriteBool("0", true);
ModbusTcpServer.get().WriteBool("1", true);
ModbusTcpServer.get().WriteBool("2", true);

ModbusTcpServer.get().WriteShort("0", (short) 10);
ModbusTcpServer.get().WriteShort("1", (short) 20);
ModbusTcpServer.get().WriteShort("2", (short) 30);

ModbusTcpServer.get().WriteFloat("10", 10.10f);
ModbusTcpServer.get().WriteFloat("12", 20.20f);
ModbusTcpServer.get().WriteFloat("14", 30.30f);
}
});

}


}

+ 227
- 0
app/src/main/java/com/example/bpa/view/from/add_pf_activity.java View File

@@ -0,0 +1,227 @@
package com.example.bpa.view.from;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.example.bpa.R;
import com.example.bpa.config.ConfigName;
import com.example.bpa.db.QueryDB;
import com.example.bpa.db.mode.BPA_GOODS;
import com.example.bpa.db.mode.BPA_GOODSRECIPE;
import com.example.bpa.db.mode.BPA_MATERIAL;
import com.example.bpa.helper.Json;
import com.example.bpa.helper.T;
import com.example.bpa.view.adapter.pf_adapter;
import com.example.bpa.view.adapter.sp_adapter;
import com.example.bpa.view.inteface.MyClickListener;
import com.example.bpa.view.mode.ResGoodsRecipe;

import java.util.ArrayList;

public class add_pf_activity extends AppCompatActivity implements View.OnClickListener, MyClickListener {
//region 变量
/**
* 返回按钮
*/
ImageView gongneng_fanhui;
/**
* 标题设置
*/
TextView gongneng_title;
//endregion

//region 操作变量
/**
* 输入框
*/
TextView edittext;
/**
* 增加按钮
*/
Button buttonsave, buttonaddwuliao;
/**
* 表格显示
*/
ListView datatab;
/**
* 配方数据
*/
ArrayList<ResGoodsRecipe> bpa_pf = new ArrayList<>();
/**
* 当前传入的商品数据
*/
BPA_GOODS good = null;

/**
* 商品数据
*/
ArrayList<BPA_GOODS> bpa_goods=new ArrayList<>();
/**
* wulaipo
*/
ArrayList<BPA_MATERIAL> wuliao=new ArrayList<>();
//endregion

//region 私有函数
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_add_pf);
Init();
initEvents();
}
//endregion

//region 公共函数

/**
* 初始化
*/
private void Init() {
gongneng_fanhui = this.findViewById(R.id.gongneng_fanhui);
gongneng_title = this.findViewById(R.id.gongneng_title);
edittext = this.findViewById(R.id.edittext);
buttonsave = this.findViewById(R.id.buttonsave);
buttonaddwuliao = this.findViewById(R.id.buttonaddwuliao);
datatab = this.findViewById(R.id.datatab);
//通过Activity.getIntent()获取当前页面接收到的Intent。 getXxxExtra方法获取Intent传递过来的数据
String msg = getIntent().getStringExtra("title");
String data = getIntent().getStringExtra("data");
if (!data.isEmpty()) {
good = new Json<BPA_GOODS>().jsonToobject(BPA_GOODS.class, data);
edittext.setText(good.name);
}
gongneng_title.setText(msg);
Initdata();
bpa_goods= QueryDB.GetGoodsALL();
wuliao=QueryDB.GetMaterialALL();
}

/**
* 初始化按钮事件
*/
private void initEvents() {
gongneng_fanhui.setOnClickListener(this);
buttonsave.setOnClickListener(this);
buttonaddwuliao.setOnClickListener(this);
}

/**
* 初始化数据加载
*/
public void Initdata() {
bpa_pf = new ArrayList<>();
try {
if (good != null)//修改
{
bpa_pf= QueryDB.GetGoodsSrecipeList(good.id);
}
} catch (Exception e) {

}
}

/**
* 刷新DataTab
*/
public void DataTab()
{
pf_adapter adapter = new pf_adapter(add_pf_activity.this, R.layout.pf_item, bpa_pf,wuliao,this);
datatab.setAdapter(adapter);
}
//endregion

//region 点击事件

/**
* 本页面点击事件监听22
*
* @param v
*/
@Override
public void onClick(View v) {
switch (v.getId()) {
case R.id.gongneng_fanhui://返回按钮
this.finish();
break;
case R.id.buttonaddwuliao://新增空白行
ResGoodsRecipe recipe=new ResGoodsRecipe();
recipe.sort=bpa_pf.size()+1;
bpa_pf.add(recipe);
DataTab();
break;
case R.id.buttonsave://保存按钮点击
if(bpa_pf.size()<=0)
{
T.show(this, "配方信息不能为空!");
return;
}
if (good == null)//新增
{
String name = edittext.getText().toString();
if (name.isEmpty()) {
T.show(this, "商品名称不能为空!");
return;
}
if (QueryDB.GetGoodsIs(name)) {
T.show(this, "商品名称重复,请重新输入后重试!");
return;
}
BPA_GOODS goodx = new BPA_GOODS();
goodx.name = name;
goodx.sort = bpa_goods.size() + 1;
goodx.status = 1;
goodx.deviceID = ConfigName.getInstance().DeviceId;
goodx.userID = ConfigName.getInstance().user.userID;
QueryDB.AddGoods(goodx);
good=goodx;
}else //修改
{
QueryDB.UpdateGoods(good);
QueryDB.DeleteGoodsSrecipeList(good.id);
}

for (ResGoodsRecipe item:bpa_pf)
{
BPA_GOODSRECIPE da=new BPA_GOODSRECIPE();
da.goodsID = good.id;
da.materialID = item.materialID;
da.value = item.value;
da.sort =item.sort;
da.deviceID = ConfigName.getInstance().DeviceId;
da.userID = ConfigName.getInstance().user.userID;
QueryDB.AddGoodsSrecipe(da);
}
T.show(this, "操作成功!");
this.finish();
break;
}
}

/**
* 接口方法,响应ListView按钮点击事件
*/
@Override
public void clickListener(View v, Object data) {
switch (v.getId()) {
case R.id.button_item://删除
bpa_pf.remove(data);
DataTab();
break;
case R.id.button_item_Up://上移动

break;
case R.id.button_item_Down://下移动

break;
}
}
//endregion
}

+ 54
- 1
app/src/main/java/com/example/bpa/view/from/dzcjy_activity.java View File

@@ -1,13 +1,24 @@
package com.example.bpa.view.from;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.RecyclerView;

import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

import com.example.bpa.R;
import com.example.bpa.helper.T;
import com.example.bpa.view.control.ItemClickListener;
import com.example.bpa.view.control.MainMeunAdapter;
import com.example.bpa.view.control.MyLayoutManager;
import com.example.bpa.view.mode.MenuMode;

import java.util.ArrayList;
import java.util.List;

/**
* 电子秤校验
*/
@@ -21,6 +32,9 @@ public class dzcjy_activity extends AppCompatActivity implements View.OnClickLis
* 标题设置
*/
TextView gongneng_title;
RecyclerView recyclerView;
MainMeunAdapter adapter;
List<MenuMode> menuModes = new ArrayList<>();
//endregion

//region 私有函数
@@ -45,7 +59,46 @@ public class dzcjy_activity extends AppCompatActivity implements View.OnClickLis
String msg=getIntent().getStringExtra("data");
gongneng_title.setText(msg);

((TextView)this.findViewById(R.id.test_view)).setText(msg);
recyclerView = this.findViewById(R.id.recycler_view);

menuModes.clear();
menuModes.add(new MenuMode("设置最大称重",R.mipmap.zuidachengzhong));
menuModes.add(new MenuMode("设置分度参数",R.mipmap.shezhifenducanshu));
menuModes.add(new MenuMode("归零",R.mipmap.guiling));
menuModes.add(new MenuMode("设置标准重量",R.mipmap.biaozhunzhongliang));
menuModes.add(new MenuMode("称重校验",R.mipmap.chengzhongjiaoyan));

MyLayoutManager layout = new MyLayoutManager();
//必须,防止recyclerview高度为wrap时测量item高度0
layout.setAutoMeasureEnabled(true);
recyclerView.setLayoutManager(layout);
adapter = new MainMeunAdapter(this, menuModes);
recyclerView.setAdapter(adapter);
recyclerView.addOnItemTouchListener(new ItemClickListener(recyclerView, new ItemClickListener.OnItemClickListener() {
@Override
public void onItemClick(View view, int position) {
TextView textView = (TextView) view.findViewById(R.id.meun_textview);
T.show(view.getContext(),"打开窗体:"+ textView.getText().toString());
switch (textView.getText().toString())
{
case "设置最大称重":
break;
case "设置分度参数":
break;
case "归零":
break;
case "设置标准重量":
break;
case "称重校验":
default:
break;
}
}
@Override
public void onItemLongClick(View view, int position) {

}
}));
}

/**


+ 52
- 3
app/src/main/java/com/example/bpa/view/from/lsjy_activity.java View File

@@ -4,14 +4,25 @@ import androidx.appcompat.app.AppCompatActivity;
import android.os.Bundle;
import android.view.View;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.example.bpa.R;
import com.example.bpa.db.QueryDB;
import com.example.bpa.db.mode.BPA_MATERIAL;
import com.example.bpa.db.mode.BPA_SILOS;
import com.example.bpa.helper.T;
import com.example.bpa.view.adapter.lsjy_adapter;
import com.example.bpa.view.adapter.wl_adapter;
import com.example.bpa.view.inteface.MyClickListener;
import com.example.bpa.view.mode.ResSilosMode;

import java.util.ArrayList;

/**
* 流速校验
*/
public class lsjy_activity extends AppCompatActivity implements View.OnClickListener{
public class lsjy_activity extends AppCompatActivity implements View.OnClickListener, MyClickListener {
//region 变量
/**
* 返回按钮
@@ -21,6 +32,14 @@ public class lsjy_activity extends AppCompatActivity implements View.OnClickList
* 标题设置
*/
TextView gongneng_title;
/**
* 表格显示
*/
ListView datatab;
/**
* 料仓数据
*/
ArrayList<ResSilosMode> resSilosModes=new ArrayList<>();
//endregion

//region 私有函数
@@ -41,11 +60,11 @@ public class lsjy_activity extends AppCompatActivity implements View.OnClickList
private void Init(){
gongneng_fanhui = this.findViewById(R.id.gongneng_fanhui);
gongneng_title = this.findViewById(R.id.gongneng_title);
datatab= this.findViewById(R.id.datatab);
//通过Activity.getIntent()获取当前页面接收到的Intent。 getXxxExtra方法获取Intent传递过来的数据
String msg=getIntent().getStringExtra("data");
gongneng_title.setText(msg);

((TextView)this.findViewById(R.id.test_view)).setText(msg);
Initdata();
}

/**
@@ -54,6 +73,20 @@ public class lsjy_activity extends AppCompatActivity implements View.OnClickList
private void initEvents() {
gongneng_fanhui.setOnClickListener(this);
}

/**
* 初始化数据加载
*/
public void Initdata()
{
try{
resSilosModes= QueryDB.GetSilos();
lsjy_adapter adapter = new lsjy_adapter(lsjy_activity.this, R.layout.lsjy_item, resSilosModes,this);
datatab.setAdapter(adapter);
}catch(Exception e){

}
}
//endregion

//region 点击事件
@@ -70,5 +103,21 @@ public class lsjy_activity extends AppCompatActivity implements View.OnClickList
break;
}
}
int k=404;
/**
* 接口方法,响应ListView按钮点击事件
*/
@Override
public void clickListener(View v,Object data) {
switch (v.getId())
{
case R.id.button_item://校验
k=k+1;
T.show(this,((ResSilosMode)data).id);
QueryDB.UpdateJYZ(((ResSilosMode)data).id,k);
Initdata();
break;
}
}
//endregion
}

+ 3
- 3
app/src/main/java/com/example/bpa/view/from/wlgl_activity.java View File

@@ -35,8 +35,10 @@ public class wlgl_activity extends AppCompatActivity implements View.OnClickList
* 标题设置
*/
TextView gongneng_title;
//edittext buttonadd ListView datatab
//endregion

//region 操作变量
/**
* 输入框
*/
@@ -53,8 +55,6 @@ public class wlgl_activity extends AppCompatActivity implements View.OnClickList
* 物料数据
*/
ArrayList<BPA_MATERIAL> bpa_materials=new ArrayList<>();
//region 操作变量

//endregion

//region 私有函数


+ 104
- 4
app/src/main/java/com/example/bpa/view/from/yfpf_activity.java View File

@@ -2,17 +2,30 @@ package com.example.bpa.view.from;

import androidx.appcompat.app.AppCompatActivity;

import android.content.Intent;
import android.os.Bundle;
import android.util.Log;
import android.view.View;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.ListView;
import android.widget.TextView;

import com.example.bpa.R;
import com.example.bpa.config.ConfigName;
import com.example.bpa.db.QueryDB;
import com.example.bpa.db.mode.BPA_GOODS;
import com.example.bpa.helper.Json;
import com.example.bpa.helper.T;
import com.example.bpa.view.adapter.sp_adapter;
import com.example.bpa.view.inteface.MyClickListener;

import java.util.ArrayList;

/**
* 配方研发
*/
public class yfpf_activity extends AppCompatActivity implements View.OnClickListener{
public class yfpf_activity extends AppCompatActivity implements View.OnClickListener, MyClickListener {
//region 变量
/**
* 返回按钮
@@ -24,6 +37,21 @@ public class yfpf_activity extends AppCompatActivity implements View.OnClickList
TextView gongneng_title;
//endregion

//region 操作变量
/**
* 增加按钮
*/
Button buttonaddpf;
/**
* 表格显示
*/
ListView datatab;
/**
* 商品数据
*/
ArrayList<BPA_GOODS> bpa_goods=new ArrayList<>();
//endregion

//region 私有函数
@Override
protected void onCreate(Bundle savedInstanceState) {
@@ -42,11 +70,12 @@ public class yfpf_activity extends AppCompatActivity implements View.OnClickList
private void Init(){
gongneng_fanhui = this.findViewById(R.id.gongneng_fanhui);
gongneng_title = this.findViewById(R.id.gongneng_title);
buttonaddpf=this.findViewById(R.id.buttonaddpf);
datatab= this.findViewById(R.id.datatab);
//通过Activity.getIntent()获取当前页面接收到的Intent。 getXxxExtra方法获取Intent传递过来的数据
String msg=getIntent().getStringExtra("data");
gongneng_title.setText(msg);

((TextView)this.findViewById(R.id.test_view)).setText(msg);
Initdata();
}

/**
@@ -54,12 +83,27 @@ public class yfpf_activity extends AppCompatActivity implements View.OnClickList
*/
private void initEvents() {
gongneng_fanhui.setOnClickListener(this);
buttonaddpf.setOnClickListener(this);
}

/**
* 初始化数据加载
*/
public void Initdata()
{
try{
bpa_goods= QueryDB.GetGoodsALL();
sp_adapter adapter = new sp_adapter(yfpf_activity.this, R.layout.sp_item, bpa_goods,this);
datatab.setAdapter(adapter);
}catch(Exception e){

}
}
//endregion

//region 点击事件
/**
* 本页面点击事件监听
* 本页面点击事件监听22
*
* @param v
*/
@@ -69,6 +113,62 @@ public class yfpf_activity extends AppCompatActivity implements View.OnClickList
case R.id.gongneng_fanhui://返回按钮
this.finish();
break;
case R.id.buttonaddpf://新建配方
Intent intent = new Intent(this, add_pf_activity.class);
intent.putExtra("title", "新建配方");
intent.putExtra("data", "");
startActivity(intent);
break;
}
}

/**
* 接口方法,响应ListView按钮点击事件
*/
@Override
public void clickListener(View v,Object data) {
switch (v.getId())
{
case R.id.button_item://删除按钮
int sort=((BPA_GOODS)data).sort;
String id=((BPA_GOODS)data).id;
Log.i("日志",sort + "--- "+id);
QueryDB.DeleteGoods((BPA_GOODS)data);
Initdata();
for (BPA_GOODS k:bpa_goods) {
if(k.sort>sort)
{
QueryDB.GetGoodsSort(k,1);
}
}
Initdata();
break;
case R.id.button_item_Up://上移动按钮
BPA_GOODS good=(BPA_GOODS)data;
if(good.sort==1)
{
T.show(this, "已是最顶部!");
return;
}
QueryDB.GetGoodsSort((BPA_GOODS)data,1);
Initdata();
break;
case R.id.button_item_Down://下移动按钮
BPA_GOODS good2=(BPA_GOODS)data;
if(good2.sort==bpa_goods.size())
{
T.show(this, "已是最底部!");
return;
}
QueryDB.GetGoodsSort((BPA_GOODS)data,0);
Initdata();
break;
case R.id.button_item_update://修改按钮
Intent intent = new Intent(this, add_pf_activity.class);
intent.putExtra("title", "新建配方");
intent.putExtra("data",new Json().objectToJson(BPA_GOODS.class,data));
startActivity(intent);
break;
}
}
//endregion

+ 11
- 0
app/src/main/java/com/example/bpa/view/mode/ResGoodsRecipe.java View File

@@ -0,0 +1,11 @@
package com.example.bpa.view.mode;

import com.example.bpa.db.mode.BPA_GOODSRECIPE;

/**
* 界面显示商品配方结构
*/
public class ResGoodsRecipe extends BPA_GOODSRECIPE {
//物料名称
public String materialName;
}

+ 14
- 0
app/src/main/java/com/example/bpa/view/mode/ResSilosMode.java View File

@@ -0,0 +1,14 @@
package com.example.bpa.view.mode;

import com.example.bpa.db.mode.BPA_SILOS;

public class ResSilosMode extends BPA_SILOS {
//物料ID
public String materialID;
//物料图片路径
public String materialimgUrl;
//物料名称
public String materialname;
//当前余量
public int dvalue;
}

+ 97
- 0
app/src/main/res/layout/datatab/layout/lsjy_item.xml View File

@@ -0,0 +1,97 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TableLayout
android:background="@mipmap/bgxz"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_gravity="center"
android:stretchColumns="0">
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"
android:layout_alignParentLeft="true"
android:text="回锅肉"
android:textColor="@color/foreground"
android:textSize="@dimen/textSize" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<TextView
android:id="@+id/lc_num"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"
android:layout_alignParentLeft="true"
android:text="1"
android:textColor="@color/foreground"
android:textSize="@dimen/textSize" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<TextView
android:id="@+id/lc_bzls"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"
android:layout_alignParentLeft="true"
android:text="1"
android:textColor="@color/foreground"
android:textSize="@dimen/textSize" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<TextView
android:id="@+id/lc_xyls"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"
android:layout_alignParentLeft="true"
android:text="1"
android:textColor="@color/foreground"
android:textSize="@dimen/textSize" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<Button
android:id="@+id/button_item"
android:text="开始校验"
android:background="@drawable/btn_button"
android:textSize="@dimen/textSize"
android:textColor="@color/foreground"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"
android:layout_width="60dp"
android:layout_height="26dp"
/>
</RelativeLayout>

</TableRow>
</TableLayout>
</RelativeLayout>

+ 102
- 0
app/src/main/res/layout/datatab/layout/pf_item.xml View File

@@ -0,0 +1,102 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TableLayout
android:background="@mipmap/bgxz"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_gravity="center"
android:stretchColumns="0">
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<Spinner
android:id="@+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"
android:layout_alignParentLeft="true"
android:inputType="text"
android:padding="3dp"
android:textColor="@color/foreground"
android:theme="@style/MyEditText1"
android:background="@drawable/round_corners_bg"
android:hint="请输入序号"
android:maxLines="1"
android:textSize="@dimen/textSize"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<EditText
android:id="@+id/sort"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"
android:layout_alignParentLeft="true"
android:inputType="text"
android:padding="3dp"
android:textColor="@color/foreground"
android:theme="@style/MyEditText1"
android:background="@drawable/round_corners_bg"
android:hint="请输入序号"
android:maxLines="1"
android:textSize="@dimen/textSize"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<EditText
android:id="@+id/value"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"
android:layout_alignParentLeft="true"
android:inputType="text"
android:padding="3dp"
android:textColor="@color/foreground"
android:theme="@style/MyEditText1"
android:background="@drawable/round_corners_bg"
android:hint="请输入数值"
android:maxLines="1"
android:textSize="@dimen/textSize"/>
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/button_item"
android:text="删除"
android:background="@drawable/btn_button"
android:textSize="@dimen/textSize"
android:textColor="@color/foreground"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"
android:layout_width="60dp"
android:layout_height="26dp"
/>
</LinearLayout>

</RelativeLayout>

</TableRow>
</TableLayout>
</RelativeLayout>

+ 120
- 0
app/src/main/res/layout/datatab/layout/sp_item.xml View File

@@ -0,0 +1,120 @@
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TableLayout
android:background="@mipmap/bgxz"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_gravity="center"
android:stretchColumns="0">
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<TextView
android:id="@+id/name"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"
android:layout_alignParentLeft="true"
android:text="回锅肉"
android:textColor="@color/foreground"
android:textSize="@dimen/textSize" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<TextView
android:id="@+id/time"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"
android:layout_alignParentLeft="true"
android:text="回锅肉"
android:textColor="@color/foreground"
android:textSize="@dimen/textSize" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="1">
<TextView
android:id="@+id/sort"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"
android:layout_alignParentLeft="true"
android:text="回锅肉"
android:textColor="@color/foreground"
android:textSize="@dimen/textSize" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="2">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<Button
android:id="@+id/button_item_Up"
android:text="上移"
android:background="@drawable/btn_button"
android:textSize="@dimen/textSize"
android:textColor="@color/foreground"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"
android:layout_width="60dp"
android:layout_height="26dp"
/>
<Button
android:id="@+id/button_item_Down"
android:text="下移"
android:background="@drawable/btn_button"
android:textSize="@dimen/textSize"
android:textColor="@color/foreground"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"
android:layout_width="60dp"
android:layout_height="26dp"
/>
<Button
android:id="@+id/button_item_update"
android:text="修改"
android:background="@drawable/btn_button"
android:textSize="@dimen/textSize"
android:textColor="@color/foreground"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"
android:layout_width="60dp"
android:layout_height="26dp"
/>
<Button
android:id="@+id/button_item"
android:text="删除"
android:background="@drawable/btn_button"
android:textSize="@dimen/textSize"
android:textColor="@color/foreground"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"
android:layout_width="60dp"
android:layout_height="26dp"
/>
</LinearLayout>

</RelativeLayout>

</TableRow>
</TableLayout>
</RelativeLayout>

+ 1
- 4
app/src/main/res/layout/datatab/values/strings.xml View File

@@ -1,4 +1 @@
<resources>
<!-- TODO: Remove or change this placeholder text -->
<string name="hello_blank_fragment">Hello blank fragment</string>
</resources>
<resources></resources>

+ 250
- 0
app/src/main/res/layout/from/layout/activity_add_pf.xml View File

@@ -0,0 +1,250 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@mipmap/dpbj"
tools:context=".view.from.add_pf_activity">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="30dp"
android:background="@color/test">
<ImageView
android:id="@+id/gongneng_fanhui"
android:layout_width="26dp"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_centerVertical="true"
android:layout_marginLeft="20dp"
android:textSize="@dimen/TitleSize"
android:textColor="@color/titleforeground"
android:src="@mipmap/zj"
/>
<RelativeLayout
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<TextView
android:id="@+id/gongneng_title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:textColor="@color/white"
android:textSize="@dimen/textTitleSize"
android:textStyle="bold" />
<ImageView
android:layout_width="400dp"
android:layout_height="22dp"
android:layout_alignParentBottom="true"
android:src="@mipmap/tittle"
android:layout_marginLeft="5dp"
/>
</RelativeLayout>
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#FF03668F" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="5dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:src="@mipmap/zs"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
android:src="@mipmap/zx"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:src="@mipmap/ys"/>
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:src="@mipmap/yx"/>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="饮料名称:"
android:textSize="@dimen/textSize"
android:textColor="@color/foreground"/>
<EditText
android:id="@+id/edittext"
android:layout_width="200dp"
android:layout_height="wrap_content"
android:inputType="text"
android:padding="3dp"
android:textColor="@color/foreground"
android:theme="@style/MyEditText1"
android:background="@drawable/round_corners_bg"
android:layout_marginLeft="5dp"
android:hint="请输入饮料名称"
android:maxLines="1"
android:textSize="@dimen/textSize"/>
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="20dp"
android:layout_alignParentBottom="true">
<Button
android:id="@+id/buttonaddwuliao"
android:text="添加新行"
android:background="@drawable/btn_button"
android:textSize="@dimen/textSize"
android:textColor="@color/foreground"
android:layout_marginLeft="5dp"
android:layout_gravity="center"
android:layout_width="80dp"
android:layout_height="26dp"
/>
<Button
android:id="@+id/buttonsave"
android:text="保存饮品"
android:background="@drawable/btn_button"
android:textSize="@dimen/textSize"
android:textColor="@color/foreground"
android:layout_marginLeft="5dp"
android:layout_gravity="center"
android:layout_width="80dp"
android:layout_height="26dp"
/>
</LinearLayout>

</RelativeLayout>

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:background="@mipmap/bgbtbj"
android:layout_height="26dp">
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#FF03668F" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_alignParentBottom="true"
android:background="#FF03668F" />
<TableLayout
android:layout_centerVertical="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_gravity="center"
android:stretchColumns="0">
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_alignParentLeft="true"
android:text="物料名称"
android:textColor="@color/dataGridColumnHeaderColor"
android:textSize="@dimen/textSize" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_alignParentLeft="true"
android:text="出料顺序"
android:textColor="@color/dataGridColumnHeaderColor"
android:textSize="@dimen/textSize" />
</RelativeLayout>

<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_alignParentLeft="true"
android:text="微调数值"
android:textColor="@color/dataGridColumnHeaderColor"
android:textSize="@dimen/textSize" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_alignParentLeft="true"
android:text="操作"
android:textColor="@color/dataGridColumnHeaderColor"
android:textSize="@dimen/textSize" />
</RelativeLayout>
</TableRow>
</TableLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/datatab"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="#00000000"
android:dividerHeight="3dp"
android:layout_marginTop="3dp"
/>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
</LinearLayout>

+ 4
- 7
app/src/main/res/layout/from/layout/activity_dzcjy.xml View File

@@ -79,13 +79,10 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp">
<TextView
android:id="@+id/test_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/foreground"
android:textSize="@dimen/TitleSize">
</TextView>
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</RelativeLayout>
</RelativeLayout>
</LinearLayout>

+ 121
- 7
app/src/main/res/layout/from/layout/activity_lsjy.xml View File

@@ -80,13 +80,127 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp">
<TextView
android:id="@+id/test_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/foreground"
android:textSize="@dimen/TitleSize">
</TextView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:background="@mipmap/bgbtbj"
android:layout_height="26dp">
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#FF03668F" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_alignParentBottom="true"
android:background="#FF03668F" />
<TableLayout
android:layout_centerVertical="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_gravity="center"
android:stretchColumns="0">
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_alignParentLeft="true"
android:text="饮料名称"
android:textColor="@color/dataGridColumnHeaderColor"
android:textSize="@dimen/textSize" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_alignParentLeft="true"
android:text="料仓编号"
android:textColor="@color/dataGridColumnHeaderColor"
android:textSize="@dimen/textSize" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_alignParentLeft="true"
android:text="标准出料值"
android:textColor="@color/dataGridColumnHeaderColor"
android:textSize="@dimen/textSize" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_alignParentLeft="true"
android:text="校准出料值"
android:textColor="@color/dataGridColumnHeaderColor"
android:textSize="@dimen/textSize" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_alignParentLeft="true"
android:text="用户操作"
android:textColor="@color/dataGridColumnHeaderColor"
android:textSize="@dimen/textSize" />
</RelativeLayout>

</TableRow>
</TableLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/datatab"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="#00000000"
android:dividerHeight="3dp"
android:layout_marginTop="3dp"
/>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
</LinearLayout>

+ 130
- 7
app/src/main/res/layout/from/layout/activity_yfpf.xml View File

@@ -79,13 +79,136 @@
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp">
<TextView
android:id="@+id/test_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/foreground"
android:textSize="@dimen/TitleSize">
</TextView>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="50dp">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true">
</LinearLayout>
<Button
android:id="@+id/buttonaddpf"
android:layout_alignParentRight="true"
android:text="新建配方"
android:background="@drawable/btn_button"
android:textSize="@dimen/textSize"
android:textColor="@color/foreground"
android:layout_marginLeft="5dp"
android:layout_gravity="center"
android:layout_marginRight="20dp"
android:layout_width="100dp"
android:layout_height="36dp"
/>
</RelativeLayout>

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:orientation="vertical">
<RelativeLayout
android:layout_width="match_parent"
android:background="@mipmap/bgbtbj"
android:layout_height="26dp">
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="#FF03668F" />
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:layout_alignParentBottom="true"
android:background="#FF03668F" />
<TableLayout
android:layout_centerVertical="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center"
android:layout_gravity="center"
android:stretchColumns="0">
<TableRow
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal">
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_alignParentLeft="true"
android:text="饮料名称"
android:textColor="@color/dataGridColumnHeaderColor"
android:textSize="@dimen/textSize" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_alignParentLeft="true"
android:text="创建时间"
android:textColor="@color/dataGridColumnHeaderColor"
android:textSize="@dimen/textSize" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_alignParentLeft="true"
android:text="排序"
android:textColor="@color/dataGridColumnHeaderColor"
android:textSize="@dimen/textSize" />
</RelativeLayout>
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="2">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_alignParentLeft="true"
android:text="用户操作"
android:textColor="@color/dataGridColumnHeaderColor"
android:textSize="@dimen/textSize" />
</RelativeLayout>

</TableRow>
</TableLayout>
</RelativeLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<ListView
android:id="@+id/datatab"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:divider="#00000000"
android:dividerHeight="3dp"
android:layout_marginTop="3dp"
/>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
</LinearLayout>
</RelativeLayout>
</RelativeLayout>
</LinearLayout>

+ 17
- 5
app/src/main/res/layout/from/layout/fragment_system_set.xml View File

@@ -6,11 +6,23 @@
android:layout_height="match_parent"
android:tag="系统设置"
tools:context=".view.fragment.SystemSetFragment">
<TextView

<Button
android:id="@+id/ConnectDevice"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="系统设置"
android:textSize="50dp"
android:textColor="@color/color_purl">
</TextView>
android:text="连接设备"/>

<Button
android:id="@+id/ReadData"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="读取数据"/>

<Button
android:id="@+id/WriteData"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="写入数据"/>

</LinearLayout>

BIN
View File


BIN
View File


BIN
View File


BIN
View File


BIN
View File


BIN
View File


+ 3
- 2
build.gradle View File

@@ -1,6 +1,7 @@
// Top-level build file where you can add configuration options common to all sub-projects/modules.

plugins {
id 'com.android.application' version '7.4.1' apply false
id 'com.android.library' version '7.4.1' apply false
id 'com.android.application' version '7.0.0' apply false
id 'com.android.library' version '7.0.0' apply false
}


+ 1
- 0
settings.gradle View File

@@ -12,6 +12,7 @@ dependencyResolutionManagement {
google()
jcenter()
mavenCentral()
maven { url 'https://jitpack.io' }
}
}
rootProject.name = "ChaBaiDao"


Loading…
Cancel
Save