From 0112914e9e7a295fd3d626ed27dd1baee5d3b75e Mon Sep 17 00:00:00 2001 From: fyf Date: Tue, 18 Jul 2023 15:17:36 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=E8=B0=83=E5=91=B3=E5=90=A7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/misc.xml | 2 +- app/build.gradle | 2 + .../com/example/bpa/Model/Res_PLCADDRESS.java | 16 +++ .../com/example/bpa/config/ConfigName.java | 55 ++++++++ .../example/bpa/db/mode/BPA_PLCADDRESS.java | 15 +++ .../com/example/bpa/service/DeviceData.java | 83 ++++++++++++ .../control/AutoNextLineLinearLayout.java | 107 +++++++++++++++ .../bpa/view/control/sdkz_control.java | 80 ++++++++++++ .../example/bpa/view/control/tab_control.java | 31 +++++ .../bpa/view/fragment/HomeFragment.java | 123 +++++++++++++++++- .../bpa/view/from/sdkz_new_Activity.java | 63 ++++++++- .../res/layout/Dialog/layout/zdkz_dialog.xml | 96 ++++++++++++++ .../res/layout/from/layout/activity_dzcjy.xml | 123 +++++++++--------- .../res/layout/from/layout/activity_sdkz.xml | 1 + .../layout/from/layout/activity_sdkz_new.xml | 10 ++ .../res/layout/from/layout/fragment_home.xml | 11 ++ .../main/res/layout/item/layout/tab_item.xml | 25 ++++ .../layout/item/layout/wrapanl_sdkz_item.xml | 11 ++ app/src/main/res/mipmap-xhdpi/zdkz.png | Bin 0 -> 3798 bytes app/src/main/res/mipmap-xhdpi/zdkz1.png | Bin 0 -> 4165 bytes app/src/main/res/mipmap-xhdpi/zdkz2.png | Bin 0 -> 3562 bytes 21 files changed, 786 insertions(+), 68 deletions(-) create mode 100644 app/src/main/java/com/example/bpa/Model/Res_PLCADDRESS.java create mode 100644 app/src/main/java/com/example/bpa/db/mode/BPA_PLCADDRESS.java create mode 100644 app/src/main/java/com/example/bpa/view/control/AutoNextLineLinearLayout.java create mode 100644 app/src/main/java/com/example/bpa/view/control/sdkz_control.java create mode 100644 app/src/main/java/com/example/bpa/view/control/tab_control.java create mode 100644 app/src/main/res/layout/Dialog/layout/zdkz_dialog.xml create mode 100644 app/src/main/res/layout/item/layout/tab_item.xml create mode 100644 app/src/main/res/layout/item/layout/wrapanl_sdkz_item.xml create mode 100644 app/src/main/res/mipmap-xhdpi/zdkz.png create mode 100644 app/src/main/res/mipmap-xhdpi/zdkz1.png create mode 100644 app/src/main/res/mipmap-xhdpi/zdkz2.png diff --git a/.idea/misc.xml b/.idea/misc.xml index 369983e..d4f9d85 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,7 +1,7 @@ - + diff --git a/app/build.gradle b/app/build.gradle index 3ef2ec7..9af0bcf 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -72,4 +72,6 @@ dependencies { // implementation 'androidx.appcompat:appcompat:1.3.1' // implementation 'androidx.core:core-ktx:1.6.0' // implementation 'androidx.databinding:databinding-runtime:4.3.1' + + implementation 'com.github.zcweng:switch-button:0.0.3@aar' } \ No newline at end of file diff --git a/app/src/main/java/com/example/bpa/Model/Res_PLCADDRESS.java b/app/src/main/java/com/example/bpa/Model/Res_PLCADDRESS.java new file mode 100644 index 0000000..c17972d --- /dev/null +++ b/app/src/main/java/com/example/bpa/Model/Res_PLCADDRESS.java @@ -0,0 +1,16 @@ +package com.example.bpa.Model; + +import com.example.bpa.db.mode.BPA_PLCADDRESS; + +public class Res_PLCADDRESS extends BPA_PLCADDRESS { + + public Res_PLCADDRESS( String _address,String _zd_address,String _name, int _isread, int _iswrite) + { + this.name=_name; + this.address=_address; + this.zd_address=_zd_address; + this.isread=_isread; + this.iswrite=_iswrite; + this.val=false; + } +} diff --git a/app/src/main/java/com/example/bpa/config/ConfigName.java b/app/src/main/java/com/example/bpa/config/ConfigName.java index a53bcb3..f46251e 100644 --- a/app/src/main/java/com/example/bpa/config/ConfigName.java +++ b/app/src/main/java/com/example/bpa/config/ConfigName.java @@ -3,8 +3,13 @@ package com.example.bpa.config; import android.content.Context; import android.graphics.Region; +import com.example.bpa.Model.Res_PLCADDRESS; import com.example.bpa.db.mode.BPA_USER; +import java.util.ArrayList; +import java.util.List; +import java.util.concurrent.ConcurrentHashMap; + /** * 配置文件 */ @@ -179,4 +184,54 @@ public class ConfigName { public String UpdateVersion="http://111.9.47.105:18097/api/Version/GetLatest"; //endregion + + /** + * 大炒基础PLC模型 + */ + public List PlcAddress_配料吧_手动=new ArrayList(){{ + + //硬件设备 初始化 + add(new Res_PLCADDRESS("-------------","","出料口",1,0)); + add(new Res_PLCADDRESS("M51.6","M101.6","出料口振动器",1,1)); + + add(new Res_PLCADDRESS("-------------","","酱油仓/猪油仓",1,0)); + add(new Res_PLCADDRESS("M52.7","M102.7","酱油仓控制",0,1)); + add(new Res_PLCADDRESS("M53.0","M103.0","猪油仓控制",0,1)); + add(new Res_PLCADDRESS("M51.7","M101.7","猪油仓加热",1,1)); + add(new Res_PLCADDRESS("M52.1","M102.1","猪油管道保温",1,1)); + + + add(new Res_PLCADDRESS("-------------","","外置仓",1,0)); + add(new Res_PLCADDRESS("M50.0","M100.0","外置仓控制(1)",0,1)); + add(new Res_PLCADDRESS("M50.1","M100.1","外置仓控制(2)",0,1)); + add(new Res_PLCADDRESS("M50.2","M100.2","外置仓控制(3)",0,1)); + add(new Res_PLCADDRESS("M50.3","M100.3","外置仓控制(4)",0,1)); + add(new Res_PLCADDRESS("M50.4","M100.4","外置仓控制(5)",0,1)); + add(new Res_PLCADDRESS("M50.5","M100.5","外置仓控制(6)",0,1)); + + add(new Res_PLCADDRESS("M51.0","M101.0","外置仓搅拌(1)",1,1)); + add(new Res_PLCADDRESS("M51.1","M101.1","外置仓搅拌(2)",1,1)); + add(new Res_PLCADDRESS("M51.2","M101.2","外置仓搅拌(3)",1,1)); + add(new Res_PLCADDRESS("M51.3","M101.3","外置仓搅拌(4)",1,1)); + add(new Res_PLCADDRESS("M51.4","M101.4","外置仓搅拌(5)",1,1)); + add(new Res_PLCADDRESS("M51.5","M101.5","外置仓搅拌(6)",1,1)); + + add(new Res_PLCADDRESS("-------------","","粉料仓",0,0)); + add(new Res_PLCADDRESS("M52.2","M102.2","粉料仓控制(1)",0,1)); + add(new Res_PLCADDRESS("M52.3","M102.3","粉料仓控制(1)",0,1)); + add(new Res_PLCADDRESS("M52.4","M102.4","粉料仓控制(1)",0,1)); + add(new Res_PLCADDRESS("M52.5","M102.5","粉料仓控制(1)",0,1)); + + add(new Res_PLCADDRESS("-------------","","水池",1,0)); + add(new Res_PLCADDRESS("M50.6","M100.6","水池排水阀",1,1)); + add(new Res_PLCADDRESS("M52.6","M102.6","水池进水阀",1,1)); + add(new Res_PLCADDRESS("M52.0","M102.0","水池加热",1,1)); + + + add(new Res_PLCADDRESS("-------------","","外部水箱",1,0)); + add(new Res_PLCADDRESS("M50.7","M100.7","水箱排水阀",1,1)); + add(new Res_PLCADDRESS("M53.1","M103.1","水箱加热",1,1)); + add(new Res_PLCADDRESS("M53.2","M103.2","水箱水泵",1,1)); + add(new Res_PLCADDRESS("M53.3","M103.3","外部管道加热",1,1)); + }}; } diff --git a/app/src/main/java/com/example/bpa/db/mode/BPA_PLCADDRESS.java b/app/src/main/java/com/example/bpa/db/mode/BPA_PLCADDRESS.java new file mode 100644 index 0000000..da09f59 --- /dev/null +++ b/app/src/main/java/com/example/bpa/db/mode/BPA_PLCADDRESS.java @@ -0,0 +1,15 @@ +package com.example.bpa.db.mode; + +/** + * PLC地址管理 + */ +public class BPA_PLCADDRESS extends ModeBase{ + public String name; + public String address; + public String zd_address; + public int isread;//是否可读 + public int iswrite;//是否可写 + + public int sort; + public boolean val;//地址变量 +} diff --git a/app/src/main/java/com/example/bpa/service/DeviceData.java b/app/src/main/java/com/example/bpa/service/DeviceData.java index 2030d9d..5c2aac8 100644 --- a/app/src/main/java/com/example/bpa/service/DeviceData.java +++ b/app/src/main/java/com/example/bpa/service/DeviceData.java @@ -10,6 +10,8 @@ import com.example.bpa.helper.ModbusTcpServer; import com.example.bpa.helper.RTrig; import com.example.bpa.helper.ThreadManager; +import java.util.ArrayList; +import java.util.List; import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentLinkedQueue; @@ -68,6 +70,27 @@ public class DeviceData { WeightCalibrationMode = booleans[0]; }); + //读取手动模式状态 + ModbusTcpServer.get().ReadBool("M50.0", 1, booleans -> { + WeightCalibrationMode = booleans[0]; + }); + + //读取手动模式状态 + ModbusTcpServer.get().ReadBool("M50.0", 28, booleans -> { + for (int i=0;i { + for (int i=0;i ManualValue = new ConcurrentHashMap<>(); + /** + * 自动值 + */ + ConcurrentHashMap AutomationValue = new ConcurrentHashMap<>(); + /** + * 获取手动 + * @param addr + * @return + */ + public boolean getManualValue(String addr) { + int index= GetAddressIndex(addr); + if (!ManualValue.containsKey(index)) + return false; + return ManualValue.get(index); + } + /** + * 获取自动 + * @param addr + * @return + */ + public boolean getAutomationValue(String addr) { + int index= GetAddressIndex(addr); + if (!AutomationValue.containsKey(index)) + return false; + return AutomationValue.get(index); + } + /** + * 获取地址顺序 + * @param address + * @return + */ + private int GetAddressIndex(String address) { + //put("M51.2",10);// 1*8+2 =10 + if (address == null) return -1; + if (address.length() > 0) { + address = address.trim(); + if (address.toUpperCase().contains("M") && address.length() >= 4) { + String[] res = address.substring(1).split("[.]"); + if (res != null && res.length == 2) { + try { + //int a= intNum%10;//个 + int firstAdd = Integer.parseInt(res[0])%10;//51 1 + int endAdd = Integer.parseInt(res[1]);//2 + return firstAdd*8+endAdd; + } catch (NumberFormatException e) { + return -1; + } + } + } + } + return -1; + } + //endregion + } diff --git a/app/src/main/java/com/example/bpa/view/control/AutoNextLineLinearLayout.java b/app/src/main/java/com/example/bpa/view/control/AutoNextLineLinearLayout.java new file mode 100644 index 0000000..559d257 --- /dev/null +++ b/app/src/main/java/com/example/bpa/view/control/AutoNextLineLinearLayout.java @@ -0,0 +1,107 @@ +package com.example.bpa.view.control; + +import android.content.Context; +import android.util.AttributeSet; +import android.util.Log; +import android.view.View; +import android.widget.LinearLayout; + +import java.util.Hashtable; + +/** + * 自动换行的LinearLayout + */ +public class AutoNextLineLinearLayout extends LinearLayout { + + int mLeft, mRight, mTop, mBottom; + Hashtable map = new Hashtable(); + + public AutoNextLineLinearLayout(Context context) { + super(context); + } + + public AutoNextLineLinearLayout(Context context, int horizontalSpacing, int verticalSpacing) { + super(context); + } + + public AutoNextLineLinearLayout(Context context, AttributeSet attrs) { + super(context, attrs); + } + + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + + int mWidth = MeasureSpec.getSize(widthMeasureSpec); + int mCount = getChildCount(); + int mX = 0; + int mY = 0; + mLeft = 0; + mRight = 0; + mTop = 5; + mBottom = 0; + + int j = 0; + + for (int i = 0; i < mCount; i++) { + final View child = getChildAt(i); + LinearLayout.LayoutParams params = (LinearLayout.LayoutParams) child.getLayoutParams(); + child.measure(MeasureSpec.UNSPECIFIED, MeasureSpec.UNSPECIFIED); + // 此处增加onlayout中的换行判断,用于计算所需的高度 + int childw = child.getMeasuredWidth()+params.leftMargin + params.rightMargin; + int childh = child.getMeasuredHeight(); + mX += childw; // 将每次子控件宽度进行统计叠加,如果大于设定的高度则需要换行,高度即Top坐标也需重新设置 + + Position position = new Position(); + mLeft = getPosition(i - j, i); + mRight = mLeft + child.getMeasuredWidth(); + if (mX >= mWidth) { + mX = childw; + mY += childh; + j = i; + mLeft = 0; + mRight = mLeft + child.getMeasuredWidth(); + mTop = mY + params.topMargin; + // PS:如果发现高度还是有问题就得自己再细调了 + } + mBottom = mTop + child.getMeasuredHeight()+params.bottomMargin; + mY = mTop; // 每次的高度必须记录 否则控件会叠加到一起 + position.left = mLeft; + position.top = mTop + 3; + position.right = mRight; + position.bottom = mBottom; + map.put(child, position); + } + setMeasuredDimension(mWidth, mBottom); + } + + @Override + protected LayoutParams generateDefaultLayoutParams() { + return new LayoutParams(0, 0); // default of 1px spacing + } + + @Override + protected void onLayout(boolean changed, int l, int t, int r, int b) { + + int count = getChildCount(); + for (int i = 0; i < count; i++) { + View child = getChildAt(i); + Position pos = (Position) map.get(child); + if (pos != null) { + child.layout(pos.left, pos.top, pos.right, pos.bottom); + } else { + Log.i("MyLayout", "error"); + } + } + } + + private static class Position { + int left, top, right, bottom; + } + + public int getPosition(int IndexInRow, int childIndex) { + if (IndexInRow > 0) { + return getPosition(IndexInRow - 1, childIndex - 1) + getChildAt(childIndex - 1).getMeasuredWidth()+30; + } + return getPaddingLeft(); + } +} diff --git a/app/src/main/java/com/example/bpa/view/control/sdkz_control.java b/app/src/main/java/com/example/bpa/view/control/sdkz_control.java new file mode 100644 index 0000000..5dff3c5 --- /dev/null +++ b/app/src/main/java/com/example/bpa/view/control/sdkz_control.java @@ -0,0 +1,80 @@ +package com.example.bpa.view.control; + +import android.app.Activity; +import android.content.Context; +import android.util.AttributeSet; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.LinearLayout; +import android.widget.Switch; +import android.widget.TextView; + +import androidx.annotation.Nullable; + +import com.example.bpa.Model.Res_PLCADDRESS; +import com.example.bpa.R; +import com.example.bpa.config.ConfigName; +import com.example.bpa.helper.T; +import com.example.bpa.service.DeviceData; +import com.example.bpa.view.from.lcsz_activity; + +import java.util.List; + +public class sdkz_control extends LinearLayout { + AutoNextLineLinearLayout tagLayout; + private View root; + + public sdkz_control(Context context, @Nullable AttributeSet attrs, List address, Activity activity,boolean Issd) { + super(context, attrs); + root= LayoutInflater.from(context).inflate(R.layout.wrapanl_sdkz_item, this); + tagLayout=this.findViewById(R.id.tagLayout); + Init(address,activity,Issd); + } + + /** + * + * @param plcaddresses + */ + public void Init(List plcaddresses,Activity activity,boolean Issd) + { + for (Res_PLCADDRESS item:plcaddresses) + { + Switch aSwitch=new Switch(activity); + AutoNextLineLinearLayout.LayoutParams params = new AutoNextLineLinearLayout + .LayoutParams(AutoNextLineLinearLayout.LayoutParams.WRAP_CONTENT, + AutoNextLineLinearLayout.LayoutParams.WRAP_CONTENT); + //通过这个属性可以控制 排列方式 + params.setMargins(20, 0, 0, 0); + aSwitch.setLayoutParams(params); + //aSwitch.setWidth(120); + aSwitch.setText(item.name); + if(Issd) + { + aSwitch.setTag(item.address); + aSwitch.setChecked(DeviceData.Get().getManualValue(item.address)); + }else + { + aSwitch.setTag(item.zd_address); + aSwitch.setChecked(DeviceData.Get().getAutomationValue(item.address)); + } + + aSwitch.setBackground(ConfigName.getInstance().dishesCon.getResources().getDrawable(R.drawable.qs_switch)); + aSwitch.setOnClickListener(new OnClickListener() { + @Override + public void onClick(View view) { + boolean isopen= aSwitch.isChecked(); + String addr= aSwitch.getTag().toString(); + DeviceData.Get().setSwitch(isopen,addr,null); + T.show(view.getContext(), aSwitch.getText().toString()+",地址:"+addr+".状态:"+isopen); + } + }); + tagLayout.addView(aSwitch); + } + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/bpa/view/control/tab_control.java b/app/src/main/java/com/example/bpa/view/control/tab_control.java new file mode 100644 index 0000000..7814404 --- /dev/null +++ b/app/src/main/java/com/example/bpa/view/control/tab_control.java @@ -0,0 +1,31 @@ +package com.example.bpa.view.control; + +import android.content.Context; +import android.util.AttributeSet; +import android.view.LayoutInflater; +import android.view.View; +import android.widget.Button; +import android.widget.EditText; +import android.widget.LinearLayout; +import android.widget.RelativeLayout; +import android.widget.Switch; +import android.widget.TextView; + +import androidx.annotation.Nullable; + +import com.example.bpa.R; + +/** + * Tab-控件 + */ +public class tab_control extends LinearLayout { + TextView name; + private View root; + + public tab_control(Context context, @Nullable AttributeSet attrs, String _name) { + super(context, attrs); + root= LayoutInflater.from(context).inflate(R.layout.tab_item, this); + name=this.findViewById(R.id.name); + name.setText(_name+""); + } +} \ No newline at end of file diff --git a/app/src/main/java/com/example/bpa/view/fragment/HomeFragment.java b/app/src/main/java/com/example/bpa/view/fragment/HomeFragment.java index 2bda62d..f400071 100644 --- a/app/src/main/java/com/example/bpa/view/fragment/HomeFragment.java +++ b/app/src/main/java/com/example/bpa/view/fragment/HomeFragment.java @@ -7,25 +7,46 @@ import androidx.recyclerview.widget.LinearLayoutManager; import androidx.recyclerview.widget.RecyclerView; import android.app.Activity; +import android.app.AlertDialog; import android.content.Context; import android.content.ContextWrapper; import android.os.Bundle; +import android.view.Display; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; +import android.view.Window; +import android.view.WindowManager; +import android.widget.ImageView; import android.widget.LinearLayout; +import android.widget.TextView; +import com.example.bpa.MainActivity; +import com.example.bpa.Model.Res_PLCADDRESS; import com.example.bpa.R; import com.example.bpa.config.ConfigName; import com.example.bpa.config.DataBus; import com.example.bpa.config.MessageName; +import com.example.bpa.db.QueryDB; +import com.example.bpa.db.mode.BPA_GOODS; +import com.example.bpa.db.mode.BPA_SUBORDER; +import com.example.bpa.helper.T; import com.example.bpa.helper.WrapContentLinearLayoutManager; import com.example.bpa.message.MessageLooper; import com.example.bpa.message.MessageManager; import com.example.bpa.view.adapter.maingoods_adapter; import com.example.bpa.view.adapter.makegood_adapter; +import com.example.bpa.view.adapter.order_adapter; import com.example.bpa.view.control.MyLayoutManager; +import com.example.bpa.view.control.sdkz_control; +import com.example.bpa.view.control.tab_control; import com.example.bpa.view.inteface.MyClickListener; +import com.example.bpa.view.mode.MakeStatus; +import com.example.bpa.view.mode.ResGoodsMake; +import com.example.bpa.view.mode.ResGoodsRecipe; + +import java.util.ArrayList; +import java.util.List; /** * 主页界面 @@ -42,6 +63,10 @@ public class HomeFragment extends Fragment implements View.OnClickListener, MyCl * 商品制作列表 */ RecyclerView MakeGood; + /** + * 自动控制按钮 + */ + ImageView image_zdkz; /** * 界面实例 */ @@ -67,6 +92,7 @@ public class HomeFragment extends Fragment implements View.OnClickListener, MyCl good_recyclerView = view.findViewById(R.id.good_recyclerView); makesp=view.findViewById(R.id.makesp); nohelp=view.findViewById(R.id.nohelp); + image_zdkz=view.findViewById(R.id.image_zdkz); if( ConfigName.getInstance().IsUserDownOrder) { makesp.setVisibility(View.VISIBLE); @@ -80,12 +106,14 @@ public class HomeFragment extends Fragment implements View.OnClickListener, MyCl //MakeGood=view.findViewById(R.id.MakeGood); Initdata();//初始化数据 RegisterMessage();//消息中心事件接收 + initEvents(); } /** * 初始化按钮事件 */ private void initEvents() { activity=findActivity(view.getContext()); + image_zdkz.setOnClickListener(this); } private Activity findActivity(@NonNull Context context) { if (context instanceof Activity) { @@ -134,8 +162,8 @@ public class HomeFragment extends Fragment implements View.OnClickListener, MyCl @Override public void onClick(View v) { switch (v.getId()) { - case R.id.buttonaddpf://新建配方 - + case R.id.image_zdkz://image + ShowDialog(); break; } } @@ -153,6 +181,97 @@ public class HomeFragment extends Fragment implements View.OnClickListener, MyCl } } + AlertDialog alg = null; + /** + * 显示自动控制 + */ + public void ShowDialog() + { + try { + if (alg == null) { + alg = new AlertDialog.Builder(this.getContext()).create(); + if (!alg.isShowing()) + alg.show(); + Window win = alg.getWindow(); + win.setContentView(R.layout.zdkz_dialog); + + WindowManager m = this.activity.getWindowManager(); + Display d = m.getDefaultDisplay(); //为获取屏幕宽、高 + + android.view.WindowManager.LayoutParams p = win.getAttributes(); //获取对话框当前的参数值 + p.height = (int) (d.getHeight() * 1); //高度设置为屏幕的0.3 + p.width = (int) (d.getWidth() * 1); //宽度设置为屏幕的0.5 + win.setAttributes(p); //设置生效 + + ImageView gongneng_fanhui = win.findViewById(R.id.gongneng_fanhui); + TextView gongneng_title = win.findViewById(R.id.gongneng_title); + LinearLayout sdkz_linrarlaout = win.findViewById(R.id.sdkz_linrarlaout); + gongneng_title.setText("硬件控制"); + + new Thread(new Runnable() { + @Override + public void run() { + try { + activity.runOnUiThread(new Runnable() { + @Override + public void run() { + try { + + List plcaddresses=new ArrayList<>(); + for (Res_PLCADDRESS item : ConfigName.getInstance().PlcAddress_配料吧_手动) { + if(item.isread==1) + { + if(item.address.equals("-------------"))//这是标题 + { + if(plcaddresses.size()>0) + { + sdkz_control sdkz = new sdkz_control(getContext(), null, plcaddresses,activity,false); + sdkz_linrarlaout.addView(sdkz); + } + plcaddresses=new ArrayList<>(); + tab_control tab = new tab_control(getContext(), null, item.name); + sdkz_linrarlaout.addView(tab); + }else + { + plcaddresses.add(item); + } + } + } + if(plcaddresses.size()>0) + { + sdkz_control sdkz = new sdkz_control(getContext(), null, plcaddresses,activity,false); + sdkz_linrarlaout.addView(sdkz); + } + } catch (Exception e) { + + } + } + }); + } catch (Exception e) { + + } + } + }).start(); + gongneng_fanhui.setOnClickListener(new View.OnClickListener() { + @Override + public void onClick(View view) { + alg.dismiss(); + } + }); + }else + { + if (!alg.isShowing()) + alg.show(); + else + { + alg.dismiss(); + alg = null; + } + } + + } catch (Exception ex) { + } + } //endregion //region 接收事件 diff --git a/app/src/main/java/com/example/bpa/view/from/sdkz_new_Activity.java b/app/src/main/java/com/example/bpa/view/from/sdkz_new_Activity.java index 72a2b4c..138c9f5 100644 --- a/app/src/main/java/com/example/bpa/view/from/sdkz_new_Activity.java +++ b/app/src/main/java/com/example/bpa/view/from/sdkz_new_Activity.java @@ -2,19 +2,26 @@ package com.example.bpa.view.from; import androidx.appcompat.app.AppCompatActivity; +import android.app.Activity; +import android.content.Context; import android.os.Bundle; import android.view.View; import android.view.Window; import android.view.WindowManager; import android.widget.CompoundButton; import android.widget.ImageView; +import android.widget.LinearLayout; import android.widget.Switch; import android.widget.TextView; import com.example.bpa.Model.IWriteCallBack; +import com.example.bpa.Model.Res_PLCADDRESS; import com.example.bpa.R; +import com.example.bpa.config.ConfigName; import com.example.bpa.helper.T; import com.example.bpa.service.DeviceData; +import com.example.bpa.view.control.sdkz_control; +import com.example.bpa.view.control.tab_control; import java.util.ArrayList; import java.util.Arrays; @@ -31,6 +38,13 @@ public class sdkz_new_Activity extends AppCompatActivity implements View.OnClick * 标题设置 */ TextView gongneng_title; + + /** + * + */ + LinearLayout sdkz_linrarlaout; + Context context; + Activity activity; //endregion //region 私有函数 @@ -40,6 +54,8 @@ public class sdkz_new_Activity extends AppCompatActivity implements View.OnClick this.getWindow().setFlags(WindowManager.LayoutParams.FLAG_FULLSCREEN, WindowManager.LayoutParams.FLAG_FULLSCREEN); super.onCreate(savedInstanceState); setContentView(R.layout.activity_sdkz_new); + context=this.getBaseContext(); + activity=this; Init(); initEvents(); } @@ -65,7 +81,7 @@ public class sdkz_new_Activity extends AppCompatActivity implements View.OnClick private void Init(){ gongneng_fanhui = this.findViewById(R.id.gongneng_fanhui); gongneng_title = this.findViewById(R.id.gongneng_title); - + sdkz_linrarlaout= this.findViewById(R.id.sdkz_linrarlaout); //通过Activity.getIntent()获取当前页面接收到的Intent。 getXxxExtra方法获取Intent传递过来的数据 String msg = getIntent().getStringExtra("data"); gongneng_title.setText(msg); @@ -80,6 +96,7 @@ public class sdkz_new_Activity extends AppCompatActivity implements View.OnClick private void initEvents() { gongneng_fanhui.setOnClickListener(this); //switch + } /** @@ -87,9 +104,49 @@ public class sdkz_new_Activity extends AppCompatActivity implements View.OnClick */ public void Initdata() { try { - - //设置手动模式 DeviceData.Get().setHandOrAutoSwitch(false, null); + + new Thread(new Runnable() { + @Override + public void run() { + try { + runOnUiThread(new Runnable() { + @Override + public void run() { + try { + + List plcaddresses=new ArrayList<>(); + for (Res_PLCADDRESS item : ConfigName.getInstance().PlcAddress_配料吧_手动) { + if(item.address.equals("-------------"))//这是标题 + { + if(plcaddresses.size()>0) + { + sdkz_control sdkz = new sdkz_control(context, null, plcaddresses,activity,true); + sdkz_linrarlaout.addView(sdkz); + } + plcaddresses=new ArrayList<>(); + tab_control tab = new tab_control(context, null, item.name); + sdkz_linrarlaout.addView(tab); + }else + { + plcaddresses.add(item); + } + } + if(plcaddresses.size()>0) + { + sdkz_control sdkz = new sdkz_control(context, null, plcaddresses,activity,true); + sdkz_linrarlaout.addView(sdkz); + } + } catch (Exception e) { + + } + } + }); + } catch (Exception e) { + + } + } + }).start(); } catch (Exception e) { } diff --git a/app/src/main/res/layout/Dialog/layout/zdkz_dialog.xml b/app/src/main/res/layout/Dialog/layout/zdkz_dialog.xml new file mode 100644 index 0000000..8135769 --- /dev/null +++ b/app/src/main/res/layout/Dialog/layout/zdkz_dialog.xml @@ -0,0 +1,96 @@ + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/app/src/main/res/layout/from/layout/activity_dzcjy.xml b/app/src/main/res/layout/from/layout/activity_dzcjy.xml index 0038794..1696c2a 100644 --- a/app/src/main/res/layout/from/layout/activity_dzcjy.xml +++ b/app/src/main/res/layout/from/layout/activity_dzcjy.xml @@ -83,7 +83,6 @@ - - - - - -