From cb8e8c2b5a7fbadb4fd020e37cd0a86bac019b06 Mon Sep 17 00:00:00 2001 From: fyf Date: Sat, 16 Dec 2023 15:54:29 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=82=92=E9=94=85=E8=B0=83?= =?UTF-8?q?=E8=AF=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- app/src/main/AndroidManifest.xml | 9 + .../home/fragment/from/WhActivity.java | 21 +- .../home/fragment/from/WokSetActivity.java | 159 ++++ .../from/fragment/WokSetGKCXFragment.java | 394 ++++++++ .../from/fragment/WokSetTLZZFragment.java | 447 +++++++++ .../modules/mine/fragment/MyFragment.java | 16 + app/src/main/res/drawable-hdpi/device_sz.png | Bin 0 -> 1161 bytes app/src/main/res/drawable/button2.xml | 30 + app/src/main/res/drawable/button3.xml | 30 + app/src/main/res/layout/activity_wok_set.xml | 91 ++ app/src/main/res/layout/fragment_my.xml | 9 + .../main/res/layout/fragment_wok_set_gkcx.xml | 726 ++++++++++++++ .../main/res/layout/fragment_wok_set_tlzz.xml | 891 ++++++++++++++++++ app/src/main/res/menu/deviceset.xml | 10 + app/src/main/res/mipmap-xhdpi/status_y.png | Bin 0 -> 674 bytes app/src/main/res/mipmap-xhdpi/status_z.png | Bin 0 -> 646 bytes 16 files changed, 2822 insertions(+), 11 deletions(-) create mode 100644 app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/WokSetActivity.java create mode 100644 app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/WokSetGKCXFragment.java create mode 100644 app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/WokSetTLZZFragment.java create mode 100644 app/src/main/res/drawable-hdpi/device_sz.png create mode 100644 app/src/main/res/drawable/button2.xml create mode 100644 app/src/main/res/drawable/button3.xml create mode 100644 app/src/main/res/layout/activity_wok_set.xml create mode 100644 app/src/main/res/layout/fragment_wok_set_gkcx.xml create mode 100644 app/src/main/res/layout/fragment_wok_set_tlzz.xml create mode 100644 app/src/main/res/menu/deviceset.xml create mode 100644 app/src/main/res/mipmap-xhdpi/status_y.png create mode 100644 app/src/main/res/mipmap-xhdpi/status_z.png diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index 8fe53452..e90f1d0e 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -33,6 +33,15 @@ tools:ignore="GoogleAppIndexingWarning" tools:node="merge" tools:replace="android:icon"> + + + diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/WhActivity.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/WhActivity.java index 13927f9f..c4449034 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/WhActivity.java +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/WhActivity.java @@ -45,6 +45,7 @@ public class WhActivity extends BaseActivity { Button quanxianmima;//权限密码 private MenuItem menuItem; + @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); @@ -66,7 +67,7 @@ public class WhActivity extends BaseActivity { private void initTopBar() { mTopBar.setTitle("系统维护"); - mTopBar.addLeftImageButton(R.mipmap.fanhui,R.id.topbar).setOnClickListener(new View.OnClickListener() { + mTopBar.addLeftImageButton(R.mipmap.fanhui, R.id.topbar).setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { finish(); @@ -76,25 +77,23 @@ public class WhActivity extends BaseActivity { quanxianmima.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { - String s=edittext_quanxian.getText().toString(); - if (s==null ||s.isEmpty()) - { + String s = edittext_quanxian.getText().toString(); + if (s == null || s.isEmpty()) { ToastUtils.warning("权限密码不能为空!"); - }else - { - if(s.equals(ConfigName.getInstance().user.pass)) - { + } else { + if (s.equals(ConfigName.getInstance().user.pass)) { quanxian.setVisibility(View.GONE); viewPager.setVisibility(View.VISIBLE); - }else - { + } else { ToastUtils.warning("权限密码不正确!"); } } } }); } - FragmentAdapter fragmentAdapter=null; + + FragmentAdapter fragmentAdapter = null; + /** * viewPager里添加fragment */ diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/WokSetActivity.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/WokSetActivity.java new file mode 100644 index 00000000..3c33588f --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/WokSetActivity.java @@ -0,0 +1,159 @@ +package com.bonait.bnframework.modules.home.fragment.from; + +import androidx.annotation.NonNull; +import androidx.appcompat.app.AppCompatActivity; +import androidx.viewpager.widget.ViewPager; + +import android.os.Bundle; +import android.view.MenuItem; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; +import android.widget.RelativeLayout; + +import com.bonait.bnframework.R; +import com.bonait.bnframework.common.base.BaseActivity; +import com.bonait.bnframework.common.constant.ConfigName; +import com.bonait.bnframework.common.utils.ToastUtils; +import com.bonait.bnframework.modules.home.adapter.FragmentAdapter; +import com.bonait.bnframework.modules.home.fragment.from.fragment.SystemCsControlFragment; +import com.bonait.bnframework.modules.home.fragment.from.fragment.SystemCsFltlFragment; +import com.bonait.bnframework.modules.home.fragment.from.fragment.SystemCsMonitorFragment; +import com.bonait.bnframework.modules.home.fragment.from.fragment.SystemCsPLCFragment; +import com.bonait.bnframework.modules.home.fragment.from.fragment.WokSetGKCXFragment; +import com.bonait.bnframework.modules.home.fragment.from.fragment.WokSetTLZZFragment; +import com.google.android.material.bottomnavigation.BottomNavigationView; +import com.qmuiteam.qmui.widget.QMUITopBarLayout; +import com.qmuiteam.qmui.widget.QMUIViewPager; + +import butterknife.BindView; +import butterknife.ButterKnife; + +public class WokSetActivity extends BaseActivity { + + @BindView(R.id.topbar) + QMUITopBarLayout mTopBar; + @BindView(R.id.navigation) + BottomNavigationView bottomNavigationView; + @BindView(R.id.viewpager) + QMUIViewPager viewPager; + + @BindView(R.id.quanxian) + RelativeLayout quanxian;//权限显示 + @BindView(R.id.edittext_quanxian) + EditText edittext_quanxian;//权限密码 + @BindView(R.id.quanxianmima) + Button quanxianmima;//权限密码 + + private MenuItem menuItem; + + @Override + protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + setContentView(R.layout.activity_wok_set); + + ButterKnife.bind(this); + initTopBar(); + initFragment(); + viewPager.addOnPageChangeListener(pageChangeListener); + // 设置viewPager缓存多少个fragment + viewPager.setOffscreenPageLimit(2); + bottomNavigationView.setOnNavigationItemSelectedListener(mOnNavigationItemSelectedListener); + } + + @Override + public void onWindowFocusChanged(boolean hasFocus) { + super.onWindowFocusChanged(hasFocus); + } + + private void initTopBar() { + mTopBar.setTitle("炒锅运维调试"); + mTopBar.addLeftImageButton(R.mipmap.fanhui, R.id.topbar).setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + finish(); + } + }); + + quanxianmima.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + String s = edittext_quanxian.getText().toString(); + if (s == null || s.isEmpty()) { + ToastUtils.warning("权限密码不能为空!"); + } else { + if (s.equals(ConfigName.getInstance().user.pass)) { + quanxian.setVisibility(View.GONE); + viewPager.setVisibility(View.VISIBLE); + } else { + ToastUtils.warning("权限密码不正确!"); + } + } + } + }); + } + + FragmentAdapter fragmentAdapter = null; + + /** + * viewPager里添加fragment + */ + private void initFragment() { + fragmentAdapter = new FragmentAdapter(getSupportFragmentManager()); + fragmentAdapter.addFragment(new WokSetGKCXFragment()); + fragmentAdapter.addFragment(new WokSetTLZZFragment()); + viewPager.setAdapter(fragmentAdapter); + } + //-------------------------配置viewPager与fragment关联----------------------------// + /** + * 配置bottom底部菜单栏监听器,手指点击底部菜单监听 + */ + private BottomNavigationView.OnNavigationItemSelectedListener mOnNavigationItemSelectedListener + = new BottomNavigationView.OnNavigationItemSelectedListener() { + + @Override + public boolean onNavigationItemSelected(@NonNull MenuItem item) { + switch (item.getItemId()) { + case R.id.bottom_device_1: + viewPager.setCurrentItem(0); + return true; + case R.id.bottom_device_2: + viewPager.setCurrentItem(1); + return true; + } + return false; + } + }; + + + /** + * 配置ViewPager监听器,手指滑动监听 + */ + private ViewPager.OnPageChangeListener pageChangeListener = new ViewPager.OnPageChangeListener() { + @Override + public void onPageScrolled(int position, float positionOffset, int positionOffsetPixels) { + MenuItem menuItem = bottomNavigationView.getMenu().getItem(position); + } + + @Override + public void onPageSelected(int position) { + menuItem = bottomNavigationView.getMenu().getItem(position); + menuItem.setChecked(true); + } + + @Override + public void onPageScrollStateChanged(int state) { + + } + }; + + @Override + public void onDestroy() { + super.onDestroy(); + } + + @Override + protected boolean canDragBack() { + return false; + } +} \ No newline at end of file diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/WokSetGKCXFragment.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/WokSetGKCXFragment.java new file mode 100644 index 00000000..ac37916b --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/WokSetGKCXFragment.java @@ -0,0 +1,394 @@ +package com.bonait.bnframework.modules.home.fragment.from.fragment; + +import static com.bonait.bnframework.MainApplication.getContext; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; + +import android.content.Context; +import android.content.Intent; +import android.os.Bundle; +import android.os.Handler; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.MotionEvent; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; +import android.widget.RelativeLayout; +import android.widget.TextView; + +import com.bonait.bnframework.R; +import com.bonait.bnframework.business.ExecuteTheRecipe; +import com.bonait.bnframework.common.base.BaseFragment; +import com.bonait.bnframework.common.constant.MessageName; +import com.bonait.bnframework.common.db.QueryDB; +import com.bonait.bnframework.common.db.mode.BPA_GOODS; +import com.bonait.bnframework.common.db.mode.BPA_GOODSRECIPE; +import com.bonait.bnframework.common.helper.I.IWriteCallBack; +import com.bonait.bnframework.common.message.MessageManager; +import com.bonait.bnframework.common.utils.AlertDialogUtils; +import com.bonait.bnframework.common.utils.ToastUtils; +import com.bonait.bnframework.modules.home.fragment.from.DiyMemoryActivity; +import com.bonait.bnframework.modules.home.fragment.from.ImageChooseActivity; +import com.orhanobut.logger.Logger; +import com.qmuiteam.qmui.widget.QMUIViewPager; +import com.qmuiteam.qmui.widget.dialog.QMUIDialog; +import com.qmuiteam.qmui.widget.dialog.QMUIDialogAction; + +import java.util.ArrayList; + +import butterknife.BindView; +import butterknife.ButterKnife; +import butterknife.OnClick; + +public class WokSetGKCXFragment extends BaseFragment { + //region 变量 + @BindView(R.id.edit_ydw1) + EditText edit_ydw1;//原点下限 + + @BindView(R.id.edit_ydw2) + EditText edit_ydw2;//原点上限 + + @BindView(R.id.edit_xgw1) + EditText edit_xgw1;//洗锅位下限 + + @BindView(R.id.edit_xgw2) + EditText edit_xgw2;//洗锅位上限 + + @BindView(R.id.edit_ccw1) + EditText edit_ccw1;//出餐位置下限 + + @BindView(R.id.edit_ccw2) + EditText edit_ccw2;//出餐位置上限 + + @BindView(R.id.edit_ctl1) + EditText edit_ctl1;//抽料位置下限 + + @BindView(R.id.edit_ctl2) + EditText edit_ctl2;//抽料位置上限 + + @BindView(R.id.edit_czw11) + EditText edit_czw11;//1#炒制位下限 + + @BindView(R.id.edit_czw12) + EditText edit_czw12;//1#炒制位上限 + + @BindView(R.id.edit_czw21) + EditText edit_czw21;//2#炒制位下限 + + @BindView(R.id.edit_czw22) + EditText edit_czw22;//2#炒制位上限 + + @BindView(R.id.edit_czw31) + EditText edit_czw31;//3#炒制位下限 + + @BindView(R.id.edit_czw32) + EditText edit_czw32;//3#炒制位上限 + + @BindView(R.id.edit_gzfw1) + EditText edit_gzfw1;//工作范围下限 + + @BindView(R.id.edit_gzfw2) + EditText edit_gzfw2;//工作范围上限 + + @BindView(R.id.chaoguo_weizhi) + TextView chaoguo_weizhi;//炒锅当前位置 + + @BindView(R.id.ydw_status) + RelativeLayout ydw_status; + @BindView(R.id.xgw_status) + RelativeLayout xgw_status; + @BindView(R.id.ccw_status) + RelativeLayout ccw_status; + @BindView(R.id.ctl_status) + RelativeLayout ctl_status; + @BindView(R.id.czw1_status) + RelativeLayout czw1_status; + @BindView(R.id.czw2_status) + RelativeLayout czw2_status; + @BindView(R.id.czw3_status) + RelativeLayout czw3_status; + + @BindView(R.id.gkzx_button) + Button gkzx_button; + + @BindView(R.id.gkfx_button) + Button gkfx_button; + //endregion + + //region 界面 + private Context context; + + @Override + protected View onCreateView() { + View root = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_wok_set_gkcx, null); + ButterKnife.bind(this, root); + return root; + } + + @Override + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + Logger.d("我的fragment创建"); + context = getContext(); + Init(); + RefreshThread(); + } + //endregion + + //region 函数 + + /** + * 初始化 + */ + public void Init() { + new Thread(new Runnable() { + @Override + public void run() { + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + SetShowValue("原点位置",edit_ydw1,edit_ydw2); + SetShowValue("洗锅位置",edit_xgw1,edit_xgw2); + SetShowValue("倒菜位置",edit_ccw1,edit_ccw2); + SetShowValue("抽调料位置",edit_ctl1,edit_ctl2); + SetShowValue("1#炒制位置",edit_czw11,edit_czw11); + SetShowValue("2#炒制位置",edit_czw21,edit_czw21); + SetShowValue("3#炒制位置",edit_czw31,edit_czw31); + SetShowValue("炒锅工作范围",edit_gzfw1,edit_gzfw2); + } + }); + } + }).start(); + + gkzx_button.setOnTouchListener(new View.OnTouchListener() { + @Override + public boolean onTouch(View view, MotionEvent motionEvent) { + if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { + Log.e("鼠标", "按下: "); + ExecuteTheRecipe.WritePLC("转动速度", 50, null); + ExecuteTheRecipe.WritePLC("翻转正转", true, null); + } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) { + Log.e("鼠标", "松开: "); + ExecuteTheRecipe.WritePLC("翻转正转", false, null); + } + return false; + } + }); + + gkfx_button.setOnTouchListener(new View.OnTouchListener() { + @Override + public boolean onTouch(View view, MotionEvent motionEvent) { + if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { + Log.e("鼠标", "按下: "); + ExecuteTheRecipe.WritePLC("转动速度", 50,null); + ExecuteTheRecipe.WritePLC("翻转反转", true, null); + } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) { + Log.e("鼠标", "松开: "); + ExecuteTheRecipe.WritePLC("翻转反转", false, null); + } + return false; + } + }); + } + + /** + * 刷新UI线程 + */ + public void RefreshThread() + { + new Thread(new Runnable() { + @Override + public void run() { + try { + while (true) + { + Object o0=ExecuteTheRecipe.ReadPLC("编码器当前位值"); + Object o1=ExecuteTheRecipe.ReadPLC("原点位反馈"); + Object o2=ExecuteTheRecipe.ReadPLC("清洗位反馈"); + Object o3=ExecuteTheRecipe.ReadPLC("倒菜位反馈"); + Object o4=ExecuteTheRecipe.ReadPLC("抽料位反馈"); + Object o5=ExecuteTheRecipe.ReadPLC("炒菜位1反馈"); + Object o6=ExecuteTheRecipe.ReadPLC("炒菜位2反馈"); + Object o7=ExecuteTheRecipe.ReadPLC("炒菜位3反馈"); + + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + if(o0!=null) { chaoguo_weizhi.setText(o0 + ""); } + else {chaoguo_weizhi.setText("未知");} + + if(o1!=null) { ydw_status.setBackgroundResource((boolean)o1?R.mipmap.status_z:R.mipmap.status_y); } + else {ydw_status.setBackgroundResource(R.mipmap.status_y); } + + if(o2!=null) { xgw_status.setBackgroundResource((boolean)o1?R.mipmap.status_z:R.mipmap.status_y); } + else {xgw_status.setBackgroundResource(R.mipmap.status_y); } + + if(o3!=null) { ccw_status.setBackgroundResource((boolean)o1?R.mipmap.status_z:R.mipmap.status_y); } + else {ccw_status.setBackgroundResource(R.mipmap.status_y); } + + if(o4!=null) { ctl_status.setBackgroundResource((boolean)o1?R.mipmap.status_z:R.mipmap.status_y); } + else {ctl_status.setBackgroundResource(R.mipmap.status_y); } + + if(o5!=null) { czw1_status.setBackgroundResource((boolean)o1?R.mipmap.status_z:R.mipmap.status_y); } + else {czw1_status.setBackgroundResource(R.mipmap.status_y); } + + if(o6!=null) { czw2_status.setBackgroundResource((boolean)o1?R.mipmap.status_z:R.mipmap.status_y); } + else {czw2_status.setBackgroundResource(R.mipmap.status_y); } + + if(o7!=null) { czw3_status.setBackgroundResource((boolean)o1?R.mipmap.status_z:R.mipmap.status_y); } + else {czw3_status.setBackgroundResource(R.mipmap.status_y); } + } + }); + Thread.sleep(500); + } + }catch (Exception ex) + { + } + } + }).start(); + } + + /** + * 点击事件 + * + * @param view + */ + @OnClick({R.id.ydw_save, R.id.xgw_save, + R.id.ccw_save, R.id.ctl_save, + R.id.czw1_save, R.id.czw2_save, R.id.czw3_save, + R.id.gzfw_save, + + R.id.ydw_button, R.id.xgw_button, + R.id.ccw_button, R.id.ctl_button, + R.id.czw1_button, R.id.czw2_button, R.id.czw3_button, + }) + public void onViewClicked(View view) { + switch (view.getId()) { + case R.id.ydw_save: + SaveValue("原点位置",edit_ydw1,edit_ydw2); + break; + case R.id.xgw_save: + SaveValue("洗锅位置",edit_xgw1,edit_xgw2); + break; + case R.id.ccw_save: + SaveValue("倒菜位置",edit_ccw1,edit_ccw2); + break; + case R.id.ctl_save: + SaveValue("抽调料位置",edit_ctl1,edit_ctl2); + break; + case R.id.czw1_save: + SaveValue("1#炒制位置",edit_czw11,edit_czw11); + break; + case R.id.czw2_save: + SaveValue("2#炒制位置",edit_czw21,edit_czw21); + break; + case R.id.czw3_save: + SaveValue("3#炒制位置",edit_czw31,edit_czw31); + break; + case R.id.gzfw_save: + SaveValue("炒锅工作范围",edit_gzfw1,edit_gzfw2); + break; + + case R.id.ydw_button: + ButtomZhiWeiZhi("原点位"); + break; + case R.id.xgw_button: + ButtomZhiWeiZhi("清洗位"); + break; + case R.id.ccw_button: + ButtomZhiWeiZhi("倒菜位"); + break; + case R.id.ctl_button: + ButtomZhiWeiZhi("抽料位"); + break; + case R.id.czw1_button: + ButtomZhiWeiZhi("炒菜位1"); + break; + case R.id.czw2_button: + ButtomZhiWeiZhi("炒菜位2"); + break; + case R.id.czw3_button: + ButtomZhiWeiZhi("炒菜位3"); + break; + } + } + //endregion + + //region 私有函数 + + /** + * 根据监听设置值 + * @param name + * @param edit1 + * @param edit2 + */ + private void SetShowValue(String name,EditText edit1,EditText edit2) + { + Object val1= ExecuteTheRecipe.ListeningValue.get(name+"下限"); + Object val2= ExecuteTheRecipe.ListeningValue.get(name+"上限"); + if(val1!=null) + { + String str=String.valueOf(val1); + edit1.setText(str.toCharArray(), 0, str.length()); + } + + if(val2!=null) + { + String str=String.valueOf(val2); + edit2.setText(str.toCharArray(), 0, str.length()); + } + } + + + /** + * 写入设置值 + * @param name + * @param edit1 + * @param edit2 + */ + private void SaveValue(String name,EditText edit1,EditText edit2) { + String val1 = edit1.getText().toString(); + String val2 = edit2.getText().toString(); + if (val1.isEmpty()) { + ToastUtils.warning(name + "下限不能为空!"); + return; + } + if (val2.isEmpty()) { + ToastUtils.warning(name + "上限不能为空!"); + return; + } + int va1 = 0; + int va2 = 0; + try { + va1=Integer.parseInt(val1); + va2=Integer.parseInt(val2); + } catch (Exception ex) + { + ToastUtils.warning(name + "异常了,"+ex.getMessage()); + return; + } + + ExecuteTheRecipe.WritePLC(name+"下限",va1,null); + ExecuteTheRecipe.WritePLC(name+"上限",va2,null); + ToastUtils.info(name + "保存成功!"); + } + + /** + * 执行去某个位置 + */ + private void ButtomZhiWeiZhi(String name) + { + ExecuteTheRecipe.WritePLC(name,true,null); + new Handler().postDelayed(new Runnable() { + @Override + public void run() { + ExecuteTheRecipe.WritePLC(name, false, null); + } + }, 500); + ToastUtils.info(name+"执行成功!"); + } + //endregion +} \ No newline at end of file diff --git a/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/WokSetTLZZFragment.java b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/WokSetTLZZFragment.java new file mode 100644 index 00000000..91d31677 --- /dev/null +++ b/app/src/main/java/com/bonait/bnframework/modules/home/fragment/from/fragment/WokSetTLZZFragment.java @@ -0,0 +1,447 @@ +package com.bonait.bnframework.modules.home.fragment.from.fragment; + +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AppCompatActivity; + +import android.content.Context; +import android.os.Bundle; +import android.os.Handler; +import android.util.Log; +import android.view.LayoutInflater; +import android.view.MotionEvent; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; +import android.widget.TextView; + +import com.bonait.bnframework.R; +import com.bonait.bnframework.business.ExecuteTheRecipe; +import com.bonait.bnframework.common.base.BaseFragment; +import com.bonait.bnframework.common.utils.ToastUtils; +import com.orhanobut.logger.Logger; +import com.suke.widget.SwitchButton; + +import butterknife.BindView; +import butterknife.ButterKnife; +import butterknife.OnClick; + +public class WokSetTLZZFragment extends BaseFragment { + + //region 变量 + @BindView(R.id.pyz_zz) + Button pyz_zz; + + @BindView(R.id.pyz_fz) + Button pyz_fz; + + @BindView(R.id.fzz_zz) + Button fzz_zz; + + @BindView(R.id.fzz_fz) + Button fzz_fz; + + + @BindView(R.id.edit_pyz_hlsd) + EditText edit_pyz_hlsd; + + @BindView(R.id.edit_pyz_ddsd) + EditText edit_pyz_ddsd; + + @BindView(R.id.edit_pyz_zdsd) + EditText edit_pyz_zdsd; + + @BindView(R.id.edit_fzz_hlsd) + EditText edit_fzz_hlsd; + + @BindView(R.id.edit_fzz_ddsd) + EditText edit_fzz_ddsd; + + @BindView(R.id.edit_fzz_zdsd) + EditText edit_fzz_zdsd; + + @BindView(R.id.edit_pyz_dqz) + TextView edit_pyz_dqz; + @BindView(R.id.edit_pyz_wz1) + TextView edit_pyz_wz1; + @BindView(R.id.edit_pyz_wz2) + TextView edit_pyz_wz2; + @BindView(R.id.edit_pyz_wz3) + TextView edit_pyz_wz3; + @BindView(R.id.edit_pyz_wz4) + TextView edit_pyz_wz4; + + @BindView(R.id.edit_fzz_dqz) + TextView edit_fzz_dqz; + @BindView(R.id.edit_fzz_wz1) + TextView edit_fzz_wz1; + @BindView(R.id.edit_fzz_wz2) + TextView edit_fzz_wz2; + @BindView(R.id.edit_fzz_wz3) + TextView edit_fzz_wz3; + @BindView(R.id.edit_fzz_wz4) + TextView edit_fzz_wz4; + + @BindView(R.id.ctxh_button) + SwitchButton ctxh_button; + //endregion + + //region 界面 + private Context context; + + @Override + protected View onCreateView() { + View root = LayoutInflater.from(getActivity()).inflate(R.layout.fragment_wok_set_tlzz, null); + ButterKnife.bind(this, root); + return root; + } + + @Override + public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { + super.onViewCreated(view, savedInstanceState); + Logger.d("我的fragment创建"); + context = getContext(); + Init(); + RefreshThread(); + } + //endregion + + //region 公共 + + /** + * 初始化 + */ + public void Init() { + new Thread(new Runnable() { + @Override + public void run() { + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + SetShowValue("平移-回原点速度", edit_pyz_hlsd); + SetShowValue("平移-点动速度", edit_pyz_ddsd); + SetShowValue("平移-定位运行速度", edit_pyz_zdsd); + + SetShowValue("翻转-回原点速度", edit_fzz_hlsd); + SetShowValue("翻转-点动速度", edit_fzz_ddsd); + SetShowValue("翻转-定位运行速度", edit_fzz_zdsd); + } + }); + } + }).start(); + + pyz_zz.setOnTouchListener(new View.OnTouchListener() { + @Override + public boolean onTouch(View view, MotionEvent motionEvent) { + if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { + Log.e("鼠标", "按下: "); + ExecuteTheRecipe.WritePLC("平移-点动正转", true, null); + } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) { + Log.e("鼠标", "松开: "); + ExecuteTheRecipe.WritePLC("平移-点动正转", false, null); + } + return false; + } + }); + + pyz_fz.setOnTouchListener(new View.OnTouchListener() { + @Override + public boolean onTouch(View view, MotionEvent motionEvent) { + if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { + Log.e("鼠标", "按下: "); + ExecuteTheRecipe.WritePLC("平移-点动正转", true, null); + } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) { + Log.e("鼠标", "松开: "); + ExecuteTheRecipe.WritePLC("平移-点动反转", false, null); + } + return false; + } + }); + + fzz_zz.setOnTouchListener(new View.OnTouchListener() { + @Override + public boolean onTouch(View view, MotionEvent motionEvent) { + if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { + Log.e("鼠标", "按下: "); + ExecuteTheRecipe.WritePLC("翻转-点动正转", true, null); + } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) { + Log.e("鼠标", "松开: "); + ExecuteTheRecipe.WritePLC("翻转-点动正转", false, null); + } + return false; + } + }); + + fzz_fz.setOnTouchListener(new View.OnTouchListener() { + @Override + public boolean onTouch(View view, MotionEvent motionEvent) { + if (motionEvent.getAction() == MotionEvent.ACTION_DOWN) { + Log.e("鼠标", "按下: "); + ExecuteTheRecipe.WritePLC("翻转-点动正转", true, null); + } else if (motionEvent.getAction() == MotionEvent.ACTION_UP) { + Log.e("鼠标", "松开: "); + ExecuteTheRecipe.WritePLC("翻转-点动反转", false, null); + } + return false; + } + }); + + ctxh_button.setOnCheckedChangeListener(new SwitchButton.OnCheckedChangeListener() { + @Override + public void onCheckedChanged(SwitchButton view, boolean isChecked) { + boolean ischick = ctxh_button.isChecked(); + ExecuteTheRecipe.WritePLC("磁铁吸合", ischick, null); + ToastUtils.info("磁铁吸合!状态:" + (ischick ? "打开" : "关闭")); + } + }); + } + + /** + * 刷新UI线程 + */ + public void RefreshThread() { + new Thread(new Runnable() { + @Override + public void run() { + try { + while (true) { + Object o0 = ExecuteTheRecipe.ReadPLC("平移-伺服当前值"); + Object o1 = ExecuteTheRecipe.ReadPLC("平移-1号位置值"); + Object o2 = ExecuteTheRecipe.ReadPLC("平移-2号位置值"); + Object o3 = ExecuteTheRecipe.ReadPLC("平移-3号位置值"); + Object o4 = ExecuteTheRecipe.ReadPLC("平移-4号位置值"); + + Object m0 = ExecuteTheRecipe.ReadPLC("翻转-伺服当前值"); + Object m1 = ExecuteTheRecipe.ReadPLC("翻转-1号位置值"); + Object m2 = ExecuteTheRecipe.ReadPLC("翻转-2号位置值"); + Object m3 = ExecuteTheRecipe.ReadPLC("翻转-3号位置值"); + Object m4 = ExecuteTheRecipe.ReadPLC("翻转-4号位置值"); + + getActivity().runOnUiThread(new Runnable() { + @Override + public void run() { + if (o0 != null) { + edit_pyz_dqz.setText(o0 + ""); + } else { + edit_pyz_dqz.setText("未知"); + } + if (o1 != null) { + edit_pyz_wz1.setText(o1 + ""); + } else { + edit_pyz_wz1.setText("未知"); + } + if (o2 != null) { + edit_pyz_wz2.setText(o2 + ""); + } else { + edit_pyz_wz2.setText("未知"); + } + if (o3 != null) { + edit_pyz_wz3.setText(o3 + ""); + } else { + edit_pyz_wz3.setText("未知"); + } + if (o4 != null) { + edit_pyz_wz4.setText(o4 + ""); + } else { + edit_pyz_wz4.setText("未知"); + } + + if (m0 != null) { + edit_fzz_dqz.setText(m0 + ""); + } else { + edit_fzz_dqz.setText("未知"); + } + if (m1 != null) { + edit_fzz_wz1.setText(m1 + ""); + } else { + edit_fzz_wz1.setText("未知"); + } + if (m2 != null) { + edit_fzz_wz2.setText(m2 + ""); + } else { + edit_fzz_wz2.setText("未知"); + } + if (m3 != null) { + edit_fzz_wz3.setText(m3 + ""); + } else { + edit_fzz_wz3.setText("未知"); + } + if (m4 != null) { + edit_fzz_wz4.setText(m4 + ""); + } else { + edit_fzz_wz4.setText("未知"); + } + } + }); + Thread.sleep(500); + } + } catch (Exception ex) { + } + } + }).start(); + } + + /** + * 点击事件 + * + * @param view + */ + @OnClick({ + R.id.pyz_hl, + R.id.pyz_wzsz1, R.id.pyz_wzsz2, R.id.pyz_wzsz3, R.id.pyz_wzsz4, + R.id.pyz_qu1, R.id.pyz_qu2, R.id.pyz_qu3, R.id.pyz_qu4, + + R.id.fzz_hl, + R.id.fzz_wzsz1, R.id.fzz_wzsz2, R.id.fzz_wzsz3, R.id.fzz_wzsz4, + R.id.fzz_qu1, R.id.fzz_qu2, R.id.fzz_qu3, R.id.fzz_qu4, + + R.id.dcqd_button, + + R.id.pyz_savevalue, R.id.fzz_savevalue + }) + public void onViewClicked(View view) { + switch (view.getId()) { + case R.id.pyz_hl: + ButtomZhiWeiZhi("平移-回原点"); + break; + case R.id.pyz_wzsz1: + ButtomZhiWeiZhi("平移-1#位置设定"); + break; + case R.id.pyz_wzsz2: + ButtomZhiWeiZhi("平移-2#位置设定"); + break; + case R.id.pyz_wzsz3: + ButtomZhiWeiZhi("平移-3#位置设定"); + break; + case R.id.pyz_wzsz4: + ButtomZhiWeiZhi("平移-4#位置设定"); + break; + case R.id.pyz_qu1: + ButtomZhiWeiZhi("平移-去1号位"); + break; + case R.id.pyz_qu2: + ButtomZhiWeiZhi("平移-去2号位"); + break; + case R.id.pyz_qu3: + ButtomZhiWeiZhi("平移-去3号位"); + break; + case R.id.pyz_qu4: + ButtomZhiWeiZhi("平移-去4号位"); + break; + + case R.id.fzz_hl: + ButtomZhiWeiZhi("翻转-回原点"); + break; + case R.id.fzz_wzsz1: + ButtomZhiWeiZhi("翻转-1#位置设定"); + break; + case R.id.fzz_wzsz2: + ButtomZhiWeiZhi("翻转-2#位置设定"); + break; + case R.id.fzz_wzsz3: + ButtomZhiWeiZhi("翻转-3#位置设定"); + break; + case R.id.fzz_wzsz4: + ButtomZhiWeiZhi("翻转-4#位置设定"); + break; + case R.id.fzz_qu1: + ButtomZhiWeiZhi("翻转-去1号位"); + break; + case R.id.fzz_qu2: + ButtomZhiWeiZhi("翻转-去2号位"); + break; + case R.id.fzz_qu3: + ButtomZhiWeiZhi("翻转-去3号位"); + break; + case R.id.fzz_qu4: + ButtomZhiWeiZhi("翻转-去4号位"); + break; + case R.id.dcqd_button: + ButtomZhiWeiZhi("倒菜启动"); + break; + + case R.id.pyz_savevalue: + SaveValue("平移", edit_pyz_hlsd, edit_pyz_ddsd, edit_pyz_zdsd); + break; + case R.id.fzz_savevalue: + SaveValue("翻转", edit_fzz_hlsd, edit_fzz_ddsd, edit_fzz_zdsd); + break; + } + } + //endregion + + //region 私有 + + /** + * 写入设置值 + * + * @param name + * @param edit1 + * @param edit2 + */ + private void SaveValue(String name, EditText edit1, EditText edit2, EditText edit3) { + String val1 = edit1.getText().toString(); + String val2 = edit2.getText().toString(); + String val3 = edit3.getText().toString(); + + if (val1.isEmpty()) { + ToastUtils.warning(name + "回零速度不能为空!"); + return; + } + if (val2.isEmpty()) { + ToastUtils.warning(name + "点动速度不能为空!"); + return; + } + if (val3.isEmpty()) { + ToastUtils.warning(name + "自动速度不能为空!"); + return; + } + int va1 = 0; + int va2 = 0; + int va3 = 0; + + try { + va1 = Integer.parseInt(val1); + va2 = Integer.parseInt(val2); + va3 = Integer.parseInt(val3); + + } catch (Exception ex) { + ToastUtils.warning(name + "异常了," + ex.getMessage()); + return; + } + + ExecuteTheRecipe.WritePLC(name + "-回原点速度", va1, null); + ExecuteTheRecipe.WritePLC(name + "-点动速度", va2, null); + ExecuteTheRecipe.WritePLC(name + "-定位运行速度", va3, null); + ToastUtils.info(name + "保存成功!"); + } + + /** + * 根据监听设置值 + * + * @param name + * @param edit1 + */ + private void SetShowValue(String name, EditText edit1) { + Object val1 = ExecuteTheRecipe.ListeningValue.get(name); + if (val1 != null) { + String str = String.valueOf(val1); + edit1.setText(str.toCharArray(), 0, str.length()); + } + } + + /** + * 执行去某个位置 + */ + private void ButtomZhiWeiZhi(String name) { + ExecuteTheRecipe.WritePLC(name, true, null); + new Handler().postDelayed(new Runnable() { + @Override + public void run() { + ExecuteTheRecipe.WritePLC(name, false, null); + } + }, 500); + ToastUtils.info(name + "执行成功!"); + } + //endregion +} \ No newline at end of file diff --git a/app/src/main/java/com/bonait/bnframework/modules/mine/fragment/MyFragment.java b/app/src/main/java/com/bonait/bnframework/modules/mine/fragment/MyFragment.java index c45bce8a..a326e912 100644 --- a/app/src/main/java/com/bonait/bnframework/modules/mine/fragment/MyFragment.java +++ b/app/src/main/java/com/bonait/bnframework/modules/mine/fragment/MyFragment.java @@ -30,6 +30,7 @@ import com.bonait.bnframework.common.utils.AlertDialogUtils; import com.bonait.bnframework.common.utils.ToastUtils; import com.bonait.bnframework.common.utils.UpdateAppUtils; import com.bonait.bnframework.manager.ActivityLifecycleManager; +import com.bonait.bnframework.modules.home.fragment.from.WokSetActivity; import com.bonait.bnframework.modules.mine.fragment.from.NoticeActivity; import com.bonait.bnframework.modules.welcome.activity.LoginActivity; import com.orhanobut.logger.Logger; @@ -67,6 +68,9 @@ public class MyFragment extends BaseFragment { @BindView(R.id.stv_user) SuperTextView stv_user; + @BindView(R.id.stv_devicesz) + SuperTextView stv_devicesz; + @BindView(R.id.stv_announcement) SuperTextView stvAnnouncement; @@ -167,6 +171,18 @@ public class MyFragment extends BaseFragment { } }); + /** + * 炒锅设置 + */ + stv_devicesz.setOnSuperTextViewClickListener(new SuperTextView.OnSuperTextViewClickListener() { + @Override + public void onClickListener(SuperTextView superTextView) { + Intent intent = new Intent(context, WokSetActivity.class); + intent.setFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); + startActivity(intent); + } + }); + /** * 用户名点击 */ diff --git a/app/src/main/res/drawable-hdpi/device_sz.png b/app/src/main/res/drawable-hdpi/device_sz.png new file mode 100644 index 0000000000000000000000000000000000000000..3b09d1d6f4c6440ef311d2163bcb1c37b446ea79 GIT binary patch literal 1161 zcmV;41a|w0P)Px(LrFwIR9HvNm``lmR2;{@&vu%BP1|*AyRDt#F6kH-q#>cLAP}cSL)y3@f#3q$ z4roZ_vI`p8kl+9Zia-c~;J`RcTqd@|)SM7#v;&Dr?7*ZZYsyO3HtX6nO`ImS-}KzL zixd0V*;Xm`+eSfzkkmJZ8pf`@Vq=T6Yy)=kU*sf)1wo$upx?bzYY(VA60M5 zK#AM4$Dq?=pm-4k2W<^g+ycSx5XhC({^*rf;5-8*)7jIMVhjYaRt$h5LkPwv;__Es z=D7kTX6_t@ri}wQ;zc1xW(uM>mKxr7ou`Kjl*nY?2F3S}31Xd2@J=cw|KOz45h$6N z8KabZ{zPGF$_SzFPsE1Vt~U)^pl#WiM$-;E)dW=YnWRz+|z6g0ADo z=pZBzyfHh6h#+7z970joajjT#Qw0LNSDz9rK#A#W+AYt#)!TzNcXS(ua;l0?mzJ@= z!-tYiv7o9r)4vmal4N}UX(f*f_gDE)6q(eB95;owfNB}|vfGmCflS$xcjl4TH2f^@ zvrPZ9q~Pq`B{!9TK#rRk{UJ~~`z?TzZnKYebz-baN@sttn0cLwWx?R$hrh$hmz@ZoI;xB&5Zdw@O(IgL7#*kQN*EO zU`w1CXM?2xbKFqMSk*NAUsa7=%4}4)USi5Jag&;em`F6>f}1P57}hc9x=NJctwFyQ9`v2Z^#zlg7g_81X%aW#+M)*Wk`O=8?^-fc^VSuXx6 zDY%p`;1dTYZzN=8-3D$L3gE*{<9ym+@REhe@QSbIV{k%rOr+6<4OoOZ#D0T$7nu17so=Z36vxG3SyHIqgTym$(huOPwKnFwkch znJg+ew_vU2=XUpFG#oU(GZ>EFFcE%(W&mwod$=tuD-kRK&R132)$jF5M#3~pisKe} zX<-eh?YRClQh9Ci&3SEg4Kks&Wv3qXqPPXsPFLyrV{e + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/drawable/button3.xml b/app/src/main/res/drawable/button3.xml new file mode 100644 index 00000000..6b18fda8 --- /dev/null +++ b/app/src/main/res/drawable/button3.xml @@ -0,0 +1,30 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/activity_wok_set.xml b/app/src/main/res/layout/activity_wok_set.xml new file mode 100644 index 00000000..8e49a665 --- /dev/null +++ b/app/src/main/res/layout/activity_wok_set.xml @@ -0,0 +1,91 @@ + + + + + + + + + + + +