Sfoglia il codice sorgente

1. 修改仓位物料校准、满管校准、酱料校准及相应模拟出料逻辑。2. 修改配方出料及余量逻辑。3. 下发配方时添加余量检验逻辑。4.串口断线重连修改。5. 电子秤读取重量程序修改。

味魔方Android
Nah 11 mesi fa
parent
commit
5643a69a85
17 ha cambiato i file con 824 aggiunte e 576 eliminazioni
  1. +3
    -0
      app/build.gradle
  2. +317
    -342
      app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java
  3. +2
    -1
      app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java
  4. +2
    -1
      app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_SILOS.java
  5. +4
    -10
      app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigationMainActivity.java
  6. +55
    -36
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/MakeGoodFragment.java
  7. +16
    -3
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DzcjyActivity.java
  8. +4
    -15
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/RealTimeActivity.java
  9. +3
    -13
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/Silos_item_jiaoyan_fragment.java
  10. +29
    -25
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_silos_ck.java
  11. +17
    -14
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/fragment_plc_control.java
  12. +347
    -82
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/silos_jiaoyan.java
  13. +0
    -16
      app/src/main/res/layout/fragment_make_good.xml
  14. +1
    -1
      app/src/main/res/layout/fragment_she_zhi.xml
  15. +3
    -0
      app/src/main/res/layout/item/layout/dialog_add_silos_ck.xml
  16. +2
    -2
      app/src/main/res/layout/item/layout/fragment_silos_item_jiaoyan.xml
  17. +19
    -15
      app/src/main/res/layout/item/layout/silos_jiaoyan_item.xml

+ 3
- 0
app/build.gradle Vedi File

@@ -157,4 +157,7 @@ dependencies {
implementation 'com.github.CymChad:BaseRecyclerViewAdapterHelper:3.0.4'

implementation 'com.contrarywind:Android-PickerView:3.2.6'

//曲线拟合方程式。
implementation 'org.apache.commons:commons-math3:3.6.1'
}

+ 317
- 342
app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java Vedi File

@@ -1,64 +1,53 @@
package com.bonait.bnframework.business;

import android.app.Activity;
import android.content.Context;
import android.content.ContextWrapper;
import android.graphics.Bitmap;
import android.media.MediaPlayer;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;

import androidx.annotation.NonNull;

import com.bonait.bnframework.R;
import com.bonait.bnframework.business.devicesControl.PLCControl;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.constant.DataBus;
import com.bonait.bnframework.common.db.QueryDB;
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;
import com.bonait.bnframework.common.db.mode.BPA_SILOS;
import com.bonait.bnframework.common.db.res.AlertLogEnum;
import com.bonait.bnframework.common.db.res.ResGoodsMake;
import com.bonait.bnframework.common.db.res.ResGoodsRecipe;
import com.bonait.bnframework.common.db.res.SilosLsjyMode;
import com.bonait.bnframework.common.db.res.UserLogEnum;
import com.bonait.bnframework.common.helper.ByteHelper;
import com.bonait.bnframework.common.helper.DataFormat;
import com.bonait.bnframework.common.helper.I.IReadCallBack;
import com.bonait.bnframework.common.helper.I.IRun;
import com.bonait.bnframework.common.helper.I.IRunT;
import com.bonait.bnframework.common.helper.I.IThread;
import com.bonait.bnframework.common.helper.I.IWriteCallBack;
import com.bonait.bnframework.common.helper.MediaPlayerHelper;
import com.bonait.bnframework.common.helper.MessageLog;
import com.bonait.bnframework.common.helper.RTrig;
import com.bonait.bnframework.common.helper.ThreadManager;
import com.bonait.bnframework.common.modbus.ModbusRTUServer;
import com.bonait.bnframework.common.modbus.ModbusTcpServer;
import com.bonait.bnframework.common.utils.AlertDialogUtils;
import com.bonait.bnframework.common.utils.ToastUtils;
import com.qmuiteam.qmui.widget.dialog.QMUIDialog;
import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.IdentityHashMap;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

import kotlin.UShort;

/**
* 执行配方
*/
public class ExecuteTheRecipe {

//region 变量

/**是否处于自动模式*/
public static boolean isAutoMode=true;

/**是否处于称重模式*/
public static boolean isGravimetricMode=false;

/**PLC连接是否超时,默认超时。*/
public static boolean isTimeOut=true;
/**
* 等待超时时间
*/
@@ -207,7 +196,6 @@ public class ExecuteTheRecipe {
//endregion

//region PLC监听线程
static List<String> names=new ArrayList<>();
public static void Listening() {

ConfigName.getInstance().PLC_Address.clear();
@@ -218,35 +206,25 @@ public class ExecuteTheRecipe {
}
}

names.clear();
if (ConfigName.getInstance().versionSelectionEnum.equals("配料吧台")) {
names.add("水池温度");
}else if (ConfigName.getInstance().versionSelectionEnum.equals("奶茶机"))
{
names.add("水池温度");
names.add("果糖左温度");
names.add("果糖右温度");
}

ThreadManager.Get().StartLong("PLC设备数据监听", true, new IThread() {
@Override
public void Run() throws InterruptedException {
try {
//region 临时屏蔽实时数据
// for (String item : ConfigName.getInstance().PLC_Address.keySet()) {
// String key = item;
// BPA_PLCADDRESS plcaddress = ConfigName.getInstance().PLC_Address.get(item);
// if (plcaddress.isread == 1) {
// Object val = ReadPLC(key);
// ListeningValue.put(key, val);
// }
// }
//endregion

isTimeOut=PLCControl.get().isTimeOut("超时标志");

if (isTimeOut /*&& ConfigName.getInstance().SerialIsConnect*/){
ConfigName.getInstance().SerialIsConnect=false;
Thread.sleep(5000);
if (!PLCControl.get().isTimeOut("超时标志")){
timeOutHandler();
}
}

if(!IsMakeGood)
{
//1.读取扫码数据
ReadCode();
//ReadCode();
//2.读取实时状态
ReadPLCStatus();
}
@@ -266,27 +244,10 @@ public class ExecuteTheRecipe {
@Override
public void Run() throws InterruptedException {
try {
if(!IsMakeGood)
{
Object zl= ExecuteTheRecipe.ReadPLC("称当前重量");
OutletWeigh=zl==null?0:(int)zl;
Object bz= ExecuteTheRecipe.ReadPLC("出料口检测");
IsCup=bz==null?false:(boolean) bz;
Object obj1= ExecuteTheRecipe.ReadPLC("水池温度");
WaterTemp=obj1==null?0:(int)obj1;

if (ConfigName.getInstance().versionSelectionEnum.equals("奶茶机"))
{
Object obj2= ExecuteTheRecipe.ReadPLC("果糖左温度");
Object obj3= ExecuteTheRecipe.ReadPLC("果糖右温度");
SugarTempLeft=obj2==null?0:(int)obj2;
SugarTempRight=obj3==null?0:(int)obj3;

Object obj21= ExecuteTheRecipe.ReadPLC("果糖左温度设置");
Object obj31= ExecuteTheRecipe.ReadPLC("果糖右温度设置");
SugarTempLeft_SZ=obj21==null?0:(int)obj21;
SugarTempRight_SZ=obj31==null?0:(int)obj31;
}
// if(!IsMakeGood)
// {
OutletWeigh=PLCControl.get().getCurrentWeight();
PLCControl.get().clrHeartbeat("心跳时间",null);

if (WeighComplete!=null)
{
@@ -296,53 +257,33 @@ public class ExecuteTheRecipe {
{
TempComplete.Run();
}
}
} catch (Exception ex) {
ToastUtils.error("异常信息:" + ex.getMessage());
}
Thread.sleep(200);
}
@Override
public void RunComplete() throws InterruptedException {

}
});

ThreadManager.Get().StartLong("PLC设备-自动加热补水", true, new IThread() {
@Override
public void Run() throws InterruptedException {
try {
if(!IsMakeGood)
{
AutoJR();
}
// }
} catch (Exception ex) {
ToastUtils.error("异常信息:" + ex.getMessage());
}
Thread.sleep(5000);
Thread.sleep(300);
}

@Override
public void RunComplete() throws InterruptedException {

}
});

ThreadManager.Get().StartLong("PLC设备数据监听-信号检测", true, new IThread() {
@Override
public void Run() throws InterruptedException {
try {
ChargeSignal();
} catch (Exception ex) {
ToastUtils.error("异常信息:" + ex.getMessage());
}
Thread.sleep(100);
}
@Override
public void RunComplete() throws InterruptedException {
}
});
// ThreadManager.Get().StartLong("PLC设备数据监听-信号检测", true, new IThread() {
// @Override
// public void Run() throws InterruptedException {
// try {
// ChargeSignal();
// } catch (Exception ex) {
// ToastUtils.error("异常信息:" + ex.getMessage());
// }
// Thread.sleep(100);
// }
// @Override
// public void RunComplete() throws InterruptedException {
//
// }
// });

ThreadManager.Get().StartLong("商品制作线程", true, new IThread() {
@Override
@@ -350,7 +291,6 @@ public class ExecuteTheRecipe {
try {
if(IsMakeGood && GoodMake!=null)
{

ArrayList<ResGoodsRecipe> recipes= GoodMake.recipes;

//region 根据物料配方排序Sort步骤分组
@@ -362,9 +302,13 @@ public class ExecuteTheRecipe {
}
//endregion

//计算系数,称重模式下配方默认是按1kg配料的,所以需要计算系数。
double ratio=OutletWeigh/10.0/1000;

PLCControl.get().Speak("配料开始",null);
int count = 0;
for (LinkedHashMap.Entry<Integer, List<ResGoodsRecipe>> entry : rgrs.entrySet()) {
WritePLC("配料完成", false,null);
//WritePLC("配料完成", false,null);

final Integer key = entry.getKey();

@@ -377,7 +321,11 @@ public class ExecuteTheRecipe {
}
count=2;
DataBus.getInstance().UpdateGoodsMake(GoodMake.subOrder.id, "步骤【" + key + "】准备下发物料:" + RecipesNames, count, key, false);
final boolean[] stepCompleted = {false};


final boolean[] siloComplted=new boolean[goodsRecipes.size()];
//region 给每个料仓下发指令
for (int m = 0; m < goodsRecipes.size(); m++) {
ResGoodsRecipe recipe = goodsRecipes.get(m);
final String message = "[" + GoodMake.good.name + "]步骤【" + key + "】下发【" + recipe.materialName + "】";
@@ -390,54 +338,109 @@ public class ExecuteTheRecipe {
silos = item;
}
if (silos == null) {
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, message + "下发失败!物料没有管理料仓!");
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, message + "下发失败!物料没有关联料仓!");
} else {
//MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, message + "准备下发【" + silos.num + "】号料仓PLC控制命令,需求量:=" + recipe.value);
int _val = (int)Math.round((Double.parseDouble(recipe.value) * 10));
WritePLC("需求值" + silos.num, (short) _val, null);
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, message + "准备下发【" + silos.num + "】号料仓PLC控制命令,需求量:=" + recipe.value);

double silo_adjustTime=Double.parseDouble(silos.jTime);
double silo_adjustValue=Double.parseDouble(silos.jValue);
double demand_value=Double.parseDouble(recipe.value);

int delayTime=0;
if (silos.name.equals("外置仓")){
delayTime=(int)(getDelayTimeByLCID(silos.id,demand_value)*1000);
}else{
//打开时间= 校准时间/校准重量*需求量 .方法单位是ms,需要*1000.
delayTime=(int)(silo_adjustTime/silo_adjustValue*demand_value*1000);
}
//如果在称重模式下,要计算比例,否则直接出料。
if (isGravimetricMode){
delayTime=(int)(delayTime*ratio);
}
//保存当前值,传入OnSuccess里。
final int[] index={0};
index[0]=m;
final String siloId= silos.id;
//出完料后的余量。
final int afterMargin=silos.silosmargin-(int)demand_value;
PLCControl.get().openMotorAndClose(silos.num, delayTime, new IWriteCallBack() {
@Override
public void onSuccess() {
ToastUtils.success("[" + GoodMake.good.name + "] 配料完成!");

QueryDB.UpdateYL(siloId, afterMargin );
siloComplted[index[0]]=true;
}

@Override
public void onFailure(String ErrorMsg) {
ToastUtils.error("[" + GoodMake.good.name + "] 配料失败!");
}
});
MessageLog.ShowInfo("[" + GoodMake.good.name + "]步骤【" + key + "】开始配料成功!");
}
}
//endregion

MessageLog.ShowInfo(RecipesNames + "下发成功!");
//endregion

//region 旧代码
//等待配料完成,一直等待
final boolean[] IsComplete = {false};
OnChargeMixtureCompleteNotify = new IRun() {
@Override
public void Run() {
IsComplete[0] = true;
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, "[" + GoodMake.good.name + "]步骤【" + key + "】配料完成!");
}
};
//
// OnChargeMixtureCompleteNotify = new IRun() {
// @Override
// public void Run() {
// IsComplete[0] = true;
// MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, "[" + GoodMake.good.name + "]步骤【" + key + "】配料完成!");
// }
// };

//启动配料
WritePLC("配料启动",true,new IWriteCallBack() {
@Override
public void onSuccess() {
MessageLog.ShowInfo("[" + GoodMake.good.name + "]步骤【" + key + "】启动配料成功!");
}

@Override
public void onFailure(String ErrorMsg) {
MessageLog.ShowInfo("[" + GoodMake.good.name + "]步骤【" + key + "】启动配料失败!");
MessageLog.ShowAlertMessage(AlertLogEnum.异常订单未制作日志, "[" + GoodMake.good.name + "]步骤【" + key + "】启动配料失败!");
}
});

// WritePLC("配料启动",true,new IWriteCallBack() {
// @Override
// public void onSuccess() {
// MessageLog.ShowInfo("[" + GoodMake.good.name + "]步骤【" + key + "】启动配料成功!");
// }
//
// @Override
// public void onFailure(String ErrorMsg) {
// MessageLog.ShowInfo("[" + GoodMake.good.name + "]步骤【" + key + "】启动配料失败!");
// MessageLog.ShowAlertMessage(AlertLogEnum.异常订单未制作日志, "[" + GoodMake.good.name + "]步骤【" + key + "】启动配料失败!");
// }
// });
//endregion

//一分钟未完成 强制认为完成了。
long a = System.currentTimeMillis();
while (!IsComplete[0]) {
while (!stepCompleted[0]) {
if ((System.currentTimeMillis() - a) > 1000 * 60) {
break;
}
Thread.sleep(100);//10 *6

stepCompleted[0]=true;
for (int i=0;i<siloComplted.length;i++){
if (siloComplted[i]==false){
stepCompleted[0]=false;
break;
}
}for (int i=0;i<siloComplted.length;i++){
if (siloComplted[i]==false){
stepCompleted[0]=false;
break;
}
}
Thread.sleep(500);//10 *6
}
//更新缓存商品制作列表状态
count += goodsRecipes.size();
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, "[" + GoodMake.good.name + "]步骤【" + key + "】配料完成!");
DataBus.getInstance().UpdateGoodsMake(GoodMake.subOrder.id, "步骤【" + key + "】:" + RecipesNames + "-配料完成!", count, key, true);
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, "[" + GoodMake.good.name + "]步骤【" + key + "】下发" + RecipesNames + "执行完成!");
}

DataBus.getInstance().DeleteGoodsMake(GoodMake.subOrder.id);
PLCControl.get().Speak("配料完成",null);
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, "[" + GoodMake.good.name + "]-订单执行完成,请取餐!");

GoodMake=null;
@@ -459,6 +462,27 @@ public class ExecuteTheRecipe {

//region PLC基础控制类


/**PLC通讯超时处理**/
public static void timeOutHandler(){

//ConfigName.getInstance().SerialIsConnect=false;

ToastUtils.info("检测到PLC连接超时,尝试执行超时处理。");
//ModbusTcpHelper.get().release();
//ModbusRTUServer.get().ConnectPLC();
PLCControl.get().initalPLC(new IWriteCallBack() {
@Override
public void onSuccess() {
ToastUtils.success("超时处理--复位PLC变量完成。");
}
@Override
public void onFailure(String ErrorMsg) {
//ToastUtils.error("超时处理--复位PLC变量失败。");
}
});
}

/**
* 写PLC数据
*
@@ -508,6 +532,49 @@ public class ExecuteTheRecipe {
}
}

/**
* RTU模式向写PLC数据
*
* @param name
* @param value
*/
public static void WritePLCForRTU(String name, Object value, IWriteCallBack callback) {
try {
int plcAddress=ConfigName.getInstance().SerialPLCAddress;
if (plcAddress<1) return;
if (ConfigName.getInstance().PLC_Address.containsKey(name)) {
BPA_PLCADDRESS plcaddress = ConfigName.getInstance().PLC_Address.get(name);
if (!plcaddress.address.isEmpty() && !isTimeOut) {
if (plcaddress.address.toUpperCase().startsWith("D"))//int
{
int startAddress=ModbusRTUServer.GetAddress(plcaddress.address);
short newvalue=Short.parseShort(value.toString());
ModbusRTUServer.get().WriteShort(plcAddress,startAddress, newvalue, callback);
} else if (plcaddress.address.toUpperCase().startsWith("M"))//bool
{
int startAddress=ModbusRTUServer.GetAddress(plcaddress.address);
boolean newValue=Boolean.parseBoolean(value.toString());
ModbusRTUServer.get().WriteBool(plcAddress,startAddress, newValue, callback);
} else if (plcaddress.address.toUpperCase().startsWith("X"))//bool
{
int startAddress=ModbusRTUServer.GetAddress(plcaddress.address);
boolean newValue=Boolean.parseBoolean(value.toString());
ModbusRTUServer.get().WriteBool(plcAddress,startAddress, newValue, callback);
} else if (plcaddress.address.toUpperCase().startsWith("Y"))//bool
{
int startAddress=ModbusRTUServer.GetAddress(plcaddress.address);
boolean newValue=Boolean.parseBoolean(value.toString());
ModbusRTUServer.get().WriteBool(plcAddress,startAddress, newValue, callback);
}
}
}
} catch (Exception ex) {
ToastUtils.error("异常信息:" + ex.getMessage());
} finally {

}
}

/**
* 读PLC数据
*
@@ -562,56 +629,6 @@ public class ExecuteTheRecipe {
}
}

/**
* 读PLC数据
*
* @param name
* @return
*/
public static Object[] ReadPLC(String name,int length) {
final Object[] ReturnsVariable = new Object[length];
try {
if (ConfigName.getInstance().PLC_Address.containsKey(name)) {
BPA_PLCADDRESS plcaddress = ConfigName.getInstance().PLC_Address.get(name);
if (!plcaddress.address.isEmpty() && ConfigName.getInstance().PlcIsConnect) {
if (plcaddress.address.toUpperCase().startsWith("VD"))//int
{
ModbusTcpServer.get().ReadInt(plcaddress.address, length, val -> {
for (int i = 0; i < length; i++) {
ReturnsVariable[i] = val[i];
}
});
} else if (plcaddress.address.toUpperCase().startsWith("M"))//bool
{
ModbusTcpServer.get().ReadBool(plcaddress.address, length, val -> {
for (int i = 0; i < length; i++) {
ReturnsVariable[i] = val[i];
}
});
} else if (plcaddress.address.toUpperCase().startsWith("VW"))//short
{
ModbusTcpServer.get().ReadShort(plcaddress.address, length, val -> {
for (int i = 0; i < length; i++) {
ReturnsVariable[i] = val[i];
}
});
} else if (plcaddress.address.toUpperCase().startsWith("VR"))//float
{
ModbusTcpServer.get().ReadFloat(plcaddress.address, length, val -> {
for (int i = 0; i < length; i++) {
ReturnsVariable[i] = val[i];
}
});
}
}
}
} catch (Exception ex) {
ToastUtils.error("异常信息:" + ex.getMessage());
} finally {
return ReturnsVariable;
}
}

/**
* 根据地址写 PLC数据 bool
*
@@ -659,25 +676,6 @@ public class ExecuteTheRecipe {
*/
public static void ReadPLCStatus() {
try {
// if (ConfigName.getInstance().PLC_Address.containsKey("实时状态")) {
// BPA_PLCADDRESS plcaddress = ConfigName.getInstance().PLC_Address.get("实时状态");
// if (!plcaddress.address.isEmpty() && ConfigName.getInstance().PlcIsConnect) {
// ModbusTcpServer.get().ReadStatus(plcaddress.address, 4, (data) -> {
// for (int i = 0; i < data.length; i++) {
// byte status=data[i];//0x92
// IoStatus.put(i*8+0, ByteHelper.getBit(status,0)==1);
// IoStatus.put(i*8+1, ByteHelper.getBit(status,1)==1);
// IoStatus.put(i*8+2, ByteHelper.getBit(status,2)==1);
// IoStatus.put(i*8+3, ByteHelper.getBit(status,3)==1);
// IoStatus.put(i*8+4, ByteHelper.getBit(status,4)==1);
// IoStatus.put(i*8+5, ByteHelper.getBit(status,5)==1);
// IoStatus.put(i*8+6, ByteHelper.getBit(status,6)==1);
// IoStatus.put(i*8+7, ByteHelper.getBit(status,7)==1);
// }
// });
// }
// }
//TODO:修改实时状态更新
boolean[] result= PLCControl.get().getAllMotorStatus();
for (int i=0;i< result.length;i++){
IoStatus.put(i,result[i]);
@@ -689,43 +687,6 @@ public class ExecuteTheRecipe {
}
}

/**
* 读取扫码信息
*/
public static void ReadCode() {
try {
if (ConfigName.getInstance().PLC_Address.containsKey("扫码数据")) {
BPA_PLCADDRESS plcaddress = ConfigName.getInstance().PLC_Address.get("扫码数据");
if (!plcaddress.address.isEmpty() && ConfigName.getInstance().PlcIsConnect) {
ModbusTcpServer.get().ReadString(plcaddress.address, 40, (data) -> {

if(!data.isEmpty() && !Code.equals(data) && OnScanTheCodeInformationT != null)
{
Log.d("信息", "扫码数据: "+data);
OnScanTheCodeInformationT.Run(data);
ModbusTcpServer.get().WriteString(plcaddress.address, 40, null);
}

//记录上一次读取PLC 扫码数据
Code = data;
});
}
}

// if (ConfigName.getInstance().PLC_Address.containsKey("配料次数")) {
// BPA_PLCADDRESS plcaddress = ConfigName.getInstance().PLC_Address.get("配料次数");
// if (!plcaddress.address.isEmpty() && ConfigName.getInstance().PlcIsConnect) {
// ModbusTcpServer.get().ReadInt(plcaddress.address, 1, (data) -> {
// MakeGoodCount=data[0] ;
// });
// }
// }
} catch (Exception ex) {
ToastUtils.error("异常信息:" + ex.getMessage());
} finally {
}
}

/**
* 信号检测
*/
@@ -753,80 +714,6 @@ public class ExecuteTheRecipe {
}
}

/**
* 自动加热
*/
public static void AutoJR() {
try {

if(ConfigName.getInstance().PlcIsConnect)
{

for (String item:names)
{
boolean isopen=false;
if(item.equals("水池温度"))
{
isopen=ConfigName.getInstance().AutomaticHeating;
}else if(item.equals("果糖左温度"))
{
isopen=ConfigName.getInstance().GT1_AutomaticHeating;
}else if(item.equals("果糖右温度"))
{
isopen=ConfigName.getInstance().GT2_AutomaticHeating;
}

if(isopen)
{
Object sc= ReadPLC(item);
Object scsz= ReadPLC(item+"设置");

int sx_temp=sc==null?0:(int)sc;//水箱温度
int sx_temp_sz=scsz==null?0:(int)scsz;//水箱温度设置值
if(sx_temp_sz>0)
{
if(sx_temp>=sx_temp_sz)
{
WritePLC(item+"加热",false,null);
}else
{
WritePLC(item+"加热",true,null);
}
}
}
}

//自动补水
if(ConfigName.getInstance().AutomaticWaterRefill)
{
Object yw= ReadPLC("水池液位检测");
boolean isopen=yw==null?false:(boolean) yw;
if(!isopen)
{
WritePLC("水池进水阀",true,null);
}else
{
if(yw!=null )
{
Object jsf= ReadPLC("水池进水阀");
if(jsf!=null && (boolean)jsf)
{
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
WritePLC("水池进水阀",false,null);
}
}, (int)Math.round((Double.parseDouble(ConfigName.getInstance().AutomaticWaterRefillTime) * 1000)));
}
}
}
}
}
} catch (Exception ex) {
ToastUtils.error("异常信息:" + ex.getMessage());
} finally {
}
}

/**
* 完成信号监听
@@ -856,26 +743,15 @@ public class ExecuteTheRecipe {
*/
public static boolean StartJiaoYanMode()
{

final boolean[] issucess1 = {false};
final boolean[] issucess2 = {false};
final boolean[] issucess3 = {false};

//写校准模式
WritePLC("砝码校准模式", true, new IWriteCallBack() {
@Override
public void onSuccess() {
issucess1[0] =true;
}

@Override
public void onFailure(String ErrorMsg) {

}
});
WritePLC("关闭写保护", true, new IWriteCallBack() {
// 1. 关闭写保护。
PLCControl.get().closeWriteProtect(new IWriteCallBack() {
@Override
public void onSuccess() {
issucess2[0] =true;
issucess1[0]=true;
}
@Override
public void onFailure(String ErrorMsg) {
@@ -883,17 +759,59 @@ public class ExecuteTheRecipe {
}
});

WritePLC("零点校准", true, new IWriteCallBack() {
// 2.称台清零。
PLCControl.get().zeroScale(new IWriteCallBack() {
@Override
public void onSuccess() {
issucess3[0] =true;
issucess2[0]=true;
}

@Override
public void onFailure(String ErrorMsg) {

}
});
return issucess1[0] && issucess2[0]&& issucess3[0];
return issucess1[0] && issucess2[0];
//region 旧代码。
// final boolean[] issucess1 = {false};
// final boolean[] issucess2 = {false};
// final boolean[] issucess3 = {false};
//
// //写校准模式
// WritePLC("砝码校准模式", true, new IWriteCallBack() {
// @Override
// public void onSuccess() {
// issucess1[0] =true;
// }
//
// @Override
// public void onFailure(String ErrorMsg) {
//
// }
// });
// WritePLC("关闭写保护", true, new IWriteCallBack() {
// @Override
// public void onSuccess() {
// issucess2[0] =true;
// }
// @Override
// public void onFailure(String ErrorMsg) {
//
// }
// });
//
// WritePLC("零点校准", true, new IWriteCallBack() {
// @Override
// public void onSuccess() {
// issucess3[0] =true;
// }
// @Override
// public void onFailure(String ErrorMsg) {
//
// }
// });
// return issucess1[0] && issucess2[0]&& issucess3[0];
// endregion
}

/**
@@ -901,14 +819,42 @@ public class ExecuteTheRecipe {
*/
public static boolean StopJiaoYanMode()
{
final boolean[] issucess1 = {false};
final boolean[] issucess2 = {false};
//region 旧代码
// final boolean[] issucess1 = {false};
// final boolean[] issucess2 = {false};
//
// //写校准模式
// WritePLC("砝码校准模式", false, new IWriteCallBack() {
// @Override
// public void onSuccess() {
// issucess1[0] =true;
// }
//
// @Override
// public void onFailure(String ErrorMsg) {
//
// }
// });
// WritePLC("打开写保护", true, new IWriteCallBack() {
// @Override
// public void onSuccess() {
// issucess2[0] =true;
// }
// @Override
// public void onFailure(String ErrorMsg) {
//
// }
// });

//return issucess1[0] && issucess2[0];
//endregion

//写校准模式
WritePLC("砝码校准模式", false, new IWriteCallBack() {
final boolean[] issucess1 = {false};
// 1. 打开写保护
PLCControl.get().openWriteProtect(new IWriteCallBack() {
@Override
public void onSuccess() {
issucess1[0] =true;
issucess1[0]=true;
}

@Override
@@ -916,17 +862,46 @@ public class ExecuteTheRecipe {

}
});
WritePLC("打开写保护", true, new IWriteCallBack() {
@Override
public void onSuccess() {
issucess2[0] =true;
}
@Override
public void onFailure(String ErrorMsg) {
return issucess1[0];
}
//endregion

}
});
return issucess1[0] && issucess2[0];
//region 外置仓相关

/**根据外置仓的仓位ID获取对应克重的延时时间*/
public static double getDelayTimeByLCID(String lcID,double weight){

if (lcID.isEmpty() || weight<=0){
return 0;
}
BPA_SILOS silo= QueryDB.GetSilosID(lcID);
if (silo ==null || silo.maxweight==null || silo.minweight==null || silo.bcsfValue==null){
return 0;
}
final double maxWeight=Double.parseDouble(silo.maxweight);
final double minWeight=Double.parseDouble(silo.minweight);
final double[] coefficients=stringToDoubleArray(silo.bcsfValue);
if (weight<=minWeight || weight>=maxWeight){
return 0;
}

double delayTime=0.0;
final int degree=coefficients.length-1;
for (int i=0;i<coefficients.length;i++){
delayTime+=coefficients[i]* Math.pow(weight,degree-i);
}

return delayTime;
}

/**根据字符串,返回double数组,字符串必须是[1.0,2.0,3.0]这种形式*/
private static double[] stringToDoubleArray(@NonNull String str) {
String[] strArray = str.substring(1, str.length() - 1).split(", ");
double[] doubleArray=new double[strArray.length];
for (int i=0;i< strArray.length;i++){
doubleArray[i]=Double.parseDouble(strArray[i]);
}
return doubleArray;
}
//endregion
}

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

@@ -158,6 +158,7 @@ public class ConfigName {
//endregion

//region 串口PLC连接参数
public int SerialPLCAddress=3;
/**
* 串口是否连接。
* */
@@ -236,7 +237,7 @@ public class ConfigName {

//region 心跳变量
add(new Res_PLCADDRESS("心跳时间", "D0", 0, 1));
add(new Res_PLCADDRESS("超时标志", "M0", 1, 1));
add(new Res_PLCADDRESS("超时标志", "M0", 1, 0));

//endregion



+ 2
- 1
app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_SILOS.java Vedi File

@@ -31,7 +31,8 @@ public class BPA_SILOS extends ModeBase {

//校准时间 jValue/jTime = (1s 出多少g)
public String jTime;
//反转时间

/**反转时间*/
public String fTime;
//是否启用算法补偿 0 不启用 1 启用
public int isenablebcsf;


+ 4
- 10
app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigationMainActivity.java Vedi File

@@ -1,14 +1,10 @@
package com.bonait.bnframework.modules.home.activity;

import androidx.annotation.NonNull;
import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;

import android.os.Bundle;
import android.util.Log;
import android.view.MenuItem;
import android.widget.RelativeLayout;

import androidx.fragment.app.Fragment;
import androidx.viewpager.widget.ViewPager;

import com.bonait.bnframework.R;
import com.bonait.bnframework.business.ConfigData;
@@ -21,14 +17,11 @@ import com.bonait.bnframework.common.helper.MediaPlayerHelper;
import com.bonait.bnframework.common.helper.MessageLog;
import com.bonait.bnframework.common.helper.ThreadManager;
import com.bonait.bnframework.common.modbus.ModbusRTUServer;
import com.bonait.bnframework.common.modbus.ModbusTcpServer;
import com.bonait.bnframework.common.tabbar.MainNavigateTabBar;
import com.bonait.bnframework.common.utils.NetworkUtils;
import com.bonait.bnframework.modules.home.adapter.FragmentAdapter;
import com.bonait.bnframework.modules.home.fragment.DingDanfragment;
import com.bonait.bnframework.modules.home.fragment.GongnengFragment;
import com.bonait.bnframework.modules.home.fragment.GuanLifragment;
import com.bonait.bnframework.modules.home.fragment.JiaoYanFragment;
import com.bonait.bnframework.modules.home.fragment.MakeGoodFragment;
import com.bonait.bnframework.modules.home.fragment.SheZhifragment;
import com.bonait.bnframework.modules.mine.fragment.MyFragment;
@@ -127,6 +120,7 @@ public class BottomNavigationMainActivity extends BaseActivity {
@Override
public void Run() throws InterruptedException {
try {
//if (ExecuteTheRecipe.isTimeOut) {
if (!ConfigName.getInstance().SerialIsConnect) {
ModbusRTUServer.get().ConnectPLC();
}


+ 55
- 36
app/src/main/java/com/bonait/bnframework/modules/home/fragment/MakeGoodFragment.java Vedi File

@@ -1,54 +1,45 @@
package com.bonait.bnframework.modules.home.fragment;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.appcompat.app.AppCompatActivity;
import androidx.core.content.ContextCompat;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import android.app.Activity;
import android.content.Context;
import android.content.res.Resources;
import android.graphics.Color;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.Button;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.recyclerview.widget.LinearLayoutManager;
import androidx.recyclerview.widget.RecyclerView;

import com.bonait.bnframework.R;
import com.bonait.bnframework.business.ConfigData;
import com.bonait.bnframework.business.ExecuteTheRecipe;
import com.bonait.bnframework.business.devicesControl.PLCControl;
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_GOODPROPERTY;
import com.bonait.bnframework.common.db.mode.BPA_GOODS;
import com.bonait.bnframework.common.db.mode.BPA_GOODSRECIPENAME;
import com.bonait.bnframework.common.db.mode.BPA_GOODSTYPE;
import com.bonait.bnframework.common.db.mode.BPA_ORDER;
import com.bonait.bnframework.common.db.mode.BPA_SILOS;
import com.bonait.bnframework.common.db.mode.BPA_SUBORDER;
import com.bonait.bnframework.common.db.res.ResGoodProperty;
import com.bonait.bnframework.common.db.res.ResGoodsMake;
import com.bonait.bnframework.common.db.res.SilosLsjyMode;
import com.bonait.bnframework.common.helper.I.IRun;
import com.bonait.bnframework.common.db.res.ResGoodsRecipe;
import com.bonait.bnframework.common.db.res.UserLogEnum;
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.I.MyClickListener;
import com.bonait.bnframework.common.helper.ThreadManager;
import com.bonait.bnframework.common.helper.MessageLog;
import com.bonait.bnframework.common.linktab.LinkMode;
import com.bonait.bnframework.common.linktab.TopItemDecoration;
import com.bonait.bnframework.common.linktab.good.GoodLeftAdapter;
import com.bonait.bnframework.common.linktab.good.GoodRightAdapter;
import com.bonait.bnframework.common.linktab.makegood.MakeGoodLeftAdapter;
import com.bonait.bnframework.common.linktab.makegood.MakeGoodRightAdapter;
import com.bonait.bnframework.common.message.MessageLooper;
@@ -56,11 +47,8 @@ import com.bonait.bnframework.common.message.MessageManager;
import com.bonait.bnframework.common.utils.AlertDialogUtils;
import com.bonait.bnframework.common.utils.ToastUtils;
import com.bonait.bnframework.modules.home.adapter.loadinggood_adapter;
import com.bonait.bnframework.modules.home.adapter.wl_adapter;
import com.bonait.bnframework.modules.home.fragment.mode.add_makegood_control;
import com.bonait.bnframework.modules.home.fragment.mode.add_manguan_control;
import com.bonait.bnframework.modules.home.fragment.mode.add_pf_control;
import com.litao.slider.NiftySlider;
import com.orhanobut.logger.Logger;
import com.qmuiteam.qmui.widget.QMUITopBarLayout;
import com.qmuiteam.qmui.widget.dialog.QMUIDialog;
@@ -68,8 +56,9 @@ import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.LinkedHashMap;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import butterknife.BindView;
import butterknife.ButterKnife;
@@ -112,13 +101,6 @@ public class MakeGoodFragment extends BaseFragment {
@BindView(R.id.add_manguan)
add_manguan_control add_manguan;

/**
* 当前温度
*/
@BindView(R.id.wendu1)
TextView wendu1;
// @BindView(R.id.pf_ms)
// TextView pf_ms;
@BindView(R.id.plc_status)
TextView plc_status;
@BindView(R.id.dianzichen)
@@ -243,7 +225,7 @@ public class MakeGoodFragment extends BaseFragment {
@Override
public void clickListener(View v, Object data) {
ResGoodsMake makegood = (ResGoodsMake) data;
if (!ConfigName.getInstance().PlcIsConnect) {
if (!ConfigName.getInstance().SerialIsConnect || ExecuteTheRecipe.isTimeOut) {
ToastUtils.warning("设备已离线,请检查设备...");
return;
}
@@ -275,6 +257,42 @@ public class MakeGoodFragment extends BaseFragment {
}
}

//region 配方所需物料是否充足校验
String lackMaterialList="";
HashMap<String,Double> demandMap=new HashMap<>();
//物料ID和物料名称对照表。
HashMap<String,String> materialNameMap=new HashMap<>();
for (ResGoodsRecipe material:makegood.recipes) {
//获取每个物料对应的料仓余量。
double demand_value=Double.parseDouble(material.value);
String materialName=material.materialName;
String materialID=material.materialID;
if (!demandMap.containsKey(materialID)){
demandMap.put(materialID,0.0);
}
double currentValue=demandMap.get(materialID);
demandMap.put(materialID,currentValue+demand_value);
materialNameMap.put(materialID,materialName);
}
for (Map.Entry<String,Double> entry :demandMap.entrySet()){
BPA_SILOS silos = null;
List<BPA_SILOS> siloslist = QueryDB.GetSolisByMaterialID(entry.getKey());
String materialName=materialNameMap.get(entry.getKey());
for (BPA_SILOS item : siloslist) {
if(silos==null)
silos = item;
}
if (silos == null) {
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, "下发失败!物料["+materialName+"]没有关联料仓!");
return;
}else{
if (silos.silosmargin<entry.getValue()){
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, "下发失败!物料["+materialName+"]余量可能不足,总需求量["+entry.getValue()+"g]请检查!");
return;
}
}
}
//endregion

String title = "温馨提示!";
String message = "客官确定要开始制作【" + makegood.good.name + "】吗?";
@@ -379,8 +397,9 @@ public class MakeGoodFragment extends BaseFragment {
Initdata();
break;
case R.id.cheng_clear://称重清零
ExecuteTheRecipe.WritePLC("重量清零", true, new IWriteCallBack() {
@Override
//ExecuteTheRecipe.WritePLC("重量清零", true, new IWriteCallBack() {
PLCControl.get().tare(new IWriteCallBack() {
@Override
public void onSuccess() {
ToastUtils.info("清零成功!");
}
@@ -410,9 +429,9 @@ public class MakeGoodFragment extends BaseFragment {
public void handleMessage(Message msg) {
switch (msg.what) {
case 0:
plc_status.setText(ConfigName.getInstance().PlcIsConnect ? "正常" : "异常");
plc_status.setTextColor(ConfigName.getInstance().PlcIsConnect ? Color.parseColor("#4CAF50") : Color.parseColor("#D32F2F"));
wendu1.setText(ExecuteTheRecipe.WaterTemp + "°C");
plc_status.setText(ExecuteTheRecipe.isTimeOut ? "异常" : "正常");
plc_status.setTextColor(ExecuteTheRecipe.isTimeOut ? Color.parseColor("#D32F2F") : Color.parseColor("#4CAF50"));
//wendu1.setText(ExecuteTheRecipe.WaterTemp + "°C");
dianzichen.setText(String.valueOf((int) ExecuteTheRecipe.OutletWeigh / 10.0) + " g");
break;
case 1:


+ 16
- 3
app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DzcjyActivity.java Vedi File

@@ -10,6 +10,7 @@ import android.widget.EditText;

import com.bonait.bnframework.R;
import com.bonait.bnframework.business.ExecuteTheRecipe;
import com.bonait.bnframework.business.devicesControl.PLCControl;
import com.bonait.bnframework.common.base.BaseActivity;
import com.bonait.bnframework.common.helper.I.IWriteCallBack;
import com.bonait.bnframework.common.utils.ToastUtils;
@@ -83,13 +84,25 @@ public class DzcjyActivity extends BaseActivity {

String outres = edittext_zl.getText().toString().trim();
if (!outres.equals("")) {
ExecuteTheRecipe.WritePLC("砝码值", Short.parseShort(outres), new IWriteCallBack() {
//region 旧代码
// ExecuteTheRecipe.WritePLC("砝码值", Short.parseShort(outres), new IWriteCallBack() {
// @Override
// public void onSuccess() {
// ExecuteTheRecipe.WritePLC("砝码值写入",true,null);
// ToastUtils.info("校正重量成功!");
// }
//
// @Override
// public void onFailure(String ErrorMsg) {
// ToastUtils.error("校正重量失败!");
// }
// });
//endregion
PLCControl.get().writeCounterWeight(Short.parseShort(outres), new IWriteCallBack(){
@Override
public void onSuccess() {
ExecuteTheRecipe.WritePLC("砝码值写入",true,null);
ToastUtils.info("校正重量成功!");
}

@Override
public void onFailure(String ErrorMsg) {
ToastUtils.error("校正重量失败!");


+ 4
- 15
app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/RealTimeActivity.java Vedi File

@@ -2,34 +2,22 @@ package com.bonait.bnframework.modules.home.fragment.from;

import static com.bonait.bnframework.MainApplication.getContext;

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

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;

import androidx.recyclerview.widget.RecyclerView;

import com.bonait.bnframework.R;
import com.bonait.bnframework.business.ExecuteTheRecipe;
import com.bonait.bnframework.common.base.BaseActivity;
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.db.res.StatusMode;
import com.bonait.bnframework.common.view.MyLayoutManager;
import com.bonait.bnframework.modules.home.adapter.devstatus_adapter;
import com.bonait.bnframework.modules.home.fragment.GuanLifragment;
import com.bonait.bnframework.modules.home.fragment.from.fragment.Jcsjgl_sxgl_fragment;
import com.bonait.bnframework.modules.home.fragment.from.fragment.Jcsjgl_wl_fragment;
import com.qmuiteam.qmui.arch.QMUIFragment;
import com.qmuiteam.qmui.arch.QMUIFragmentPagerAdapter;
import com.qmuiteam.qmui.widget.QMUITopBarLayout;
import com.qmuiteam.qmui.widget.QMUIViewPager;
import com.qmuiteam.qmui.widget.tab.QMUITabSegment;

import java.util.ArrayList;

@@ -136,7 +124,8 @@ public class RealTimeActivity extends BaseActivity {
new Thread(new Runnable() {
@Override
public void run() {
while (ConfigName.getInstance().PlcIsConnect) {
//while (ConfigName.getInstance().SerialIsConnect) {
while (!ExecuteTheRecipe.isTimeOut) {
try {
runOnUiThread(new Runnable() {
@Override


+ 3
- 13
app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/Silos_item_jiaoyan_fragment.java Vedi File

@@ -2,7 +2,6 @@ package com.bonait.bnframework.modules.home.fragment.mode;

import android.app.Activity;
import android.content.Context;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
import android.os.SystemClock;
@@ -15,29 +14,19 @@ import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.TextView;

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

import com.bonait.bnframework.R;
import com.bonait.bnframework.business.ExecuteTheRecipe;
import com.bonait.bnframework.common.base.BaseFragment;
import com.bonait.bnframework.business.devicesControl.PLCControl;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.constant.DataBus;
import com.bonait.bnframework.common.db.QueryDB;
import com.bonait.bnframework.common.db.res.SilosLsjyMode;
import com.bonait.bnframework.common.db.res.lcMode;
import com.bonait.bnframework.common.helper.I.IRun;
import com.bonait.bnframework.common.helper.I.IWriteCallBack;
import com.bonait.bnframework.common.utils.ToastUtils;
import com.bonait.bnframework.modules.home.fragment.from.LogActivity;
import com.bonait.bnframework.modules.home.fragment.from.PlcControlActivity;
import com.bonait.bnframework.modules.home.fragment.from.RealTimeActivity;
import com.orhanobut.logger.Logger;
import com.qmuiteam.qmui.arch.QMUIFragment;
import com.suke.widget.SwitchButton;

import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
import butterknife.OnClick;
@@ -379,7 +368,8 @@ public class Silos_item_jiaoyan_fragment extends LinearLayout {
* 电子秤清零
*/
public void dzcql() {
ExecuteTheRecipe.WritePLC("重量清零", true, new IWriteCallBack() {
//ExecuteTheRecipe.WritePLC("重量清零", true, new IWriteCallBack() {
PLCControl.get().tare(new IWriteCallBack() {
@Override
public void onSuccess() {
ToastUtils.info("清零成功!");


+ 29
- 25
app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_silos_ck.java Vedi File

@@ -1,5 +1,6 @@
package com.bonait.bnframework.modules.home.fragment.mode;

import android.annotation.SuppressLint;
import android.content.Context;
import android.content.DialogInterface;
import android.os.Handler;
@@ -15,7 +16,6 @@ import android.widget.Chronometer;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.ListView;
import android.widget.RelativeLayout;
import android.widget.Spinner;
import android.widget.TextView;
@@ -23,31 +23,22 @@ import android.widget.TextView;
import androidx.annotation.Nullable;

import com.bonait.bnframework.R;
import com.bonait.bnframework.business.ConfigData;
import com.bonait.bnframework.business.ExecuteTheRecipe;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.business.devicesControl.PLCControl;
import com.bonait.bnframework.common.db.QueryDB;
import com.bonait.bnframework.common.db.mode.BPA_GOODS;
import com.bonait.bnframework.common.db.mode.BPA_GOODSRECIPENAME;
import com.bonait.bnframework.common.db.mode.BPA_GOODSTYPE;
import com.bonait.bnframework.common.db.mode.BPA_MATERIAL;
import com.bonait.bnframework.common.db.mode.BPA_SILOS;
import com.bonait.bnframework.common.db.mode.BPA_SILOSANDMATERIAL;
import com.bonait.bnframework.common.db.res.ResGoodsRecipe;
import com.bonait.bnframework.common.db.res.lcMode;
import com.bonait.bnframework.common.helper.I.IWriteCallBack;
import com.bonait.bnframework.common.helper.I.MyClickListener;
import com.bonait.bnframework.common.utils.ToastUtils;
import com.bonait.bnframework.modules.home.adapter.goodpf_apapter;
import com.qmuiteam.qmui.widget.dialog.QMUIDialog;
import com.suke.widget.SwitchButton;

import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import butterknife.BindView;
import butterknife.ButterKnife;
@@ -111,6 +102,8 @@ public class add_silos_ck extends LinearLayout {

@BindView(R.id.jishiqi)
RelativeLayout jishiqi;//
@BindView(R.id.menu_silo)
RelativeLayout menu_silo;

ArrayList<BPA_MATERIAL> materials = new ArrayList<>();

@@ -165,6 +158,7 @@ public class add_silos_ck extends LinearLayout {

boolean ismanguan = false;

@SuppressLint("ClickableViewAccessibility")
private void initEvent() {
buchongyuanliao.setOnClickListener(new OnClickListener() {
@Override
@@ -223,13 +217,16 @@ public class add_silos_ck extends LinearLayout {
if (ismanguan == false) {
ismanguan = true;
StartTime();
ExecuteTheRecipe.WritePLC("手自切换", false, null);
//ExecuteTheRecipe.WritePLC("手自切换", false, null);
int time = lcMode.bValue <= 0 ? 10 : lcMode.bValue;//默认10秒
ExecuteTheRecipe.WritePLC("手动控制" + lcMode.num, true, null);
//ExecuteTheRecipe.WritePLC("手动控制" + lcMode.num, true, null);
PLCControl.get().openMotor(lcMode.num,null);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
ExecuteTheRecipe.WritePLC("手动控制" + lcMode.num, false, null);
//ExecuteTheRecipe.WritePLC("手动控制" + lcMode.num, false, null);

PLCControl.get().closeMotor(lcMode.num,null);
ToastUtils.info("满管成功!!!");
ismanguan = false;
StopTime();
@@ -345,19 +342,22 @@ public class add_silos_ck extends LinearLayout {
public boolean onTouch(View view, MotionEvent motionEvent) {
if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
Log.e("鼠标", "按下: ");
ExecuteTheRecipe.WritePLC("手自切换", false, new IWriteCallBack() {
@Override
public void onSuccess() {
ExecuteTheRecipe.WritePLC("手动控制" + lcMode.num, true, null);
}

@Override
public void onFailure(String ErrorMsg) {
}
});
// ExecuteTheRecipe.WritePLC("手自切换", false, new IWriteCallBack() {
// @Override
// public void onSuccess() {
// ExecuteTheRecipe.WritePLC("手动控制" + lcMode.num, true, null);
// }
//
// @Override
// public void onFailure(String ErrorMsg) {
// }
// });
ExecuteTheRecipe.isAutoMode=false;
PLCControl.get().openMotor(lcMode.num,null);
} else if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
Log.e("鼠标", "松开: ");
ExecuteTheRecipe.WritePLC("手动控制" + lcMode.num, false, null);
//ExecuteTheRecipe.WritePLC("手动控制" + lcMode.num, false, null);
PLCControl.get().closeMotor(lcMode.num,null);
}
return false;
}
@@ -437,6 +437,7 @@ public class add_silos_ck extends LinearLayout {
*/
public void StartTime() {
jishiqi.setVisibility(View.VISIBLE);
menu_silo.setVisibility(View.GONE);

runtime.setBase(SystemClock.elapsedRealtime());
runtime.start();
@@ -447,6 +448,9 @@ public class add_silos_ck extends LinearLayout {
*/
public int StopTime() {
jishiqi.setVisibility(View.GONE);
menu_silo.setVisibility(View.VISIBLE);


long elapsedMillis = SystemClock.elapsedRealtime() - runtime.getBase();
runtime.stop();



+ 17
- 14
app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/fragment_plc_control.java Vedi File

@@ -188,7 +188,7 @@ public class fragment_plc_control extends LinearLayout {
@Override
public void onCheckedChanged(SwitchButton view, boolean isChecked) {
boolean ischick= control_switch.isChecked();
ExecuteTheRecipe.WritePLC(model.name,ischick,null);
ExecuteTheRecipe.WritePLCForRTU(model.name,ischick,null);
ToastUtils.info("写入地址:"+model.address+"成功!状态:"+(ischick?"打开":"关闭"));
}
});
@@ -223,19 +223,22 @@ public class fragment_plc_control extends LinearLayout {
return;
}

if(model.address.startsWith("VW"))
{
Short val=Short.parseShort(text);
ExecuteTheRecipe.WritePLC(model.name,val,null);
}else if(model.address.startsWith("VD"))
{
int val=Integer.parseInt(text);
ExecuteTheRecipe.WritePLC(model.name,val,null);
}else
{
Short val=Short.parseShort(text);
ExecuteTheRecipe.WritePLC(model.name,val,null);
}
// if(model.address.startsWith("VW"))
// {
// Short val=Short.parseShort(text);
// ExecuteTheRecipe.WritePLC(model.name,val,null);
// }else if(model.address.startsWith("VD"))
// {
// int val=Integer.parseInt(text);
// ExecuteTheRecipe.WritePLC(model.name,val,null);
// }else
// {
// Short val=Short.parseShort(text);
// ExecuteTheRecipe.WritePLC(model.name,val,null);
// }

ExecuteTheRecipe.WritePLCForRTU(model.name,text,null);
//TODO:修改手动写入操作代码。
ToastUtils.info("写入地址:"+model.address+"成功!");
break;



+ 347
- 82
app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/silos_jiaoyan.java Vedi File

@@ -2,55 +2,48 @@ package com.bonait.bnframework.modules.home.fragment.mode;

import android.app.Activity;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Color;
import android.os.Handler;
import android.os.Looper;
import android.os.Message;
import android.os.SystemClock;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.MotionEvent;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.Button;
import android.widget.Chronometer;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.RelativeLayout;
import android.widget.Spinner;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.FragmentManager;

import com.bonait.bnframework.R;
import com.bonait.bnframework.business.ExecuteTheRecipe;
import com.bonait.bnframework.business.devicesControl.PLCControl;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.db.QueryDB;
import com.bonait.bnframework.common.db.mode.BPA_MATERIAL;
import com.bonait.bnframework.common.db.mode.BPA_SILOS;
import com.bonait.bnframework.common.db.mode.BPA_SILOSANDMATERIAL;
import com.bonait.bnframework.common.db.res.UserLogEnum;
import com.bonait.bnframework.common.db.res.lcMode;
import com.bonait.bnframework.common.helper.I.IRun;
import com.bonait.bnframework.common.helper.I.IWriteCallBack;
import com.bonait.bnframework.common.helper.I.MyClickListener;
import com.bonait.bnframework.common.model.mode.ResMenuLeft;
import com.bonait.bnframework.common.helper.MessageLog;
import com.bonait.bnframework.common.utils.AlertDialogUtils;
import com.bonait.bnframework.common.utils.ToastUtils;
import com.qmuiteam.qmui.arch.QMUIFragment;
import com.qmuiteam.qmui.arch.QMUIFragmentPagerAdapter;
import com.qmuiteam.qmui.widget.QMUIViewPager;
import com.qmuiteam.qmui.widget.dialog.QMUIDialog;
import com.qmuiteam.qmui.widget.tab.QMUIBasicTabSegment;
import com.qmuiteam.qmui.widget.tab.QMUITabSegment;
import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction;
import com.suke.widget.SwitchButton;

import java.math.BigDecimal;
import java.text.DecimalFormat;
import org.apache.commons.math3.fitting.PolynomialCurveFitter;
import org.apache.commons.math3.fitting.WeightedObservedPoints;

import java.util.ArrayList;
import java.util.List;
import java.util.Arrays;
import java.util.Map;

import butterknife.BindView;
import butterknife.ButterKnife;
@@ -119,12 +112,15 @@ public class silos_jiaoyan extends LinearLayout {
//endregion

//region 物料校准变量
/**物料校准--校准时间*/
@BindView(R.id.wljz1)
EditText wljz1;

/**物料校准--反转时间*/
@BindView(R.id.wljz2)
EditText wljz2;

/**物料校准--校准重量*/
@BindView(R.id.wljz3)
EditText wljz3;

@@ -146,6 +142,26 @@ public class silos_jiaoyan extends LinearLayout {
EditText bcjz_clsj;
//endregion

//region 酱料校准的控件
/**酱料校准下限*/
@BindView(R.id.txt_jljz_lowLimit)
EditText txt_jljz_lowLimit;


/**酱料校准上限*/
@BindView(R.id.txt_jljz_highLimit)
EditText txt_jljz_highLimit;


/**酱料校准频率*/
@BindView(R.id.txt_jljz_adjFreq)
EditText txt_jljz_adjFreq;

/**开始酱料校准*/
@BindView(R.id.btn_jljz_startAdj)
Button btn_jljz_startAdj;
//endregion

public silos_jiaoyan(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
root= LayoutInflater.from(context).inflate(R.layout.silos_jiaoyan_item, this);
@@ -159,6 +175,9 @@ public class silos_jiaoyan extends LinearLayout {
TextView text_wlkz;
@BindView(R.id.text_mgkz)
TextView text_mgkz;

@BindView(R.id.text_mgkz1)
TextView text_mgkz1;
@BindView(R.id.text_jlkz)
TextView text_jlkz;
@BindView(R.id.text_bckz)
@@ -176,12 +195,19 @@ public class silos_jiaoyan extends LinearLayout {
title_bc.setText(lcMode.num+" "+lcMode.materialName);
if(lcMode.name.equals("外置仓"))
{
text_wlkz.setVisibility(View.GONE);
text_mgkz1.setVisibility(View.GONE);

text_jlkz.setVisibility(View.VISIBLE);
text_bckz.setVisibility(View.VISIBLE);
text_bckz.setVisibility(View.GONE);
text_jlkz1.setVisibility(View.VISIBLE);
text_bckz1.setVisibility(View.VISIBLE);
text_bckz1.setVisibility(View.GONE);

}else
{
text_wlkz.setVisibility(View.VISIBLE);
text_mgkz1.setVisibility(View.VISIBLE);

text_jlkz.setVisibility(View.GONE);
text_bckz.setVisibility(View.GONE);
text_jlkz1.setVisibility(View.GONE);
@@ -264,7 +290,13 @@ public class silos_jiaoyan extends LinearLayout {
activity=ac;
this.lcMode=_lcMode;
initData();
InitView("物料校准");
//InitView("物料校准");
if (lcMode.name.equals("外置仓")){
InitView("酱料校准");
}else{
InitView("物料校准");
}

Run();
}

@@ -460,7 +492,7 @@ public class silos_jiaoyan extends LinearLayout {
R.id.chuliao1, R.id.chuliao2, R.id.chuliao3,
R.id.click_mgjz, R.id.click_mgjz_save,
R.id.click_wljz, R.id.click_wljz_save,
R.id.click_bcjz_save,
R.id.click_bcjz_save,R.id.btn_jljz_startAdj,
})
public void onViewClicked(View view) {
switch (view.getId()) {
@@ -499,6 +531,9 @@ public class silos_jiaoyan extends LinearLayout {
case R.id.click_bcjz_save://补偿校准 保存参数
SaveBCJZ();
break;
case R.id.btn_jljz_startAdj:
JLJZ();
break;
}
}
//endregion
@@ -509,8 +544,9 @@ public class silos_jiaoyan extends LinearLayout {
* 电子秤清零
*/
public void dzcql() {
ExecuteTheRecipe.WritePLC("重量清零", true, new IWriteCallBack() {
@Override
//ExecuteTheRecipe.WritePLC("重量清零", true, new IWriteCallBack() {
PLCControl.get().tare(new IWriteCallBack() {
@Override
public void onSuccess() {
ToastUtils.info("清零成功!");
}
@@ -542,7 +578,7 @@ public class silos_jiaoyan extends LinearLayout {
ToastUtils.warning("出料重量不能为空!");
return;
}
double zl = 0;
double zl = 0;//需求重量。
try {
zl = Double.parseDouble(zltext);
} catch (Exception e) {
@@ -554,39 +590,225 @@ public class silos_jiaoyan extends LinearLayout {
return;
}

if (ConfigName.getInstance().versionSelectionEnum.equals("奶茶机"))
{
if (!ExecuteTheRecipe.IsCup) {
ToastUtils.warning("出料口没有检测到器皿!");
return;
}
}
// if (ConfigName.getInstance().versionSelectionEnum.equals("奶茶机"))
// {
// if (!ExecuteTheRecipe.IsCup) {
// ToastUtils.warning("出料口没有检测到器皿!");
// return;
// }
// }


//short kkk = (short) ((int) (zl * 10));

short kkk = (short) ((int) (zl * 10));
final int[] delayTime=new int[]{0};
if (TypeName.equals("酱料校准")){
delayTime[0]=(int)(ExecuteTheRecipe.getDelayTimeByLCID(lcMode.id,zl)*1000);
}else{
delayTime[0] =(int)(Double.parseDouble(lcMode.jTime)/Double.parseDouble(lcMode.jValue)*zl*1000);
}
if (delayTime[0]<=0){
ToastUtils.error("Simulation Fail,the open motor time must greater than 0");
return;
}
new Thread(new Runnable() {
@Override
public void run() {
try {
ExecuteTheRecipe.WritePLC("配料完成", false, null);
ExecuteTheRecipe.WritePLC("手自切换", true, null);
ExecuteTheRecipe.WritePLC("需求值" + lcMode.num, kkk, new IWriteCallBack() {
// ExecuteTheRecipe.WritePLC("配料完成", false, null);
// ExecuteTheRecipe.WritePLC("手自切换", true, null);
ExecuteTheRecipe.isAutoMode=false;

PLCControl.get().openMotorAndClose(lcMode.num, delayTime[0], new IWriteCallBack() {
@Override
public void onSuccess() {
ExecuteTheRecipe.WritePLC("配料启动", true, null);
ToastUtils.warning("启动成功......");

ToastUtils.success("Start Simulation Success......");
}

@Override
public void onFailure(String ErrorMsg) {
ToastUtils.error("Start Simulation Failure:"+ ErrorMsg);
}
});
} catch (Exception e) {
ToastUtils.error("Simulation Open:"+ e.getMessage());
}
}
}).start();
ToastUtils.info("需求值下发成功!开始配料......");
ToastUtils.info("Start Simulation......");
}
//endregion

//region 酱料校准
/**酱料校准--校准成功自动保存*/
private void JLJZ(){

//region 校验及转换数据
String highLimit=txt_jljz_highLimit.getText().toString().trim();
String lowLimit=txt_jljz_lowLimit.getText().toString().trim();
String text_adjFreq=txt_jljz_adjFreq.getText().toString().trim();

if (lowLimit.isEmpty() || lowLimit.equals("")){
ToastUtils.warning("校准范围下限不能为空!");
return;
}
if (highLimit.isEmpty() || highLimit.equals("")){
ToastUtils.warning("校准范围上限不能为空!");
return;
}
if (text_adjFreq.isEmpty() || text_adjFreq.equals("")){
ToastUtils.warning("校准频率不能为空!");
return;
}

final double weightLowLimit;
final double weightHighLimit;
final int adjFreq;

try {
weightLowLimit=Double.parseDouble(lowLimit);
}catch (Exception e){
ToastUtils.error("校准下限异常!" + e.getMessage());
return;
}
try {
weightHighLimit=Double.parseDouble(highLimit);
}catch (Exception e){
ToastUtils.error("校准上限异常!" + e.getMessage());
return;
}
try {
adjFreq=Integer.parseInt(text_adjFreq);
}catch (Exception e){
ToastUtils.error("校准频率异常!" + e.getMessage());
return;
}
if (weightLowLimit<0 || (weightLowLimit>=weightHighLimit)){
ToastUtils.error("校准范围值异常,下限应大于0,且小于上限值!");
return;
}
//endregion

btn_jljz_startAdj.setEnabled(false);
btn_jljz_startAdj.setText("正在校准...");
new Thread(new Runnable() {
@Override
public void run() {
try {
ExecuteTheRecipe.isAutoMode=false;
final double[] currentWeight=new double[]{0};
currentWeight[0]=ExecuteTheRecipe.OutletWeigh/10;
//出料时间及出料重量对比表。
//HashMap<Double,Double> outMaterialMap=new HashMap<Double, Double>();

WeightedObservedPoints points=new WeightedObservedPoints();
long startTime=System.currentTimeMillis();
ToastUtils.info("开始酱料校准,时间较长,请耐心等待。");
while (currentWeight[0]<=weightHighLimit){
// PLCControl.get().openMotorAndClose(lcMode.num, adjFreq * 1000, new IWriteCallBack() {
// @Override
// public void onSuccess() {
// currentWeight[0]=ExecuteTheRecipe.OutletWeigh/10;
// if (currentWeight[0]>=weightLowLimit){
// //出料时间
// long outTime=System.currentTimeMillis()-startTime;
// double time=((double)outTime)/1000;
// outMaterialMap.put(time,currentWeight[0]);
// }
// }
// @Override
// public void onFailure(String ErrorMsg) {
// //ToastUtils.error("酱料校准开关电机错误,校准失败");
// }
// });
PLCControl.get().openMotor(lcMode.num, new IWriteCallBack() {
@Override
public void onSuccess() {
try {
Thread.sleep(adjFreq*1000);
PLCControl.get().closeMotor(lcMode.num, new IWriteCallBack() {
@Override
public void onSuccess() {
currentWeight[0]=ExecuteTheRecipe.OutletWeigh/10.0;
if (currentWeight[0]>=weightLowLimit){
//出料时间
long outTime=System.currentTimeMillis()-startTime;
double time=((double)outTime)/1000;
//outMaterialMap.put(time,currentWeight[0]);
//方程式里,x是重量,Y才是时间
points.add(currentWeight[0],time);
}
}
@Override
public void onFailure(String ErrorMsg) {

}
});
} catch (Exception e) {
ToastUtils.error("酱料校准错误 :"+e.getMessage());
}
}
@Override
public void onFailure(String ErrorMsg) {

}
});

}
//没出错就保存。
//String result= jzDataToString(outMaterialMap);
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
new QMUIDialog.MessageDialogBuilder(activity).setTitle("确定要保存该酱料校准结果吗?")
.setCanceledOnTouchOutside(false)
.addAction("确认", new QMUIDialogAction.ActionListener() {
@Override
public void onClick(QMUIDialog dialog, int index) {
//Toast.makeText(activity.getApplicationContext(), "确认", Toast.LENGTH_SHORT).show();

//region 生成公式
//公式多项式阶数
int degree=3;

// 创建 PolynomialCurveFitter 对象,并进行多项式回归拟合
PolynomialCurveFitter fitter = PolynomialCurveFitter.create(degree);
double[] coefficients = fitter.fit(points.toList());

// 打印回归方程的系数
// for (int i = 0; i < coefficients.length; i++) {
// System.out.print(coefficients[i] + " ");
// }
//endregion

dialog.dismiss();
//lcMode.bcsfValue=result;
QueryDB.UpdateSilosBcsfValue(lcMode.id,String.valueOf(weightLowLimit),String.valueOf(weightHighLimit),String.valueOf(adjFreq));
//QueryDB.UpdateSilosBcsfValue(lcMode.id, result);
QueryDB.UpdateSilosBcsfValue(lcMode.id, Arrays.toString(coefficients));
//ToastUtils.success("酱料校准结果保存成功!");
MessageLog.ShowUserMessage(UserLogEnum.角色操作日志,lcMode.num+"仓位酱料校准结果保存成功。");
}
}).addAction("取消", new QMUIDialogAction.ActionListener() {
@Override
public void onClick(QMUIDialog dialog, int index) {
//Toast.makeText(activity.getApplicationContext(), "取消", Toast.LENGTH_SHORT).show();
dialog.dismiss();
}
}).create(AlertDialogUtils.mCurrentDialogStyle).show();
}
});
//ToastUtils.success("酱料校准结束,数据已保存。");
}catch (Exception ex){
ToastUtils.error("酱料校准失败:"+ex.getMessage());
}finally {
activity.runOnUiThread(()->{
btn_jljz_startAdj.setEnabled(true);
btn_jljz_startAdj.setText("开始校准");
});
}

}
}).start();
}
//endregion

@@ -633,17 +855,17 @@ public class silos_jiaoyan extends LinearLayout {
ToastUtils.error("时间异常!" + e.getMessage());
return;
}
ExecuteTheRecipe.WritePLC("反转时间", (short) ftime_1, new IWriteCallBack() {
@Override
public void onSuccess() {
ToastUtils.info("反转时间保存成功!");
}
@Override
public void onFailure(String ErrorMsg) {
ToastUtils.error("反转时间保存失败!");
}
});
// ExecuteTheRecipe.WritePLC("反转时间", (short) ftime_1, new IWriteCallBack() {
// @Override
// public void onSuccess() {
// ToastUtils.info("反转时间保存成功!");
// }
//
// @Override
// public void onFailure(String ErrorMsg) {
// ToastUtils.error("反转时间保存失败!");
// }
// });
}
lcMode.fTime=ftime;
lcMode.jTime=stime;
@@ -655,53 +877,70 @@ public class silos_jiaoyan extends LinearLayout {
QueryDB.UpdateSilosJZTime(item.id, stime, ftime);
}
QueryDB.UpdateJYZ(lcMode.id, zl);
ExecuteTheRecipe.WritePLC("基准时间", (short) stime_1, new IWriteCallBack() {
@Override
public void onSuccess() {
ToastUtils.info("校准基准时间保存成功!");
}

@Override
public void onFailure(String ErrorMsg) {
ToastUtils.error("校准基准时间保存失败!");
}
});
ToastUtils.success("物料校准时间保存成功!");

// ExecuteTheRecipe.WritePLC("基准时间", (short) stime_1, new IWriteCallBack() {
// @Override
// public void onSuccess() {
// ToastUtils.info("校准基准时间保存成功!");
// }
//
// @Override
// public void onFailure(String ErrorMsg) {
// ToastUtils.error("校准基准时间保存失败!");
// }
// });
}
//endregion

//region 物料校准
public void WLJZ() {

//判断是否为果糖->判断温度
if (ConfigName.getInstance().versionSelectionEnum.equals("奶茶机")) {
if (lcMode.num == 11) {
if (ExecuteTheRecipe.SugarTempLeft < ExecuteTheRecipe.SugarTempLeft_SZ) {
ToastUtils.warning("果糖左仓温度未达到设置值,不允许校准...");
return;
}
} else if (lcMode.num == 12) {
if (ExecuteTheRecipe.SugarTempRight < ExecuteTheRecipe.SugarTempRight_SZ) {
ToastUtils.warning("果糖右仓温度未达到设置值,不允许校准...");
return;
}
}
//TODO:重写物料校准。

//region 物料校准--可提取为内部方法
String stime = wljz1.getText().toString();
String ftime = wljz2.getText().toString();

if (stime.equals("")) {
ToastUtils.warning("校准基准时间不能为空!");
return;
}
final int[] stime_1 = {0};

try {
stime_1[0] = (int) Math.round((Double.parseDouble(stime)));
} catch (Exception e) {
ToastUtils.error("时间异常!" + e.getMessage());
return;
}
//endregion

new Thread(new Runnable() {
@Override
public void run() {
try {
ExecuteTheRecipe.WritePLC("校准完成", false, null);
ExecuteTheRecipe.WritePLC("手自切换", false, null);
ExecuteTheRecipe.WritePLC("通道校准", true, new IWriteCallBack() {
ExecuteTheRecipe.isAutoMode=false;
PLCControl.get().openMotor(lcMode.num, new IWriteCallBack() {
@Override
public void onSuccess() {
ToastUtils.info("启动通道校准成功!");
new Handler(Looper.getMainLooper()).postDelayed(()->{
PLCControl.get().closeMotor(lcMode.num, new IWriteCallBack() {
@Override
public void onSuccess() {
ToastUtils.info("通道校准完成--请确认重量!");
}
@Override
public void onFailure(String ErrorMsg) {
ToastUtils.error("通道校准---关闭通道失败!");
}
});
},stime_1[0]*1000);
}

@Override
public void onFailure(String ErrorMsg) {
ToastUtils.error("启动通道校准失败!");
ToastUtils.error("通道校准---开启通道失败!");
}
});
} catch (Exception e) {
@@ -807,4 +1046,30 @@ public class silos_jiaoyan extends LinearLayout {
}
//endregion


//region 数据校验
/**物料校准参数校验*/
private void validateForWLJZ(){

}
//endregion


/**键值都为Double的HashMap转换为字符串,提供给酱料校准使用。*/
private String jzDataToString(Map<Double,Double> hashMap){
String result="";
if (hashMap.isEmpty()){
result= "";
}
StringBuilder stringBuilder=new StringBuilder();
for (Map.Entry<Double,Double> entry:hashMap.entrySet()){
stringBuilder.append(entry.getKey()).append(",").append(entry.getValue()).append("|");
}
if (stringBuilder.length()>0){
stringBuilder.setLength(stringBuilder.length()-1);
result=stringBuilder.toString();
}
return result;
}

}

+ 0
- 16
app/src/main/res/layout/fragment_make_good.xml Vedi File

@@ -136,22 +136,6 @@
android:textColor="@color/green_primary"
android:textSize="@dimen/TitleSize" />

<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="水箱:"
android:textSize="@dimen/TitleSize" />

<TextView
android:id="@+id/wendu1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="5dp"
android:text="89.9°C"
android:textColor="@color/green_primary"
android:textSize="@dimen/TitleSize" />

<TextView
android:id="@+id/cheng_clear"
android:layout_width="wrap_content"


+ 1
- 1
app/src/main/res/layout/fragment_she_zhi.xml Vedi File

@@ -72,7 +72,7 @@
</LinearLayout>
</RelativeLayout>

<RelativeLayout
<RelativeLayout android:visibility="gone"
android:id="@+id/wdsz"
android:layout_width="0dp"
android:layout_height="match_parent"


+ 3
- 0
app/src/main/res/layout/item/layout/dialog_add_silos_ck.xml Vedi File

@@ -9,6 +9,7 @@
android:clickable="true">

<RelativeLayout
android:id="@+id/menu_silo"
android:layout_centerInParent="true"
android:layout_margin="20dp"
android:layout_width="400dp"
@@ -148,6 +149,7 @@
android:textSize="18sp"/>

<Button
android:visibility="gone"
android:layout_marginTop="@dimen/dp_10"
android:id="@+id/control_huishou"
android:layout_width="60dp"
@@ -340,6 +342,7 @@
android:layout_width="400dp"
android:layout_height="400dp"
android:orientation="horizontal"
android:focusable="true"
android:background="@drawable/common_bg_with_radius_and_border">
<LinearLayout
android:layout_centerInParent="true"


+ 2
- 2
app/src/main/res/layout/item/layout/fragment_silos_item_jiaoyan.xml Vedi File

@@ -721,9 +721,9 @@
android:layout_centerInParent="true"
android:fontFamily="sans-serif-medium"
android:text="128.0g"
android:textColor="@color/white"
android:textSize="20dp"
android:textStyle="bold|italic"
android:textColor="@color/white"/>
android:textStyle="bold|italic" />
</RelativeLayout>
<RelativeLayout
android:layout_marginTop="10dp"


+ 19
- 15
app/src/main/res/layout/item/layout/silos_jiaoyan_item.xml Vedi File

@@ -485,6 +485,7 @@
android:textAlignment="center"
android:textSize="16dp"/>
<EditText
android:id="@+id/txt_jljz_lowLimit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
@@ -508,6 +509,7 @@
android:background="@color/color3"/>
</RelativeLayout>
<EditText
android:id="@+id/txt_jljz_highLimit"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
@@ -531,11 +533,12 @@
android:textSize="16dp"
/>
<EditText
android:id="@+id/txt_jljz_adjFreq"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:background="@drawable/input_bj"
android:digits="0123456789."
android:digits="0123456789"
android:hint="请输入"
android:inputType="text"
android:maxLines="1"
@@ -545,6 +548,7 @@
android:layout_marginBottom="10dp"
/>
<Button
android:id="@+id/btn_jljz_startAdj"
android:layout_width="match_parent"
android:layout_height="40dp"
android:layout_centerHorizontal="true"
@@ -646,20 +650,20 @@
/>
</LinearLayout>

<RelativeLayout
android:focusable="true"
android:clickable="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#BE000000">
<TextView
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="研发中..."
android:textSize="40dp"
android:textColor="#DA1CD7"></TextView>
</RelativeLayout>
<!-- <RelativeLayout-->
<!-- android:focusable="true"-->
<!-- android:clickable="true"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="match_parent"-->
<!-- android:background="#BE000000">-->
<!-- <TextView-->
<!-- android:layout_centerInParent="true"-->
<!-- android:layout_width="wrap_content"-->
<!-- android:layout_height="wrap_content"-->
<!-- android:text="研发中..."-->
<!-- android:textSize="40dp"-->
<!-- android:textColor="#DA1CD7"></TextView>-->
<!-- </RelativeLayout>-->

</RelativeLayout>
</LinearLayout>


Caricamento…
Annulla
Salva