Browse Source

现场调试改动

master
fyf 1 year ago
parent
commit
666f851284
21 changed files with 659 additions and 396 deletions
  1. +2
    -2
      app/src/main/java/com/example/bpa/MainActivity.java
  2. +41
    -15
      app/src/main/java/com/example/bpa/app/BusinessServer.java
  3. +51
    -40
      app/src/main/java/com/example/bpa/app/DeviceData.java
  4. +39
    -1
      app/src/main/java/com/example/bpa/app/ICSApp.java
  5. +51
    -32
      app/src/main/java/com/example/bpa/app/ModbusTcpServer.java
  6. +2
    -2
      app/src/main/java/com/example/bpa/helper/RTrig.java
  7. +1
    -1
      app/src/main/java/com/example/bpa/view/fragment/setting/Fragment_lcparameter.java
  8. +61
    -56
      app/src/main/java/com/example/bpa/view/from/dzcjy_activity.java
  9. +46
    -98
      app/src/main/java/com/example/bpa/view/from/lcsz_activity.java
  10. +119
    -44
      app/src/main/java/com/example/bpa/view/from/lsjy_activity.java
  11. +142
    -78
      app/src/main/java/com/example/bpa/view/from/zdqx_activity.java
  12. +2
    -2
      app/src/main/res/layout/datatab/layout/sp_item.xml
  13. +1
    -1
      app/src/main/res/layout/from/layout/activity_add_pf.xml
  14. +11
    -0
      app/src/main/res/layout/from/layout/activity_dzcjy.xml
  15. +67
    -3
      app/src/main/res/layout/from/layout/activity_lsjy.xml
  16. +3
    -0
      app/src/main/res/layout/from/layout/activity_systemparameter.xml
  17. +2
    -2
      app/src/main/res/layout/from/layout/activity_yfpf.xml
  18. +9
    -1
      app/src/main/res/layout/from/layout/activity_zdqx.xml
  19. +1
    -6
      app/src/main/res/layout/from/layout/fragment_home.xml
  20. +6
    -12
      app/src/main/res/layout/item/layout/maingoods.xml
  21. +2
    -0
      app/src/main/res/values/styles.xml

+ 2
- 2
app/src/main/java/com/example/bpa/MainActivity.java View File

@@ -70,8 +70,8 @@ public class MainActivity extends FragmentActivity implements View.OnClickListen
ColseMain= findViewById(R.id.ColseMain);
fragment_container= findViewById(R.id.fragment_container);
clist_title.setText(ConfigName.getInstance().Shop_Name);
//ShowFragment(homeFragment,"系统主页");
ShowFragment(systemCapabilitiesFragment,"功能菜单");
ShowFragment(homeFragment,"系统主页");
//ShowFragment(systemCapabilitiesFragment,"功能菜单");
DataBus.getInstance().UpdateMainGoods();
}
/**


+ 41
- 15
app/src/main/java/com/example/bpa/app/BusinessServer.java View File

@@ -1,5 +1,6 @@
package com.example.bpa.app;

import com.example.bpa.Model.IRun;
import com.example.bpa.Model.IRunT;
import com.example.bpa.Model.IThread;
import com.example.bpa.Model.IWriteCallBack;
@@ -71,32 +72,57 @@ public class BusinessServer {
List<BPA_SILOS> bss = QueryDB.GetSolisByMaterialID(entry.getValue().get(m).materialID);
//GetsugarId
for (int x = 0; x < bss.size(); x++) {
if (DeviceData.Get().getCallCurrentWeight(bss.get(x).num) >= (float) entry.getValue().get(m).value) {
//if (DeviceData.Get().getCallCurrentWeight(bss.get(x).num) >= (float) entry.getValue().get(m).value) {
MessageLog.ShowInfo("下发【" + bss.get(x).num + "】号料仓PLC控制命令,需求量:=" + entry.getValue().get(m).value);
DeviceData.Get().setDemandValue((short) entry.getValue().get(m).value, bss.get(x).num, null);
DeviceData.Get().setDemandValue((short) entry.getValue().get(m).value, bss.get(x).num, new IWriteCallBack() {
@Override
public void onSuccess() {
MessageLog.ShowInfo("下发物料成功!");
}

@Override
public void onFailure(String ErrorMsg) {
MessageLog.ShowInfo("下发物料失败!");
}
});
//}
}

DeviceData.Get().setChargeMixtureStart(new IWriteCallBack() {
@Override
public void onSuccess() {
MessageLog.ShowInfo("启动配料成功!");
}

@Override
public void onFailure(String ErrorMsg) {
MessageLog.ShowInfo("启动配料失败!");
}
});//启动配料
final boolean[] IsComplete = {false};
DeviceData.Get().OnChargeMixtureCompleteNotify = new IRun() {
@Override
public void Run() {
IsComplete[0] = true;
MessageLog.ShowInfo("通道配料完成!");
}
};

while (!IsComplete[0]) {
Thread.sleep(100);
}
MessageLog.ShowInfo("步骤【" + entry.getKey() + "】执行完成");
}
//2.果糖
else if (materialType == 2) {
BPA_SUGAR bs = QueryDB.GetsugarId(entry.getValue().get(m).materialID);
ModbusTcpServer.get().WriteBool(bs.plcvar, true);
Thread.sleep(500);
ModbusTcpServer.get().WriteBool(bs.plcvar, false);
MessageLog.ShowInfo("步骤【" + entry.getKey() + "】下发"+entry.getValue().get(m).materialName+"执行完成");
}
}
DeviceData.Get().setChargeMixtureStart(null);//启动配料
final boolean[] IsComplete = {false};
DeviceData.Get().OnChargeMixtureComNotPar = new IRunT() {
@Override
public void Run(Object o) {
IsComplete[0] = true;
MessageLog.ShowInfo("通道【" + o + "】配料完成!");
}
};

while (!IsComplete[0]) {
Thread.sleep(100);
}
MessageLog.ShowInfo("步骤【" + entry.getKey() + "】执行完成");
}
MessageLog.ShowInfo("配方执行完成");
}


+ 51
- 40
app/src/main/java/com/example/bpa/app/DeviceData.java View File

@@ -73,39 +73,39 @@ public class DeviceData {
}
});

// //获取称当前重量
// ModbusTcpServer.get().ReadInt("VD260", 9, ints -> {
// for (int i = 0; i < ints.length; i++) {
// CallCurrentWeight.put(i + 1, ints[i]);
// }
// });
//
// //获取校准基准时间
// ModbusTcpServer.get().ReadInt("VD124", 1, ints -> {
// CalibrationReferenceTime = ints[0];
// });
//
// //获取清洗参数
// ModbusTcpServer.get().ReadShort("VW140", 4, shorts -> {
// DrainageTime = shorts[0];
// AddCleaningAgentTime = shorts[1];
// InletTime = shorts[2];
// CyclicCleaningTime = shorts[3];
// });
//
// //获取清洗参数
// ModbusTcpServer.get().ReadBool("M6.5", 1, booleans -> {
// WeightCalibrationMode = booleans[0];
// });
//
// //配料完成 M0.3
// CompleteListen("M0.3", "配料完成", OnChargeMixtureCompleteNotify);
//
// //清洗完成 M0.6
// CompleteListen("M0.6", "清洗完成", OnCleaningCompleteNotify);
//
// //去皮完成 M1.3
// CompleteListen("M1.3", "去皮完成", OnPeelingCompleteNotify);
//获取称当前重量
ModbusTcpServer.get().ReadInt("VD260", 9, ints -> {
for (int i = 0; i < ints.length; i++) {
CallCurrentWeight.put(i + 1, ints[i]);
}
});
//获取校准基准时间
ModbusTcpServer.get().ReadInt("VD124", 1, ints -> {
CalibrationReferenceTime = ints[0];
});
//获取清洗参数
ModbusTcpServer.get().ReadShort("VW140", 4, shorts -> {
DrainageTime = shorts[0];
AddCleaningAgentTime = shorts[1];
InletTime = shorts[2];
CyclicCleaningTime = shorts[3];
});
//获取清洗参数
ModbusTcpServer.get().ReadBool("M6.5", 1, booleans -> {
WeightCalibrationMode = booleans[0];
});
//配料完成 M0.3
CompleteListen("M0.3", "配料完成", OnChargeMixtureCompleteNotify);
//清洗完成 M0.6
CompleteListen("M0.6", "清洗完成", OnCleaningCompleteNotify);
//去皮完成 M1.3
CompleteListen("M1.3", "去皮完成", OnPeelingCompleteNotify);

Thread.sleep(10);
}
@@ -213,7 +213,18 @@ public class DeviceData {
*/
public void setChCalibrationSwitch(boolean value, int ch, IWriteCallBack callback) {
if (ch >= 1 && ch <= 10) {
String add = ModbusTcpServer.get().getBitSingleAdd("M", 2, ch);
String add="";
if(ch==9)
{
add="M03.0";
}else if(ch==10)
{
add="M03.1";
}else
{
add = ModbusTcpServer.get().getBitSingleAdd("M", 2, ch);
}

if (add.length() > 0)
ModbusTcpServer.get().WriteBool(add, value, callback);
}
@@ -443,9 +454,9 @@ public class DeviceData {
* @param ch 需要获取的通道号,称1--称9
* @return
*/
public float getCallCurrentWeight(int ch) {
public int getCallCurrentWeight(int ch) {
if (!CallCurrentWeight.containsKey(ch)) {
return 0.0f;
return 0;
}
return CallCurrentWeight.get(ch);
}
@@ -457,21 +468,21 @@ public class DeviceData {
*
* @param value 需要写入的值
*/
public void setCalibrationReferenceTime(float value, IWriteCallBack callback) {
ModbusTcpServer.get().WriteFloat("VD124", value, callback);
public void setCalibrationReferenceTime(int value, IWriteCallBack callback) {
ModbusTcpServer.get().WriteInt("VD124", value, callback);
}

/**
* 校准基准时间
*/
int CalibrationReferenceTime;
int CalibrationReferenceTime=0;

/**
* 获取校准基准时间
*
* @return
*/
public float getCalibrationReferenceTime() {
public int getCalibrationReferenceTime() {
return CalibrationReferenceTime;
}



+ 39
- 1
app/src/main/java/com/example/bpa/app/ICSApp.java View File

@@ -116,7 +116,6 @@ public class ICSApp extends Application {
sugar_B_5.plcvar = "M9.5";
sugar_B_9.plcvar = "M9.6";
sugar_B_2.plcvar = "M9.7";
sugar_A_1.plcvar = "M9.8";
QueryDB.AddSugar(sugar_A_1);
QueryDB.AddSugar(sugar_A_5);
QueryDB.AddSugar(sugar_A_9);
@@ -127,5 +126,44 @@ public class ICSApp extends Application {
QueryDB.AddSugar(sugar_B_2);
}
}
// for (BPA_SUGAR ite:QueryDB.GetSugarALL())
// {
// QueryDB.DeleteSugar(ite);
// }

// if (QueryDB.GetSugarALL().size() == 0) {
// BPA_SUGAR sugar_A_1 = new BPA_SUGAR();
// BPA_SUGAR sugar_A_5 = new BPA_SUGAR();
// BPA_SUGAR sugar_A_9 = new BPA_SUGAR();
// BPA_SUGAR sugar_A_2 = new BPA_SUGAR();
// BPA_SUGAR sugar_B_1 = new BPA_SUGAR();
// BPA_SUGAR sugar_B_5 = new BPA_SUGAR();
// BPA_SUGAR sugar_B_9 = new BPA_SUGAR();
// BPA_SUGAR sugar_B_2 = new BPA_SUGAR();
// sugar_A_1.sugarName = "果糖A_1";
// sugar_A_5.sugarName = "果糖A_5";
// sugar_A_9.sugarName = "果糖A_9";
// sugar_A_2.sugarName = "果糖A_2";
// sugar_B_1.sugarName = "果糖B_1";
// sugar_B_5.sugarName = "果糖B_5";
// sugar_B_9.sugarName = "果糖B_9";
// sugar_B_2.sugarName = "果糖B_2";
// sugar_A_1.plcvar = "M9.0";
// sugar_A_5.plcvar = "M9.1";
// sugar_A_9.plcvar = "M9.2";
// sugar_A_2.plcvar = "M9.3";
// sugar_B_1.plcvar = "M9.4";
// sugar_B_5.plcvar = "M9.5";
// sugar_B_9.plcvar = "M9.6";
// sugar_B_2.plcvar = "M9.7";
// QueryDB.AddSugar(sugar_A_1);
// QueryDB.AddSugar(sugar_A_5);
// QueryDB.AddSugar(sugar_A_9);
// QueryDB.AddSugar(sugar_A_2);
// QueryDB.AddSugar(sugar_B_1);
// QueryDB.AddSugar(sugar_B_5);
// QueryDB.AddSugar(sugar_B_9);
// QueryDB.AddSugar(sugar_B_2);
// }
}
}

+ 51
- 32
app/src/main/java/com/example/bpa/app/ModbusTcpServer.java View File

@@ -49,7 +49,7 @@ public class ModbusTcpServer {
if (address.length() > 0) {
address = address.trim();
if (address.toUpperCase().contains("M") && address.length() >= 4) {
String[] res = address.substring(1).split(".");
String[] res = address.substring(1).split("[.]");
if (res != null && res.length == 2) {
try {
int firstAdd = Integer.parseInt(res[0]);
@@ -126,6 +126,10 @@ public class ModbusTcpServer {
DeviceData.Get().Init();
//2.业务线程
BusinessServer.Get().Init();
//3.设置自动模式
DeviceData.Get().setHandOrAutoSwitch(true, null);
DeviceData.Get().setCleaningMode(false,null);//关闭自动清洗模式

}

@Override
@@ -239,8 +243,8 @@ public class ModbusTcpServer {
try {
ReadHoldingRegistersResponse res = ModbusTcpHelper.get().syncReadHoldingRegisters(1, add, length);
short[] data = res.getShortData();
if (data.length == length)
callback.onSuccess(data);
if (data.length == length){
if(callback!=null) callback.onSuccess(data);}
} catch (InterruptedException e) {
MessageLog.ShowError("ReadShort onFailure,Address=" + Address + ",length=" + length + ",msg:" + e.toString());
} catch (ExecutionException e) {
@@ -262,7 +266,9 @@ public class ModbusTcpServer {
boolean[] data = res.getBooleanData();
boolean[] result = Arrays.copyOfRange(data, 0, length);
if (result.length == length)
callback.onSuccess(result);
{
if(callback!=null)callback.onSuccess(result);
}
} catch (InterruptedException e) {
MessageLog.ShowError("ReadBool onFailure,Address=" + Address + ",length=" + length + ",msg:" + e.toString());
} catch (ExecutionException e) {
@@ -291,7 +297,9 @@ public class ModbusTcpServer {
tempValues[i] = BytesToFloat(tempData, DataFormat.ABCD);
}
if (tempValues.length == length)
callback.onSuccess(tempValues);
{
if(callback!=null)callback.onSuccess(tempValues);
}
} catch (InterruptedException e) {
MessageLog.ShowError("ReadFloat onFailure,Address=" + Address + ",length=" + length + ",msg:" + e.toString());
} catch (ExecutionException e) {
@@ -309,7 +317,7 @@ public class ModbusTcpServer {
int add = GetAddress(Address);
if (add < 0) return;
try {
ReadHoldingRegistersResponse res = ModbusTcpHelper.get().syncReadHoldingRegisters(1, add, length);
ReadHoldingRegistersResponse res = ModbusTcpHelper.get().syncReadHoldingRegisters(1, add, length*2);
byte[] data = res.getData();
int[] tempValues = new int[length];
for (int i = 0; i < length; i++) {
@@ -317,10 +325,18 @@ public class ModbusTcpServer {
for (int m = 0; m < 4; m++) {
tempData[m] = data[i * 4 + m];
}
tempValues[i] = BytesToInt(tempData, DataFormat.ABCD);
// Integer a1 = tempValues[i] = BytesToInt(tempData, DataFormat.ABCD);
// Integer a2 = tempValues[i] = BytesToInt(tempData, DataFormat.BADC);
// Integer a3 = tempValues[i] = BytesToInt(tempData, DataFormat.CDAB);
// Integer a4 = tempValues[i] = BytesToInt(tempData, DataFormat.DCBA);

tempValues[i] = BytesToInt(tempData, DataFormat.BADC);

}
if (tempValues.length == length)
callback.onSuccess(tempValues);
{
if(callback!=null)callback.onSuccess(tempValues);
}
} catch (InterruptedException e) {
MessageLog.ShowError("ReadInt onFailure,Address=" + Address + ",length=" + length + ",msg:" + e.toString());
} catch (ExecutionException e) {
@@ -341,22 +357,23 @@ public class ModbusTcpServer {
send[0] = Value;
try {
ModbusTcpHelper.get().syncWriteRegisters(1, add, send);
callback.onSuccess();
if(callback!=null)
callback.onSuccess();
} catch (InterruptedException e) {
MessageLog.ShowError("WriteShort onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
callback.onFailure(e.toString());
if(callback!=null)callback.onFailure(e.toString());
} catch (ExecutionException e) {
MessageLog.ShowError("WriteShort onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
callback.onFailure(e.toString());
if(callback!=null)callback.onFailure(e.toString());
} catch (ModbusTransportException e) {
MessageLog.ShowError("WriteShort onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
callback.onFailure(e.toString());
if(callback!=null)callback.onFailure(e.toString());
} catch (ModbusInitException e) {
MessageLog.ShowError("WriteShort onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
callback.onFailure(e.toString());
if(callback!=null)callback.onFailure(e.toString());
} catch (ModbusRespException e) {
MessageLog.ShowError("WriteShort onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
callback.onFailure(e.toString());
if(callback!=null)callback.onFailure(e.toString());
}
}

@@ -365,22 +382,23 @@ public class ModbusTcpServer {
if (add < 0) return;
try {
ModbusTcpHelper.get().syncWriteCoil(1, add, Value);
callback.onSuccess();
if (callback!=null)
callback.onSuccess();
} catch (InterruptedException e) {
MessageLog.ShowError("WriteBool onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
callback.onFailure(e.toString());
if (callback!=null)callback.onFailure(e.toString());
} catch (ExecutionException e) {
MessageLog.ShowError("WriteBool onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
callback.onFailure(e.toString());
if (callback!=null)callback.onFailure(e.toString());
} catch (ModbusTransportException e) {
MessageLog.ShowError("WriteBool onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
callback.onFailure(e.toString());
if (callback!=null)callback.onFailure(e.toString());
} catch (ModbusInitException e) {
MessageLog.ShowError("WriteBool onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
callback.onFailure(e.toString());
if (callback!=null)callback.onFailure(e.toString());
} catch (ModbusRespException e) {
MessageLog.ShowError("WriteBool onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
callback.onFailure(e.toString());
if (callback!=null)callback.onFailure(e.toString());
}
}

@@ -391,22 +409,23 @@ public class ModbusTcpServer {
short[] send = new short[]{(short) ((intBits >> 16) & 0xffff), (short) (intBits & 0xffff)};
try {
ModbusTcpHelper.get().syncWriteRegisters(1, add, send);
callback.onSuccess();

if(callback!=null)callback.onSuccess();
} catch (InterruptedException e) {
MessageLog.ShowError("WriteFloat onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
callback.onFailure(e.toString());
if(callback!=null)callback.onFailure(e.toString());
} catch (ExecutionException e) {
MessageLog.ShowError("WriteFloat onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
callback.onFailure(e.toString());
if(callback!=null)callback.onFailure(e.toString());
} catch (ModbusTransportException e) {
MessageLog.ShowError("WriteFloat onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
callback.onFailure(e.toString());
if(callback!=null)callback.onFailure(e.toString());
} catch (ModbusInitException e) {
MessageLog.ShowError("WriteFloat onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
callback.onFailure(e.toString());
if(callback!=null)callback.onFailure(e.toString());
} catch (ModbusRespException e) {
MessageLog.ShowError("WriteFloat onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
callback.onFailure(e.toString());
if(callback!=null)callback.onFailure(e.toString());
}
}

@@ -416,22 +435,22 @@ public class ModbusTcpServer {
short[] send = IntToShorts(Value);
try {
ModbusTcpHelper.get().syncWriteRegisters(1, add, send);
callback.onSuccess();
if(callback!=null)callback.onSuccess();
} catch (InterruptedException e) {
MessageLog.ShowError("WriteInt onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
callback.onFailure(e.toString());
if(callback!=null)callback.onFailure(e.toString());
} catch (ExecutionException e) {
MessageLog.ShowError("WriteInt onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
callback.onFailure(e.toString());
if(callback!=null)callback.onFailure(e.toString());
} catch (ModbusTransportException e) {
MessageLog.ShowError("WriteInt onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
callback.onFailure(e.toString());
if(callback!=null)callback.onFailure(e.toString());
} catch (ModbusInitException e) {
MessageLog.ShowError("WriteInt onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
callback.onFailure(e.toString());
if(callback!=null)callback.onFailure(e.toString());
} catch (ModbusRespException e) {
MessageLog.ShowError("WriteInt onFailure,Address=" + Address + ",length=" + Value + ",msg:" + e.toString());
callback.onFailure(e.toString());
if(callback!=null)callback.onFailure(e.toString());
}
}



+ 2
- 2
app/src/main/java/com/example/bpa/helper/RTrig.java View File

@@ -22,8 +22,8 @@ public class RTrig {
private RTrig() {
}

private boolean flag;
private boolean Q;
private boolean flag=false;
private boolean Q=false;

public boolean getQ() {
return Q;


+ 1
- 1
app/src/main/java/com/example/bpa/view/fragment/setting/Fragment_lcparameter.java View File

@@ -129,7 +129,7 @@ public class Fragment_lcparameter extends Fragment implements CompoundButton.On
try {
String stime = timeText.getText().toString();
if(stime.equals("")){return;}
Float ftime = Float.parseFloat(stime);
int ftime =Integer.parseInt(stime);
DeviceData.Get().setCalibrationReferenceTime(ftime,new IWriteCallBack() {
@Override
public void onSuccess() {


+ 61
- 56
app/src/main/java/com/example/bpa/view/from/dzcjy_activity.java View File

@@ -41,7 +41,7 @@ public class dzcjy_activity extends AppCompatActivity implements View.OnClickLis
* out_switch:称重模块校准
* marialmode_switch:出口称重模块校准
*/
Switch out_switch,marialmode_switch;
Switch out_switch, marialmode_switch;
/**
* mwSave_button:物料砝码值保存
* owSave_button:出口砝码值保存
@@ -50,16 +50,17 @@ public class dzcjy_activity extends AppCompatActivity implements View.OnClickLis
* zeroweight_button:重量清零
* outWrite_button:出口砝码值写入
* zerocalibration_button:零点校准
* allcalibration_button:一键去皮
*/
Button mwSave_button,owSave_button,materilwrite_button,calibration_button,zeroweight_button,outWrite_button,zerocalibration_button;
Button mwSave_button, owSave_button, materilwrite_button, calibration_button, zeroweight_button, outWrite_button, zerocalibration_button, allcalibration_button;

EditText materialweight_edit,outweight_edit;
EditText materialweight_edit, outweight_edit;

Spinner values_spinner;

EditText mode_1_realvalue,mode_2_realvalue,mode_3_realvalue,mode_4_realvalue,mode_5_realvalue,mode_6_realvalue,mode_7_realvalue,mode_8_realvalue,mode_out_realvalue;
EditText mode_1_realvalue, mode_2_realvalue, mode_3_realvalue, mode_4_realvalue, mode_5_realvalue, mode_6_realvalue, mode_7_realvalue, mode_8_realvalue, mode_out_realvalue;

Map<String,Integer> datamaps = new LinkedHashMap<String,Integer>();
Map<String, Integer> datamaps = new LinkedHashMap<String, Integer>();

//endregion

@@ -80,11 +81,11 @@ public class dzcjy_activity extends AppCompatActivity implements View.OnClickLis
/**
* 初始化
*/
private void Init(){
private void Init() {
gongneng_fanhui = this.findViewById(R.id.gongneng_fanhui);
gongneng_title = this.findViewById(R.id.gongneng_title);
//通过Activity.getIntent()获取当前页面接收到的Intent。 getXxxExtra方法获取Intent传递过来的数据
String msg=getIntent().getStringExtra("data");
String msg = getIntent().getStringExtra("data");
gongneng_title.setText(msg);
//edittext
materialweight_edit = this.findViewById(R.id.materialweight_edit);
@@ -102,6 +103,7 @@ public class dzcjy_activity extends AppCompatActivity implements View.OnClickLis
zerocalibration_button = this.findViewById(R.id.zerocalibration_button);

values_spinner = this.findViewById(R.id.values_spinner);
allcalibration_button = this.findViewById(R.id.allcalibration_button);
//edit
mode_1_realvalue = this.findViewById(R.id.mode_1_realvalue);
mode_2_realvalue = this.findViewById(R.id.mode_2_realvalue);
@@ -114,14 +116,14 @@ public class dzcjy_activity extends AppCompatActivity implements View.OnClickLis
mode_out_realvalue = this.findViewById(R.id.mode_out_realvalue);


datamaps.put("称重_1",1);
datamaps.put("称重_2",2);
datamaps.put("称重_3",3);
datamaps.put("称重_4",4);
datamaps.put("称重_5",5);
datamaps.put("称重_6",6);
datamaps.put("称重_7",7);
datamaps.put("称重_8",8);
datamaps.put("称重_1", 1);
datamaps.put("称重_2", 2);
datamaps.put("称重_3", 3);
datamaps.put("称重_4", 4);
datamaps.put("称重_5", 5);
datamaps.put("称重_6", 6);
datamaps.put("称重_7", 7);
datamaps.put("称重_8", 8);


}
@@ -130,7 +132,7 @@ public class dzcjy_activity extends AppCompatActivity implements View.OnClickLis
* 初始化按钮事件
*/
private void initEvents() {
gongneng_fanhui.setOnClickListener(new View.OnClickListener() {
gongneng_fanhui.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
dzcjy_activity.this.finish();
@@ -143,7 +145,7 @@ public class dzcjy_activity extends AppCompatActivity implements View.OnClickLis
zeroweight_button.setOnClickListener(this);
outWrite_button.setOnClickListener(this);
zerocalibration_button.setOnClickListener(this);
allcalibration_button.setOnClickListener(this);
out_switch.setOnCheckedChangeListener(this);
marialmode_switch.setOnCheckedChangeListener(this);

@@ -171,7 +173,7 @@ public class dzcjy_activity extends AppCompatActivity implements View.OnClickLis
/**
* 监听外部数据变化
*/
private void startListening(){
private void startListening() {
new Thread(new Runnable() {
@Override
public void run() {
@@ -188,13 +190,13 @@ public class dzcjy_activity extends AppCompatActivity implements View.OnClickLis
mode_6_realvalue.setText(String.valueOf(DeviceData.Get().getCallCurrentWeight(6)));
mode_7_realvalue.setText(String.valueOf(DeviceData.Get().getCallCurrentWeight(7)));
mode_8_realvalue.setText(String.valueOf(DeviceData.Get().getCallCurrentWeight(8)));
mode_out_realvalue.setText(String.valueOf(DeviceData.Get().getCallCurrentWeight(9)));
mode_out_realvalue.setText(String.valueOf(DeviceData.Get().getCallCurrentWeight(9)/10.0));
}
});

Thread.sleep(500);

}catch (Exception e) {
} catch (Exception e) {

}
}
@@ -205,52 +207,58 @@ public class dzcjy_activity extends AppCompatActivity implements View.OnClickLis
//endregion

//region 点击事件

/**
* 本页面需要写入plc的点击事件监听
* 开启新线程,防止阻塞UI线程
*
* @param v
*/
@Override
public void onClick(View v) {
new Thread(() -> {
switch (v.getId()) {
case R.id.mwSave_button://物料砝码值保存
String mwres = materialweight_edit.getText().toString().trim();
if(!mwres.equals("")){
DeviceData.Get().setCalibrationWeight(Short.parseShort(mwres),null);
}
break;
case R.id.owSave_button://出口砝码值保存
String outres = outweight_edit.getText().toString().trim();
if(!outres.equals("")){
DeviceData.Get().setCalibrationWeight9(Short.parseShort(outres),null);
}
break;
case R.id.materilwrite_button://物料砝码值写入
String s = String.valueOf(values_spinner.getSelectedItem()) ;
Integer value = datamaps.get(s);
DeviceData.Get().setWeightValue(true,value,null);
break;
case R.id.calibration_button://物料校准
String s2 = String.valueOf(values_spinner.getSelectedItem()) ;
Integer value2 = datamaps.get(s2);
DeviceData.Get().setRemovePeelCalibration(true,value2,null);
break;
case R.id.zeroweight_button://重量清零
DeviceData.Get().setWeightClear(null);
break;
case R.id.outWrite_button://出口砝码值写入
DeviceData.Get().setWeightValueWrite(null);
break;
case R.id.zerocalibration_button://零点校准
DeviceData.Get().setZeroPointCalibration(null);
break;

}}).start();
case R.id.mwSave_button://物料砝码值保存
String mwres = materialweight_edit.getText().toString().trim();
if (!mwres.equals("")) {
DeviceData.Get().setCalibrationWeight(Short.parseShort(mwres), null);
}
break;
case R.id.owSave_button://出口砝码值保存
String outres = outweight_edit.getText().toString().trim();
if (!outres.equals("")) {
DeviceData.Get().setCalibrationWeight9(Short.parseShort(outres), null);
}
break;
case R.id.materilwrite_button://物料砝码值写入
String s = String.valueOf(values_spinner.getSelectedItem());
Integer value = datamaps.get(s);
DeviceData.Get().setWeightValue(true, value, null);
break;
case R.id.calibration_button://物料校准
String s2 = String.valueOf(values_spinner.getSelectedItem());
Integer value2 = datamaps.get(s2);
DeviceData.Get().setRemovePeelCalibration(true, value2, null);
break;
case R.id.zeroweight_button://重量清零
DeviceData.Get().setWeightClear(null);
break;
case R.id.outWrite_button://出口砝码值写入
DeviceData.Get().setWeightValueWrite(null);
break;
case R.id.zerocalibration_button://零点校准
DeviceData.Get().setZeroPointCalibration(null);
break;
case R.id.allcalibration_button://一件去皮
DeviceData.Get().setOneClickPeeling(null);
break;

}
}).start();


}

/**
* 本页面switch点击事件监听
*
@@ -290,7 +298,4 @@ public class dzcjy_activity extends AppCompatActivity implements View.OnClickLis
}
}
//endregion

//按钮写入plc

}

+ 46
- 98
app/src/main/java/com/example/bpa/view/from/lcsz_activity.java View File

@@ -52,7 +52,6 @@ public class lcsz_activity extends AppCompatActivity implements View.OnClickList
* 标题设置
*/
TextView gongneng_title;
//endregion
RecyclerView recyclerView;
//物料listview
ListView materiallist;
@@ -64,6 +63,7 @@ public class lcsz_activity extends AppCompatActivity implements View.OnClickList
lc_item_adapter.MyLCViewHolder currentSilo;
//当前料仓集合
List<lcMode> datas = new ArrayList<lcMode>();
//endregion

//region 私有函数
@Override
@@ -225,112 +225,60 @@ public class lcsz_activity extends AppCompatActivity implements View.OnClickList
//endregion

//region 线程

/**
* 实时显示线程
*/
public void Run() {

ThreadManager.Get().StartLong("更新料仓数据", true, new IThread() {
new Thread(new Runnable() {
@Override
public void Run() throws InterruptedException {
lcsz_activity.this.runOnUiThread(new Runnable() {
@Override
public void run() {

for (int i = 0; i < datas.size(); i++) {
int num = datas.get(i).num;
float val = DeviceData.Get().getCallCurrentWeight(num);
RecyclerView.ViewHolder viewHolder = recyclerView.findViewHolderForAdapterPosition(i);
if (viewHolder != null) {
lc_item_adapter.MyLCViewHolder hold = (lc_item_adapter.MyLCViewHolder) viewHolder;
//hold.silosmargin.setText(new java.text.DecimalFormat("#.00").format(val)+"g");
hold.silosmargin.setText(val + "g");

if (!datas.get(i).materialId.isEmpty()) {
if (val < datas.get(i).warningValue)//补料
{
hold.image_yj.setVisibility(View.VISIBLE);
} else {
hold.image_yj.setVisibility(View.GONE);
FlashHelper.getInstance().stopFlick(hold.image_yj);
}

if (val < datas.get(i).thrsoleValue)//告警
{
hold.image_gj.setVisibility(View.VISIBLE);
} else {
hold.image_gj.setVisibility(View.GONE);
FlashHelper.getInstance().stopFlick(hold.image_gj);
public void run() {
while (DataBus.getInstance().PlcIsConnect) {
try {
lcsz_activity.this.runOnUiThread(new Runnable() {
@Override
public void run() {

for (int i = 0; i < datas.size(); i++) {
int num = datas.get(i).num;
int val = DeviceData.Get().getCallCurrentWeight(num);
RecyclerView.ViewHolder viewHolder = recyclerView.findViewHolderForAdapterPosition(i);
if (viewHolder != null) {
lc_item_adapter.MyLCViewHolder hold = (lc_item_adapter.MyLCViewHolder) viewHolder;
//hold.silosmargin.setText(new java.text.DecimalFormat("#.00").format(val)+"g");
hold.silosmargin.setText(val + "g");

if (!datas.get(i).materialId.isEmpty()) {
if (val < datas.get(i).warningValue)//补料
{
hold.image_yj.setVisibility(View.VISIBLE);
} else {
hold.image_yj.setVisibility(View.GONE);
FlashHelper.getInstance().stopFlick(hold.image_yj);
}

if (val < datas.get(i).thrsoleValue)//告警
{
hold.image_gj.setVisibility(View.VISIBLE);
} else {
hold.image_gj.setVisibility(View.GONE);
FlashHelper.getInstance().stopFlick(hold.image_gj);
}
} else {
hold.image_yj.setVisibility(View.GONE);
hold.image_gj.setVisibility(View.GONE);
hold.stopFlick();
}
}
} else {
hold.image_yj.setVisibility(View.GONE);
hold.image_gj.setVisibility(View.GONE);
hold.stopFlick();
}
}
}
});
Thread.sleep(1000);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
});
Thread.sleep(1000);
}

@Override
public void RunComplete() throws InterruptedException {

}
}
});
// new Thread(new Runnable() {
// @Override
// public void run() {
// while (DataBus.getInstance().PlcIsConnect) {
// try {
// lcsz_activity.this.runOnUiThread(new Runnable() {
// @Override
// public void run() {
//
// for (int i = 0; i < datas.size(); i++) {
// int num = datas.get(i).num;
// float val = DeviceData.Get().getCallCurrentWeight(num);
// RecyclerView.ViewHolder viewHolder = recyclerView.findViewHolderForAdapterPosition(i);
// if (viewHolder != null) {
// lc_item_adapter.MyLCViewHolder hold = (lc_item_adapter.MyLCViewHolder) viewHolder;
// //hold.silosmargin.setText(new java.text.DecimalFormat("#.00").format(val)+"g");
// hold.silosmargin.setText(val + "g");
//
// if (!datas.get(i).materialId.isEmpty()) {
// if (val < datas.get(i).warningValue)//补料
// {
// hold.image_yj.setVisibility(View.VISIBLE);
// } else {
// hold.image_yj.setVisibility(View.GONE);
// FlashHelper.getInstance().stopFlick(hold.image_yj);
// }
//
// if (val < datas.get(i).thrsoleValue)//告警
// {
// hold.image_gj.setVisibility(View.VISIBLE);
// } else {
// hold.image_gj.setVisibility(View.GONE);
// FlashHelper.getInstance().stopFlick(hold.image_gj);
// }
// }else
// {
// hold.image_yj.setVisibility(View.GONE);
// hold.image_gj.setVisibility(View.GONE);
// hold.stopFlick();
// }
// }
// }
// }
// });
// Thread.sleep(1000);
// } catch (InterruptedException e) {
// throw new RuntimeException(e);
// }
// }
// }
// }).start();
}).start();
}
//endreion
//endregion
}

+ 119
- 44
app/src/main/java/com/example/bpa/view/from/lsjy_activity.java View File

@@ -1,6 +1,7 @@
package com.example.bpa.view.from;

import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.RecyclerView;

import android.graphics.Color;
import android.os.Bundle;
@@ -14,13 +15,18 @@ import android.widget.ListView;
import android.widget.Switch;
import android.widget.TextView;

import com.example.bpa.Model.IThread;
import com.example.bpa.Model.IWriteCallBack;
import com.example.bpa.R;
import com.example.bpa.app.DeviceData;
import com.example.bpa.config.DataBus;
import com.example.bpa.db.QueryDB;
import com.example.bpa.db.mode.BPA_MATERIAL;
import com.example.bpa.db.mode.BPA_SILOS;
import com.example.bpa.helper.FlashHelper;
import com.example.bpa.helper.T;
import com.example.bpa.helper.ThreadManager;
import com.example.bpa.view.adapter.lc_item_adapter;
import com.example.bpa.view.adapter.lsjy_adapter;
import com.example.bpa.view.adapter.wl_adapter;
import com.example.bpa.view.inteface.MyClickListener;
@@ -57,6 +63,10 @@ public class lsjy_activity extends AppCompatActivity implements View.OnClickList
Button StartButton;
//保存
Button SaveButton;
//清零
Button ClearText;
//重量
TextView zhongliang;
//endregion

//region 私有函数
@@ -67,7 +77,21 @@ public class lsjy_activity extends AppCompatActivity implements View.OnClickList
Init();
initEvents();
Initdata();
Run();
}

@Override
protected void onDestroy() {

try {
//设置自动模式
DeviceData.Get().setHandOrAutoSwitch(true, null);
} catch (Exception e) {

}
super.onDestroy();
}

//endregion

//region 公共函数
@@ -111,6 +135,9 @@ public class lsjy_activity extends AppCompatActivity implements View.OnClickList
StartButton = findViewById(R.id.StartButton);
timeText = findViewById(R.id.edi_time);
SaveButton = findViewById(R.id.savetime);

ClearText = findViewById(R.id.ClearText);
zhongliang = findViewById(R.id.zhongliang);
}

/**
@@ -120,6 +147,7 @@ public class lsjy_activity extends AppCompatActivity implements View.OnClickList
gongneng_fanhui.setOnClickListener(this);
StartButton.setOnClickListener(this);
SaveButton.setOnClickListener(this);
ClearText.setOnClickListener(this);
//switch
// Switch_1.setOnCheckedChangeListener(this);
// Switch_2.setOnCheckedChangeListener(this);
@@ -146,6 +174,9 @@ public class lsjy_activity extends AppCompatActivity implements View.OnClickList
String time = String.valueOf(DeviceData.Get().getCalibrationReferenceTime());
//校准时间
timeText.setText(time);

//设置手动模式
DeviceData.Get().setHandOrAutoSwitch(false, null);
} catch (Exception e) {

}
@@ -166,35 +197,31 @@ public class lsjy_activity extends AppCompatActivity implements View.OnClickList
this.finish();
break;
case R.id.savetime://校准基准时间保存
new Thread(new Runnable() {
String stime = timeText.getText().toString();
if (stime.equals("")) {
T.show(lsjy_activity.this, "校准基准时间不能为空!");
return;
}
int ftime = 0;
try {
ftime = Integer.parseInt(stime);
} catch (Exception e) {
T.show(lsjy_activity.this, "校准基准时间异常!" + e.getMessage());
return;
}

DeviceData.Get().setCalibrationReferenceTime(ftime, new IWriteCallBack() {
@Override
public void run() {
try {
String stime = timeText.getText().toString();
if (stime.equals("")) {
T.show(lsjy_activity.this, "校准基准时间不能为空!");
return;
}
Float ftime = Float.parseFloat(stime);
DeviceData.Get().setCalibrationReferenceTime(ftime, new IWriteCallBack() {
@Override
public void onSuccess() {
T.show(lsjy_activity.this, "校准时间写入成功");
}
public void onSuccess() {
T.show(lsjy_activity.this, "校准时间写入成功");
}

@Override
public void onFailure(String ErrorMsg) {
T.show(lsjy_activity.this, "校准时间写入失败");
}
});
} catch (ArithmeticException e) {
e.printStackTrace();
}
@Override
public void onFailure(String ErrorMsg) {
T.show(lsjy_activity.this, "校准时间写入失败");
}
});
break;
case R.id.StartButton://开始校准
//检验数据正确性

for (int i = 0; i < 10; i++) {
if (switchLists.get(i).isChecked() == true)//校准开关打开后,允许校准
{
@@ -212,8 +239,13 @@ public class lsjy_activity extends AppCompatActivity implements View.OnClickList
}
//写开关状态 数值
for (int i = 0; i < 10; i++) {
//1.写入开关状态
DeviceData.Get().setChCalibrationSwitch(switchLists.get(i).isChecked(), i + 1, new IWriteCallBack() {
String value = editTextLists.get(i).getText().toString();
Short val = 0;
try {
val = Short.parseShort(value);
} catch (Exception e) {
}
DeviceData.Get().setCalibrationValue(val, i + 1, new IWriteCallBack() {
@Override
public void onSuccess() {
}
@@ -222,25 +254,22 @@ public class lsjy_activity extends AppCompatActivity implements View.OnClickList
public void onFailure(String ErrorMsg) {
}
});
//2.校准开关打开后,允许校准
if (switchLists.get(i).isChecked() == true) {
String value = editTextLists.get(i).getText().toString();
Short val = 0;
try {
val = Short.parseShort(value);
} catch (Exception e) {
}
}

DeviceData.Get().setCalibrationValue(val, i + 1, new IWriteCallBack() {
@Override
public void onSuccess() {
}
break;
case R.id.StartButton://开始校准
//写开关状态 数值
for (int i = 0; i < 10; i++) {
//1.写入开关状态
DeviceData.Get().setChCalibrationSwitch(switchLists.get(i).isChecked(), i + 1, new IWriteCallBack() {
@Override
public void onSuccess() {
}

@Override
public void onFailure(String ErrorMsg) {
}
});
}
@Override
public void onFailure(String ErrorMsg) {
}
});
}
//写开始校准
DeviceData.Get().setChStartCalibration(new IWriteCallBack() {
@@ -248,14 +277,29 @@ public class lsjy_activity extends AppCompatActivity implements View.OnClickList
public void onSuccess() {
T.show(lsjy_activity.this, "通道开始校准");
}

@Override
public void onFailure(String ErrorMsg) {
T.show(lsjy_activity.this, "通道开始校准失败");
}
});
break;
case R.id.ClearText://清空称重重量
DeviceData.Get().setWeightClear(new IWriteCallBack() {
@Override
public void onSuccess() {
T.show(lsjy_activity.this, "清零成功");
}

@Override
public void onFailure(String ErrorMsg) {
T.show(lsjy_activity.this, "清零失败");
}
});
break;
}
}

/**
* 本页面switch点击事件监听
*
@@ -346,4 +390,35 @@ public class lsjy_activity extends AppCompatActivity implements View.OnClickList
T.show(lsjy_activity.this, sb.toString());
}
//endregion

//region 线程

/**
* 实时显示线程
*/
public void Run() {
new Thread(new Runnable() {
@Override
public void run() {
while (DataBus.getInstance().PlcIsConnect) {
try {
lsjy_activity.this.runOnUiThread(new Runnable() {
@Override
public void run() {
try {
zhongliang.setText(String.valueOf(DeviceData.Get().getCallCurrentWeight(9)/10.0)+" g");
} catch (Exception e) {

}
}
});
Thread.sleep(500);
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}
}).start();
}
//endregion
}

+ 142
- 78
app/src/main/java/com/example/bpa/view/from/zdqx_activity.java View File

@@ -17,13 +17,14 @@ 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.config.DataBus;
import com.example.bpa.db.QueryDB;
import com.example.bpa.helper.T;

/**
* 自动清洗
*/
public class zdqx_activity extends AppCompatActivity implements View.OnClickListener{
public class zdqx_activity extends AppCompatActivity implements View.OnClickListener {
//region 变量
/**
* 返回按钮
@@ -34,9 +35,9 @@ public class zdqx_activity extends AppCompatActivity implements View.OnClickList
*/
TextView gongneng_title;
//参数
EditText edit_pstime,edit_jstime,edit_jqxjtime,edit_xhtime;
EditText edit_pstime, edit_jstime, edit_jqxjtime, edit_xhtime;
//按钮
Button bt_save,bt_start;
Button bt_save, bt_start;
//switch
Switch qsmode;
//进度条
@@ -44,7 +45,7 @@ public class zdqx_activity extends AppCompatActivity implements View.OnClickList

// TextView progress_text;

boolean mValue = false;
boolean IsStart = false;
//endregion

//region 私有函数
@@ -57,6 +58,19 @@ public class zdqx_activity extends AppCompatActivity implements View.OnClickList
InitData();
startListening();
}

@Override
protected void onDestroy() {
try {
if(DataBus.getInstance().PlcIsConnect)
{
DeviceData.Get().setCleaningMode(false, null);//打开自动清洗模式
}
} catch (Exception e) {
}
super.onDestroy();
}

//endregion

//region 公共函数
@@ -64,7 +78,7 @@ public class zdqx_activity extends AppCompatActivity implements View.OnClickList
/**
* 初始化
*/
private void Init(){
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);
@@ -77,10 +91,8 @@ public class zdqx_activity extends AppCompatActivity implements View.OnClickList
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");
String msg = getIntent().getStringExtra("data");
gongneng_title.setText(msg);


}

/**
@@ -98,7 +110,19 @@ public class zdqx_activity extends AppCompatActivity implements View.OnClickList
@Override
public void run() {
try {
DeviceData.Get().setCleaningMode(isChecked,null);//设置清洗模式
DeviceData.Get().setCleaningMode(isChecked, null);//设置清洗模式
if (!isChecked) {
runOnUiThread(new Runnable() {
@Override
public void run() {
IsStart = false;
ProgressClose();
bt_start.setText("开始清洗");
k = 0;
}
});

}
} catch (Exception e) {
e.printStackTrace();
}
@@ -108,52 +132,81 @@ public class zdqx_activity extends AppCompatActivity implements View.OnClickList
});
}

private void InitData(){
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); // 将进度条设置为不确定状态

ProgressClose();
try {
if(DataBus.getInstance().PlcIsConnect) {
DeviceData.Get().setCleaningMode(false, null);//打开自动清洗模式
}
} catch (Exception e) {
}
}

/**
* 关闭进度条
*/
public void ProgressClose() {
progress_bar.setIndeterminate(true); // 将进度条设置为不确定状态
progress_bar.setProgress(100);
}

int k = 0;

/**
* 打开进度条
*/
public void ProgressStart() {
progress_bar.setIndeterminate(false);
progress_bar.setProgress(0);
IsStart = true;
k = 0;
}

/**
* 监听外部数据变化
*/
private void startListening(){
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) {

}
}
while (true) {
try {
if (IsStart) {
if (DeviceData.Get().getCleaningComplete()) {
runOnUiThread(new Runnable() {
@Override
public void run() {
IsStart = false;
ProgressClose();
bt_start.setText("开始清洗");
k = 0;
T.show(zdqx_activity.this, "清洗完成");
}
});
}
k++;
progress_bar.setProgress(k <= 100 ? k : 100);
}
Thread.sleep(1000);

} catch (Exception e) {

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

//region 点击事件

/**
* 本页面点击事件监听
*
@@ -161,85 +214,96 @@ public class zdqx_activity extends AppCompatActivity implements View.OnClickList
*/
@Override
public void onClick(View v) {
short ps = Short.parseShort(edit_pstime.getText().toString());
short js = Short.parseShort(edit_jstime.getText().toString());
short qxj = Short.parseShort(edit_jqxjtime.getText().toString());
switch (v.getId()) {
case R.id.gongneng_fanhui://返回按钮
this.finish();
break;
case R.id.bt_save://保存

if (qxj >= js || qxj >= ps) {
T.show(zdqx_activity.this, "加清洗剂时间不能大于进水时间!");
return;
}
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);
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);
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);
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);
DeviceData.Get().setCyclicCleaningTime(Short.parseShort(edit_xhtime.getText().toString()), null);
Thread.sleep(200);
}
}catch (InterruptedException e) {

}catch (Exception e) {
} catch (InterruptedException e) {

} catch (Exception e) {

}

}
}).start();
T.show(zdqx_activity.this, "保存成功!");
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) {
if (qxj >= js || qxj >= ps) {
T.show(zdqx_activity.this, "加清洗剂时间不能大于进水时间!");
return;
}
if (!qsmode.isChecked()) {
T.show(zdqx_activity.this, "请先打开清洗模式!");
return;
}

if (IsStart) {
T.show(zdqx_activity.this, "正在清洗中,请勿重复点击!");
return;
}
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() {
ProgressStart();
bt_start.setText("正在清洗");
}
});
}

@Override
public void onFailure(String ErrorMsg) {

}
});

}
} catch (Exception e) {

}
}).start();

}
}).start();
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;
}
}

+ 2
- 2
app/src/main/res/layout/datatab/layout/sp_item.xml View File

@@ -48,7 +48,7 @@
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5">
android:layout_weight="1">
<TextView
android:id="@+id/sort"
android:layout_width="wrap_content"
@@ -63,7 +63,7 @@
<RelativeLayout
android:layout_width="0dp"
android:layout_height="match_parent"
android:layout_weight="0.5">
android:layout_weight="1">
<TextView
android:id="@+id/status"
android:layout_width="wrap_content"


+ 1
- 1
app/src/main/res/layout/from/layout/activity_add_pf.xml View File

@@ -85,7 +85,7 @@
android:layout_height="match_parent"
android:orientation="vertical">
<LinearLayout
android:layout_marginTop="10dp"
android:layout_marginTop="0dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content">
<Spinner


+ 11
- 0
app/src/main/res/layout/from/layout/activity_dzcjy.xml View File

@@ -118,6 +118,8 @@
android:textColor="@color/white"
android:backgroundTint="@color/colorAccent"
android:theme="@style/MyEditText_num"
android:maxLines="1"
android:singleLine="true"
android:layout_margin="5dp"/>
<Button
android:id="@+id/mwSave_button"
@@ -155,6 +157,13 @@
android:background="@drawable/btn_greenblue"
android:text="去皮/校准"
android:layout_margin="5dp"/>
<Button
android:id="@+id/allcalibration_button"
android:layout_width="wrap_content"
android:layout_height="30dp"
android:background="@drawable/btn_greenblue"
android:text="一键去皮"
android:layout_margin="5dp"/>
</LinearLayout>
</LinearLayout>
<LinearLayout
@@ -189,6 +198,8 @@
android:textColor="@color/white"
android:backgroundTint="@color/colorAccent"
android:theme="@style/MyEditText_num"
android:maxLines="1"
android:singleLine="true"
android:layout_margin="5dp"/>
<Button
android:id="@+id/owSave_button"


+ 67
- 3
app/src/main/res/layout/from/layout/activity_lsjy.xml View File

@@ -76,6 +76,8 @@
android:layout_height="wrap_content"
android:layout_marginRight="15dp"
android:theme="@style/MyEditText_num"
android:maxLines="1"
android:singleLine="true"
android:textColor="@color/white"
android:backgroundTint="@color/colorAccent"/>
<Switch
@@ -98,6 +100,8 @@
android:minWidth="60dp"
android:layout_marginRight="15dp"
android:theme="@style/MyEditText_num"
android:maxLines="1"
android:singleLine="true"
android:textColor="@color/white"
android:backgroundTint="@color/colorAccent"/>
<Switch
@@ -126,6 +130,8 @@
android:layout_height="wrap_content"
android:layout_marginRight="15dp"
android:theme="@style/MyEditText_num"
android:maxLines="1"
android:singleLine="true"
android:textColor="@color/white"
android:backgroundTint="@color/colorAccent"/>
<Switch
@@ -148,6 +154,8 @@
android:minWidth="60dp"
android:layout_marginRight="15dp"
android:theme="@style/MyEditText_num"
android:maxLines="1"
android:singleLine="true"
android:textColor="@color/white"
android:backgroundTint="@color/colorAccent"/>
<Switch
@@ -176,6 +184,8 @@
android:layout_height="wrap_content"
android:layout_marginRight="15dp"
android:theme="@style/MyEditText_num"
android:maxLines="1"
android:singleLine="true"
android:textColor="@color/white"
android:backgroundTint="@color/colorAccent"/>
<Switch
@@ -198,6 +208,8 @@
android:minWidth="60dp"
android:layout_marginRight="15dp"
android:theme="@style/MyEditText_num"
android:maxLines="1"
android:singleLine="true"
android:textColor="@color/white"
android:backgroundTint="@color/colorAccent"/>
<Switch
@@ -226,6 +238,8 @@
android:layout_height="wrap_content"
android:layout_marginRight="15dp"
android:theme="@style/MyEditText_num"
android:maxLines="1"
android:singleLine="true"
android:textColor="@color/white"
android:backgroundTint="@color/colorAccent"/>
<Switch
@@ -248,6 +262,8 @@
android:minWidth="60dp"
android:layout_marginRight="15dp"
android:theme="@style/MyEditText_num"
android:maxLines="1"
android:singleLine="true"
android:textColor="@color/white"
android:backgroundTint="@color/colorAccent"/>
<Switch
@@ -276,6 +292,8 @@
android:layout_height="wrap_content"
android:layout_marginRight="15dp"
android:theme="@style/MyEditText_num"
android:maxLines="1"
android:singleLine="true"
android:textColor="@color/white"
android:backgroundTint="@color/colorAccent"/>
<Switch
@@ -298,6 +316,8 @@
android:minWidth="60dp"
android:layout_marginRight="15dp"
android:theme="@style/MyEditText_num"
android:maxLines="1"
android:singleLine="true"
android:textColor="@color/white"
android:backgroundTint="@color/colorAccent"/>
<Switch
@@ -312,6 +332,28 @@
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_marginLeft="100dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical">
<TextView
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="重量:"
android:textColor="@color/white"
android:textStyle="bold">
</TextView>
<TextView
android:id="@+id/zhongliang"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:text="0g"
android:textSize="40dp"
android:textColor="@color/color_purl"
android:textStyle="bold">
</TextView>
</LinearLayout>
<Button
android:id="@+id/StartButton"
android:layout_marginTop="10dp"
@@ -355,21 +397,43 @@
<EditText
android:id="@+id/edi_time"
android:minWidth="60dp"
android:layout_width="wrap_content"
android:layout_marginLeft="20dp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColor="@color/white"
android:backgroundTint="@color/colorAccent"
android:theme="@style/MyEditText_num"/>
android:theme="@style/MyEditText_num"
android:maxLines="1"
android:singleLine="true"/>
<Button
android:id="@+id/savetime"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="保存"
android:layout_gravity="center"
android:layout_marginLeft="25dp"
android:layout_marginLeft="5dp"
android:textColor="@color/white"
android:textSize="12dp"
android:textStyle="bold"
android:background="@drawable/settingbutton"/>
</TableRow>
<TableRow
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginRight="35dp">
<Button
android:id="@+id/ClearText"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="称重清零"
android:layout_marginLeft="20dp"
android:layout_marginRight="5dp"
android:layout_marginTop="10dp"
android:textColor="@color/white"
android:textSize="12dp"
android:textStyle="bold"
android:layout_weight="2"
android:background="@drawable/settingbutton"/>
</TableRow>
</TableLayout>


+ 3
- 0
app/src/main/res/layout/from/layout/activity_systemparameter.xml View File

@@ -208,6 +208,9 @@
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/MyEditText_num"

android:maxLines="1"
android:singleLine="true"
android:layout_marginRight="15dp"
android:text="0"
android:textColor="@color/white"


+ 2
- 2
app/src/main/res/layout/from/layout/activity_yfpf.xml View File

@@ -167,7 +167,7 @@
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.5">
android:layout_weight="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
@@ -180,7 +180,7 @@
<RelativeLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.5">
android:layout_weight="1">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"


+ 9
- 1
app/src/main/res/layout/from/layout/activity_zdqx.xml View File

@@ -134,6 +134,8 @@
android:layout_margin="5dp"
android:backgroundTint="@color/colorAccent"
android:theme="@style/MyEditText_num"
android:maxLines="1"
android:singleLine="true"
android:gravity="center"
android:minWidth="50dp"
android:textColor="@color/white" />
@@ -145,6 +147,8 @@
android:layout_margin="5dp"
android:backgroundTint="@color/colorAccent"
android:theme="@style/MyEditText_num"
android:maxLines="1"
android:singleLine="true"
android:gravity="center"
android:minWidth="50dp"
android:textColor="@color/white" />
@@ -188,6 +192,8 @@
android:layout_margin="5dp"
android:backgroundTint="@color/colorAccent"
android:theme="@style/MyEditText_num"
android:maxLines="1"
android:singleLine="true"
android:gravity="center"
android:minWidth="50dp"
android:textColor="@color/white" />
@@ -199,6 +205,8 @@
android:layout_margin="5dp"
android:backgroundTint="@color/colorAccent"
android:theme="@style/MyEditText_num"
android:maxLines="1"
android:singleLine="true"
android:gravity="center"
android:minWidth="50dp"
android:textColor="@color/white" />
@@ -226,7 +234,7 @@
<Switch
android:id="@+id/qsmode"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_height="match_parent"
android:background="@drawable/qs_switch"
android:layout_marginLeft="40dp"
android:text="清洗模式启动"


+ 1
- 6
app/src/main/res/layout/from/layout/fragment_home.xml View File

@@ -6,12 +6,9 @@
android:tag="系统主页"
tools:context=".view.fragment.HomeFragment">
<LinearLayout
android:layout_marginTop="20dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="20dp"
android:orientation="vertical">

<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
@@ -20,9 +17,7 @@
android:id="@+id/good_recyclerView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbarStyle="outsideOverlay"
>

android:scrollbarStyle="outsideOverlay">
</androidx.recyclerview.widget.RecyclerView>
</RelativeLayout>
<!-- <RelativeLayout-->


+ 6
- 12
app/src/main/res/layout/item/layout/maingoods.xml View File

@@ -1,7 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="180dp"
android:layout_height="130dp"
android:layout_width="200dp"
android:layout_height="140dp"
>
<LinearLayout
android:layout_width="match_parent"
@@ -45,24 +45,18 @@

<Button
android:id="@+id/goodmake"
android:layout_width="100dp"
android:layout_height="20dp"
android:layout_width="match_parent"
android:layout_height="30dp"
android:layout_gravity="center_vertical"
android:layout_alignParentBottom="true"
android:layout_alignParentRight="true"
android:layout_marginLeft="18dp"
android:layout_marginRight="18dp"
android:layout_marginBottom="23dp"
android:textColor="@color/white"
android:background="@drawable/ripple_goods"
android:text="make" />
android:text="制作" />
</RelativeLayout>





</RelativeLayout>


</LinearLayout>
</LinearLayout>

+ 2
- 0
app/src/main/res/values/styles.xml View File

@@ -167,6 +167,8 @@
</style>
<style name="MyEditText_num" parent="Theme.AppCompat.Light">
<item name="android:imeOptions">flagNoFullscreen</item>
<item name="maxLines">1</item>
<item name="singleLine">true</item>
</style>

<style name="Widget.AppTheme.ButtonBar.Fullscreen" parent="">


Loading…
Cancel
Save