ソースを参照

配料吧台业务开发

调味吧台
pry 6ヶ月前
コミット
54d64ae59d
17個のファイルの変更835行の追加1690行の削除
  1. +7
    -0
      .idea/misc.xml
  2. +39
    -21
      app/src/main/java/com/bonait/bnframework/HBL/Dialog/DialogManager.java
  3. +46
    -0
      app/src/main/java/com/bonait/bnframework/HBL/Dialog/WaitDialog.java
  4. +5
    -0
      app/src/main/java/com/bonait/bnframework/HBL/Interface/IFunc.java
  5. +3
    -2
      app/src/main/java/com/bonait/bnframework/HBL/Result/OperateResult.java
  6. +14
    -3
      app/src/main/java/com/bonait/bnframework/HBL/Trig/RTrig.java
  7. +53
    -0
      app/src/main/java/com/bonait/bnframework/HBL/Trig/TTrig.java
  8. +73
    -0
      app/src/main/java/com/bonait/bnframework/HBL/Unity.java
  9. +139
    -76
      app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java
  10. +5
    -0
      app/src/main/java/com/bonait/bnframework/business/PLCControl.java
  11. +13
    -0
      app/src/main/java/com/bonait/bnframework/business/PLCName.java
  12. +65
    -242
      app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java
  13. +13
    -3
      app/src/main/java/com/bonait/bnframework/common/db/QueryDB.java
  14. +12
    -0
      app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_SILOS_CALIBRATE.java
  15. +1
    -1
      app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigationMainActivity.java
  16. +139
    -606
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/silos_jiaoyan.java
  17. +208
    -736
      app/src/main/res/layout/item/layout/silos_jiaoyan_item_edit.xml

+ 7
- 0
.idea/misc.xml ファイルの表示

@@ -1,4 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="corretto-11" project-jdk-type="JavaSDK" />
<component name="VisualizationToolProject">
<option name="state">
<ProjectState>
<option name="scale" value="0.5" />
</ProjectState>
</option>
</component>
</project>

+ 39
- 21
app/src/main/java/com/bonait/bnframework/HBL/Dialog/DialogManager.java ファイルの表示

@@ -202,7 +202,7 @@ public class DialogManager {
public static void showInfo(String message, AlertDialogButton btn, IDialogAction action) {
if(mActivity!=null)
mActivity.runOnUiThread(()->{showDialog(message,btn,DialogType.提示,action);});
else showDialog(message,btn,DialogType.提示,action);
else if(mContext!=null) showDialog(message,btn,DialogType.提示,action);
}

/**
@@ -214,7 +214,7 @@ public class DialogManager {
public static void showWarn(String message, AlertDialogButton btn, IDialogAction action) {
if(mActivity!=null)
mActivity.runOnUiThread(()->{showDialog(message,btn,DialogType.警告,action);});
else showDialog(message,btn,DialogType.警告,action);
else if(mContext!=null) showDialog(message,btn,DialogType.警告,action);
}

/**
@@ -226,7 +226,7 @@ public class DialogManager {
public static void showError(String message, AlertDialogButton btn, IDialogAction action) {
if(mActivity!=null)
mActivity.runOnUiThread(()->{showDialog(message,btn,DialogType.错误,action);});
else showDialog(message,btn,DialogType.错误,action);
else if(mContext!=null) showDialog(message,btn,DialogType.错误,action);
}


@@ -238,9 +238,12 @@ public class DialogManager {
* @param action 执行回调
*/
public static void showInfo( Context ct,String message, AlertDialogButton btn, IDialogAction action) {
if(mActivity!=null)
mActivity.runOnUiThread(()->{showDialog(ct,message,btn,DialogType.提示,action);});
else showDialog(ct,message,btn,DialogType.提示,action);
if(ct!=null)
showDialog(ct,message,btn,DialogType.提示,action);
else {
if(mActivity!=null)showDialog(mActivity,message,btn,DialogType.提示,action);
else if (mContext!=null)showDialog(mContext,message,btn,DialogType.提示,action);
}
}

/**
@@ -250,9 +253,12 @@ public class DialogManager {
* @param action 执行回调
*/
public static void showWarn( Context ct,String message, AlertDialogButton btn, IDialogAction action) {
if(mActivity!=null)
mActivity.runOnUiThread(()->{showDialog(ct,message,btn,DialogType.警告,action);});
else showDialog(ct,message,btn,DialogType.警告,action);
if(ct!=null)
showDialog(ct,message,btn,DialogType.警告,action);
else {
if(mActivity!=null)showDialog(mActivity,message,btn,DialogType.警告,action);
else if (mContext!=null)showDialog(mContext,message,btn,DialogType.警告,action);
}
}

/**
@@ -262,9 +268,12 @@ public class DialogManager {
* @param action 执行回调
*/
public static void showError( Context ct,String message, AlertDialogButton btn, IDialogAction action) {
if(mActivity!=null)
mActivity.runOnUiThread(()->{showDialog(ct,message,btn,DialogType.错误,action);});
else showDialog(ct,message,btn,DialogType.错误,action);
if(ct!=null){
showDialog(ct,message,btn,DialogType.错误,action);
}else {
if(mActivity!=null)showDialog(mActivity,message,btn,DialogType.错误,action);
else if (mContext!=null)showDialog(mContext,message,btn,DialogType.错误,action);
}
}


@@ -276,9 +285,12 @@ public class DialogManager {
* @param action 执行回调
*/
public static void showInfo( Activity activity,String message, AlertDialogButton btn, IDialogAction action) {
if(mActivity!=null)
mActivity.runOnUiThread(()->{showDialog(activity,message,btn,DialogType.提示,action);});
else showDialog(activity,message,btn,DialogType.提示,action);
if(activity!=null)
activity.runOnUiThread(()->{showDialog(activity,message,btn,DialogType.提示,action);});
else {
if(mActivity!=null)showDialog(mActivity,message,btn,DialogType.提示,action);
else if (mContext!=null)showDialog(mContext,message,btn,DialogType.提示,action);
}
}

/**
@@ -288,9 +300,12 @@ public class DialogManager {
* @param action 执行回调
*/
public static void showWarn(Activity activity,String message, AlertDialogButton btn, IDialogAction action) {
if(mActivity!=null)
mActivity.runOnUiThread(()->{showDialog(activity,message,btn,DialogType.警告,action);});
else showDialog(activity,message,btn,DialogType.警告,action);
if(activity!=null)
activity.runOnUiThread(()->{showDialog(activity,message,btn,DialogType.警告,action);});
else {
if(mActivity!=null)showDialog(mActivity,message,btn,DialogType.警告,action);
else if (mContext!=null)showDialog(mContext,message,btn,DialogType.警告,action);
}
}

/**
@@ -300,9 +315,12 @@ public class DialogManager {
* @param action 执行回调
*/
public static void showError( Activity activity,String message, AlertDialogButton btn, IDialogAction action) {
if(mActivity!=null)
mActivity.runOnUiThread(()->{showDialog(activity,message,btn,DialogType.错误,action);});
else showDialog(activity,message,btn,DialogType.错误,action);
if(activity!=null)
activity.runOnUiThread(()->{showDialog(activity,message,btn,DialogType.错误,action);});
else {
if(mActivity!=null)showDialog(mActivity,message,btn,DialogType.错误,action);
else if (mContext!=null)showDialog(mContext,message,btn,DialogType.错误,action);
}
}

}


+ 46
- 0
app/src/main/java/com/bonait/bnframework/HBL/Dialog/WaitDialog.java ファイルの表示

@@ -0,0 +1,46 @@
package com.bonait.bnframework.HBL.Dialog;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;

import com.bonait.bnframework.R;

public class WaitDialog {

static Context context;
static Activity activity;
static ProgressDialog progressDialog;

public static void Show(String title,String msg,Context _context,Activity _activity){
context=_context;
activity=_activity;
if(context==null) return;
progressDialog = new ProgressDialog(context);
progressDialog.setTitle(title);
progressDialog.setCancelable(false);
progressDialog.setMessage(msg);
progressDialog.show();
}

public static void AddText(String info){
if(context==null) return;
if(activity==null) return;
if(progressDialog==null) return;
activity.runOnUiThread(()->{ progressDialog.setMessage(info);});
}

public static void Dismiss(){
if(activity==null) return;
if(progressDialog==null) return;
activity.runOnUiThread(()->{ progressDialog.dismiss();});
}

public static void TimeOut(String info){
if(activity==null) return;
if(progressDialog==null) return;
Dismiss();
DialogManager.showError(activity,info,AlertDialogButton.OK,null);
}
}

+ 5
- 0
app/src/main/java/com/bonait/bnframework/HBL/Interface/IFunc.java ファイルの表示

@@ -0,0 +1,5 @@
package com.bonait.bnframework.HBL.Interface;

public interface IFunc {
boolean Run();
}

+ 3
- 2
app/src/main/java/com/bonait/bnframework/HBL/Result/OperateResult.java ファイルの表示

@@ -1,6 +1,7 @@
package com.bonait.bnframework.HBL.Result;

import com.bonait.bnframework.HBL.Interface.IRun;
import com.bonait.bnframework.HBL.Interface.IRunT;
import com.bonait.bnframework.HBL.Logs.MessageLog;

public class OperateResult extends IResult {
@@ -41,9 +42,9 @@ public class OperateResult extends IResult {
return this;
}

public OperateResult OnFailed(IRun action){
public OperateResult OnFailed(IRunT<String> action){
try{
if(action!=null&&!getIsSuccess())action.Run();
if(action!=null&&!getIsSuccess())action.Run(message);
}catch(Exception e){
MessageLog.ShowError(e);
}


+ 14
- 3
app/src/main/java/com/bonait/bnframework/HBL/Trig/RTrig.java ファイルの表示

@@ -20,6 +20,12 @@ public class RTrig {
return _Instance.get(name);
}

public static void Remove(String name){
if(_Instance!=null&&_Instance.containsKey(name)){
_Instance.remove(name);
}
}

private RTrig() {
}

@@ -35,10 +41,15 @@ public class RTrig {
flag = falag;
}

public void Start(boolean IN, IRun callback) {
public boolean Start(boolean IN, IRun callback) {
setIN(IN);
if (Q)
callback.Run();
if (Q&&callback!=null)callback.Run();
return Q;
}

public boolean Start(boolean IN) {
setIN(IN);
return Q;
}

}

+ 53
- 0
app/src/main/java/com/bonait/bnframework/HBL/Trig/TTrig.java ファイルの表示

@@ -0,0 +1,53 @@
package com.bonait.bnframework.HBL.Trig;

import com.bonait.bnframework.HBL.Interface.IRun;

import java.util.concurrent.ConcurrentHashMap;

/**
* 下降沿操作类
*/
public class TTrig {
private static volatile ConcurrentHashMap<String, TTrig> _Instance;

public static TTrig get(String name) {
if (_Instance == null)
_Instance = new ConcurrentHashMap<String, TTrig>();
if (!_Instance.containsKey(name))
_Instance.put(name, new TTrig());
return _Instance.get(name);
}

public static void Remove(String name){
if(_Instance!=null&&_Instance.containsKey(name)){
_Instance.remove(name);
}
}

private TTrig() {
}

private boolean flag=false;
private boolean Q=false;

public boolean getQ() {
return Q;
}

private void setIN(boolean falag) {
Q = !falag && flag;
flag = falag;
}

public boolean Start(boolean IN, IRun callback) {
setIN(IN);
if (Q&&callback!=null)callback.Run();
return Q;
}

public boolean Start(boolean IN) {
setIN(IN);
return Q;
}

}

+ 73
- 0
app/src/main/java/com/bonait/bnframework/HBL/Unity.java ファイルの表示

@@ -0,0 +1,73 @@
package com.bonait.bnframework.HBL;

import com.bonait.bnframework.HBL.Dialog.AlertDialogButton;
import com.bonait.bnframework.HBL.Dialog.DialogManager;
import com.bonait.bnframework.HBL.Interface.IFunc;
import com.bonait.bnframework.HBL.Result.OperateResult;

public class Unity {

public static void Delay(long miss){
try{
Thread.sleep(miss);
}catch (Exception e){}
}

/**
* 阻塞等待条件满足
* @param func
* @param timeOut
* @return
*/
public static OperateResult Wait(IFunc func, int timeOut){
long startTime = System.currentTimeMillis();
if(func==null) return OperateResult.CreateFailed("条件为空");
while(!func.Run()){
Delay(10);
if(timeOut>0&&(System.currentTimeMillis()-startTime)>timeOut) break;
}
return func.Run()?OperateResult.CreateSuccess():OperateResult.CreateFailed("任务超时");
}

/**
* 地址拼接
* @param Prefix 地址标头
* @param num 地址偏移量
* @param StartAdd 起始地址
* @return 例如:M6.6=GetSiemensBitSingleAdd("M",15,5)
*/
public static String GetSiemensBitSingleAdd(String Prefix, int num, int StartAdd)
{
String result = "";
if (num > 0) {
int FirstAdd = num / 8;
int EndAdd = num % 8;
if (EndAdd == 0)
{
FirstAdd--;
EndAdd = 7;
}
else EndAdd--;
result =Prefix+(FirstAdd + StartAdd)+"."+ EndAdd;
return result;
}
return result;
}


/**
* 整形数据缩放
* @param InputValue 需要缩放的值
* @param InputMax 需要缩放的最大值
* @param InputMin 需要缩放的最小值
* @param OutMax 缩放后的最大值
* @param OutMin 缩放后的最下值
* @return
*/
public static int Scale( int InputValue, int InputMax, int InputMin, int OutMax, int OutMin)
{
int value = ((OutMax - OutMin) * (InputValue - InputMin)) / (InputMax - InputMin) + OutMin;
return value;
}

}

+ 139
- 76
app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java ファイルの表示

@@ -4,12 +4,14 @@ import android.app.Activity;
import android.content.Context;
import android.content.ContextWrapper;
import android.media.MediaPlayer;
import android.net.wifi.rtt.WifiRttManager;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;

import androidx.annotation.NonNull;

import com.bonait.bnframework.HBL.Unity;
import com.bonait.bnframework.R;
import com.bonait.bnframework.common.constant.ConfigName;
import com.bonait.bnframework.common.constant.DataBus;
@@ -18,6 +20,7 @@ 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.mode.BPA_SILOS_CALIBRATE;
import com.bonait.bnframework.common.db.res.AlertLogEnum;
import com.bonait.bnframework.common.db.res.ResGoodsMake;
import com.bonait.bnframework.common.db.res.ResGoodsRecipe;
@@ -185,26 +188,48 @@ public class ExecuteTheRecipe {
* @param name m名称
* @param time 时间 毫秒
*/
public static void BottomClick(String name,long time)
{
try
{
WritePLC(name,true,null);
new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
@Override
public void run() {
ExecuteTheRecipe.WritePLC(name, false, null);
}
}, time);
}catch (Exception ex)
{
}
}
// public static void BottomClick(String name,long time)
// {
// try
// {
// WritePLC(name,true,null);
// new Handler(Looper.getMainLooper()).postDelayed(new Runnable() {
// @Override
// public void run() {
// ExecuteTheRecipe.WritePLC(name, false, null);
// }
// }, time);
// }catch (Exception ex)
// {
//
// }
// }
//endregion

//region PLC监听线程
static List<String> names=new ArrayList<>();
/**
* 心跳标志
*/
static boolean HeartbeatMarkers=false;
static long StartTime=0;
static void Heart(){
if(!HeartbeatMarkers&&(System.currentTimeMillis()-StartTime)>=3000) {
Write("心跳",true,null);
HeartbeatMarkers=true;
StartTime=System.currentTimeMillis();
}

if(HeartbeatMarkers&&(System.currentTimeMillis()-StartTime)>=3000){
Write("心跳",false,null);
HeartbeatMarkers=false;
StartTime=System.currentTimeMillis();
}

Write("掉线标志",false,null);
}


public static void Listening() {

ConfigName.getInstance().PLC_Address.clear();
@@ -215,48 +240,50 @@ public class ExecuteTheRecipe {
}
}

names.clear();
if (ConfigName.getInstance().versionSelectionEnum.equals("配料吧台")) {
names.add("水池温度");
}else if (ConfigName.getInstance().versionSelectionEnum.equals("奶茶机"))
{
names.add("水池温度");
names.add("果糖左温度");
names.add("果糖右温度");
}
new Thread(new Runnable() {
@Override
public void run() {
//1.自动模式
ExecuteTheRecipe.WritePLC("手自切换",true,null);
//1.清除开关
for (int i=1;i<=20;i++)
{
ExecuteTheRecipe.WritePLC("通道"+i+"校准开关",false,null);
}
for (int i=1;i<=20;i++)
{
ExecuteTheRecipe.WritePLC("手动控制"+i,false,null);
}
}
}).start();
// names.clear();
// if (ConfigName.getInstance().versionSelectionEnum.equals("配料吧台")) {
// names.add("水池温度");
// }else if (ConfigName.getInstance().versionSelectionEnum.equals("奶茶机"))
// {
// names.add("水池温度");
// names.add("果糖左温度");
// names.add("果糖右温度");
// }
// new Thread(new Runnable() {
// @Override
// public void run() {
// //1.自动模式
// ExecuteTheRecipe.WritePLC("手自切换",true,null);
// //1.清除开关
// for (int i=1;i<=20;i++)
// {
// ExecuteTheRecipe.WritePLC("通道"+i+"校准开关",false,null);
// }
//
// for (int i=1;i<=20;i++)
// {
// ExecuteTheRecipe.WritePLC("手动控制"+i,false,null);
// }
// }
// }).start();

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

//状态读取
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);
}
}

Heart();//心跳处理

if(!IsMakeGood)
{
@@ -268,7 +295,7 @@ public class ExecuteTheRecipe {
} catch (Exception ex) {
ToastUtils.error("异常信息:" + ex.getMessage());
}
Thread.sleep(500);
Thread.sleep(10);
}

@Override
@@ -323,25 +350,25 @@ public class ExecuteTheRecipe {
}
});

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);
}
@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);
// }
//
// @Override
// public void RunComplete() throws InterruptedException {
//
// }
// });

ThreadManager.Get().StartLong("PLC设备数据监听-信号检测", true, new IThread() {
@Override
@@ -409,7 +436,15 @@ public class ExecuteTheRecipe {
} 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);

BPA_SILOS_CALIBRATE res = QueryDB.GetSilosCalibrateByNum(silos.num);
if(res!=null){
String name = silos.name+silos.num+"出料时间";
int outValue = Unity.Scale(_val,res.inputWightMax,res.inputWightMin,res.outputTimeMax,res.outputTimeMin);
WritePLC(name, (short) outValue, null);
}else{ MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, message + "下发失败!物料没有对应的校准值!");}



//減去料仓数量
int otherG=silos.silosmargin-(_val/10);
@@ -527,6 +562,10 @@ public class ExecuteTheRecipe {
}
}

public static void Write(Object plcName,Object value,IWriteCallBack callBack){
WritePLC(plcName.toString(),value,callBack);
}

/**
* 读PLC数据
*
@@ -581,6 +620,30 @@ public class ExecuteTheRecipe {
}
}

public static boolean ReadBool(Object plcName){
try{
return Boolean.getBoolean(ReadPLC(plcName.toString()).toString());
}catch(Exception e){
return false;
}
}

public static short ReadShort(Object plcName){
try{
return Short.parseShort(ReadPLC(plcName.toString()).toString());
}catch(Exception e){
return 0;
}
}

public static int ReadInt(Object plcName){
try{
return Integer.getInteger(ReadPLC(plcName.toString()).toString());
}catch(Exception e){
return 0;
}
}

/**
* 读PLC数据
*
@@ -710,13 +773,13 @@ public class ExecuteTheRecipe {
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) -> {
ModbusTcpServer.get().ReadString(plcaddress.address, 39, (data) -> {

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

//记录上一次读取PLC 扫码数据


+ 5
- 0
app/src/main/java/com/bonait/bnframework/business/PLCControl.java ファイルの表示

@@ -0,0 +1,5 @@
package com.bonait.bnframework.business;

public class PLCControl {

}

+ 13
- 0
app/src/main/java/com/bonait/bnframework/business/PLCName.java ファイルの表示

@@ -0,0 +1,13 @@
package com.bonait.bnframework.business;

public enum PLCName {
重量清零,
当前重量,
外置仓1出料时间,
外置仓2出料时间,
外置仓3出料时间,
外置仓4出料时间,
外置仓5出料时间,


}

+ 65
- 242
app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java ファイルの表示

@@ -6,6 +6,7 @@ import android.content.Context;
import androidx.fragment.app.Fragment;
import androidx.fragment.app.FragmentManager;

import com.bonait.bnframework.HBL.Unity;
import com.bonait.bnframework.R;
import com.bonait.bnframework.common.db.mode.BPA_PLCADDRESS;
import com.bonait.bnframework.common.db.mode.BPA_SILOS;
@@ -556,260 +557,82 @@ public class ConfigName {
*/
public List<Res_PLCADDRESS> PlcAddress_配料吧台 = new ArrayList<Res_PLCADDRESS>() {{

//通道校准
add(new Res_PLCADDRESS("通道校准", "-------------", 0, 0));
add(new Res_PLCADDRESS("校准值1", "VW0", 1, 1));
add(new Res_PLCADDRESS("校准值2", "VW2", 1, 1));
add(new Res_PLCADDRESS("校准值3", "VW4", 1, 1));
add(new Res_PLCADDRESS("校准值4", "VW6", 1, 1));
add(new Res_PLCADDRESS("校准值5", "VW8", 1, 1));
add(new Res_PLCADDRESS("校准值6", "VW10", 1, 1));
add(new Res_PLCADDRESS("校准值7", "VW12", 1, 1));
add(new Res_PLCADDRESS("校准值8", "VW14", 1, 1));
add(new Res_PLCADDRESS("校准值9", "VW16", 1, 1));
add(new Res_PLCADDRESS("校准值10", "VW18", 1, 1));
add(new Res_PLCADDRESS("校准值11", "VW20", 1, 1));
add(new Res_PLCADDRESS("校准值12", "VW22", 1, 1));
add(new Res_PLCADDRESS("校准值13", "VW24", 1, 1));
add(new Res_PLCADDRESS("校准值14", "VW26", 1, 1));
add(new Res_PLCADDRESS("校准值15", "VW28", 1, 1));
add(new Res_PLCADDRESS("校准值16", "VW30", 1, 1));
add(new Res_PLCADDRESS("校准值17", "VW32", 1, 1));
add(new Res_PLCADDRESS("校准值18", "VW34", 1, 1));
add(new Res_PLCADDRESS("校准值19", "VW36", 1, 1));
add(new Res_PLCADDRESS("校准值20", "VW38", 1, 1));

add(new Res_PLCADDRESS("通道1校准开关", "M2.0", 1, 1));
add(new Res_PLCADDRESS("通道2校准开关", "M2.1", 1, 1));
add(new Res_PLCADDRESS("通道3校准开关", "M2.2", 1, 1));
add(new Res_PLCADDRESS("通道4校准开关", "M2.3", 1, 1));
add(new Res_PLCADDRESS("通道5校准开关", "M2.4", 1, 1));
add(new Res_PLCADDRESS("通道6校准开关", "M2.5", 1, 1));
add(new Res_PLCADDRESS("通道7校准开关", "M2.6", 1, 1));
add(new Res_PLCADDRESS("通道8校准开关", "M2.7", 1, 1));
add(new Res_PLCADDRESS("通道9校准开关", "M3.0", 1, 1));
add(new Res_PLCADDRESS("通道10校准开关", "M3.1", 1, 1));
add(new Res_PLCADDRESS("通道11校准开关", "M3.2", 1, 1));
add(new Res_PLCADDRESS("通道12校准开关", "M3.3", 1, 1));
add(new Res_PLCADDRESS("通道13校准开关", "M3.4", 1, 1));
add(new Res_PLCADDRESS("通道14校准开关", "M3.5", 1, 1));
add(new Res_PLCADDRESS("通道15校准开关", "M3.6", 1, 1));
add(new Res_PLCADDRESS("通道16校准开关", "M3.7", 1, 1));
add(new Res_PLCADDRESS("通道17校准开关", "M4.0", 1, 1));
add(new Res_PLCADDRESS("通道18校准开关", "M4.1", 1, 1));
add(new Res_PLCADDRESS("通道19校准开关", "M4.2", 1, 1));
add(new Res_PLCADDRESS("通道20校准开关", "M4.3", 1, 1));

add(new Res_PLCADDRESS("配料次数", "VD90", 1, 1));
add(new Res_PLCADDRESS("反转时间", "VW94", 1, 1));//pl
//add(new Res_PLCADDRESS("基准时间", "VW96", 1, 1));
add(new Res_PLCADDRESS("基准时间", "VW98", 1, 1));

add(new Res_PLCADDRESS("通道校准", "M0.0", 0, 1));
add(new Res_PLCADDRESS("校准完成", "M0.7", 1, 0));

// add(new Res_PLCADDRESS("出料系数1", "VR400", 1, 1));
// add(new Res_PLCADDRESS("出料系数2", "VR404", 1, 1));
// add(new Res_PLCADDRESS("出料系数3", "VR408", 1, 1));
// add(new Res_PLCADDRESS("出料系数4", "VR412", 1, 1));
// add(new Res_PLCADDRESS("出料系数5", "VR416", 1, 1));
// add(new Res_PLCADDRESS("出料系数6", "VR420", 1, 1));
// add(new Res_PLCADDRESS("出料系数7", "VR424", 1, 1));
// add(new Res_PLCADDRESS("出料系数8", "VR428", 1, 1));
// add(new Res_PLCADDRESS("出料系数9", "VR432", 1, 1));
// add(new Res_PLCADDRESS("出料系数10", "VR436", 1, 1));
// add(new Res_PLCADDRESS("出料系数11", "VR440", 1, 1));
// add(new Res_PLCADDRESS("出料系数12", "VR444", 1, 1));
// add(new Res_PLCADDRESS("出料系数13", "VR448", 1, 1));
// add(new Res_PLCADDRESS("出料系数14", "VR452", 1, 1));
// add(new Res_PLCADDRESS("出料系数15", "VR456", 1, 1));
// add(new Res_PLCADDRESS("出料系数16", "VR460", 1, 1));
// add(new Res_PLCADDRESS("出料系数17", "VR464", 1, 1));
// add(new Res_PLCADDRESS("出料系数18", "VR468", 1, 1));
// add(new Res_PLCADDRESS("出料系数19", "VR472", 1, 1));
// add(new Res_PLCADDRESS("出料系数20", "VR476", 1, 1));

//模拟出料
add(new Res_PLCADDRESS("模拟出料", "-------------", 0, 0));
add(new Res_PLCADDRESS("需求值1", "VW100", 1, 1));
add(new Res_PLCADDRESS("需求值2", "VW102", 1, 1));
add(new Res_PLCADDRESS("需求值3", "VW104", 1, 1));
add(new Res_PLCADDRESS("需求值4", "VW106", 1, 1));
add(new Res_PLCADDRESS("需求值5", "VW108", 1, 1));
add(new Res_PLCADDRESS("需求值6", "VW110", 1, 1));
add(new Res_PLCADDRESS("需求值7", "VW112", 1, 1));
add(new Res_PLCADDRESS("需求值8", "VW114", 1, 1));
add(new Res_PLCADDRESS("需求值9", "VW116", 1, 1));
add(new Res_PLCADDRESS("需求值10", "VW118", 1, 1));
add(new Res_PLCADDRESS("需求值11", "VW120", 1, 1));
add(new Res_PLCADDRESS("需求值12", "VW122", 1, 1));
add(new Res_PLCADDRESS("需求值13", "VW124", 1, 1));
add(new Res_PLCADDRESS("需求值14", "VW126", 1, 1));
add(new Res_PLCADDRESS("需求值15", "VW128", 1, 1));
add(new Res_PLCADDRESS("需求值16", "VW130", 1, 1));
add(new Res_PLCADDRESS("需求值17", "VW132", 1, 1));
add(new Res_PLCADDRESS("需求值18", "VW134", 1, 1));
add(new Res_PLCADDRESS("需求值19", "VW136", 1, 1));
add(new Res_PLCADDRESS("需求值20", "VW138", 1, 1));
add(new Res_PLCADDRESS("配料启动", "M0.1", 0, 1));
add(new Res_PLCADDRESS("手自切换", "M0.2", 1, 1));
add(new Res_PLCADDRESS("配料完成", "M0.3", 1, 0));
add(new Res_PLCADDRESS("按钮启动", "M0.5", 1, 0));
add(new Res_PLCADDRESS("配料信号", "-------------", 0, 0));
add(new Res_PLCADDRESS("配料启动", "M0.0", 0, 1));
add(new Res_PLCADDRESS("配料完成", "M0.1", 1, 1));
add(new Res_PLCADDRESS("按钮配料启动", "I0.0", 1, 0));

//出料算法补偿
add(new Res_PLCADDRESS("出料算法补偿", "-------------", 0, 0));
add(new Res_PLCADDRESS("低系数1", "VW44", 1, 1));
add(new Res_PLCADDRESS("低系数2", "VW46", 1, 1));
add(new Res_PLCADDRESS("低系数3", "VW48", 1, 1));
add(new Res_PLCADDRESS("低系数4", "VW50", 1, 1));
add(new Res_PLCADDRESS("低系数5", "VW52", 1, 1));
add(new Res_PLCADDRESS("低系数6", "VW54", 1, 1));
add(new Res_PLCADDRESS("外置仓", "-------------", 0, 0));
for (int i=1;i<=5;i++){
add(new Res_PLCADDRESS("外置仓"+i+"出料时间", "VW"+(98+(i*2)), 0, 1));
add(new Res_PLCADDRESS("外置仓"+i+"启停控制", "M10."+(i-1), 1, 1));
}

add(new Res_PLCADDRESS("高系数1", "VW144", 1, 1));
add(new Res_PLCADDRESS("高系数2", "VW146", 1, 1));
add(new Res_PLCADDRESS("高系数3", "VW148", 1, 1));
add(new Res_PLCADDRESS("高系数4", "VW150", 1, 1));
add(new Res_PLCADDRESS("高系数5", "VW152", 1, 1));
add(new Res_PLCADDRESS("高系数6", "VW154", 1, 1));
add(new Res_PLCADDRESS("加热仓", "-------------", 0, 0));
add(new Res_PLCADDRESS("加热仓1出料时间", "VW110", 0, 1));
add(new Res_PLCADDRESS("加热仓1启停控制", "M10.5", 1, 1));
add(new Res_PLCADDRESS("加热仓2出料时间", "VW112", 0, 1));
add(new Res_PLCADDRESS("加热仓2启停控制", "M10.6", 1, 1));

add(new Res_PLCADDRESS("粉料仓", "-------------", 0, 0));
for (int i=1;i<=6;i++){
add(new Res_PLCADDRESS("粉料仓"+i+"出料时间", "VW"+(112+(i*2)), 0, 1));
add(new Res_PLCADDRESS("粉料仓"+i+"启停控制", Unity.GetSiemensBitSingleAdd("M",7+i,10), 1, 1));
}

add(new Res_PLCADDRESS("补偿1时间", "VW168", 1, 1));
add(new Res_PLCADDRESS("补偿2时间", "VW170", 1, 1));
add(new Res_PLCADDRESS("补偿3时间", "VW172", 1, 1));
add(new Res_PLCADDRESS("补偿4时间", "VW174", 1, 1));
add(new Res_PLCADDRESS("补偿5时间", "VW176", 1, 1));
add(new Res_PLCADDRESS("补偿6时间", "VW178", 1, 1));
add(new Res_PLCADDRESS("液体仓", "-------------", 0, 0));
for (int i=1;i<=4;i++){
add(new Res_PLCADDRESS("液体仓"+i+"出料时间", "VW"+(124+(i*2)), 0, 1));
add(new Res_PLCADDRESS("液体仓"+i+"启停控制", Unity.GetSiemensBitSingleAdd("M",5+i,11), 1, 1));
}

add(new Res_PLCADDRESS("通道1补偿开关", "VW194.0", 1, 1));
add(new Res_PLCADDRESS("通道2补偿开关", "VW194.1", 1, 1));
add(new Res_PLCADDRESS("通道3补偿开关", "VW194.2", 1, 1));
add(new Res_PLCADDRESS("通道4补偿开关", "VW194.3", 1, 1));
add(new Res_PLCADDRESS("通道5补偿开关", "VW194.4", 1, 1));
add(new Res_PLCADDRESS("通道6补偿开关", "VW194.5", 1, 1));
add(new Res_PLCADDRESS("备用仓", "-------------", 0, 0));
for (int i=1;i<=9;i++){
add(new Res_PLCADDRESS("备用仓"+i+"出料时间", "VW"+(132+(i*2)), 0, 1));
add(new Res_PLCADDRESS("备用仓"+i+"启停控制", Unity.GetSiemensBitSingleAdd("M",1+i,12), 1, 1));
}

//电子秤校验
add(new Res_PLCADDRESS("电子秤校验", "-------------", 0, 0));
add(new Res_PLCADDRESS("称当前重量", "VD344", 1, 0));
//add(new Res_PLCADDRESS("砝码值", "VW94", 1, 1));
add(new Res_PLCADDRESS("砝码值", "VW96", 1, 1));
add(new Res_PLCADDRESS("砝码校准模式", "M1.0", 1, 1));
add(new Res_PLCADDRESS("重量清零", "M1.1", 0, 1));
add(new Res_PLCADDRESS("关闭写保护", "M1.2", 0, 1));
add(new Res_PLCADDRESS("零点校准", "M1.3", 0, 1));
add(new Res_PLCADDRESS("砝码值写入", "M1.4", 0, 1));
add(new Res_PLCADDRESS("打开写保护", "M1.5", 0, 1));
add(new Res_PLCADDRESS("清洗状态", "M1.6", 1, 0));

//温度监控
add(new Res_PLCADDRESS("温度控制", "-------------", 0, 0));
// add(new Res_PLCADDRESS("水池温度", "VD354", 1, 0));
// add(new Res_PLCADDRESS("水池温度设置", "VD378", 1, 1));
// add(new Res_PLCADDRESS("水池温度加热", "M104.1", 1, 0));
//
// add(new Res_PLCADDRESS("果糖左温度", "VD358", 1, 0));
// add(new Res_PLCADDRESS("果糖左温度设置", "VD382", 1, 1));
// add(new Res_PLCADDRESS("果糖左温度加热", "M103.7", 1, 0));
//
// add(new Res_PLCADDRESS("果糖右温度", "VD362", 1, 0));
// add(new Res_PLCADDRESS("果糖右温度设置", "VD386", 1, 1));
// add(new Res_PLCADDRESS("果糖右温度加热", "M104.0", 1, 0));

add(new Res_PLCADDRESS("水池温度", "VD352", 1, 0));
add(new Res_PLCADDRESS("水池温度设置", "VD360", 1, 1));
add(new Res_PLCADDRESS("水池温度加热", "M104.0", 1, 0));

//自动清洗
add(new Res_PLCADDRESS("自动清洗", "-------------", 0, 0));
add(new Res_PLCADDRESS("排水阀排水时间", "VW244", 1, 1));
add(new Res_PLCADDRESS("循环清洗时间", "VW246", 1, 1));
add(new Res_PLCADDRESS("加热时间", "VW248", 1, 1));
add(new Res_PLCADDRESS("自动补水延迟时间", "VW250", 1, 1));


add(new Res_PLCADDRESS("清洗模式", "M0.4", 1, 1));
add(new Res_PLCADDRESS("自动清洗开始", "M0.5", 1, 1));
add(new Res_PLCADDRESS("自动清洗完成", "M0.6", 1, 1));


//手动控制
add(new Res_PLCADDRESS("手动控制", "-------------", 0, 0));
add(new Res_PLCADDRESS("手动控制1", "M50.0", 1, 1));
add(new Res_PLCADDRESS("手动控制2", "M50.1", 1, 1));
add(new Res_PLCADDRESS("手动控制3", "M50.2", 1, 1));
add(new Res_PLCADDRESS("手动控制4", "M50.3", 1, 1));
add(new Res_PLCADDRESS("手动控制5", "M50.4", 1, 1));
add(new Res_PLCADDRESS("手动控制6", "M50.5", 1, 1));
add(new Res_PLCADDRESS("手动控制7", "M51.4", 1, 1));
add(new Res_PLCADDRESS("手动控制8", "M51.5", 1, 1));
add(new Res_PLCADDRESS("手动控制9", "M51.6", 1, 1));
add(new Res_PLCADDRESS("手动控制10", "M51.7", 1, 1));
add(new Res_PLCADDRESS("手动控制11", "M52.0", 1, 1));
add(new Res_PLCADDRESS("手动控制12", "M52.1", 1, 1));
add(new Res_PLCADDRESS("手动控制13", "M52.2", 1, 1));
add(new Res_PLCADDRESS("手动控制14", "M52.3", 1, 1));
add(new Res_PLCADDRESS("手动控制15", "M52.4", 1, 1));
add(new Res_PLCADDRESS("手动控制16", "M52.5", 1, 1));


add(new Res_PLCADDRESS("M_外置仓1反转", "M50.6", 1, 1));
add(new Res_PLCADDRESS("M_外置仓2反转", "M50.7", 1, 1));
add(new Res_PLCADDRESS("M_外置仓3反转", "M51.0", 1, 1));
add(new Res_PLCADDRESS("M_外置仓4反转", "M51.1", 1, 1));
add(new Res_PLCADDRESS("M_外置仓5反转", "M51.2", 1, 1));
add(new Res_PLCADDRESS("M_外置仓6反转", "M51.3", 1, 1));


add(new Res_PLCADDRESS("保温池进水阀", "M103.4", 1, 1));
add(new Res_PLCADDRESS("保温池排水阀", "M103.5", 1, 1));
add(new Res_PLCADDRESS("猪油管道保温", "M103.6", 1, 1));
add(new Res_PLCADDRESS("牛油管道保温", "M103.7", 1, 1));
add(new Res_PLCADDRESS("保温池加热", "M104.0", 1, 1));
add(new Res_PLCADDRESS("三色灯-绿", "M104.1", 1, 1));
add(new Res_PLCADDRESS("三色灯-红", "M104.2", 1, 1));

// add(new Res_PLCADDRESS("M_保温池进水阀", "M53.4", 1, 1));
// add(new Res_PLCADDRESS("M_保温池排水阀", "M53.5", 1, 1));
// add(new Res_PLCADDRESS("M_猪油管道保温", "M53.6", 1, 1));
// add(new Res_PLCADDRESS("M_牛油管道保温", "M53.7", 1, 1));
// add(new Res_PLCADDRESS("M_保温池加热", "M54.0", 1, 1));
// add(new Res_PLCADDRESS("M_三色灯-绿", "M54.1", 1, 1));
// add(new Res_PLCADDRESS("M_三色灯-红", "M54.2", 1, 1));

add(new Res_PLCADDRESS("扫码数据读取", "-------------", 0, 0));
add(new Res_PLCADDRESS("扫码数据", "VW702", 1, 0));

add(new Res_PLCADDRESS("实时状态读取", "-------------", 0, 0));
add(new Res_PLCADDRESS("实时状态", "VW500", 1, 0));
add(new Res_PLCADDRESS("水池液位检测", "M5.2", 1, 0));
add(new Res_PLCADDRESS("出料口检测", "M5.3", 1, 0));
add(new Res_PLCADDRESS("水池进水阀", "M103.4", 1, 1));
add(new Res_PLCADDRESS("水池排水阀-开", "M103.5", 1, 1));
add(new Res_PLCADDRESS("水池排水阀-关", "M103.5", 1, 1));

add(new Res_PLCADDRESS("管道自动排水", "M5.4", 1, 1));
add(new Res_PLCADDRESS("管道自动排水完成", "M5.5", 1, 1));

add(new Res_PLCADDRESS("电子秤", "-------------", 0, 0));
add(new Res_PLCADDRESS("称当前重量", "VW82", 1, 0));
add(new Res_PLCADDRESS("砝码值", "VW86", 1, 1));
add(new Res_PLCADDRESS("重量清零", "M20.2", 0, 1));
add(new Res_PLCADDRESS("校准模式", "M20.1", 0, 1));
add(new Res_PLCADDRESS("关闭写保护", "M20.2", 0, 1));
add(new Res_PLCADDRESS("零点校准", "M20.3", 0, 1));
add(new Res_PLCADDRESS("砝码值写入", "M20.4", 0, 1));
add(new Res_PLCADDRESS("打开写保护", "M20.5", 0, 1));

add(new Res_PLCADDRESS("其它数据", "-------------", 0, 0));
add(new Res_PLCADDRESS("扫码数据", "VW2", 1, 0));
add(new Res_PLCADDRESS("掉线标志", "M100.0", 1, 1));
add(new Res_PLCADDRESS("心跳", "M100.1", 0, 1));
}};
/**
* 配料吧台料仓模型
*/
public List<ResSilosModel> Silos_配料吧台 = new ArrayList<ResSilosModel>() {{
add(new ResSilosModel("外置仓",1 , 1 ));
add(new ResSilosModel("外置仓",2 , 2 ));
add(new ResSilosModel("外置仓",3 , 3 ));
add(new ResSilosModel("外置仓",4 , 4 ));
add(new ResSilosModel("外置仓",5 , 5 ));
add(new ResSilosModel("外置仓",6 , 6 ));
add(new ResSilosModel("粉料仓",7 , 7 ));
add(new ResSilosModel("粉料仓",8 , 8 ));
add(new ResSilosModel("粉料仓",9 , 9 ));
add(new ResSilosModel("液料仓",13, 10));
add(new ResSilosModel("液料仓",14, 11));
add(new ResSilosModel("加热仓",15, 12));
add(new ResSilosModel("加热仓",16, 13));
add(new ResSilosModel("粉料仓",10, 14));
add(new ResSilosModel("粉料仓",11, 15));
add(new ResSilosModel("粉料仓",12, 16));

int num=0;
for(int i=1;i<=5;i++){
num++;
add(new ResSilosModel("外置仓",num , num ));
}

for(int i=1;i<=6;i++){
num++;
add(new ResSilosModel("粉料仓",num, num ));
}

for(int i=1;i<=4;i++){
num++;
add(new ResSilosModel("液体仓",num, num ));
}

for(int i=1;i<=2;i++){
num++;
add(new ResSilosModel("加热仓",num, num ));
}
}};

/**


+ 13
- 3
app/src/main/java/com/bonait/bnframework/common/db/QueryDB.java ファイルの表示

@@ -3144,7 +3144,7 @@ public class QueryDB {
* @param inputMax
* @param inputMin
*/
public static void UpdateSilosCalibrate(String id, int outputMax,int outputMin,int inputMax,int inputMin) {
public static boolean UpdateSilosCalibrate(String id, int outputMax,int outputMin,int inputMax,int inputMin) {
BPA_SILOS_CALIBRATE silos = GetSilosCalibrate(id);
if (silos != null) {
if(outputMax>=0){
@@ -3159,9 +3159,9 @@ public class QueryDB {
if(inputMin>=0){
silos.inputWightMin = inputMin;
}
Update(BPA_SILOS_CALIBRATE.class, silos);
// ModbusHelper.get().Add(QueryDB.GetSilosCalibrateAll());
return Update(BPA_SILOS_CALIBRATE.class, silos);
}
return false;
}
//endregion

@@ -3579,6 +3579,16 @@ public class QueryDB {
((BPA_PLCADDRESS) data).isread = cursor.getInt((int) cursor.getColumnIndex("isread"));
((BPA_PLCADDRESS) data).iswrite = cursor.getInt((int) cursor.getColumnIndex("iswrite"));
break;
case "BPA_SILOS_CALIBRATE":
data = new BPA_SILOS_CALIBRATE();
//私有
((BPA_SILOS_CALIBRATE) data).name = cursor.getString((int) cursor.getColumnIndex("name"));
((BPA_SILOS_CALIBRATE) data).inputWightMin = cursor.getInt((int) cursor.getColumnIndex("inputWightMin"));
((BPA_SILOS_CALIBRATE) data).inputWightMax = cursor.getInt((int) cursor.getColumnIndex("inputWightMax"));
((BPA_SILOS_CALIBRATE) data).outputTimeMin = cursor.getInt((int) cursor.getColumnIndex("outputTimeMin"));
((BPA_SILOS_CALIBRATE) data).outputTimeMax = cursor.getInt((int) cursor.getColumnIndex("outputTimeMax"));
((BPA_SILOS_CALIBRATE) data).num = cursor.getInt((int) cursor.getColumnIndex("num"));
break;
}
((ModeBase) data).id = cursor.getString((int) cursor.getColumnIndex("id"));
((ModeBase) data).createTime = cursor.getString((int) cursor.getColumnIndex("createTime"));


+ 12
- 0
app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_SILOS_CALIBRATE.java ファイルの表示

@@ -18,6 +18,18 @@ public class BPA_SILOS_CALIBRATE extends ModeBase {
//输入重量最小值: g
public int inputWightMin;

public BPA_SILOS_CALIBRATE(String _nmae,int _num,int _OutMax,int _OutMin,int _InputMax,int _InputMin){
name=_nmae;
num=_num;
outputTimeMax=_OutMax;
outputTimeMin=_OutMin;
inputWightMax=_InputMax;
inputWightMin=_InputMin;
}

public BPA_SILOS_CALIBRATE(){

}

@Override
public String toString() {


+ 1
- 1
app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigationMainActivity.java ファイルの表示

@@ -180,7 +180,7 @@ public class BottomNavigationMainActivity extends BaseActivity{
//判断连接环境
ConfigData.getInstance().ToggleEnvironment();
//2.初始化PLC
ReconnectModbus();
// ReconnectModbus();
//MQTT数据监听
OrderServer.Get().MqttInit();



+ 139
- 606
app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/silos_jiaoyan.java ファイルの表示

@@ -1,12 +1,14 @@
package com.bonait.bnframework.modules.home.fragment.mode;

import android.app.Activity;
import android.app.ProgressDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.graphics.Color;
import android.os.Handler;
import android.os.Message;
import android.os.SystemClock;
import android.provider.ContactsContract;
import android.util.AttributeSet;
import android.util.Log;
import android.view.LayoutInflater;
@@ -26,19 +28,29 @@ import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.FragmentManager;

import com.bonait.bnframework.HBL.Dialog.AlertDialogButton;
import com.bonait.bnframework.HBL.Dialog.DialogManager;
import com.bonait.bnframework.HBL.Dialog.WaitDialog;
import com.bonait.bnframework.HBL.Executor;
import com.bonait.bnframework.HBL.Interface.IFunc;
import com.bonait.bnframework.HBL.Trig.TTrig;
import com.bonait.bnframework.HBL.Unity;
import com.bonait.bnframework.R;
import com.bonait.bnframework.business.ExecuteTheRecipe;
import com.bonait.bnframework.business.PLCName;
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.mode.BPA_SILOS_CALIBRATE;
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.utils.ToastUtils;
import com.bonait.bnframework.modules.home.fragment.from.SilosNewActivity;
import com.qmuiteam.qmui.arch.QMUIFragment;
import com.qmuiteam.qmui.arch.QMUIFragmentPagerAdapter;
import com.qmuiteam.qmui.widget.QMUIViewPager;
@@ -47,6 +59,7 @@ import com.qmuiteam.qmui.widget.tab.QMUIBasicTabSegment;
import com.qmuiteam.qmui.widget.tab.QMUITabSegment;
import com.suke.widget.SwitchButton;

import java.io.Console;
import java.math.BigDecimal;
import java.text.DecimalFormat;
import java.util.ArrayList;
@@ -75,80 +88,26 @@ public class silos_jiaoyan extends LinearLayout {
*/
public MyClickListener mListener=null;
private View root;
//endregion

//region 界面布局
@BindView(R.id.wuliaojiaozhun)
LinearLayout wuliaojiaozhun;
@BindView(R.id.manguanjiaozhun)
LinearLayout manguanjiaozhun;
@BindView(R.id.jiaoliaojiaozhun)
LinearLayout jiaoliaojiaozhun;
@BindView(R.id.buchangjiaozhun)
LinearLayout buchangjiaozhun;
//endregion

//region 称相关
// @BindView(R.id.dianzicheng1)
// TextView dianzicheng1;
@BindView(R.id.dianzicheng2)
TextView dianzicheng2;
@BindView(R.id.dianzicheng3)
TextView dianzicheng3;

// @BindView(R.id.chuliaokeshu1)
// EditText chuliaokeshu1;
@BindView(R.id.chuliaokeshu2)
EditText chuliaokeshu2;
@BindView(R.id.chuliaokeshu3)
EditText chuliaokeshu3;
//endregion
@BindView(R.id.min_time)
EditText min_time;

//region 满管
@BindView(R.id.runtime)
Chronometer runtime;
@BindView(R.id.min_weight)
EditText min_weight;

@BindView(R.id.exit_mgjz)
EditText exit_mgjz;
@BindView(R.id.max_time)
EditText max_time;

final int[] time = {0};
@BindView(R.id.max_weight)
EditText max_weight;

final int[] zl = {0};

public boolean isStartMg=false;
@BindView(R.id.sim_discharge_weight)
EditText sim_discharge_weight;
//endregion

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

// @BindView(R.id.wljz2)
// EditText wljz2;

// @BindView(R.id.wljz3)
// EditText wljz3;

// @BindView(R.id.text_wljz)
// TextView text_wljz2;
//endregion

//region 通道补偿
@BindView(R.id.control_switch)
SwitchButton control_switch;

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

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

@BindView(R.id.bcjz_clsj)
EditText bcjz_clsj;
//endregion

public silos_jiaoyan(Context context, @Nullable AttributeSet attrs) {
super(context, attrs);
// root= LayoutInflater.from(context).inflate(R.layout.silos_jiaoyan_item, this);
root= LayoutInflater.from(context).inflate(R.layout.silos_jiaoyan_item_edit, this);
ButterKnife.bind(this, root);
//初始化界面控件的事件
@@ -156,20 +115,6 @@ public class silos_jiaoyan extends LinearLayout {
}


@BindView(R.id.text_wlkz)
TextView text_wlkz;
@BindView(R.id.text_mgkz)
TextView text_mgkz;
@BindView(R.id.text_jlkz)
TextView text_jlkz;
@BindView(R.id.text_bckz)
TextView text_bckz;

@BindView(R.id.text_jlkz1)
TextView text_jlkz1;
@BindView(R.id.text_bckz1)
TextView text_bckz1;


/**
* 初始化数据
@@ -177,27 +122,6 @@ public class silos_jiaoyan extends LinearLayout {
private void initData()
{
title_bc.setText(lcMode.num+" "+lcMode.materialName);
if(lcMode.name.equals("外置仓"))
{
text_jlkz.setVisibility(View.VISIBLE);
text_bckz.setVisibility(View.VISIBLE);
text_jlkz1.setVisibility(View.VISIBLE);
text_bckz1.setVisibility(View.VISIBLE);


// text_wljz2.setVisibility(View.GONE);
// wljz2.setVisibility(View.GONE);
}else
{
text_jlkz.setVisibility(View.GONE);
text_bckz.setVisibility(View.GONE);
text_jlkz1.setVisibility(View.GONE);
text_bckz1.setVisibility(View.GONE);


// text_wljz2.setVisibility(View.GONE);
// wljz2.setVisibility(View.GONE);
}
}

private void initEvent()
@@ -206,63 +130,11 @@ public class silos_jiaoyan extends LinearLayout {
close_from.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
// new Thread(new Runnable() {
// @Override
// public void run() {
// try {
// ExecuteTheRecipe.WritePLC("通道" + lcMode.num + "校准开关", false, null);
// ExecuteTheRecipe.WritePLC("手自切换", true, null);
// } catch (Exception e) {
//
// }
// }
// }).start();
if (mListener != null) {
mListener.clickListenerNew(v,0,null);
}
}
});

text_wlkz.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
InitView("物料校准");
}
});
text_mgkz.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
InitView("满管校准");
}
});
text_jlkz.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
InitView("酱料校准");
}
});
text_bckz.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
InitView("补偿校准");
}
});

control_switch.setOnCheckedChangeListener(new SwitchButton.OnCheckedChangeListener() {
@Override
public void onCheckedChanged(SwitchButton view, boolean isChecked) {
//设置
boolean isopen = control_switch.isChecked();
if (ConfigName.getInstance().PlcIsConnect) {
lcMode.isOpenbcsf=isopen?1:0;
ExecuteTheRecipe.WritePLC("通道" + lcMode.num + "补偿开关", isopen, null);
QueryDB.UpdateSilosisOpenbcsf(lcMode.id, isopen);
ToastUtils.info(lcMode.name.toString() + (isopen ? "打开" : "关闭") + "成功!");
} else {
ToastUtils.warning(lcMode.name.toString() + (isopen ? "打开" : "关闭") + "失败!PLC未连接!!");
}
}
});
}

Activity activity =null;
@@ -277,6 +149,20 @@ public class silos_jiaoyan extends LinearLayout {
initData();
InitView("物料校准");
Run();

BPA_SILOS_CALIBRATE res = QueryDB.GetSilosCalibrateByNum(lcMode.num);
if(res!=null){
min_time.setText(String.valueOf(res.outputTimeMin));
max_time.setText(String.valueOf(res.outputTimeMax));
min_weight.setText(String.valueOf(res.inputWightMax));
max_weight.setText(String.valueOf(res.inputWightMax));
}else{
min_time.setText("2");
max_time.setText("2");
min_weight.setText("0");
max_weight.setText("0");
}

}


@@ -287,65 +173,6 @@ public class silos_jiaoyan extends LinearLayout {
*/
public void InitView(String _TypeName) {
TypeName=_TypeName;
switch (TypeName) {
case "满管校准":
wuliaojiaozhun.setVisibility(View.GONE);
manguanjiaozhun.setVisibility(View.VISIBLE);
jiaoliaojiaozhun.setVisibility(View.GONE);
buchangjiaozhun.setVisibility(View.GONE);

text_wlkz.setTextColor(Color.BLACK);
text_mgkz.setTextColor(Color.parseColor("#7dcce1"));
text_jlkz.setTextColor(Color.BLACK);
text_bckz.setTextColor(Color.BLACK);
break;
case "酱料校准":
wuliaojiaozhun.setVisibility(View.GONE);
manguanjiaozhun.setVisibility(View.GONE);
jiaoliaojiaozhun.setVisibility(View.VISIBLE);
buchangjiaozhun.setVisibility(View.GONE);

text_wlkz.setTextColor(Color.BLACK);
text_mgkz.setTextColor(Color.BLACK);
text_jlkz.setTextColor(Color.parseColor("#7dcce1"));
text_bckz.setTextColor(Color.BLACK);
break;
case "补偿校准":
wuliaojiaozhun.setVisibility(View.GONE);
manguanjiaozhun.setVisibility(View.GONE);
jiaoliaojiaozhun.setVisibility(View.GONE);
buchangjiaozhun.setVisibility(View.VISIBLE);

text_wlkz.setTextColor(Color.BLACK);
text_mgkz.setTextColor(Color.BLACK);
text_jlkz.setTextColor(Color.BLACK);
text_bckz.setTextColor(Color.parseColor("#7dcce1"));
break;
default:
wuliaojiaozhun.setVisibility(View.VISIBLE);
manguanjiaozhun.setVisibility(View.GONE);
jiaoliaojiaozhun.setVisibility(View.GONE);
buchangjiaozhun.setVisibility(View.GONE);

text_wlkz.setTextColor(Color.parseColor("#7dcce1"));
text_mgkz.setTextColor(Color.BLACK);
text_jlkz.setTextColor(Color.BLACK);
text_bckz.setTextColor(Color.BLACK);
break;
}

/**
* 计时器超时
*/
runtime.setOnChronometerTickListener(new Chronometer.OnChronometerTickListener() {
@Override
public void onChronometerTick(Chronometer chronometer) {
//如果计时到现在超过了一小时秒 20s
if (SystemClock.elapsedRealtime() - runtime.getBase() > 20 * 1000) {
mHandler.sendEmptyMessage(1);
}
}
});
}
//endregion

@@ -360,11 +187,6 @@ public class silos_jiaoyan extends LinearLayout {
@Override
public void Run() {
mHandler.sendEmptyMessage(0);
if ((ExecuteTheRecipe.OutletWeigh >= (zl[0] + 2)) && isStartMg)//当前重量大于2g
{
isStartMg=false;
mHandler.sendEmptyMessage(1);
}
}
};
//通道校准完成
@@ -415,28 +237,6 @@ public class silos_jiaoyan extends LinearLayout {
ExecuteTheRecipe.WritePLC("通道" + lcMode.num + "校准开关", true, null);
if(activity!=null)
{
activity.runOnUiThread(new Runnable() {
@Override
public void run() {
exit_mgjz.setText(lcMode.bValue + "");
//填充校准时间
String time = lcMode.jTime == null ? "0.0" : lcMode.jTime;
String ftime = lcMode.fTime == null ? "0.0" : lcMode.fTime;
String jvalue = lcMode.jValue == null ? "0.0" : lcMode.jValue;
// wljz1.setText(time);
// wljz2.setText(ftime);
// wljz3.setText(jvalue);

String Gxs = lcMode.Gxs == null ? "0.0" : lcMode.Gxs;
String Lxs = lcMode.Lxs == null ? "0.0" : lcMode.Lxs;
String tdclsj = lcMode.tdclsj == null ? "0.0" : lcMode.tdclsj;

control_switch.setChecked(lcMode.isOpenbcsf == 1);
bcjz_gxs.setText(Gxs);
bcjz_dxs.setText(Lxs);
bcjz_clsj.setText(tdclsj);
}
});
}
}
}).start();
@@ -449,389 +249,122 @@ public class silos_jiaoyan extends LinearLayout {
*/
private Handler mHandler = new Handler() {
public void handleMessage(Message msg) {
switch (msg.what) {
case 0:
// dianzicheng1.setText(String.valueOf((int) ExecuteTheRecipe.OutletWeigh / 10.0) + " g");
dianzicheng2.setText(String.valueOf((int) ExecuteTheRecipe.OutletWeigh / 10.0) + " g");
dianzicheng3.setText(String.valueOf((int) ExecuteTheRecipe.OutletWeigh / 10.0) + " g");
break;
case 1:
time[0] = StopTime();
lcMode.bValue = time[0];
exit_mgjz.setText(time[0] + "");
QueryDB.UpdateMGTime(lcMode.id, time[0]);
break;
case 2:

break;
}
}
};
//endregion

//region 点击事件
@OnClick({
// R.id.qingling1,R.id.chuliao1,
R.id.qingling2, R.id.qingling3,
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,
})
public void onViewClicked(View view) {
switch (view.getId()) {
case R.id.qingling1:
case R.id.qingling2:
case R.id.qingling3:
dzcql();
break;
case R.id.chuliao1:
case R.id.chuliao2:
case R.id.chuliao3:
mncl();
break;
case R.id.click_mgjz://满管校准
zl[0] = ExecuteTheRecipe.OutletWeigh;
StartTime();
break;
case R.id.click_mgjz_save://满管校准 保存参数
String value1 = exit_mgjz.getText().toString();
int val1 = 0;
try {
val1 = (value1 == null || value1.isEmpty()) ? 0 : Integer.parseInt(value1);
lcMode.bValue = val1;
QueryDB.UpdateMGTime(lcMode.id, val1);
ToastUtils.info("校准时间保存成功!");
} catch (Exception e) {

}
break;
case R.id.click_wljz://物料校准
WLJZ();
break;
case R.id.click_wljz_save://物料校准 保存参数
SaveWLJZ();
break;
case R.id.click_bcjz_save://补偿校准 保存参数
SaveBCJZ();
break;
}
}
//endregion

//region 电子秤清零

/**
* 电子秤清零
*/
public void dzcql() {
ExecuteTheRecipe.WritePLC("重量清零", true, new IWriteCallBack() {
@Override
public void onSuccess() {
ToastUtils.info("清零成功!");
}

@Override
public void onFailure(String ErrorMsg) {
ToastUtils.error("清零失败!");
}
});
}
//endregion

//region 模拟出料

/**
* 模拟出料
*/
public void mncl() {
// String zltext = chuliaokeshu1.getText().toString();
// if (TypeName.equals("物料校准")) {
// zltext = chuliaokeshu1.getText().toString();
// } else if (TypeName.equals("酱料校准")) {
// zltext = chuliaokeshu2.getText().toString();
// } else if (TypeName.equals("补偿校准")) {
// zltext = chuliaokeshu3.getText().toString();
// }

// if (zltext.equals("")) {
// ToastUtils.warning("出料重量不能为空!");
// return;
// }
double zl = 0;
try {
// zl = Double.parseDouble(zltext);
} catch (Exception e) {
ToastUtils.warning("出料重量获取异常!" + e.getMessage());
return;
}
if (zl <= 0) {
ToastUtils.warning("出料重量至少大于0g!");
return;
}

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


short kkk = (short) ((int) (zl * 10));
new Thread(new Runnable() {
@Override
public void run() {
try {
ExecuteTheRecipe.WritePLC("配料完成", false, null);
ExecuteTheRecipe.WritePLC("手自切换", true, null);
int otherG=lcMode.silosmargin-(kkk/10);
QueryDB.UpdateYL(lcMode.id,otherG>=0?otherG:0);
ExecuteTheRecipe.WritePLC("需求值" + lcMode.num, kkk, new IWriteCallBack() {
@Override
public void onSuccess() {
ExecuteTheRecipe.WritePLC("配料启动", true, null);
ToastUtils.warning("启动成功......");

}

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

//region 保存物料校准参数
public void SaveWLJZ() {
// String stime = wljz1.getText().toString();
// String ftime = wljz2.getText().toString();
// String zl = wljz3.getText().toString();

// if (stime.equals("")) {
// ToastUtils.warning("校准基准时间不能为空!");
// return;
// }

if (zl.equals("")) {
ToastUtils.warning("校准重量不能为空!");
return;
}

int stime_1 = 0;
int ftime_1 = 0;

try {
// stime_1 = (int) Math.round((Double.parseDouble(stime) * 10));
} catch (Exception e) {
ToastUtils.error("时间异常!" + e.getMessage());
return;
private int EditTextValidate(EditText et,String info){
if(et==null) return -1;
if(et.getText().toString().isEmpty()){
DialogManager.showError(activity,info,AlertDialogButton.OK,null);
return -1;
}
double zhongl= 0;

try {
// zhongl=Double.parseDouble(zl);
} catch (Exception e) {
ToastUtils.error("校准重量获取异常!" + e.getMessage());
return;
try{
return Integer.parseInt(et.getText().toString());
}catch (Exception e){
return -1;
}
if (zhongl <= 0) {
ToastUtils.warning("校准重量至少大于0g!");
return;
}


if (!ConfigName.getInstance().versionSelectionEnum.equals("奶茶机")) {
// if (ftime.equals("")) {
// ToastUtils.warning("反转基准时间不能为空!");
// return;
// }
try {
// ftime_1 = (int) Math.round((Double.parseDouble(ftime) * 10));
} catch (Exception e) {
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("反转时间保存失败!");
}
});
}
// lcMode.fTime=ftime;
// lcMode.jTime=stime;
// lcMode.jValue=zl;

ArrayList<BPA_SILOS> Ss=QueryDB.GetSilosALL();
for (BPA_SILOS item:Ss)
{
// 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("校准基准时间保存失败!");
}
});
int kkk= lcMode.num;
ExecuteTheRecipe.WritePLC("校准值" + kkk, (short) (short) ((int) (zhongl * 10)), null);
}
//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;
}
}
}

new Thread(new Runnable() {
@Override
public void run() {
try {
ExecuteTheRecipe.WritePLC("校准完成", false, null);
ExecuteTheRecipe.WritePLC("手自切换", false, null);
ExecuteTheRecipe.WritePLC("通道校准", true, new IWriteCallBack() {
@Override
public void onSuccess() {
ToastUtils.info("启动通道校准成功!");
/**
* 按钮单击事件
* @param view
*/
@OnClick({R.id.btn_min_standard, R.id.btn_max_standard,R.id.btn_sim_discharge,R.id.btn_save})
public void onViewClicked(View view) {
switch (view.getId()) {
case R.id.btn_max_standard:
case R.id.btn_min_standard:
int time = EditTextValidate(view.getId()==R.id.btn_min_standard? min_time:max_time,"请输入正确的时间");
if(time<0) return;
DialogManager.showWarn(activity,"校准前请确认是否准备就绪?\r\n是否开始校准?", AlertDialogButton.YesNo,s->{
if(s){
WaitDialog.Show("最小校准","开始校准",getContext(),activity);
Executor.get().runThread(()->{

WaitDialog.AddText("电子秤清零");
ExecuteTheRecipe.Write(PLCName.重量清零, true, null);//电子秤重量清零

WaitDialog.AddText("等待清零完成");
//等待清零完成
Unity.Wait(()->{return ExecuteTheRecipe.ReadShort(PLCName.当前重量)==0;},3000).OnSource(()->{

WaitDialog.AddText("下发参数,开始校准");
ExecuteTheRecipe.Write(lcMode.name+lcMode.num+"出料时间",time,null);//下发出料时间
ExecuteTheRecipe.Write(lcMode.name+lcMode.num+"启停控制",true,null);//下发启动信号

WaitDialog.AddText("等待校准完成");
String name = lcMode.name+lcMode.num+"启停控制";
//等待出料完成
Unity.Wait(()->{return TTrig.get(name).Start(ExecuteTheRecipe.ReadBool(name));},time+2000).OnSource(()->{
//获取电子秤重量,并填充到对应位置
activity.runOnUiThread(()->{
if(view.getId()==R.id.min_time) min_time.setText(ExecuteTheRecipe.ReadShort(PLCName.当前重量));
else max_time.setText(ExecuteTheRecipe.ReadShort(PLCName.当前重量));
});
DialogManager.showInfo(activity,"校准完成",AlertDialogButton.OK,null);
}).OnFailed(msg->{WaitDialog.TimeOut("等待校准完成超时,请退出后重试!");});
TTrig.Remove(name);
}).OnFailed((msg)->{WaitDialog.TimeOut("等待清零超时,请退出后重试!");});
});
}
});
break;
case R.id.btn_sim_discharge:
DialogManager.showWarn(activity,"模拟出料前请将容器放入指定位置!\r\n请问是否继续",AlertDialogButton.YesNo,(s->{
if(s){
try{
int weight = Integer.parseInt(sim_discharge_weight.getText().toString());
BPA_SILOS_CALIBRATE res = QueryDB.GetSilosCalibrateByNum(lcMode.num);
if(res!=null){
int outValue = Unity.Scale(weight,res.inputWightMax,res.inputWightMin,res.outputTimeMax,res.outputTimeMin);
WaitDialog.Show("模拟出料","启动模拟出料",getContext(),activity);
Executor.get().runThread(()->{
ExecuteTheRecipe.Write(lcMode.name+lcMode.num+"出料时间",outValue*100,null);//下发出料时间
ExecuteTheRecipe.Write(lcMode.name+lcMode.num+"启停控制",true,null);//下发启动信号
WaitDialog.AddText("等待出料完成");
String name = lcMode.name+lcMode.num+"启停控制";
Unity.Wait(()->{return TTrig.get(name).Start(ExecuteTheRecipe.ReadBool(name));},(outValue*1000)+1000).OnSource(()->{
WaitDialog.Dismiss();
}).OnFailed(msg->{WaitDialog.TimeOut("等待出料完成超时,请退出后重试!");});
TTrig.Remove(name);
});

}else{
DialogManager.showWarn(activity,"料仓参数未校准,请校准后再试!",AlertDialogButton.OK,null);
}
}catch(Exception e){
DialogManager.showError(activity,"模拟出料失败,"+e.getMessage(),AlertDialogButton.OK,null);
}

@Override
public void onFailure(String ErrorMsg) {
ToastUtils.error("启动通道校准失败!");
}
}));
break;
case R.id.btn_save:
DialogManager.showWarn(activity,"请问是否覆盖本地参数?",AlertDialogButton.YesNo,s->{
if(s){
boolean runResult = false;
try{
int outputMax = Integer.parseInt(max_time.getText().toString());
int outputMin=Integer.parseInt(min_time.getText().toString());
int inputMax=Integer.parseInt(max_weight.getText().toString());
int inputMin=Integer.parseInt(min_weight.getText().toString());
if(lcMode!=null){
BPA_SILOS_CALIBRATE res = QueryDB.GetSilosCalibrateByNum(lcMode.num);
if(res!=null) runResult =QueryDB.UpdateSilosCalibrate(res.id,outputMax,outputMin,inputMax,inputMin);
else runResult =QueryDB.AddSilosCalibrate(new BPA_SILOS_CALIBRATE(lcMode.name,lcMode.num,outputMax,outputMin,inputMax,inputMin));
}
}catch (Exception e){
}
});
} catch (Exception e) {
}
}
}).start();
}
//endregion

//region 补偿校准
public void SaveBCJZ() {
Short H = 0;
Short L = 0;
Short time = 0;
try {
H = Short.parseShort(bcjz_gxs.getText().toString());
L = Short.parseShort(bcjz_dxs.getText().toString());
int ftime = (int) Math.round((Double.parseDouble(bcjz_clsj.getText().toString()) * 10));
time = (short) ftime;
} catch (Exception ex) {
ToastUtils.error("数据不合法,保存变量失败!" + ex.getMessage());
return;
if(runResult) DialogManager.showInfo(activity,"参数保存成功",AlertDialogButton.OK,null);
else DialogManager.showError(activity,"参数保存失败",AlertDialogButton.OK,null);
}
});
break;
}
Short finalH = H;
Short finalL = L;
Short finalTime = time;

lcMode.Gxs = bcjz_gxs.getText().toString();
lcMode.Lxs = bcjz_dxs.getText().toString();
lcMode.tdclsj = bcjz_clsj.getText().toString();

new Thread(new Runnable() {
@Override
public void run() {
try {
ExecuteTheRecipe.WritePLC("高系数" + lcMode.num, finalH, null);
ExecuteTheRecipe.WritePLC("低系数" + lcMode.num, finalL, null);
ExecuteTheRecipe.WritePLC("补偿" + lcMode.num + "时间", finalTime, new IWriteCallBack() {
@Override
public void onSuccess() {
ToastUtils.info("保存变量成功!");
QueryDB.UpdateSilosisOpenbcsf(lcMode.id, bcjz_gxs.getText().toString(),
bcjz_dxs.getText().toString(), bcjz_clsj.getText().toString());
}

@Override
public void onFailure(String ErrorMsg) {
ToastUtils.warning("保存变量失败!");
}
});
} catch (Exception e) {

}
}
}).start();

}
//endregion

//region 定时器

/**
* 启动定时器
*/
public void StartTime() {
isStartMg=true;
runtime.setBase(SystemClock.elapsedRealtime());
runtime.start();
new Thread(new Runnable() {
@Override
public void run() {
try {
//自动模式
ExecuteTheRecipe.WritePLC("手自切换", false, null);
//开启
ExecuteTheRecipe.WritePLC("手动控制" + lcMode.num, true, null);
} catch (Exception e) {

}
}
}).start();
}

/**
* 停止定时器
*/
public int StopTime() {
long elapsedMillis = SystemClock.elapsedRealtime() - runtime.getBase();
runtime.stop();
isStartMg=false;
int time = (int) (elapsedMillis / 1000);
new Thread(new Runnable() {
@Override
public void run() {
try {
ExecuteTheRecipe.WritePLC("手动控制" + lcMode.num, false, null);
} catch (Exception e) {

}
}
}).start();
return time;//当前点击多少秒
}
//endregion

}

+ 208
- 736
app/src/main/res/layout/item/layout/silos_jiaoyan_item_edit.xml
ファイル差分が大きすぎるため省略します
ファイルの表示


読み込み中…
キャンセル
保存