|
|
@@ -31,6 +31,7 @@ import com.bonait.bnframework.modules.home.fragment.from.LogActivity; |
|
|
|
import com.bonait.bnframework.modules.home.fragment.from.PlcControlActivity; |
|
|
|
import com.bonait.bnframework.modules.home.fragment.from.RealTimeActivity; |
|
|
|
import com.orhanobut.logger.Logger; |
|
|
|
import com.qmuiteam.qmui.arch.QMUIFragment; |
|
|
|
import com.suke.widget.SwitchButton; |
|
|
|
|
|
|
|
import java.util.List; |
|
|
@@ -136,8 +137,7 @@ public class Silos_item_jiaoyan_fragment extends BaseFragment { |
|
|
|
super.onViewCreated(view, savedInstanceState); |
|
|
|
Logger.d("我的fragment创建"); |
|
|
|
InitView(); |
|
|
|
InitData(); |
|
|
|
Run(); |
|
|
|
|
|
|
|
} |
|
|
|
//endregion |
|
|
|
|
|
|
@@ -188,21 +188,21 @@ public class Silos_item_jiaoyan_fragment extends BaseFragment { |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 初始化数据 |
|
|
|
*/ |
|
|
|
public void InitData() { |
|
|
|
exit_mgjz.setText(lcMode.bValue + ""); |
|
|
|
public QMUIFragment SetType(String type) { |
|
|
|
TypeName = type; |
|
|
|
return this; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 设置名称 |
|
|
|
* |
|
|
|
* @param type |
|
|
|
* @param |
|
|
|
*/ |
|
|
|
public void SetData(lcMode mode, String type) { |
|
|
|
TypeName = type; |
|
|
|
public QMUIFragment SetData(lcMode mode) { |
|
|
|
lcMode = mode; |
|
|
|
|
|
|
|
Run(); |
|
|
|
return this; |
|
|
|
} |
|
|
|
//endregion |
|
|
|
|
|
|
@@ -240,10 +240,10 @@ public class Silos_item_jiaoyan_fragment extends BaseFragment { |
|
|
|
int zhongliangxianshi = ExecuteTheRecipe.OutletWeigh; |
|
|
|
ExecuteTheRecipe.WritePLC("校准值" + kkk, (short) zhongliangxianshi, null); |
|
|
|
String s = String.valueOf(zhongliangxianshi); |
|
|
|
String zll=String.format("%.1f", (Double.parseDouble(s) / 10)); |
|
|
|
wljz3.setText(zll+""); |
|
|
|
lcMode.jValue=zll; |
|
|
|
QueryDB.UpdateJYZ(lcMode.id,zll); |
|
|
|
String zll = String.format("%.1f", (Double.parseDouble(s) / 10)); |
|
|
|
wljz3.setText(zll + ""); |
|
|
|
lcMode.jValue = zll; |
|
|
|
QueryDB.UpdateJYZ(lcMode.id, zll); |
|
|
|
ToastUtils.warning("通道校准完成!"); |
|
|
|
} |
|
|
|
}, 2000); |
|
|
@@ -258,23 +258,40 @@ public class Silos_item_jiaoyan_fragment extends BaseFragment { |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
new Thread(new Runnable() { |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
while (!isAdded()) { |
|
|
|
try { |
|
|
|
Thread.sleep(100); |
|
|
|
} catch (InterruptedException e) { |
|
|
|
} |
|
|
|
} |
|
|
|
getActivity().runOnUiThread(new Runnable() { |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
exit_mgjz.setText(lcMode.bValue + ""); |
|
|
|
//填充校准时间 |
|
|
|
String time = lcMode.jTime == null ? "0.0" : lcMode.jTime; |
|
|
|
String ftime = lcMode.fTime == null ? "0.0" : lcMode.fTime; |
|
|
|
String jvalue = lcMode.jValue == null ? "0.0" : lcMode.jValue; |
|
|
|
wljz1.setText(time); |
|
|
|
wljz1.setText(ftime); |
|
|
|
wljz3.setText(jvalue); |
|
|
|
|
|
|
|
String Gxs = lcMode.Gxs == null ? "0.0" : lcMode.Gxs; |
|
|
|
String Lxs = lcMode.Lxs == null ? "0.0" : lcMode.Lxs; |
|
|
|
String tdclsj = lcMode.tdclsj == null ? "0.0" : lcMode.tdclsj; |
|
|
|
|
|
|
|
control_switch.setChecked(lcMode.isOpenbcsf == 1); |
|
|
|
bcjz_gxs.setText(Gxs); |
|
|
|
bcjz_gxs.setText(Lxs); |
|
|
|
bcjz_gxs.setText(tdclsj); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
}).start(); |
|
|
|
|
|
|
|
//填充校准时间 |
|
|
|
String time = lcMode.jTime == null ? "0.0" : lcMode.jTime; |
|
|
|
String ftime = lcMode.fTime == null ? "0.0" : lcMode.fTime; |
|
|
|
String jvalue = lcMode.jValue == null ? "0.0" : lcMode.jValue; |
|
|
|
wljz1.setText(time); |
|
|
|
wljz1.setText(ftime); |
|
|
|
wljz3.setText(jvalue); |
|
|
|
|
|
|
|
String Gxs = lcMode.Gxs == null ? "0.0" : lcMode.Gxs; |
|
|
|
String Lxs = lcMode.Lxs == null ? "0.0" : lcMode.Lxs; |
|
|
|
String tdclsj = lcMode.tdclsj == null ? "0.0" : lcMode.tdclsj; |
|
|
|
|
|
|
|
control_switch.setChecked(lcMode.isOpenbcsf==1); |
|
|
|
bcjz_gxs.setText(Gxs); |
|
|
|
bcjz_gxs.setText(Lxs); |
|
|
|
bcjz_gxs.setText(tdclsj); |
|
|
|
} |
|
|
|
//endregion |
|
|
|
|
|
|
@@ -310,7 +327,7 @@ public class Silos_item_jiaoyan_fragment extends BaseFragment { |
|
|
|
R.id.chuliao1, R.id.chuliao2, R.id.chuliao3, |
|
|
|
R.id.click_mgjz, R.id.click_mgjz_save, |
|
|
|
R.id.click_wljz, R.id.click_wljz_save, |
|
|
|
R.id.control_switch,R.id.click_bcjz_save, |
|
|
|
R.id.control_switch, R.id.click_bcjz_save, |
|
|
|
}) |
|
|
|
public void onViewClicked(View view) { |
|
|
|
switch (view.getId()) { |
|
|
@@ -348,15 +365,13 @@ public class Silos_item_jiaoyan_fragment extends BaseFragment { |
|
|
|
break; |
|
|
|
|
|
|
|
case R.id.control_switch://通道开关 |
|
|
|
boolean isopen= control_switch.isChecked(); |
|
|
|
if (ConfigName.getInstance().PlcIsConnect) |
|
|
|
{ |
|
|
|
ExecuteTheRecipe.WritePLC("通道"+lcMode.num+"补偿开关",isopen,null); |
|
|
|
QueryDB.UpdateSilosisOpenbcsf(lcMode.id,isopen); |
|
|
|
ToastUtils.info(lcMode.name.toString()+(isopen?"打开":"关闭")+"成功!"); |
|
|
|
}else |
|
|
|
{ |
|
|
|
ToastUtils.warning(lcMode.name.toString()+(isopen?"打开":"关闭")+"失败!PLC未连接!!"); |
|
|
|
boolean isopen = control_switch.isChecked(); |
|
|
|
if (ConfigName.getInstance().PlcIsConnect) { |
|
|
|
ExecuteTheRecipe.WritePLC("通道" + lcMode.num + "补偿开关", isopen, null); |
|
|
|
QueryDB.UpdateSilosisOpenbcsf(lcMode.id, isopen); |
|
|
|
ToastUtils.info(lcMode.name.toString() + (isopen ? "打开" : "关闭") + "成功!"); |
|
|
|
} else { |
|
|
|
ToastUtils.warning(lcMode.name.toString() + (isopen ? "打开" : "关闭") + "失败!PLC未连接!!"); |
|
|
|
} |
|
|
|
break; |
|
|
|
case R.id.click_bcjz_save://补偿校准 保存参数 |
|
|
@@ -451,13 +466,21 @@ public class Silos_item_jiaoyan_fragment extends BaseFragment { |
|
|
|
public void SaveWLJZ() { |
|
|
|
String stime = wljz1.getText().toString(); |
|
|
|
String ftime = wljz2.getText().toString(); |
|
|
|
String zl = wljz3.getText().toString(); |
|
|
|
|
|
|
|
if (stime.equals("")) { |
|
|
|
ToastUtils.info("校准基准时间不能为空!"); |
|
|
|
ToastUtils.warning("校准基准时间不能为空!"); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
if (zl.equals("")) { |
|
|
|
ToastUtils.warning("校准重量不能为空!"); |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
int stime_1 = 0; |
|
|
|
int ftime_1 = 0; |
|
|
|
|
|
|
|
try { |
|
|
|
stime_1 = (int) Math.round((Double.parseDouble(stime) * 10)); |
|
|
|
} catch (Exception e) { |
|
|
@@ -465,9 +488,15 @@ public class Silos_item_jiaoyan_fragment extends BaseFragment { |
|
|
|
return; |
|
|
|
} |
|
|
|
|
|
|
|
try { |
|
|
|
Double.parseDouble(zl); |
|
|
|
} catch (Exception e) { |
|
|
|
ToastUtils.error("重量异常!" + e.getMessage()); |
|
|
|
return; |
|
|
|
} |
|
|
|
if (!ConfigName.getInstance().versionSelectionEnum.equals("奶茶机")) { |
|
|
|
if (ftime.equals("")) { |
|
|
|
ToastUtils.info("反转基准时间不能为空!"); |
|
|
|
ToastUtils.warning("反转基准时间不能为空!"); |
|
|
|
return; |
|
|
|
} |
|
|
|
try { |
|
|
@@ -488,7 +517,8 @@ public class Silos_item_jiaoyan_fragment extends BaseFragment { |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
QueryDB.UpdateSilosJZTime(lcMode.id,stime,ftime); |
|
|
|
QueryDB.UpdateSilosJZTime(lcMode.id, stime, ftime); |
|
|
|
QueryDB.UpdateJYZ(lcMode.id, zl); |
|
|
|
ExecuteTheRecipe.WritePLC("基准时间", (short) stime_1, new IWriteCallBack() { |
|
|
|
@Override |
|
|
|
public void onSuccess() { |
|
|
@@ -546,18 +576,16 @@ public class Silos_item_jiaoyan_fragment extends BaseFragment { |
|
|
|
|
|
|
|
//region 补偿校准 |
|
|
|
public void SaveBCJZ() { |
|
|
|
Short H=0; |
|
|
|
Short L=0; |
|
|
|
Short time=0; |
|
|
|
Short H = 0; |
|
|
|
Short L = 0; |
|
|
|
Short time = 0; |
|
|
|
try { |
|
|
|
H=Short.parseShort(bcjz_gxs.getText().toString()) ; |
|
|
|
L=Short.parseShort(bcjz_dxs.getText().toString()) ; |
|
|
|
int ftime = (int)Math.round((Double.parseDouble(bcjz_clsj.getText().toString()) * 10)); |
|
|
|
time=(short) ftime; |
|
|
|
} |
|
|
|
catch (Exception ex) |
|
|
|
{ |
|
|
|
ToastUtils.error( "数据不合法,保存变量失败!"+ex.getMessage()); |
|
|
|
H = Short.parseShort(bcjz_gxs.getText().toString()); |
|
|
|
L = Short.parseShort(bcjz_dxs.getText().toString()); |
|
|
|
int ftime = (int) Math.round((Double.parseDouble(bcjz_clsj.getText().toString()) * 10)); |
|
|
|
time = (short) ftime; |
|
|
|
} catch (Exception ex) { |
|
|
|
ToastUtils.error("数据不合法,保存变量失败!" + ex.getMessage()); |
|
|
|
return; |
|
|
|
} |
|
|
|
Short finalH = H; |
|
|
@@ -568,15 +596,16 @@ public class Silos_item_jiaoyan_fragment extends BaseFragment { |
|
|
|
@Override |
|
|
|
public void run() { |
|
|
|
try { |
|
|
|
ExecuteTheRecipe.WritePLC("高系数"+lcMode.num, finalH,null); |
|
|
|
ExecuteTheRecipe.WritePLC("低系数"+lcMode.num, finalL,null); |
|
|
|
ExecuteTheRecipe.WritePLC("高系数" + lcMode.num, finalH, null); |
|
|
|
ExecuteTheRecipe.WritePLC("低系数" + lcMode.num, finalL, null); |
|
|
|
ExecuteTheRecipe.WritePLC("补偿" + lcMode.num + "时间", finalTime, new IWriteCallBack() { |
|
|
|
@Override |
|
|
|
public void onSuccess() { |
|
|
|
ToastUtils.info("保存变量成功!"); |
|
|
|
QueryDB.UpdateSilosisOpenbcsf(lcMode.id,bcjz_gxs.getText().toString(), |
|
|
|
bcjz_dxs.getText().toString(),bcjz_clsj.getText().toString()); |
|
|
|
QueryDB.UpdateSilosisOpenbcsf(lcMode.id, bcjz_gxs.getText().toString(), |
|
|
|
bcjz_dxs.getText().toString(), bcjz_clsj.getText().toString()); |
|
|
|
} |
|
|
|
|
|
|
|
@Override |
|
|
|
public void onFailure(String ErrorMsg) { |
|
|
|
ToastUtils.warning("保存变量失败!"); |
|
|
|