瀏覽代碼

自动清洗

master
NXX 1 年之前
父節點
當前提交
b897dc8079
共有 23 個文件被更改,包括 1073 次插入57 次删除
  1. +2
    -1
      app/build.gradle
  2. +2
    -0
      app/src/main/java/com/example/bpa/LoginActivity.java
  3. +1
    -1
      app/src/main/java/com/example/bpa/Model/IMessageLogNotify.java
  4. +2
    -0
      app/src/main/java/com/example/bpa/app/DeviceData.java
  5. +66
    -6
      app/src/main/java/com/example/bpa/db/QueryDB.java
  6. +1
    -1
      app/src/main/java/com/example/bpa/helper/MessageLog.java
  7. +0
    -4
      app/src/main/java/com/example/bpa/helper/Tools.java
  8. +11
    -2
      app/src/main/java/com/example/bpa/view/fragment/SystemSetFragment.java
  9. +223
    -2
      app/src/main/java/com/example/bpa/view/fragment/setting/Fragment_lcparameter.java
  10. +28
    -15
      app/src/main/java/com/example/bpa/view/from/lcsz_activity.java
  11. +171
    -1
      app/src/main/java/com/example/bpa/view/from/zdqx_activity.java
  12. +44
    -0
      app/src/main/res/drawable/bt_circular.xml
  13. +11
    -0
      app/src/main/res/drawable/btn_greenblue.xml
  14. +1
    -1
      app/src/main/res/drawable/lcbg_border.xml
  15. +19
    -0
      app/src/main/res/drawable/qs_switch.xml
  16. +5
    -0
      app/src/main/res/drawable/qs_textcolor.xml
  17. +2
    -0
      app/src/main/res/drawable/settingbutton.xml
  18. +179
    -8
      app/src/main/res/layout/from/layout/activity_zdqx.xml
  19. +295
    -12
      app/src/main/res/layout/from/layout/fragment_lcparameter.xml
  20. +9
    -3
      app/src/main/res/layout/from/layout/fragment_system_set.xml
  21. 二進制
     
  22. 二進制
     
  23. +1
    -0
      app/src/main/res/values/colors.xml

+ 2
- 1
app/build.gradle 查看文件

@@ -51,12 +51,13 @@ dependencies {
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.recyclerview:recyclerview:1.2.1'
implementation 'com.google.android.libraries.places:places:2.5.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation 'com.qmuiteam:qmui:2.0.0-alpha10' //腾讯ui包
implementation("com.iqiyi.xcrash:xcrash-android-lib:3.1.0") //爱奇艺捕获异常插件
implementation files('libs\\gson-2.2.2.jar')
// implementation files('libs\\gson-2.2.2.jar')
implementation files('libs\\sdkapi.jar')
compileOnly files('libs/sdkapi.jar')
implementation files('libs/modbus4Android-1.2.jar')

+ 2
- 0
app/src/main/java/com/example/bpa/LoginActivity.java 查看文件

@@ -10,6 +10,7 @@ import com.example.bpa.app.Main;
import com.example.bpa.config.ConfigName;
import com.example.bpa.db.QueryDB;
import com.example.bpa.db.mode.BPA_USER;
import com.example.bpa.helper.MessageLog;
import com.example.bpa.helper.T;

public class LoginActivity extends Activity implements View.OnClickListener {
@@ -60,6 +61,7 @@ public class LoginActivity extends Activity implements View.OnClickListener {
if (user!=null) {
ConfigName.getInstance().user = user;
Main.getInstance().SavePZ();//保存配置
MessageLog.ShowInfo("登录");
T.show(LoginActivity.this, "登录成功!");
try {
Intent intent = new Intent(LoginActivity.this, MainActivity.class);


+ 1
- 1
app/src/main/java/com/example/bpa/Model/IMessageLogNotify.java 查看文件

@@ -3,7 +3,7 @@ package com.example.bpa.Model;
public interface IMessageLogNotify {
void ErrorMsg(String msg);

void InfoMsg(String msg);
void InfoMsg(String msg,String datetiem);

void WarnMsg(String msg);
}

+ 2
- 0
app/src/main/java/com/example/bpa/app/DeviceData.java 查看文件

@@ -4,6 +4,7 @@ import com.example.bpa.Model.IReadCallBack;
import com.example.bpa.Model.IRun;
import com.example.bpa.Model.IThread;
import com.example.bpa.Model.IWriteCallBack;
import com.example.bpa.helper.MessageLog;
import com.example.bpa.helper.RTrig;
import com.example.bpa.helper.ThreadManager;

@@ -17,6 +18,7 @@ public class DeviceData {
if (_instance == null)
_instance = new DeviceData();
return _instance;

}

public void Init() {


+ 66
- 6
app/src/main/java/com/example/bpa/db/QueryDB.java 查看文件

@@ -1,10 +1,7 @@
package com.example.bpa.db;

import android.content.ContentValues;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.util.Log;

import com.example.bpa.config.ConfigName;
import com.example.bpa.db.file.DBHelper;
import com.example.bpa.db.mode.BPA_ALERTLOG;
@@ -26,7 +23,6 @@ import com.example.bpa.db.mode.ModeBase;
import com.example.bpa.helper.Tools;
import com.example.bpa.view.mode.ResGoodsRecipe;
import com.example.bpa.view.mode.ResSilosMode;

import java.lang.reflect.Field;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
@@ -95,6 +91,39 @@ public class QueryDB {
return Delete(BPA_MATERIAL.class, data.id);
}

// public static boolean DeleteMaterial(String id){
// boolean result = false;
// SQLiteDatabase db = helper.getWritableDatabase();
// try {
// db.beginTransaction();
// StringBuilder sql = new StringBuilder();
// sql.append("delete from ").append(BPA_MATERIAL.class.getSimpleName()).append(" where id=?");
// db.execSQL(sql.toString(), new String[]{id});
// db.setTransactionSuccessful();
// result = true;
// }catch (SQLException e) {
// e.printStackTrace();
// result = false;
// }finally {
// db.endTransaction();
// }
//
// try {
// db.beginTransaction();
// StringBuilder sql = new StringBuilder();
// sql.append("delete from ").append(BPA_SILOSANDMATERIAL.class.getSimpleName()).append(" where materialID=?");
// db.execSQL(sql.toString(), new String[]{id});
// db.setTransactionSuccessful();
// }catch (SQLException e) {
// e.printStackTrace();
//
// }finally {
// db.endTransaction();//结束第二个事务,回滚或提交操作
// }
// db.close();
// return result;
// }



/**
@@ -114,7 +143,7 @@ public class QueryDB {
return data;
}
/**
* 根据id获取物料
* 根据物料id获取物料
*
* @param
* @return
@@ -363,7 +392,7 @@ public class QueryDB {
}

/**
* 根据料仓id查询物料
* 根据料仓id查询物料id
* @param id
* @return
*/
@@ -416,6 +445,34 @@ public class QueryDB {
}
return data;
}

/**
* 根据料仓id查询物料
* @param id
* @return
*/
public static List<BPA_MATERIAL> GetMaterialBySilosID(String id){
List<BPA_MATERIAL> data = new ArrayList<>();
List<String> res = GetMaterialList(id);//根据料仓ID获取物料ID
if (res.size() == 0){
return data;
}
if (res.get(0).equals("")){return data;}
//根据物料id查询物料
String orderby=Desc_Time_Up;//先按排序 创建时间倒序
String where="isDelete=? and id=?";

for (String s : res) {
String[] args=new String[] { "0",s };
List<Object> obj=Get(BPA_MATERIAL.class,where,args,orderby);
for (Object o : obj) {
data.add((BPA_MATERIAL) o);
}

}
return data;

}
//endregion

//region BPA_GOODS 商品表
@@ -881,10 +938,12 @@ public class QueryDB {
ArrayList<Object> obj = Get(BPA_LOG.class, where, args, orderby);
for (Object k : obj) {
data.add((BPA_LOG) k);

}
return data;
}


/**
* 获取所有今日日志
*
@@ -1307,6 +1366,7 @@ public class QueryDB {
// cv.put(key, (Date) value);
// }
}

SQLiteDatabase db = helper.getWritableDatabase();
long insert = db.insert(c.getSimpleName(), null, cv);
db.close();


+ 1
- 1
app/src/main/java/com/example/bpa/helper/MessageLog.java 查看文件

@@ -12,7 +12,7 @@ public class MessageLog {
SimpleDateFormat formatter = new SimpleDateFormat("HH:mm:ss");
Date date = new Date();
if (MsgNotify != null)
MsgNotify.InfoMsg(formatter.format(date) + ":" + msg);
MsgNotify.InfoMsg(formatter.format(date) + ":" + msg,formatter.format(date));
}

public static void ShowWarning(String msg) {


+ 0
- 4
app/src/main/java/com/example/bpa/helper/Tools.java 查看文件

@@ -1,5 +1,4 @@
package com.example.bpa.helper;

import android.content.Context;
import android.content.res.AssetManager;
import android.graphics.Bitmap;
@@ -14,12 +13,9 @@ import android.graphics.RectF;
import android.os.Build;
import android.os.Environment;
import android.view.View;

import com.google.gson.Gson;

import org.json.JSONException;
import org.json.JSONObject;

import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;


+ 11
- 2
app/src/main/java/com/example/bpa/view/fragment/SystemSetFragment.java 查看文件

@@ -17,6 +17,9 @@ import android.widget.Button;

import com.example.bpa.Model.IMessageLogNotify;
import com.example.bpa.R;
import com.example.bpa.config.ConfigName;
import com.example.bpa.db.QueryDB;
import com.example.bpa.db.mode.BPA_LOG;
import com.example.bpa.helper.MessageLog;
import com.example.bpa.view.fragment.setting.Fragment_lcparameter;

@@ -52,13 +55,19 @@ public class SystemSetFragment extends Fragment implements View.OnClickListener
@Override
public void ErrorMsg(String msg) {
Log.e("Error", msg);

}

@Override
public void InfoMsg(String msg) {
public void InfoMsg(String msg,String datetime) {
BPA_LOG log = new BPA_LOG();
log.userID = ConfigName.getInstance().user.userID;
log.createTime = datetime;
log.type = 1;
log.text = msg;
QueryDB.Addlog(log);
Log.i("Info", msg);
}

@Override
public void WarnMsg(String msg) {
Log.w("Warn", msg);


+ 223
- 2
app/src/main/java/com/example/bpa/view/fragment/setting/Fragment_lcparameter.java 查看文件

@@ -11,18 +11,44 @@ import android.os.Bundle;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.LinearLayout;
import android.widget.Switch;

import com.example.bpa.Model.IWriteCallBack;
import com.example.bpa.R;
import com.example.bpa.app.DeviceData;
import com.example.bpa.helper.T;

public class Fragment_lcparameter extends Fragment {
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

public class Fragment_lcparameter extends Fragment implements CompoundButton.OnCheckedChangeListener {

private View view;
LinearLayout mylayout;

//通道校准值

EditText passwayText_1,passwayText_2,passwayText_3,passwayText_4,passwayText_5,passwayText_6,passwayText_7,passwayText_8,passwayText_9,passwayText_10;

EditText timeText;
List<EditText> editTextLists = new ArrayList<EditText>();
//通道校准开关
Switch Switch_1,Switch_2,Switch_3,Switch_4,Switch_5,Switch_6,Switch_7,Switch_8,Switch_9,Switch_10;
List<Switch> switchLists = new ArrayList<Switch>();
Button StartButton;

Button SaveButton;
@Override
public View onCreateView(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {
view = inflater.inflate(R.layout.fragment_system_capabilities, container,false);
view = inflater.inflate(R.layout.fragment_lcparameter, container,false);
Init();
InitEvent();
InitData();
return view;

}
@@ -30,5 +56,200 @@ public class Fragment_lcparameter extends Fragment {
private void Init(){
mylayout = view.findViewById(R.id.lcparameter_layout);
mylayout.setBackgroundColor(Color.TRANSPARENT);
//校准数值

passwayText_1 = view.findViewById(R.id.passwayText_1);
passwayText_2 = view.findViewById(R.id.passwayText_2);
passwayText_3 = view.findViewById(R.id.passwayText_3);
passwayText_4 = view.findViewById(R.id.passwayText_4);
passwayText_5 = view.findViewById(R.id.passwayText_5);
passwayText_6 = view.findViewById(R.id.passwayText_6);
passwayText_7 = view.findViewById(R.id.passwayText_7);
passwayText_8 = view.findViewById(R.id.passwayText_8);
passwayText_9 = view.findViewById(R.id.passwayText_9);
passwayText_10 = view.findViewById(R.id.passwayText_10);
editTextLists = Arrays.asList(passwayText_1,passwayText_2,passwayText_3,passwayText_4,passwayText_5,passwayText_6,passwayText_7,passwayText_8,passwayText_9,passwayText_10);

//校准开关
Switch_1 = view.findViewById(R.id.Switch_1);
Switch_2 = view.findViewById(R.id.Switch_2);
Switch_3 = view.findViewById(R.id.Switch_3);
Switch_4 = view.findViewById(R.id.Switch_4);
Switch_5 = view.findViewById(R.id.Switch_5);
Switch_6 = view.findViewById(R.id.Switch_6);
Switch_7 = view.findViewById(R.id.Switch_7);
Switch_8 = view.findViewById(R.id.Switch_8);
Switch_9 = view.findViewById(R.id.Switch_9);
Switch_10 = view.findViewById(R.id.Switch_10);

//校准按钮
StartButton = view.findViewById(R.id.StartButton);

timeText = view.findViewById(R.id.edi_time);
SaveButton = view.findViewById(R.id.savetime);
}

//点击事件
private void InitEvent(){
Switch_1.setOnCheckedChangeListener(this);
Switch_2.setOnCheckedChangeListener(this);
Switch_3.setOnCheckedChangeListener(this);
Switch_4.setOnCheckedChangeListener(this);
Switch_5.setOnCheckedChangeListener(this);
Switch_6.setOnCheckedChangeListener(this);
Switch_7.setOnCheckedChangeListener(this);
Switch_8.setOnCheckedChangeListener(this);
Switch_9.setOnCheckedChangeListener(this);
Switch_10.setOnCheckedChangeListener(this);

//开始校准
StartButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
DeviceData.Get().setChStartCalibration(new IWriteCallBack() {
@Override
public void onSuccess() {
T.show(view.getContext(),"通道开始校准");
}

@Override
public void onFailure(String ErrorMsg) {
T.show(view.getContext(),"通道开始校准失败");
}
});
}
});

SaveButton.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
new Thread(new Runnable() {
@Override
public void run() {
try {
String stime = timeText.getText().toString();
if(stime.equals("")){return;}
Float ftime = Float.parseFloat(stime);
DeviceData.Get().setCalibrationReferenceTime(ftime,new IWriteCallBack() {
@Override
public void onSuccess() {
T.show(view.getContext(),"校准时间写入成功");
}

@Override
public void onFailure(String ErrorMsg) {
T.show(view.getContext(),"校准时间写入失败");
}
});
}catch (ArithmeticException e) {
e.printStackTrace();
}
}
});


}
});

}

//初始化数据
private void InitData(){
//初始化标准值数据
for (int i = 0; i <10;i++){
String s = String.valueOf(DeviceData.Get().getCalibrationValue(i+1));
editTextLists.get(i).setText(s);
}
String time = String.valueOf(DeviceData.Get().getCalibrationReferenceTime());
timeText.setText(time);



}

//switch 事件
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
switch (buttonView.getId()){
case R.id.Switch_1:
SwitchClick(1,isChecked);
break;
case R.id.Switch_2:
SwitchClick(2,isChecked);
break;
case R.id.Switch_3:
SwitchClick(3,isChecked);
break;
case R.id.Switch_4:
SwitchClick(4,isChecked);
break;
case R.id.Switch_5:
SwitchClick(5,isChecked);
break;
case R.id.Switch_6:
SwitchClick(6,isChecked);
break;
case R.id.Switch_7:
SwitchClick(7,isChecked);
break;
case R.id.Switch_8:
SwitchClick(8,isChecked);
break;
case R.id.Switch_9:
SwitchClick(9,isChecked);
break;
case R.id.Switch_10:
SwitchClick(10,isChecked);
break;
}
}

private void SwitchClick(int index, boolean isChecked){
StringBuffer sb = new StringBuffer("PLC写入:");
new Thread (new Runnable() {
public void run() {
if (isChecked){ //校准开关开启状态才会写入值


String value = editTextLists.get(index-1).getText().toString();
DeviceData.Get().setCalibrationValue(Short.parseShort(value),index, new IWriteCallBack() {
@Override
public void onSuccess() {
sb.append("通道");
sb.append(index);
sb.append("校准值写入成功;");
}

@Override
public void onFailure(String ErrorMsg) {
sb.append("通道");
sb.append(index);
sb.append("校准值写入失败;");
}
});
}
DeviceData.Get().setChCalibrationSwitch(isChecked, index, new IWriteCallBack() {
@Override
public void onSuccess() {
sb.append("通道");
sb.append(index);
sb.append("校准开关成功;");

}

@Override
public void onFailure(String ErrorMsg) {
sb.append("通道");
sb.append(index);
sb.append("校准开关失败;");

}
});
}
});


T.show(view.getContext(), sb.toString());
}

}

+ 28
- 15
app/src/main/java/com/example/bpa/view/from/lcsz_activity.java 查看文件

@@ -48,8 +48,8 @@ public class lcsz_activity extends AppCompatActivity implements View.OnClickList
RecyclerView recyclerView;
//物料listview
ListView materiallist;
//materiallist父控件
View material_parent;
//物料列表
ArrayList<BPA_MATERIAL> bpa_materials=new ArrayList<>();
//当前选中的料仓id
@@ -79,6 +79,7 @@ public class lcsz_activity extends AppCompatActivity implements View.OnClickList
//横向排列
recyclerView = this.findViewById(R.id.lc_view);
materiallist = this.findViewById(R.id.materials);
material_parent =(View) materiallist.getParent();
try {
//加载 recyclercview数据
MyLayoutManager layout = new MyLayoutManager();
@@ -91,18 +92,23 @@ public class lcsz_activity extends AppCompatActivity implements View.OnClickList
//加载materials数据
if(bpa_silos.size()>0){
for (BPA_SILOS silo : bpa_silos){
String resmaterialid = QueryDB.GetMaterialList(silo.id).size()==0? "-1" : QueryDB.GetMaterialList(silo.id).get(0);
String material_name = "未设置";
String material_id = "";
if (resmaterialid != "-1"){
BPA_MATERIAL res= QueryDB.GetMaterialbyid(resmaterialid);
if (res!=null) {
material_name = res.name;
material_id = res.id;
}

// String resmaterialid = QueryDB.GetMaterialList(silo.id).size()==0? "-1" : QueryDB.GetMaterialList(silo.id).get(0);
// String material_name = "未设置";
// String material_id = "";
// if (resmaterialid != "-1"){
// BPA_MATERIAL res= QueryDB.GetMaterialbyid(resmaterialid);
// if (res!=null) {
// material_name = res.name;
// material_id = res.id;
// }
//
// }
List<BPA_MATERIAL> m = QueryDB.GetMaterialBySilosID(silo.id);
if(m.size()>0) {
datas.add(new lcMode(silo.id, silo.num, m.get(0).name, "", m.get(0).id));
}else {
datas.add(new lcMode(silo.id, silo.num, "未设置", "", ""));
}
datas.add(new lcMode(silo.id,silo.num,material_name,"",material_id));

}
}
@@ -156,8 +162,7 @@ public class lcsz_activity extends AppCompatActivity implements View.OnClickList
public void onItemClick(AdapterView<?> parent, View view, int position, long id) {
ArrayAdapter viewHolder = (ArrayAdapter)materiallist.getAdapter();
if (viewHolder instanceof selectitem_adapter){
View listViewParent = (View) materiallist.getParent();
listViewParent.setVisibility(View.GONE);
material_parent.setVisibility(View.GONE);//隐藏父控件
if (currentSilo!=null){
BPA_SILOSANDMATERIAL item = new BPA_SILOSANDMATERIAL();
item.silosID = currentSilo.id;
@@ -174,6 +179,14 @@ public class lcsz_activity extends AppCompatActivity implements View.OnClickList
}
}
});

//region materials父控件点击事件
material_parent.setOnClickListener(new View.OnClickListener(){
@Override
public void onClick(View v) {
material_parent.setVisibility(View.GONE);//隐藏materiallist
}
});
//endregion

}


+ 171
- 1
app/src/main/java/com/example/bpa/view/from/zdqx_activity.java 查看文件

@@ -1,13 +1,24 @@
package com.example.bpa.view.from;

import static com.example.bpa.helper.T.show;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.View;
import android.widget.Button;
import android.widget.CompoundButton;
import android.widget.EditText;
import android.widget.ImageView;
import android.widget.ProgressBar;
import android.widget.Switch;
import android.widget.TextView;

import com.example.bpa.Model.IWriteCallBack;
import com.example.bpa.R;
import com.example.bpa.app.DeviceData;
import com.example.bpa.db.QueryDB;
import com.example.bpa.helper.T;

/**
* 自动清洗
@@ -22,6 +33,18 @@ public class zdqx_activity extends AppCompatActivity implements View.OnClickList
* 标题设置
*/
TextView gongneng_title;
//参数
EditText edit_pstime,edit_jstime,edit_jqxjtime,edit_xhtime;
//按钮
Button bt_save,bt_start;
//switch
Switch qsmode;
//进度条
ProgressBar progress_bar;

// TextView progress_text;

boolean mValue = false;
//endregion

//region 私有函数
@@ -31,6 +54,8 @@ public class zdqx_activity extends AppCompatActivity implements View.OnClickList
setContentView(R.layout.activity_zdqx);
Init();
initEvents();
InitData();
startListening();
}
//endregion

@@ -42,11 +67,20 @@ public class zdqx_activity extends AppCompatActivity implements View.OnClickList
private void Init(){
gongneng_fanhui = this.findViewById(R.id.gongneng_fanhui);
gongneng_title = this.findViewById(R.id.gongneng_title);
edit_pstime = this.findViewById(R.id.edit_pstime);
edit_jstime = this.findViewById(R.id.edit_jstime);
edit_jqxjtime = this.findViewById(R.id.edit_jqxjtime);
edit_xhtime = this.findViewById(R.id.edit_xhtime);
bt_save = this.findViewById(R.id.bt_save);
bt_start = this.findViewById(R.id.bt_start);
qsmode = this.findViewById(R.id.qsmode);
progress_bar = this.findViewById(R.id.progress_bar);
// progress_text = this.findViewById(R.id.progress_text);
//通过Activity.getIntent()获取当前页面接收到的Intent。 getXxxExtra方法获取Intent传递过来的数据
String msg=getIntent().getStringExtra("data");
gongneng_title.setText(msg);

((TextView)this.findViewById(R.id.test_view)).setText(msg);
}

/**
@@ -54,6 +88,68 @@ public class zdqx_activity extends AppCompatActivity implements View.OnClickList
*/
private void initEvents() {
gongneng_fanhui.setOnClickListener(this);
bt_save.setOnClickListener(this);
bt_start.setOnClickListener(this);
qsmode.setOnCheckedChangeListener(new Switch.OnCheckedChangeListener() {

@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
new Thread(new Runnable() {
@Override
public void run() {
try {
DeviceData.Get().setCleaningMode(isChecked,null);//设置清洗模式
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
});
}

private void InitData(){

edit_pstime.setText(String.valueOf(DeviceData.Get().getDrainageTime()));//排水
edit_jstime.setText(String.valueOf(DeviceData.Get().getInletTime()));//进水
edit_jqxjtime.setText(String.valueOf(DeviceData.Get().getAddCleaningAgentTime()));//加清洗剂时间
edit_xhtime.setText(String.valueOf(DeviceData.Get().getCyclicCleaningTime()));//循环清洗
qsmode.setChecked(DeviceData.Get().getCleaningMode());
progress_bar.setProgress(0);
//progress_bar.setIndeterminate(true); // 将进度条设置为不确定状态
}


/**
* 监听外部数据变化
*/
private void startListening(){
new Thread(new Runnable() {
@Override
public void run() {
while (true) {
try {
if (SetValue(mValue,DeviceData.Get().getCleaningMode())) {
runOnUiThread(new Runnable() {
@Override
public void run() {
progress_bar.setIndeterminate(false);//停止旋转
progress_bar.setProgress(100);//进度条设置为100%
bt_start.setText("清洗完成");
// T.show(zdqx_activity.this,"清洗完成");
}
});
}

Thread.sleep(1000);


}catch (Exception e) {

}
}
}
}).start();
}
//endregion

@@ -69,7 +165,81 @@ public class zdqx_activity extends AppCompatActivity implements View.OnClickList
case R.id.gongneng_fanhui://返回按钮
this.finish();
break;
case R.id.bt_save://保存
new Thread(new Runnable() {
@Override
public void run() {
try {
if (!edit_pstime.getText().toString().equals("")) {
DeviceData.Get().setDrainageTime(Short.parseShort(edit_pstime.getText().toString()),null);
Thread.sleep(200);
}
if (!edit_jstime.getText().toString().equals("")) {
DeviceData.Get().setInletTime(Short.parseShort(edit_jstime.getText().toString()),null);
Thread.sleep(200);
}
if (!edit_jqxjtime.getText().toString().equals("")) {
DeviceData.Get().setAddCleaningAgentTime(Short.parseShort(edit_jqxjtime.getText().toString()),null);
Thread.sleep(200);
}
if (!edit_xhtime.getText().toString().equals("")) {
DeviceData.Get().setCyclicCleaningTime(Short.parseShort(edit_xhtime.getText().toString()),null);
Thread.sleep(200);
}
}catch (InterruptedException e) {

}catch (Exception e) {

}

}
});
break;
case R.id.bt_start://开始清洗
new Thread(new Runnable() {
@Override
public void run() {
try {
DeviceData.Get().setStartCleaning(new IWriteCallBack() {
@Override
public void onSuccess() {
//UI线程操作UI控件
runOnUiThread(new Runnable() {
@Override
public void run() {
progress_bar.setVisibility(View.VISIBLE);
progress_bar.setIndeterminate(true);//进度条开始旋转
bt_start.setText("开始清洗");
}
});
}

@Override
public void onFailure(String ErrorMsg) {

}
});

} catch (Exception e) {

}

}
});
break;
}
}
//endregion

//判断boolen 从fales变成true
private boolean SetValue(boolean value, boolean newValue) {
boolean mflag = value;

if (newValue && !mflag) { // 当新值为 true 且前一个值为 false 时,发出通知
value = newValue; // 更新标志变量的值
return true;
}
value = newValue; // 更新标志变量的值
return false;
}
}

+ 44
- 0
app/src/main/res/drawable/bt_circular.xml 查看文件

@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<!-- Button 被按下时的样式 -->
<item android:state_pressed="true">
<shape android:shape="oval">
<gradient
android:startColor="#FF4081"
android:endColor="#FF6699"
android:type="sweep"
android:angle="45" />
<padding
android:left="10dp"
android:top="10dp"
android:right="10dp"
android:bottom="10dp" />
<stroke
android:width="2dp"
android:color="#FF4081" />

</shape>

</item>

<!-- Button 正常状态下的样式 -->
<item>
<shape android:shape="oval">
<gradient
android:startColor="#0088ff"
android:endColor="#006bff"
android:type="linear"
android:angle="45" />
<padding
android:left="5dp"
android:top="5dp"
android:right="10dp"
android:bottom="10dp" />
<stroke
android:width="2dp"
android:color="#444444" />


</shape>
</item>
</selector>

+ 11
- 0
app/src/main/res/drawable/btn_greenblue.xml 查看文件

@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="rectangle">

<gradient
android:startColor="#009688"
android:endColor="#00BCD4"
android:type="linear"
android:angle="90" />

</selector>

+ 1
- 1
app/src/main/res/drawable/lcbg_border.xml 查看文件

@@ -5,7 +5,7 @@
<stroke
android:width="2dp"
android:color="#007AFF" />
<solid android:color="@color/test" />
<solid android:color="#FF092B51" />
<corners
android:radius="20dp" />
</shape>

+ 19
- 0
app/src/main/res/drawable/qs_switch.xml 查看文件

@@ -0,0 +1,19 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true">
<shape android:shape="rectangle">
<corners android:radius="30dp" />
<solid android:color="#2ecc71" />
<padding android:left="10dp" />
</shape>

</item>
<item android:state_checked="false">
<shape android:shape="rectangle">
<corners android:radius="30dp" />
<solid android:color="#d1f2eb" />
<padding android:left="10dp" />
</shape>

</item>
</selector>

+ 5
- 0
app/src/main/res/drawable/qs_textcolor.xml 查看文件

@@ -0,0 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_checked="true" android:color="@android:color/white" />
<item android:state_checked="false" android:color="#8A8A8A" />
</selector>

+ 2
- 0
app/src/main/res/drawable/settingbutton.xml 查看文件

@@ -17,7 +17,9 @@
<stroke
android:width="2dp"
android:color="#FF4081" />

</shape>

</item>

<!-- Button 正常状态下的样式 -->


+ 179
- 8
app/src/main/res/layout/from/layout/activity_zdqx.xml 查看文件

@@ -75,17 +75,188 @@
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:src="@mipmap/yx"/>
<RelativeLayout

<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp">
<TextView
android:id="@+id/test_view"
android:layout_marginStart="10dp"
android:layout_marginTop="10dp"
android:layout_marginEnd="10dp"
android:layout_marginBottom="10dp"
android:orientation="vertical">

<TableLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/foreground"
android:textSize="@dimen/TitleSize">
</TextView>
</RelativeLayout>
android:layout_gravity="center"
>

<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp">

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="vertical">

<TextView
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_margin="5dp"
android:gravity="center"
android:text="排水阀排水时间:"
android:textColor="@color/white" />

<TextView
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_margin="5dp"
android:gravity="center"
android:text="进水阀进水时间:"
android:textColor="@color/white" />
</LinearLayout>

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginRight="30dp"
android:layout_marginBottom="10dp"
android:orientation="vertical">

<EditText
android:id="@+id/edit_pstime"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_margin="5dp"
android:backgroundTint="@color/colorAccent"
android:gravity="center"
android:minWidth="50dp"
android:textColor="@color/white" />

<EditText
android:id="@+id/edit_jstime"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_margin="5dp"
android:backgroundTint="@color/colorAccent"
android:gravity="center"
android:minWidth="50dp"
android:textColor="@color/white" />
</LinearLayout>

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:orientation="vertical">

<TextView
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_margin="5dp"
android:gravity="center"
android:text="加清洗剂时间:"
android:textColor="@color/white" />

<TextView
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_margin="5dp"
android:gravity="center"
android:text="循环清洗时间:"
android:textColor="@color/white" />
</LinearLayout>

<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="10dp"
android:layout_marginRight="30dp"
android:layout_marginBottom="10dp"
android:orientation="vertical">

<EditText
android:id="@+id/edit_jqxjtime"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_margin="5dp"
android:backgroundTint="@color/colorAccent"
android:gravity="center"
android:minWidth="50dp"
android:textColor="@color/white" />

<EditText
android:id="@+id/edit_xhtime"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_margin="5dp"
android:backgroundTint="@color/colorAccent"
android:gravity="center"
android:minWidth="50dp"
android:textColor="@color/white" />
</LinearLayout>

</TableRow>


</TableLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:layout_gravity="center"
android:layout_margin="20dp">
<Button
android:id="@+id/bt_save"
android:layout_width="140dp"
android:layout_height="40dp"
android:background="@drawable/settingbutton"
android:text="保存"
android:layout_marginRight="50dp"
android:textColor="@color/white" />

<Switch
android:id="@+id/qsmode"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:background="@drawable/qs_switch"
android:layout_marginLeft="40dp"
android:text="清洗模式启动"
android:textColor="@drawable/qs_textcolor"
android:thumbTint="@android:color/white"
android:trackTint="@android:color/white" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_margin="20dp">
<Button
android:id="@+id/bt_start"
android:layout_width="120dp"
android:layout_height="80dp"
android:background="@drawable/bt_circular"
android:text="开始清洗"
android:textColor="@color/white" />
</LinearLayout>

<ProgressBar
android:id="@+id/progress_bar"
style="?android:attr/progressBarStyleHorizontal"
android:layout_width="400dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:visibility="visible"
android:layout_centerInParent="true"
android:duration="3000"
android:indeterminate="true"
android:max="100" />


</LinearLayout>
</RelativeLayout>
</LinearLayout>

+ 295
- 12
app/src/main/res/layout/from/layout/fragment_lcparameter.xml 查看文件

@@ -12,37 +12,320 @@
android:layout_gravity="center"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<!-- Table1-->
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="10dp">
android:layout_margin="5dp">
<TextView
android:layout_marginRight="5dp"
android:text="通道一校准"/>
android:layout_marginRight="15dp"
android:text="通道一:"
android:textColor="@color/white"
android:textStyle="bold"/>
<EditText
android:id="@+id/passwayText_1"
android:minWidth="60dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:hint="校准值"/>
android:layout_marginRight="15dp"

android:textColor="@color/white"
android:backgroundTint="@color/colorAccent"/>
<Switch
android:id="@+id/Switch_1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="校准开关"
android:layout_marginRight="40dp"
android:textColor="@color/white"/>

<TextView
android:layout_marginRight="15dp"
android:text="通道二:"
android:textColor="@color/white"
android:textStyle="bold"/>
<EditText
android:id="@+id/passwayText_2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minWidth="60dp"
android:layout_marginRight="15dp"

android:textColor="@color/white"
android:backgroundTint="@color/colorAccent"/>
<Switch
android:id="@+id/Switch_2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="校准开关"
android:layout_marginRight="40dp"
android:textColor="@color/white"/>
</TableRow>
<!-- Table3-->
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="5dp">
<TextView
android:layout_marginRight="15dp"
android:text="通道三:"
android:textColor="@color/white"
android:textStyle="bold"/>
<EditText
android:id="@+id/passwayText_3"
android:minWidth="60dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="15dp"

android:textColor="@color/white"
android:backgroundTint="@color/colorAccent"/>
<Switch
android:id="@+id/Switch_3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="校准开关"
android:layout_marginRight="40dp"
android:textColor="@color/white"/>

<TextView
android:layout_marginRight="15dp"
android:text="通道四:"
android:textColor="@color/white"
android:textStyle="bold"/>
<EditText
android:id="@+id/passwayText_4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minWidth="60dp"
android:layout_marginRight="15dp"

android:textColor="@color/white"
android:backgroundTint="@color/colorAccent"/>
<Switch
android:id="@+id/Switch_4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="校准"
android:layout_marginRight="40dp"/>
android:text="校准开关"
android:layout_marginRight="40dp"
android:textColor="@color/white"/>
</TableRow>
<!-- Table3-->
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="5dp">
<TextView
android:layout_marginRight="15dp"
android:text="通道五:"
android:textColor="@color/white"
android:textStyle="bold"/>
<EditText
android:id="@+id/passwayText_5"
android:minWidth="60dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="15dp"

android:textColor="@color/white"
android:backgroundTint="@color/colorAccent"/>
<Switch
android:id="@+id/Switch_5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="校准开关"
android:layout_marginRight="40dp"
android:textColor="@color/white"/>

<TextView
android:layout_marginRight="5dp"
android:text="通道二校准"/>
android:layout_marginRight="15dp"
android:text="通道六:"
android:textColor="@color/white"
android:textStyle="bold"/>
<EditText
android:id="@+id/passwayText_6"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="5dp"
android:hint="校准值"/>
android:minWidth="60dp"
android:layout_marginRight="15dp"

android:textColor="@color/white"
android:backgroundTint="@color/colorAccent"/>
<Switch
android:id="@+id/Switch_6"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="校准开关"/>
android:text="校准开关"
android:layout_marginRight="40dp"
android:textColor="@color/white"/>
</TableRow>
<!-- Table4-->
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="5dp">
<TextView
android:layout_marginRight="15dp"
android:text="通道七:"
android:textColor="@color/white"
android:textStyle="bold"/>
<EditText
android:id="@+id/passwayText_7"
android:minWidth="60dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="15dp"

android:textColor="@color/white"
android:backgroundTint="@color/colorAccent"/>
<Switch
android:id="@+id/Switch_7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="校准开关"
android:layout_marginRight="40dp"
android:textColor="@color/white"/>

<TextView
android:layout_marginRight="15dp"
android:text="通道八:"
android:textColor="@color/white"
android:textStyle="bold"/>
<EditText
android:id="@+id/passwayText_8"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minWidth="60dp"
android:layout_marginRight="15dp"

android:textColor="@color/white"
android:backgroundTint="@color/colorAccent"/>
<Switch
android:id="@+id/Switch_8"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="校准开关"
android:layout_marginRight="40dp"
android:textColor="@color/white"/>
</TableRow>
<!-- Table5-->
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="5dp">
<TextView
android:layout_marginRight="15dp"
android:text="通道九:"
android:textColor="@color/white"
android:textStyle="bold"/>
<EditText
android:id="@+id/passwayText_9"
android:minWidth="60dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginRight="15dp"

android:textColor="@color/white"
android:backgroundTint="@color/colorAccent"/>
<Switch
android:id="@+id/Switch_9"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="校准开关"
android:layout_marginRight="40dp"
android:textColor="@color/white"/>

<TextView
android:layout_marginRight="15dp"
android:text="通道十:"
android:textColor="@color/white"
android:textStyle="bold"/>
<EditText
android:id="@+id/passwayText_10"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:minWidth="60dp"
android:layout_marginRight="15dp"

android:textColor="@color/white"
android:backgroundTint="@color/colorAccent"/>
<Switch
android:id="@+id/Switch_10"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="校准开关"
android:layout_marginRight="40dp"
android:textColor="@color/white"/>
</TableRow>
</TableLayout>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:id="@+id/StartButton"
android:layout_marginTop="10dp"
android:layout_marginBottom="5dp"
android:layout_width="90dp"
android:layout_height="90dp"
android:layout_gravity="center"
android:layout_centerHorizontal="true"
android:background="@drawable/bt_circular"
android:textColor="@color/white"
android:text="开始
校准"
android:textSize="16dp"/>
<TableLayout
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:layout_alignParentRight="true"
android:layout_marginTop="10dp"
android:layout_marginLeft="5dp"
>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="5dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="校准基准时间:"
android:textColor="@color/white"
android:textStyle="bold"
android:gravity="center"
android:textSize="16dp"/>
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="5dp">
<EditText
android:id="@+id/edi_time"
android:minWidth="60dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textColor="@color/white"
android:backgroundTint="@color/colorAccent"/>
<Button
android:id="@+id/savetime"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:text="保存"
android:layout_gravity="center"
android:background="@drawable/btn_button"/>
</TableRow>
</TableLayout>



</RelativeLayout>



</LinearLayout>

+ 9
- 3
app/src/main/res/layout/from/layout/fragment_system_set.xml 查看文件

@@ -8,7 +8,11 @@
tools:context=".view.fragment.SystemSetFragment">
<TableLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content">
android:layout_height="match_parent"
android:layout_marginTop="10dp"
android:layout_marginRight="5dp"
android:background="@drawable/lcbg_border"
>
<Button
android:id="@+id/stparameter"
android:text="系统参数"
@@ -18,17 +22,19 @@
/>
<Button
android:id="@+id/lcparameter"
android:text="料仓设置"
android:text="料仓校准"
android:background="@drawable/settingbutton"
android:layout_margin="10dp"
android:textColor="@color/white"
/>

</TableLayout>

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_margin="10dp">
android:layout_marginTop="10dp"
android:background="@drawable/lcbg_border">
<FrameLayout
android:id="@+id/fragment_container"
android:layout_width="match_parent"


二進制
查看文件


二進制
查看文件


+ 1
- 0
app/src/main/res/values/colors.xml 查看文件

@@ -16,6 +16,7 @@

<resources>
<color name="test">#FF061B51</color>
<color name="setting">#FF061B51</color>
<color name="colorPrimary">#0A1026</color>
<color name="colorPrimaryDark">#0A1026</color>
<color name="colorAccent">#F57F17</color>


Loading…
取消
儲存