Browse Source

23232

调味吧台
fyf 1 year ago
parent
commit
589c93f4da
3 changed files with 142 additions and 81 deletions
  1. +2
    -0
      app/src/main/java/com/example/bpa/service/BusinessServer.java
  2. +0
    -1
      app/src/main/java/com/example/bpa/view/fragment/HomeFragment.java
  3. +140
    -80
      app/src/main/java/com/example/bpa/view/from/lsjy_activity.java

+ 2
- 0
app/src/main/java/com/example/bpa/service/BusinessServer.java View File

@@ -61,6 +61,7 @@ public class BusinessServer {
* @param info 配方信息
*/
public void AddCommodity(BPA_SUBORDER info) {
DeviceData.Get().setHandOrAutoSwitch(true, null);
//2.数据中心添加制作队列商品数据
DataBus.getInstance().AddGoodsMake(info);
//1.添加制作队列
@@ -79,6 +80,7 @@ public class BusinessServer {
BPA_SUBORDER suborder = Commoditys.peek();
String GoodId = suborder.goodsID;
try {

// boolean IsMake=true;
ResultA resultA = DataBus.getInstance().InspectMaterial(GoodId);
// if(resultA.IsMake==false)//如果商品物料不足


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

@@ -310,7 +310,6 @@ public class HomeFragment extends Fragment implements View.OnClickListener, MyCl
wendu2.setText(String.valueOf(DeviceData.Get().getJRX_FructoseTemperature()) + "°C");
plc_status.setText(DataBus.getInstance().PlcIsConnect?"正常":"异常");
// plc_status.setTextColor(DataBus.getInstance().PlcIsConnect?getResources().getColor(R.color.foreground):getResources().getColor(R.color.warm_red));

}
});
Thread.sleep(100);


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

@@ -3,6 +3,7 @@ package com.example.bpa.view.from;
import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.os.Handler;
import android.view.View;
import android.view.Window;
import android.view.WindowManager;
@@ -15,15 +16,19 @@ import android.widget.TextView;

import com.example.bpa.Model.IWriteCallBack;
import com.example.bpa.R;
import com.example.bpa.config.ConfigName;
import com.example.bpa.helper.ActiveMax;
import com.example.bpa.helper.MessageLog;
import com.example.bpa.service.DeviceData;
import com.example.bpa.config.DataBus;
import com.example.bpa.helper.T;
import com.example.bpa.view.mode.UserLogEnum;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;

/**
* 流速校验
@@ -39,12 +44,12 @@ public class lsjy_activity extends AppCompatActivity implements View.OnClickList
*/
TextView gongneng_title;
//通道校准值
EditText passwayText_1, passwayText_2, passwayText_3, passwayText_4, passwayText_5, passwayText_6, passwayText_7, passwayText_8, passwayText_9, passwayText_10, passwayText_11, passwayText_12,passwayText_13;
EditText passwayText_1, passwayText_2, passwayText_3, passwayText_4, passwayText_5, passwayText_6, passwayText_7, passwayText_8, passwayText_9, passwayText_10, passwayText_11, passwayText_12, passwayText_13;
//校准基准时间
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, Switch_11, Switch_12,Switch_13;
Switch Switch_1, Switch_2, Switch_3, Switch_4, Switch_5, Switch_6, Switch_7, Switch_8, Switch_9, Switch_10, Switch_11, Switch_12, Switch_13;
List<Switch> switchLists = new ArrayList<Switch>();
//开始校准
Button StartButton;
@@ -153,11 +158,11 @@ public class lsjy_activity extends AppCompatActivity implements View.OnClickList
try {
for (int i = 0; i < 13; i++) {
String s = String.valueOf(DeviceData.Get().getCalibrationValue(i + 1));
editTextLists.get(i).setText(String.format ("%.1f", (Double.parseDouble(s)/10)));
editTextLists.get(i).setText(String.format("%.1f", (Double.parseDouble(s) / 10)));
}
String time = String.valueOf(DeviceData.Get().getCalibrationReferenceTime());
//校准时间
timeText.setText(String.format ("%.1f", (Double.parseDouble(time)/10)));
timeText.setText(String.format("%.1f", (Double.parseDouble(time) / 10)));

//设置手动模式
DeviceData.Get().setHandOrAutoSwitch(false, null);
@@ -168,6 +173,7 @@ public class lsjy_activity extends AppCompatActivity implements View.OnClickList
//endregion

//region 点击事件
private boolean isClicked = false;

/**
* 本页面点击事件监听
@@ -181,92 +187,146 @@ public class lsjy_activity extends AppCompatActivity implements View.OnClickList
this.finish();
break;
case R.id.savetime://校准基准时间保存
String stime = timeText.getText().toString();
if (stime.equals("")) {
T.show(lsjy_activity.this, "校准基准时间不能为空!");
return;
}
int ftime = 0;
try {
ftime = (int)Math.round((Double.parseDouble(stime) * 10));
} catch (Exception e) {
T.show(lsjy_activity.this, "校准基准时间异常!" + e.getMessage());
return;
}

DeviceData.Get().setCalibrationReferenceTime((short) ftime, new IWriteCallBack() {
@Override
public void onSuccess() {
T.show(lsjy_activity.this, "校准时间写入成功");
}

@Override
public void onFailure(String ErrorMsg) {
T.show(lsjy_activity.this, "校准时间写入失败");
}
});
// 执行操作
if (!isClicked) {
isClicked = true;
SaveButton.setEnabled(false); // 禁用按钮防止重复点击

for (int i = 0; i < 13; i++) {
if (switchLists.get(i).isChecked() == true)//校准开关打开后,允许校准
{
String value = editTextLists.get(i).getText().toString();
Short val = 0;
try {
val =(short)Math.round((Double.parseDouble(value) * 10));
} catch (Exception e) {
}
if (val <= 0) {
T.show(lsjy_activity.this, "请检查[通道" + (i + 1) + "]数值不能小于0");
return;
}
}
}
//写开关状态 数值
for (int i = 0; i < 13; i++) {
String value = editTextLists.get(i).getText().toString();
Short val = 0;
try {
val =(short)Math.round((Double.parseDouble(value) * 10));
} catch (Exception e) {
}
DeviceData.Get().setCalibrationValue(val, i + 1, new IWriteCallBack() {
// 在2秒后执行按钮操作
new Handler().postDelayed(new Runnable() {
@Override
public void onSuccess() {
}
public void run() {
// 执行按钮操作
// TODO: 在这里添加你的代码
try {
String stime = timeText.getText().toString();
if (stime.equals("")) {
T.show(lsjy_activity.this, "校准基准时间不能为空!");
return;
}
int ftime = 0;
try {
ftime = (int) Math.round((Double.parseDouble(stime) * 10));
} catch (Exception e) {
T.show(lsjy_activity.this, "校准基准时间异常!" + e.getMessage());
return;
}
for (int i = 0; i < 13; i++) {
if (switchLists.get(i).isChecked() == true)//校准开关打开后,允许校准
{
String value = editTextLists.get(i).getText().toString();
Short val = 0;
try {
val = (short) Math.round((Double.parseDouble(value) * 10));
} catch (Exception e) {
}
if (val <= 0) {
T.show(lsjy_activity.this, "请检查[通道" + (i + 1) + "]数值不能小于0");
return;
}
}
}

@Override
public void onFailure(String ErrorMsg) {
DeviceData.Get().setCalibrationReferenceTime((short) ftime, new IWriteCallBack() {
@Override
public void onSuccess() {
}

@Override
public void onFailure(String ErrorMsg) {
}
});
//写开关状态 数值
for (int i = 0; i < 13; i++) {
String value = editTextLists.get(i).getText().toString();
Short val = 0;
try {
val = (short) Math.round((Double.parseDouble(value) * 10));
} catch (Exception e) {
}

final boolean[] IsComplete = {false};
DeviceData.Get().setCalibrationValue(val, i + 1, new IWriteCallBack() {
@Override
public void onSuccess() {
IsComplete[0] = true;
}

@Override
public void onFailure(String ErrorMsg) {
IsComplete[0] = true;
}
});

long a = System.currentTimeMillis();
while (!IsComplete[0]) {
if ((System.currentTimeMillis() - a) > 1000 * 60) {
break;
}
Thread.sleep(100);//10 *6
}
}
} catch (WindowManager.BadTokenException ex) {
MessageLog.ShowInfo("校准保存配置异常:" + ex.getMessage());
} catch (InterruptedException ex) {
MessageLog.ShowInfo("校准保存配置异常:" + ex.getMessage());
}
T.show(lsjy_activity.this, "参数写入成功");

SaveButton.setEnabled(true); // 恢复按钮状态
isClicked = false; // 重置点击状态
}
});
}, 2000);
}

break;
case R.id.StartButton://开始校准
//写开关状态 数值
for (int i = 0; i < 13; i++) {
//1.写入开关状态
DeviceData.Get().setChCalibrationSwitch(switchLists.get(i).isChecked(), i + 1, new IWriteCallBack() {
@Override
public void onSuccess() {
}
if (!isClicked) {
isClicked = true;
StartButton.setEnabled(false); // 禁用按钮防止重复点击

// 在2秒后执行按钮操作
new Handler().postDelayed(new Runnable() {
@Override
public void onFailure(String ErrorMsg) {
public void run() {
// 执行按钮操作
// TODO: 在这里添加你的代码
try {
//写开关状态 数值
for (int i = 0; i < 13; i++) {
//1.写入开关状态
DeviceData.Get().setChCalibrationSwitch(switchLists.get(i).isChecked(), i + 1, new IWriteCallBack() {
@Override
public void onSuccess() {
}

@Override
public void onFailure(String ErrorMsg) {
}
});
}
//写开始校准
DeviceData.Get().setChStartCalibration(new IWriteCallBack() {
@Override
public void onSuccess() {
T.show(lsjy_activity.this, "通道开始校准");
}

@Override
public void onFailure(String ErrorMsg) {
T.show(lsjy_activity.this, "通道开始校准失败");
}
});
} catch (Exception ex) {
MessageLog.ShowInfo("开始校准异常:" + ex.getMessage());
}


StartButton.setEnabled(true); // 恢复按钮状态
isClicked = false; // 重置点击状态
}
});
}, 2000);
}
//写开始校准
DeviceData.Get().setChStartCalibration(new IWriteCallBack() {
@Override
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() {
@@ -300,9 +360,9 @@ public class lsjy_activity extends AppCompatActivity implements View.OnClickList
@Override
public void run() {
try {
zhongliang.setText(String.valueOf(DeviceData.Get().getCallCurrentWeight(1)/10.0)+" g");
zhongliang.setText(String.valueOf(DeviceData.Get().getCallCurrentWeight(1) / 10.0) + " g");
} catch (Exception e) {
MessageLog.ShowInfo("重量解析显示异常!"+e.getMessage());
MessageLog.ShowInfo("重量解析显示异常!" + e.getMessage());
}
}
});


Loading…
Cancel
Save