@@ -1,7 +1,7 @@ | |||
<?xml version="1.0" encoding="UTF-8"?> | |||
<project version="4"> | |||
<component name="ExternalStorageConfigurationManager" enabled="true" /> | |||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" project-jdk-name="JDK" project-jdk-type="JavaSDK"> | |||
<component name="ProjectRootManager" version="2" languageLevel="JDK_11" default="true" project-jdk-name="JDK" project-jdk-type="JavaSDK"> | |||
<output url="file://$PROJECT_DIR$/build/classes" /> | |||
</component> | |||
<component name="ProjectType"> | |||
@@ -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' | |||
} |
@@ -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; | |||
} | |||
} |
@@ -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<Res_PLCADDRESS> PlcAddress_配料吧_手动=new ArrayList<Res_PLCADDRESS>(){{ | |||
//硬件设备 初始化 | |||
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)); | |||
}}; | |||
} |
@@ -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;//地址变量 | |||
} |
@@ -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<booleans.length;i++) | |||
{ | |||
ManualValue.put(i,booleans[i]); | |||
} | |||
}); | |||
//读取自动模式状态 | |||
ModbusTcpServer.get().ReadBool("M100.0", 28, booleans -> { | |||
for (int i=0;i<booleans.length;i++) | |||
{ | |||
AutomationValue.put(i,booleans[i]); | |||
} | |||
}); | |||
//配料完成 M0.3 | |||
CompleteListen("M0.3", "配料完成", OnChargeMixtureCompleteNotify); | |||
@@ -748,4 +771,64 @@ public class DeviceData { | |||
ModbusTcpServer.get().WriteBool("M103.4", value, callback); | |||
} | |||
//endregion | |||
//region 手动或自动状态监控 | |||
/** | |||
* 手动值 | |||
*/ | |||
ConcurrentHashMap<Integer, Boolean> ManualValue = new ConcurrentHashMap<>(); | |||
/** | |||
* 自动值 | |||
*/ | |||
ConcurrentHashMap<Integer, Boolean> 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 | |||
} |
@@ -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(); | |||
} | |||
} |
@@ -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<Res_PLCADDRESS> 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); | |||
} | |||
/** | |||
* <Switch | |||
* android:id="@+id/out_switch" | |||
* android:layout_width="wrap_content" | |||
* android:layout_height="wrap_content" | |||
* android:background="@drawable/qs_switch" | |||
* android:text="出口称重模块校准" | |||
* android:layout_margin="5dp"/> | |||
* @param plcaddresses | |||
*/ | |||
public void Init(List<Res_PLCADDRESS> 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); | |||
} | |||
} | |||
} |
@@ -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+""); | |||
} | |||
} |
@@ -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<Res_PLCADDRESS> 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 接收事件 | |||
@@ -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<Res_PLCADDRESS> 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) { | |||
} | |||
@@ -0,0 +1,96 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent" | |||
android:orientation="vertical" | |||
android:background="@mipmap/dpbj"> | |||
<RelativeLayout | |||
android:layout_width="match_parent" | |||
android:layout_height="30dp" | |||
android:background="@color/test"> | |||
<ImageView | |||
android:id="@+id/gongneng_fanhui" | |||
android:layout_width="26dp" | |||
android:layout_height="wrap_content" | |||
android:layout_alignParentLeft="true" | |||
android:layout_centerVertical="true" | |||
android:layout_marginLeft="20dp" | |||
android:textSize="@dimen/TitleSize" | |||
android:textColor="@color/titleforeground" | |||
android:src="@mipmap/zj" | |||
/> | |||
<RelativeLayout | |||
android:layout_centerInParent="true" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content"> | |||
<TextView | |||
android:id="@+id/gongneng_title" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_centerInParent="true" | |||
android:textColor="@color/white" | |||
android:textSize="@dimen/textTitleSize" | |||
android:textStyle="bold" /> | |||
<ImageView | |||
android:layout_width="400dp" | |||
android:layout_height="22dp" | |||
android:layout_alignParentBottom="true" | |||
android:src="@mipmap/tittle" | |||
android:layout_marginLeft="5dp" | |||
/> | |||
</RelativeLayout> | |||
</RelativeLayout> | |||
<View | |||
android:layout_width="match_parent" | |||
android:layout_height="1dp" | |||
android:background="#FF03668F" /> | |||
<RelativeLayout | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent" | |||
android:layout_margin="5dp"> | |||
<ImageView | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_alignParentLeft="true" | |||
android:layout_alignParentTop="true" | |||
android:src="@mipmap/zs"/> | |||
<ImageView | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_alignParentLeft="true" | |||
android:layout_alignParentBottom="true" | |||
android:src="@mipmap/zx"/> | |||
<ImageView | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_alignParentRight="true" | |||
android:layout_alignParentTop="true" | |||
android:src="@mipmap/ys"/> | |||
<ImageView | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_alignParentRight="true" | |||
android:layout_alignParentBottom="true" | |||
android:src="@mipmap/yx"/> | |||
<RelativeLayout | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent" | |||
android:layout_margin="10dp"> | |||
<RelativeLayout | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent" | |||
> | |||
<ScrollView | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent"> | |||
<LinearLayout | |||
android:id="@+id/sdkz_linrarlaout" | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" | |||
android:orientation="vertical"></LinearLayout> | |||
</ScrollView> | |||
</RelativeLayout> | |||
</RelativeLayout> | |||
</RelativeLayout> | |||
</LinearLayout> |
@@ -83,7 +83,6 @@ | |||
<RelativeLayout | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content"> | |||
<LinearLayout | |||
android:layout_centerInParent="true" | |||
android:layout_width="wrap_content" | |||
@@ -97,69 +96,9 @@ | |||
android:background="@drawable/qs_switch" | |||
android:text="出口称重模块校准" | |||
android:layout_margin="5dp"/> | |||
<LinearLayout | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
> | |||
<TextView | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:textColor="@color/white" | |||
android:text="砝码重量" | |||
android:layout_margin="5dp"/> | |||
<EditText | |||
android:id="@+id/outweight_edit" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:minWidth="60dp" | |||
android:textColor="@color/white" | |||
android:backgroundTint="@color/colorAccent" | |||
android:inputType="number|numberDecimal" | |||
android:theme="@style/MyEditText_num" | |||
android:maxLines="1" | |||
android:singleLine="true" | |||
android:layout_margin="5dp"/> | |||
<Button | |||
android:id="@+id/owSave_button" | |||
android:layout_width="wrap_content" | |||
android:layout_height="30dp" | |||
android:background="@drawable/btn_greenblue" | |||
android:text="保存" | |||
android:layout_margin="5dp"/> | |||
</LinearLayout> | |||
<LinearLayout | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content"> | |||
<Button | |||
android:id="@+id/zeroweight_button" | |||
android:layout_height="30dp" | |||
android:layout_width="wrap_content" | |||
android:background="@drawable/btn_greenblue" | |||
android:text="重量清零" | |||
android:layout_margin="5dp" | |||
/> | |||
<Button | |||
android:id="@+id/outWrite_button" | |||
android:layout_width="wrap_content" | |||
android:layout_height="30dp" | |||
android:background="@drawable/btn_greenblue" | |||
android:text="写入砝码值" | |||
android:layout_margin="5dp"/> | |||
<Button | |||
android:id="@+id/zerocalibration_button" | |||
android:layout_width="wrap_content" | |||
android:layout_height="30dp" | |||
android:background="@drawable/btn_greenblue" | |||
android:text="零点校准" | |||
android:layout_margin="5dp"/> | |||
</LinearLayout> | |||
</LinearLayout> | |||
</RelativeLayout> | |||
<TextView | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
@@ -170,7 +109,6 @@ | |||
android:textSize="24dp" | |||
android:textColor="@color/white"/> | |||
<LinearLayout | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
@@ -191,6 +129,67 @@ | |||
android:minWidth="60dp" | |||
/> | |||
</LinearLayout> | |||
<LinearLayout | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_gravity="center_horizontal" | |||
> | |||
<TextView | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:textColor="@color/white" | |||
android:text="砝码重量" | |||
android:layout_margin="5dp"/> | |||
<EditText | |||
android:id="@+id/outweight_edit" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:minWidth="60dp" | |||
android:textColor="@color/white" | |||
android:backgroundTint="@color/colorAccent" | |||
android:inputType="number|numberDecimal" | |||
android:theme="@style/MyEditText_num" | |||
android:maxLines="1" | |||
android:singleLine="true" | |||
android:layout_margin="5dp"/> | |||
<Button | |||
android:id="@+id/owSave_button" | |||
android:layout_width="wrap_content" | |||
android:layout_height="30dp" | |||
android:background="@drawable/btn_greenblue" | |||
android:text="保存" | |||
android:layout_margin="5dp"/> | |||
</LinearLayout> | |||
<LinearLayout | |||
android:layout_gravity="center_horizontal" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content"> | |||
<Button | |||
android:id="@+id/zeroweight_button" | |||
android:layout_height="30dp" | |||
android:layout_width="wrap_content" | |||
android:background="@drawable/btn_greenblue" | |||
android:text="重量清零" | |||
android:layout_margin="5dp" | |||
/> | |||
<Button | |||
android:id="@+id/outWrite_button" | |||
android:layout_width="wrap_content" | |||
android:layout_height="30dp" | |||
android:background="@drawable/btn_greenblue" | |||
android:text="写入砝码值" | |||
android:layout_margin="5dp"/> | |||
<Button | |||
android:id="@+id/zerocalibration_button" | |||
android:layout_width="wrap_content" | |||
android:layout_height="30dp" | |||
android:background="@drawable/btn_greenblue" | |||
android:text="零点校准" | |||
android:layout_margin="5dp"/> | |||
</LinearLayout> | |||
</LinearLayout> | |||
@@ -356,6 +356,7 @@ | |||
android:textColor="@color/white" | |||
android:thumb="@drawable/switch_custom_thumb_selector1" | |||
android:track="@drawable/switch_custom_track_selector1"/> | |||
<Switch | |||
android:id="@+id/Switch_17" | |||
android:layout_width="wrap_content" | |||
@@ -7,6 +7,7 @@ | |||
android:background="@mipmap/dpbj" | |||
android:orientation="vertical" | |||
tools:context=".view.from.sdkz_new_Activity"> | |||
<RelativeLayout | |||
android:layout_width="match_parent" | |||
android:layout_height="30dp" | |||
@@ -89,6 +90,15 @@ | |||
android:layout_height="match_parent" | |||
android:layout_margin="10dp"> | |||
<ScrollView | |||
android:layout_width="match_parent" | |||
android:layout_height="match_parent"> | |||
<LinearLayout | |||
android:id="@+id/sdkz_linrarlaout" | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" | |||
android:orientation="vertical"></LinearLayout> | |||
</ScrollView> | |||
</RelativeLayout> | |||
</RelativeLayout> |
@@ -164,6 +164,17 @@ | |||
</RelativeLayout> | |||
</LinearLayout> | |||
<ImageView | |||
android:id="@+id/image_zdkz" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_alignParentRight="true" | |||
android:layout_alignParentBottom="true" | |||
android:layout_marginRight="10dp" | |||
android:layout_marginBottom="10dp" | |||
android:src="@mipmap/zdkz1" | |||
android:elevation="20dp" | |||
android:translationZ="2dp"></ImageView> | |||
</RelativeLayout> | |||
<!-- <RelativeLayout--> | |||
<!-- android:layout_width="wrap_content"--> | |||
@@ -0,0 +1,25 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content"> | |||
<LinearLayout | |||
android:layout_marginTop="5dp" | |||
android:layout_width="match_parent" | |||
android:layout_height="24dp" | |||
android:orientation="horizontal"> | |||
<ImageView | |||
android:layout_width="40dp" | |||
android:layout_height="10dp" | |||
android:layout_marginTop="8dp" | |||
android:src="@mipmap/tab"> | |||
</ImageView> | |||
<TextView | |||
android:id="@+id/name" | |||
android:layout_width="wrap_content" | |||
android:layout_height="wrap_content" | |||
android:layout_marginLeft="2dp" | |||
android:text="订单列表" | |||
android:textColor="@color/titleforeground"> | |||
</TextView> | |||
</LinearLayout> | |||
</LinearLayout> |
@@ -0,0 +1,11 @@ | |||
<?xml version="1.0" encoding="utf-8"?> | |||
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content"> | |||
<com.example.bpa.view.control.AutoNextLineLinearLayout | |||
android:id="@+id/tagLayout" | |||
android:layout_width="match_parent" | |||
android:layout_height="wrap_content" | |||
android:orientation="horizontal"> | |||
</com.example.bpa.view.control.AutoNextLineLinearLayout> | |||
</LinearLayout> |