@@ -0,0 +1,264 @@ | |||
package com.bonait.bnframework.business; | |||
import com.bonait.bnframework.common.helper.NotifyPropVar; | |||
public class DeviceData { | |||
/** | |||
* 搅拌上限 | |||
*/ | |||
public boolean MixingUpperLimit; | |||
/** | |||
* 搅拌下限 | |||
*/ | |||
public boolean MixingLowerLimit; | |||
/** | |||
* 锅后限位 | |||
*/ | |||
public boolean PostPotLimit; | |||
/** | |||
* 摆臂上限 | |||
*/ | |||
public boolean SwingArmUpperLimit; | |||
/** | |||
* 摆臂下限 | |||
*/ | |||
public boolean SwingArmLowerLimit; | |||
/** | |||
* 点火正常 | |||
*/ | |||
public boolean IgnitionNormal; | |||
/** | |||
* 点火异常 | |||
*/ | |||
public boolean IgnitionError; | |||
/** | |||
* 设备急停 | |||
*/ | |||
public boolean EStop; | |||
/** | |||
* 炒锅当前重量 | |||
*/ | |||
public float CurrentWeight; | |||
/** | |||
* 炒锅当前温度 | |||
*/ | |||
public float CurrentTemperature; | |||
//region 状态属性 | |||
// /** | |||
// * 系统启停状态 | |||
// */ | |||
// public boolean SystemStartStopStatus; | |||
// | |||
// /** | |||
// * 超温停气状态 | |||
// */ | |||
// public boolean OverTemperatureShutdown; | |||
// | |||
// /** | |||
// * 点火模式:true:手动,false:自动 | |||
// */ | |||
// public boolean IgnideMode; | |||
// | |||
// /** | |||
// * 小火比例值 | |||
// */ | |||
// public float SmallFireProportion; | |||
// | |||
// /** | |||
// * 中火比例值 | |||
// */ | |||
// public float MediumFireProportion ; | |||
// | |||
// /** | |||
// * 大火比例值 | |||
// */ | |||
// public float HighFireProportion ; | |||
// | |||
// /** | |||
// * 强火比例值 | |||
// */ | |||
// public float StrongFireProportion ; | |||
// | |||
// /** | |||
// * 小火控制状态 | |||
// */ | |||
// public boolean SmallFireStatus; | |||
// | |||
// /** | |||
// * 中火控制状态 | |||
// */ | |||
// public boolean MediumFireStatus ; | |||
// | |||
// /** | |||
// * 大火控制状态 | |||
// */ | |||
// public boolean HighFireStatus ; | |||
// | |||
// /** | |||
// * 强火控制状态 | |||
// */ | |||
// public boolean StrongFireStatus ; | |||
// | |||
// /** | |||
// * 点火控制状态 | |||
// */ | |||
// public boolean IgnitionStatus; | |||
// | |||
// /** | |||
// * 温度修正值 | |||
// */ | |||
// public float TemperatureCorrectionValue; | |||
// | |||
// /** | |||
// * 温度上限值 | |||
// */ | |||
// public float UpperTemperatureLimit; | |||
// | |||
// /** | |||
// * 搅拌控制状态 | |||
// */ | |||
// public boolean StirControlStatus; | |||
//endregion | |||
//region 通知属性 | |||
/** | |||
* 系统启停状态通知对象 | |||
*/ | |||
public NotifyPropVar<Boolean> SystemStartStopStatusNotify=new NotifyPropVar<>(false); | |||
/** | |||
* 超温停气状态通知对象 | |||
*/ | |||
public NotifyPropVar<Boolean> OverTemperatureShutdownNotify=new NotifyPropVar<>(false); | |||
/** | |||
* 点火模式状态通知对象 | |||
*/ | |||
public NotifyPropVar<Boolean> IgnideModeNotify =new NotifyPropVar<>(false); | |||
/** | |||
* 小火比例值状态通知对象 | |||
*/ | |||
public NotifyPropVar<Float> SmallFireProportionNotify=new NotifyPropVar<>(0f); | |||
/** | |||
* 中火比例值状态通知对象 | |||
*/ | |||
public NotifyPropVar<Float> MediumFireProportionNotify =new NotifyPropVar<>(0f); | |||
/** | |||
* 大火比例值状态通知对象 | |||
*/ | |||
public NotifyPropVar<Float> HighFireProportionNotify =new NotifyPropVar<>(0f); | |||
/** | |||
* 强火比例值状态通知对象 | |||
*/ | |||
public NotifyPropVar<Float> StrongFireProportionNotify =new NotifyPropVar<>(0f); | |||
/** | |||
* 小火控制状态通知对象 | |||
*/ | |||
public NotifyPropVar<Boolean> SmallFireStatusNotify =new NotifyPropVar<>(false); | |||
/** | |||
* 中火控制状态通知对象 | |||
*/ | |||
public NotifyPropVar<Boolean> MediumFireStatusNotify =new NotifyPropVar<>(false); | |||
/** | |||
* 大火控制状态通知对象 | |||
*/ | |||
public NotifyPropVar<Boolean> HighFireStatusNotify =new NotifyPropVar<>(false) ; | |||
/** | |||
* 强火控制状态通知对象 | |||
*/ | |||
public NotifyPropVar<Boolean> StrongFireStatusNotify =new NotifyPropVar<>(false) ; | |||
/** | |||
* 点火控制状态态通知对象 | |||
*/ | |||
public NotifyPropVar<Boolean> IgnitionStatusNotify =new NotifyPropVar<>(false); | |||
/** | |||
* 温度修正值态通知对象 | |||
*/ | |||
public NotifyPropVar<Float> TemperatureCorrectionValueNotify =new NotifyPropVar<>(0f); | |||
/** | |||
* 温度上限值态通知对象 | |||
*/ | |||
public NotifyPropVar<Float> UpperTemperatureLimitNotify =new NotifyPropVar<>(0f); | |||
/** | |||
* 搅拌控制状态通知 | |||
*/ | |||
public NotifyPropVar<Boolean> StirControlStatusNotify =new NotifyPropVar<>(false); | |||
/** | |||
* 抽油启停状态通知 | |||
*/ | |||
public NotifyPropVar<Boolean> OilPumpingStatusNotify =new NotifyPropVar<>(false); | |||
/** | |||
* 备用气缸启停状态通知 | |||
*/ | |||
public NotifyPropVar<Boolean> StandbyCylinderStatusNotify =new NotifyPropVar<>(false); | |||
/** | |||
* 当前设定重量值改变通知 | |||
*/ | |||
public NotifyPropVar<Float> SetWeightNotify =new NotifyPropVar<>(0f); | |||
/** | |||
* 提前量设定值改变通知 | |||
*/ | |||
public NotifyPropVar<Float> LeadNotify =new NotifyPropVar<>(0f); | |||
/** | |||
* 急停故障 | |||
*/ | |||
public NotifyPropVar<Boolean> EstopFaultNotify=new NotifyPropVar<>(false); | |||
/** | |||
* 油泵故障 | |||
*/ | |||
public NotifyPropVar<Boolean> OilPumpFault=new NotifyPropVar<>(false); | |||
/** | |||
* 搅拌故障 | |||
*/ | |||
public NotifyPropVar<Boolean> MixingFailure=new NotifyPropVar<>(false); | |||
/** | |||
* 点火故障 | |||
*/ | |||
public NotifyPropVar<Boolean> IgnitionMalfunction=new NotifyPropVar<>(false); | |||
/** | |||
* 高温报警 | |||
*/ | |||
public NotifyPropVar<Boolean> HighTemperatureAlarm=new NotifyPropVar<>(false); | |||
/** | |||
* 备用故障 | |||
*/ | |||
public NotifyPropVar<Boolean> StandbyFailure=new NotifyPropVar<>(false); | |||
//endregion | |||
} |
@@ -3,8 +3,6 @@ package com.bonait.bnframework.business; | |||
import android.app.Activity; | |||
import android.content.Context; | |||
import android.content.ContextWrapper; | |||
import android.os.Handler; | |||
import android.os.Looper; | |||
import android.util.Log; | |||
import androidx.annotation.NonNull; | |||
@@ -14,13 +12,17 @@ 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.I.IRun; | |||
import com.bonait.bnframework.common.helper.Convert; | |||
import com.bonait.bnframework.common.helper.Executor; | |||
import com.bonait.bnframework.common.helper.I.IDialogAction; | |||
import com.bonait.bnframework.common.helper.I.IRunT; | |||
import com.bonait.bnframework.common.helper.I.IThread; | |||
import com.bonait.bnframework.common.helper.I.IWriteCallBack; | |||
import com.bonait.bnframework.common.helper.MessageLog; | |||
import com.bonait.bnframework.common.helper.NotifyPropVar; | |||
import com.bonait.bnframework.common.helper.Result.OperateResultT; | |||
import com.bonait.bnframework.common.helper.ThreadManager; | |||
import com.bonait.bnframework.common.modbus.s7.CommHelper; | |||
import com.bonait.bnframework.common.modbus.s7.SiemensHelper; | |||
import com.bonait.bnframework.common.utils.AlertDialogUtils; | |||
import com.bonait.bnframework.common.utils.ToastUtils; | |||
import com.qmuiteam.qmui.widget.dialog.QMUIDialog; | |||
import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction; | |||
@@ -55,7 +57,8 @@ public class ExecuteTheRecipe { | |||
/** | |||
* 是否启动 | |||
*/ | |||
public static boolean IsStart = false; | |||
public static NotifyPropVar<Boolean> IsStart = new NotifyPropVar<>(false); | |||
/** | |||
* 通知手动暂停 | |||
*/ | |||
@@ -64,6 +67,9 @@ public class ExecuteTheRecipe { | |||
* 手动操作耗时时长 | |||
*/ | |||
public static int HandTime = 0; | |||
public static Context mainContext; | |||
public static Activity mainActivity; | |||
//endregion | |||
//region 强制结束 | |||
@@ -73,6 +79,7 @@ public class ExecuteTheRecipe { | |||
*/ | |||
public static void SetForcedEnd() { | |||
ToastUtils.info("客官,小菠萝正在强制结束当前炒制菜品,请耐心等候!!!"); | |||
showlog("强制结束任务"); | |||
IsForcedEnd = true; | |||
} | |||
@@ -86,6 +93,119 @@ public class ExecuteTheRecipe { | |||
//region 执行配方 | |||
/** | |||
* 设备状态信号 | |||
*/ | |||
public static DeviceData getDeviceData=new DeviceData(); | |||
public static void DeviceMonitor(){ | |||
ThreadManager.Get().StartLong("设备数据监听", true, new IThread() { | |||
@Override | |||
public void Run() throws InterruptedException { | |||
Convert.TryToBoolean(ReadPLC("监控_搅拌上限")).OnSource(s->{ getDeviceData.MixingUpperLimit=s.Content;}); | |||
Convert.TryToBoolean(ReadPLC("监控_搅拌下限")).OnSource(s->{ getDeviceData.MixingLowerLimit=s.Content;}); | |||
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.EStop=s.Content;}); | |||
Convert.TryToFloat(ReadPLC("炒锅当前重量")).OnSource(s->{ getDeviceData.CurrentWeight=s.Content;}); | |||
Convert.TryToFloat(ReadPLC("炒锅当前温度")).OnSource(s->{ getDeviceData.CurrentTemperature=s.Content;}); | |||
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);}); | |||
Convert.TryToFloat(ReadPLC("小火比例阀开度")).OnSource(s->{getDeviceData.SmallFireProportionNotify.setValue( s.Content);}); | |||
Convert.TryToFloat(ReadPLC("中火比例阀开度")).OnSource(s->{getDeviceData.MediumFireProportionNotify.setValue( s.Content);}); | |||
Convert.TryToFloat(ReadPLC("大火比例阀开度")).OnSource(s->{getDeviceData.HighFireProportionNotify.setValue( s.Content);}); | |||
Convert.TryToFloat(ReadPLC("强火比例阀开度")).OnSource(s->{getDeviceData.StrongFireProportionNotify.setValue( s.Content);}); | |||
Convert.TryToBoolean(ReadPLC("小火开关(一圈)")).OnSource(s->{getDeviceData.SmallFireStatusNotify.setValue( s.Content);}); | |||
Convert.TryToBoolean(ReadPLC("中火开关(二圈)")).OnSource(s->{getDeviceData.MediumFireStatusNotify.setValue( s.Content);}); | |||
Convert.TryToBoolean(ReadPLC("大火开关(三圈)")).OnSource(s->{getDeviceData.HighFireStatusNotify.setValue( s.Content);}); | |||
Convert.TryToBoolean(ReadPLC("强火开关(四圈)")).OnSource(s->{getDeviceData.StrongFireStatusNotify.setValue( s.Content);}); | |||
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.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("备用故障1")).OnSource(s->{getDeviceData.StandbyFailure.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); | |||
Thread.sleep(10); | |||
} | |||
@Override | |||
public void RunComplete() throws InterruptedException { | |||
} | |||
}); | |||
} | |||
/** | |||
* 执行配方 | |||
* | |||
@@ -97,7 +217,7 @@ public class ExecuteTheRecipe { | |||
try { | |||
//1.解析 | |||
if (IsForcedEnd) { | |||
ExecuteTheRecipe.showlog("客官,小菠萝正在强制结束当前炒制菜品,请耐心等候!!!"); | |||
ExecuteTheRecipe.showlog("正在强制结束中,请耐心等待"); | |||
return false; | |||
} | |||
ExecuteTheRecipe.showlog("开始执行:" + recipe.sort + "、" + recipe.processms); | |||
@@ -111,7 +231,8 @@ public class ExecuteTheRecipe { | |||
ExecuteOperationSteps(recipe.processname, recipe.processvalue); | |||
} | |||
} catch (Exception ex) { | |||
ToastUtils.error("异常信息:" + ex.getMessage()); | |||
// ToastUtils.error("异常信息:" + ex.getMessage()); | |||
MessageLog.ShowError(ex.toString()); | |||
status = false; | |||
} finally { | |||
return status; | |||
@@ -235,10 +356,10 @@ public class ExecuteTheRecipe { | |||
try { | |||
ExecuteTheRecipe.showlog("准备写入PLC仓号需求:" + silos.num + "," + val); | |||
String name = "料仓" + silos.num + "出料"; | |||
WritePLC(name, false); //复位料仓1号 | |||
Write(name, false); //复位料仓1号 | |||
WritePLC("设定重量", val); | |||
WritePLC("设定提前量", 20); | |||
Write("设定重量", val); | |||
Write("设定提前量", 20); | |||
ExecuteTheRecipe.showlog("需求值写入成功!"); | |||
//減去料仓数量 | |||
@@ -246,7 +367,7 @@ public class ExecuteTheRecipe { | |||
QueryDB.UpdateYL(silos.id, otherG >= 0 ? otherG : 0); | |||
//开始出料 | |||
WritePLC(name, true); | |||
Write(name, true); | |||
//等待出料完成,false信号 | |||
ThreadWhileMaterialOver(name); | |||
@@ -340,18 +461,49 @@ public class ExecuteTheRecipe { | |||
} | |||
} | |||
WritePLC("搅拌速度", seep); | |||
Write("搅拌速度", seep); | |||
if (status) { | |||
BottomClick("搅拌启动开关"); | |||
BottomClickAsync("搅拌启动开关"); | |||
} else { | |||
BottomClick("搅拌停止开关"); | |||
BottomClickAsync("搅拌停止开关"); | |||
} | |||
} catch (Exception ex) { | |||
ToastUtils.error("异常信息:" + ex.getMessage()); | |||
} | |||
} | |||
/** | |||
* 加热流程状态,0:无,1:确认,2:取消 | |||
*/ | |||
static int HeatStatus=0; | |||
static void Delay(long millis){ | |||
try{ | |||
Thread.sleep(millis); | |||
}catch(InterruptedException e){ | |||
} | |||
} | |||
static boolean WaitDialog(IDialogAction action){ | |||
while(HeatStatus<=0&&!IsForcedEnd){Delay(100);} | |||
if(HeatStatus==2)IsForcedEnd=true; | |||
if(IsForcedEnd) return false; | |||
if(action!=null) action.ExitDialog(HeatStatus==1); | |||
HeatStatus=0; | |||
return false; | |||
} | |||
public static void ForcedEndTask(){ | |||
Write("点火启动开关", false);//启动点火 | |||
Write("小火开关(一圈)", false); | |||
Write("中火开关(二圈)", false); | |||
Write("大火开关(三圈)", false); | |||
Write("强火开关(四圈)", false); | |||
BottomClick("搅拌停止开关"); | |||
} | |||
/** | |||
* 写PLC 设置加热功率 | |||
* | |||
@@ -359,6 +511,7 @@ public class ExecuteTheRecipe { | |||
*/ | |||
private static void Write_PLC_Heating(HashMap<String, String> data) { | |||
try { | |||
boolean status = false; | |||
int val1 = 0; | |||
int val2 = 0; | |||
int val3 = 0; | |||
@@ -375,13 +528,109 @@ public class ExecuteTheRecipe { | |||
val3 = Integer.parseInt(value); | |||
} else if (key.contains("四环功率")) { | |||
val4 = Integer.parseInt(value); | |||
} else if (key.contains("火力状态")) { | |||
status = value.contains("启动") ? true : false; | |||
} | |||
} | |||
WritePLC("小火开关(一圈)", val1); | |||
WritePLC("中火开关(二圈)", val2); | |||
WritePLC("大火开关(三圈)", val3); | |||
WritePLC("强火开关(四圈)", val4); | |||
if(status){ | |||
MessageLog.ShowInfo("开火中...."); | |||
//确认点火提示 | |||
mainActivity.runOnUiThread(()->{ | |||
AlertDialogUtils.showDialog(mainContext, "提示", "是否开始点火?",(s)->{ | |||
HeatStatus=s?1:2; | |||
}); | |||
}); | |||
//等待弹框关闭 | |||
WaitDialog((s)->{ | |||
if(s){ | |||
MessageLog.ShowInfo("确认开始点火"); | |||
Write("点火手自动切换开关", false);//设置自动点火模式 | |||
Write("点火启动开关", true);//启动点火 | |||
} | |||
}); | |||
while(!IsForcedEnd){ | |||
if(getDeviceData.IgnitionError){ | |||
MessageLog.ShowInfo("点火失败,请求重试"); | |||
// mainActivity.runOnUiThread(new Runnable() { | |||
// @Override | |||
// public void run() { | |||
// AlertDialogUtils.showDialog(mainContext, "提示", "点火失败,是否复位后重试?", new IDialogAction() { | |||
// @Override | |||
// public void Confirm() { | |||
// MessageLog.ShowInfo("确认重新点火"); | |||
// WriteAsync("点火手自动切换开关", false);//设置自动点火模式 | |||
// WriteAsync("点火启动开关", false);//关闭点火 | |||
// BottomClick("点火复位开关");//复位点火开关 | |||
// WriteAsync("点火启动开关", true);//重新点火 | |||
// } | |||
// @Override | |||
// public void Cancel() { | |||
// IsForcedEnd=true; | |||
// MessageLog.ShowInfo("点火失败,取消继续点火,强制结束任务"); | |||
// } | |||
// | |||
// @Override | |||
// public void ExitDialog(boolean status) { | |||
// | |||
// } | |||
// }); | |||
// } | |||
// }); | |||
//点火失败提示 | |||
mainActivity.runOnUiThread(()->{ | |||
AlertDialogUtils.showDialog(mainContext, "提示", "点火失败,是否复位后重试?",(s)->{ | |||
HeatStatus=s?1:2; | |||
}); | |||
}); | |||
//等待弹框被关闭 | |||
WaitDialog((s)->{ | |||
if(s){ | |||
MessageLog.ShowInfo("确认重新点火"); | |||
Write("点火手自动切换开关", false);//设置自动点火模式 | |||
Write("点火启动开关", false);//关闭点火 | |||
BottomClick("点火复位开关");//复位点火开关 | |||
Write("点火启动开关", true);//重新点火 | |||
} | |||
else{ | |||
IsForcedEnd=true; | |||
MessageLog.ShowInfo("点火失败,取消继续点火,强制结束任务"); | |||
} | |||
}); | |||
Delay(2000); | |||
} | |||
Delay(3000); | |||
if(getDeviceData.IgnitionNormal){ | |||
MessageLog.ShowInfo("开火成功"); | |||
break; | |||
} | |||
Delay(100); | |||
} | |||
}else{ | |||
MessageLog.ShowInfo("关火中...."); | |||
Write("点火启动开关", false);//关闭点火 | |||
} | |||
if(!IsForcedEnd){ | |||
Write("小火比例阀开度", val1); | |||
Write("中火比例阀开度", val2); | |||
Write("大火比例阀开度", val3); | |||
Write("强火比例阀开度", val4); | |||
Write("小火开关(一圈)", val1>0); | |||
Write("中火开关(二圈)", val2>0); | |||
Write("大火开关(三圈)", val3>0); | |||
Write("强火开关(四圈)", val4>0); | |||
} | |||
} catch (Exception ex) { | |||
ToastUtils.error("异常信息:" + ex.getMessage()); | |||
} | |||
@@ -394,38 +643,83 @@ public class ExecuteTheRecipe { | |||
*/ | |||
private static void Write_PLC_ConstraintCondition(HashMap<String, String> data) { | |||
try { | |||
int time = 0; | |||
int temp = 0; | |||
int val = 0; | |||
// int time = 0; | |||
// float temp = 0; | |||
// float val = 0; | |||
// for (HashMap.Entry<String, String> entry : data.entrySet()) { | |||
// String key = entry.getKey(); | |||
// String value = entry.getValue(); | |||
// if (key.contains("(秒)")) { | |||
// time = Integer.parseInt(value); | |||
// } | |||
// if (key.contains("锅内重量")) { | |||
// val = Float.parseFloat(value); | |||
// } | |||
// if (key.contains("温度设定")) { | |||
// temp = Float.parseFloat(value); | |||
// } | |||
// } | |||
for (HashMap.Entry<String, String> entry : data.entrySet()) { | |||
String key = entry.getKey(); | |||
String value = entry.getValue(); | |||
if (key.contains("(秒)")) { | |||
time = Integer.parseInt(value); | |||
Convert.<Integer>TryToGenericity(value).OnSource(p->{ | |||
if (p.Content > 0 && !IsForcedEnd) { | |||
MessageLog.ShowInfo("等待时间:"+p.Content+" 秒"); | |||
ThreadDelay(p.Content); | |||
if(IsForcedEnd) MessageLog.ShowInfo("等待时间:强制结束"); | |||
else MessageLog.ShowInfo("等待时间完成"); | |||
} | |||
}); | |||
} | |||
if (key.contains("锅内重量")) { | |||
val = Integer.parseInt(value); | |||
Convert.<Float>TryToGenericity(value).OnSource(p->{ | |||
if (p.Content > 0 && !IsForcedEnd) { | |||
MessageLog.ShowInfo("等待温度:"+p.Content+" ℃"); | |||
ThreadWhile("炒锅当前温度", p.Content); | |||
if(IsForcedEnd) MessageLog.ShowInfo("等待温度:强制结束"); | |||
else MessageLog.ShowInfo("等待温度完成"); | |||
} | |||
}); | |||
} | |||
if (key.contains("温度设定")) { | |||
temp = Integer.parseInt(value); | |||
Convert.<Float>TryToGenericity(value).OnSource(p->{ | |||
if (p.Content > 0 && !IsForcedEnd) { | |||
MessageLog.ShowInfo("等待重量:"+p.Content+"KG"); | |||
ThreadWhile("炒锅当前重量", p.Content); | |||
if(IsForcedEnd) MessageLog.ShowInfo("等待重量:强制结束"); | |||
else MessageLog.ShowInfo("等待重量完成"); | |||
} | |||
}); | |||
} | |||
} | |||
//1.判断等待时长是否满足 | |||
if (time > 0 && !IsForcedEnd) { | |||
ThreadDelay(time); | |||
} | |||
// if (time > 0 && !IsForcedEnd) { | |||
// MessageLog.ShowInfo("等待时间:"+time+" 秒"); | |||
// ThreadDelay(time); | |||
// if(IsForcedEnd) MessageLog.ShowInfo("等待时间:强制结束"); | |||
// else MessageLog.ShowInfo("等待时间完成"); | |||
// } | |||
//2.判断温度是否满足 | |||
if (temp > 0 && !IsForcedEnd) { | |||
ThreadWhile("炒锅当前温度", temp); | |||
} | |||
// if (temp > 0 && !IsForcedEnd) { | |||
// MessageLog.ShowInfo("等待温度:"+temp+" ℃"); | |||
// ThreadWhile("炒锅当前温度", temp); | |||
// if(IsForcedEnd) MessageLog.ShowInfo("等待温度:强制结束"); | |||
// else MessageLog.ShowInfo("等待温度完成"); | |||
// } | |||
//3.判断重量是否到达 | |||
if (val > 0 && !IsForcedEnd) { | |||
ThreadWhile("炒锅当前重量", val); | |||
} | |||
// if (val > 0 && !IsForcedEnd) { | |||
// MessageLog.ShowInfo("等待重量:"+val+"KG"); | |||
// ThreadWhile("炒锅当前重量", val); | |||
// if(IsForcedEnd) MessageLog.ShowInfo("等待重量:强制结束"); | |||
// else MessageLog.ShowInfo("等待重量完成"); | |||
// } | |||
} catch (Exception ex) { | |||
ToastUtils.error("异常信息:" + ex.getMessage()); | |||
@@ -447,14 +741,6 @@ public class ExecuteTheRecipe { | |||
ConfigName.getInstance().PLC_Address.put(item.name, item); | |||
} | |||
} | |||
new Thread(new Runnable() { | |||
@Override | |||
public void run() { | |||
WritePLC("系统启停开关", true); | |||
} | |||
}).start(); | |||
ThreadManager.Get().StartLong("PLC设备数据监听", true, new IThread() { | |||
@Override | |||
public void Run() throws InterruptedException { | |||
@@ -486,9 +772,9 @@ public class ExecuteTheRecipe { | |||
try { | |||
if (ConfigName.getInstance().PlcIsConnect) { | |||
//心跳 | |||
WritePLC("上位机-PLC", true); | |||
Write("上位机-PLC", true); | |||
Thread.sleep(500); | |||
WritePLC("上位机-PLC", false); | |||
Write("上位机-PLC", false); | |||
} | |||
} catch (Exception ex) { | |||
ToastUtils.error("异常信息:" + ex.getMessage()); | |||
@@ -506,6 +792,41 @@ public class ExecuteTheRecipe { | |||
//region 界面事件 | |||
/** | |||
* 阻断按钮 | |||
* | |||
* @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); | |||
Write(name, true); | |||
Thread.sleep(100); | |||
Write(name, false); | |||
// Log.e("按钮复位", name); | |||
ExecuteTheRecipe.showlog("写入plc-------" + name); | |||
} catch (Exception ex) { | |||
// Log.e("按钮异常", name + ex.getMessage()); | |||
MessageLog.ShowError(name + ex.getMessage()); | |||
Write(name, false); | |||
} | |||
}); | |||
} | |||
/** | |||
* 阻断按钮 | |||
* | |||
@@ -513,15 +834,13 @@ public class ExecuteTheRecipe { | |||
*/ | |||
public static void BottomClick(String name) { | |||
try { | |||
Log.e("按钮按下", name); | |||
WritePLC(name, true); | |||
Write(name, true); | |||
Thread.sleep(100); | |||
WritePLC(name, false); | |||
Log.e("按钮复位", name); | |||
Write(name, false); | |||
ExecuteTheRecipe.showlog("写入plc-------" + name); | |||
} catch (Exception ex) { | |||
Log.e("按钮异常", name + ex.getMessage()); | |||
WritePLC(name, false); | |||
Write(name, false); | |||
} | |||
} | |||
@@ -550,7 +869,7 @@ public class ExecuteTheRecipe { | |||
* @param delay | |||
*/ | |||
public static void ThreadDelay(int delay) { | |||
ExecuteTheRecipe.showlog("工序线程等待-------时长:" + delay + "秒,请耐心等待,开始计时!"); | |||
// ExecuteTheRecipe.showlog("工序线程等待-------时长:" + delay + "秒,请耐心等待,开始计时!"); | |||
long startTime = System.currentTimeMillis(); | |||
while ((System.currentTimeMillis() - startTime) <= (delay * 1000) && !IsForcedEnd) { | |||
@@ -562,7 +881,7 @@ public class ExecuteTheRecipe { | |||
long endTime = System.currentTimeMillis(); //结束时间 | |||
int time = (int) ((endTime - startTime) / 1000); | |||
ExecuteTheRecipe.showlog("工序线程等待结束-------总耗时:" + time); | |||
// ExecuteTheRecipe.showlog("工序线程等待结束-------总耗时:" + time); | |||
} | |||
/** | |||
@@ -636,24 +955,19 @@ public class ExecuteTheRecipe { | |||
* | |||
* @param name | |||
*/ | |||
public static void ThreadWhile(String name, int val) { | |||
public static void ThreadWhile(String name, Float val) { | |||
final boolean[] IsComplete = {false}; | |||
long a = System.currentTimeMillis(); | |||
ExecuteTheRecipe.showlog(name + ",等待数据大于" + val); | |||
// ExecuteTheRecipe.showlog(name + ",等待数据大于" + val); | |||
while (!IsComplete[0] && !IsForcedEnd) { | |||
if ((System.currentTimeMillis() - a) > 1000 * whileTime) { | |||
ExecuteTheRecipe.showlog(name + ",异常超时退出!"); | |||
break; | |||
} else { | |||
Object sb = ReadPLC(name); | |||
int value = sb == null ? 0 : (int) (sb); | |||
float value = sb == null ? 0 : (float) (sb); | |||
if (value >= val) { | |||
IsComplete[0] = true; | |||
ExecuteTheRecipe.showlog(name + ",接收到信号!"); | |||
// ExecuteTheRecipe.showlog(name + ",接收到信号!"); | |||
} else { | |||
IsComplete[0] = false; | |||
} | |||
} | |||
try { | |||
Thread.sleep(100); | |||
} catch (InterruptedException e) { | |||
@@ -661,7 +975,7 @@ public class ExecuteTheRecipe { | |||
ExecuteTheRecipe.showlog(name + ",异常退出!" + e.getMessage()); | |||
} | |||
} | |||
ExecuteTheRecipe.showlog(name + ",等待结束!"); | |||
// ExecuteTheRecipe.showlog(name + ",等待结束!"); | |||
} | |||
//endregion | |||
@@ -817,9 +1131,10 @@ public class ExecuteTheRecipe { | |||
* 显示日志 | |||
*/ | |||
public static void showlog(String msg) { | |||
msg=ConfigName.getInstance().user.name+"_"+msg; | |||
Log.e("hbl", msg); | |||
ToastUtils.info(msg); | |||
msg=ConfigName.getInstance().user.name+"-"+msg; | |||
MessageLog.ShowInfo(msg); | |||
// Log.e("hbl", msg); | |||
//ToastUtils.info(msg); | |||
} | |||
//endregion | |||
@@ -831,21 +1146,60 @@ public class ExecuteTheRecipe { | |||
* @param name | |||
* @param value | |||
*/ | |||
public static void WritePLC(String name, Object value) { | |||
public static void Write(String name, Object value) { | |||
try { | |||
if (ConfigName.getInstance().PLC_Address.containsKey(name)) { | |||
BPA_PLCADDRESS plcaddress = ConfigName.getInstance().PLC_Address.get(name); | |||
if (!plcaddress.address.isEmpty()) { | |||
CommHelper.get().writePLC(plcaddress.address, value); | |||
showlog(name+"_写入值_"+value); | |||
CommHelper.get().writePLC(plcaddress.address, value); | |||
} | |||
else{ | |||
MessageLog.ShowInfo(name+":写入数据失败,PLC地址为空"); | |||
} | |||
} | |||
else{ | |||
MessageLog.ShowInfo(name+":写入数据失败,配置文件中不存在该PLC地址"); | |||
} | |||
} catch (Exception ex) { | |||
ToastUtils.error("异常信息:" + ex.getMessage()); | |||
} finally { | |||
} | |||
} | |||
/** | |||
* 写PLC数据 | |||
* | |||
* @param name | |||
* @param value | |||
*/ | |||
public static void WriteAsync(String name, Object value) { | |||
Executor.get().runThread(()->{ | |||
if (ConfigName.getInstance().PLC_Address.containsKey(name)) { | |||
BPA_PLCADDRESS plcaddress = ConfigName.getInstance().PLC_Address.get(name); | |||
if (!plcaddress.address.isEmpty()) { | |||
showlog(name+"_写入值_"+value); | |||
CommHelper.get().writePLC(plcaddress.address, value); | |||
} | |||
else{ | |||
MessageLog.ShowInfo(name+":写入数据失败,PLC地址为空"); | |||
} | |||
} | |||
else{ | |||
MessageLog.ShowInfo(name+":写入数据失败,配置文件中不存在该PLC地址"); | |||
} | |||
}); | |||
} | |||
public static void DischargeControlAsync(Float SetWeight,Float SetLead){ | |||
showlog("手动出料,设定重量:"+SetWeight+",提前量:"+SetLead); | |||
Executor.get().runThread(()->{ | |||
Write("设定重量", SetWeight); | |||
Write("设定提前量", SetLead); | |||
Write("料仓1出料", true); | |||
}); | |||
} | |||
/** | |||
* 读PLC数据 | |||
* | |||
@@ -858,9 +1212,14 @@ public class ExecuteTheRecipe { | |||
if (ConfigName.getInstance().PLC_Address.containsKey(name)) { | |||
BPA_PLCADDRESS plcaddress = ConfigName.getInstance().PLC_Address.get(name); | |||
if (!plcaddress.address.isEmpty() ) { | |||
ReturnsVariable = CommHelper.get().readPLC(plcaddress.address); | |||
} | |||
else{ | |||
MessageLog.ShowInfo(name+":读取数据失败,PLC地址为空"); | |||
} | |||
} | |||
else{ | |||
MessageLog.ShowInfo(name+":读取数据失败,配置文件中不存在该PLC地址"); | |||
} | |||
} catch (Exception ex) { | |||
ToastUtils.error("异常信息:" + ex.getMessage()); | |||
@@ -869,6 +1228,25 @@ public class ExecuteTheRecipe { | |||
} | |||
} | |||
public static <T> OperateResultT<T> Read(String name) { | |||
try { | |||
if (ConfigName.getInstance().PLC_Address.containsKey(name)) { | |||
BPA_PLCADDRESS plcaddress = ConfigName.getInstance().PLC_Address.get(name); | |||
if (!plcaddress.address.isEmpty() ) { | |||
return CommHelper.get().Read(plcaddress.address); | |||
} | |||
else{ | |||
return OperateResultT.CreateFailedT(name+":读取数据失败,PLC地址为空"); | |||
} | |||
} | |||
else{ | |||
return OperateResultT.CreateFailedT(name+":读取数据失败,配置文件中不存在该PLC地址"); | |||
} | |||
} catch (Exception ex) { | |||
return OperateResultT.CreateFailedT("读取异常,异常信息:" + ex.toString()); | |||
} | |||
} | |||
/** | |||
* 获取监听变量 | |||
* | |||
@@ -335,18 +335,18 @@ public class ConfigName { | |||
add(new Res_PLCADDRESS("PLC-上位机", "V280.1", 1, 1)); | |||
}}; | |||
/** | |||
* 大炒工序模型 | |||
* 燃气炒锅工艺功能的配置 | |||
*/ | |||
public List<ProcessT> Process_燃气大炒 = new ArrayList<ProcessT>() {{ | |||
add(new ProcessT("物料", Arrays.asList())); | |||
add(new ProcessT("主料", Arrays.asList("主料名称"))); | |||
add(new ProcessT("搅拌", Arrays.asList("搅拌速度","搅拌状态"))); | |||
add(new ProcessT("火力设置", Arrays.asList("一环功率", "二环功率", "三环功率", "四环功率"))); | |||
add(new ProcessT("火力设置", Arrays.asList("一环功率", "二环功率", "三环功率", "四环功率","火力状态"))); | |||
add(new ProcessT("约束条件", Arrays.asList("温度设定", "锅内重量", "等待(秒)"))); | |||
}}; | |||
/** | |||
* 根据名称获取变量 | |||
* 根据工艺的功能属性配置属性的数据类型 | |||
* | |||
* @param item | |||
* @return | |||
@@ -358,6 +358,9 @@ public class ConfigName { | |||
} else if (item.equals("位置动作")) { | |||
data = "炒菜位、倒菜位、清洗位"; | |||
} | |||
else if (item.equals("火力状态")) { | |||
data = "启动、停止"; | |||
} | |||
return data; | |||
} | |||
@@ -0,0 +1,50 @@ | |||
package com.bonait.bnframework.common.helper; | |||
import com.bonait.bnframework.common.helper.Result.OperateResultT; | |||
public class Convert { | |||
public static OperateResultT<Boolean> TryToBoolean(Object value){ | |||
if(value==null) return OperateResultT.CreateFailedT("TryToBoolean 解析对象为空"); | |||
try{ | |||
return OperateResultT.CreateSuccess(Boolean.parseBoolean(value.toString())); | |||
}catch (Exception e) { | |||
return OperateResultT.CreateFailedT(e); | |||
} | |||
} | |||
public static OperateResultT<Integer> TryToInt(Object value){ | |||
if(value==null) return OperateResultT.CreateFailedT("TryToInt 解析对象为空"); | |||
try{ | |||
return OperateResultT.CreateSuccess(Integer.parseInt(value.toString())); | |||
}catch (Exception e) { | |||
return OperateResultT.CreateFailedT(e); | |||
} | |||
} | |||
public static OperateResultT<Short> TryToShort(Object value){ | |||
if(value==null) return OperateResultT.CreateFailedT("TryToShort 解析对象为空"); | |||
try{ | |||
return OperateResultT.CreateSuccess(Short.parseShort(value.toString())); | |||
}catch (Exception e) { | |||
return OperateResultT.CreateFailedT(e); | |||
} | |||
} | |||
public static OperateResultT<Float> TryToFloat(Object value){ | |||
if(value==null) return OperateResultT.CreateFailedT("TryToFloat 解析对象为空"); | |||
try{ | |||
return OperateResultT.CreateSuccess(Float.parseFloat(value.toString())); | |||
}catch (Exception e) { | |||
return OperateResultT.CreateFailedT(e); | |||
} | |||
} | |||
public static <T> OperateResultT<T> TryToGenericity( Object value){ | |||
if(value==null) return OperateResultT.CreateFailedT("TryToGenericity 解析对象为空"); | |||
try{ | |||
return OperateResultT.CreateSuccess((T)value); | |||
}catch (Exception e) { | |||
return OperateResultT.CreateFailedT(e); | |||
} | |||
} | |||
} |
@@ -0,0 +1,42 @@ | |||
package com.bonait.bnframework.common.helper; | |||
import com.bonait.bnframework.common.helper.I.IRun; | |||
import com.bonait.bnframework.common.modbus.s7.CommHelper; | |||
import com.bonait.bnframework.common.utils.ToastUtils; | |||
import java.util.concurrent.CompletableFuture; | |||
import java.util.concurrent.ExecutorService; | |||
import java.util.concurrent.Executors; | |||
import java.util.function.Supplier; | |||
public class Executor { | |||
private static Executor mInstance; //实例变量设置私有,防止直接通过类名访问 | |||
private Executor() { //默认构造函数私有,防止类外直接new创建对象 | |||
} | |||
public static synchronized Executor get() { //静态同步方法作为唯一的实例对象获取方式 | |||
if (mInstance == null) { | |||
mInstance = new Executor(); | |||
} | |||
return mInstance; | |||
} | |||
private ExecutorService executor= Executors.newCachedThreadPool() ; | |||
public void runThread(IRun run) { | |||
executor.submit(new Runnable(){ | |||
@Override | |||
public void run() { | |||
try { | |||
if(run!=null)run.Run(); | |||
}catch(Exception ex) { | |||
ToastUtils.error("异常信息:" + ex.getMessage()); | |||
MessageLog.ShowError("runThread 异常:"+ex.getMessage()); | |||
} | |||
} | |||
}); | |||
} | |||
} |
@@ -0,0 +1,8 @@ | |||
package com.bonait.bnframework.common.helper.I; | |||
public interface IDialogAction { | |||
// void Confirm(); | |||
// void Cancel(); | |||
void ExitDialog(boolean status); | |||
} |
@@ -0,0 +1,29 @@ | |||
package com.bonait.bnframework.common.helper; | |||
import com.bonait.bnframework.common.helper.I.IRunT; | |||
import com.bonait.bnframework.common.helper.Result.OperateResultT; | |||
public class NotifyPropVar<T> { | |||
public NotifyPropVar(T defaultValue){ | |||
_value=defaultValue; | |||
} | |||
public IRunT<T> ChangeNotify; | |||
private T _value; | |||
private boolean IsFirst=false; | |||
public T getValue(){ | |||
return _value; | |||
} | |||
public void setValue(T value){ | |||
if (value != null && !value.equals(_value) || !IsFirst) | |||
{ | |||
_value=value; | |||
if(ChangeNotify!=null) ChangeNotify.Run(value); | |||
IsFirst = true; | |||
} | |||
} | |||
} |
@@ -0,0 +1,45 @@ | |||
package com.bonait.bnframework.common.helper.Result; | |||
public abstract class IResult { | |||
/** | |||
* 是否成功 | |||
*/ | |||
public boolean isSuccess ; | |||
/** | |||
* 返回消息 | |||
*/ | |||
public String message; | |||
/** | |||
* 操作代码 | |||
*/ | |||
public ResultCode resultCode = ResultCode.Default ; | |||
abstract void setErrorMsg(String msg); | |||
public boolean getIsSuccess(){ | |||
return resultCode==ResultCode.Success; | |||
} | |||
public void setIsSuccess(boolean tempSuccess){ | |||
isSuccess= tempSuccess; | |||
resultCode = tempSuccess ? ResultCode.Success : ResultCode.Fail; | |||
} | |||
// | |||
// String getMessage(){ | |||
// return Message; | |||
// } | |||
// | |||
// void setMessage(String message){ | |||
// Message= message; | |||
// } | |||
// | |||
// ResultCode getResultCode(){ | |||
// return ResultCode; | |||
// } | |||
// | |||
// void setResult(ResultCode resultCode){ | |||
// ResultCode=resultCode; | |||
// } | |||
} |
@@ -0,0 +1,77 @@ | |||
package com.bonait.bnframework.common.helper.Result; | |||
import com.bonait.bnframework.common.helper.I.IRun; | |||
import com.bonait.bnframework.common.helper.MessageLog; | |||
public class OperateResult extends IResult { | |||
public OperateResult(){ | |||
} | |||
public OperateResult(Exception ex){ | |||
message = ex.getMessage()+"\rException:"+ex.toString(); | |||
resultCode = ResultCode.Exception; | |||
isSuccess=false; | |||
} | |||
public OperateResult(String msg, ResultCode rc) | |||
{ | |||
message = msg; | |||
resultCode = rc; | |||
isSuccess=false; | |||
} | |||
public OperateResult(ResultCode rc) | |||
{ | |||
resultCode = rc; | |||
isSuccess=true; | |||
} | |||
@Override | |||
public void setErrorMsg(String msg) { | |||
message =message+ msg; | |||
isSuccess=false; | |||
resultCode = ResultCode.Fail; | |||
} | |||
public OperateResult OnSource(IRun action){ | |||
if(action!=null&&getIsSuccess())action.Run(); | |||
return this; | |||
} | |||
public OperateResult OnFailed(IRun action){ | |||
if(action!=null&&!getIsSuccess())action.Run(); | |||
return this; | |||
} | |||
public OperateResult OnFinally(IRun action){ | |||
if(action!=null)action.Run(); | |||
return this; | |||
} | |||
public static OperateResult CreateSuccess() | |||
{ | |||
return new OperateResult(ResultCode.Success); | |||
} | |||
public static OperateResult CreateFailed(String msg) | |||
{ | |||
MessageLog.ShowError(msg); | |||
return new OperateResult(msg, ResultCode.Fail); | |||
} | |||
public static OperateResult CreateFailed(Exception ex) | |||
{ | |||
MessageLog.ShowError(ex.toString()); | |||
return new OperateResult(ex); | |||
} | |||
} | |||
@@ -0,0 +1,74 @@ | |||
package com.bonait.bnframework.common.helper.Result; | |||
import com.bonait.bnframework.common.helper.I.IRunT; | |||
import com.bonait.bnframework.common.helper.MessageLog; | |||
public class OperateResultT<T> extends OperateResult | |||
{ | |||
public OperateResultT(Exception ex) | |||
{ | |||
super(ex); | |||
} | |||
public OperateResultT(String msg, ResultCode rc ) | |||
{ | |||
super(msg, rc); | |||
} | |||
public OperateResultT(ResultCode rc) | |||
{ | |||
super(rc); | |||
} | |||
public OperateResultT() | |||
{ | |||
super(); | |||
} | |||
public OperateResultT(T content, String msg, ResultCode rc) | |||
{ | |||
Content = content; | |||
message = msg; | |||
resultCode = rc; | |||
isSuccess=getIsSuccess(); | |||
} | |||
public T Content ; | |||
public void setContent(T value) | |||
{ | |||
Content = value; | |||
resultCode = ResultCode.Success; | |||
isSuccess=true; | |||
} | |||
public OperateResultT<T> OnSource(IRunT<OperateResultT<T>> action){ | |||
if(action!=null&&getIsSuccess())action.Run(this); | |||
return this; | |||
} | |||
public OperateResultT<T> OnFailed(IRunT<OperateResultT<T>> action){ | |||
if(action!=null&&!getIsSuccess())action.Run(this); | |||
return this; | |||
} | |||
public OperateResultT<T> OnFinally(IRunT<OperateResultT<T>> action){ | |||
if(action!=null)action.Run(this); | |||
return this; | |||
} | |||
public static <T> OperateResultT<T> CreateSuccess(T value) | |||
{ | |||
return new OperateResultT<T>(value,"", ResultCode.Success); | |||
} | |||
public static <T> OperateResultT<T> CreateFailedT(String msg) | |||
{ | |||
MessageLog.ShowError(msg); | |||
return new OperateResultT<T>( msg, ResultCode.Fail); | |||
} | |||
public static <T> OperateResultT<T> CreateFailedT(Exception ex) | |||
{ | |||
MessageLog.ShowError(ex.toString()); | |||
return new OperateResultT<T>(ex); | |||
} | |||
} |
@@ -0,0 +1,38 @@ | |||
package com.bonait.bnframework.common.helper.Result; | |||
public enum ResultCode { | |||
/** | |||
* 默认 | |||
*/ | |||
Default, | |||
/** | |||
* 错误 | |||
*/ | |||
Error, | |||
/** | |||
* 异常 | |||
*/ | |||
Exception, | |||
/** | |||
* 成功 | |||
*/ | |||
Success, | |||
/** | |||
* 失败 | |||
*/ | |||
Fail, | |||
/** | |||
* 操作超时 | |||
*/ | |||
Overtime, | |||
/** | |||
* 操作取消 | |||
*/ | |||
Canceled | |||
} |
@@ -0,0 +1,37 @@ | |||
package com.bonait.bnframework.common.helper; | |||
public class Stopwatch { | |||
private long ElapsedMilliseconds; | |||
private boolean IsRunning; | |||
private long StartTime; | |||
public long getElapsedMilliseconds() { | |||
return ElapsedMilliseconds; | |||
} | |||
public void Reset(){ | |||
ElapsedMilliseconds=0; | |||
StartTime =0; | |||
} | |||
public void Restart(){ | |||
ElapsedMilliseconds=0; | |||
StartTime =System.currentTimeMillis(); | |||
IsRunning=true; | |||
} | |||
public void Start(){ | |||
StartTime =System.currentTimeMillis(); | |||
IsRunning=true; | |||
} | |||
public void Stop(){ | |||
if(IsRunning){ | |||
ElapsedMilliseconds = System.currentTimeMillis()- StartTime; | |||
} | |||
IsRunning=false; | |||
} | |||
} |
@@ -1,15 +1,14 @@ | |||
package com.bonait.bnframework.common.modbus.s7; | |||
import android.util.Log; | |||
import com.bonait.bnframework.common.constant.ConfigName; | |||
import com.bonait.bnframework.common.helper.Convert; | |||
import com.bonait.bnframework.common.helper.I.IRun; | |||
import com.bonait.bnframework.common.helper.MessageLog; | |||
import com.bonait.bnframework.common.helper.Result.OperateResult; | |||
import com.bonait.bnframework.common.helper.Result.OperateResultT; | |||
import com.github.xingshuangs.iot.protocol.s7.enums.EPlcType; | |||
import java.io.IOException; | |||
import java.io.InputStreamReader; | |||
import java.io.LineNumberReader; | |||
import kotlin.UShort; | |||
public class CommHelper { | |||
@@ -24,10 +23,12 @@ public class CommHelper { | |||
} | |||
return mInstance; | |||
} | |||
public boolean IsConnected(){ | |||
return siemens.IsConnected; | |||
} | |||
public IRun ConnectOk; | |||
SiemensHelper siemens=new SiemensHelper(EPlcType.S200_SMART, ConfigName.getInstance().Address); | |||
public SiemensHelper siemens=new SiemensHelper(EPlcType.S200_SMART, ConfigName.getInstance().Address); | |||
public void Connect(){ | |||
new Thread(new Runnable() { | |||
@@ -38,27 +39,36 @@ public class CommHelper { | |||
while (!siemens.checkConnected()){ | |||
try{ | |||
tempFlag++; | |||
siemens=new SiemensHelper(EPlcType.S200_SMART, ConfigName.getInstance().Address); | |||
siemens.connect(); | |||
siemens.Delay(1000); | |||
}catch (Exception e){ | |||
if(tempFlag==1)MessageLog.ShowInfo("PLC连接失败:"+e.getMessage()); | |||
siemens.Delay(1000); | |||
} | |||
} | |||
if(ConnectOk!=null)ConnectOk.Run(); | |||
siemens.IsConnected=true; | |||
MessageLog.ShowInfo("PLC连接成功"); | |||
} | |||
}).start(); | |||
} | |||
public void writePLC(String add,Object value){ | |||
if(!IsConnected()) { | |||
MessageLog.ShowInfo(add+":写入数据失败,连接已断开"); | |||
return; | |||
} | |||
if(value==null) { | |||
MessageLog.ShowInfo("writePLC:写入值为空"); | |||
return; | |||
} | |||
try{ | |||
if(add.toUpperCase().contains("VD")){ | |||
Integer tempVD= Integer.parseInt(value.toString()); | |||
siemens.WriteInt32(add,tempVD); | |||
Float tempVD= Float.parseFloat(value.toString()); | |||
siemens.WriteFloat32(add,tempVD); | |||
} | |||
else if (add.toUpperCase().contains("VW")){ | |||
Integer tempVW= Integer.parseInt(value.toString()); | |||
@@ -75,9 +85,13 @@ public class CommHelper { | |||
} | |||
public Object readPLC(String add){ | |||
if(!IsConnected()) { | |||
MessageLog.ShowInfo(add+":读取数据失败,连接已断开"); | |||
return new Object(); | |||
} | |||
try{ | |||
if(add.toUpperCase().contains("VD")){ | |||
return siemens.ReadInt32(add); | |||
return siemens.ReadFloat32(add); | |||
} | |||
else if (add.toUpperCase().contains("VW")){ | |||
return siemens.ReadUInt16(add); | |||
@@ -91,4 +105,59 @@ public class CommHelper { | |||
return new Object(); | |||
} | |||
public <T> OperateResultT<T> Read(String add){ | |||
if(!IsConnected()) return OperateResultT.CreateFailedT(add+":读取数据失败,连接已断开"); | |||
OperateResultT<T> result = new OperateResultT<>(); | |||
String typeName=result.Content.getClass() .getName(); | |||
try{ | |||
if(typeName.contains("Boolean")){ | |||
return Convert.TryToGenericity(siemens.ReadBoolean(add)); | |||
}else if(typeName.contains("Integer")){ | |||
if(add.toUpperCase().contains("VD")){ | |||
return Convert.TryToGenericity(siemens.ReadInt32(add)); | |||
} | |||
else if (add.toUpperCase().contains("VW")){ | |||
return Convert.TryToGenericity(siemens.ReadUInt16(add)); | |||
} | |||
}else if(typeName.contains("Short")){ | |||
return Convert.TryToGenericity(siemens.ReadInt16(add)); | |||
}else if(typeName.contains("Float")){ | |||
return Convert.TryToGenericity(siemens.ReadFloat32(add)); | |||
}else{ | |||
return OperateResultT.CreateFailedT(typeName+" 暂不支持的数据类型"); | |||
} | |||
}catch (Exception e){ | |||
return OperateResultT.CreateFailedT(e); | |||
} | |||
return result; | |||
} | |||
public <T> OperateResult Write(String add, T value){ | |||
if(!IsConnected()) return OperateResult.CreateFailed(add+":读取数据失败,连接已断开"); | |||
if(value ==null) return OperateResult.CreateFailed(add+":写入值无效"); | |||
String typeName=value.getClass() .getName(); | |||
try{ | |||
if(typeName.contains("Boolean")){ | |||
Convert.<Boolean>TryToGenericity(value).OnSource(s->{ siemens.WriteBoolean(add,s.Content);}); | |||
}else if(typeName.contains("Integer")){ | |||
if(add.toUpperCase().contains("VD")){ | |||
Convert.<Integer>TryToGenericity(value).OnSource(s->{ siemens.WriteInt32(add,s.Content);}); | |||
} | |||
else if (add.toUpperCase().contains("VW")){ | |||
Convert.<Integer>TryToGenericity(value).OnSource(s->{ siemens.WriteUInt16(add,s.Content);}); | |||
} | |||
}else if(typeName.contains("Short")){ | |||
Convert.<Short>TryToGenericity(value).OnSource(s->{ siemens.WriteInt16(add,s.Content);}); | |||
}else if(typeName.contains("Float")){ | |||
Convert.<Float>TryToGenericity(value).OnSource(s->{ siemens.WriteFloat32(add,s.Content);}); | |||
}else{ | |||
return OperateResult.CreateFailed(typeName+" 暂不支持的数据类型"); | |||
} | |||
return OperateResult.CreateSuccess(); | |||
}catch (Exception e){ | |||
return OperateResult.CreateFailed(e); | |||
} | |||
} | |||
} |
@@ -4,6 +4,7 @@ import static com.github.xingshuangs.iot.common.constant.GeneralConst.S7_PORT; | |||
import android.util.Log; | |||
import com.bonait.bnframework.common.helper.MessageLog; | |||
import com.github.xingshuangs.iot.exceptions.SocketRuntimeException; | |||
import com.github.xingshuangs.iot.protocol.s7.enums.EPlcType; | |||
import com.github.xingshuangs.iot.protocol.s7.model.DataItem; | |||
@@ -21,18 +22,20 @@ import java.util.List; | |||
public class SiemensHelper extends S7PLC { | |||
/** | |||
* 判断PLC连接是否成功 | |||
* @return | |||
*/ | |||
public boolean IsConnected(){ | |||
try { | |||
socket.sendUrgentData(0xff); | |||
return true; | |||
}catch(Exception e){ | |||
return false; | |||
} | |||
} | |||
// /** | |||
// * 判断PLC连接是否成功 | |||
// * @return | |||
// */ | |||
// public boolean IsConnected(){ | |||
// try { | |||
// socket.sendUrgentData(0xff); | |||
// return true; | |||
// }catch(Exception e){ | |||
// return false; | |||
// } | |||
// } | |||
public Boolean IsConnected=false; | |||
public void Delay(long millis){ | |||
try{ | |||
@@ -43,187 +46,317 @@ public class SiemensHelper extends S7PLC { | |||
} | |||
public boolean ReadBoolean(String address){ | |||
if(!IsConnected){ | |||
MessageLog.ShowInfo(address+":读取数据失败,连接已断开"); | |||
return false; | |||
} | |||
try { | |||
return this.readBoolean(address); | |||
boolean result=this.readBoolean(address); | |||
IsConnected=true; | |||
return result; | |||
} | |||
catch(SocketRuntimeException ex){ | |||
this.close(); | |||
IsConnected=false; | |||
} | |||
return false; | |||
} | |||
public List<Boolean> ReadBoolean(String... address) { | |||
if(!IsConnected){ | |||
MessageLog.ShowInfo(address+":读取数据失败,连接已断开"); | |||
return new ArrayList<Boolean>(); | |||
} | |||
try { | |||
return this.readBoolean(Arrays.asList(address)); | |||
List<Boolean> result=this.readBoolean(Arrays.asList(address)); | |||
IsConnected=true; | |||
return result; | |||
} | |||
catch(SocketRuntimeException ex){ | |||
this.close(); | |||
IsConnected=false; | |||
} | |||
return new ArrayList<Boolean>(); | |||
} | |||
public short ReadInt16(String address) { | |||
if(!IsConnected){ | |||
MessageLog.ShowInfo(address+":读取数据失败,连接已断开"); | |||
return 0; | |||
} | |||
try { | |||
DataItem dataItem = this.readS7Data(AddressUtil.parseByte(address, 2)); | |||
return ShortUtil.toInt16(dataItem.getData()); | |||
short result= ShortUtil.toInt16(dataItem.getData()); | |||
IsConnected=true; | |||
return result; | |||
} | |||
catch(SocketRuntimeException ex){ | |||
this.close(); | |||
IsConnected=false; | |||
} | |||
return 0; | |||
} | |||
public List<Short> ReadInt16(String... address) { | |||
if(!IsConnected){ | |||
MessageLog.ShowInfo(address+":读取数据失败,连接已断开"); | |||
return new ArrayList<Short>(); | |||
} | |||
try { | |||
return this.readInt16(Arrays.asList(address)); | |||
List<Short> result=this.readInt16(Arrays.asList(address)); | |||
IsConnected=true; | |||
return result; | |||
} | |||
catch(SocketRuntimeException ex){ | |||
this.close(); | |||
IsConnected=false; | |||
} | |||
return new ArrayList<Short>(); | |||
} | |||
public int ReadUInt16(String address) { | |||
if(!IsConnected){ | |||
MessageLog.ShowInfo(address+":读取数据失败,连接已断开"); | |||
return 0; | |||
} | |||
try { | |||
DataItem dataItem = this.readS7Data(AddressUtil.parseByte(address, 2)); | |||
return ShortUtil.toUInt16(dataItem.getData()); | |||
int result= ShortUtil.toUInt16(dataItem.getData()); | |||
IsConnected=true; | |||
return result; | |||
} | |||
catch(SocketRuntimeException ex){ | |||
this.close(); | |||
IsConnected=false; | |||
} | |||
return 0; | |||
} | |||
public List<Integer> ReadUInt16(String... address) { | |||
if(!IsConnected){ | |||
MessageLog.ShowInfo(address+":读取数据失败,连接已断开"); | |||
return new ArrayList<Integer>(); | |||
} | |||
try { | |||
return this.readUInt16(Arrays.asList(address)); | |||
List<Integer> result=this.readUInt16(Arrays.asList(address)); | |||
IsConnected=true; | |||
return result; | |||
} | |||
catch(SocketRuntimeException ex){ | |||
this.close(); | |||
IsConnected=false; | |||
} | |||
return new ArrayList<Integer>(); | |||
} | |||
public int ReadInt32(String address) { | |||
if(!IsConnected){ | |||
MessageLog.ShowInfo(address+":读取数据失败,连接已断开"); | |||
return 0; | |||
} | |||
try { | |||
DataItem dataItem = this.readS7Data(AddressUtil.parseByte(address, 4)); | |||
return IntegerUtil.toInt32(dataItem.getData()); | |||
int result= IntegerUtil.toInt32(dataItem.getData()); | |||
IsConnected=true; | |||
return result; | |||
} | |||
catch(SocketRuntimeException ex){ | |||
this.close(); | |||
IsConnected=false; | |||
} | |||
return 0; | |||
} | |||
public List<Integer> ReadInt32(String... address) { | |||
if(!IsConnected){ | |||
MessageLog.ShowInfo(address+":读取数据失败,连接已断开"); | |||
return new ArrayList<Integer>(); | |||
} | |||
try { | |||
return this.readInt32(Arrays.asList(address)); | |||
List<Integer> result=this.readInt32(Arrays.asList(address)); | |||
IsConnected=true; | |||
return result; | |||
} | |||
catch(SocketRuntimeException ex){ | |||
this.close(); | |||
IsConnected=false; | |||
} | |||
return new ArrayList<Integer>(); | |||
} | |||
public float ReadFloat32(String address) { | |||
if(!IsConnected){ | |||
MessageLog.ShowInfo(address+":读取数据失败,连接已断开"); | |||
return 0; | |||
} | |||
try { | |||
DataItem dataItem = this.readS7Data(AddressUtil.parseByte(address, 4)); | |||
return FloatUtil.toFloat32(dataItem.getData()); | |||
float result= FloatUtil.toFloat32(dataItem.getData()); | |||
IsConnected=true; | |||
return result; | |||
} | |||
catch(SocketRuntimeException ex){ | |||
this.close(); | |||
IsConnected=false; | |||
} | |||
return 0; | |||
} | |||
public List<Float> ReadFloat32(String... address) { | |||
if(!IsConnected){ | |||
MessageLog.ShowInfo(address+":读取数据失败,连接已断开"); | |||
return new ArrayList<Float>(); | |||
} | |||
try { | |||
return this.readFloat32(Arrays.asList(address)); | |||
List<Float> result=this.readFloat32(Arrays.asList(address)); | |||
IsConnected=true; | |||
return result; | |||
} | |||
catch(SocketRuntimeException ex){ | |||
this.close(); | |||
IsConnected=false; | |||
} | |||
return new ArrayList<Float>(); | |||
} | |||
public void WriteBoolean(String address, boolean data) { | |||
if(!IsConnected){ | |||
MessageLog.ShowInfo(address+":写入数据失败,连接已断开"); | |||
return; | |||
} | |||
while (true) { | |||
try { | |||
this.writeS7Data(AddressUtil.parseBit(address), DataItem.createReqByBoolean(data)); | |||
IsConnected=true; | |||
break; | |||
} | |||
catch(SocketRuntimeException ex){ | |||
this.close(); | |||
IsConnected=false; | |||
Delay(100); | |||
} | |||
catch (Exception e){ | |||
MessageLog.ShowError("WriteBoolean 写入异常:"+e.toString()); | |||
break; | |||
} | |||
} | |||
} | |||
public void WriteUInt16(String address, int data) { | |||
if(!IsConnected){ | |||
MessageLog.ShowInfo(address+":写入数据失败,连接已断开"); | |||
return; | |||
} | |||
while (true) { | |||
try { | |||
this.writeByte(address, ShortUtil.toByteArray(data)); | |||
IsConnected=true; | |||
break; | |||
} | |||
catch(SocketRuntimeException ex){ | |||
this.close(); | |||
IsConnected=false; | |||
Delay(100); | |||
} | |||
catch (Exception e){ | |||
MessageLog.ShowError("WriteUInt16 写入异常:"+e.toString()); | |||
break; | |||
} | |||
} | |||
} | |||
public void WriteInt16(String address, short data) { | |||
if(!IsConnected){ | |||
MessageLog.ShowInfo(address+":写入数据失败,连接已断开"); | |||
return; | |||
} | |||
while (true) { | |||
try { | |||
Log.e("info","准备写入数据:"+data); | |||
this.writeByte(address, ShortUtil.toByteArray(data)); | |||
IsConnected=true; | |||
break; | |||
} | |||
catch(SocketRuntimeException ex){ | |||
Log.e("socketException","写入:"+data+"失败"); | |||
this.close(); | |||
IsConnected=false; | |||
Delay(100); | |||
} | |||
catch (Exception e){ | |||
MessageLog.ShowError("WriteInt16 写入异常:"+e.toString()); | |||
break; | |||
} | |||
} | |||
} | |||
public void WriteUInt32(String address, long data) { | |||
if(!IsConnected){ | |||
MessageLog.ShowInfo(address+":写入数据失败,连接已断开"); | |||
return; | |||
} | |||
while (true) { | |||
try { | |||
this.writeByte(address, IntegerUtil.toByteArray(data)); | |||
IsConnected=true; | |||
break; | |||
} | |||
catch(SocketRuntimeException ex){ | |||
this.close(); | |||
IsConnected=false; | |||
Delay(100); | |||
} | |||
catch (Exception e){ | |||
MessageLog.ShowError("WriteUInt32 写入异常:"+e.toString()); | |||
break; | |||
} | |||
} | |||
} | |||
public void WriteInt32(String address, int data) { | |||
if(!IsConnected){ | |||
MessageLog.ShowInfo(address+":写入数据失败,连接已断开"); | |||
return; | |||
} | |||
while (true) { | |||
try { | |||
this.writeByte(address, IntegerUtil.toByteArray(data)); | |||
IsConnected=true; | |||
break; | |||
} | |||
catch(SocketRuntimeException ex){ | |||
this.close(); | |||
IsConnected=false; | |||
Delay(100); | |||
} | |||
catch (Exception e){ | |||
MessageLog.ShowError("WriteInt32 写入异常:"+e.toString()); | |||
break; | |||
} | |||
} | |||
} | |||
public void WriteFloat32(String address, float data) { | |||
if(!IsConnected){ | |||
MessageLog.ShowInfo(address+":写入数据失败,连接已断开"); | |||
return; | |||
} | |||
while (true) { | |||
try { | |||
this.writeByte(address, FloatUtil.toByteArray(data)); | |||
IsConnected=true; | |||
break; | |||
} | |||
catch(SocketRuntimeException ex){ | |||
this.close(); | |||
IsConnected=false; | |||
Delay(100); | |||
} | |||
catch (Exception e){ | |||
MessageLog.ShowError("WriteFloat32 写入异常:"+e.toString()); | |||
break; | |||
} | |||
} | |||
} | |||
@@ -2,6 +2,9 @@ package com.bonait.bnframework.common.utils; | |||
import android.content.Context; | |||
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; | |||
@@ -65,6 +68,38 @@ public class AlertDialogUtils { | |||
.create(mCurrentDialogStyle).show(); | |||
} | |||
/** | |||
* 对话框,有取消确定按钮 | |||
* */ | |||
public static void showDialog(Context context, String title, String message, IDialogAction action) { | |||
new QMUIDialog.MessageDialogBuilder(context) | |||
.setCancelable(false) | |||
.setTitle(title) | |||
.setMessage(message) | |||
.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() { | |||
@Override | |||
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(); | |||
} | |||
/** | |||
* 对话框,自定义确定按钮 | |||
* */ | |||
@@ -101,7 +101,8 @@ public class BottomNavigationMainActivity extends BaseActivity { | |||
ConfigData.getInstance().ToggleEnvironment(); | |||
//2.初始化PLC | |||
// ReconnectModbus(); | |||
CommHelper.get().Connect(); | |||
// ConfigData.getInstance().PLC_Init(); | |||
// CommHelper.get().Connect(); | |||
} | |||
/** | |||
@@ -2,16 +2,13 @@ package com.bonait.bnframework.modules.home.fragment.mode; | |||
import android.content.Context; | |||
import android.os.Handler; | |||
import android.text.InputType; | |||
import android.util.AttributeSet; | |||
import android.view.LayoutInflater; | |||
import android.view.View; | |||
import android.widget.Button; | |||
import android.widget.CheckBox; | |||
import android.widget.EditText; | |||
import android.widget.LinearLayout; | |||
import android.widget.RelativeLayout; | |||
import android.widget.Switch; | |||
import android.widget.TextView; | |||
import androidx.annotation.Nullable; | |||
@@ -19,16 +16,10 @@ import androidx.annotation.Nullable; | |||
import com.bonait.bnframework.R; | |||
import com.bonait.bnframework.business.ExecuteTheRecipe; | |||
import com.bonait.bnframework.common.constant.ConfigName; | |||
import com.bonait.bnframework.common.db.QueryDB; | |||
import com.bonait.bnframework.common.db.mode.BPA_PLCADDRESS; | |||
import com.bonait.bnframework.common.utils.AlertDialogUtils; | |||
import com.bonait.bnframework.common.utils.ToastUtils; | |||
import com.qmuiteam.qmui.widget.dialog.QMUIDialog; | |||
import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction; | |||
import com.suke.widget.SwitchButton; | |||
import java.util.HashMap; | |||
import butterknife.BindView; | |||
import butterknife.ButterKnife; | |||
import butterknife.OnClick; | |||
@@ -188,7 +179,7 @@ public class fragment_plc_control extends LinearLayout { | |||
@Override | |||
public void onCheckedChanged(SwitchButton view, boolean isChecked) { | |||
boolean ischick= control_switch.isChecked(); | |||
ExecuteTheRecipe.WritePLC(model.name,ischick); | |||
ExecuteTheRecipe.Write(model.name,ischick); | |||
ToastUtils.info("写入地址:"+model.address+"成功!状态:"+(ischick?"打开":"关闭")); | |||
} | |||
}); | |||
@@ -199,11 +190,11 @@ public class fragment_plc_control extends LinearLayout { | |||
control_botton.setOnClickListener(new OnClickListener() { | |||
@Override | |||
public void onClick(View view) { | |||
ExecuteTheRecipe.WritePLC(model.name,true); | |||
ExecuteTheRecipe.Write(model.name,true); | |||
new Handler().postDelayed(new Runnable() { | |||
@Override | |||
public void run() { | |||
ExecuteTheRecipe.WritePLC(model.name, false); | |||
ExecuteTheRecipe.Write(model.name, false); | |||
} | |||
}, 500); | |||
@@ -223,7 +214,7 @@ public class fragment_plc_control extends LinearLayout { | |||
return; | |||
} | |||
int val=Integer.parseInt(text); | |||
ExecuteTheRecipe.WritePLC(model.name,val); | |||
ExecuteTheRecipe.Write(model.name,val); | |||
ToastUtils.info("写入地址:"+model.address+"成功!"); | |||
break; | |||
@@ -4,9 +4,9 @@ | |||
<layer-list xmlns:android="http://schemas.android.com/apk/res/android" | |||
> | |||
<item | |||
android:left="-10dp" | |||
android:right="-10dp" | |||
android:top="-10dp"> | |||
android:left="0dp" | |||
android:right="0dp" | |||
android:top="0dp"> | |||
<shape> | |||
<!-- <solid android:color="@color/tab_panel_bg" />--> | |||
<stroke | |||
@@ -29,6 +29,8 @@ | |||
<TableLayout | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" | |||
android:focusable="true" | |||
android:focusableInTouchMode="true" | |||
android:layout_centerHorizontal="true"> | |||
<!-- Table1--> | |||
<TableRow | |||
@@ -75,6 +75,7 @@ | |||
<com.qmuiteam.qmui.widget.textview.QMUILinkTextView | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
tools:ignore="TouchTargetSizeCheck" | |||
android:text="菜谱名称:" /> | |||
<!--账号输入框--> | |||
<EditText | |||
@@ -83,11 +84,12 @@ | |||
android:layout_height="wrap_content" | |||
android:layout_marginLeft="5dp" | |||
android:background="@drawable/input_bj" | |||
tools:ignore="TouchTargetSizeCheck" | |||
android:hint="请输入菜谱名称" | |||
android:inputType="text" | |||
android:maxLines="1" | |||
android:padding="3dp" | |||
android:textSize="12dp" /> | |||
android:textSize="12sp" /> | |||
</LinearLayout> | |||
<LinearLayout | |||
@@ -97,6 +99,7 @@ | |||
<com.qmuiteam.qmui.widget.textview.QMUILinkTextView | |||
android:layout_width="wrap_content" | |||
tools:ignore="TouchTargetSizeCheck" | |||
android:layout_height="wrap_content" | |||
android:text="制作时长:" /> | |||
<!--账号输入框--> | |||
@@ -110,8 +113,9 @@ | |||
android:inputType="number" | |||
android:maxLines="1" | |||
android:padding="3dp" | |||
tools:ignore="TouchTargetSizeCheck" | |||
android:text="0" | |||
android:textSize="12dp" /> | |||
android:textSize="12sp" /> | |||
</LinearLayout> | |||
<LinearLayout | |||
@@ -123,6 +127,7 @@ | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_marginLeft="70dp" | |||
tools:ignore="TouchTargetSizeCheck" | |||
android:buttonTint="@color/radiusImageView_selected_mask_color" | |||
android:text="默认收藏" /> | |||
</LinearLayout> | |||
@@ -158,6 +163,7 @@ | |||
<com.qmuiteam.qmui.widget.textview.QMUILinkTextView | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
tools:ignore="TouchTargetSizeCheck" | |||
android:text="步骤:" /> | |||
<Button | |||
@@ -166,8 +172,9 @@ | |||
android:layout_height="26dp" | |||
android:background="@drawable/button" | |||
android:text="上移" | |||
tools:ignore="TouchTargetSizeCheck" | |||
android:textColor="@color/black" | |||
android:textSize="14dp" /> | |||
android:textSize="14sp" /> | |||
<Button | |||
android:id="@+id/xiayi" | |||
@@ -176,8 +183,9 @@ | |||
android:layout_marginLeft="@dimen/dp_10" | |||
android:background="@drawable/button" | |||
android:text="下移" | |||
tools:ignore="TouchTargetSizeCheck" | |||
android:textColor="@color/black" | |||
android:textSize="14dp" /> | |||
android:textSize="14sp" /> | |||
</LinearLayout> | |||
<ListView | |||
@@ -231,6 +239,7 @@ | |||
android:id="@+id/hrgx" | |||
style="@style/commonSpinnerStyle" | |||
android:layout_width="match_parent" | |||
tools:ignore="TouchTargetSizeCheck" | |||
android:layout_height="24dp" | |||
android:layout_centerVertical="true" /> | |||
</LinearLayout> | |||
@@ -259,32 +268,35 @@ | |||
<Button | |||
android:id="@+id/add_hrgx" | |||
android:layout_width="50dp" | |||
android:layout_height="26dp" | |||
android:layout_width="80dp" | |||
android:layout_height="30dp" | |||
android:background="@drawable/button1" | |||
android:text="添加" | |||
tools:ignore="TouchTargetSizeCheck" | |||
android:textColor="@color/black" | |||
android:textSize="14dp" /> | |||
android:textSize="14sp" /> | |||
<Button | |||
android:id="@+id/update_gx" | |||
android:layout_width="50dp" | |||
android:layout_height="26dp" | |||
android:layout_width="80dp" | |||
android:layout_height="30dp" | |||
android:layout_marginLeft="@dimen/dp_10" | |||
android:background="@drawable/button" | |||
tools:ignore="TouchTargetSizeCheck" | |||
android:text="修改" | |||
android:textColor="@color/black" | |||
android:textSize="14dp" /> | |||
android:textSize="14sp" /> | |||
<Button | |||
android:id="@+id/delete_gx" | |||
android:layout_width="50dp" | |||
android:layout_height="26dp" | |||
android:layout_width="80dp" | |||
android:layout_height="30dp" | |||
android:layout_marginLeft="@dimen/dp_10" | |||
android:background="@drawable/button" | |||
tools:ignore="TouchTargetSizeCheck" | |||
android:text="删除" | |||
android:textColor="@color/black" | |||
android:textSize="14dp" /> | |||
android:textSize="14sp" /> | |||
</LinearLayout> | |||
</RelativeLayout> | |||
@@ -302,6 +314,7 @@ | |||
android:layout_height="45dp" | |||
android:background="@drawable/bg_btn_login_selected" | |||
android:text="生成菜谱" | |||
tools:ignore="TouchTargetSizeCheck" | |||
android:textColor="@color/white" | |||
android:textSize="18sp" /> | |||
</RelativeLayout> | |||
@@ -29,6 +29,8 @@ | |||
<LinearLayout | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" | |||
android:focusable="true" | |||
android:focusableInTouchMode="true" | |||
android:layout_alignParentBottom="true"> | |||
<EditText | |||
android:id="@+id/starttime" | |||
@@ -31,6 +31,8 @@ | |||
<LinearLayout | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" | |||
android:focusable="true" | |||
android:focusableInTouchMode="true" | |||
android:layout_alignParentBottom="true"> | |||
<EditText | |||
@@ -26,6 +26,8 @@ | |||
<TableLayout | |||
android:layout_centerHorizontal="true" | |||
android:layout_width="wrap_content" | |||
android:focusable="true" | |||
android:focusableInTouchMode="true" | |||
android:layout_height="wrap_content"> | |||
<!-- Table1--> | |||
<TableRow | |||
@@ -416,99 +416,132 @@ | |||
android:focusable="true" | |||
android:clickable="true" | |||
> | |||
<RelativeLayout | |||
android:layout_centerInParent="true" | |||
android:layout_width="600dp" | |||
android:layout_height="400dp" | |||
android:layout_height="450dp" | |||
android:layout_centerInParent="true" | |||
android:background="@drawable/silosbj"> | |||
<ImageView | |||
android:id="@+id/close_hlkz" | |||
android:layout_width="50dp" | |||
android:layout_height="50dp" | |||
android:layout_alignParentRight="true" | |||
android:layout_marginTop="10dp" | |||
android:layout_marginRight="10dp" | |||
android:layout_alignParentRight="true" | |||
android:src="@mipmap/newdelete"/> | |||
android:src="@mipmap/newdelete" /> | |||
<RelativeLayout | |||
android:layout_marginTop="70dp" | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent" | |||
android:layout_marginLeft="30dp" | |||
android:layout_marginTop="70dp" | |||
android:layout_marginRight="30dp" | |||
android:layout_marginBottom="30dp" | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent"> | |||
android:layout_marginBottom="30dp"> | |||
<LinearLayout | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:orientation="vertical"> | |||
<RelativeLayout | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content"> | |||
<LinearLayout | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content"> | |||
<RelativeLayout | |||
android:layout_width="wrap_content" | |||
android:layout_height="match_parent"> | |||
<TextView | |||
android:layout_marginLeft="@dimen/dp_10" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_centerVertical="true" | |||
android:layout_marginLeft="@dimen/dp_10" | |||
android:text="点火模式:" | |||
android:textSize="19dp"/> | |||
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 | |||
android:layout_width="wrap_content" | |||
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="手动"/> | |||
<RadioButton | |||
android:id="@+id/RB_Auto" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_marginLeft="10dp" | |||
android:text="自动"/> | |||
</RadioGroup> | |||
</LinearLayout> | |||
<LinearLayout | |||
android:layout_alignParentRight="true" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content"> | |||
<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" /> | |||
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" />--> | |||
</LinearLayout> | |||
</RelativeLayout> | |||
<RelativeLayout | |||
android:layout_marginTop="10dp" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content"> | |||
android:layout_height="wrap_content" | |||
android:layout_marginTop="10dp"> | |||
<LinearLayout | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content"> | |||
<RelativeLayout | |||
android:layout_width="wrap_content" | |||
android:layout_height="match_parent"> | |||
<TextView | |||
android:layout_marginLeft="@dimen/dp_10" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_centerVertical="true" | |||
android:layout_marginLeft="@dimen/dp_10" | |||
android:text="小火控制:" | |||
android:textSize="19dp"/> | |||
android:textSize="19dp" /> | |||
</RelativeLayout> | |||
<com.litao.slider.NiftySlider | |||
android:id="@+id/slider_小火" | |||
android:layout_width="340dp" | |||
android:layout_height="wrap_content" | |||
android:layout_marginLeft="@dimen/dp_10" | |||
android:layout_centerVertical="true" | |||
android:layout_marginLeft="@dimen/dp_10" | |||
android:hapticFeedbackEnabled="true" | |||
android:stepSize="1" | |||
android:value="0" | |||
@@ -528,42 +561,47 @@ | |||
</LinearLayout> | |||
<LinearLayout | |||
android:layout_alignParentRight="true" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content"> | |||
android:layout_height="wrap_content" | |||
android:layout_alignParentRight="true"> | |||
<RelativeLayout | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content"> | |||
<com.suke.widget.SwitchButton | |||
android:id="@+id/switch_小火" | |||
android:layout_marginLeft="20dp" | |||
app:sb_uncheck_color="@color/app_color_blue" | |||
app:sb_uncheckcircle_color="@color/app_color_blue" | |||
app:sb_button_color="@color/app_color_blue" | |||
android:layout_width="80dp" | |||
android:layout_height="wrap_content" | |||
android:focusable="true"/> | |||
android:layout_marginLeft="20dp" | |||
android:focusable="true" | |||
app:sb_button_color="@color/app_color_blue" | |||
app:sb_uncheck_color="@color/app_color_blue" | |||
app:sb_uncheckcircle_color="@color/app_color_blue" /> | |||
</RelativeLayout> | |||
</LinearLayout> | |||
</RelativeLayout> | |||
<RelativeLayout | |||
android:layout_marginTop="10dp" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content"> | |||
android:layout_height="wrap_content" | |||
android:layout_marginTop="10dp"> | |||
<LinearLayout | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content"> | |||
<RelativeLayout | |||
android:layout_width="wrap_content" | |||
android:layout_height="match_parent"> | |||
<TextView | |||
android:layout_marginLeft="@dimen/dp_10" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_centerVertical="true" | |||
android:layout_marginLeft="@dimen/dp_10" | |||
android:text="中火控制:" | |||
android:textSize="19dp"/> | |||
android:textSize="19dp" /> | |||
</RelativeLayout> | |||
<com.litao.slider.NiftySlider | |||
@@ -571,8 +609,8 @@ | |||
android:layout_width="340dp" | |||
android:layout_height="wrap_content" | |||
android:layout_marginLeft="@dimen/dp_10" | |||
android:layout_centerVertical="true" | |||
android:layout_marginLeft="@dimen/dp_10" | |||
android:hapticFeedbackEnabled="true" | |||
android:stepSize="1" | |||
android:value="0" | |||
@@ -592,43 +630,47 @@ | |||
</LinearLayout> | |||
<LinearLayout | |||
android:layout_alignParentRight="true" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content"> | |||
android:layout_height="wrap_content" | |||
android:layout_alignParentRight="true"> | |||
<RelativeLayout | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content"> | |||
<com.suke.widget.SwitchButton | |||
android:id="@+id/switch_中火" | |||
android:layout_marginLeft="20dp" | |||
app:sb_uncheck_color="@color/app_color_blue" | |||
app:sb_uncheckcircle_color="@color/app_color_blue" | |||
app:sb_button_color="@color/app_color_blue" | |||
android:layout_width="80dp" | |||
android:layout_height="wrap_content" | |||
android:focusable="true"/> | |||
android:layout_marginLeft="20dp" | |||
android:focusable="true" | |||
app:sb_button_color="@color/app_color_blue" | |||
app:sb_uncheck_color="@color/app_color_blue" | |||
app:sb_uncheckcircle_color="@color/app_color_blue" /> | |||
</RelativeLayout> | |||
</LinearLayout> | |||
</RelativeLayout> | |||
<RelativeLayout | |||
android:layout_marginTop="10dp" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content"> | |||
android:layout_height="wrap_content" | |||
android:layout_marginTop="10dp"> | |||
<LinearLayout | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content"> | |||
<RelativeLayout | |||
android:layout_width="wrap_content" | |||
android:layout_height="match_parent"> | |||
<TextView | |||
android:layout_marginLeft="@dimen/dp_10" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_centerVertical="true" | |||
android:layout_marginLeft="@dimen/dp_10" | |||
android:text="大火控制:" | |||
android:textSize="19dp"/> | |||
android:textSize="19dp" /> | |||
</RelativeLayout> | |||
<com.litao.slider.NiftySlider | |||
@@ -636,8 +678,8 @@ | |||
android:layout_width="340dp" | |||
android:layout_height="wrap_content" | |||
android:layout_marginLeft="@dimen/dp_10" | |||
android:layout_centerVertical="true" | |||
android:layout_marginLeft="@dimen/dp_10" | |||
android:hapticFeedbackEnabled="true" | |||
android:stepSize="1" | |||
android:value="0" | |||
@@ -657,51 +699,56 @@ | |||
</LinearLayout> | |||
<LinearLayout | |||
android:layout_alignParentRight="true" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content"> | |||
android:layout_height="wrap_content" | |||
android:layout_alignParentRight="true"> | |||
<RelativeLayout | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content"> | |||
<com.suke.widget.SwitchButton | |||
android:id="@+id/switch_大火" | |||
android:layout_marginLeft="20dp" | |||
app:sb_uncheck_color="@color/app_color_blue" | |||
app:sb_uncheckcircle_color="@color/app_color_blue" | |||
app:sb_button_color="@color/app_color_blue" | |||
android:layout_width="80dp" | |||
android:layout_height="wrap_content" | |||
android:focusable="true"/> | |||
android:layout_marginLeft="20dp" | |||
android:focusable="true" | |||
app:sb_button_color="@color/app_color_blue" | |||
app:sb_uncheck_color="@color/app_color_blue" | |||
app:sb_uncheckcircle_color="@color/app_color_blue" /> | |||
</RelativeLayout> | |||
</LinearLayout> | |||
</RelativeLayout> | |||
<RelativeLayout | |||
android:layout_marginTop="10dp" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content"> | |||
android:layout_height="wrap_content" | |||
android:layout_marginTop="10dp"> | |||
<LinearLayout | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content"> | |||
<RelativeLayout | |||
android:layout_width="wrap_content" | |||
android:layout_height="match_parent"> | |||
<TextView | |||
android:layout_marginLeft="@dimen/dp_10" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_centerVertical="true" | |||
android:layout_marginLeft="@dimen/dp_10" | |||
android:text="强火控制:" | |||
android:textSize="19dp"/> | |||
android:textSize="19dp" /> | |||
</RelativeLayout> | |||
<com.litao.slider.NiftySlider | |||
android:id="@+id/slider_强火" | |||
android:layout_width="340dp" | |||
android:layout_height="wrap_content" | |||
android:layout_marginLeft="@dimen/dp_10" | |||
android:layout_centerVertical="true" | |||
android:layout_marginLeft="@dimen/dp_10" | |||
android:hapticFeedbackEnabled="true" | |||
android:stepSize="1" | |||
android:value="0" | |||
@@ -721,122 +768,166 @@ | |||
</LinearLayout> | |||
<LinearLayout | |||
android:layout_alignParentRight="true" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content"> | |||
android:layout_height="wrap_content" | |||
android:layout_alignParentRight="true"> | |||
<RelativeLayout | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content"> | |||
<com.suke.widget.SwitchButton | |||
android:id="@+id/switch_强火" | |||
android:layout_marginLeft="20dp" | |||
app:sb_uncheck_color="@color/app_color_blue" | |||
app:sb_uncheckcircle_color="@color/app_color_blue" | |||
app:sb_button_color="@color/app_color_blue" | |||
android:layout_width="80dp" | |||
android:layout_height="wrap_content" | |||
android:focusable="true"/> | |||
android:layout_marginLeft="20dp" | |||
android:focusable="true" | |||
app:sb_button_color="@color/app_color_blue" | |||
app:sb_uncheck_color="@color/app_color_blue" | |||
app:sb_uncheckcircle_color="@color/app_color_blue" /> | |||
</RelativeLayout> | |||
</LinearLayout> | |||
</RelativeLayout> | |||
<RelativeLayout | |||
android:layout_marginTop="10dp" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content"> | |||
android:layout_height="wrap_content" | |||
android:layout_marginTop="10dp"> | |||
<LinearLayout | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content"> | |||
<RelativeLayout | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content"> | |||
<TextView | |||
android:layout_marginLeft="@dimen/dp_10" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_centerVertical="true" | |||
android:layout_marginLeft="@dimen/dp_10" | |||
android:text="温度修正:" | |||
android:textSize="19dp"/> | |||
android:textSize="19dp" /> | |||
</RelativeLayout> | |||
<EditText | |||
android:id="@+id/edit_温度修正" | |||
android:layout_width="120dp" | |||
android:layout_height="wrap_content" | |||
android:layout_marginLeft="5dp" | |||
android:layout_width="100dp" | |||
android:layout_height="25dp" | |||
android:layout_marginLeft="18dp" | |||
android:layout_marginTop="-3dp" | |||
android:background="@drawable/input_bj" | |||
android:hint="请输入" | |||
android:inputType="number" | |||
android:inputType="numberDecimal" | |||
android:maxLines="1" | |||
android:padding="3dp" | |||
android:textSize="12dp" | |||
android:text="0"/> | |||
android:paddingLeft="2dp" | |||
android:text="0.0" | |||
android:textSize="18sp" /> | |||
<RelativeLayout | |||
android:layout_width="wrap_content" | |||
android:layout_height="match_parent"> | |||
<TextView | |||
android:layout_marginLeft="@dimen/dp_10" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_centerVertical="true" | |||
android:layout_marginLeft="40dp" | |||
android:text="温度上限:" | |||
android:textSize="19dp"/> | |||
android:textSize="19dp" /> | |||
</RelativeLayout> | |||
<EditText | |||
android:id="@+id/edit_温度上限" | |||
android:layout_width="120dp" | |||
android:layout_height="wrap_content" | |||
android:layout_width="100dp" | |||
android:layout_height="25dp" | |||
android:layout_marginLeft="5dp" | |||
android:layout_marginTop="-3dp" | |||
android:background="@drawable/input_bj" | |||
android:hint="请输入" | |||
android:inputType="number" | |||
android:inputType="numberDecimal" | |||
android:paddingLeft="2dp" | |||
android:maxLines="1" | |||
android:padding="3dp" | |||
android:textSize="12dp" | |||
android:text="0"/> | |||
android:text="0.0" | |||
android:textSize="18sp" /> | |||
<Button | |||
android:id="@+id/button_写入参数" | |||
android:layout_width="70dp" | |||
android:layout_height="30dp" | |||
android:layout_marginLeft="25dp" | |||
android:background="@drawable/bg_btn_login_selected" | |||
android:text="写入" | |||
android:textColor="@color/white" | |||
android:textSize="18sp" /> | |||
</LinearLayout> | |||
</RelativeLayout> | |||
<RelativeLayout | |||
android:layout_marginTop="10dp" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content"> | |||
android:layout_height="wrap_content" | |||
android:layout_marginTop="10dp"> | |||
<LinearLayout | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content"> | |||
<RelativeLayout | |||
android:layout_width="wrap_content" | |||
android:layout_height="match_parent"> | |||
<TextView | |||
android:layout_marginLeft="@dimen/dp_10" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_centerVertical="true" | |||
android:layout_marginLeft="@dimen/dp_10" | |||
android:text="点火控制:" | |||
android:textSize="19dp"/> | |||
android:textSize="19dp" /> | |||
</RelativeLayout> | |||
<com.suke.widget.SwitchButton | |||
android:id="@+id/switch_点火控制" | |||
android:layout_marginLeft="20dp" | |||
app:sb_uncheck_color="@color/app_color_blue" | |||
app:sb_uncheckcircle_color="@color/app_color_blue" | |||
app:sb_button_color="@color/app_color_blue" | |||
android:layout_width="80dp" | |||
android:layout_height="wrap_content" | |||
android:focusable="true"/> | |||
android:layout_marginLeft="20dp" | |||
android:focusable="true" | |||
app:sb_button_color="@color/app_color_blue" | |||
app:sb_uncheck_color="@color/app_color_blue" | |||
app:sb_uncheckcircle_color="@color/app_color_blue" /> | |||
<RelativeLayout | |||
android:layout_width="wrap_content" | |||
android:layout_height="match_parent"> | |||
<TextView | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_centerVertical="true" | |||
android:layout_marginLeft="60dp" | |||
android:text="点火状态:" | |||
android:textSize="19dp" /> | |||
</RelativeLayout> | |||
<TextView | |||
android:layout_marginLeft="30dp" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_centerVertical="true" | |||
android:layout_marginTop="4dp" | |||
android:layout_marginLeft="5dp" | |||
android:text="点火失败" | |||
android:textSize="19dp" | |||
android:textColor="@color/purple_primary"/> | |||
android:textColor="@color/purple_primary" | |||
android:textSize="19dp" /> | |||
<Button | |||
android:id="@+id/button_点火复位" | |||
android:layout_width="70dp" | |||
android:layout_height="30dp" | |||
android:layout_marginLeft="47dp" | |||
android:background="@drawable/bg_btn_login_selected" | |||
android:text="复位" | |||
android:textColor="@color/white" | |||
android:textSize="18sp" /> | |||
</LinearLayout> | |||
</RelativeLayout> | |||
</LinearLayout> | |||
@@ -1048,12 +1139,12 @@ | |||
android:layout_height="match_parent" | |||
android:background="#BD25323F" | |||
android:focusable="true" | |||
android:clickable="true" | |||
android:visibility="gone"> | |||
android:visibility="gone" | |||
android:clickable="true"> | |||
<RelativeLayout | |||
android:layout_centerInParent="true" | |||
android:layout_width="600dp" | |||
android:layout_height="400dp" | |||
android:layout_width="500dp" | |||
android:layout_height="300dp" | |||
android:background="@drawable/silosbj"> | |||
<ImageView | |||
android:id="@+id/close_jykz" | |||
@@ -1076,7 +1167,9 @@ | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:orientation="vertical"> | |||
<RelativeLayout | |||
android:layout_marginTop="20dp" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content"> | |||
<LinearLayout | |||
@@ -1090,50 +1183,52 @@ | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_centerVertical="true" | |||
android:text="当前重量:" | |||
android:text="抽油启停:" | |||
android:textSize="19dp"/> | |||
</RelativeLayout> | |||
<TextView | |||
android:id="@+id/PanWeight" | |||
android:layout_marginLeft="@dimen/dp_10" | |||
android:layout_width="wrap_content" | |||
<com.suke.widget.SwitchButton | |||
android:id="@+id/switch_抽油启停" | |||
android:layout_marginLeft="8dp" | |||
app:sb_uncheck_color="@color/app_color_blue" | |||
app:sb_uncheckcircle_color="@color/app_color_blue" | |||
app:sb_button_color="@color/app_color_blue" | |||
android:layout_width="80dp" | |||
android:layout_height="wrap_content" | |||
android:layout_centerVertical="true" | |||
android:text="100kg" | |||
android:textColor="@color/app_color_blue" | |||
android:textSize="19dp"/> | |||
android:focusable="true"/> | |||
</LinearLayout> | |||
<LinearLayout | |||
android:layout_alignParentRight="true" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content"> | |||
<RelativeLayout | |||
android:layout_width="wrap_content" | |||
android:layout_height="match_parent"> | |||
<TextView | |||
android:layout_marginLeft="@dimen/dp_10" | |||
android:layout_marginLeft="230dp" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_centerVertical="true" | |||
android:text="选择原油:" | |||
android:text="备用气缸:" | |||
android:textSize="19dp"/> | |||
</RelativeLayout> | |||
<Spinner | |||
android:id="@+id/editsp_物料" | |||
style="@style/commonSpinnerStyle" | |||
<com.suke.widget.SwitchButton | |||
android:id="@+id/switch_备用气缸" | |||
android:layout_marginLeft="6dp" | |||
app:sb_uncheck_color="@color/app_color_blue" | |||
app:sb_uncheckcircle_color="@color/app_color_blue" | |||
app:sb_button_color="@color/app_color_blue" | |||
android:layout_width="80dp" | |||
android:layout_height="24dp" | |||
android:layout_centerVertical="true" /> | |||
android:layout_height="wrap_content" | |||
android:focusable="true"/> | |||
</LinearLayout> | |||
</RelativeLayout> | |||
<RelativeLayout | |||
android:layout_marginTop="20dp" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content"> | |||
android:layout_height="35dp"> | |||
<LinearLayout | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content"> | |||
@@ -1156,17 +1251,17 @@ | |||
android:layout_marginLeft="5dp" | |||
android:background="@drawable/input_bj" | |||
android:hint="请输入" | |||
android:inputType="number" | |||
android:inputType="numberDecimal" | |||
android:maxLines="1" | |||
android:padding="3dp" | |||
android:textSize="14dp" | |||
android:text="0"/> | |||
android:paddingLeft="5dp" | |||
android:textSize="18sp" | |||
android:text="0.0"/> | |||
<RelativeLayout | |||
android:layout_width="wrap_content" | |||
android:layout_height="match_parent"> | |||
<TextView | |||
android:layout_marginLeft="@dimen/dp_10" | |||
android:layout_marginLeft="30dp" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_centerVertical="true" | |||
@@ -1181,21 +1276,21 @@ | |||
android:layout_marginLeft="5dp" | |||
android:background="@drawable/input_bj" | |||
android:hint="请输入" | |||
android:inputType="number" | |||
android:inputType="numberDecimal" | |||
android:maxLines="1" | |||
android:padding="3dp" | |||
android:textSize="14dp" | |||
android:text="0"/> | |||
<Button | |||
android:id="@+id/button_出料" | |||
android:layout_width="100dp" | |||
android:layout_height="45dp" | |||
android:layout_marginLeft="15dp" | |||
android:background="@drawable/bg_btn_login_selected" | |||
android:text="出料" | |||
android:textColor="@color/white" | |||
android:textSize="18sp" /> | |||
android:paddingLeft="5dp" | |||
android:textSize="18sp" | |||
android:text="0.0"/> | |||
<!-- <Button--> | |||
<!-- android:id="@+id/button_出料"--> | |||
<!-- android:layout_width="100dp"--> | |||
<!-- android:layout_height="45dp"--> | |||
<!-- android:layout_marginLeft="15dp"--> | |||
<!-- android:background="@drawable/bg_btn_login_selected"--> | |||
<!-- android:text="出料"--> | |||
<!-- android:textColor="@color/white"--> | |||
<!-- android:textSize="18sp" />--> | |||
</LinearLayout> | |||
@@ -1216,49 +1311,56 @@ | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_centerVertical="true" | |||
android:text="抽油启停:" | |||
android:text="当前重量:" | |||
android:textSize="19dp"/> | |||
</RelativeLayout> | |||
<com.suke.widget.SwitchButton | |||
android:id="@+id/switch_抽油启停" | |||
android:layout_marginLeft="20dp" | |||
app:sb_uncheck_color="@color/app_color_blue" | |||
app:sb_uncheckcircle_color="@color/app_color_blue" | |||
app:sb_button_color="@color/app_color_blue" | |||
android:layout_width="80dp" | |||
android:layout_height="wrap_content" | |||
android:focusable="true"/> | |||
</LinearLayout> | |||
<LinearLayout | |||
android:layout_alignParentRight="true" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content"> | |||
<RelativeLayout | |||
<TextView | |||
android:id="@+id/PanWeight" | |||
android:layout_marginLeft="@dimen/dp_10" | |||
android:layout_width="wrap_content" | |||
android:layout_height="match_parent"> | |||
<TextView | |||
android:layout_marginLeft="@dimen/dp_10" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_centerVertical="true" | |||
android:text="备用气缸:" | |||
android:textSize="19dp"/> | |||
</RelativeLayout> | |||
<com.suke.widget.SwitchButton | |||
android:id="@+id/switch_备用气缸" | |||
android:layout_marginLeft="20dp" | |||
app:sb_uncheck_color="@color/app_color_blue" | |||
app:sb_uncheckcircle_color="@color/app_color_blue" | |||
app:sb_button_color="@color/app_color_blue" | |||
android:layout_width="80dp" | |||
android:layout_height="wrap_content" | |||
android:focusable="true"/> | |||
android:layout_centerVertical="true" | |||
android:text="100kg" | |||
android:textColor="@color/app_color_blue" | |||
android:textSize="19dp"/> | |||
</LinearLayout> | |||
<Button | |||
android:id="@+id/button_出料" | |||
android:layout_width="100dp" | |||
android:layout_height="35dp" | |||
android:layout_marginLeft="320dp" | |||
android:background="@drawable/bg_btn_login_selected" | |||
android:text="出料" | |||
android:textColor="@color/white" | |||
android:textSize="18sp" /> | |||
<!-- <LinearLayout--> | |||
<!-- android:layout_alignParentRight="true"--> | |||
<!-- android:layout_width="wrap_content"--> | |||
<!-- android:layout_height="wrap_content">--> | |||
<!-- <RelativeLayout--> | |||
<!-- android:layout_width="wrap_content"--> | |||
<!-- android:layout_height="match_parent">--> | |||
<!-- <TextView--> | |||
<!-- android:layout_marginLeft="@dimen/dp_10"--> | |||
<!-- android:layout_width="wrap_content"--> | |||
<!-- android:layout_height="wrap_content"--> | |||
<!-- android:layout_centerVertical="true"--> | |||
<!-- android:text="选择原油:"--> | |||
<!-- android:textSize="19dp"/>--> | |||
<!-- </RelativeLayout>--> | |||
<!-- <Spinner--> | |||
<!-- android:id="@+id/editsp_物料"--> | |||
<!-- style="@style/commonSpinnerStyle"--> | |||
<!-- android:layout_width="80dp"--> | |||
<!-- android:layout_height="24dp"--> | |||
<!-- android:layout_centerVertical="true" />--> | |||
<!-- </LinearLayout>--> | |||
</RelativeLayout> | |||
</LinearLayout> | |||
</RelativeLayout> | |||