Browse Source

修改称重校准

调味吧台
liup 7 months ago
parent
commit
206ec99911
18 changed files with 225 additions and 110 deletions
  1. +10
    -0
      .idea/deploymentTargetSelector.xml
  2. +1
    -1
      .idea/gradle.xml
  3. +10
    -0
      .idea/migrations.xml
  4. +0
    -1
      .idea/misc.xml
  5. +13
    -1
      app/src/main/java/com/bonait/bnframework/HBL/Unity.java
  6. +23
    -4
      app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java
  7. +1
    -1
      app/src/main/java/com/bonait/bnframework/business/PLCName.java
  8. +1
    -0
      app/src/main/java/com/bonait/bnframework/common/base/BaseActivity.java
  9. +1
    -0
      app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java
  10. +5
    -0
      app/src/main/java/com/bonait/bnframework/common/helper/ActiveMax.java
  11. +8
    -2
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/MakeGoodFragment.java
  12. +1
    -1
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/DzcjyActivity.java
  13. +12
    -1
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_silos_ck.java
  14. +67
    -65
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/silos_jiaoyan.java
  15. +19
    -8
      app/src/main/res/layout/fragment_gongneng.xml
  16. +4
    -5
      app/src/main/res/layout/item/layout/dialog_add_silos_ck.xml
  17. +49
    -20
      app/src/main/res/layout/item/layout/silos_jiaoyan_item_edit.xml
  18. BIN
     

+ 10
- 0
.idea/deploymentTargetSelector.xml View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="deploymentTargetSelector">
<selectionStates>
<SelectionState runConfigName="app">
<option name="selectionMode" value="DROPDOWN" />
</SelectionState>
</selectionStates>
</component>
</project>

+ 1
- 1
.idea/gradle.xml View File

@@ -5,7 +5,7 @@
<option name="linkedExternalProjectsSettings">
<GradleProjectSettings>
<option name="externalProjectPath" value="$PROJECT_DIR$" />
<option name="gradleJvm" value="corretto-11" />
<option name="gradleJvm" value="#GRADLE_LOCAL_JAVA_HOME" />
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />


+ 10
- 0
.idea/migrations.xml View File

@@ -0,0 +1,10 @@
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ProjectMigrations">
<option name="MigrateToGradleLocalJavaHome">
<set>
<option value="$PROJECT_DIR$" />
</set>
</option>
</component>
</project>

+ 0
- 1
.idea/misc.xml View File

@@ -1,4 +1,3 @@
<?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">


+ 13
- 1
app/src/main/java/com/bonait/bnframework/HBL/Unity.java View File

@@ -25,11 +25,12 @@ public class Unity {
if(func==null) return OperateResult.CreateFailed("条件为空");
boolean tag=false;
while(!tag){
Delay(100);
tag=func.Run();
Delay(100);
if(timeOut>0&&(System.currentTimeMillis()-startTime)>timeOut) break;
}
if(!tag) MessageLog.ShowInfo("任务超时,超时时间:"+String.valueOf(timeOut)+"/"+String.valueOf(System.currentTimeMillis()-startTime));
if(!tag) MessageLog.ShowInfo("任务超时,超时时间:"+String.valueOf(timeOut)+"/"+String.valueOf(System.currentTimeMillis()-startTime));

// System.out.println("任务超时,超时时间:"+String.valueOf(timeOut)+"/"+String.valueOf(System.currentTimeMillis()-startTime));
return tag?OperateResult.CreateSuccess():OperateResult.CreateFailed("任务超时");
@@ -87,7 +88,18 @@ public class Unity {
*/
public static float Scale( float InputValue, float InputMax, float InputMin, float OutMax, float OutMin)
{
MessageLog.ShowInfo("AnalogConvert measureCookTime InputValue="+InputValue+" InputMax="+InputMax+";InputMin="+InputMin+";OutMax="+OutMax+";OutMin="+OutMin);

if(InputValue<=0|| InputMax<=0||InputMin<=0){
return 0;
}
if(((InputMax - InputMin) + OutMin)==0){
return 0;
}
float value = ((OutMax - OutMin) * (InputValue - InputMin)) / (InputMax - InputMin) + OutMin;
if(value<=0){
value = 0;
}
String formattedNum = String.format("%.2f", value);
return Float.parseFloat(formattedNum);
}


+ 23
- 4
app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java View File

@@ -40,6 +40,7 @@ import com.bonait.bnframework.common.helper.ThreadManager;
import com.bonait.bnframework.common.modbus.ModbusTcpServer;
import com.bonait.bnframework.common.utils.AlertDialogUtils;
import com.bonait.bnframework.common.utils.ToastUtils;
import com.http.utils.LogUtils;
import com.qmuiteam.qmui.widget.dialog.QMUIDialog;
import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction;

@@ -520,9 +521,12 @@ public class ExecuteTheRecipe {
* @param value
*/
public static void WritePLC(String name, Object value, IWriteCallBack callback) {
MessageLog.ShowInfo("WritePLC name="+name +";value="+value.toString());
try {
if (ConfigName.getInstance().PLC_Address.containsKey(name)) {
BPA_PLCADDRESS plcaddress = ConfigName.getInstance().PLC_Address.get(name);
MessageLog.ShowInfo("WritePLC name="+name + ";plcaddress.address="+plcaddress.address.toString()+";value="+value.toString());

if (!plcaddress.address.isEmpty() && ConfigName.getInstance().PlcIsConnect) {
if (plcaddress.address.toUpperCase().startsWith("VD"))//int
{
@@ -563,6 +567,7 @@ public class ExecuteTheRecipe {
}

public static void Write(Object plcName,Object value,IWriteCallBack callBack){
MessageLog.ShowInfo("WritePLC plcName=" +plcName.toString() +";value="+value.toString());
WritePLC(plcName.toString(),value,callBack);
}

@@ -573,10 +578,12 @@ public class ExecuteTheRecipe {
* @return
*/
public static Object ReadPLC(String name) {

final Object[] ReturnsVariable = {null};
try {
if (ConfigName.getInstance().PLC_Address.containsKey(name)) {
BPA_PLCADDRESS plcaddress = ConfigName.getInstance().PLC_Address.get(name);
MessageLog.ShowInfo("ReadPLC name=" +name +" plcaddress="+plcaddress.address.toString());
if (!plcaddress.address.isEmpty() && ConfigName.getInstance().PlcIsConnect) {
if (plcaddress.address.toUpperCase().startsWith("VD"))//int
{
@@ -611,16 +618,23 @@ public class ExecuteTheRecipe {
ReturnsVariable[0] = val[0];
});
}
if ((plcaddress.address.toUpperCase().equals("VW82"))){
MessageLog.ShowInfo("ReadPLC 称当前重量 name=" +name+" ReturnsVariable[0]="+ReturnsVariable[0] );
OutletWeigh = (short)ReturnsVariable[0];

}
}
}
} catch (Exception ex) {
ToastUtils.error("异常信息:" + ex.getMessage());
} finally {
MessageLog.ShowInfo("ReadPLC name=" +name+" ReturnsVariable[0]="+ReturnsVariable[0] );
return ReturnsVariable[0];
}
}

public static boolean ReadBool(Object plcName){
MessageLog.ShowInfo("ReadBool plcName=" +plcName.toString() );
try{
if(ListeningValue.containsKey(plcName)){
return Boolean.parseBoolean(ListeningValue.get(plcName).toString());
@@ -633,11 +647,16 @@ public class ExecuteTheRecipe {
}

public static short ReadShort(Object plcName){
MessageLog.ShowInfo("ReadShort "+plcName.toString());
try{
if(ListeningValue.containsKey(plcName)){
return Short.parseShort(ListeningValue.get(plcName).toString());
short result = Short.parseShort(ListeningValue.get(plcName).toString());
MessageLog.ShowInfo(plcName.toString()+" result="+result);
return result;
}else{
return Short.parseShort(ReadPLC(plcName.toString()).toString());
short result = Short.parseShort(ReadPLC(plcName.toString()).toString());
MessageLog.ShowInfo(plcName.toString()+" result="+result);
return result;
}
}catch(Exception e){
return 0;
@@ -956,7 +975,7 @@ public class ExecuteTheRecipe {
final boolean[] issucess3 = {false};

//写校准模式
WritePLC("砝码校准模式", true, new IWriteCallBack() {
WritePLC("校准模式", true, new IWriteCallBack() {
@Override
public void onSuccess() {
issucess1[0] =true;
@@ -1000,7 +1019,7 @@ public class ExecuteTheRecipe {
final boolean[] issucess2 = {false};

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


+ 1
- 1
app/src/main/java/com/bonait/bnframework/business/PLCName.java View File

@@ -2,7 +2,7 @@ package com.bonait.bnframework.business;

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


+ 1
- 0
app/src/main/java/com/bonait/bnframework/common/base/BaseActivity.java View File

@@ -52,6 +52,7 @@ public class BaseActivity extends QMUIActivity implements EasyPermissions.Permis
@Override
protected void onDestroy() {
super.onDestroy();
ActiveMax.destroy(this);
/*LocalCacheUtils.Get().ClearBitmapFile();*/
}



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

@@ -46,6 +46,7 @@ import java.util.concurrent.ConcurrentHashMap;
* 配置文件
*/
public class ConfigName {
public static final boolean TEST = true;
//region 单例模式
private static ConfigName mInstance; //实例变量设置私有,防止直接通过类名访问



+ 5
- 0
app/src/main/java/com/bonait/bnframework/common/helper/ActiveMax.java View File

@@ -49,6 +49,11 @@ public class ActiveMax {
// activity.getWindow().getDecorView().setOnSystemUiVisibilityChangeListener(setOnSystemUiVisibilityChangeListener);
}

public static void destroy(Activity activity){
activities.remove(activity);
activity.getWindow().getDecorView().getViewTreeObserver().removeOnGlobalLayoutListener(keyboardVisibilityListener);
}

/**
* 状态栏变化后事件
*/


+ 8
- 2
app/src/main/java/com/bonait/bnframework/modules/home/fragment/MakeGoodFragment.java View File

@@ -477,6 +477,7 @@ public class MakeGoodFragment extends BaseFragment {
@Override
public void onSuccess() {
ToastUtils.info("清零成功!");
mHandler.sendEmptyMessage(0);
}

@Override
@@ -505,6 +506,7 @@ public class MakeGoodFragment extends BaseFragment {
plc_status.setText(ConfigName.getInstance().PlcIsConnect ? "正常" : "异常");
plc_status.setTextColor(ConfigName.getInstance().PlcIsConnect ? Color.parseColor("#4CAF50") : Color.parseColor("#D32F2F"));
wendu1.setText(ExecuteTheRecipe.WaterTemp + "°C");
MessageLog.ShowInfo("重量 ExecuteTheRecipe.OutletWeigh="+ExecuteTheRecipe.OutletWeigh);
dianzichen.setText(String.valueOf((int) ExecuteTheRecipe.OutletWeigh / 10.0) + " g");
break;
case 1:
@@ -666,11 +668,12 @@ public class MakeGoodFragment extends BaseFragment {
//接收扫码信息
ExecuteTheRecipe.OnScanTheCodeInformationT = new IRunT<String>() {
@Override
public void Run(String msg) {
public void Run(String msg2) {

activity.runOnUiThread(new Runnable() {
@Override
public void run() {
String msg = " |03cb1364-8b85-446a-b00b-d3657de1a19f| | ";
if ((msg != null) && (((String) msg).length() > 2) && ((String) msg).contains("|")) {
//拿到扫码数据
//例如 ORD001|P0003|A001,M002,T001|2
@@ -712,8 +715,11 @@ public class MakeGoodFragment extends BaseFragment {
}
} catch (Exception ex) {
}

BPA_GOODS good = QueryDB.GetGoodsforeignKeyId(goodid);
ConfigName.getInstance();
if(ConfigName.TEST){
good = QueryDB.GetGoodsId(goodid);
}
if (good == null) {
message = "没有查询到该商品!";
mHandler.sendEmptyMessage(1);


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

@@ -83,7 +83,7 @@ public class DzcjyActivity extends BaseActivity {

String outres = edittext_zl.getText().toString().trim();
if (!outres.equals("")) {
ExecuteTheRecipe.WritePLC("砝码值", Short.parseShort(outres), new IWriteCallBack() {
ExecuteTheRecipe.WritePLC("砝码值", Short.parseShort(outres)*10, new IWriteCallBack() {
@Override
public void onSuccess() {
ExecuteTheRecipe.WritePLC("砝码值写入",true,null);


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

@@ -48,6 +48,7 @@ import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.concurrent.Delayed;

import butterknife.BindView;
import butterknife.ButterKnife;
@@ -347,11 +348,21 @@ public class add_silos_ck extends LinearLayout {
if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
Log.e("鼠标", "按下:2222 ");
ExecuteTheRecipe.WritePLC("清洗模式", true,null);
try {
Thread.sleep(100L);//避免启动的时候还是按时间出料
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
ExecuteTheRecipe.WritePLC(name, true, null);
} else if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
Log.e("鼠标", "松开:33333 ");
ExecuteTheRecipe.WritePLC("清洗模式", false,null);
ExecuteTheRecipe.WritePLC(name, false, null);
try {
Thread.sleep(100L);//避免启动的时候还是按时间出料
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
ExecuteTheRecipe.WritePLC("清洗模式", false,null);
}
return false;
});


+ 67
- 65
app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/silos_jiaoyan.java View File

@@ -1,30 +1,18 @@
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;
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;

@@ -32,38 +20,18 @@ 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.helper.MessageLog;
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;
import com.qmuiteam.qmui.widget.dialog.QMUIDialog;
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;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;
@@ -90,19 +58,21 @@ public class silos_jiaoyan extends LinearLayout {
private View root;

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

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

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

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

@BindView(R.id.sim_discharge_weight)
EditText sim_discharge_weight;
@BindView(R.id.tv_discharge_result)
TextView tv_discharge_result;

// @BindView(R.id.controlStatus)
// TextView controlStatus;
@@ -297,29 +267,44 @@ public class silos_jiaoyan extends LinearLayout {
if(time<0) return;
DialogManager.showWarn(activity,"校准前请确认是否准备就绪?\r\n是否开始校准?", AlertDialogButton.YesNo,s->{
if(s){
WaitDialog.Show("最小校准","开始校准",getContext(),activity);
WaitDialog.Show(view.getId()==R.id.min_time?"最小校准":"最大校准","开始校准",getContext(),activity);
Executor.get().runThread(()->{

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

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

WaitDialog.AddText("下发参数,开始校准");
ExecuteTheRecipe.Write(lcMode.name+lcMode.num+"出料时间",time,null);//下发出料时间
ExecuteTheRecipe.Write(lcMode.name+lcMode.num+"出料时间",((int) time)*100,null);//下发出料时间
long startTime = System.currentTimeMillis();
MessageLog.ShowInfo("下发参数,开始校准 当前时间:"+startTime +" 出料时间"+((int) time)*100);
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));},(int)(time+2000)).OnSource(()->{
Unity.Wait(()->{return TTrig.get(name).Start(ExecuteTheRecipe.ReadBool(name));},(int)(time*1000+2000)).OnSource(()->{
//获取电子秤重量,并填充到对应位置
try {
Thread.sleep(500);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
MessageLog.ShowInfo("下发参数,结束校准 结束时间:"+(System.currentTimeMillis()-startTime) +" 读取启停控制 false");

activity.runOnUiThread(()->{
if(view.getId()==R.id.min_time) min_time.setText(ExecuteTheRecipe.ReadShort(PLCName.当前重量));
else max_time.setText(ExecuteTheRecipe.ReadShort(PLCName.当前重量));
float weight = (float) (ExecuteTheRecipe.ReadShort(PLCName.称当前重量)/10.0);
MessageLog.ShowInfo("下发参数,结束校准 校准重量:"+weight);
if(view.getId()==R.id.btn_min_standard) min_weight.setText(weight+"");
else max_weight.setText(weight+"");
});
WaitDialog.Dismiss();
DialogManager.showInfo(activity,"校准完成",AlertDialogButton.OK,null);
}).OnFailed(msg->{WaitDialog.TimeOut("等待校准完成超时,请退出后重试!");});
TTrig.Remove(name);
@@ -333,15 +318,15 @@ public class silos_jiaoyan extends LinearLayout {
float minWeight = Float.parseFloat(min_weight.getText().toString());
float weight = Float.parseFloat(sim_discharge_weight.getText().toString());
float maxweight = Float.parseFloat(max_weight.getText().toString());
if(weight<minWeight){
DialogManager.showError(activity,"模拟出料重量小于最小出料重量,请重新输入模拟出料重量",AlertDialogButton.OK,null);
return;
}
if(weight>maxweight){
DialogManager.showError(activity,"模拟出料重量大于最大出料重量,请重新输入模拟出料重量",AlertDialogButton.OK,null);
return;
}
// if(weight<minWeight){
// DialogManager.showError(activity,"模拟出料重量小于最小出料重量,请重新输入模拟出料重量",AlertDialogButton.OK,null);
// return;
// }
//
// if(weight>maxweight){
// DialogManager.showError(activity,"模拟出料重量大于最大出料重量,请重新输入模拟出料重量",AlertDialogButton.OK,null);
// return;
// }

}catch(Exception e){}

@@ -351,19 +336,36 @@ public class silos_jiaoyan extends LinearLayout {
float weight = Float.parseFloat(sim_discharge_weight.getText().toString());
BPA_SILOS_CALIBRATE res = QueryDB.GetSilosCalibrateByNum(lcMode.num);
if(res!=null){
float 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+"出料时间",(short)(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));},(int)(outValue*1000)+2000).OnSource(()->{
WaitDialog.Dismiss();
}).OnFailed(msg->{WaitDialog.TimeOut("等待出料完成超时,请退出后重试!");});
TTrig.Remove(name);
});

WaitDialog.AddText("电子秤清零");
ExecuteTheRecipe.Write(PLCName.重量清零, true, null);//电子秤重量清零
ExecuteTheRecipe.Write(PLCName.重量清零, true, null);//电子秤重量清零
ExecuteTheRecipe.Write(PLCName.重量清零, true, null);//电子秤重量清零
WaitDialog.AddText("等待清零完成");
//等待清零完成
Unity.Wait(()->{return ExecuteTheRecipe.ReadShort(PLCName.称当前重量)>-20&&ExecuteTheRecipe.ReadShort(PLCName.称当前重量)<=20;},3000).OnSource(()->{
float 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+"出料时间",(short)(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));},(int)(outValue*1000)+2000).OnSource(()->{
try {
Thread.sleep(500);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
WaitDialog.Dismiss();

activity.runOnUiThread(()->{
float resultWeight = (float) (ExecuteTheRecipe.ReadShort(PLCName.称当前重量)/10.0);
tv_discharge_result.setText(resultWeight+"g");
});
}).OnFailed(msg->{WaitDialog.TimeOut("等待出料完成超时,请退出后重试!");});
TTrig.Remove(name);
});
}).OnFailed((msg)->{WaitDialog.TimeOut("等待清零超时,请退出后重试!");});
}else{
DialogManager.showWarn(activity,"料仓参数未校准,请校准后再试!",AlertDialogButton.OK,null);
}


+ 19
- 8
app/src/main/res/layout/fragment_gongneng.xml View File

@@ -133,7 +133,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="sans-serif-condensed-medium"
android:text="饮料配方管理"
android:text="配方管理"
android:textColor="@color/white"
android:textSize="26dp"
android:focusable="false"/>
@@ -243,13 +243,24 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/app_color_blue" >
<Button
android:id="@+id/btn_sync"
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:background="@mipmap/yxz"
android:textSize="16sp"
android:layout_centerHorizontal="true"/>
android:layout_height="wrap_content">
<Button
android:id="@+id/btn_sync"
android:layout_width="100dp"
android:layout_height="match_parent"
android:background="null"
android:textSize="16sp"
android:layout_centerHorizontal="true"/>
<ImageView
android:layout_width="48dp"
android:layout_height="48dp"
android:src="@mipmap/yxz"
android:layout_gravity="center"
android:scaleType="fitXY"
/>
</FrameLayout>

</com.qmuiteam.qmui.widget.QMUITopBarLayout>
</com.qmuiteam.qmui.widget.QMUIWindowInsetLayout>

+ 4
- 5
app/src/main/res/layout/item/layout/dialog_add_silos_ck.xml View File

@@ -22,12 +22,11 @@
</RelativeLayout>
<Button
android:id="@+id/close_from"
android:layout_width="32dp"
android:layout_height="32dp"
android:layout_width="50dp"
android:layout_height="50dp"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_marginRight="@dimen/dp_10"
android:layout_marginTop="@dimen/dp_10"
android:background="@mipmap/newdelete"
android:textSize="14dp"
android:textColor="@color/white"/>
@@ -139,7 +138,7 @@
android:orientation="vertical">
<Button
android:id="@+id/control_switch_shoudong"
android:layout_width="60dp"
android:layout_width="80dp"
android:layout_height="40dp"
android:layout_centerHorizontal="true"
android:background="@drawable/silosbuttonbj"
@@ -150,7 +149,7 @@
<Button
android:layout_marginTop="@dimen/dp_10"
android:id="@+id/control_huishou"
android:layout_width="60dp"
android:layout_width="80dp"
android:layout_height="40dp"
android:layout_centerHorizontal="true"
android:background="@drawable/silosbuttonbj"


+ 49
- 20
app/src/main/res/layout/item/layout/silos_jiaoyan_item_edit.xml View File

@@ -238,6 +238,22 @@

</LinearLayout>

<View
android:layout_width="650dp"
android:layout_height="1dp"
android:layout_marginTop="20dp"
android:background="@color/gray"/>

<Button
android:layout_marginTop="30dp"
android:id="@+id/btn_save"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/bg_btn_login_selected"
android:text="保存参数"
android:textColor="@color/white"
android:textSize="25sp" />

<View
android:layout_width="650dp"
android:layout_height="1dp"
@@ -288,28 +304,41 @@

</LinearLayout>

<View
android:layout_width="650dp"
android:layout_height="1dp"
android:layout_marginTop="20dp"
android:background="@color/gray"/>

<Button
android:layout_marginTop="30dp"
android:id="@+id/btn_save"
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/bg_btn_login_selected"
android:text="保存参数"
android:textColor="@color/white"
android:textSize="25sp" />
android:layout_height="match_parent"
android:layout_marginTop="30dp"
android:orientation="horizontal">

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="实际出料重量:"
android:textSize="25sp"/>

<TextView
android:id="@+id/tv_discharge_result"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text=""
android:textSize="25sp"/>

</LinearLayout>

</LinearLayout>



<!-- <TextView-->
<!-- android:id="@+id/controlStatus"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="match_parent"-->
<!-- android:text="控制状态:"-->
<!-- android:textSize="20sp"/>-->
<!-- <TextView-->
<!-- android:id="@+id/controlStatus"-->
<!-- android:layout_width="match_parent"-->
<!-- android:layout_height="match_parent"-->
<!-- android:text="控制状态:"-->
<!-- android:textSize="20sp"/>-->

</LinearLayout>



BIN
View File


Loading…
Cancel
Save