Przeglądaj źródła

444

味魔方Android
fyf 1 rok temu
rodzic
commit
cb8ef4dbf8
3 zmienionych plików z 106 dodań i 68 usunięć
  1. +87
    -58
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/Silos_item_jiaoyan_fragment.java
  2. +16
    -9
      app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/silos_jiaoyan.java
  3. +3
    -1
      app/src/main/res/layout/item/layout/fragment_silos_item_jiaoyan.xml

+ 87
- 58
app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/Silos_item_jiaoyan_fragment.java Wyświetl plik

@@ -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("保存变量失败!");


+ 16
- 9
app/src/main/java/com/bonait/bnframework/modules/home/fragment/mode/silos_jiaoyan.java Wyświetl plik

@@ -17,6 +17,7 @@ import android.widget.RelativeLayout;
import android.widget.Spinner;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.fragment.app.FragmentManager;

@@ -34,6 +35,7 @@ import com.qmuiteam.qmui.arch.QMUIFragment;
import com.qmuiteam.qmui.arch.QMUIFragmentPagerAdapter;
import com.qmuiteam.qmui.widget.QMUIViewPager;
import com.qmuiteam.qmui.widget.dialog.QMUIDialog;
import com.qmuiteam.qmui.widget.tab.QMUIBasicTabSegment;
import com.qmuiteam.qmui.widget.tab.QMUITabSegment;

import java.math.BigDecimal;
@@ -94,16 +96,17 @@ public class silos_jiaoyan extends LinearLayout {
{
title_bc.setText(lcMode.num+" "+lcMode.materialName);
froms.clear();
Silos_item_jiaoyan_fragment jiaoyan_fragment=new Silos_item_jiaoyan_fragment();
if(lcMode.name.equals("外置仓"))
{
froms.add(new ResMenuLeft(null,"物料校准",0,0,true));
froms.add(new ResMenuLeft(null,"满管校准",0,0,false));
froms.add(new ResMenuLeft(null,"酱料校准",0,0,false));
froms.add(new ResMenuLeft(null,"补偿校准",0,0,false));
froms.add(new ResMenuLeft(new Silos_item_jiaoyan_fragment().SetType("物料校准"),"物料校准",0,0,true));
froms.add(new ResMenuLeft(new Silos_item_jiaoyan_fragment().SetType("满管校准"),"满管校准",0,0,false));
froms.add(new ResMenuLeft(new Silos_item_jiaoyan_fragment().SetType("酱料校准"),"酱料校准",0,0,false));
froms.add(new ResMenuLeft(new Silos_item_jiaoyan_fragment().SetType("补偿校准"),"补偿校准",0,0,false));
}else
{
froms.add(new ResMenuLeft(null,"物料校准",0,0,true));
froms.add(new ResMenuLeft(null,"满管校准",0,0,false));
froms.add(new ResMenuLeft(new Silos_item_jiaoyan_fragment().SetType("物料校准"),"物料校准",0,0,true));
froms.add(new ResMenuLeft(new Silos_item_jiaoyan_fragment().SetType("满管校准"),"满管校准",0,0,false));
}

QMUIFragmentPagerAdapter adapter = new QMUIFragmentPagerAdapter(fragmentManager) {
@@ -115,18 +118,22 @@ public class silos_jiaoyan extends LinearLayout {
@Override
public QMUIFragment createFragment(int position) {
//显示数元
Silos_item_jiaoyan_fragment jiaoyan_fragment=new Silos_item_jiaoyan_fragment();
jiaoyan_fragment.SetData(lcMode, froms.get(position).name);
return jiaoyan_fragment;
return ((Silos_item_jiaoyan_fragment)froms.get(position).fragment).SetData(lcMode);
}

@Override
public CharSequence getPageTitle(int position) {
return froms.get(position).name.toString();
}

@Override
public int getItemPosition(@NonNull Object object) {
return super.getItemPosition(object);
}
};
viewpager_jiaozhun.setAdapter(adapter);
tabs_jiaozhun.setupWithViewPager(viewpager_jiaozhun, true);

}

private void initEvent()


+ 3
- 1
app/src/main/res/layout/item/layout/fragment_silos_item_jiaoyan.xml Wyświetl plik

@@ -539,6 +539,8 @@
</LinearLayout>

<RelativeLayout
android:focusable="true"
android:clickable="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#BE000000">
@@ -546,7 +548,7 @@
android:layout_centerInParent="true"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="后续开放"
android:text="研发中..."
android:textSize="40dp"
android:textColor="#DA1CD7"></TextView>
</RelativeLayout>


Ładowanie…
Anuluj
Zapisz