Browse Source

增加一拖四

燃气自翻炒锅
fyf 1 year ago
parent
commit
343fe15e04
23 changed files with 3265 additions and 144 deletions
  1. +3
    -0
      app/src/main/AndroidManifest.xml
  2. +68
    -17
      app/src/main/java/com/bonait/bnframework/business/ConfigData.java
  3. +492
    -14
      app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java
  4. +314
    -6
      app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java
  5. +4
    -0
      app/src/main/java/com/bonait/bnframework/common/constant/MessageName.java
  6. +43
    -0
      app/src/main/java/com/bonait/bnframework/common/modbus/ModbusTcpMainHelper.java
  7. +740
    -0
      app/src/main/java/com/bonait/bnframework/common/modbus/ModbusTcpMainServer.java
  8. +0
    -32
      app/src/main/java/com/bonait/bnframework/common/modbus/ModbusTcpServer.java
  9. +25
    -0
      app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigation2Activity.java
  10. +73
    -25
      app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigationNewActivity.java
  11. +34
    -7
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/Home1Fragment.java
  12. +1
    -1
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/HomeFragmentSBKZ.java
  13. +1
    -1
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/CookingActivity.java
  14. +1
    -1
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/CookingSimulatedActivity.java
  15. +1
    -1
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DishTestActivity.java
  16. +8
    -1
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/WhActivity.java
  17. +45
    -0
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/SystemSystemsetFragment.java
  18. +437
    -0
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/WokSetTLZZ1Fragment.java
  19. +3
    -15
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/WokSetTLZZFragment.java
  20. +11
    -11
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_qupenren.java
  21. +71
    -0
      app/src/main/res/layout/fragment_system_systemset.xml
  22. +1
    -12
      app/src/main/res/layout/fragment_wok_set_tlzz.xml
  23. +889
    -0
      app/src/main/res/layout/fragment_wok_set_tlzz1.xml

+ 3
- 0
app/src/main/AndroidManifest.xml View File

@@ -33,6 +33,9 @@
tools:ignore="GoogleAppIndexingWarning"
tools:node="merge"
tools:replace="android:icon">
<activity
android:name=".modules.home.fragment.from.fragment.WokSetTLZZ1Fragment"
android:exported="false" />
<activity
android:name=".modules.home.fragment.from.fragment.WokSetTLZZFragment"
android:exported="false" />


+ 68
- 17
app/src/main/java/com/bonait/bnframework/business/ConfigData.java View File

@@ -30,6 +30,7 @@ import com.bonait.bnframework.common.http.callback.json.JsonDialogCallback;
import com.bonait.bnframework.common.image.utils.LocalCacheUtils;
import com.bonait.bnframework.common.message.MessageManager;
import com.bonait.bnframework.common.modbus.ModbusTcpHelper;
import com.bonait.bnframework.common.modbus.ModbusTcpMainHelper;
import com.bonait.bnframework.common.modbus.ModbusTcpServer;
import com.bonait.bnframework.common.model.ResAPI;
import com.bonait.bnframework.common.model.mode.ActionJsonMode;
@@ -155,11 +156,21 @@ public class ConfigData {

BPA_SYSTEMSET find_99 = null;
BPA_SYSTEMSET find_100 = null;
BPA_SYSTEMSET find_200 = null;
BPA_SYSTEMSET find_201 = null;
BPA_SYSTEMSET find_202 = null;

for (BPA_SYSTEMSET item : bpa_systemsets) {
if (item.type == -99) {
find_99 = item;
} else if (item.type == -100) {
find_100 = item;
}else if (item.type == -200) {
find_200 = item;
}else if (item.type == -201) {
find_201 = item;
}else if (item.type == -202) {
find_202 = item;
}
}
if (find_99 == null) {
@@ -179,6 +190,34 @@ public class ConfigData {
QueryDB.AddSystemset(set);
}

if (find_200 == null) {
BPA_SYSTEMSET set = new BPA_SYSTEMSET();
set.type = -200;
set.value = ConfigName.getInstance().MainAddress;
set.deviceID = ConfigName.getInstance().DeviceId;
set.userID = ConfigName.getInstance().user.userID;
QueryDB.AddSystemset(set);
}

if (find_201 == null) {
BPA_SYSTEMSET set = new BPA_SYSTEMSET();
set.type = -201;
set.value = String.valueOf(ConfigName.getInstance().MainPost);
set.deviceID = ConfigName.getInstance().DeviceId;
set.userID = ConfigName.getInstance().user.userID;
QueryDB.AddSystemset(set);
}

if (find_202 == null) {
BPA_SYSTEMSET set = new BPA_SYSTEMSET();
set.type = -202;
set.value = String.valueOf(ConfigName.getInstance().DeviceHao);
set.deviceID = ConfigName.getInstance().DeviceId;
set.userID = ConfigName.getInstance().user.userID;
QueryDB.AddSystemset(set);
}


bpa_systemsets = QueryDB.GetSystemsetALL();
for (BPA_SYSTEMSET item : bpa_systemsets) {
switch (item.type) {
@@ -188,6 +227,15 @@ public class ConfigData {
case -99:
ConfigName.getInstance().Environment = item.value;
break;
case -200:
ConfigName.getInstance().MainAddress = item.value;
break;
case -201:
ConfigName.getInstance().MainPost = Integer.parseInt(item.value);
break;
case -202:
ConfigName.getInstance().DeviceHao = Integer.parseInt(item.value);
break;
case 1:
ConfigName.getInstance().Address = item.value;
break;
@@ -1041,6 +1089,12 @@ public class ConfigData {
} else if (ConfigName.getInstance().versionSelectionEnum.equals("小炒版本")) {
plcaddresses = ConfigName.getInstance().PlcAddress_小炒;
processTS = ConfigName.getInstance().Process_小炒;
} else if (ConfigName.getInstance().versionSelectionEnum.equals("一拖四大炒")) {
plcaddresses = ConfigName.getInstance().PlcAddress_一拖四;
processTS = ConfigName.getInstance().Process_一拖四;
} else if (ConfigName.getInstance().versionSelectionEnum.equals("一拖二大炒")) {
plcaddresses = ConfigName.getInstance().PlcAddress_大炒自动投料;
processTS = ConfigName.getInstance().Process_一拖四;
}

//region 恢复PLC
@@ -1100,29 +1154,18 @@ public class ConfigData {
//endregion

//region PLC初始化

/**
* 连接PLC
*/
public void ConnectPLC() {
new Thread(new Runnable() {
@Override
public void run() {
try {
ModbusTcpServer.get().Connect();
} catch (Exception e) {

}
}
}).start();
}

/**
* 关闭PLC
*/
public void ColsePLC() {
ModbusTcpHelper.get().release();//释放modbus
ConfigName.getInstance().PlcIsConnect = false;

if(ConfigName.getInstance().versionSelectionEnum.contains("一拖"))
{
ModbusTcpMainHelper.get().release();//释放modbus
ConfigName.getInstance().PlcMainIsConnect = false;
}
}

/**
@@ -1132,6 +1175,14 @@ public class ConfigData {
//PLC连接成功,启动数据监听
ExecuteTheRecipe.Listening();
}

/**
* PLC主控初始化完成时,需要注册的服务
*/
public void MainPLC_Init() {
//PLC连接成功,启动数据监听
ExecuteTheRecipe.MainListening();
}
//endregion
}


+ 492
- 14
app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java View File

@@ -6,11 +6,15 @@ import android.content.ContextWrapper;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import android.view.View;

import androidx.annotation.NonNull;

import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.constant.DataBus;
import com.bonait.bnframework.common.constant.MessageName;
import com.bonait.bnframework.common.db.QueryDB;
import com.bonait.bnframework.common.db.mode.BPA_GOODS;
import com.bonait.bnframework.common.db.mode.BPA_GOODSRECIPE;
import com.bonait.bnframework.common.db.mode.BPA_MATERIAL;
import com.bonait.bnframework.common.db.mode.BPA_PLCADDRESS;
@@ -21,6 +25,8 @@ import com.bonait.bnframework.common.helper.I.IRunT;
import com.bonait.bnframework.common.helper.I.IThread;
import com.bonait.bnframework.common.helper.I.IWriteCallBack;
import com.bonait.bnframework.common.helper.ThreadManager;
import com.bonait.bnframework.common.message.MessageManager;
import com.bonait.bnframework.common.modbus.ModbusTcpMainServer;
import com.bonait.bnframework.common.modbus.ModbusTcpServer;
import com.bonait.bnframework.common.utils.AlertDialogUtils;
import com.bonait.bnframework.common.utils.ToastUtils;
@@ -50,7 +56,7 @@ public class ExecuteTheRecipe {
* 等待超时时间
*/
//public static int whileTime = 40;
public static int whileTime = 40;
public static int whileTime = 5;

/**
* 监听变量值
@@ -279,7 +285,16 @@ public class ExecuteTheRecipe {
Write_PLC_Heating(formulation);
break;
case "主料":
Write_PLC_Ingredients(formulation);
if (ConfigName.getInstance().versionSelectionEnum.contains("一拖")) {
Write_PLC_MainIngredients(formulation);
} else {
Write_PLC_Ingredients(formulation);
}
break;
case "辅料":
if (ConfigName.getInstance().versionSelectionEnum.contains("一拖")) {
Write_PLC_MainAccessory(formulation);
}
break;
case "加水":
Write_PLC_Water(formulation);
@@ -288,14 +303,16 @@ public class ExecuteTheRecipe {
Write_PLC_Delay(formulation);
break;
case "出菜":
Write_PLC_Outdishes(formulation);
if (ConfigName.getInstance().versionSelectionEnum.contains("一拖")) {
Write_PLC_MainOutdishes(formulation);
} else {
Write_PLC_Outdishes(formulation);
}
break;
case "清洗":
Write_PLC_CleanPan(formulation);
break;
}


}
}
} catch (Exception ex) {
@@ -416,7 +433,7 @@ public class ExecuteTheRecipe {
} else if (key.contains("速度")) {
int writeValue = GetMXValue(key, value);
//修改最高速度40
WritePLC(key, writeValue>=30?30:writeValue, null);
WritePLC(key, writeValue >= 30 ? 30 : writeValue, null);
}
}

@@ -656,6 +673,7 @@ public class ExecuteTheRecipe {

/**
* 组断执行
*
* @param name
*/
public static void BottomClick1(String name) {
@@ -801,13 +819,14 @@ public class ExecuteTheRecipe {
ToastUtils.info("工序:" + key + "," + value);
if (key.contains("(秒)")) {
int val = Integer.parseInt(value);
if(all_list.size()>0)
{
if (all_list.size() > 0) {
Thread.sleep(val * 1000);
}
}
}

ExecuteTheRecipe.WritePLC("搅拌", false, null);
ExecuteTheRecipe.WritePLC("加热", false, null);
BottomClick1("出菜");

//一直等待机器移动到该位置,否则就一直等待 6s超时
@@ -815,7 +834,7 @@ public class ExecuteTheRecipe {
final boolean[] IsComplete = {false};
long a = System.currentTimeMillis();
while (!IsComplete[0]) {
if ((System.currentTimeMillis() - a) > 1000 * (whileTime*3)) {
if ((System.currentTimeMillis() - a) > 1000 * (whileTime * 3)) {
break;
} else {
Object sb = ReadPLC(name);//ListeningValue.get(name);
@@ -858,7 +877,7 @@ public class ExecuteTheRecipe {
final boolean[] IsComplete = {false};
long a = System.currentTimeMillis();
while (!IsComplete[0]) {
if ((System.currentTimeMillis() - a) > 1000 * (whileTime*5)) {
if ((System.currentTimeMillis() - a) > 1000 * (whileTime * 5)) {
break;
} else {
Object sb = ReadPLC(name);//ListeningValue.get(name);
@@ -876,6 +895,266 @@ public class ExecuteTheRecipe {
}
//endregion

//region 一拖四写PLC工序

/**
* 写PLC主料
*
* @param data
*/
private static void Write_PLC_MainIngredients(HashMap<String, String> data) {
try {
//是否手动
boolean ishand = true;
ToastUtils.info("准备倒入主料!");

//region 判断是否手动
if (ConfigName.getInstance().versionSelectionEnum.equals("大炒版本")) {
ishand = true;
} else {
for (HashMap.Entry<String, String> entry : data.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
if (key.contains("投料动作")) {
if (value.contains("手动投料")) {
ishand = true;
} else {
ishand = false;
}
}
}
}
//endregion


if (ishand) {
String name = "";
String zl = "";
int val = 0;
for (HashMap.Entry<String, String> entry : data.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
if (key.contains("名称")) {
name = value;
} else if (key.contains("重量")) {
zl = value;
}
}
ToastUtils.info("工序:手动投料," + name + "," + zl);
String title = "手动投料-温馨提示!";
String message = "客官请投入主料,[" + name + "]重量" + zl + "g,投入后点击[确定]继续流程!";
ExecuteTheRecipe.WritePLC("暂停开关", true, null);

final boolean[] IsComplete = {false};
Activity activity = findActivity(context);
if (activity != null) {
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
try {

new QMUIDialog.MessageDialogBuilder(context)
.setCancelable(false)
.setTitle(title)
.setMessage(message)
.addAction("确定", new QMUIDialogAction.ActionListener() {
@Override
public void onClick(QMUIDialog dialog, int index) {
IsComplete[0] = true;
dialog.dismiss();
}
})
.create(com.qmuiteam.qmui.R.style.QMUI_Dialog).show();

} catch (Exception e) {

}
}
});
}

while (!IsComplete[0]) {
Thread.sleep(100);//10 *6
}
ExecuteTheRecipe.WritePLC("暂停开关", false, null);
ToastUtils.info("确定完成,继续制作!");
} else {
//自动投料
String writeValue = "1号位";
for (HashMap.Entry<String, String> entry : data.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
if (key.contains("主料位置")) {
if (!value.contains("3") && !value.contains("4")) {
writeValue = value;
}
}
}
if (ExecuteCurrentOperation != null) {
ExecuteCurrentOperation.Run("主料" + "|" + writeValue);
}

//2.给倒菜启动
BottomClick1("主料" + writeValue);
String name = writeValue + "倒菜完成";
final boolean[] IsComplete = {false};
long a = System.currentTimeMillis();
while (!IsComplete[0]) {
if ((System.currentTimeMillis() - a) > 1000 * whileTime) {
break;
} else {
Object sb = ReadPLC(name);// ListeningValue.get(name);
if (sb != null) {
IsComplete[0] = (boolean) (sb);
}
}
Thread.sleep(100);//10 *6
}
ToastUtils.info("主料倒入完成,继续制作!");
}
Log.d("倒菜", "倒菜完成了");

if (IsMoveYiHaoWei()) {
WriteMainPLC("机器人放主料完成", true, null);
}

//判断是否有烹饪时间
int val = 0;
for (HashMap.Entry<String, String> entry : data.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
if (key.contains("(秒)")) {
val = Integer.parseInt(value);
}
}
if (val > 0) {
Thread.sleep(val * 1000);
}

Log.d("烹饪时间", "烹饪时间完成了");


} catch (Exception ex) {
ToastUtils.error("异常信息:" + ex.getMessage());
}
}

/**
* 写PLC投辅料
*
* @param data
*/
private static void Write_PLC_MainAccessory(HashMap<String, String> data) {
try {
int val = 0;
for (HashMap.Entry<String, String> entry : data.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
if (key.contains("(秒)")) {
val = Integer.parseInt(value);
}
}

if (ExecuteCurrentOperation != null) {
ExecuteCurrentOperation.Run("辅料" + "|" + val);
}
WriteMainPLC("机器人放辅料完成", false, null);
WriteMainPLC("炒锅请求投辅料", true, null);
final boolean[] IsComplete = {false};
long a = System.currentTimeMillis();
while (!IsComplete[0]) {
if ((System.currentTimeMillis() - a) > 1000 * (whileTime * 3)) {
break;
} else {
Object sb = ReadMainPLC("机器人放辅料完成");//ListeningValue.get(name);
if (sb != null) {
IsComplete[0] = (boolean) (sb);
}
}
Thread.sleep(100);//10 *6
}
WriteMainPLC("机器人放辅料完成", false, null);

if (val > 0) {
Thread.sleep(val * 1000);
}
} catch (Exception ex) {
ToastUtils.error("异常信息:" + ex.getMessage());
}
}

/**
* 写PLC 出菜
*
* @param data
*/
private static void Write_PLC_MainOutdishes(HashMap<String, String> data) {
try {
ToastUtils.info("准备出菜!");
//先延迟
for (HashMap.Entry<String, String> entry : data.entrySet()) {
String key = entry.getKey();
String value = entry.getValue();
ToastUtils.info("工序:" + key + "," + value);
if (key.contains("(秒)")) {
int val = Integer.parseInt(value);
if (all_list.size() > 0) {
Thread.sleep(val * 1000);
}
}
}
ExecuteTheRecipe.WritePLC("搅拌", false, null);
ExecuteTheRecipe.WritePLC("加热", false, null);

WriteMainPLC("炒锅出餐完成", false, null);
WriteMainPLC("机器人到达炒锅出餐位", false, null);
WriteMainPLC("炒菜完成请求出餐", true, null);
//等待机器人就位
final boolean[] IsComplete = {false};
long a = System.currentTimeMillis();
while (!IsComplete[0]) {
if ((System.currentTimeMillis() - a) > 1000 * (whileTime * 3)) {
break;
} else {
Object sb = ReadMainPLC("机器人到达炒锅出餐位");//ListeningValue.get(name);
if (sb != null) {
IsComplete[0] = (boolean) (sb);
}
}
Thread.sleep(100);//10 *6
}
WriteMainPLC("机器人到达炒锅出餐位", false, null);
WriteMainPLC("炒锅倒菜减速位", false, null);

BottomClick1("出菜");

//一直等待机器移动到该位置,否则就一直等待 6s超时
String name = "出餐启动反馈";
IsComplete[0] = false;
a = System.currentTimeMillis();
while (!IsComplete[0]) {
if ((System.currentTimeMillis() - a) > 1000 * (whileTime * 3)) {
break;
} else {
Object sb = ReadPLC(name);//ListeningValue.get(name);
if (sb != null) {
IsComplete[0] = (boolean) (sb);
}
Object jsw = ReadPLC("炒锅倒菜减速位");//ListeningValue.get(name);
if (jsw != null) {
WriteMainPLC("炒锅出餐减速到位", (Boolean) jsw, null);
}
}
Thread.sleep(100);//10 *6
}
WriteMainPLC("炒锅出餐完成", true, null);
ToastUtils.info("出菜完成,锅体准备回到原位!");
} catch (Exception ex) {
ToastUtils.error("异常信息:" + ex.getMessage());
}
}
//endregion

//region 判断当前工序后是否还有 主料 不包含 手动配料

/**
@@ -900,7 +1179,7 @@ public class ExecuteTheRecipe {
}


if (kkkkkk.size() <= 0 && all_list.size()>0) {
if (kkkkkk.size() <= 0 && all_list.size() > 0) {
IsMove = true;
}

@@ -964,6 +1243,10 @@ public class ExecuteTheRecipe {
//endregion

//region PLC监听线程

/**
* 自提设备监听
*/
public static void Listening() {

ConfigName.getInstance().PLC_Address.clear();
@@ -1011,6 +1294,7 @@ public class ExecuteTheRecipe {
if (ConfigName.getInstance().PlcIsConnect) {
TempControl();
ReadPLCStatus();
ReadPLCMainStatus();
}

} catch (Exception ex) {
@@ -1031,7 +1315,7 @@ public class ExecuteTheRecipe {
try {
if (ConfigName.getInstance().PlcIsConnect) {
//心跳
WritePLC("心跳位",0,null);
WritePLC("心跳位", 0, null);
Log.e("心跳", "心跳: ");
//Log.e("心跳", "心跳: "+new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(new Date()));
}
@@ -1048,6 +1332,48 @@ public class ExecuteTheRecipe {
}
});
}

/**
* 主控设备监听
*/
public static void MainListening() {
new Thread(new Runnable() {
@Override
public void run() {
for (String item : ConfigName.getInstance().MainPlcAddress.keySet()) {
if (!item.equals("商品信息")) {
WriteMainPLC(item, false, null);
}
}
}
}).start();

ThreadManager.Get().StartLong("主控PLC设备-心跳", true, new IThread() {
@Override
public void Run() throws InterruptedException {
try {
if (ConfigName.getInstance().PlcMainIsConnect) {
//心跳
WriteMainPLC("心跳", false, null);
WriteMainPLC("炒锅空闲状态", ConfigName.getInstance().WokStatus, null);
WriteMainPLC("投料机构状态", ConfigName.getInstance().TouLiaoStatus, null);

//读取主控下发的商品
ReadMasterDeliveryGoods();
}

} catch (Exception ex) {
ToastUtils.error("异常信息:" + ex.getMessage());
}
Thread.sleep(2000);
}

@Override
public void RunComplete() throws InterruptedException {

}
});
}
//endregion

//region PLC基础控制类
@@ -1096,7 +1422,6 @@ public class ExecuteTheRecipe {
if (!plcaddress.address.isEmpty() && ConfigName.getInstance().PlcIsConnect) {
if (plcaddress.address.toUpperCase().startsWith("VD"))//int
{

ModbusTcpServer.get().ReadInt(plcaddress.address, 1, ints -> {
ReturnsVariable[0] = ints[0];
});
@@ -1120,6 +1445,59 @@ public class ExecuteTheRecipe {
}
}

/**
* 写主控PLC数据
*
* @param name
* @param value
*/
public static void WriteMainPLC(String name, boolean value, IWriteCallBack callback) {
try {
if (ConfigName.getInstance().MainPlcAddress.containsKey(name)) {
Integer plcaddress = ConfigName.getInstance().MainPlcAddress.get(name) + (ConfigName.getInstance().DeviceHao - 1) * 100;
if (ConfigName.getInstance().PlcMainIsConnect) {
ModbusTcpMainServer.get().WriteBool(String.valueOf(plcaddress), value, callback);
}
}
} catch (Exception ex) {
ToastUtils.error("异常信息:" + ex.getMessage());
} finally {
}
}

/**
* 读主控PLC数据
*
* @param name
* @return
*/
public static Object ReadMainPLC(String name) {
final Object[] ReturnsVariable = {null};
try {
if (ConfigName.getInstance().MainPlcAddress.containsKey(name)) {
if (!name.equals("商品信息")) {
Integer plcaddress = ConfigName.getInstance().MainPlcAddress.get(name) + (ConfigName.getInstance().DeviceHao - 1) * 100;
if (ConfigName.getInstance().PlcMainIsConnect) {
ModbusTcpMainServer.get().ReadBool(String.valueOf(plcaddress), 1, val -> {
ReturnsVariable[0] = val[0];
});
}
} else {
Integer plcaddress = ConfigName.getInstance().MainPlcAddress.get(name) + (ConfigName.getInstance().DeviceHao - 1) * 20;
if (ConfigName.getInstance().PlcMainIsConnect) {
ModbusTcpMainServer.get().ReadString(String.valueOf(plcaddress), 36, val1 -> {
ReturnsVariable[0] = val1;
});
}
}
}
} catch (Exception ex) {
ToastUtils.error("异常信息:" + ex.getMessage());
} finally {
return ReturnsVariable[0];
}
}

/**
* 实时状态
*/
@@ -1195,13 +1573,35 @@ public class ExecuteTheRecipe {
}
}

/**
* 反馈主控制台状态
*/
public static void ReadPLCMainStatus() {
try {
if (ConfigName.getInstance().PlcIsConnect) {
Object obj1 = getListingValue("翻转轴1允许机器人放盒取盒");
Object obj2 = getListingValue("翻转轴2允许机器人放盒取盒");
boolean ob1 = obj1 == null ? false : (boolean) obj1;
boolean ob2 = obj2 == null ? false : (boolean) obj2;
ConfigName.getInstance().TouLiaoStatus = ob1 && ob2;

Object obj3 = getListingValue("初始化");
boolean ob3 = obj3 == null ? false : (boolean) obj3;
ConfigName.getInstance().WokStatus = ob3 && !ExecuteTheRecipe.IsStart;
}
} catch (Exception ex) {
ToastUtils.error("异常信息:" + ex.getMessage());
} finally {
}
}

/**
* 温控
*/
public static void TempControl() {
boolean TempBool = false;
Object val_wd = ExecuteTheRecipe.getListingValue("当前锅底温度");
int dq_wd =val_wd==null?0: (int) val_wd;//当前锅底温度
int dq_wd = val_wd == null ? 0 : (int) val_wd;//当前锅底温度
if (dq_wd >= (ConfigName.getInstance().MaxTemp - 5)) //如果当前温度大于最大温度限制 断开
{
TempBool = true;//设置断开
@@ -1226,6 +1626,84 @@ public class ExecuteTheRecipe {
}
}
}

/**
* 读取主控下发的商品
*/
public static void ReadMasterDeliveryGoods() {
Object Ismake = ReadMainPLC("商品下发");
if (Ismake != null) {
if ((boolean) Ismake) //信息来了,是否需要制作
{
WriteMainPLC("商品下发", false, null);
Object obj = ReadMainPLC("商品信息");
String id = obj == null ? "--------" : (String) obj;

BPA_GOODS goods = QueryDB.GetGoodsId(id);
if (goods == null) {
WriteMainPLC("商品数据验证", false, null);
} else {
// Object chushiover = ExecuteTheRecipe.getListingValue("初始化完成");
// if (!ConfigName.getInstance().PlcIsConnect) {
// ToastUtils.warning("PLC未准备就绪!!!");
// WriteMainPLC("商品数据验证", false, null);
// }else if (chushiover == null || !(boolean) chushiover) {
// ToastUtils.warning("设备未初始化,请先手动初始化设备!!!");
// WriteMainPLC("商品数据验证", false, null);
// }else
if (ExecuteTheRecipe.IsStart) {
ToastUtils.warning("请耐心等待商品制作结束!!!");
WriteMainPLC("商品数据验证", false, null);
} else {
if (ConfigName.getInstance().user.name.equals("admin") || ConfigName.getInstance().user.account.equals("admin") || ConfigName.getInstance().user.userID.equals("超级管理员")) {
DataBus.getInstance().mListener.clickListener(null, goods);
try {
final boolean[] IsComplete = {false};
long a = System.currentTimeMillis();
while (!IsComplete[0]) {
if ((System.currentTimeMillis() - a) > 1000 * (whileTime * 3)) {
break;
} else {
Object sb = ReadMainPLC("机器人放主料完成");
if (sb != null) {
IsComplete[0] = (boolean) (sb);
}
}
Thread.sleep(100);//10 *6
}
WriteMainPLC("机器人放主料完成", false, null);
} catch (Exception e) {

}
MessageManager.getInstance().sendMessage(MessageName.IsStratMakeGood1, goods.id);

} else {
MessageManager.getInstance().sendMessage(MessageName.OpenMakeGoodFrom, goods.id);
try {
final boolean[] IsComplete = {false};
long a = System.currentTimeMillis();
while (!IsComplete[0]) {
if ((System.currentTimeMillis() - a) > 1000 * (whileTime * 3)) {
break;
} else {
Object sb = ReadMainPLC("机器人放主料完成");
if (sb != null) {
IsComplete[0] = (boolean) (sb);
}
}
Thread.sleep(100);//10 *6
}
WriteMainPLC("机器人放主料完成", false, null);
} catch (Exception e) {

}
MessageManager.getInstance().sendMessage(MessageName.IsStratMakeGood, goods.id);
}
}
}
}
}
}
//endregion

//region 获取基础挡位变量


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

@@ -197,6 +197,39 @@ public class ConfigName {
* Plc端口
*/
public int Post = 502;


/**
* 主控 Plc是否连接
*/
public boolean PlcMainIsConnect = false;

/**
* 主控PLC地址
*/
public String MainAddress = "192.168.4.100";
/**
* 主控 Plc端口
*/
public int MainPost = 30000;

/**
* 一拖四设备号
*/
public int DeviceHao = 1;

/**
* 炒锅状态:空闲 或者 不正常
*/
public boolean WokStatus = true;
/**
* 炒锅投料机构:空闲 或者 不正常
*/
public boolean TouLiaoStatus = true;
/**
* 出餐减速位:空闲 或者 不正常
*/
public boolean ChuCaiJainShuStatus = false;
//endregion

//region URL
@@ -828,6 +861,285 @@ public class ConfigName {

}};

/**
* 一拖四基础PLC模型
*/
public List<Res_PLCADDRESS> PlcAddress_一拖四 = new ArrayList<Res_PLCADDRESS>() {{

//硬件设备 初始化
add(new Res_PLCADDRESS("硬件设备", "-------------", 0, 0));
add(new Res_PLCADDRESS("初始化", "M10.0", 1, 1));
add(new Res_PLCADDRESS("停止", "M10.1", 1, 1));
add(new Res_PLCADDRESS("复位", "M10.2", 0, 1));

//搅拌模型
add(new Res_PLCADDRESS("模型控制", "-------------", 0, 0));
add(new Res_PLCADDRESS("搅拌", "M10.3", 0, 1));
add(new Res_PLCADDRESS("搅拌速度", "VW102", 1, 1));

//翻转正转模型
add(new Res_PLCADDRESS("翻转正转", "M10.4", 0, 1));
add(new Res_PLCADDRESS("翻转反转", "M10.5", 0, 1));
add(new Res_PLCADDRESS("转动速度", "VW104", 1, 1));


//加热模型
add(new Res_PLCADDRESS("加热", "M10.6", 0, 1));
add(new Res_PLCADDRESS("加热功率", "VW100", 1, 1));
add(new Res_PLCADDRESS("温控开关", "M17.6", 1, 1));
add(new Res_PLCADDRESS("暂停开关", "M17.7", 1, 1));

//主料
add(new Res_PLCADDRESS("主料1号位", "M17.4", 0, 1));
add(new Res_PLCADDRESS("主料2号位", "M19.4", 0, 1));

//抽水放水
add(new Res_PLCADDRESS("炒锅抽水", "M10.7", 0, 1));
add(new Res_PLCADDRESS("炒锅放水", "M11.0", 0, 1));


//出菜模型
add(new Res_PLCADDRESS("出菜", "M11.5", 0, 1));


//位置动作
add(new Res_PLCADDRESS("原点位", "M11.4", 0, 1));
add(new Res_PLCADDRESS("倒菜位", "M12.7", 0, 1));
add(new Res_PLCADDRESS("抽料位", "M11.7", 0, 1));
add(new Res_PLCADDRESS("清洗位", "M13.0", 0, 1));
add(new Res_PLCADDRESS("炒菜位1", "M12.0", 0, 1));
add(new Res_PLCADDRESS("炒菜位2", "M12.1", 0, 1));
add(new Res_PLCADDRESS("炒菜位3", "M12.2", 0, 1));

add(new Res_PLCADDRESS("出餐启动", "M11.5", 0, 1));
add(new Res_PLCADDRESS("炒锅清洗", "M11.6", 0, 1));

//液体料模型
add(new Res_PLCADDRESS("料仓校准", "-------------", 0, 0));
add(new Res_PLCADDRESS("校准时间", "VW112", 1, 1));
add(new Res_PLCADDRESS("料仓1校准开关", "M12.3", 0, 1));
add(new Res_PLCADDRESS("料仓1校准值", "VW114", 1, 1));
add(new Res_PLCADDRESS("料仓2校准开关", "M12.4", 0, 1));
add(new Res_PLCADDRESS("料仓2校准值", "VW116", 1, 1));
add(new Res_PLCADDRESS("料仓3校准开关", "M12.5", 0, 1));
add(new Res_PLCADDRESS("料仓3校准值", "VW118", 1, 1));
add(new Res_PLCADDRESS("料仓4校准开关", "M13.5", 0, 1));
add(new Res_PLCADDRESS("料仓4校准值", "VW120", 1, 1));
add(new Res_PLCADDRESS("开始校正", "M12.6", 0, 1));

add(new Res_PLCADDRESS("料仓自动", "-------------", 0, 0));
add(new Res_PLCADDRESS("料仓1需求值", "VW106", 1, 1));
add(new Res_PLCADDRESS("料仓1下料", "M11.1", 0, 1));
add(new Res_PLCADDRESS("料仓2需求值", "VW108", 1, 1));
add(new Res_PLCADDRESS("料仓2下料", "M11.2", 0, 1));
add(new Res_PLCADDRESS("料仓3需求值", "VW110", 1, 1));
add(new Res_PLCADDRESS("料仓3下料", "M11.3", 0, 1));
add(new Res_PLCADDRESS("料仓4需求值", "VW122", 1, 1));
add(new Res_PLCADDRESS("料仓4下料", "M13.4", 0, 1));

add(new Res_PLCADDRESS("料仓手动", "-------------", 0, 0));
add(new Res_PLCADDRESS("料仓1手动开关", "M13.1", 1, 1));
add(new Res_PLCADDRESS("料仓2手动开关", "M13.2", 1, 1));
add(new Res_PLCADDRESS("料仓3手动开关", "M13.3", 1, 1));
add(new Res_PLCADDRESS("料仓4手动开关", "M10.7", 1, 1));

//上下限
add(new Res_PLCADDRESS("位置上下限", "-------------", 0, 0));
add(new Res_PLCADDRESS("原点位置下限", "VD150", 1, 1));
add(new Res_PLCADDRESS("原点位置上限", "VD154", 1, 1));
add(new Res_PLCADDRESS("洗锅位置下限", "VD158", 1, 1));
add(new Res_PLCADDRESS("洗锅位置上限", "VD162", 1, 1));
add(new Res_PLCADDRESS("倒菜位置下限", "VD166", 1, 1));
add(new Res_PLCADDRESS("倒菜位置上限", "VD170", 1, 1));
add(new Res_PLCADDRESS("抽调料位置下限", "VD174", 1, 1));
add(new Res_PLCADDRESS("抽调料位置上限", "VD178", 1, 1));
add(new Res_PLCADDRESS("1#炒制位置下限", "VD182", 1, 1));
add(new Res_PLCADDRESS("1#炒制位置上限", "VD186", 1, 1));
add(new Res_PLCADDRESS("2#炒制位置下限", "VD190", 1, 1));
add(new Res_PLCADDRESS("2#炒制位置上限", "VD194", 1, 1));
add(new Res_PLCADDRESS("3#炒制位置下限", "VD198", 1, 1));
add(new Res_PLCADDRESS("3#炒制位置上限", "VD202", 1, 1));
add(new Res_PLCADDRESS("炒锅工作范围下限", "VD206", 1, 1));
add(new Res_PLCADDRESS("炒锅工作范围上限", "VD210", 1, 1));

//自动投料-平移轴
// add(new Res_PLCADDRESS("平移轴控制", "-------------", 0, 0));
// add(new Res_PLCADDRESS("平移-伺服当前值", "VD220", 1, 1));
// add(new Res_PLCADDRESS("平移-点动速度", "VD224", 1, 1));
// add(new Res_PLCADDRESS("平移-回原点速度", "VD228", 1, 1));
// add(new Res_PLCADDRESS("平移-定位运行速度", "VD232", 1, 1));
//
// add(new Res_PLCADDRESS("平移-点动正转", "M14.0", 0, 1));
// add(new Res_PLCADDRESS("平移-点动反转", "M14.1", 0, 1));
// add(new Res_PLCADDRESS("平移-回原点", "M14.2", 0, 1));
// add(new Res_PLCADDRESS("平移-去1号位", "M14.3", 0, 1));
// add(new Res_PLCADDRESS("平移-去2号位", "M14.4", 0, 1));
// add(new Res_PLCADDRESS("平移-去3号位", "M14.5", 0, 1));
// add(new Res_PLCADDRESS("平移-去4号位", "M14.6", 0, 1));
//
// add(new Res_PLCADDRESS("平移-1号位置值", "VD236", 1, 1));
// add(new Res_PLCADDRESS("平移-1#位置设定", "M15.0", 0, 1));
// add(new Res_PLCADDRESS("平移-2号位置值", "VD240", 1, 1));
// add(new Res_PLCADDRESS("平移-2#位置设定", "M15.1", 0, 1));
// add(new Res_PLCADDRESS("平移-3号位置值", "VD244", 1, 1));
// add(new Res_PLCADDRESS("平移-3#位置设定", "M15.2", 0, 1));
// add(new Res_PLCADDRESS("平移-4号位置值", "VD248", 1, 1));
// add(new Res_PLCADDRESS("平移-4#位置设定", "M15.3", 0, 1));

//自动投料-翻转轴
add(new Res_PLCADDRESS("翻转轴控制1", "-------------", 0, 0));
add(new Res_PLCADDRESS("翻转1-伺服当前值", "VD260", 1, 1));
add(new Res_PLCADDRESS("翻转1-点动速度", "VD264", 1, 1));
add(new Res_PLCADDRESS("翻转1-回原点速度", "VD268", 1, 1));
add(new Res_PLCADDRESS("翻转1-定位运行速度", "VD272", 1, 1));

add(new Res_PLCADDRESS("翻转1-点动正转", "M16.0", 0, 1));
add(new Res_PLCADDRESS("翻转1-点动反转", "M16.1", 0, 1));
add(new Res_PLCADDRESS("翻转1-回原点", "M16.2", 0, 1));
add(new Res_PLCADDRESS("翻转1-去1号位", "M16.3", 0, 1));
add(new Res_PLCADDRESS("翻转1-去2号位", "M16.4", 0, 1));
add(new Res_PLCADDRESS("翻转1-去3号位", "M16.5", 0, 1));
add(new Res_PLCADDRESS("翻转1-去4号位", "M16.6", 0, 1));

add(new Res_PLCADDRESS("翻转1-1号位置值", "VD276", 1, 1));
add(new Res_PLCADDRESS("翻转1-1#位置设定", "M17.0", 0, 1));
add(new Res_PLCADDRESS("翻转1-2号位置值", "VD280", 1, 1));
add(new Res_PLCADDRESS("翻转1-2#位置设定", "M17.1", 0, 1));
add(new Res_PLCADDRESS("翻转1-3号位置值", "VD284", 1, 1));
add(new Res_PLCADDRESS("翻转1-3#位置设定", "M17.2", 0, 1));
add(new Res_PLCADDRESS("翻转1-4号位置值", "VD288", 1, 1));
add(new Res_PLCADDRESS("翻转1-4#位置设定", "M17.3", 0, 1));
add(new Res_PLCADDRESS("倒菜启动1", "M17.4", 0, 1));

add(new Res_PLCADDRESS("翻转轴控制2", "-------------", 0, 0));
add(new Res_PLCADDRESS("翻转2-伺服当前值", "VD2000", 1, 1));
add(new Res_PLCADDRESS("翻转2-点动速度", "VD2004", 1, 1));
add(new Res_PLCADDRESS("翻转2-回原点速度", "VD2008", 1, 1));
add(new Res_PLCADDRESS("翻转2-定位运行速度", "VD2012", 1, 1));

add(new Res_PLCADDRESS("翻转2-点动正转", "M18.0", 0, 1));
add(new Res_PLCADDRESS("翻转2-点动反转", "M18.1", 0, 1));
add(new Res_PLCADDRESS("翻转2-回原点", "M18.2", 0, 1));
add(new Res_PLCADDRESS("翻转2-去1号位", "M18.3", 0, 1));
add(new Res_PLCADDRESS("翻转2-去2号位", "M18.4", 0, 1));
add(new Res_PLCADDRESS("翻转2-去3号位", "M18.5", 0, 1));
add(new Res_PLCADDRESS("翻转2-去4号位", "M18.6", 0, 1));

add(new Res_PLCADDRESS("翻转2-1号位置值", "VD2016", 1, 1));
add(new Res_PLCADDRESS("翻转2-1#位置设定", "M19.0", 0, 1));
add(new Res_PLCADDRESS("翻转2-2号位置值", "VD2020", 1, 1));
add(new Res_PLCADDRESS("翻转2-2#位置设定", "M19.1", 0, 1));
add(new Res_PLCADDRESS("翻转2-3号位置值", "VD2024", 1, 1));
add(new Res_PLCADDRESS("翻转2-3#位置设定", "M19.2", 0, 1));
add(new Res_PLCADDRESS("翻转2-4号位置值", "VD2028", 1, 1));
add(new Res_PLCADDRESS("翻转2-4#位置设定", "M19.3", 0, 1));
add(new Res_PLCADDRESS("倒菜启动2", "M19.4", 0, 1));

//反馈信号
add(new Res_PLCADDRESS("反馈信号", "-------------", 0, 0));
add(new Res_PLCADDRESS("初始化完成", "M40.0", 1, 0));
add(new Res_PLCADDRESS("设备急停", "M40.1", 1, 0));
add(new Res_PLCADDRESS("原点位反馈", "M40.2", 1, 0));
add(new Res_PLCADDRESS("抽料位反馈", "M40.3", 1, 0));
add(new Res_PLCADDRESS("炒菜位1反馈", "M40.4", 1, 0));
add(new Res_PLCADDRESS("炒菜位2反馈", "M40.5", 1, 0));
add(new Res_PLCADDRESS("炒菜位3反馈", "M40.6", 1, 0));
add(new Res_PLCADDRESS("倒菜位反馈", "M40.7", 1, 0));
add(new Res_PLCADDRESS("投料位反馈", "M41.0", 1, 0));
add(new Res_PLCADDRESS("清洗位反馈", "M41.1", 1, 0));
add(new Res_PLCADDRESS("料仓1下料完成", "M41.2", 1, 0));
add(new Res_PLCADDRESS("料仓2下料完成", "M41.3", 1, 0));
add(new Res_PLCADDRESS("料仓3下料完成", "M41.4", 1, 0));
add(new Res_PLCADDRESS("料仓4下料完成", "M42.0", 1, 0));
add(new Res_PLCADDRESS("炒锅清洗反馈", "M41.5", 1, 0));
add(new Res_PLCADDRESS("出餐启动反馈", "M41.6", 1, 0));
add(new Res_PLCADDRESS("炒锅倒菜减速位", "M41.7", 1, 0));
add(new Res_PLCADDRESS("平移轴在1号位", "M43.0", 1, 0));
add(new Res_PLCADDRESS("平移轴在2号位", "M43.1", 1, 0));
add(new Res_PLCADDRESS("平移轴在3号位", "M43.2", 1, 0));
add(new Res_PLCADDRESS("平移轴在4号位", "M43.3", 1, 0));

add(new Res_PLCADDRESS("翻转轴1在1号位", "M44.0", 1, 0));
add(new Res_PLCADDRESS("翻转轴1在2号位", "M44.1", 1, 0));
add(new Res_PLCADDRESS("翻转轴1在3号位", "M44.2", 1, 0));
add(new Res_PLCADDRESS("翻转轴1在4号位", "M44.3", 1, 0));
add(new Res_PLCADDRESS("翻转轴1允许机器人放盒取盒", "M44.4", 1, 0));
add(new Res_PLCADDRESS("1号位倒菜完成", "M44.7", 1, 0));


add(new Res_PLCADDRESS("翻转轴2在1号位", "M45.0", 1, 0));
add(new Res_PLCADDRESS("翻转轴2在2号位", "M45.1", 1, 0));
add(new Res_PLCADDRESS("翻转轴2在3号位", "M45.2", 1, 0));
add(new Res_PLCADDRESS("翻转轴2在4号位", "M45.3", 1, 0));
add(new Res_PLCADDRESS("翻转轴2允许机器人放盒取盒", "M45.4", 1, 0));
add(new Res_PLCADDRESS("2号位倒菜完成", "M45.7", 1, 0));

add(new Res_PLCADDRESS("心跳位", "VW1000", 0, 1));

//检测信号
add(new Res_PLCADDRESS("监测信号", "-------------", 0, 0));
add(new Res_PLCADDRESS("当前锅底温度", "VD300", 1, 0));
add(new Res_PLCADDRESS("炒锅搅拌转速", "VD304", 1, 0));
add(new Res_PLCADDRESS("当前加热档位", "VD308", 1, 0));
add(new Res_PLCADDRESS("炒锅当前电压", "VD312", 1, 0));
add(new Res_PLCADDRESS("炒锅当前电流", "VD316", 1, 0));
add(new Res_PLCADDRESS("炒锅当前功率", "VD320", 1, 0));
add(new Res_PLCADDRESS("搅拌频率", "VW324", 1, 0));
add(new Res_PLCADDRESS("搅拌电机电流", "VW326", 1, 0));
add(new Res_PLCADDRESS("搅拌电机电压", "VW328", 1, 0));
add(new Res_PLCADDRESS("搅拌变频器温度", "VW330", 1, 0));
add(new Res_PLCADDRESS("翻转频率", "VW332", 1, 0));
add(new Res_PLCADDRESS("翻转电机电流", "VW334", 1, 0));
add(new Res_PLCADDRESS("翻转电机电压", "VW336", 1, 0));
add(new Res_PLCADDRESS("翻转变频器温度", "VW338", 1, 0));
add(new Res_PLCADDRESS("编码器当前位值", "VD340", 1, 0));

//状态上报
add(new Res_PLCADDRESS("状态上报", "-------------", 0, 0));
add(new Res_PLCADDRESS("搅拌电机", "VW350", 1, 0));
add(new Res_PLCADDRESS("翻转电机", "VW352", 1, 0));
add(new Res_PLCADDRESS("炒锅", "VW354", 1, 0));

}};
/**
* 一拖四工序模型
*/
public List<ProcessT> Process_一拖四 = new ArrayList<ProcessT>() {{
add(new ProcessT("搅拌", Arrays.asList("搅拌速度", "延迟(秒)")));
add(new ProcessT("位置", Arrays.asList("转动速度", "位置动作", "延迟(秒)")));
add(new ProcessT("加热", Arrays.asList("加热功率", "延迟(秒)")));
add(new ProcessT("主料", Arrays.asList("主料名称", "主料位置", "主料重量", "投料动作","烹饪(秒)")));
add(new ProcessT("辅料", Arrays.asList("辅料名称", "烹饪(秒)")));
add(new ProcessT("液体料", new ArrayList<>()));
add(new ProcessT("延迟", Arrays.asList("延迟(秒)")));
add(new ProcessT("出菜", Arrays.asList("等待(秒)")));
add(new ProcessT("清洗", Arrays.asList("等待(秒)")));
}};

/**
* 主控地址列表
*/
public ConcurrentHashMap<String, Integer> MainPlcAddress = new ConcurrentHashMap<String, Integer>() {{
put("炒锅空闲状态",1); //实时
put("炒锅出餐完成",2);
put("炒锅投主料完成",3);
put("炒锅请求投辅料",4);
put("商品数据验证",5);
put("投料机构状态",6); //实时
put("心跳",7); //实时
put("炒菜完成请求出餐",8);
put("炒锅出餐减速到位",9); //实时


put("机器人放主料完成",51);
put("机器人放辅料完成",52);
put("机器人到达炒锅出餐位",53);
put("商品下发",54);
put("商品信息",0);
}};



/**
* 根据名称获取变量
*
@@ -879,9 +1191,6 @@ public class ConfigName {
put("七档", 7);
put("八档", 8);
}};



public Map<String, Integer> HeatingGearL = new LinkedHashMap<String, Integer>() {{
put("二档", 0);
put("三档", 1);
@@ -892,7 +1201,6 @@ public class ConfigName {
put("八档", 6);
}};


//region 火力最大级别
/**
* 最大火力级别
@@ -1026,7 +1334,7 @@ public class ConfigName {
/**
* 版本信息
*/
public String[] versionSelectionValues = new String[]{"大炒版本", "大炒自动投料版本", "小炒版本"};
public String[] versionSelectionValues = new String[]{"大炒版本", "大炒自动投料版本", "小炒版本","一拖四大炒","一拖二大炒"};
/**
* 选配版本信息
*/
@@ -1039,7 +1347,7 @@ public class ConfigName {
add("研发用户");
add("超级管理员");
}};
//eneregion
//endregion

//region 料仓显示物料
/**


+ 4
- 0
app/src/main/java/com/bonait/bnframework/common/constant/MessageName.java View File

@@ -29,4 +29,8 @@ public interface MessageName {
String OpenMakeGoodFrom="OpenMakeGoodFrom";//打开制作界面

String GoodIsCunZai="GoodIsCunZai";

String IsStratMakeGood="IsStratMakeGood";//打开制作界面
String IsStratMakeGood1="IsStratMakeGood1";//打开制作界面

}

+ 43
- 0
app/src/main/java/com/bonait/bnframework/common/modbus/ModbusTcpMainHelper.java View File

@@ -0,0 +1,43 @@
package com.bonait.bnframework.common.modbus;

import com.licheedev.modbus4android.ModbusWorker;
import com.serotonin.modbus4j.ModbusMaster;

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

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

private ModbusTcpMainHelper() {
}

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

/**
* 获取
* @return
*/
public synchronized ModbusMaster getModbusMaster()
{
return super.getModbusMaster();
}

}

+ 740
- 0
app/src/main/java/com/bonait/bnframework/common/modbus/ModbusTcpMainServer.java View File

@@ -0,0 +1,740 @@
package com.bonait.bnframework.common.modbus;

import com.bonait.bnframework.business.ConfigData;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.helper.DataFormat;
import com.bonait.bnframework.common.helper.I.IReadCallBack;
import com.bonait.bnframework.common.helper.I.IWriteCallBack;
import com.bonait.bnframework.common.helper.MessageLog;
import com.bonait.bnframework.common.utils.ToastUtils;
import com.licheedev.modbus4android.ModbusCallback;
import com.licheedev.modbus4android.ModbusParam;
import com.licheedev.modbus4android.ModbusRespException;
import com.licheedev.modbus4android.param.TcpParam;
import com.serotonin.modbus4j.ModbusMaster;
import com.serotonin.modbus4j.exception.ModbusInitException;
import com.serotonin.modbus4j.exception.ModbusTransportException;
import com.serotonin.modbus4j.msg.ReadCoilsResponse;
import com.serotonin.modbus4j.msg.ReadHoldingRegistersResponse;

import java.io.IOException;
import java.io.InputStreamReader;
import java.io.LineNumberReader;
import java.io.UnsupportedEncodingException;
import java.nio.ByteBuffer;
import java.util.Arrays;
import java.util.concurrent.ExecutionException;

/**
* 主控Tcp服务
*/
public class ModbusTcpMainServer {
private static volatile ModbusTcpMainServer instance = null;

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

private ModbusTcpMainServer() {
}

static 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("I") && 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) + 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;
// }
// }
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 "";
}

/**
* Ping PLC地址是否通畅
* @param address
* @param pingTimes ping的次数
* @param timeOut 超时时间 10
* @return
*/
public static boolean ping2(String address, int pingTimes, int timeOut) {
Process process = null;
try {
process = Runtime.getRuntime().exec( "ping " + "-c " + pingTimes + " -w " + timeOut+ " "+address);
InputStreamReader r = new InputStreamReader(process.getInputStream());

LineNumberReader returnData = new LineNumberReader(r);

String returnMsg="";

String line = "";

while ((line = returnData.readLine()) != null) {

System.out.println(line);

returnMsg += line;

}

if(returnMsg.indexOf("100% packet loss")!=-1){
System.out.println("与 " +address +" 连接不畅通.");
//ToastUtils.info("与 " +address +" 连接不畅通.");
return false;
} else{
System.out.println("与 " +address +" 连接畅通.");
//ToastUtils.info("与 " +address +" 连接不畅通.");
return true;
}
} catch (IOException e) {
// e.printStackTrace();
}
return false;

}


/**
* 连接
*/
public void Connect() throws InterruptedException {
boolean status = false;
while (!status) {
try {
//status为0则代表通,为1则代表不通。
status =ping2(ConfigName.getInstance().Address,1,1);
Thread.sleep(1000);
} catch (InterruptedException e) {
MessageLog.ShowInfo("设备 " + ConfigName.getInstance().Address + " 网络验证失败");
} catch (Exception e) {
MessageLog.ShowInfo("设备 " + ConfigName.getInstance().Address + " 网络验证失败");
}
}
MessageLog.ShowInfo("设备 " + ConfigName.getInstance().Address + " PLC通讯正常,准备连接!");

while (ConfigName.getInstance().PlcIsConnect==false)
{
ConnectPLC();
Thread.sleep(5000);
}
}

/**
* 连接PLC
*/
public static void ConnectPLC()
{
String host=ConfigName.getInstance().MainAddress;
int port=ConfigName.getInstance().MainPost;
param = TcpParam.create(host, port)
.setTimeout(1000)
.setRetries(0)
.setEncapsulated(false)
.setKeepAlive(true);
ModbusTcpMainHelper.get().init(param, new ModbusCallback<ModbusMaster>() {
@Override
public void onSuccess(ModbusMaster modbusMaster) {
ToastUtils.info("设备 " + ConfigName.getInstance().MainAddress + " 连接成功");

MessageLog.ShowInfo("设备 " + ConfigName.getInstance().MainAddress + " 连接成功");
ConfigName.getInstance().PlcMainIsConnect = true;
ConfigData.getInstance().MainPLC_Init();
}

@Override
public void onFailure(Throwable tr) {
ConfigName.getInstance().PlcMainIsConnect = false;
ToastUtils.info("设备 " + ConfigName.getInstance().MainAddress + " 连接失败:" + tr.getMessage());
MessageLog.ShowError("设备 " + ConfigName.getInstance().MainAddress + " 连接失败:" + tr.getMessage());
}
@Override
public void onFinally() {

}
});
}


private Float BytesToFloat(byte[] buffers, DataFormat df) {
if (buffers.length == 4) {
byte[] bytes = new byte[4];
if (df == DataFormat.ABCD) {
bytes[0] = buffers[3];
bytes[1] = buffers[2];
bytes[2] = buffers[1];
bytes[3] = buffers[0];
} else if (df == DataFormat.CDAB) {
bytes[0] = buffers[1];
bytes[1] = buffers[0];
bytes[2] = buffers[3];
bytes[3] = buffers[2];
} else if (df == DataFormat.BADC) {
bytes[0] = buffers[2];
bytes[1] = buffers[3];
bytes[2] = buffers[0];
bytes[3] = buffers[1];
} else if (df == DataFormat.DCBA) {
bytes[0] = buffers[0];
bytes[1] = buffers[1];
bytes[2] = buffers[2];
bytes[3] = buffers[3];
}
return ByteBuffer.wrap(bytes).getFloat();
}
return 0.0f;
}

private Integer BytesToInt(byte[] buffers, DataFormat df) {
if (buffers.length == 4) {
byte[] bytes = new byte[4];
if (df == DataFormat.ABCD) {
bytes[0] = buffers[3];
bytes[1] = buffers[2];
bytes[2] = buffers[1];
bytes[3] = buffers[0];
} else if (df == DataFormat.CDAB) {
bytes[0] = buffers[1];
bytes[1] = buffers[0];
bytes[2] = buffers[3];
bytes[3] = buffers[2];
} else if (df == DataFormat.BADC) {
bytes[0] = buffers[2];
bytes[1] = buffers[3];
bytes[2] = buffers[0];
bytes[3] = buffers[1];
} else if (df == DataFormat.DCBA) {
bytes[0] = buffers[0];
bytes[1] = buffers[1];
bytes[2] = buffers[2];
bytes[3] = buffers[3];
}
return ByteBuffer.wrap(bytes).getInt();
}
return 0;
}

private byte[] IntToByte(int number) {
int temp = number;
byte[] b = new byte[4];
for (int i = 0; i < b.length; i++) {
b[i] = new Integer(temp & 0xff).byteValue();// 将最低位保存在最低位
temp = temp >> 8; // 向右移8位
}
return b;
}

private short[] IntToShorts(int value) {
short[] res = new short[2];
int temp = value;
byte[] b = new byte[4];
for (int i = 0; i < b.length; i++) {
b[i] = new Integer(temp & 0xff).byteValue();// 将最低位保存在最低位
temp = temp >> 8; // 向右移8位
}
for (int i = 0; i < res.length; i++) {
short s0 = (short) (b[i * 2] & 0xff);// 最低位
short s1 = (short) (b[i * 2 + 1] & 0xff);
s1 <<= 8;
res[i] = (short) (s0 | s1);
}
return res;
}

public static String GetString(short[] src, int start, int len) throws UnsupportedEncodingException {
short[] temp = new short[len];
for (int i = 0; i < len; i++) {
temp[i] = src[i + start];
}
byte[] bytesTemp = shorts2Bytes(temp);
for (int i = 0; i < bytesTemp.length; i++) {
byte b = bytesTemp[i];
}
String str = new String(bytesTemp, "UTF-8");
return str;
}

public static byte[] shorts2Bytes(short[] data) {
byte[] byteValue = new byte[data.length * 2];
for (int i = 0; i < data.length; i++) {
byteValue[i * 2] = (byte) (data[i] & 0xff);
byteValue[i * 2 + 1] = (byte) ((data[i] & 0xff00) >> 8);
}
return byteValue;
}

/***
*读取实时状态
* @param Address the address
* @param length 读取的长度 3
* @param callback 读取成功的回调
*/
public void ReadStatus(String Address, int length, IReadCallBack<byte[]> callback) {
int add = GetAddress(Address);
if (add < 0) return;
try {
ReadHoldingRegistersResponse res = ModbusTcpMainHelper.get().syncReadHoldingRegisters(1, add, length);
byte[] data = res.getData();
byte[] tempData = new byte[6];
tempData[0] = data[1];
tempData[1] = data[0];
if (callback != null) callback.onSuccess(tempData);
} catch (InterruptedException e) {
MessageLog.ShowError("ReadShort onFailure,Address=" + Address + ",length=" + length + ",msg:" + e.toString());
} catch (ExecutionException e) {
MessageLog.ShowError("ReadShort onFailure,Address=" + Address + ",length=" + length + ",msg:" + e.toString());
} catch (ModbusTransportException e) {
MessageLog.ShowError("ReadShort onFailure,Address=" + Address + ",length=" + length + ",msg:" + e.toString());
} catch (ModbusInitException e) {
MessageLog.ShowError("ReadShort onFailure,Address=" + Address + ",length=" + length + ",msg:" + e.toString());
} catch (ModbusRespException e) {
MessageLog.ShowError("ReadShort onFailure,Address=" + Address + ",length=" + length + ",msg:" + e.toString());
}
}

/***
*读取扫码数据
* @param Address the address
* @param length 读取的长度
* @param callback 读取成功的回调
*/
public void ReadString(String Address, int length, IReadCallBack<String> callback) {
int add = GetAddress(Address);
if (add < 0) return;
try {
ReadHoldingRegistersResponse res = ModbusTcpMainHelper.get().syncReadHoldingRegisters(1, add, length);
byte[] data = res.getData();
byte[] data1 = Arrays.copyOfRange(data, 0, length);
//36 GUID 18 Number
String id = "";
try {
byte[] tempdata = new byte[length];
for (int i = 0; i < data1.length; i++) {
if (i % 2 == 0) {

tempdata[i + 1] = data1[i];
} else {
tempdata[i - 1] = data1[i];
}
}
id = new String(tempdata, "UTF-8").trim();
} catch (UnsupportedEncodingException ex) {
}
if (callback != null) callback.onSuccess(id);
} catch (InterruptedException e) {
MessageLog.ShowError("ReadShort onFailure,Address=" + Address + ",length=" + length + ",msg:" + e.toString());
} catch (ExecutionException e) {
MessageLog.ShowError("ReadShort onFailure,Address=" + Address + ",length=" + length + ",msg:" + e.toString());
} catch (ModbusTransportException e) {
MessageLog.ShowError("ReadShort onFailure,Address=" + Address + ",length=" + length + ",msg:" + e.toString());
} catch (ModbusInitException e) {
MessageLog.ShowError("ReadShort onFailure,Address=" + Address + ",length=" + length + ",msg:" + e.toString());
} catch (ModbusRespException e) {
MessageLog.ShowError("ReadShort onFailure,Address=" + Address + ",length=" + length + ",msg:" + e.toString());
}
}

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

public void ReadShort(String Address, int length, IReadCallBack<short[]> callback) {
int add = GetAddress(Address);
if (add < 0) return;
try {
ReadHoldingRegistersResponse res = ModbusTcpMainHelper.get().syncReadHoldingRegisters(1, add, length);
short[] data = res.getShortData();
if (data.length == length) {
if (callback != null) callback.onSuccess(data);
}
} catch (InterruptedException e) {
MessageLog.ShowError("ReadShort onFailure,Address=" + Address + ",length=" + length + ",msg:" + e.toString());
} catch (ExecutionException e) {
MessageLog.ShowError("ReadShort onFailure,Address=" + Address + ",length=" + length + ",msg:" + e.toString());
} catch (ModbusTransportException e) {
MessageLog.ShowError("ReadShort onFailure,Address=" + Address + ",length=" + length + ",msg:" + e.toString());
} catch (ModbusInitException e) {
MessageLog.ShowError("ReadShort onFailure,Address=" + Address + ",length=" + length + ",msg:" + e.toString());
} catch (ModbusRespException e) {
MessageLog.ShowError("ReadShort onFailure,Address=" + Address + ",length=" + length + ",msg:" + e.toString());
}
}

public void ReadBool(String Address, int length, IReadCallBack<boolean[]> callback) {
int add = GetAddress(Address);
if (add < 0) return;
try {
ReadCoilsResponse res = ModbusTcpMainHelper.get().syncReadCoil(1, add, length);
boolean[] data = res.getBooleanData();
boolean[] result = Arrays.copyOfRange(data, 0, length);
if (result.length == length) {
if (callback != null) callback.onSuccess(result);
}
} catch (InterruptedException e) {
MessageLog.ShowError("ReadBool onFailure,Address=" + Address + ",length=" + length + ",msg:" + e.toString());
} catch (ExecutionException e) {
MessageLog.ShowError("ReadBool onFailure,Address=" + Address + ",length=" + length + ",msg:" + e.toString());
} catch (ModbusTransportException e) {
MessageLog.ShowError("ReadBool onFailure,Address=" + Address + ",length=" + length + ",msg:" + e.toString());
} catch (ModbusInitException e) {
MessageLog.ShowError("ReadBool onFailure,Address=" + Address + ",length=" + length + ",msg:" + e.toString());
} catch (ModbusRespException e) {
MessageLog.ShowError("ReadBool onFailure,Address=" + Address + ",length=" + length + ",msg:" + e.toString());
}
}

public void ReadFloat(String Address, int length, IReadCallBack<float[]> callback) {
int add = GetAddress(Address);
if (add < 0) return;
try {
ReadHoldingRegistersResponse res = ModbusTcpMainHelper.get().syncReadHoldingRegisters(1, add, length);
byte[] data = res.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] = BytesToFloat(tempData, DataFormat.ABCD);
}
if (tempValues.length == length) {
if (callback != null) callback.onSuccess(tempValues);
}
} catch (InterruptedException e) {
MessageLog.ShowError("ReadFloat onFailure,Address=" + Address + ",length=" + length + ",msg:" + e.toString());
} catch (ExecutionException e) {
MessageLog.ShowError("ReadFloat onFailure,Address=" + Address + ",length=" + length + ",msg:" + e.toString());
} catch (ModbusTransportException e) {
MessageLog.ShowError("ReadFloat onFailure,Address=" + Address + ",length=" + length + ",msg:" + e.toString());
} catch (ModbusInitException e) {
MessageLog.ShowError("ReadFloat onFailure,Address=" + Address + ",length=" + length + ",msg:" + e.toString());
} catch (ModbusRespException e) {
MessageLog.ShowError("ReadFloat onFailure,Address=" + Address + ",length=" + length + ",msg:" + e.toString());
}
}

public void ReadInt(String Address, int length, IReadCallBack<int[]> callback) {
int add = GetAddress(Address);
if (add < 0) return;
try {
ReadHoldingRegistersResponse res = ModbusTcpMainHelper.get().syncReadHoldingRegisters(1, add, length * 2);
byte[] data = res.getData();
int[] tempValues = new int[length];
if(data.length>=4)
{
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];
}
// Integer a1 = tempValues[i] = BytesToInt(tempData, DataFormat.ABCD);
// Integer a2 = tempValues[i] = BytesToInt(tempData, DataFormat.BADC);
// Integer a3 = tempValues[i] = BytesToInt(tempData, DataFormat.CDAB);
// Integer a4 = tempValues[i] = BytesToInt(tempData, DataFormat.DCBA);
tempValues[i] = BytesToInt(tempData, DataFormat.BADC);
}
}else
{
MessageLog.ShowError("ReadInt onFailure,Address=" );

}
if (callback != null) callback.onSuccess(tempValues);
} catch (InterruptedException e) {
MessageLog.ShowError("ReadInt onFailure,Address=" + Address + ",length=" + length + ",msg:" + e.toString());
} catch (ExecutionException e) {
MessageLog.ShowError("ReadInt onFailure,Address=" + Address + ",length=" + length + ",msg:" + e.toString());
} catch (ModbusTransportException e) {
MessageLog.ShowError("ReadInt onFailure,Address=" + Address + ",length=" + length + ",msg:" + e.toString());
} catch (ModbusInitException e) {
MessageLog.ShowError("ReadInt onFailure,Address=" + Address + ",length=" + length + ",msg:" + e.toString());
} catch (ModbusRespException e) {
MessageLog.ShowError("ReadInt onFailure,Address=" + Address + ",length=" + length + ",msg:" + e.toString());
}
}

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

public void WriteBool(String Address, boolean Value, IWriteCallBack callback) {
int add = GetAddress(Address);
if (add < 0) return;
try {
ModbusTcpMainHelper.get().syncWriteCoil(1, add, Value);
if (callback != null)
callback.onSuccess();
} catch (InterruptedException e) {
MessageLog.ShowError("WriteBool onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
if (callback != null) callback.onFailure(e.toString());
} catch (ExecutionException e) {
MessageLog.ShowError("WriteBool onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
if (callback != null) callback.onFailure(e.toString());
} catch (ModbusTransportException e) {
MessageLog.ShowError("WriteBool onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
if (callback != null) callback.onFailure(e.toString());
} catch (ModbusInitException e) {
MessageLog.ShowError("WriteBool onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
if (callback != null) callback.onFailure(e.toString());
} catch (ModbusRespException e) {
MessageLog.ShowError("WriteBool onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
if (callback != null) callback.onFailure(e.toString());
}
}

public void WriteFloat(String Address, float Value, IWriteCallBack callback) {
int add = GetAddress(Address);
if (add < 0) return;
int intBits = Float.floatToRawIntBits(Value);
short[] send = new short[]{(short) ((intBits >> 16) & 0xffff), (short) (intBits & 0xffff)};
try {
ModbusTcpMainHelper.get().syncWriteRegisters(1, add, send);

if (callback != null) callback.onSuccess();
} catch (InterruptedException e) {
MessageLog.ShowError("WriteFloat onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
if (callback != null) callback.onFailure(e.toString());
} catch (ExecutionException e) {
MessageLog.ShowError("WriteFloat onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
if (callback != null) callback.onFailure(e.toString());
} catch (ModbusTransportException e) {
MessageLog.ShowError("WriteFloat onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
if (callback != null) callback.onFailure(e.toString());
} catch (ModbusInitException e) {
MessageLog.ShowError("WriteFloat onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
if (callback != null) callback.onFailure(e.toString());
} catch (ModbusRespException e) {
MessageLog.ShowError("WriteFloat onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
if (callback != null) callback.onFailure(e.toString());
}
}

public void WriteInt(String Address, int Value, IWriteCallBack callback) {
int add = GetAddress(Address);
if (add < 0) return;
short[] send = IntToShorts(Value);
try {
ModbusTcpMainHelper.get().syncWriteRegisters(1, add, send);
if (callback != null) callback.onSuccess();
} catch (InterruptedException e) {
MessageLog.ShowError("WriteInt onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
if (callback != null) callback.onFailure(e.toString());
} catch (ExecutionException e) {
MessageLog.ShowError("WriteInt onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
if (callback != null) callback.onFailure(e.toString());
} catch (ModbusTransportException e) {
MessageLog.ShowError("WriteInt onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
if (callback != null) callback.onFailure(e.toString());
} catch (ModbusInitException e) {
MessageLog.ShowError("WriteInt onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
if (callback != null) callback.onFailure(e.toString());
} catch (ModbusRespException e) {
MessageLog.ShowError("WriteInt onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
if (callback != null) callback.onFailure(e.toString());
}
}

public void WriteShort(String Address, short Value) {
int add = GetAddress(Address);
if (add < 0) return;
short[] send = new short[1];
send[0] = Value;
try {
ModbusTcpMainHelper.get().syncWriteRegisters(1, add, send);
} catch (InterruptedException e) {
MessageLog.ShowError("WriteShort onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
} catch (ExecutionException e) {
MessageLog.ShowError("WriteShort onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
} catch (ModbusTransportException e) {
MessageLog.ShowError("WriteShort onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
} catch (ModbusInitException e) {
MessageLog.ShowError("WriteShort onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
} catch (ModbusRespException e) {
MessageLog.ShowError("WriteShort onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
}
}

public void WriteBool(String Address, boolean Value) {
int add = GetAddress(Address);
if (add < 0) return;

try {
ModbusTcpMainHelper.get().syncWriteCoil(1, add, Value);
} catch (InterruptedException e) {
MessageLog.ShowError("WriteBool onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
} catch (ExecutionException e) {
MessageLog.ShowError("WriteBool onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
} catch (ModbusTransportException e) {
MessageLog.ShowError("WriteBool onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
} catch (ModbusInitException e) {
MessageLog.ShowError("WriteBool onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
} catch (ModbusRespException e) {
MessageLog.ShowError("WriteBool onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
}
}

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)};
try {
ModbusTcpMainHelper.get().syncWriteRegisters(1, add, send);
} catch (InterruptedException e) {
MessageLog.ShowError("WriteFloat onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
} catch (ExecutionException e) {
MessageLog.ShowError("WriteFloat onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
} catch (ModbusTransportException e) {
MessageLog.ShowError("WriteFloat onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
} catch (ModbusInitException e) {
MessageLog.ShowError("WriteFloat onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
} catch (ModbusRespException e) {
MessageLog.ShowError("WriteFloat onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
}
}

public void WriteInt(String Address, int Value) {
int add = GetAddress(Address);
if (add < 0) return;
short[] send = IntToShorts(Value);
try {
ModbusTcpMainHelper.get().syncWriteRegisters(1, add, send);
} catch (InterruptedException e) {
MessageLog.ShowError("WriteInt onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
} catch (ExecutionException e) {
MessageLog.ShowError("WriteInt onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
} catch (ModbusTransportException e) {
MessageLog.ShowError("WriteInt onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
} catch (ModbusInitException e) {
MessageLog.ShowError("WriteInt onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
} catch (ModbusRespException e) {
MessageLog.ShowError("WriteInt onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
}
}
}

+ 0
- 32
app/src/main/java/com/bonait/bnframework/common/modbus/ModbusTcpServer.java View File

@@ -232,38 +232,6 @@ public class ModbusTcpServer {
});
}

// /**
// * 重新连接Modbus
// */
// public void ReconnectModbus()
// {
// try {
//
// ThreadManager.Get().StartLong("PLC断线重连线程", true, new IThread() {
// @Override
// public void Run() throws InterruptedException {
// try {
// boolean status =ping2(ConfigName.getInstance().Address,1,1);
// if(status)
// {
// ModbusMaster master= ModbusTcpHelper.get().getModbusMaster();
// if (master==null || master.isConnected() == false) {
// ConnectPLC();
// }
// Thread.sleep(20000);
// }
// } catch (Exception e) {
// Log.i("PLC", "PLC重连接失败!"+e.getMessage());
// }
// }
// @Override
// public void RunComplete() throws InterruptedException {
// }
// });
// }catch (Exception e) {
// MessageLog.ShowInfo("重新连接Modbus异常," +e.getMessage());
// }
// }

private Float BytesToFloat(byte[] buffers, DataFormat df) {
if (buffers.length == 4) {


+ 25
- 0
app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigation2Activity.java View File

@@ -10,6 +10,7 @@ import com.bonait.bnframework.common.constant.DataBus;
import com.bonait.bnframework.common.helper.I.IThread;
import com.bonait.bnframework.common.helper.MessageLog;
import com.bonait.bnframework.common.helper.ThreadManager;
import com.bonait.bnframework.common.modbus.ModbusTcpMainServer;
import com.bonait.bnframework.common.modbus.ModbusTcpServer;
import com.bonait.bnframework.common.utils.NetworkUtils;
import com.google.android.material.bottomnavigation.BottomNavigationView;
@@ -204,6 +205,28 @@ public class BottomNavigation2Activity extends BaseActivity {
ConfigName.getInstance().PlcIsConnect = false;
}
}

if(ConfigName.getInstance().versionSelectionEnum.contains("一拖"))
{
if (ConfigName.getInstance().PlcMainIsConnect) {
//ping 不通
boolean status = ModbusTcpMainServer.ping2(ConfigName.getInstance().MainAddress, 1, 1);
if (!status) //ping 不通 连接
{
MessageLog.ShowInfo("主控PLC状态断开,尝试连接...");
ConfigName.getInstance().PlcMainIsConnect = false;
}
} else {
boolean status = ModbusTcpMainServer.ping2(ConfigName.getInstance().MainAddress, 1, 1);
if (status) {
MessageLog.ShowInfo("设备 " + ConfigName.getInstance().MainAddress + " 主控PLC通讯正常,准备连接!");
ModbusTcpMainServer.ConnectPLC();
} else {
MessageLog.ShowInfo("主控PLC状态断开,尝试连接...");
ConfigName.getInstance().PlcMainIsConnect = false;
}
}
}
Thread.sleep(10000);
} catch (Exception e) {
Log.i("PLC", "PLC重连接失败!" + e.getMessage());
@@ -214,6 +237,8 @@ public class BottomNavigation2Activity extends BaseActivity {
public void RunComplete() throws InterruptedException {
}
});


} catch (Exception e) {
MessageLog.ShowInfo("重新连接Modbus异常," + e.getMessage());
}


+ 73
- 25
app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigationNewActivity.java View File

@@ -28,6 +28,7 @@ import com.bonait.bnframework.common.helper.MessageLog;
import com.bonait.bnframework.common.helper.ThreadManager;
import com.bonait.bnframework.common.message.MessageLooper;
import com.bonait.bnframework.common.message.MessageManager;
import com.bonait.bnframework.common.modbus.ModbusTcpMainServer;
import com.bonait.bnframework.common.modbus.ModbusTcpServer;
import com.bonait.bnframework.common.utils.NetworkUtils;
import com.bonait.bnframework.common.utils.ToastUtils;
@@ -100,12 +101,17 @@ public class BottomNavigationNewActivity extends BaseActivity {
};
viewPager.setCurrentItem(1);
}

@Override
protected void onDestroy() {
ConfigData.getInstance().ColsePLC();
IsRunThread=false;
if(makeThread!=null){makeThread=null;}
if(makeThreadDC!=null){makeThreadDC=null;}
IsRunThread = false;
if (makeThread != null) {
makeThread = null;
}
if (makeThreadDC != null) {
makeThreadDC = null;
}
super.onDestroy();
}

@@ -145,10 +151,34 @@ public class BottomNavigationNewActivity extends BaseActivity {
@Override
public void onMessage(Object msg) {
if (msg != null) {
String id = (String) msg;
goods = QueryDB.GetGoodsId(id);
cooking.initData(goods, activity, myClickListener);
cooking.setVisibility(View.VISIBLE);
runOnUiThread(new Runnable() {
@Override
public void run() {
String id = (String) msg;
goods = QueryDB.GetGoodsId(id);
cooking.initData(goods, activity, myClickListener);
cooking.setVisibility(View.VISIBLE);
}
});

}
}
});

//打开制作界面
MessageManager.getInstance().registerMessageReceiver(this, MessageName.IsStratMakeGood, new MessageLooper.OnMessageListener() {
@Override
public void onMessage(Object msg) {
if (msg != null) {
runOnUiThread(new Runnable() {
@Override
public void run() {
ExecuteTheRecipe.IsPause = false;
ExecuteTheRecipe.WritePLC("暂停开关", false, null);
onRecordStart();
}
});

}
}
});
@@ -249,7 +279,6 @@ public class BottomNavigationNewActivity extends BaseActivity {
*/
public void ReconnectModbus() {
try {

ThreadManager.Get().StartLong("PLC断线重连线程", true, new IThread() {
@Override
public void Run() throws InterruptedException {
@@ -272,6 +301,27 @@ public class BottomNavigationNewActivity extends BaseActivity {
ConfigName.getInstance().PlcIsConnect = false;
}
}

if (ConfigName.getInstance().versionSelectionEnum.contains("一拖")) {
if (ConfigName.getInstance().PlcMainIsConnect) {
//ping 不通
boolean status = ModbusTcpMainServer.ping2(ConfigName.getInstance().MainAddress, 1, 1);
if (!status) //ping 不通 连接
{
MessageLog.ShowInfo("主控PLC状态断开,尝试连接...");
ConfigName.getInstance().PlcMainIsConnect = false;
}
} else {
boolean status = ModbusTcpMainServer.ping2(ConfigName.getInstance().MainAddress, 1, 1);
if (status) {
MessageLog.ShowInfo("设备 " + ConfigName.getInstance().MainAddress + " 主控PLC通讯正常,准备连接!");
ModbusTcpMainServer.ConnectPLC();
} else {
MessageLog.ShowInfo("主控PLC状态断开,尝试连接...");
ConfigName.getInstance().PlcMainIsConnect = false;
}
}
}
Thread.sleep(10000);
} catch (Exception e) {
Log.i("PLC", "PLC重连接失败!" + e.getMessage());
@@ -296,22 +346,22 @@ public class BottomNavigationNewActivity extends BaseActivity {
public BPA_GOODS goods = null;


public Thread makeThread=null;
public Thread makeThreadDC=null;
public boolean IsRunThread=true;
public Thread makeThread = null;
public Thread makeThreadDC = null;
public boolean IsRunThread = true;

/**
* 商品制作线程
*/
public void MakeThread() {
ExecuteTheRecipe.context = this;
makeThread=new Thread(new Runnable() {
makeThread = new Thread(new Runnable() {
@Override
public void run() {
while (IsRunThread) {
try {
if (ExecuteTheRecipe.IsStart && goods != null) {
long startTime= System.currentTimeMillis(); //起始时间
long startTime = System.currentTimeMillis(); //起始时间
try {
//获取工艺
ArrayList<BPA_GOODSRECIPE> goodsrecipes = QueryDB.GetGoodsSrecipeID(goods.id);
@@ -319,8 +369,7 @@ public class BottomNavigationNewActivity extends BaseActivity {
gongxuIndex = 1;
int m = 0;
for (BPA_GOODSRECIPE item : goodsrecipes) {
while (ExecuteTheRecipe.IsPause)
{
while (ExecuteTheRecipe.IsPause) {
ToastUtils.info("客官,当前菜品已暂停炒制!!!");
Thread.sleep(1000);
}
@@ -348,12 +397,14 @@ public class BottomNavigationNewActivity extends BaseActivity {
ExecuteTheRecipe.IsStart = false;

long endTime = System.currentTimeMillis(); //结束时间
int time=(int) ((endTime-startTime)/1000);
Log.e("运行时长",String.format("方法使用时间 %d s",time));
int time = (int) ((endTime - startTime) / 1000);
Log.e("运行时长", String.format("方法使用时间 %d s", time));

if (!ExecuteTheRecipe.IsForcedEnd){QueryDB.UpdateGoodsMakeTime(goods.id,time);}
if (!ExecuteTheRecipe.IsForcedEnd) {
QueryDB.UpdateGoodsMakeTime(goods.id, time);
}

ExecuteTheRecipe.all_list=new ArrayList<>();
ExecuteTheRecipe.all_list = new ArrayList<>();
runOnUiThread(new Runnable() {
@Override
public void run() {
@@ -377,7 +428,7 @@ public class BottomNavigationNewActivity extends BaseActivity {
});
makeThread.start();

makeThreadDC=new Thread(new Runnable() {
makeThreadDC = new Thread(new Runnable() {
@Override
public void run() {
while (IsRunThread) {
@@ -490,17 +541,14 @@ public class BottomNavigationNewActivity extends BaseActivity {
switch (v.getId()) {
case R.id.start_goodmake://启动按钮
ExecuteTheRecipe.IsPause = false;
ExecuteTheRecipe.WritePLC("暂停开关",false,null);
ExecuteTheRecipe.WritePLC("暂停开关", false, null);
if (Status) {
onRecordStart();
}
// else {
// onRecordStop();
// }
break;
case R.id.zanting_goodmake://暂停按钮
ExecuteTheRecipe.IsPause = Status;
ExecuteTheRecipe.WritePLC("暂停开关",Status,null);
ExecuteTheRecipe.WritePLC("暂停开关", Status, null);
if (Status) {
onRecordPause();
} else {


+ 34
- 7
app/src/main/java/com/bonait/bnframework/modules/home/fragment/Home1Fragment.java View File

@@ -35,6 +35,7 @@ import com.bonait.bnframework.business.ExecuteTheRecipe;
import com.bonait.bnframework.common.base.BaseFragment;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.constant.DataBus;
import com.bonait.bnframework.common.constant.MessageName;
import com.bonait.bnframework.common.db.QueryDB;
import com.bonait.bnframework.common.db.mode.BPA_GOODS;
import com.bonait.bnframework.common.db.mode.BPA_GOODSRECIPE;
@@ -46,6 +47,8 @@ import com.bonait.bnframework.common.helper.I.MyClickListener;
import com.bonait.bnframework.common.helper.Json;
import com.bonait.bnframework.common.helper.MessageLog;
import com.bonait.bnframework.common.helper.ThreadManager;
import com.bonait.bnframework.common.message.MessageLooper;
import com.bonait.bnframework.common.message.MessageManager;
import com.bonait.bnframework.common.modbus.ModbusTcpServer;
import com.bonait.bnframework.common.utils.AlertDialogUtils;
import com.bonait.bnframework.common.utils.ToastUtils;
@@ -153,6 +156,7 @@ public class Home1Fragment extends BaseFragment {
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
context = getContext();

initTopBar();
initData();
HuoLiClicked();
@@ -232,13 +236,20 @@ public class Home1Fragment extends BaseFragment {
DataBus.getInstance().mListener = new MyClickListener() {
@Override
public void clickListener(View v, Object data) {
if (!IsMake(true)) {
return;
}
good = (BPA_GOODS) data;
SetBottonStatus(false);
caipumingcheng.setText(good.name);
SetProcesssUI(good.maketime, 0);

getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
if (!IsMake(true)) {
return;
}
good = (BPA_GOODS) data;
SetBottonStatus(false);
caipumingcheng.setText(good.name);
SetProcesssUI(good.maketime, 0);
}
});

}

@Override
@@ -523,6 +534,22 @@ public class Home1Fragment extends BaseFragment {
}
});


MessageManager.getInstance().registerMessageReceiver(getActivity(), MessageName.IsStratMakeGood1, new MessageLooper.OnMessageListener() {
@Override
public void onMessage(Object msg) {
if (msg != null) {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
ExecuteTheRecipe.StopForcedEnd();
SetBottonStatus(true);
}
});

}
}
});
}

int gongxuIndex = 10000;


+ 1
- 1
app/src/main/java/com/bonait/bnframework/modules/home/fragment/HomeFragmentSBKZ.java View File

@@ -305,7 +305,7 @@ public class HomeFragmentSBKZ extends BaseFragment {
SetStirFrySpeed(SpeedEnum.停, false);
RefreshLiquidSilo();

if (ConfigName.getInstance().versionSelectionEnum.equals("大炒版本")) {
if (ConfigName.getInstance().versionSelectionEnum.equals("大炒版本") || ConfigName.getInstance().versionSelectionEnum.contains("一拖")) {
touliao_k.setVisibility(View.GONE);
touliao_m.setVisibility(View.GONE);
device_image.setImageResource(R.mipmap.device00);


+ 1
- 1
app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/CookingActivity.java View File

@@ -183,7 +183,7 @@ public class CookingActivity extends LinearLayout {
SetMiaoShu("等待开始...");
runtime.setText(formatTime(goods.maketime));

if (ConfigName.getInstance().versionSelectionEnum.equals("大炒版本")) {
if (ConfigName.getInstance().versionSelectionEnum.equals("大炒版本") || ConfigName.getInstance().versionSelectionEnum.contains("一拖")) {
touliao_k.setVisibility(View.GONE);
touliao_m.setVisibility(View.GONE);
device_image.setImageResource(R.mipmap.device00);


+ 1
- 1
app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/CookingSimulatedActivity.java View File

@@ -147,7 +147,7 @@ public class CookingSimulatedActivity extends BaseActivity {
* 初始化数据
*/
public void initData() {
if (ConfigName.getInstance().versionSelectionEnum.equals("大炒版本")) {
if (ConfigName.getInstance().versionSelectionEnum.equals("大炒版本") || ConfigName.getInstance().versionSelectionEnum.contains("一拖")) {
touliao_k.setVisibility(View.GONE);
touliao_m.setVisibility(View.GONE);
device_image.setImageResource(R.mipmap.device00);


+ 1
- 1
app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DishTestActivity.java View File

@@ -267,7 +267,7 @@ public class DishTestActivity extends BaseActivity {
* 初始化显示数据
*/
private void initData() {
if (ConfigName.getInstance().versionSelectionEnum.equals("大炒版本")) {
if (ConfigName.getInstance().versionSelectionEnum.equals("大炒版本") || ConfigName.getInstance().versionSelectionEnum.contains("一拖")) {
touliao_k.setVisibility(View.GONE);
touliao_m.setVisibility(View.GONE);
device_image.setImageResource(R.mipmap.device00);


+ 8
- 1
app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/WhActivity.java View File

@@ -6,6 +6,7 @@ import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.utils.ToastUtils;
import com.bonait.bnframework.modules.home.fragment.from.fragment.SystemCsPLCFragment;
import com.bonait.bnframework.modules.home.fragment.from.fragment.WokSetGKCXFragment;
import com.bonait.bnframework.modules.home.fragment.from.fragment.WokSetTLZZ1Fragment;
import com.bonait.bnframework.modules.home.fragment.from.fragment.WokSetTLZZFragment;
import com.google.android.material.bottomnavigation.BottomNavigationView;

@@ -102,7 +103,13 @@ public class WhActivity extends BaseActivity {
private void initFragment() {
fragmentAdapter = new FragmentAdapter(getSupportFragmentManager());
fragmentAdapter.addFragment(new WokSetGKCXFragment());
fragmentAdapter.addFragment(new WokSetTLZZFragment());
if (ConfigName.getInstance().versionSelectionEnum.contains("一拖"))
{
fragmentAdapter.addFragment(new WokSetTLZZ1Fragment());
}else
{
fragmentAdapter.addFragment(new WokSetTLZZFragment());
}
fragmentAdapter.addFragment(new SystemCsMonitorFragment());
fragmentAdapter.addFragment(new SystemCsFltlFragment());
viewPager.setAdapter(fragmentAdapter);


+ 45
- 0
app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/SystemSystemsetFragment.java View File

@@ -43,6 +43,13 @@ public class SystemSystemsetFragment extends BaseFragment {
EditText edittext3;
@BindView(R.id.edittext4)
EditText edittext4;

@BindView(R.id.edittext100)
EditText edittext100;
@BindView(R.id.edittext101)
EditText edittext101;
@BindView(R.id.edittext102)
EditText edittext102;
@BindView(R.id.environment)
Spinner environment;

@@ -133,6 +140,18 @@ public class SystemSystemsetFragment extends BaseFragment {
bpa_systemsets = QueryDB.GetSystemsetALL();
for (BPA_SYSTEMSET item : bpa_systemsets) {
switch (item.type) {
case -200:
ConfigName.getInstance().MainAddress = item.value;
edittext100.setText(item.value);
break;
case -201:
ConfigName.getInstance().MainPost = Integer.parseInt(item.value);
edittext101.setText(item.value);
break;
case -202:
ConfigName.getInstance().DeviceHao = Integer.parseInt(item.value);
edittext102.setText(item.value);
break;
case -100:
ConfigName.getInstance().versionSelectionEnum = item.value;
versionselection.setSelection(material_map_vis.get(item.value));
@@ -192,6 +211,10 @@ public class SystemSystemsetFragment extends BaseFragment {
case R.id.StartButton://保存按钮
ConfigName.getInstance().Address = edittext1.getText().toString();
ConfigName.getInstance().Post = Integer.parseInt(edittext2.getText().toString());
ConfigName.getInstance().MainAddress = edittext100.getText().toString();
ConfigName.getInstance().MainPost = Integer.parseInt(edittext101.getText().toString());
ConfigName.getInstance().DeviceHao = Integer.parseInt(edittext102.getText().toString());

ConfigName.getInstance().ClientAutoKey = edittext3.getText().toString();
ConfigName.getInstance().DeviceAutoKey = edittext4.getText().toString();

@@ -228,6 +251,28 @@ public class SystemSystemsetFragment extends BaseFragment {
set_vis.deviceID = ConfigName.getInstance().DeviceId;
set_vis.userID = ConfigName.getInstance().user.userID;
QueryDB.AddSystemset(set_vis);

BPA_SYSTEMSET set_main1 = new BPA_SYSTEMSET();
set_main1.type = -200;
set_main1.value = edittext100.getText().toString();
set_main1.deviceID = ConfigName.getInstance().DeviceId;
set_main1.userID = ConfigName.getInstance().user.userID;
QueryDB.AddSystemset(set_main1);

BPA_SYSTEMSET set_main2 = new BPA_SYSTEMSET();
set_main2.type = -201;
set_main2.value =edittext101.getText().toString();
set_main2.deviceID = ConfigName.getInstance().DeviceId;
set_main2.userID = ConfigName.getInstance().user.userID;
QueryDB.AddSystemset(set_main2);

BPA_SYSTEMSET set_main3 = new BPA_SYSTEMSET();
set_main3.type = -202;
set_main3.value =edittext102.getText().toString();
set_main3.deviceID = ConfigName.getInstance().DeviceId;
set_main3.userID = ConfigName.getInstance().user.userID;
QueryDB.AddSystemset(set_main3);

if (isgb) {
ConfigData.getInstance().RevertPLCProcess();
}


+ 437
- 0
app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/WokSetTLZZ1Fragment.java View File

@@ -0,0 +1,437 @@
package com.bonait.bnframework.modules.home.fragment.from.fragment;

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

import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.TextView;

import com.bonait.bnframework.R;
import com.bonait.bnframework.business.ExecuteTheRecipe;
import com.bonait.bnframework.common.base.BaseFragment;
import com.bonait.bnframework.common.utils.ToastUtils;
import com.orhanobut.logger.Logger;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;

public class WokSetTLZZ1Fragment extends BaseFragment {

//region 变量
@BindView(R.id.pyz_zz)
Button pyz_zz;

@BindView(R.id.pyz_fz)
Button pyz_fz;

@BindView(R.id.fzz_zz)
Button fzz_zz;

@BindView(R.id.fzz_fz)
Button fzz_fz;


@BindView(R.id.edit_pyz_hlsd)
EditText edit_pyz_hlsd;

@BindView(R.id.edit_pyz_ddsd)
EditText edit_pyz_ddsd;

@BindView(R.id.edit_pyz_zdsd)
EditText edit_pyz_zdsd;

@BindView(R.id.edit_fzz_hlsd)
EditText edit_fzz_hlsd;

@BindView(R.id.edit_fzz_ddsd)
EditText edit_fzz_ddsd;

@BindView(R.id.edit_fzz_zdsd)
EditText edit_fzz_zdsd;

@BindView(R.id.edit_pyz_dqz)
TextView edit_pyz_dqz;
@BindView(R.id.edit_pyz_wz1)
TextView edit_pyz_wz1;
@BindView(R.id.edit_pyz_wz2)
TextView edit_pyz_wz2;
@BindView(R.id.edit_pyz_wz3)
TextView edit_pyz_wz3;
@BindView(R.id.edit_pyz_wz4)
TextView edit_pyz_wz4;

@BindView(R.id.edit_fzz_dqz)
TextView edit_fzz_dqz;
@BindView(R.id.edit_fzz_wz1)
TextView edit_fzz_wz1;
@BindView(R.id.edit_fzz_wz2)
TextView edit_fzz_wz2;
@BindView(R.id.edit_fzz_wz3)
TextView edit_fzz_wz3;
@BindView(R.id.edit_fzz_wz4)
TextView edit_fzz_wz4;
//endregion

//region 界面
private Context context;

@Override
protected View onCreateView() {
View root = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_wok_set_tlzz1, null);
ButterKnife.bind(this, root);
return root;
}

@Override
public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) {
super.onViewCreated(view, savedInstanceState);
Logger.d("我的fragment创建");
context = getContext();
Init();
RefreshThread();
}
//endregion

//region 公共

/**
* 初始化
*/
public void Init() {
new Thread(new Runnable() {
@Override
public void run() {
getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
SetShowValue("翻转1-回原点速度", edit_pyz_hlsd);
SetShowValue("翻转1-点动速度", edit_pyz_ddsd);
SetShowValue("翻转1-定位运行速度", edit_pyz_zdsd);

SetShowValue("翻转2-回原点速度", edit_fzz_hlsd);
SetShowValue("翻转2-点动速度", edit_fzz_ddsd);
SetShowValue("翻转2-定位运行速度", edit_fzz_zdsd);
}
});
}
}).start();

pyz_zz.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
Log.e("鼠标", "按下: ");
ExecuteTheRecipe.WritePLC("翻转1-点动正转", true, null);
} else if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
Log.e("鼠标", "松开: ");
ExecuteTheRecipe.WritePLC("翻转1-点动正转", false, null);
}
return false;
}
});

pyz_fz.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
Log.e("鼠标", "按下: ");
ExecuteTheRecipe.WritePLC("翻转1-点动反转", true, null);
} else if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
Log.e("鼠标", "松开: ");
ExecuteTheRecipe.WritePLC("翻转1-点动反转", false, null);
}
return false;
}
});

fzz_zz.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
Log.e("鼠标", "按下: ");
ExecuteTheRecipe.WritePLC("翻转2-点动正转", true, null);
} else if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
Log.e("鼠标", "松开: ");
ExecuteTheRecipe.WritePLC("翻转2-点动正转", false, null);
}
return false;
}
});

fzz_fz.setOnTouchListener(new View.OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
Log.e("鼠标", "按下: ");
ExecuteTheRecipe.WritePLC("翻转2-点动反转", true, null);
} else if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
Log.e("鼠标", "松开: ");
ExecuteTheRecipe.WritePLC("翻转2-点动反转", false, null);
}
return false;
}
});
}

/**
* 刷新UI线程
*/
public void RefreshThread() {
new Thread(new Runnable() {
@Override
public void run() {
try {
while (true) {
Object o0 = ExecuteTheRecipe.ReadPLC("翻转1-伺服当前值");
Object o1 = ExecuteTheRecipe.ReadPLC("翻转1-1号位置值");
Object o2 = ExecuteTheRecipe.ReadPLC("翻转1-2号位置值");
Object o3 = ExecuteTheRecipe.ReadPLC("翻转1-3号位置值");
Object o4 = ExecuteTheRecipe.ReadPLC("翻转1-4号位置值");

Object m0 = ExecuteTheRecipe.ReadPLC("翻转2-伺服当前值");
Object m1 = ExecuteTheRecipe.ReadPLC("翻转2-1号位置值");
Object m2 = ExecuteTheRecipe.ReadPLC("翻转2-2号位置值");
Object m3 = ExecuteTheRecipe.ReadPLC("翻转2-3号位置值");
Object m4 = ExecuteTheRecipe.ReadPLC("翻转2-4号位置值");

getActivity().runOnUiThread(new Runnable() {
@Override
public void run() {
if (o0 != null) {
edit_pyz_dqz.setText(o0 + "");
} else {
edit_pyz_dqz.setText("未知");
}
if (o1 != null) {
edit_pyz_wz1.setText(o1 + "");
} else {
edit_pyz_wz1.setText("未知");
}
if (o2 != null) {
edit_pyz_wz2.setText(o2 + "");
} else {
edit_pyz_wz2.setText("未知");
}
if (o3 != null) {
edit_pyz_wz3.setText(o3 + "");
} else {
edit_pyz_wz3.setText("未知");
}
if (o4 != null) {
edit_pyz_wz4.setText(o4 + "");
} else {
edit_pyz_wz4.setText("未知");
}

if (m0 != null) {
edit_fzz_dqz.setText(m0 + "");
} else {
edit_fzz_dqz.setText("未知");
}
if (m1 != null) {
edit_fzz_wz1.setText(m1 + "");
} else {
edit_fzz_wz1.setText("未知");
}
if (m2 != null) {
edit_fzz_wz2.setText(m2 + "");
} else {
edit_fzz_wz2.setText("未知");
}
if (m3 != null) {
edit_fzz_wz3.setText(m3 + "");
} else {
edit_fzz_wz3.setText("未知");
}
if (m4 != null) {
edit_fzz_wz4.setText(m4 + "");
} else {
edit_fzz_wz4.setText("未知");
}
}
});
Thread.sleep(500);
}
} catch (Exception ex) {
}
}
}).start();
}

/**
* 点击事件
*
* @param view
*/
@OnClick({
R.id.pyz_hl,
R.id.pyz_wzsz1, R.id.pyz_wzsz2, R.id.pyz_wzsz3, R.id.pyz_wzsz4,
R.id.pyz_qu1, R.id.pyz_qu2, R.id.pyz_qu3, R.id.pyz_qu4,

R.id.fzz_hl,
R.id.fzz_wzsz1, R.id.fzz_wzsz2, R.id.fzz_wzsz3, R.id.fzz_wzsz4,
R.id.fzz_qu1, R.id.fzz_qu2, R.id.fzz_qu3, R.id.fzz_qu4,

R.id.dcqd_button1,R.id.dcqd_button2,

R.id.pyz_savevalue, R.id.fzz_savevalue
})
public void onViewClicked(View view) {
switch (view.getId()) {
case R.id.pyz_hl:
ButtomZhiWeiZhi("翻转1-回原点");
break;
case R.id.pyz_wzsz1:
ButtomZhiWeiZhi("翻转1-1#位置设定");
break;
case R.id.pyz_wzsz2:
ButtomZhiWeiZhi("翻转1-2#位置设定");
break;
case R.id.pyz_wzsz3:
ButtomZhiWeiZhi("翻转1-3#位置设定");
break;
case R.id.pyz_wzsz4:
ButtomZhiWeiZhi("翻转1-4#位置设定");
break;
case R.id.pyz_qu1:
ButtomZhiWeiZhi("翻转1-去1号位");
break;
case R.id.pyz_qu2:
ButtomZhiWeiZhi("翻转1-去2号位");
break;
case R.id.pyz_qu3:
ButtomZhiWeiZhi("翻转1-去3号位");
break;
case R.id.pyz_qu4:
ButtomZhiWeiZhi("翻转1-去4号位");
break;

case R.id.fzz_hl:
ButtomZhiWeiZhi("翻转2-回原点");
break;
case R.id.fzz_wzsz1:
ButtomZhiWeiZhi("翻转2-1#位置设定");
break;
case R.id.fzz_wzsz2:
ButtomZhiWeiZhi("翻转2-2#位置设定");
break;
case R.id.fzz_wzsz3:
ButtomZhiWeiZhi("翻转2-3#位置设定");
break;
case R.id.fzz_wzsz4:
ButtomZhiWeiZhi("翻转2-4#位置设定");
break;
case R.id.fzz_qu1:
ButtomZhiWeiZhi("翻转2-去1号位");
break;
case R.id.fzz_qu2:
ButtomZhiWeiZhi("翻转2-去2号位");
break;
case R.id.fzz_qu3:
ButtomZhiWeiZhi("翻转2-去3号位");
break;
case R.id.fzz_qu4:
ButtomZhiWeiZhi("翻转2-去4号位");
break;
case R.id.dcqd_button1:
ButtomZhiWeiZhi("主料1号位");
break;
case R.id.dcqd_button2:
ButtomZhiWeiZhi("主料2号位");
break;

case R.id.pyz_savevalue:
SaveValue("翻转1", edit_pyz_hlsd, edit_pyz_ddsd, edit_pyz_zdsd);
break;
case R.id.fzz_savevalue:
SaveValue("翻转2", edit_fzz_hlsd, edit_fzz_ddsd, edit_fzz_zdsd);
break;
}
}
//endregion

//region 私有

/**
* 写入设置值
*
* @param name
* @param edit1
* @param edit2
*/
private void SaveValue(String name, EditText edit1, EditText edit2, EditText edit3) {
String val1 = edit1.getText().toString();
String val2 = edit2.getText().toString();
String val3 = edit3.getText().toString();

if (val1.isEmpty()) {
ToastUtils.warning(name + "回零速度不能为空!");
return;
}
if (val2.isEmpty()) {
ToastUtils.warning(name + "点动速度不能为空!");
return;
}
if (val3.isEmpty()) {
ToastUtils.warning(name + "自动速度不能为空!");
return;
}
int va1 = 0;
int va2 = 0;
int va3 = 0;

try {
va1 = Integer.parseInt(val1);
va2 = Integer.parseInt(val2);
va3 = Integer.parseInt(val3);

} catch (Exception ex) {
ToastUtils.warning(name + "异常了," + ex.getMessage());
return;
}

ExecuteTheRecipe.WritePLC(name + "-回原点速度", va1, null);
ExecuteTheRecipe.WritePLC(name + "-点动速度", va2, null);
ExecuteTheRecipe.WritePLC(name + "-定位运行速度", va3, null);
ToastUtils.info(name + "保存成功!");
}

/**
* 根据监听设置值
*
* @param name
* @param edit1
*/
private void SetShowValue(String name, EditText edit1) {
Object val1 = ExecuteTheRecipe.ListeningValue.get(name);
if (val1 != null) {
String str = String.valueOf(val1);
edit1.setText(str.toCharArray(), 0, str.length());
}
}

/**
* 执行去某个位置
*/
private void ButtomZhiWeiZhi(String name) {
ExecuteTheRecipe.WritePLC(name, true, null);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
ExecuteTheRecipe.WritePLC(name, false, null);
}
}, 500);
ToastUtils.info(name + "执行成功!");
}
//endregion
}

+ 3
- 15
app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/WokSetTLZZFragment.java View File

@@ -81,9 +81,6 @@ public class WokSetTLZZFragment extends BaseFragment {
TextView edit_fzz_wz3;
@BindView(R.id.edit_fzz_wz4)
TextView edit_fzz_wz4;

@BindView(R.id.ctxh_button)
SwitchButton ctxh_button;
//endregion

//region 界面
@@ -149,7 +146,7 @@ public class WokSetTLZZFragment extends BaseFragment {
public boolean onTouch(View view, MotionEvent motionEvent) {
if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
Log.e("鼠标", "按下: ");
ExecuteTheRecipe.WritePLC("平移-点动转", true, null);
ExecuteTheRecipe.WritePLC("平移-点动转", true, null);
} else if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
Log.e("鼠标", "松开: ");
ExecuteTheRecipe.WritePLC("平移-点动反转", false, null);
@@ -177,7 +174,7 @@ public class WokSetTLZZFragment extends BaseFragment {
public boolean onTouch(View view, MotionEvent motionEvent) {
if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
Log.e("鼠标", "按下: ");
ExecuteTheRecipe.WritePLC("翻转-点动转", true, null);
ExecuteTheRecipe.WritePLC("翻转-点动转", true, null);
} else if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
Log.e("鼠标", "松开: ");
ExecuteTheRecipe.WritePLC("翻转-点动反转", false, null);
@@ -185,15 +182,6 @@ public class WokSetTLZZFragment extends BaseFragment {
return false;
}
});

ctxh_button.setOnCheckedChangeListener(new SwitchButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(SwitchButton view, boolean isChecked) {
boolean ischick = ctxh_button.isChecked();
ExecuteTheRecipe.WritePLC("磁铁吸合", ischick, null);
ToastUtils.info("磁铁吸合!状态:" + (ischick ? "打开" : "关闭"));
}
});
}

/**
@@ -357,7 +345,7 @@ public class WokSetTLZZFragment extends BaseFragment {
ButtomZhiWeiZhi("翻转-去4号位");
break;
case R.id.dcqd_button:
ButtomZhiWeiZhi("倒菜启动");
ButtomZhiWeiZhi("主料");
break;

case R.id.pyz_savevalue:


+ 11
- 11
app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_qupenren.java View File

@@ -146,17 +146,17 @@ public class add_qupenren extends LinearLayout {
quzhizuo.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View view) {
if (!ConfigName.getInstance().PlcIsConnect) {
ToastUtils.warning("PLC未准备就绪!!!");
return;
}
Object chushiover = ExecuteTheRecipe.getListingValue("初始化完成");
//Object jiting = ExecuteTheRecipe.getListingValue("设备急停");
if (chushiover == null || !(boolean) chushiover) {
ToastUtils.warning("设备未初始化,请先手动初始化设备!!!");
return;
}
// if (!ConfigName.getInstance().PlcIsConnect) {
// ToastUtils.warning("PLC未准备就绪!!!");
// return;
// }
//
// Object chushiover = ExecuteTheRecipe.getListingValue("初始化完成");
// //Object jiting = ExecuteTheRecipe.getListingValue("设备急停");
// if (chushiover == null || !(boolean) chushiover) {
// ToastUtils.warning("设备未初始化,请先手动初始化设备!!!");
// return;
// }
if (mListener != null) {
mListener.clickListenerNew(view, 5, mode);
}


+ 71
- 0
app/src/main/res/layout/fragment_system_systemset.xml View File

@@ -42,6 +42,7 @@
android:padding="3dp"
android:textSize="12dp" />


<com.qmuiteam.qmui.widget.textview.QMUILinkTextView
android:layout_marginLeft="@dimen/dp_10"
android:layout_width="wrap_content"
@@ -171,6 +172,76 @@
android:textSize="12dp"
android:text="0"/>
</TableRow>


<!-- Table11-->
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="5dp">
<com.qmuiteam.qmui.widget.textview.QMUILinkTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:text="主控连接地址:" />
<EditText
android:id="@+id/edittext100"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:background="@drawable/input_bj"
android:hint="请输入地址"
android:inputType="text"
android:maxLines="1"
android:padding="3dp"
android:textSize="12dp" />


<com.qmuiteam.qmui.widget.textview.QMUILinkTextView
android:layout_marginLeft="@dimen/dp_10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:text="主控连接端口:" />
<EditText
android:id="@+id/edittext101"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:background="@drawable/input_bj"
android:hint="请输入端口"
android:inputType="number"
android:maxLines="1"
android:padding="3dp"
android:textSize="12dp"
android:text="0"/>
</TableRow>

<!-- Table11-->
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="5dp">
<com.qmuiteam.qmui.widget.textview.QMUILinkTextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="right"
android:text="设备序号:" />
<EditText
android:id="@+id/edittext102"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:background="@drawable/input_bj"
android:hint="请输入序号"
android:inputType="number"
android:maxLines="1"
android:padding="3dp"
android:textSize="12dp"
android:text="1"/>
</TableRow>
</TableLayout>




+ 1
- 12
app/src/main/res/layout/fragment_wok_set_tlzz.xml View File

@@ -858,18 +858,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="磁铁吸合"/>
<com.suke.widget.SwitchButton
android:id="@+id/ctxh_button"
app:sb_uncheck_color="@color/app_color_blue"
app:sb_uncheckcircle_color="@color/app_color_blue"
app:sb_button_color="@color/app_color_blue"
android:layout_width="80dp"
android:layout_height="wrap_content"
android:focusable="true"/>

</LinearLayout>

<Button


+ 889
- 0
app/src/main/res/layout/fragment_wok_set_tlzz1.xml View File

@@ -0,0 +1,889 @@
<?xml version="1.0" encoding="utf-8"?>
<com.qmuiteam.qmui.widget.QMUIWindowInsetLayout 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"
tools:context=".modules.home.fragment.from.fragment.WokSetTLZZ1Fragment">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginLeft="10dp"
android:layout_marginRight="10dp"
android:orientation="vertical">

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10">

<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/dp_10"
android:minWidth="60dp"
android:text="翻转轴1"
android:textAlignment="center"
android:textSize="19dp" />
</LinearLayout>

<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_weight="1">

<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/dp_10"
android:minWidth="60dp"
android:text="翻转轴2"
android:textAlignment="center"
android:textSize="19dp" />
</LinearLayout>
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10">

<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">

<Button
android:id="@+id/pyz_hl"
android:layout_width="80dp"
android:layout_height="26dp"
android:layout_centerInParent="true"
android:layout_marginRight="@dimen/dp_10"
android:background="@drawable/bg_btn_login_selected"
android:text="回零"
android:textSize="14dp" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/dp_10"
android:minWidth="60dp"
android:text="当前值" />
<TextView
android:id="@+id/edit_pyz_dqz"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="0"
android:textColor="@color/deep_orange_primary"
android:textSize="12dp"
android:textStyle="bold" />
</LinearLayout>

<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_weight="1">

<Button
android:id="@+id/fzz_hl"
android:layout_width="80dp"
android:layout_height="26dp"
android:layout_centerInParent="true"
android:layout_marginRight="@dimen/dp_10"
android:background="@drawable/bg_btn_login_selected"
android:text="回零"
android:textSize="14dp" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/dp_10"
android:minWidth="60dp"
android:text="当前值" />
<TextView
android:id="@+id/edit_fzz_dqz"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="0"
android:textColor="@color/deep_orange_primary"
android:textSize="12dp"
android:textStyle="bold" />

</LinearLayout>
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10">

<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">

<Button
android:id="@+id/pyz_zz"
android:layout_width="80dp"
android:layout_height="26dp"
android:layout_centerInParent="true"
android:layout_marginRight="@dimen/dp_10"
android:background="@drawable/button1"
android:text="正转"
android:textSize="14dp" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/dp_10"
android:minWidth="60dp"
android:text="回零速度" />

<EditText
android:id="@+id/edit_pyz_hlsd"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_weight="1"
android:background="@drawable/input_bj"
android:hint="请输入速度"
android:inputType="number"
android:maxLines="1"
android:padding="3dp"
android:text="0"
android:textSize="12dp" />
</LinearLayout>

<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_weight="1">

<Button
android:id="@+id/fzz_zz"
android:layout_width="80dp"
android:layout_height="26dp"
android:layout_centerInParent="true"
android:layout_marginRight="@dimen/dp_10"
android:background="@drawable/button1"
android:text="正转"
android:textSize="14dp" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/dp_10"
android:minWidth="60dp"
android:text="回零速度" />

<EditText
android:id="@+id/edit_fzz_hlsd"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_weight="1"
android:background="@drawable/input_bj"
android:hint="请输入速度"
android:inputType="number"
android:maxLines="1"
android:padding="3dp"
android:text="0"
android:textSize="12dp" />
</LinearLayout>
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10">

<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">

<RelativeLayout
android:layout_width="90dp"
android:layout_height="wrap_content" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/dp_10"
android:minWidth="60dp"
android:text="点动速度" />

<EditText
android:id="@+id/edit_pyz_ddsd"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_weight="1"
android:background="@drawable/input_bj"
android:hint="请输入速度"
android:inputType="number"
android:maxLines="1"
android:padding="3dp"
android:text="0"
android:textSize="12dp" />
</LinearLayout>

<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_weight="1">

<RelativeLayout
android:layout_width="90dp"
android:layout_height="wrap_content" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/dp_10"
android:minWidth="60dp"
android:text="点动速度" />

<EditText
android:id="@+id/edit_fzz_ddsd"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_weight="1"
android:background="@drawable/input_bj"
android:hint="请输入速度"
android:inputType="number"
android:maxLines="1"
android:padding="3dp"
android:text="0"
android:textSize="12dp" />
</LinearLayout>
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10">

<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">

<Button
android:id="@+id/pyz_fz"
android:layout_width="80dp"
android:layout_height="26dp"
android:layout_centerInParent="true"
android:layout_marginRight="@dimen/dp_10"
android:background="@drawable/button1"
android:text="反转"
android:textSize="14dp" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/dp_10"
android:minWidth="60dp"
android:text="自动速度" />

<EditText
android:id="@+id/edit_pyz_zdsd"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_weight="1"
android:background="@drawable/input_bj"
android:hint="请输入速度"
android:inputType="number"
android:maxLines="1"
android:padding="3dp"
android:text="0"
android:textSize="12dp" />
</LinearLayout>

<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_weight="1">

<Button
android:id="@+id/fzz_fz"
android:layout_width="80dp"
android:layout_height="26dp"
android:layout_centerInParent="true"
android:layout_marginRight="@dimen/dp_10"
android:background="@drawable/button1"
android:text="反转"
android:textSize="14dp" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/dp_10"
android:minWidth="60dp"
android:text="自动速度" />

<EditText
android:id="@+id/edit_fzz_zdsd"
android:layout_width="120dp"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:layout_weight="1"
android:background="@drawable/input_bj"
android:hint="请输入速度"
android:inputType="number"
android:maxLines="1"
android:padding="3dp"
android:text="0"
android:textSize="12dp" />
</LinearLayout>
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10">

<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">

<Button
android:id="@+id/pyz_savevalue"
android:layout_width="80dp"
android:layout_height="26dp"
android:layout_alignParentRight="true"
android:layout_centerInParent="true"
android:layout_marginRight="@dimen/dp_10"
android:background="@drawable/bg_btn_login_selected"
android:text="保存速度值"
android:textSize="14dp" />
</RelativeLayout>
</LinearLayout>

<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_weight="1">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">

<Button
android:id="@+id/fzz_savevalue"
android:layout_width="80dp"
android:layout_height="26dp"
android:layout_alignParentRight="true"
android:layout_centerInParent="true"
android:layout_marginRight="@dimen/dp_10"
android:background="@drawable/bg_btn_login_selected"
android:text="保存速度值"
android:textSize="14dp" />
</RelativeLayout>
</LinearLayout>
</LinearLayout>




<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="30dp">

<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">

<Button
android:id="@+id/pyz_wzsz1"
android:layout_width="80dp"
android:layout_height="26dp"
android:layout_centerInParent="true"
android:layout_marginRight="@dimen/dp_10"
android:background="@drawable/button2"
android:text="1#位设定"
android:textSize="14dp" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/dp_10"
android:minWidth="60dp"
android:text="1#位值" />

<TextView
android:id="@+id/edit_pyz_wz1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="0"
android:textColor="@color/deep_orange_primary"
android:textSize="12dp"
android:textStyle="bold" />
</LinearLayout>

<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_weight="1">

<Button
android:id="@+id/fzz_wzsz1"
android:layout_width="80dp"
android:layout_height="26dp"
android:layout_centerInParent="true"
android:layout_marginRight="@dimen/dp_10"
android:background="@drawable/button2"
android:text="1#位设定"
android:textSize="14dp" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/dp_10"
android:minWidth="60dp"
android:text="1#位值" />
<TextView
android:id="@+id/edit_fzz_wz1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="0"
android:textColor="@color/deep_orange_primary"
android:textSize="12dp"
android:textStyle="bold" />

</LinearLayout>
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp">

<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">

<Button
android:id="@+id/pyz_wzsz2"
android:layout_width="80dp"
android:layout_height="26dp"
android:layout_centerInParent="true"
android:layout_marginRight="@dimen/dp_10"
android:background="@drawable/button2"
android:text="2#位设定"
android:textSize="14dp" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/dp_10"
android:minWidth="60dp"
android:text="2#位值" />
<TextView
android:id="@+id/edit_pyz_wz2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="0"
android:textColor="@color/deep_orange_primary"
android:textSize="12dp"
android:textStyle="bold" />
</LinearLayout>

<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_weight="1">

<Button
android:id="@+id/fzz_wzsz2"
android:layout_width="80dp"
android:layout_height="26dp"
android:layout_centerInParent="true"
android:layout_marginRight="@dimen/dp_10"
android:background="@drawable/button2"
android:text="2#位设定"
android:textSize="14dp" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/dp_10"
android:minWidth="60dp"
android:text="2#位值" />
<TextView
android:id="@+id/edit_fzz_wz2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="0"
android:textColor="@color/deep_orange_primary"
android:textSize="12dp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp">

<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">

<Button
android:id="@+id/pyz_wzsz3"
android:layout_width="80dp"
android:layout_height="26dp"
android:layout_centerInParent="true"
android:layout_marginRight="@dimen/dp_10"
android:background="@drawable/button2"
android:text="3#位设定"
android:textSize="14dp" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/dp_10"
android:minWidth="60dp"
android:text="3#位值" />
<TextView
android:id="@+id/edit_pyz_wz3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="0"
android:textColor="@color/deep_orange_primary"
android:textSize="12dp"
android:textStyle="bold" />
</LinearLayout>

<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_weight="1">

<Button
android:id="@+id/fzz_wzsz3"
android:layout_width="80dp"
android:layout_height="26dp"
android:layout_centerInParent="true"
android:layout_marginRight="@dimen/dp_10"
android:background="@drawable/button2"
android:text="3#位设定"
android:textSize="14dp" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/dp_10"
android:minWidth="60dp"
android:text="3#位值" />
<TextView
android:id="@+id/edit_fzz_wz3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="0"
android:textColor="@color/deep_orange_primary"
android:textSize="12dp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp">

<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">

<Button
android:id="@+id/pyz_wzsz4"
android:layout_width="80dp"
android:layout_height="26dp"
android:layout_centerInParent="true"
android:layout_marginRight="@dimen/dp_10"
android:background="@drawable/button2"
android:text="4#位设定"
android:textSize="14dp" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/dp_10"
android:minWidth="60dp"
android:text="4#位值" />
<TextView
android:id="@+id/edit_pyz_wz4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="0"
android:textColor="@color/deep_orange_primary"
android:textSize="12dp"
android:textStyle="bold" />
</LinearLayout>

<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_weight="1">

<Button
android:id="@+id/fzz_wzsz4"
android:layout_width="80dp"
android:layout_height="26dp"
android:layout_centerInParent="true"
android:layout_marginRight="@dimen/dp_10"
android:background="@drawable/button2"
android:text="4#位设定"
android:textSize="14dp" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_centerVertical="true"
android:layout_marginLeft="@dimen/dp_10"
android:minWidth="60dp"
android:text="4#位值" />
<TextView
android:id="@+id/edit_fzz_wz4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="5dp"
android:text="0"
android:textColor="@color/deep_orange_primary"
android:textSize="12dp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp">

<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">

<Button
android:id="@+id/pyz_qu1"
android:layout_width="120dp"
android:layout_height="40dp"
android:layout_marginRight="@dimen/dp_10"
android:background="@drawable/bg_btn_login_selected"
android:text="去1#位"
android:textSize="14dp" />

<Button
android:id="@+id/pyz_qu2"
android:layout_width="120dp"
android:layout_height="40dp"
android:layout_alignParentRight="true"
android:layout_marginRight="@dimen/dp_10"
android:background="@drawable/bg_btn_login_selected"
android:text="去2#位"
android:textSize="14dp" />
</RelativeLayout>

<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">

<Button
android:id="@+id/fzz_qu1"
android:layout_width="120dp"
android:layout_height="40dp"
android:layout_marginRight="@dimen/dp_10"
android:background="@drawable/bg_btn_login_selected"
android:text="去1#位"
android:textSize="14dp" />

<Button
android:id="@+id/fzz_qu2"
android:layout_width="120dp"
android:layout_height="40dp"
android:layout_alignParentRight="true"
android:layout_marginRight="@dimen/dp_10"
android:background="@drawable/bg_btn_login_selected"
android:text="去2#位"
android:textSize="14dp" />
</RelativeLayout>
</LinearLayout>

<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dp">

<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">

<Button
android:id="@+id/pyz_qu3"
android:layout_width="120dp"
android:layout_height="40dp"
android:layout_marginRight="@dimen/dp_10"
android:background="@drawable/bg_btn_login_selected"
android:text="去3#位"
android:textSize="14dp" />

<Button
android:id="@+id/pyz_qu4"
android:layout_width="120dp"
android:layout_height="40dp"
android:layout_alignParentRight="true"
android:layout_marginRight="@dimen/dp_10"
android:background="@drawable/bg_btn_login_selected"
android:text="去4#位"
android:textSize="14dp" />
</RelativeLayout>

<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">

<Button
android:id="@+id/fzz_qu3"
android:layout_width="120dp"
android:layout_height="40dp"
android:layout_marginRight="@dimen/dp_10"
android:background="@drawable/bg_btn_login_selected"
android:text="去3#位"
android:textSize="14dp" />

<Button
android:id="@+id/fzz_qu4"
android:layout_width="120dp"
android:layout_height="40dp"
android:layout_alignParentRight="true"
android:layout_marginRight="@dimen/dp_10"
android:background="@drawable/bg_btn_login_selected"
android:text="去4#位"
android:textSize="14dp" />
</RelativeLayout>
</LinearLayout>

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/dp_10">

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerInParent="true">

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">

</LinearLayout>
<Button
android:id="@+id/dcqd_button1"
android:layout_width="160dp"
android:layout_height="100dp"
android:layout_centerInParent="true"
android:layout_marginLeft="50dp"
android:layout_marginRight="@dimen/dp_10"
android:background="@drawable/button2"
android:text="倒菜\n启动"
android:textColor="@color/white"
android:textSize="20dp" />
<Button
android:id="@+id/dcqd_button2"
android:layout_width="160dp"
android:layout_height="100dp"
android:layout_centerInParent="true"
android:layout_marginLeft="50dp"
android:layout_marginRight="@dimen/dp_10"
android:background="@drawable/button3"
android:text="倒菜\n启动"
android:textColor="@color/white"
android:textSize="20dp" />
</LinearLayout>

</RelativeLayout>
</LinearLayout>
</RelativeLayout>
</com.qmuiteam.qmui.widget.QMUIWindowInsetLayout>

Loading…
Cancel
Save