private class MyBroadCastReceive extends BroadcastReceiver {
@Override
public void onReceive(Context context, Intent intent) {
String action = intent.getAction();
Log.i("jokeycheckloader", "action----" + action);
if (IConstant.ACTION_TIME.equals(action)) {
tvTime.setText(intent.getStringExtra(IConstant.TIME_NOW));
} else if (IConstant.ACTION_VOLTAGE_DATA.equals(action)) {
Log.i("jokeycheckloader", "isReceive----" + isReceive);
if (isReceive) {
float vol = intent.getFloatExtra(IConstant.VOLTAGE_VALUE, 0);
Log.i("jokeycheckloader", "vol---" + vol);
boolean checkMode = MyApplication.getApp().getAutoMode();
if (checkMode) {
//Toast.makeText(CheckLoaderActivity.this,,Toast.LENGTH_LONG).show();
Log.i("jokeyCheckLoader", "自动测量模式");
AutoCheck(vol);
// while (IConstant.ACTION_VOLTAGE_DATA_ISZERO.equals(action));
} else {
//Toast.makeText(CheckLoaderActivity.this,"手动测量模式",Toast.LENGTH_LONG).show();
Log.i("jokeyCheckLoader", "手动测量模式");
HandCheck(vol);
}
}
}
}
}
private void AutoCheck(float vol) {
showProgressDialog("自动采集数据中...");
/* ArrayList<Integer> list = new ArrayList<Integer>;
list.add((int) vol);*/
//if (vol > 0&&isHasNoData) {
if (vol > 0) {
if (volCount < maxCount) {
vols[volCount] = vol;
volCount++;
} else {
needData = MathUtil.checkReceiveData(vols);
isMeasure=true;//测过一次
MeasureNum++;
Log.i("DDDDD",""+MeasureNum);
tvMax.setText(needData[2] * bei + "mV");
tvMin.setText(needData[0] * bei + "mV");
tvTest.setText(needData[1] * bei + "");
isReceive = false;
String ji;
if (isFaceA) {
ji = "A面" + startPoint;
listA[startPoint - 1] = needData[1] * bei;
LogUtil.d(LogUtil.TAG, listA[startPoint - 1] + "");
} else {
ji = "B面" + startPoint;
listB[startPoint - 1] = needData[1] * bei;
LogUtil.d(LogUtil.TAG, listB[startPoint - 1] + "");
}
tvTestNow.setText(ji + "组数据检测结果: ");
textCount++;
//isReceive=true;
String ch = spNumberCao.getSelectedItem().toString();
if (TextUtils.isEmpty(ch)) {
ToastUtil.showToast(CheckLoaderActivity.this, ji + "没有槽号,请添加槽号!");
return;
} else if (!MathUtil.saveToLib(1, spNumberCao.getSelectedItem().toString(), ji.substring(0, 2), startPoint + "", needData[2] * bei + "",
needData[0] * bei + "", needData[1] * bei + "", TimeUtil.getFormatted("yyyy-MM-dd HH:mm:ss:SSS", System.currentTimeMillis()))) {
ToastUtil.showToast(CheckLoaderActivity.this, ji + "保存数据到本地失败!");
}
//更新图表
generateData();
if (textCount == dataCount * 2) {
cancleProgressDialog();
AlertDialog dialog;
dialog = new AlertDialog.Builder(CheckLoaderActivity.this)
.setMessage("测试完成!是否查看结果分布图?")
.setCancelable(false)
.setPositiveButton("查看分布图", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
Intent intent = new Intent(CheckLoaderActivity.this, DistributionMapActivity.class);
String cao = spNumberCao.getSelectedItem().toString();
intent.putExtra(IConstant.CHECK_NAME, cao + "号槽导杆压降分布图");
intent.putExtra(IConstant.BEISHU, bei);
intent.putExtra(IConstant.DATA_A, listA);
intent.putExtra(IConstant.DATA_B, listB);
startActivity(intent);
//finish();
}
})
.setNegativeButton("取消", new DialogInterface.OnClickListener() {
@Override
public void onClick(DialogInterface dialog, int which) {
dialog.dismiss();
}
})
.create();
dialog.show();
Button btnPositive = dialog.getButton(android.app.AlertDialog.BUTTON_POSITIVE);
btnPositive.setTextSize(30);
Button btnNegative = dialog.getButton(android.app.AlertDialog.BUTTON_NEGATIVE);
btnNegative.setTextSize(30);
textCount = 0;
vols = new float[maxCount];
volCount = 0;
startPoint = Integer.parseInt(jihaoNumber.substring(2, 4));
} else {
//cancleProgressDialog();
if (jihao[0].equals(jihaoNumber)) {//A面01
if (startPoint != dataCount) {
startPoint++;
} else {
isFaceA = false;
jihaoNumber = jihao[3];
}
} else if (jihao[3].equals(jihaoNumber)) {//B面24
if (startPoint != 1) {
startPoint--;
} else {
isFaceA = true;
jihaoNumber = jihao[0];
}
} else if (jihao[1].equals(jihaoNumber)) {//A面24
if (startPoint != 1) {
startPoint--;
} else {
isFaceA = false;
jihaoNumber = jihao[2];
}
} else if (jihao[2].equals(jihaoNumber)) {//B面01
if (startPoint != dataCount) {
startPoint++;
} else {
isFaceA = true;
jihaoNumber = jihao[1];
}
}
isReceive = true;
}
vols = new float[maxCount];
volCount = 0;
}
}
}
2018-03-30
©著作权归作者所有,转载或内容合作请联系作者
- 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
- 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
- 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...