|
|
|
|
@ -12,6 +12,9 @@ import android.widget.Button;
|
|
|
|
|
import android.widget.EditText;
|
|
|
|
|
import android.widget.RadioGroup;
|
|
|
|
|
import android.widget.TextView;
|
|
|
|
|
|
|
|
|
|
import androidx.localbroadcastmanager.content.LocalBroadcastManager;
|
|
|
|
|
|
|
|
|
|
import com.bjzc.zjyxdxj.DBModel.Dqgz;
|
|
|
|
|
import com.bjzc.zjyxdxj.R;
|
|
|
|
|
import com.bjzc.zjyxdxj.base.BaseActivity3;
|
|
|
|
|
@ -19,8 +22,8 @@ import com.bjzc.zjyxdxj.contans.Contans;
|
|
|
|
|
import com.bjzc.zjyxdxj.utils.SPUtils;
|
|
|
|
|
import com.bjzc.zjyxdxj.weight.AuditDialog;
|
|
|
|
|
import com.bjzc.zjyxdxj.weight.EditDialog;
|
|
|
|
|
import com.rinsun.mtdriver.MTnativeInterface;
|
|
|
|
|
import org.litepal.crud.DataSupport;
|
|
|
|
|
|
|
|
|
|
import java.text.SimpleDateFormat;
|
|
|
|
|
import java.util.Date;
|
|
|
|
|
|
|
|
|
|
@ -40,7 +43,7 @@ public class CheckVibrationDqgzActivity extends BaseActivity3 {
|
|
|
|
|
private String vibrationValue;
|
|
|
|
|
public static final int RESULT_SUCCESS = 1;
|
|
|
|
|
//private String checkType;
|
|
|
|
|
int checkVibrationType = MTnativeInterface.CMD_VIBD_R;
|
|
|
|
|
|
|
|
|
|
int level = 0;
|
|
|
|
|
// 振动位移单位 mm
|
|
|
|
|
//振动速度单位 mm/s
|
|
|
|
|
@ -64,7 +67,7 @@ public class CheckVibrationDqgzActivity extends BaseActivity3 {
|
|
|
|
|
private int pplen; // 1024, 4096, 8192
|
|
|
|
|
///////////////////////////////////////////////
|
|
|
|
|
|
|
|
|
|
MTnativeInterface mt= MTnativeInterface.getInstance();//获取传感器调用接口
|
|
|
|
|
|
|
|
|
|
Intent intentTemplate;
|
|
|
|
|
private String username;
|
|
|
|
|
|
|
|
|
|
@ -94,7 +97,7 @@ public class CheckVibrationDqgzActivity extends BaseActivity3 {
|
|
|
|
|
initToolbar("测振", "开始测量", new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View v) {
|
|
|
|
|
demo();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
} else {
|
|
|
|
|
@ -110,31 +113,7 @@ public class CheckVibrationDqgzActivity extends BaseActivity3 {
|
|
|
|
|
|
|
|
|
|
noticeValue.setKeyListener(null);
|
|
|
|
|
|
|
|
|
|
//回调函数(自动返回数据)。CMDtype:数据类型,参数说明见“说明文档.txt”
|
|
|
|
|
mt.setOnReceiveListener(new MTnativeInterface.OnReceiveListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onShowMessage(byte[] recBuff,int CMDtype, int tag) {
|
|
|
|
|
/* 根据CMDtype区分数据类型,普通测量值/频谱数据/配置数据。如果10秒没读到数据会返回超时提示并关闭电源 */
|
|
|
|
|
System.out.println("-------------");
|
|
|
|
|
System.out.println(new String(recBuff)+"/"+CMDtype+"/"+tag);
|
|
|
|
|
|
|
|
|
|
if(CMDtype==MTnativeInterface.CMD_VIBA_R){
|
|
|
|
|
if(recBuff!=null){
|
|
|
|
|
String recv = new String(recBuff);
|
|
|
|
|
String cut = " ";
|
|
|
|
|
String[] newStr = recv.split(cut); // 分割成数组
|
|
|
|
|
updateUI(newStr[0]);//可直接显示数据
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
//收到普通测量值
|
|
|
|
|
updateUI(new String(recBuff));//可直接显示数据
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//收到频谱采集部分
|
|
|
|
|
//recBuff 原始数据数组,CMDtype 返回数据类型,tag 数据长度
|
|
|
|
|
System.out.println((recBuff.length)+"/"+CMDtype+"/"+tag);
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
btnSubmit.setOnClickListener(new View.OnClickListener() {
|
|
|
|
|
@Override
|
|
|
|
|
public void onClick(View view) {
|
|
|
|
|
@ -162,7 +141,7 @@ public class CheckVibrationDqgzActivity extends BaseActivity3 {
|
|
|
|
|
bundle.putParcelable("bean", dqgz);
|
|
|
|
|
intent.putExtras(bundle);
|
|
|
|
|
//发送广播
|
|
|
|
|
sendBroadcast(intent);
|
|
|
|
|
LocalBroadcastManager.getInstance(context).sendBroadcast(intent);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
Intent intent = new Intent();
|
|
|
|
|
@ -185,11 +164,11 @@ public class CheckVibrationDqgzActivity extends BaseActivity3 {
|
|
|
|
|
public void onCheckedChanged(RadioGroup radioGroup, int i) {
|
|
|
|
|
if(i==R.id.rb1){
|
|
|
|
|
level = 0;
|
|
|
|
|
demo();//测量
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
if(i==R.id.rb2){
|
|
|
|
|
level = 1;
|
|
|
|
|
demo();//测量
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
});
|
|
|
|
|
@ -197,24 +176,24 @@ public class CheckVibrationDqgzActivity extends BaseActivity3 {
|
|
|
|
|
@Override
|
|
|
|
|
public void onCheckedChanged(RadioGroup radioGroup, int i) {
|
|
|
|
|
if(i==R.id.rb3){
|
|
|
|
|
checkVibrationType = MTnativeInterface.CMD_VIBD_R;
|
|
|
|
|
|
|
|
|
|
etRealTitle.setText("实际值(mm):");
|
|
|
|
|
if(isEdit){
|
|
|
|
|
demo();//测量
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(i==R.id.rb4){
|
|
|
|
|
checkVibrationType = MTnativeInterface.CMD_VIBV_R;
|
|
|
|
|
|
|
|
|
|
etRealTitle.setText("实际值(mm/s):");
|
|
|
|
|
if(isEdit){
|
|
|
|
|
demo();//测量
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if(i==R.id.rb5){
|
|
|
|
|
checkVibrationType = MTnativeInterface.CMD_VIBA_R;
|
|
|
|
|
|
|
|
|
|
etRealTitle.setText("实际值(mm/(s^2)):");
|
|
|
|
|
if(isEdit){
|
|
|
|
|
demo();//测量
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
@ -234,7 +213,7 @@ public class CheckVibrationDqgzActivity extends BaseActivity3 {
|
|
|
|
|
//让软键盘隐藏
|
|
|
|
|
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
|
|
|
|
|
if (imm.isActive()) {
|
|
|
|
|
imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0); // 隐藏
|
|
|
|
|
imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, 0); // 隐藏
|
|
|
|
|
}
|
|
|
|
|
editDialog.dismiss();
|
|
|
|
|
}
|
|
|
|
|
@ -245,7 +224,7 @@ public class CheckVibrationDqgzActivity extends BaseActivity3 {
|
|
|
|
|
//让软键盘隐藏
|
|
|
|
|
InputMethodManager imm = (InputMethodManager) context.getSystemService(Context.INPUT_METHOD_SERVICE);
|
|
|
|
|
if (imm.isActive()) {
|
|
|
|
|
imm.toggleSoftInput(InputMethodManager.HIDE_IMPLICIT_ONLY, 0); // 隐藏
|
|
|
|
|
imm.toggleSoftInput(InputMethodManager.SHOW_IMPLICIT, 0); // 隐藏
|
|
|
|
|
}
|
|
|
|
|
editDialog.dismiss();
|
|
|
|
|
}
|
|
|
|
|
@ -279,27 +258,9 @@ public class CheckVibrationDqgzActivity extends BaseActivity3 {
|
|
|
|
|
super.onResume();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onPause() {
|
|
|
|
|
//使用完一定记得关闭电源
|
|
|
|
|
mt.RFIDclose();
|
|
|
|
|
mt.IRTclose();
|
|
|
|
|
mt.VIBclose();
|
|
|
|
|
mt.RPMclose();
|
|
|
|
|
super.onPause();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void demo(){
|
|
|
|
|
/*=======测振示例,参数说明见“说明文档.txt”================================================================*/
|
|
|
|
|
mt.VIBopen();//开启电源。
|
|
|
|
|
//振动值测量。(振动值测量和频谱采集同时只能使用其中一个)
|
|
|
|
|
//读振动加速度(加速度回传了2个值,取第一个就可以)
|
|
|
|
|
//CMD_VIBA_R 振动加速度(加速度回传了2个值,取第一个就可以)
|
|
|
|
|
//CMD_VIBD_R 振动位移
|
|
|
|
|
//CMD_VIBA_R 振动速度
|
|
|
|
|
mt.VIBread(checkVibrationType,level);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public void updateUI(final String info) {
|
|
|
|
|
runOnUiThread(new Runnable() {
|
|
|
|
|
@ -314,14 +275,5 @@ public class CheckVibrationDqgzActivity extends BaseActivity3 {
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
protected void onDestroy() {
|
|
|
|
|
//使用完一定记得关闭电源
|
|
|
|
|
mt.RFIDclose();
|
|
|
|
|
mt.IRTclose();
|
|
|
|
|
mt.VIBclose();
|
|
|
|
|
mt.RPMclose();
|
|
|
|
|
super.onDestroy();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|