@@ -166,4 +166,8 @@ dependencies { | |||
implementation "org.projectlombok:lombok:1.16.18" | |||
implementation 'org.glassfish:javax.annotation:10.0-b28' | |||
coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.5' | |||
//gif加载包 | |||
implementation 'com.github.bumptech.glide:glide:4.9.0' | |||
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0' | |||
} |
@@ -19,14 +19,9 @@ public class DeviceData { | |||
public boolean PostPotLimit; | |||
/** | |||
* 摆臂上限 | |||
* 搅拌原点 | |||
*/ | |||
public boolean SwingArmUpperLimit; | |||
/** | |||
* 摆臂下限 | |||
*/ | |||
public boolean SwingArmLowerLimit; | |||
public boolean MixingOrigin; | |||
/** | |||
* 点火正常 | |||
@@ -203,6 +198,11 @@ public class DeviceData { | |||
*/ | |||
public NotifyPropVar<Float> UpperTemperatureLimitNotify =new NotifyPropVar<>(0f); | |||
/** | |||
* 搅拌速度更新 | |||
*/ | |||
public NotifyPropVar<Float> StirSpeedNotify=new NotifyPropVar<>(0f); | |||
/** | |||
* 搅拌控制状态通知 | |||
*/ | |||
@@ -257,6 +257,11 @@ public class DeviceData { | |||
* 备用故障 | |||
*/ | |||
public NotifyPropVar<Boolean> StandbyFailure=new NotifyPropVar<>(false); | |||
/** | |||
* 搅拌运行状态 | |||
*/ | |||
public NotifyPropVar<Boolean> MixingState=new NotifyPropVar<>(false); | |||
//endregion | |||
@@ -12,6 +12,7 @@ import com.bonait.bnframework.common.db.QueryDB; | |||
import com.bonait.bnframework.common.db.mode.BPA_GOODSRECIPE; | |||
import com.bonait.bnframework.common.db.mode.BPA_PLCADDRESS; | |||
import com.bonait.bnframework.common.db.mode.BPA_SILOS; | |||
import com.bonait.bnframework.common.helper.AlertDialogButton; | |||
import com.bonait.bnframework.common.helper.Convert; | |||
import com.bonait.bnframework.common.helper.Executor; | |||
import com.bonait.bnframework.common.helper.I.IDialogAction; | |||
@@ -31,6 +32,7 @@ import java.util.ArrayList; | |||
import java.util.HashMap; | |||
import java.util.List; | |||
import java.util.Map; | |||
import java.util.concurrent.ConcurrentHashMap; | |||
/** | |||
* 执行配方 | |||
@@ -81,6 +83,7 @@ public class ExecuteTheRecipe { | |||
ToastUtils.info("客官,小菠萝正在强制结束当前炒制菜品,请耐心等候!!!"); | |||
showlog("强制结束任务"); | |||
IsForcedEnd = true; | |||
CommHelper.get().siemens. CancelWrite=true; | |||
} | |||
/** | |||
@@ -88,6 +91,7 @@ public class ExecuteTheRecipe { | |||
*/ | |||
public static void StopForcedEnd() { | |||
IsForcedEnd = false; | |||
CommHelper.get().siemens. CancelWrite=false; | |||
} | |||
//endregion | |||
@@ -98,6 +102,15 @@ public class ExecuteTheRecipe { | |||
*/ | |||
public static DeviceData getDeviceData=new DeviceData(); | |||
private static ConcurrentHashMap<String,Boolean> MonitoringStatus=new ConcurrentHashMap<>(); | |||
public static boolean getMonitoringStatus(String name){ | |||
if(MonitoringStatus.containsKey(name)){ | |||
return MonitoringStatus.get(name); | |||
} | |||
return false; | |||
} | |||
public static void DeviceMonitor(){ | |||
ThreadManager.Get().StartLong("设备数据监听", true, new IThread() { | |||
@Override | |||
@@ -108,10 +121,18 @@ public class ExecuteTheRecipe { | |||
Convert.TryToBoolean(ReadPLC("监控_锅后限位")).OnSource(s->{ getDeviceData.PostPotLimit=s.Content;}); | |||
Convert.TryToBoolean(ReadPLC("监控_点火正常")).OnSource(s->{ getDeviceData.IgnitionNormal=s.Content;}); | |||
Convert.TryToBoolean(ReadPLC("监控_点火异常")).OnSource(s->{ getDeviceData.IgnitionError=s.Content;}); | |||
Convert.TryToBoolean(ReadPLC("监控_搅拌原点")).OnSource(s->{ getDeviceData.MixingOrigin=s.Content;}); | |||
Convert.TryToBoolean(ReadPLC("监控_急停按钮")).OnSource(s->{ getDeviceData.EStop=s.Content;}); | |||
Convert.TryToFloat(ReadPLC("炒锅当前重量")).OnSource(s->{ getDeviceData.CurrentWeight=s.Content;}); | |||
Convert.TryToFloat(ReadPLC("炒锅当前温度")).OnSource(s->{ getDeviceData.CurrentTemperature=s.Content;}); | |||
MonitoringStatus.put("监控_搅拌上限",getDeviceData.MixingUpperLimit); | |||
MonitoringStatus.put("监控_搅拌下限",getDeviceData.MixingLowerLimit); | |||
MonitoringStatus.put("监控_锅后限位",getDeviceData.PostPotLimit); | |||
MonitoringStatus.put("监控_点火正常",getDeviceData.IgnitionNormal); | |||
MonitoringStatus.put("监控_搅拌原点",getDeviceData.MixingOrigin); | |||
MonitoringStatus.put("监控_急停按钮",getDeviceData.EStop); | |||
Convert.TryToBoolean(ReadPLC("系统启停开关")).OnSource(s->{getDeviceData.SystemStartStopStatusNotify.setValue( s.Content);}); | |||
Convert.TryToBoolean(ReadPLC("超温停气开关")).OnSource(s->{getDeviceData.OverTemperatureShutdownNotify.setValue( s.Content);}); | |||
Convert.TryToBoolean(ReadPLC("点火手自动切换开关")).OnSource(s->{getDeviceData.IgnideModeNotify.setValue( s.Content);}); | |||
@@ -126,71 +147,26 @@ public class ExecuteTheRecipe { | |||
Convert.TryToBoolean(ReadPLC("点火启动开关")).OnSource(s->{getDeviceData.IgnitionStatusNotify.setValue( s.Content);}); | |||
Convert.TryToFloat(ReadPLC("炒锅温度修正")).OnSource(s->{getDeviceData.TemperatureCorrectionValueNotify.setValue( s.Content);}); | |||
Convert.TryToFloat(ReadPLC("炒锅温度上限设置")).OnSource(s->{getDeviceData.UpperTemperatureLimitNotify.setValue( s.Content);}); | |||
Convert.TryToFloat(ReadPLC("搅拌速度")).OnSource(s->{getDeviceData.StirSpeedNotify.setValue( s.Content);}); | |||
Convert.TryToBoolean(ReadPLC("搅拌启动开关")).OnSource(s->{getDeviceData.StirControlStatusNotify.setValue( s.Content);}); | |||
Convert.TryToBoolean(ReadPLC("料仓1出料")).OnSource(s->{getDeviceData.OilPumpingStatusNotify.setValue( s.Content);}); | |||
Convert.TryToBoolean(ReadPLC("料仓2出料")).OnSource(s->{getDeviceData.StandbyCylinderStatusNotify.setValue( s.Content);}); | |||
Convert.TryToFloat(ReadPLC("设定重量")).OnSource(s->{getDeviceData.SetWeightNotify.setValue( s.Content);}); | |||
Convert.TryToFloat(ReadPLC("设定提前量")).OnSource(s->{getDeviceData.LeadNotify.setValue( s.Content);}); | |||
Convert.TryToBoolean(ReadPLC("急停按下")).OnSource(s->{getDeviceData.EstopFaultNotify.setValue(s.Content);}); | |||
Convert.TryToBoolean(ReadPLC("油泵故障")).OnSource(s->{getDeviceData.OilPumpFault.setValue(s.Content);}); | |||
Convert.TryToBoolean(ReadPLC("搅拌故障")).OnSource(s->{getDeviceData.MixingFailure.setValue(s.Content);}); | |||
Convert.TryToBoolean(ReadPLC("点火异常")).OnSource(s->{getDeviceData.IgnitionMalfunction.setValue(s.Content);}); | |||
Convert.TryToBoolean(ReadPLC("高温报警")).OnSource(s->{getDeviceData.HighTemperatureAlarm.setValue(s.Content);}); | |||
Convert.TryToBoolean(ReadPLC("急停按下!")).OnSource(s->{getDeviceData.EstopFaultNotify.setValue(s.Content);}); | |||
Convert.TryToBoolean(ReadPLC("油泵故障!")).OnSource(s->{getDeviceData.OilPumpFault.setValue(s.Content);}); | |||
Convert.TryToBoolean(ReadPLC("搅拌故障!")).OnSource(s->{getDeviceData.MixingFailure.setValue(s.Content);}); | |||
Convert.TryToBoolean(ReadPLC("点火异常!")).OnSource(s->{getDeviceData.IgnitionMalfunction.setValue(s.Content);}); | |||
Convert.TryToBoolean(ReadPLC("高温报警!")).OnSource(s->{getDeviceData.HighTemperatureAlarm.setValue(s.Content);}); | |||
Convert.TryToBoolean(ReadPLC("备用故障1")).OnSource(s->{getDeviceData.StandbyFailure.setValue(s.Content);}); | |||
Convert.TryToBoolean(ReadPLC("监控-搅拌")).OnSource(s->{getDeviceData.MixingState.setValue(s.Content);}); | |||
// getDeviceData.MixingUpperLimit=Boolean.parseBoolean(ReadPLC("监控_搅拌上限").toString()); | |||
// getDeviceData.MixingLowerLimit=Boolean.parseBoolean(ReadPLC("监控_搅拌下限").toString()); | |||
// getDeviceData.PostPotLimit=Boolean.parseBoolean(ReadPLC("监控_锅后限位").toString()); | |||
// getDeviceData.IgnitionNormal=Boolean.parseBoolean(ReadPLC("监控_点火正常").toString()); | |||
// getDeviceData.IgnitionError=Boolean.parseBoolean(ReadPLC("监控_点火异常").toString()); | |||
// getDeviceData.EStop= Boolean.parseBoolean(ReadPLC("监控_急停按钮").toString()); | |||
// getDeviceData.CurrentWeight= Float.parseFloat(ReadPLC("炒锅当前重量").toString()); | |||
// getDeviceData.CurrentTemperature= Float.parseFloat(ReadPLC("炒锅当前温度").toString()); | |||
// getDeviceData.SystemStartStopStatus=Boolean.parseBoolean(ReadPLC("系统启停开关").toString()); | |||
// getDeviceData.SystemStartStopStatusNotify.setValue( getDeviceData.SystemStartStopStatus); | |||
// getDeviceData.OverTemperatureShutdown=Boolean.parseBoolean(ReadPLC("超温停气开关").toString()); | |||
// getDeviceData.OverTemperatureShutdownNotify.setValue(getDeviceData.OverTemperatureShutdown); | |||
// getDeviceData.IgnideMode =Boolean.parseBoolean(ReadPLC("点火手自动切换开关").toString()); | |||
// getDeviceData.IgnideModeNotify.setValue( getDeviceData.IgnideMode); | |||
// getDeviceData.SmallFireProportion =Float.parseFloat(ReadPLC("小火比例阀开度").toString()); | |||
// getDeviceData.SmallFireProportionNotify.setValue( getDeviceData.SmallFireProportion); | |||
// getDeviceData.MediumFireProportion =Float.parseFloat(ReadPLC("中火比例阀开度").toString()); | |||
// getDeviceData.MediumFireProportionNotify.setValue( getDeviceData.MediumFireProportion); | |||
// getDeviceData.HighFireProportion =Float.parseFloat(ReadPLC("大火比例阀开度").toString()); | |||
// getDeviceData.HighFireProportionNotify.setValue( getDeviceData.HighFireProportion); | |||
// getDeviceData.StrongFireProportion =Float.parseFloat(ReadPLC("强火比例阀开度").toString()); | |||
// getDeviceData.StrongFireProportionNotify.setValue( getDeviceData.StrongFireProportion); | |||
// getDeviceData.SmallFireStatus =Boolean.parseBoolean(ReadPLC("小火开关(一圈)").toString()); | |||
// getDeviceData.SmallFireStatusNotify.setValue( getDeviceData.SmallFireStatus); | |||
// | |||
// getDeviceData.MediumFireStatus =Boolean.parseBoolean(ReadPLC("中火开关(二圈)").toString()); | |||
// getDeviceData.MediumFireStatusNotify.setValue( getDeviceData.MediumFireStatus); | |||
// | |||
// getDeviceData.HighFireStatus =Boolean.parseBoolean(ReadPLC("大火开关(三圈)").toString()); | |||
// getDeviceData.HighFireStatusNotify.setValue( getDeviceData.HighFireStatus); | |||
// | |||
// getDeviceData.StrongFireStatus =Boolean.parseBoolean(ReadPLC("强火开关(四圈)").toString()); | |||
// getDeviceData.StrongFireStatusNotify.setValue( getDeviceData.StrongFireStatus); | |||
// | |||
// getDeviceData.IgnitionStatus =Boolean.parseBoolean(ReadPLC("点火启动开关").toString()); | |||
// getDeviceData.IgnitionStatusNotify.setValue( getDeviceData.IgnitionStatus); | |||
// | |||
// getDeviceData.TemperatureCorrectionValue =Float.parseFloat(ReadPLC("炒锅温度修正").toString()); | |||
// getDeviceData.TemperatureCorrectionValueNotify.setValue( getDeviceData.TemperatureCorrectionValue); | |||
// | |||
// getDeviceData.UpperTemperatureLimit =Float.parseFloat(ReadPLC("炒锅温度上限设置").toString()); | |||
// getDeviceData.UpperTemperatureLimitNotify.setValue( getDeviceData.UpperTemperatureLimit); | |||
// | |||
// getDeviceData.StirControlStatus =Boolean.parseBoolean(ReadPLC("搅拌启动开关").toString()); | |||
// getDeviceData.StirControlStatusNotify.setValue( getDeviceData.StirControlStatus); | |||
MonitoringStatus.put("急停按下!",getDeviceData.EstopFaultNotify.getValue()); | |||
MonitoringStatus.put("油泵故障!",getDeviceData.OilPumpFault.getValue()); | |||
MonitoringStatus.put("搅拌故障!",getDeviceData.MixingFailure.getValue()); | |||
MonitoringStatus.put("点火异常!",getDeviceData.IgnitionMalfunction.getValue()); | |||
MonitoringStatus.put("高温报警!",getDeviceData.HighTemperatureAlarm.getValue()); | |||
MonitoringStatus.put("备用故障1",getDeviceData.StandbyFailure.getValue()); | |||
Thread.sleep(10); | |||
} | |||
@@ -202,7 +178,21 @@ public class ExecuteTheRecipe { | |||
}); | |||
} | |||
/** | |||
* 故障检测 | |||
*/ | |||
public static void FaultDetect(){ | |||
if(getDeviceData.IgnitionMalfunction.getValue()&&!IsForcedEnd){ | |||
MessageLog.ShowError("点火异常中,等待重新点火"); | |||
AlertDialogUtils.showDialog("检测到点火异常,是否复位后重新点火?",AlertDialogButton.YesNo ,(s)->{ | |||
if(s){ | |||
BottomClick("点火复位开关");//复位点火开关 | |||
} | |||
}); | |||
} | |||
//等待点火异常复位 | |||
while (getDeviceData.IgnitionMalfunction.getValue()&&!IsForcedEnd){Delay(10);} | |||
} | |||
@@ -220,6 +210,7 @@ public class ExecuteTheRecipe { | |||
ExecuteTheRecipe.showlog("正在强制结束中,请耐心等待"); | |||
return false; | |||
} | |||
ExecuteTheRecipe.showlog("开始执行:" + recipe.sort + "、" + recipe.processms); | |||
if (recipe.materialType == 0)//正常物料 | |||
{ | |||
@@ -231,7 +222,6 @@ public class ExecuteTheRecipe { | |||
ExecuteOperationSteps(recipe.processname, recipe.processvalue); | |||
} | |||
} catch (Exception ex) { | |||
// ToastUtils.error("异常信息:" + ex.getMessage()); | |||
MessageLog.ShowError(ex.toString()); | |||
status = false; | |||
} finally { | |||
@@ -285,6 +275,7 @@ public class ExecuteTheRecipe { | |||
} | |||
} catch (Exception ex) { | |||
ToastUtils.error("异常信息:" + ex.getMessage()); | |||
MessageLog.ShowError("执行出料任务出错:"+ex.getMessage()); | |||
} | |||
} | |||
@@ -323,15 +314,18 @@ public class ExecuteTheRecipe { | |||
if (formulation.size() > 0) { | |||
switch (processname) { | |||
case "主料": | |||
FaultDetect(); | |||
Write_PLC_Ingredients(formulation); | |||
break; | |||
case "搅拌": | |||
FaultDetect(); | |||
Write_PLC_Stir(formulation); | |||
break; | |||
case "火力设置": | |||
Write_PLC_Heating(formulation); | |||
break; | |||
case "约束条件": | |||
FaultDetect(); | |||
Write_PLC_ConstraintCondition(formulation); | |||
break; | |||
@@ -438,7 +432,8 @@ public class ExecuteTheRecipe { | |||
ExecuteTheRecipe.showlog("手动已确认投入主料:" + name + "-继续流程"); | |||
} catch (Exception ex) { | |||
ToastUtils.error("异常信息:" + ex.getMessage()); | |||
// ToastUtils.error("异常信息:" + ex.getMessage()); | |||
MessageLog.ShowError(ex.getMessage()); | |||
} | |||
} | |||
@@ -469,7 +464,8 @@ public class ExecuteTheRecipe { | |||
BottomClickAsync("搅拌停止开关"); | |||
} | |||
} catch (Exception ex) { | |||
ToastUtils.error("异常信息:" + ex.getMessage()); | |||
// ToastUtils.error("异常信息:" + ex.getMessage()); | |||
MessageLog.ShowError(ex.getMessage()); | |||
} | |||
} | |||
@@ -488,7 +484,7 @@ public class ExecuteTheRecipe { | |||
static boolean WaitDialog(IDialogAction action){ | |||
while(HeatStatus<=0&&!IsForcedEnd){Delay(100);} | |||
if(HeatStatus==2)IsForcedEnd=true; | |||
if(HeatStatus==2)SetForcedEnd(); | |||
if(IsForcedEnd) return false; | |||
if(action!=null) action.ExitDialog(HeatStatus==1); | |||
HeatStatus=0; | |||
@@ -598,7 +594,7 @@ public class ExecuteTheRecipe { | |||
Write("点火启动开关", true);//重新点火 | |||
} | |||
else{ | |||
IsForcedEnd=true; | |||
SetForcedEnd(); | |||
MessageLog.ShowInfo("点火失败,取消继续点火,强制结束任务"); | |||
} | |||
}); | |||
@@ -629,10 +625,8 @@ public class ExecuteTheRecipe { | |||
Write("大火开关(三圈)", val3>0); | |||
Write("强火开关(四圈)", val4>0); | |||
} | |||
} catch (Exception ex) { | |||
ToastUtils.error("异常信息:" + ex.getMessage()); | |||
MessageLog.ShowError("Write_PLC_Heating"+ex.getMessage()); | |||
} | |||
} | |||
@@ -660,12 +654,11 @@ public class ExecuteTheRecipe { | |||
// } | |||
// } | |||
for (HashMap.Entry<String, String> entry : data.entrySet()) { | |||
String key = entry.getKey(); | |||
String value = entry.getValue(); | |||
if (key.contains("(秒)")) { | |||
Convert.<Integer>TryToGenericity(value).OnSource(p->{ | |||
Convert.TryToInt(value).OnSource(p->{ | |||
if (p.Content > 0 && !IsForcedEnd) { | |||
MessageLog.ShowInfo("等待时间:"+p.Content+" 秒"); | |||
ThreadDelay(p.Content); | |||
@@ -674,8 +667,8 @@ public class ExecuteTheRecipe { | |||
} | |||
}); | |||
} | |||
if (key.contains("锅内重量")) { | |||
Convert.<Float>TryToGenericity(value).OnSource(p->{ | |||
if (key.contains("温度设定")) { | |||
Convert.TryToFloat(value).OnSource(p->{ | |||
if (p.Content > 0 && !IsForcedEnd) { | |||
MessageLog.ShowInfo("等待温度:"+p.Content+" ℃"); | |||
ThreadWhile("炒锅当前温度", p.Content); | |||
@@ -684,8 +677,8 @@ public class ExecuteTheRecipe { | |||
} | |||
}); | |||
} | |||
if (key.contains("温度设定")) { | |||
Convert.<Float>TryToGenericity(value).OnSource(p->{ | |||
if (key.contains("锅内重量")) { | |||
Convert.TryToFloat(value).OnSource(p->{ | |||
if (p.Content > 0 && !IsForcedEnd) { | |||
MessageLog.ShowInfo("等待重量:"+p.Content+"KG"); | |||
ThreadWhile("炒锅当前重量", p.Content); | |||
@@ -722,7 +715,8 @@ public class ExecuteTheRecipe { | |||
// } | |||
} catch (Exception ex) { | |||
ToastUtils.error("异常信息:" + ex.getMessage()); | |||
// ToastUtils.error("异常信息:" + ex.getMessage()); | |||
MessageLog.ShowError(ex.getMessage()); | |||
} | |||
} | |||
//endregion | |||
@@ -756,6 +750,7 @@ public class ExecuteTheRecipe { | |||
} catch (Exception ex) { | |||
ToastUtils.error("异常信息:" + ex.getMessage()); | |||
showlog("异常信息:" + ex.getMessage()); | |||
} | |||
Thread.sleep(100); | |||
} | |||
@@ -770,12 +765,12 @@ public class ExecuteTheRecipe { | |||
@Override | |||
public void Run() throws InterruptedException { | |||
try { | |||
if (ConfigName.getInstance().PlcIsConnect) { | |||
// if (ConfigName.getInstance().PlcIsConnect) { | |||
//心跳 | |||
Write("上位机-PLC", true); | |||
Thread.sleep(500); | |||
Write("上位机-PLC", false); | |||
} | |||
// } | |||
} catch (Exception ex) { | |||
ToastUtils.error("异常信息:" + ex.getMessage()); | |||
} | |||
@@ -798,19 +793,6 @@ public class ExecuteTheRecipe { | |||
* @param name | |||
*/ | |||
public static void BottomClickAsync(String name) { | |||
// try { | |||
// Log.e("按钮按下", name); | |||
// Write(name, true); | |||
// Thread.sleep(100); | |||
// Write(name, false); | |||
// Log.e("按钮复位", name); | |||
// ExecuteTheRecipe.showlog("写入plc-------" + name); | |||
// } catch (Exception ex) { | |||
// Log.e("按钮异常", name + ex.getMessage()); | |||
// Write(name, false); | |||
// } | |||
Executor.get().runThread(()->{ | |||
try { | |||
// Log.e("按钮按下", name); | |||
@@ -958,13 +940,11 @@ public class ExecuteTheRecipe { | |||
public static void ThreadWhile(String name, Float val) { | |||
final boolean[] IsComplete = {false}; | |||
long a = System.currentTimeMillis(); | |||
// ExecuteTheRecipe.showlog(name + ",等待数据大于" + val); | |||
while (!IsComplete[0] && !IsForcedEnd) { | |||
Object sb = ReadPLC(name); | |||
float value = sb == null ? 0 : (float) (sb); | |||
if (value >= val) { | |||
IsComplete[0] = true; | |||
// ExecuteTheRecipe.showlog(name + ",接收到信号!"); | |||
} else { | |||
IsComplete[0] = false; | |||
} | |||
@@ -975,7 +955,6 @@ public class ExecuteTheRecipe { | |||
ExecuteTheRecipe.showlog(name + ",异常退出!" + e.getMessage()); | |||
} | |||
} | |||
// ExecuteTheRecipe.showlog(name + ",等待结束!"); | |||
} | |||
//endregion | |||
@@ -1151,7 +1130,7 @@ public class ExecuteTheRecipe { | |||
if (ConfigName.getInstance().PLC_Address.containsKey(name)) { | |||
BPA_PLCADDRESS plcaddress = ConfigName.getInstance().PLC_Address.get(name); | |||
if (!plcaddress.address.isEmpty()) { | |||
showlog(name+"_写入值_"+value); | |||
if(!name.contains("上位机-PLC")) showlog(name+"_写入值_"+value); | |||
CommHelper.get().writePLC(plcaddress.address, value); | |||
} | |||
else{ | |||
@@ -1162,8 +1141,7 @@ public class ExecuteTheRecipe { | |||
MessageLog.ShowInfo(name+":写入数据失败,配置文件中不存在该PLC地址"); | |||
} | |||
} catch (Exception ex) { | |||
ToastUtils.error("异常信息:" + ex.getMessage()); | |||
} finally { | |||
MessageLog.ShowError("Write"+ex.toString()); | |||
} | |||
} | |||
@@ -1194,9 +1172,11 @@ public class ExecuteTheRecipe { | |||
public static void DischargeControlAsync(Float SetWeight,Float SetLead){ | |||
showlog("手动出料,设定重量:"+SetWeight+",提前量:"+SetLead); | |||
Executor.get().runThread(()->{ | |||
CommHelper.get().siemens. CancelWrite=true; | |||
Write("设定重量", SetWeight); | |||
Write("设定提前量", SetLead); | |||
Write("料仓1出料", true); | |||
CommHelper.get().siemens. CancelWrite=false; | |||
}); | |||
} | |||
@@ -16,6 +16,7 @@ import com.bonait.bnframework.common.filepicker.PickerManager; | |||
import com.bonait.bnframework.common.filepicker.adapter.FilePickerShowAdapter; | |||
import com.bonait.bnframework.common.filepicker.adapter.OnFileItemClickListener; | |||
import com.bonait.bnframework.common.filepicker.util.OpenFile; | |||
import com.bonait.bnframework.common.helper.MessageLog; | |||
import com.bonait.bnframework.common.utils.AlertDialogUtils; | |||
import com.bonait.bnframework.common.utils.ToastUtils; | |||
import com.qmuiteam.qmui.arch.QMUIFragment; | |||
@@ -73,62 +74,67 @@ public abstract class BaseFragment extends QMUIFragment implements EasyPermissio | |||
* 跳转界面 | |||
*/ | |||
public void skipToActivity(Class da) { | |||
Context context=this.getContext(); | |||
if(ConfigName.getInstance().user.name.equals("admin") | |||
|| ConfigName.getInstance().user.account.equals("admin")) | |||
{ | |||
Intent intent = new Intent(context, da); | |||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); | |||
startActivity(intent); | |||
}else | |||
{ | |||
if(da.getName().equals("com.bonait.bnframework.modules.home.fragment.from.OrderListActivity") | |||
|| da.getName().equals("com.bonait.bnframework.modules.home.fragment.from.SalesStatisticsActivity") | |||
) | |||
try{ | |||
Context context=this.getContext(); | |||
if(ConfigName.getInstance().user.name.equals("admin") | |||
|| ConfigName.getInstance().user.account.equals("admin")) | |||
{ | |||
Intent intent = new Intent(context, da); | |||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); | |||
startActivity(intent); | |||
return; | |||
} | |||
}else | |||
{ | |||
if(da.getName().equals("com.bonait.bnframework.modules.home.fragment.from.OrderListActivity") | |||
|| da.getName().equals("com.bonait.bnframework.modules.home.fragment.from.SalesStatisticsActivity") | |||
) | |||
{ | |||
Intent intent = new Intent(context, da); | |||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); | |||
startActivity(intent); | |||
return; | |||
} | |||
// 跳转到登录页面 | |||
final QMUIDialog.EditTextDialogBuilder builder2 = new QMUIDialog.EditTextDialogBuilder(context); | |||
builder2.setTitle("权限验证") | |||
.setPlaceholder("在此输入权限密码") | |||
.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD) | |||
.addAction("取消", new QMUIDialogAction.ActionListener() { | |||
@Override | |||
public void onClick(QMUIDialog dialog, int index) { | |||
dialog.dismiss(); | |||
} | |||
}) | |||
.addAction("确定", new QMUIDialogAction.ActionListener() { | |||
@Override | |||
public void onClick(QMUIDialog dialog, int index) { | |||
CharSequence s = builder2.getEditText().getText(); | |||
if (s != null && s.length() > 0) | |||
{ | |||
if(s.toString().equals(ConfigName.getInstance().user.pass)) | |||
// 跳转到登录页面 | |||
final QMUIDialog.EditTextDialogBuilder builder2 = new QMUIDialog.EditTextDialogBuilder(context); | |||
builder2.setTitle("权限验证") | |||
.setPlaceholder("在此输入权限密码") | |||
.setInputType(InputType.TYPE_TEXT_VARIATION_PASSWORD) | |||
.addAction("取消", new QMUIDialogAction.ActionListener() { | |||
@Override | |||
public void onClick(QMUIDialog dialog, int index) { | |||
dialog.dismiss(); | |||
} | |||
}) | |||
.addAction("确定", new QMUIDialogAction.ActionListener() { | |||
@Override | |||
public void onClick(QMUIDialog dialog, int index) { | |||
CharSequence s = builder2.getEditText().getText(); | |||
if (s != null && s.length() > 0) | |||
{ | |||
Intent intent = new Intent(context, da); | |||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); | |||
startActivity(intent); | |||
dialog.dismiss(); | |||
if(s.toString().equals(ConfigName.getInstance().user.pass)) | |||
{ | |||
Intent intent = new Intent(context, da); | |||
intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); | |||
startActivity(intent); | |||
dialog.dismiss(); | |||
}else | |||
{ | |||
ToastUtils.warning("权限密码不正确!"); | |||
} | |||
}else | |||
{ | |||
ToastUtils.warning("权限密码不正确!"); | |||
ToastUtils.warning("权限密码不能为空!"); | |||
} | |||
}else | |||
{ | |||
ToastUtils.warning("权限密码不能为空!"); | |||
} | |||
} | |||
}) | |||
.show(); | |||
}) | |||
.show(); | |||
} | |||
}catch(Exception e){ | |||
MessageLog.ShowInfo("打开图片界面出错:"+e.toString()); | |||
} | |||
} | |||
@Override | |||
@@ -325,6 +325,7 @@ public class ConfigName { | |||
add(new Res_PLCADDRESS("称重画面", "-------------", 0, 0)); | |||
add(new Res_PLCADDRESS("料仓1出料", "V222.0", 1, 1)); | |||
add(new Res_PLCADDRESS("料仓2出料", "V222.1", 1, 1)); | |||
add(new Res_PLCADDRESS("重量清零", "V222.2", 1, 1)); | |||
add(new Res_PLCADDRESS("炒锅当前重量", "VD500", 1, 0)); | |||
add(new Res_PLCADDRESS("设定重量", "VD510", 0, 1)); | |||
add(new Res_PLCADDRESS("设定提前量", "VD514", 0, 1)); | |||
@@ -0,0 +1,8 @@ | |||
package com.bonait.bnframework.common.helper; | |||
public enum AlertDialogButton { | |||
OK , | |||
OKCancel, | |||
YesNoCancel, | |||
YesNo, | |||
} |
@@ -10,6 +10,7 @@ import com.bonait.bnframework.common.db.res.AlertLogEnum; | |||
import com.bonait.bnframework.common.db.res.UserLogEnum; | |||
import com.bonait.bnframework.common.helper.I.IMessageLogNotify; | |||
import com.bonait.bnframework.common.helper.I.IRun; | |||
import com.bonait.bnframework.common.utils.ToastUtils; | |||
import java.text.SimpleDateFormat; | |||
import java.util.Date; | |||
@@ -116,6 +117,7 @@ public class MessageLog { | |||
} | |||
public static void ShowError(String msg) { | |||
ToastUtils.error("异常信息:" +msg); | |||
SimpleDateFormat formatter = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | |||
Date date = new Date(); | |||
String tempMsg = formatter.format(date) + ":" + msg; | |||
@@ -28,6 +28,7 @@ public class MyBitmapUtils { | |||
mNetCacheUtils=new NetCacheUtils(mLocalCacheUtils,mMemoryCacheUtils); | |||
} | |||
public void disPlay(ImageView ivPic, String url) { | |||
if(url.isEmpty()) return; | |||
ivPic.setImageResource(R.mipmap.loading123); | |||
Bitmap bitmap; | |||
//内存缓存 | |||
@@ -44,7 +45,7 @@ public class MyBitmapUtils { | |||
bitmap=mMemoryCacheUtils.getBitmapFromMemory(name); | |||
if (bitmap!=null){ | |||
ivPic.setImageBitmap(bitmap); | |||
System.out.println("从内存获取图片啦....."); | |||
// System.out.println("从内存获取图片啦....."); | |||
return; | |||
} | |||
@@ -52,7 +53,7 @@ public class MyBitmapUtils { | |||
bitmap = mLocalCacheUtils.getBitmapFromLocal(name); | |||
if(bitmap !=null){ | |||
ivPic.setImageBitmap(bitmap); | |||
System.out.println("从本地获取图片啦....."); | |||
// System.out.println("从本地获取图片啦....."); | |||
//从本地获取图片后,保存至内存中 | |||
mMemoryCacheUtils.setBitmapToMemory(name,bitmap); | |||
return; | |||
@@ -85,10 +85,10 @@ public class CommHelper { | |||
} | |||
public Object readPLC(String add){ | |||
if(!IsConnected()) { | |||
MessageLog.ShowInfo(add+":读取数据失败,连接已断开"); | |||
return new Object(); | |||
} | |||
// if(!IsConnected()) { | |||
// MessageLog.ShowInfo(add+":读取数据失败,连接已断开"); | |||
// return new Object(); | |||
// } | |||
try{ | |||
if(add.toUpperCase().contains("VD")){ | |||
return siemens.ReadFloat32(add); | |||
@@ -37,6 +37,9 @@ public class SiemensHelper extends S7PLC { | |||
public Boolean IsConnected=false; | |||
public boolean CancelWrite=false; | |||
public void Delay(long millis){ | |||
try{ | |||
Thread.sleep(millis); | |||
@@ -46,178 +49,223 @@ public class SiemensHelper extends S7PLC { | |||
} | |||
public boolean ReadBoolean(String address){ | |||
if(!IsConnected){ | |||
MessageLog.ShowInfo(address+":读取数据失败,连接已断开"); | |||
return false; | |||
} | |||
try { | |||
boolean result=this.readBoolean(address); | |||
IsConnected=true; | |||
return result; | |||
} | |||
catch(SocketRuntimeException ex){ | |||
this.close(); | |||
IsConnected=false; | |||
// if(!IsConnected){ | |||
// MessageLog.ShowInfo(address+":读取数据失败,连接已断开"); | |||
// return false; | |||
// } | |||
boolean result=false; | |||
while(true){ | |||
try { | |||
result=this.readBoolean(address); | |||
IsConnected=true; | |||
break; | |||
} | |||
catch(SocketRuntimeException ex){ | |||
this.close(); | |||
IsConnected=false; | |||
Delay(1000); | |||
} | |||
} | |||
return false; | |||
return result; | |||
} | |||
public List<Boolean> ReadBoolean(String... address) { | |||
if(!IsConnected){ | |||
MessageLog.ShowInfo(address+":读取数据失败,连接已断开"); | |||
return new ArrayList<Boolean>(); | |||
} | |||
try { | |||
List<Boolean> result=this.readBoolean(Arrays.asList(address)); | |||
IsConnected=true; | |||
return result; | |||
} | |||
catch(SocketRuntimeException ex){ | |||
this.close(); | |||
IsConnected=false; | |||
// if(!IsConnected){ | |||
// MessageLog.ShowInfo(address+":读取数据失败,连接已断开"); | |||
// return new ArrayList<Boolean>(); | |||
// } | |||
List<Boolean> result=new ArrayList<>(); | |||
while(true){ | |||
try { | |||
result=this.readBoolean(Arrays.asList(address)); | |||
IsConnected=true; | |||
break; | |||
} | |||
catch(SocketRuntimeException ex){ | |||
this.close(); | |||
IsConnected=false; | |||
Delay(1000); | |||
} | |||
} | |||
return new ArrayList<Boolean>(); | |||
return result; | |||
} | |||
public short ReadInt16(String address) { | |||
if(!IsConnected){ | |||
MessageLog.ShowInfo(address+":读取数据失败,连接已断开"); | |||
return 0; | |||
} | |||
try { | |||
DataItem dataItem = this.readS7Data(AddressUtil.parseByte(address, 2)); | |||
short result= ShortUtil.toInt16(dataItem.getData()); | |||
IsConnected=true; | |||
return result; | |||
} | |||
catch(SocketRuntimeException ex){ | |||
this.close(); | |||
IsConnected=false; | |||
// if(!IsConnected){ | |||
// MessageLog.ShowInfo(address+":读取数据失败,连接已断开"); | |||
// return 0; | |||
// } | |||
short result=0; | |||
while(true){ | |||
try { | |||
DataItem dataItem = this.readS7Data(AddressUtil.parseByte(address, 2)); | |||
result= ShortUtil.toInt16(dataItem.getData()); | |||
IsConnected=true; | |||
break; | |||
} | |||
catch(SocketRuntimeException ex){ | |||
this.close(); | |||
IsConnected=false; | |||
Delay(1000); | |||
} | |||
} | |||
return 0; | |||
return result; | |||
} | |||
public List<Short> ReadInt16(String... address) { | |||
if(!IsConnected){ | |||
MessageLog.ShowInfo(address+":读取数据失败,连接已断开"); | |||
return new ArrayList<Short>(); | |||
} | |||
try { | |||
List<Short> result=this.readInt16(Arrays.asList(address)); | |||
IsConnected=true; | |||
return result; | |||
} | |||
catch(SocketRuntimeException ex){ | |||
this.close(); | |||
IsConnected=false; | |||
// if(!IsConnected){ | |||
// MessageLog.ShowInfo(address+":读取数据失败,连接已断开"); | |||
// return new ArrayList<Short>(); | |||
// } | |||
List<Short> result=new ArrayList<>(); | |||
while(true){ | |||
try { | |||
result=this.readInt16(Arrays.asList(address)); | |||
IsConnected=true; | |||
break; | |||
} | |||
catch(SocketRuntimeException ex){ | |||
this.close(); | |||
IsConnected=false; | |||
Delay(1000); | |||
} | |||
} | |||
return new ArrayList<Short>(); | |||
return result; | |||
} | |||
public int ReadUInt16(String address) { | |||
if(!IsConnected){ | |||
MessageLog.ShowInfo(address+":读取数据失败,连接已断开"); | |||
return 0; | |||
} | |||
try { | |||
DataItem dataItem = this.readS7Data(AddressUtil.parseByte(address, 2)); | |||
int result= ShortUtil.toUInt16(dataItem.getData()); | |||
IsConnected=true; | |||
return result; | |||
} | |||
catch(SocketRuntimeException ex){ | |||
this.close(); | |||
IsConnected=false; | |||
// if(!IsConnected){ | |||
// MessageLog.ShowInfo(address+":读取数据失败,连接已断开"); | |||
// return 0; | |||
// } | |||
int result=0; | |||
while(true){ | |||
try { | |||
DataItem dataItem = this.readS7Data(AddressUtil.parseByte(address, 2)); | |||
result= ShortUtil.toUInt16(dataItem.getData()); | |||
IsConnected=true; | |||
break; | |||
} | |||
catch(SocketRuntimeException ex){ | |||
this.close(); | |||
IsConnected=false; | |||
Delay(1000); | |||
} | |||
} | |||
return 0; | |||
return result; | |||
} | |||
public List<Integer> ReadUInt16(String... address) { | |||
if(!IsConnected){ | |||
MessageLog.ShowInfo(address+":读取数据失败,连接已断开"); | |||
return new ArrayList<Integer>(); | |||
} | |||
try { | |||
List<Integer> result=this.readUInt16(Arrays.asList(address)); | |||
IsConnected=true; | |||
return result; | |||
} | |||
catch(SocketRuntimeException ex){ | |||
this.close(); | |||
IsConnected=false; | |||
// if(!IsConnected){ | |||
// MessageLog.ShowInfo(address+":读取数据失败,连接已断开"); | |||
// return new ArrayList<Integer>(); | |||
// } | |||
List<Integer> result=new ArrayList<>(); | |||
while(true){ | |||
try { | |||
result=this.readUInt16(Arrays.asList(address)); | |||
IsConnected=true; | |||
break; | |||
} | |||
catch(SocketRuntimeException ex){ | |||
this.close(); | |||
IsConnected=false; | |||
Delay(1000); | |||
} | |||
} | |||
return new ArrayList<Integer>(); | |||
return result; | |||
} | |||
public int ReadInt32(String address) { | |||
if(!IsConnected){ | |||
MessageLog.ShowInfo(address+":读取数据失败,连接已断开"); | |||
return 0; | |||
} | |||
try { | |||
DataItem dataItem = this.readS7Data(AddressUtil.parseByte(address, 4)); | |||
int result= IntegerUtil.toInt32(dataItem.getData()); | |||
IsConnected=true; | |||
return result; | |||
} | |||
catch(SocketRuntimeException ex){ | |||
this.close(); | |||
IsConnected=false; | |||
// if(!IsConnected){ | |||
// MessageLog.ShowInfo(address+":读取数据失败,连接已断开"); | |||
// return 0; | |||
// } | |||
int result=0; | |||
while(true){ | |||
try { | |||
DataItem dataItem = this.readS7Data(AddressUtil.parseByte(address, 4)); | |||
result= IntegerUtil.toInt32(dataItem.getData()); | |||
IsConnected=true; | |||
break; | |||
} | |||
catch(SocketRuntimeException ex){ | |||
this.close(); | |||
IsConnected=false; | |||
Delay(1000); | |||
} | |||
} | |||
return 0; | |||
return result; | |||
} | |||
public List<Integer> ReadInt32(String... address) { | |||
if(!IsConnected){ | |||
MessageLog.ShowInfo(address+":读取数据失败,连接已断开"); | |||
return new ArrayList<Integer>(); | |||
} | |||
try { | |||
List<Integer> result=this.readInt32(Arrays.asList(address)); | |||
IsConnected=true; | |||
return result; | |||
} | |||
catch(SocketRuntimeException ex){ | |||
this.close(); | |||
IsConnected=false; | |||
// if(!IsConnected){ | |||
// MessageLog.ShowInfo(address+":读取数据失败,连接已断开"); | |||
// return new ArrayList<Integer>(); | |||
// } | |||
List<Integer> result=new ArrayList<>(); | |||
while(true){ | |||
try { | |||
result=this.readInt32(Arrays.asList(address)); | |||
IsConnected=true; | |||
break; | |||
} | |||
catch(SocketRuntimeException ex){ | |||
this.close(); | |||
IsConnected=false; | |||
Delay(1000); | |||
} | |||
} | |||
return new ArrayList<Integer>(); | |||
return result; | |||
} | |||
public float ReadFloat32(String address) { | |||
if(!IsConnected){ | |||
MessageLog.ShowInfo(address+":读取数据失败,连接已断开"); | |||
return 0; | |||
} | |||
try { | |||
DataItem dataItem = this.readS7Data(AddressUtil.parseByte(address, 4)); | |||
float result= FloatUtil.toFloat32(dataItem.getData()); | |||
IsConnected=true; | |||
return result; | |||
} | |||
catch(SocketRuntimeException ex){ | |||
this.close(); | |||
IsConnected=false; | |||
// if(!IsConnected){ | |||
// MessageLog.ShowInfo(address+":读取数据失败,连接已断开"); | |||
// return 0; | |||
// } | |||
float result=0f; | |||
while(true){ | |||
try { | |||
DataItem dataItem = this.readS7Data(AddressUtil.parseByte(address, 4)); | |||
result= FloatUtil.toFloat32(dataItem.getData()); | |||
IsConnected=true; | |||
break; | |||
} | |||
catch(SocketRuntimeException ex){ | |||
this.close(); | |||
IsConnected=false; | |||
Delay(1000); | |||
} | |||
} | |||
return 0; | |||
return result; | |||
} | |||
public List<Float> ReadFloat32(String... address) { | |||
if(!IsConnected){ | |||
MessageLog.ShowInfo(address+":读取数据失败,连接已断开"); | |||
return new ArrayList<Float>(); | |||
} | |||
try { | |||
List<Float> result=this.readFloat32(Arrays.asList(address)); | |||
IsConnected=true; | |||
return result; | |||
} | |||
catch(SocketRuntimeException ex){ | |||
this.close(); | |||
IsConnected=false; | |||
// if(!IsConnected){ | |||
// MessageLog.ShowInfo(address+":读取数据失败,连接已断开"); | |||
// return new ArrayList<Float>(); | |||
// } | |||
List<Float> result=new ArrayList<>(); | |||
while(true){ | |||
try { | |||
result=this.readFloat32(Arrays.asList(address)); | |||
IsConnected=true; | |||
break; | |||
} | |||
catch(SocketRuntimeException ex){ | |||
this.close(); | |||
IsConnected=false; | |||
Delay(1000); | |||
} | |||
} | |||
return new ArrayList<Float>(); | |||
return result; | |||
} | |||
public void WriteBoolean(String address, boolean data) { | |||
@@ -235,6 +283,7 @@ public class SiemensHelper extends S7PLC { | |||
this.close(); | |||
IsConnected=false; | |||
Delay(100); | |||
if(CancelWrite)break; | |||
} | |||
catch (Exception e){ | |||
MessageLog.ShowError("WriteBoolean 写入异常:"+e.toString()); | |||
@@ -258,6 +307,7 @@ public class SiemensHelper extends S7PLC { | |||
this.close(); | |||
IsConnected=false; | |||
Delay(100); | |||
if(CancelWrite)break; | |||
} | |||
catch (Exception e){ | |||
MessageLog.ShowError("WriteUInt16 写入异常:"+e.toString()); | |||
@@ -283,6 +333,7 @@ public class SiemensHelper extends S7PLC { | |||
this.close(); | |||
IsConnected=false; | |||
Delay(100); | |||
if(CancelWrite)break; | |||
} | |||
catch (Exception e){ | |||
MessageLog.ShowError("WriteInt16 写入异常:"+e.toString()); | |||
@@ -306,6 +357,7 @@ public class SiemensHelper extends S7PLC { | |||
this.close(); | |||
IsConnected=false; | |||
Delay(100); | |||
if(CancelWrite)break; | |||
} | |||
catch (Exception e){ | |||
MessageLog.ShowError("WriteUInt32 写入异常:"+e.toString()); | |||
@@ -329,6 +381,7 @@ public class SiemensHelper extends S7PLC { | |||
this.close(); | |||
IsConnected=false; | |||
Delay(100); | |||
if(CancelWrite)break; | |||
} | |||
catch (Exception e){ | |||
MessageLog.ShowError("WriteInt32 写入异常:"+e.toString()); | |||
@@ -352,6 +405,7 @@ public class SiemensHelper extends S7PLC { | |||
this.close(); | |||
IsConnected=false; | |||
Delay(100); | |||
if(CancelWrite)break; | |||
} | |||
catch (Exception e){ | |||
MessageLog.ShowError("WriteFloat32 写入异常:"+e.toString()); | |||
@@ -2,11 +2,13 @@ package com.bonait.bnframework.common.utils; | |||
import android.content.Context; | |||
import com.bonait.bnframework.common.helper.AlertDialogButton; | |||
import com.bonait.bnframework.common.helper.Executor; | |||
import com.bonait.bnframework.common.helper.I.IDialogAction; | |||
import com.bonait.bnframework.common.helper.I.IRun; | |||
import com.qmuiteam.qmui.widget.dialog.QMUIDialog; | |||
import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction; | |||
import com.qmuiteam.qmui.widget.dialog.QMUIDialogBuilder; | |||
/** | |||
* Created by LY on 2019/3/25. | |||
@@ -16,6 +18,8 @@ public class AlertDialogUtils { | |||
// 定义对话框主题样式 | |||
public static final int mCurrentDialogStyle = com.qmuiteam.qmui.R.style.QMUI_Dialog; | |||
public static Context getContext; | |||
/** | |||
* 对话框,只有确定按钮 | |||
* */ | |||
@@ -24,6 +28,7 @@ public class AlertDialogUtils { | |||
.setCancelable(false) | |||
.setTitle(title) | |||
.setMessage(message) | |||
.setCanceledOnTouchOutside(false)//取消触摸外部后自动关闭 | |||
.addAction("确定", new QMUIDialogAction.ActionListener() { | |||
@Override | |||
public void onClick(QMUIDialog dialog, int index) { | |||
@@ -41,12 +46,8 @@ public class AlertDialogUtils { | |||
.setCancelable(false) | |||
.setTitle(title) | |||
.setMessage(message) | |||
.addAction(ok, new QMUIDialogAction.ActionListener() { | |||
@Override | |||
public void onClick(QMUIDialog dialog, int index) { | |||
dialog.dismiss(); | |||
} | |||
}) | |||
.setCanceledOnTouchOutside(false)//取消触摸外部后自动关闭 | |||
.addAction(ok,(dialog, index)->{dialog.dismiss();}) | |||
.create(mCurrentDialogStyle).show(); | |||
} | |||
@@ -58,12 +59,8 @@ public class AlertDialogUtils { | |||
.setCancelable(false) | |||
.setTitle(title) | |||
.setMessage(message) | |||
.addAction("取消", new QMUIDialogAction.ActionListener() { | |||
@Override | |||
public void onClick(QMUIDialog dialog, int index) { | |||
dialog.dismiss(); | |||
} | |||
}) | |||
.setCanceledOnTouchOutside(false)//取消触摸外部后自动关闭 | |||
.addAction("取消",(dialog, index)->{dialog.dismiss();}) | |||
.addAction("确定", onClickListener) | |||
.create(mCurrentDialogStyle).show(); | |||
} | |||
@@ -76,15 +73,12 @@ public class AlertDialogUtils { | |||
.setCancelable(false) | |||
.setTitle(title) | |||
.setMessage(message) | |||
.setCanceledOnTouchOutside(false)//取消触摸外部后自动关闭 | |||
.addAction("取消", new QMUIDialogAction.ActionListener() { | |||
@Override | |||
public void onClick(QMUIDialog dialog, int index) { | |||
// if(action!=null)action.Cancel(); | |||
if(action!=null)action.ExitDialog(false); | |||
dialog.dismiss(); | |||
// Executor.get().runThread(()->{ | |||
// if(action!=null)action.ExitDialog(false); | |||
// }); | |||
} | |||
}) | |||
.addAction("确定", new QMUIDialogAction.ActionListener() { | |||
@@ -92,14 +86,45 @@ public class AlertDialogUtils { | |||
public void onClick(QMUIDialog dialog, int index) { | |||
if(action!=null)action.ExitDialog(true); | |||
dialog.dismiss(); | |||
// Executor.get().runThread(()->{ | |||
// if(action!=null)action.ExitDialog(true); | |||
// }); | |||
} | |||
}) | |||
.create(mCurrentDialogStyle).show(); | |||
} | |||
/** | |||
* 对话框,自定义按钮,非阻塞 | |||
* */ | |||
public static void showDialog(String message, AlertDialogButton btn, IDialogAction action) { | |||
if(getContext==null) return; | |||
QMUIDialogBuilder qmdb= new QMUIDialog.MessageDialogBuilder(getContext) | |||
.setCancelable(false) | |||
.setTitle("提示") | |||
.setMessage(message) | |||
.setCanceledOnTouchOutside(false);//取消触摸外部后自动关闭 | |||
String btnName1="确定"; | |||
String btnName2="取消"; | |||
if(btn==AlertDialogButton.YesNoCancel||btn==AlertDialogButton.YesNo){ | |||
btnName1="是"; | |||
btnName2="否"; | |||
} | |||
qmdb.addAction(btnName1, (dialog, index)->{ | |||
if(action!=null)action.ExitDialog(true); | |||
dialog.dismiss(); | |||
}); | |||
if(btn!=AlertDialogButton.OK){ | |||
qmdb.addAction(btnName2, (dialog, index)->{ | |||
if(action!=null)action.ExitDialog(false); | |||
dialog.dismiss(); | |||
}); | |||
} | |||
qmdb.create(mCurrentDialogStyle).show(); | |||
} | |||
/** | |||
* 对话框,自定义确定按钮 | |||
* */ | |||
@@ -108,6 +133,7 @@ public class AlertDialogUtils { | |||
.setCancelable(false) | |||
.setTitle(title) | |||
.setMessage(message) | |||
.setCanceledOnTouchOutside(false)//取消触摸外部后自动关闭 | |||
.addAction("取消", new QMUIDialogAction.ActionListener() { | |||
@Override | |||
public void onClick(QMUIDialog dialog, int index) { | |||
@@ -126,12 +152,8 @@ public class AlertDialogUtils { | |||
.setCancelable(false) | |||
.setTitle(title) | |||
.setMessage(message) | |||
.addAction("取消", new QMUIDialogAction.ActionListener() { | |||
@Override | |||
public void onClick(QMUIDialog dialog, int index) { | |||
dialog.dismiss(); | |||
} | |||
}) | |||
.setCanceledOnTouchOutside(false)//取消触摸外部后自动关闭 | |||
.addAction("取消", (dialog, index)->{dialog.dismiss();}) | |||
.addAction(0, ok, QMUIDialogAction.ACTION_PROP_NEGATIVE, onClickListener) | |||
.create(mCurrentDialogStyle).show(); | |||
} | |||
@@ -106,7 +106,11 @@ public class ToastUtils { | |||
} | |||
public static void error(@NonNull String message) { | |||
error(MainApplication.getContext(), message, Toast.LENGTH_SHORT, true).show(); | |||
try{ | |||
error(MainApplication.getContext(), message, Toast.LENGTH_SHORT, true).show(); | |||
}catch(Exception e) { | |||
} | |||
} | |||
//===========================================使用ApplicationContext 方法========================= | |||
@@ -5,6 +5,7 @@ import androidx.viewpager.widget.ViewPager; | |||
import android.os.Bundle; | |||
import android.util.Log; | |||
import android.view.MotionEvent; | |||
import com.bonait.bnframework.R; | |||
import com.bonait.bnframework.business.ConfigData; | |||
@@ -87,6 +88,7 @@ public class BottomNavigationMainActivity extends BaseActivity { | |||
viewPager.setOffscreenPageLimit(5); | |||
// 再来一单 | |||
viewPager.setCurrentItem(2); | |||
viewPager.setSwipeable(false);//禁用页面滑动功能 | |||
} | |||
/** | |||
@@ -23,6 +23,7 @@ import com.bonait.bnframework.common.filepicker.adapter.FilePickerShowAdapter; | |||
import com.bonait.bnframework.common.filepicker.adapter.OnFileItemClickListener; | |||
import com.bonait.bnframework.common.filepicker.model.FileEntity; | |||
import com.bonait.bnframework.common.filepicker.model.FileType; | |||
import com.bonait.bnframework.common.helper.MessageLog; | |||
import com.bonait.bnframework.common.image.utils.LocalCacheUtils; | |||
import com.bonait.bnframework.common.utils.ToastUtils; | |||
import com.qmuiteam.qmui.widget.QMUITopBarLayout; | |||
@@ -100,42 +101,47 @@ public class ImageSourceActivity extends BaseActivity { | |||
private static final String CACHE_PATH = Environment.getExternalStorageDirectory().getAbsolutePath() + "/hblchayingdb/WebImage"; | |||
public void FlushedImage() { | |||
File path = new File(CACHE_PATH);// 获得路径 | |||
File[] files = path.listFiles();// 读取文件 | |||
yx_files.clear(); | |||
for (File f : files) { | |||
String absolutePath = f.getAbsolutePath(); | |||
FileEntity e; | |||
if (checkExits(absolutePath)) { | |||
e = new FileEntity(absolutePath, f, true); | |||
} else { | |||
e = new FileEntity(absolutePath, f, false); | |||
} | |||
if (f.isFile()) { | |||
String[] imgs = {"png", "jpg", "jpeg", "gif"}; | |||
e.setFileType(new FileType("IMG", imgs, 0)); | |||
yx_files.add(e); | |||
try{ | |||
File path = new File(CACHE_PATH);// 获得路径 | |||
File[] files = path.listFiles();// 读取文件 | |||
yx_files.clear(); | |||
for (File f : files) { | |||
String absolutePath = f.getAbsolutePath(); | |||
FileEntity e; | |||
if (checkExits(absolutePath)) { | |||
e = new FileEntity(absolutePath, f, true); | |||
} else { | |||
e = new FileEntity(absolutePath, f, false); | |||
} | |||
if (f.isFile()) { | |||
String[] imgs = {"png", "jpg", "jpeg", "gif"}; | |||
e.setFileType(new FileType("IMG", imgs, 0)); | |||
yx_files.add(e); | |||
} | |||
} | |||
} | |||
rl_yx_file.setLayoutManager(new LinearLayoutManager(context)); | |||
FilePickerShowAdapter adapter = new FilePickerShowAdapter(context, yx_files); | |||
rl_yx_file.setAdapter(adapter); | |||
adapter.setOnItemClickListener(new OnFileItemClickListener() { | |||
@Override | |||
public void click(int position) { | |||
rl_yx_file.setLayoutManager(new LinearLayoutManager(context)); | |||
FilePickerShowAdapter adapter = new FilePickerShowAdapter(context, yx_files); | |||
rl_yx_file.setAdapter(adapter); | |||
adapter.setOnItemClickListener(new OnFileItemClickListener() { | |||
@Override | |||
public void click(int position) { | |||
// String path=yx_files.get(position).getPath(); | |||
// Bitmap bitmap =BitmapFactory.decodeFile("file://" + path); | |||
// MyImageDialog myImageDialog = new MyImageDialog(getActivity(),R.style.dialogWindowAnim,0,0,bitmap); | |||
// myImageDialog.show(); | |||
//打开系统相册浏览照片 | |||
//打开系统相册浏览照片 | |||
// Intent intent = new Intent(); | |||
// intent.setAction(Intent.ACTION_VIEW); | |||
// intent.setDataAndType(Uri.parse("file://" + path), "image/*"); | |||
// startActivity(intent); | |||
} | |||
}); | |||
} | |||
}); | |||
}catch(Exception e){ | |||
MessageLog.ShowError("图片管理界面异常:" +e.toString()); | |||
} | |||
} | |||
private static boolean checkExits(String path) { | |||
@@ -0,0 +1,21 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<shape xmlns:android="http://schemas.android.com/apk/res/android" | |||
android:shape="rectangle"> | |||
<size android:width="30dp" android:height="30dp"/> | |||
<!-- 填充的颜色 --> | |||
<solid android:color="#858080"/> | |||
<!-- android:radius 圆角的半径 --> | |||
<corners android:radius="15dp"/> | |||
<!--渐变--> | |||
<gradient | |||
android:angle="0" | |||
android:gradientRadius="90" | |||
android:type="radial" | |||
android:startColor="#FFFFFF" | |||
android:endColor="#858080"/> | |||
</shape> |
@@ -0,0 +1,21 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<shape xmlns:android="http://schemas.android.com/apk/res/android" | |||
android:shape="rectangle"> | |||
<size android:width="30dp" android:height="30dp"/> | |||
<!-- 填充的颜色 --> | |||
<solid android:color="#2EB30A"/> | |||
<!-- android:radius 圆角的半径 --> | |||
<corners android:radius="15dp"/> | |||
<!--渐变--> | |||
<gradient | |||
android:angle="0.5" | |||
android:gradientRadius="70" | |||
android:type="radial" | |||
android:startColor="#DFD8D8" | |||
android:endColor="#2EB30A"/> | |||
</shape> |
@@ -0,0 +1,20 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<shape xmlns:android="http://schemas.android.com/apk/res/android"> | |||
<size android:width="30dp" android:height="30dp"/> | |||
<!-- 填充的颜色 --> | |||
<solid android:color="#FF0000"/> | |||
<!-- android:radius 圆角的半径 --> | |||
<corners android:radius="15dp"/> | |||
<!--渐变--> | |||
<gradient | |||
android:angle="0" | |||
android:gradientRadius="90" | |||
android:type="radial" | |||
android:startColor="#DFD8D8" | |||
android:endColor="#FF0000"/> | |||
</shape> |
@@ -11,7 +11,7 @@ | |||
<!-- <solid android:color="@color/tab_panel_bg" />--> | |||
<stroke | |||
android:width="1dp" | |||
android:color="@color/color3" /> | |||
android:color="@color/app_color_blue" /> | |||
</shape> | |||
</item> | |||
@@ -8,10 +8,10 @@ | |||
<!-- 边框的颜色和粗细 --> | |||
<stroke | |||
android:width="10px" | |||
android:color="@color/file_picker_des"/> | |||
android:width="1px" | |||
android:color="@color/app_color_blue"/> | |||
<!-- android:radius 圆角的半径 --> | |||
<corners android:radius="10dp"/> | |||
<corners android:radius="0dp"/> | |||
</shape> |
@@ -32,7 +32,7 @@ | |||
android:id="@+id/main_weight" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_marginLeft="80dp" | |||
android:layout_marginLeft="10dp" | |||
android:layout_marginTop="120dp" | |||
android:text="重量:100KG" | |||
android:textColor="@color/app_color_blue" | |||
@@ -203,20 +203,30 @@ | |||
android:textSize="25dp" /> | |||
</LinearLayout> | |||
<com.capton.colorfulprogressbar.ColorfulProgressbar | |||
android:id="@+id/jingdu" | |||
xmlns:app="http://schemas.android.com/apk/res-auto" | |||
android:layout_width="400dp" | |||
android:layout_height="30dp" | |||
android:layout_alignParentBottom="true" | |||
android:layout_gravity="center" | |||
android:layout_marginTop="10dp" | |||
android:duration="3000" | |||
android:indeterminate="true" | |||
android:max="100" | |||
android:visibility="visible" | |||
app:progress="10" | |||
app:style="@string/style_colorful" /> | |||
<!-- <com.capton.colorfulprogressbar.ColorfulProgressbar--> | |||
<!-- android:id="@+id/jingdu"--> | |||
<!-- xmlns:app="http://schemas.android.com/apk/res-auto"--> | |||
<!-- android:layout_width="400dp"--> | |||
<!-- android:layout_height="30dp"--> | |||
<!-- android:layout_alignParentBottom="true"--> | |||
<!-- android:layout_gravity="center"--> | |||
<!-- android:layout_marginTop="10dp"--> | |||
<!-- android:duration="3000"--> | |||
<!-- android:indeterminate="true"--> | |||
<!-- android:max="100"--> | |||
<!-- android:visibility="visible"--> | |||
<!-- app:progress="10"--> | |||
<!-- app:style="@string/style_colorful" />--> | |||
<TextView | |||
android:id="@+id/gongxumiaoshu" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_marginTop="5dp" | |||
android:text="步骤1 加油50g" | |||
android:textColor="@color/yellow_green" | |||
android:textSize="18sp" /> | |||
</LinearLayout> | |||
</RelativeLayout> | |||
@@ -253,19 +263,20 @@ | |||
</RelativeLayout> | |||
</RelativeLayout> | |||
<LinearLayout | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content"> | |||
<TextView | |||
android:id="@+id/gongxumiaoshu" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_marginTop="5dp" | |||
android:text="步骤1 加油50g" | |||
android:textColor="#797373" | |||
android:textSize="14dp" /> | |||
</LinearLayout> | |||
<!-- <LinearLayout--> | |||
<!-- android:layout_width="wrap_content"--> | |||
<!-- android:layout_height="wrap_content">--> | |||
<!-- <TextView--> | |||
<!-- android:id="@+id/gongxumiaoshu"--> | |||
<!-- android:layout_width="wrap_content"--> | |||
<!-- android:layout_height="wrap_content"--> | |||
<!-- android:layout_marginTop="5dp"--> | |||
<!-- android:text="步骤1 加油50g"--> | |||
<!-- android:textColor="#797373"--> | |||
<!-- android:textSize="14dp" />--> | |||
<!-- </LinearLayout>--> | |||
<!--弹框控制按钮--> | |||
<LinearLayout | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" | |||
@@ -284,7 +295,6 @@ | |||
<Button | |||
android:id="@+id/btn_hlkz" | |||
android:layout_width="160dp" | |||
android:layout_height="55dp" | |||
android:layout_marginRight="15dp" | |||
@@ -313,6 +323,7 @@ | |||
android:textColor="@color/white" | |||
android:textSize="18sp"/> | |||
</LinearLayout> | |||
</LinearLayout> | |||
</LinearLayout> | |||
@@ -320,6 +331,8 @@ | |||
<RelativeLayout | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent"> | |||
<!--系统控制弹框--> | |||
<RelativeLayout | |||
android:id="@+id/dialog_xtkz" | |||
android:layout_width="match_parent" | |||
@@ -408,6 +421,7 @@ | |||
</RelativeLayout> | |||
</RelativeLayout> | |||
<!--火力控制弹框--> | |||
<RelativeLayout | |||
android:id="@+id/dialog_hlkz" | |||
android:layout_width="match_parent" | |||
@@ -466,12 +480,12 @@ | |||
android:textSize="19dp" /> | |||
</RelativeLayout> | |||
<!-- <Spinner--> | |||
<!-- android:id="@+id/editsp_点火模式"--> | |||
<!-- style="@style/commonSpinnerStyle"--> | |||
<!-- android:layout_width="80dp"--> | |||
<!-- android:layout_height="34dp"--> | |||
<!-- android:layout_centerVertical="true" />--> | |||
<!-- <Spinner--> | |||
<!-- android:id="@+id/editsp_点火模式"--> | |||
<!-- style="@style/commonSpinnerStyle"--> | |||
<!-- android:layout_width="80dp"--> | |||
<!-- android:layout_height="34dp"--> | |||
<!-- android:layout_centerVertical="true" />--> | |||
<RadioGroup | |||
@@ -479,22 +493,22 @@ | |||
android:layout_height="wrap_content" | |||
android:layout_marginLeft="10dp" | |||
android:orientation="horizontal"> | |||
<RadioButton | |||
android:id="@+id/RB_Hand" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:text="手动"/> | |||
android:text="手动" /> | |||
<RadioButton | |||
android:id="@+id/RB_Auto" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_marginLeft="10dp" | |||
android:text="自动"/> | |||
android:text="自动" /> | |||
</RadioGroup> | |||
</LinearLayout> | |||
<LinearLayout | |||
@@ -502,15 +516,15 @@ | |||
android:layout_height="wrap_content" | |||
android:layout_alignParentRight="true"> | |||
<!-- <Button--> | |||
<!-- android:id="@+id/button_点火复位"--> | |||
<!-- android:layout_width="120dp"--> | |||
<!-- android:layout_height="35dp"--> | |||
<!-- android:layout_marginRight="15dp"--> | |||
<!-- android:background="@drawable/bg_btn_login_selected"--> | |||
<!-- android:text="点火复位"--> | |||
<!-- android:textColor="@color/white"--> | |||
<!-- android:textSize="18sp" />--> | |||
<!-- <Button--> | |||
<!-- android:id="@+id/button_点火复位"--> | |||
<!-- android:layout_width="120dp"--> | |||
<!-- android:layout_height="35dp"--> | |||
<!-- android:layout_marginRight="15dp"--> | |||
<!-- android:background="@drawable/bg_btn_login_selected"--> | |||
<!-- android:text="点火复位"--> | |||
<!-- android:textColor="@color/white"--> | |||
<!-- android:textSize="18sp" />--> | |||
</LinearLayout> | |||
</RelativeLayout> | |||
@@ -819,7 +833,7 @@ | |||
android:layout_marginTop="-3dp" | |||
android:background="@drawable/input_bj" | |||
android:hint="请输入" | |||
android:inputType="numberDecimal" | |||
android:inputType="text" | |||
android:maxLines="1" | |||
android:paddingLeft="2dp" | |||
android:text="0.0" | |||
@@ -846,9 +860,9 @@ | |||
android:layout_marginTop="-3dp" | |||
android:background="@drawable/input_bj" | |||
android:hint="请输入" | |||
android:inputType="numberDecimal" | |||
android:paddingLeft="2dp" | |||
android:inputType="text" | |||
android:maxLines="1" | |||
android:paddingLeft="2dp" | |||
android:text="0.0" | |||
android:textSize="18sp" /> | |||
@@ -913,8 +927,8 @@ | |||
<TextView | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_marginTop="4dp" | |||
android:layout_marginLeft="5dp" | |||
android:layout_marginTop="4dp" | |||
android:text="点火失败" | |||
android:textColor="@color/purple_primary" | |||
android:textSize="19dp" /> | |||
@@ -934,10 +948,9 @@ | |||
</RelativeLayout> | |||
</RelativeLayout> | |||
</RelativeLayout> | |||
<!--搅拌升降控制弹框--> | |||
<RelativeLayout | |||
android:id="@+id/dialog_kbkz" | |||
android:layout_width="match_parent" | |||
@@ -1133,6 +1146,7 @@ | |||
</RelativeLayout> | |||
</RelativeLayout> | |||
<!--进油弹框--> | |||
<RelativeLayout | |||
android:id="@+id/dialog_jykz" | |||
android:layout_width="match_parent" | |||
@@ -1251,7 +1265,7 @@ | |||
android:layout_marginLeft="5dp" | |||
android:background="@drawable/input_bj" | |||
android:hint="请输入" | |||
android:inputType="numberDecimal" | |||
android:inputType="text" | |||
android:maxLines="1" | |||
android:paddingLeft="5dp" | |||
android:textSize="18sp" | |||
@@ -1276,7 +1290,7 @@ | |||
android:layout_marginLeft="5dp" | |||
android:background="@drawable/input_bj" | |||
android:hint="请输入" | |||
android:inputType="numberDecimal" | |||
android:inputType="text" | |||
android:maxLines="1" | |||
android:paddingLeft="5dp" | |||
android:textSize="18sp" | |||
@@ -1366,6 +1380,7 @@ | |||
</RelativeLayout> | |||
</RelativeLayout> | |||
</RelativeLayout> | |||
</RelativeLayout> | |||
</RelativeLayout> | |||