Browse Source

配料吧台调试

调味吧台
pry 4 months ago
parent
commit
8245d4043b
15 changed files with 331 additions and 221 deletions
  1. +2
    -2
      app/src/main/java/com/bonait/bnframework/HBL/Communication/CommBase.java
  2. +25
    -3
      app/src/main/java/com/bonait/bnframework/HBL/Unity.java
  3. +156
    -137
      app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java
  4. +11
    -10
      app/src/main/java/com/bonait/bnframework/common/constant/ConfigName.java
  5. +1
    -1
      app/src/main/java/com/bonait/bnframework/common/db/QueryDB.java
  6. +5
    -5
      app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_SILOS_CALIBRATE.java
  7. +2
    -2
      app/src/main/java/com/bonait/bnframework/common/helper/MQTT.java
  8. +1
    -0
      app/src/main/java/com/bonait/bnframework/common/helper/MessageLog.java
  9. +2
    -2
      app/src/main/java/com/bonait/bnframework/common/modbus/ModbusTcpServer.java
  10. +1
    -1
      app/src/main/java/com/bonait/bnframework/modules/home/activity/BottomNavigationMainActivity.java
  11. +43
    -24
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_silos_ck_edit.java
  12. +44
    -13
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/silos_jiaoyan.java
  13. +1
    -1
      app/src/main/res/layout/fragment_my.xml
  14. +25
    -15
      app/src/main/res/layout/item/layout/item_caidan.xml
  15. +12
    -5
      app/src/main/res/layout/item/layout/silos_jiaoyan_item_edit.xml

+ 2
- 2
app/src/main/java/com/bonait/bnframework/HBL/Communication/CommBase.java View File

@@ -26,11 +26,11 @@ public class CommBase {
}

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


+ 25
- 3
app/src/main/java/com/bonait/bnframework/HBL/Unity.java View File

@@ -3,6 +3,7 @@ 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.Logs.MessageLog;
import com.bonait.bnframework.HBL.Result.OperateResult;

public class Unity {
@@ -22,11 +23,16 @@ public class Unity {
public static OperateResult Wait(IFunc func, int timeOut){
long startTime = System.currentTimeMillis();
if(func==null) return OperateResult.CreateFailed("条件为空");
while(!func.Run()){
Delay(10);
boolean tag=false;
while(!tag){
tag=func.Run();
Delay(100);
if(timeOut>0&&(System.currentTimeMillis()-startTime)>timeOut) break;
}
return func.Run()?OperateResult.CreateSuccess():OperateResult.CreateFailed("任务超时");
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("任务超时");
}

/**
@@ -70,4 +76,20 @@ public class Unity {
return value;
}

/**
* 浮点数据缩放
* @param InputValue 需要缩放的值
* @param InputMax 需要缩放的最大值
* @param InputMin 需要缩放的最小值
* @param OutMax 缩放后的最大值
* @param OutMin 缩放后的最下值
* @return
*/
public static float Scale( float InputValue, float InputMax, float InputMin, float OutMax, float OutMin)
{
float value = ((OutMax - OutMin) * (InputValue - InputMin)) / (InputMax - InputMin) + OutMin;
String formattedNum = String.format("%.2f", value);
return Float.parseFloat(formattedNum);
}

}

+ 156
- 137
app/src/main/java/com/bonait/bnframework/business/ExecuteTheRecipe.java View File

@@ -293,9 +293,9 @@ public class ExecuteTheRecipe {
ReadPLCStatus();
}
} catch (Exception ex) {
ToastUtils.error("异常信息:" + ex.getMessage());
ToastUtils.error("PLC设备数据监听异常:" + ex.getMessage());
}
Thread.sleep(10);
Thread.sleep(1);
}

@Override
@@ -304,51 +304,51 @@ public class ExecuteTheRecipe {
}
});

ThreadManager.Get().StartLong("PLC设备-温度重量", true, new IThread() {
@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 (WeighComplete!=null)
{
WeighComplete.Run();
}
if (TempComplete!=null)
{
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)
// {
// 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 (WeighComplete!=null)
// {
// WeighComplete.Run();
// }
// if (TempComplete!=null)
// {
// 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
@@ -435,19 +435,19 @@ public class ExecuteTheRecipe {
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, message + "下发失败!物料没有管理料仓!");
} else {
//MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, message + "准备下发【" + silos.num + "】号料仓PLC控制命令,需求量:=" + recipe.value);
int _val = (int)Math.round((Double.parseDouble(recipe.value) * 10));
// int _val = (int)Math.round((Double.parseDouble(recipe.value) * 10));
float _val = Float.parseFloat(recipe.value);

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);
float outValue = Unity.Scale(_val,res.inputWightMax,res.inputWightMin,res.outputTimeMax,res.outputTimeMin);
MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, "写入地址:"+name+"地址值:"+outValue*100);
WritePLC(name, (short) (outValue*100), null);
}else{ MessageLog.ShowUserMessage(UserLogEnum.订单处理日志, message + "下发失败!物料没有对应的校准值!");}



//減去料仓数量
int otherG=silos.silosmargin-(_val/10);
int otherG=silos.silosmargin-(int)(_val/10);
QueryDB.UpdateYL(silos.id,otherG>=0?otherG:0);
}
}
@@ -622,7 +622,11 @@ public class ExecuteTheRecipe {

public static boolean ReadBool(Object plcName){
try{
return Boolean.getBoolean(ReadPLC(plcName.toString()).toString());
if(ListeningValue.containsKey(plcName)){
return Boolean.parseBoolean(ListeningValue.get(plcName).toString());
}else{
return Boolean.parseBoolean(ReadPLC(plcName.toString()).toString());
}
}catch(Exception e){
return false;
}
@@ -630,7 +634,11 @@ public class ExecuteTheRecipe {

public static short ReadShort(Object plcName){
try{
return Short.parseShort(ReadPLC(plcName.toString()).toString());
if(ListeningValue.containsKey(plcName)){
return Short.parseShort(ListeningValue.get(plcName).toString());
}else{
return Short.parseShort(ReadPLC(plcName.toString()).toString());
}
}catch(Exception e){
return 0;
}
@@ -638,7 +646,12 @@ public class ExecuteTheRecipe {

public static int ReadInt(Object plcName){
try{
return Integer.getInteger(ReadPLC(plcName.toString()).toString());
if(ListeningValue.containsKey(plcName)){
return Integer.parseInt(ListeningValue.get(plcName).toString());
}else{
return Integer.parseInt(ReadPLC(plcName.toString()).toString());
}

}catch(Exception e){
return 0;
}
@@ -832,77 +845,77 @@ 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(Looper.getMainLooper()).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 {
}
}
// 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(Looper.getMainLooper()).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 {
// }
// }

/**
* 完成信号监听
@@ -911,17 +924,23 @@ public class ExecuteTheRecipe {
* @param callback 执行委托
*/
private static void CompleteListen(String name, IRun callback) {
if (ConfigName.getInstance().PLC_Address.containsKey(name)) {
BPA_PLCADDRESS plcaddress = ConfigName.getInstance().PLC_Address.get(name);
if (!plcaddress.address.isEmpty() && ConfigName.getInstance().PlcIsConnect) {
ModbusTcpServer.get().ReadBool(plcaddress.address, 1, booleans -> {
RTrig.get(name).Start(booleans[0], () -> {
if (callback != null)
callback.Run();
});
});
}
// if (ConfigName.getInstance().PLC_Address.containsKey(name)) {
// BPA_PLCADDRESS plcaddress = ConfigName.getInstance().PLC_Address.get(name);
// if (!plcaddress.address.isEmpty() && ConfigName.getInstance().PlcIsConnect) {
// ModbusTcpServer.get().ReadBool(plcaddress.address, 1, booleans -> {
// RTrig.get(name).Start(booleans[0], () -> {
// if (callback != null)
// callback.Run();
// });
// });
// }
// }

if(ListeningValue.containsKey(name)){
boolean res = Boolean.parseBoolean(ListeningValue.get(name).toString());
RTrig.get(name).Start(res,()->{if(callback!=null)callback.Run();});
}

}
//endregion



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

@@ -559,8 +559,9 @@ public class ConfigName {

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("配料完成", "M0.3", 1, 1));
add(new Res_PLCADDRESS("按钮配料启动", "I0.0", 1, 0));
add(new Res_PLCADDRESS("清洗模式", "M1.0", 0, 1));

add(new Res_PLCADDRESS("外置仓", "-------------", 0, 0));
for (int i=1;i<=5;i++){
@@ -569,21 +570,21 @@ public class ConfigName {
}

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("加热仓16出料时间", "VW110", 0, 1));
add(new Res_PLCADDRESS("加热仓16启停控制", "M10.5", 1, 1));
add(new Res_PLCADDRESS("加热仓17出料时间", "VW112", 0, 1));
add(new Res_PLCADDRESS("加热仓17启停控制", "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("粉料仓"+(i+5)+"出料时间", "VW"+(112+(i*2)), 0, 1));
add(new Res_PLCADDRESS("粉料仓"+(i+5)+"启停控制", Unity.GetSiemensBitSingleAdd("M",7+i,10), 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("液体仓"+(i+11)+"出料时间", "VW"+(124+(i*2)), 0, 1));
add(new Res_PLCADDRESS("液体仓"+(i+11)+"启停控制", Unity.GetSiemensBitSingleAdd("M",5+i,11), 1, 1));
}

add(new Res_PLCADDRESS("备用仓", "-------------", 0, 0));
@@ -606,7 +607,7 @@ public class ConfigName {
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));
add(new Res_PLCADDRESS("心跳", "M100.1", 1, 1));
}};
/**
* 配料吧台料仓模型


+ 1
- 1
app/src/main/java/com/bonait/bnframework/common/db/QueryDB.java View File

@@ -3144,7 +3144,7 @@ public class QueryDB {
* @param inputMax
* @param inputMin
*/
public static boolean UpdateSilosCalibrate(String id, int outputMax,int outputMin,int inputMax,int inputMin) {
public static boolean UpdateSilosCalibrate(String id, float outputMax,float outputMin,float inputMax,float inputMin) {
BPA_SILOS_CALIBRATE silos = GetSilosCalibrate(id);
if (silos != null) {
if(outputMax>=0){


+ 5
- 5
app/src/main/java/com/bonait/bnframework/common/db/mode/BPA_SILOS_CALIBRATE.java View File

@@ -10,15 +10,15 @@ public class BPA_SILOS_CALIBRATE extends ModeBase {
//料仓编号
public int num;
//输出时间最大值:s
public int outputTimeMax;
public float outputTimeMax;
//输出时间最小值:s
public int outputTimeMin;
public float outputTimeMin;
//输入重量最大值: g
public int inputWightMax;
public float inputWightMax;
//输入重量最小值: g
public int inputWightMin;
public float inputWightMin;

public BPA_SILOS_CALIBRATE(String _nmae,int _num,int _OutMax,int _OutMin,int _InputMax,int _InputMin){
public BPA_SILOS_CALIBRATE(String _nmae,int _num,float _OutMax,float _OutMin,float _InputMax,float _InputMin){
name=_nmae;
num=_num;
outputTimeMax=_OutMax;


+ 2
- 2
app/src/main/java/com/bonait/bnframework/common/helper/MQTT.java View File

@@ -161,11 +161,11 @@ public class MQTT {
}

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

System.out.println("与 " +address +" 连接畅通.");
// System.out.println("与 " +address +" 连接畅通.");
return true;
}
} catch (IOException e) {


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

@@ -65,6 +65,7 @@ public class MessageLog {
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
Date date = new Date();
String tempMsg = formatter.format(date) + ":" + msg;
Log.d("调试日志",msg);
if(MsgInfo.length()>=8000)MsgInfo="";
MsgInfo = tempMsg + "\r\n" + MsgInfo;
if (MsgNotify != null)


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

@@ -156,11 +156,11 @@ public class ModbusTcpServer {
}

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


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

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



+ 43
- 24
app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/add_silos_ck_edit.java View File

@@ -332,12 +332,13 @@ public class add_silos_ck_edit extends LinearLayout {
control_switch_shoudong.setOnTouchListener(new OnTouchListener() {
@Override
public boolean onTouch(View view, MotionEvent motionEvent) {
String name = lcMode.name + lcMode.num+"启停控制";
if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
Log.e("鼠标", "按下: ");
ExecuteTheRecipe.WritePLC("手自切换", false, new IWriteCallBack() {
ExecuteTheRecipe.WritePLC("清洗模式", true, new IWriteCallBack() {
@Override
public void onSuccess() {
ExecuteTheRecipe.WritePLC("手动控制" + lcMode.num, true, null);
ExecuteTheRecipe.WritePLC(name, true, null);
}

@Override
@@ -346,33 +347,51 @@ public class add_silos_ck_edit extends LinearLayout {
});
} else if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
Log.e("鼠标", "松开: ");
ExecuteTheRecipe.WritePLC("手动控制" + lcMode.num, false, null);
ExecuteTheRecipe.WritePLC("清洗模式", false, null);
ExecuteTheRecipe.WritePLC(name, false, null);
}
return false;
}
});

control_huishou.setOnTouchListener(new OnTouchListener() {
@Override
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("M_外置仓" + lcMode.num + "反转", true, null);
}
@Override
public void onFailure(String ErrorMsg) {
}
});
} else if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
Log.e("鼠标", "松开: ");
ExecuteTheRecipe.WritePLC("M_外置仓" + lcMode.num + "反转", false, null);
}
return false;
}
});
// control_switch_shoudong.setOnTouchListener(new OnTouchListener() {
// @Override
// public boolean onTouch(View view, MotionEvent motionEvent) {
// String name = lcMode.name + lcMode.num+"启停控制";
// if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) {
// Log.e("鼠标", "按下: ");
// ExecuteTheRecipe.WritePLC("清洗模式", true,null);
// ExecuteTheRecipe.WritePLC(name, true, null);
// } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
// Log.e("鼠标", "松开: ");
// ExecuteTheRecipe.WritePLC("清洗模式", false,null);
// ExecuteTheRecipe.WritePLC(name, false, null);
// }
// return false;
// }
// });

// control_huishou.setOnTouchListener(new OnTouchListener() {
// @Override
// 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("M_外置仓" + lcMode.num + "反转", true, null);
//// }
//// @Override
//// public void onFailure(String ErrorMsg) {
//// }
//// });
// } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) {
//// Log.e("鼠标", "松开: ");
//// ExecuteTheRecipe.WritePLC("M_外置仓" + lcMode.num + "反转", false, null);
// }
// return false;
// }
// });

control_switch.setOnCheckedChangeListener(new SwitchButton.OnCheckedChangeListener() {
@Override


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

@@ -103,6 +103,9 @@ public class silos_jiaoyan extends LinearLayout {

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

// @BindView(R.id.controlStatus)
// TextView controlStatus;
//endregion


@@ -150,11 +153,23 @@ public class silos_jiaoyan extends LinearLayout {
InitView("物料校准");
Run();

// new Thread(()->{
// try{
// while(true){
// String name = lcMode.name+lcMode.num+"启停控制";
// boolean res = ExecuteTheRecipe.ReadBool(name);
// activity.runOnUiThread(()->{controlStatus.setText("控制状态:"+String.valueOf(res));});
// Thread.sleep(10);
// }
//
// }catch (Exception e){}
// }).start();

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));
min_weight.setText(String.valueOf(res.inputWightMin));
max_weight.setText(String.valueOf(res.inputWightMax));
}else{
min_time.setText("2");
@@ -256,14 +271,14 @@ public class silos_jiaoyan extends LinearLayout {



private int EditTextValidate(EditText et,String info){
private float EditTextValidate(EditText et,String info){
if(et==null) return -1;
if(et.getText().toString().isEmpty()){
DialogManager.showError(activity,info,AlertDialogButton.OK,null);
return -1;
}
try{
return Integer.parseInt(et.getText().toString());
return Float.parseFloat(et.getText().toString());
}catch (Exception e){
return -1;
}
@@ -278,7 +293,7 @@ public class silos_jiaoyan extends LinearLayout {
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,"请输入正确的时间");
float 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){
@@ -299,7 +314,7 @@ public class silos_jiaoyan extends LinearLayout {
WaitDialog.AddText("等待校准完成");
String name = lcMode.name+lcMode.num+"启停控制";
//等待出料完成
Unity.Wait(()->{return TTrig.get(name).Start(ExecuteTheRecipe.ReadBool(name));},time+2000).OnSource(()->{
Unity.Wait(()->{return TTrig.get(name).Start(ExecuteTheRecipe.ReadBool(name));},(int)(time+2000)).OnSource(()->{
//获取电子秤重量,并填充到对应位置
activity.runOnUiThread(()->{
if(view.getId()==R.id.min_time) min_time.setText(ExecuteTheRecipe.ReadShort(PLCName.当前重量));
@@ -314,20 +329,36 @@ public class silos_jiaoyan extends LinearLayout {
});
break;
case R.id.btn_sim_discharge:
try{
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;
}

}catch(Exception e){}

DialogManager.showWarn(activity,"模拟出料前请将容器放入指定位置!\r\n请问是否继续",AlertDialogButton.YesNo,(s->{
if(s){
try{
int weight = Integer.parseInt(sim_discharge_weight.getText().toString());
float weight = Float.parseFloat(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);
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+"出料时间",outValue*100,null);//下发出料时间
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));},(outValue*1000)+1000).OnSource(()->{
Unity.Wait(()->{return TTrig.get(name).Start(ExecuteTheRecipe.ReadBool(name));},(int)(outValue*1000)+2000).OnSource(()->{
WaitDialog.Dismiss();
}).OnFailed(msg->{WaitDialog.TimeOut("等待出料完成超时,请退出后重试!");});
TTrig.Remove(name);
@@ -347,10 +378,10 @@ public class silos_jiaoyan extends LinearLayout {
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());
float outputMax = Float.parseFloat(max_time.getText().toString());
float outputMin=Float.parseFloat(min_time.getText().toString());
float inputMax=Float.parseFloat(max_weight.getText().toString());
float inputMin=Float.parseFloat(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);


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

@@ -70,7 +70,7 @@

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="240dp"
android:layout_height="300dp"
android:background="@mipmap/listbj">

<LinearLayout


+ 25
- 15
app/src/main/res/layout/item/layout/item_caidan.xml View File

@@ -10,22 +10,32 @@
android:layout_width="match_parent"
android:layout_height="120dp"
android:background="@mipmap/listbj">
<ImageView
android:id="@+id/caidan_image"
android:layout_marginTop="14dp"
android:layout_width="70dp"
android:layout_height="70dp"
android:layout_centerHorizontal="true"
android:src="@mipmap/wlgl"/>
<TextView
android:id="@+id/caidan_text"

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_alignParentBottom="true"
android:layout_marginBottom="@dimen/dp_10"
android:text="基础数据管理"
android:textSize="@dimen/text_size_16"
android:textColor="@color/text_color"/>
android:orientation="vertical"
android:layout_centerVertical="true"
android:layout_centerHorizontal="true">

<ImageView
android:id="@+id/caidan_image"
android:layout_marginTop="14dp"
android:layout_width="match_parent"
android:layout_height="70dp"
android:layout_centerHorizontal="true"
android:src="@mipmap/wlgl"/>
<TextView
android:id="@+id/caidan_text"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/dp_10"
android:text="基础数据管理"
android:textSize="@dimen/text_size_16"
android:textColor="@color/text_color"/>

</LinearLayout>

</RelativeLayout>
</LinearLayout>

+ 12
- 5
app/src/main/res/layout/item/layout/silos_jiaoyan_item_edit.xml View File

@@ -117,7 +117,7 @@
android:background="@drawable/edit_bord"
android:digits="0123456789"
android:hint="请输入"
android:inputType="number"
android:inputType="numberDecimal|number"
android:maxLines="1"
android:padding="3dp"
android:text="2"
@@ -144,7 +144,7 @@
android:background="@drawable/edit_bord"
android:digits="0123456789"
android:hint="请输入"
android:inputType="number"
android:inputType="numberDecimal|number"
android:maxLines="1"
android:padding="3dp"
android:text="2"
@@ -189,7 +189,7 @@
android:background="@drawable/edit_bord"
android:digits="0123456789"
android:hint="请输入"
android:inputType="number"
android:inputType="numberDecimal|number"
android:maxLines="1"
android:padding="3dp"
android:text="2"
@@ -216,7 +216,7 @@
android:background="@drawable/edit_bord"
android:digits="0123456789"
android:hint="请输入"
android:inputType="number"
android:inputType="numberDecimal|number"
android:maxLines="1"
android:padding="3dp"
android:text="2"
@@ -268,7 +268,7 @@
android:background="@drawable/edit_bord"
android:digits="0123456789"
android:hint="请输入"
android:inputType="number"
android:inputType="number|numberDecimal"
android:maxLines="1"
android:padding="3dp"
android:text="2"
@@ -304,6 +304,13 @@
android:textColor="@color/white"
android:textSize="25sp" />

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

</LinearLayout>

</RelativeLayout>


Loading…
Cancel
Save