From 8ff90d87687b6d38158809aae776b6c709d7b60a Mon Sep 17 00:00:00 2001
From: weimingfei <fei_gaming@sina.com>
Date: 星期四, 04 十二月 2025 12:01:41 +0800
Subject: [PATCH] 指纹钥匙柜
---
keyCabinet-android/app/src/main/java/com/doumee/keyCabinet/ui/main/MainActivity.java | 353 +++++++++++++++++++++++++++++++++++++---------------------
1 files changed, 226 insertions(+), 127 deletions(-)
diff --git a/keyCabinet-android/app/src/main/java/com/doumee/keyCabinet/ui/main/MainActivity.java b/keyCabinet-android/app/src/main/java/com/doumee/keyCabinet/ui/main/MainActivity.java
index 91128eb..52a2407 100644
--- a/keyCabinet-android/app/src/main/java/com/doumee/keyCabinet/ui/main/MainActivity.java
+++ b/keyCabinet-android/app/src/main/java/com/doumee/keyCabinet/ui/main/MainActivity.java
@@ -10,9 +10,11 @@
import android.graphics.drawable.BitmapDrawable;
import android.hardware.Camera;
import android.opengl.Visibility;
+import android.os.Build;
import android.os.Bundle;
import android.os.Handler;
import android.os.Message;
+import android.serialport.SerialPortFinder;
import android.text.SpannableString;
import android.text.Spanned;
import android.text.TextUtils;
@@ -68,6 +70,7 @@
import com.doumee.keyCabinet.event.OpenGridOneResultEvent;
import com.doumee.keyCabinet.event.TimeClockEvent;
import com.doumee.keyCabinet.ui.face.ActivationActivity;
+import com.doumee.keyCabinet.ui.face.ChoseActivationActivity;
import com.doumee.keyCabinet.ui.face.FaceActivity;
import com.doumee.keyCabinet.ui.keyCabinet.ChangeUrlActivity;
import com.doumee.keyCabinet.ui.keyCabinet.KeyCabinetActivity;
@@ -83,6 +86,7 @@
import com.doumee.keyCabinet.utils.CircularQueue;
import com.doumee.keyCabinet.utils.CrashHandler;
import com.doumee.keyCabinet.utils.LMobileInfo;
+import com.doumee.keyCabinet.utils.MCUtils;
import com.doumee.keyCabinet.utils.TimeUtils;
import com.doumee.keyCabinet.utils.face.FaceSDKManager;
import com.doumee.keyCabinet.utils.face.FaceUtils;
@@ -106,13 +110,16 @@
import com.doumee.lib_coremodel.util.StringUtil;
import com.doumee.lib_coremodel.view.ToastView;
import com.example.datalibrary.api.FaceApi;
+import com.example.datalibrary.db.DBManager;
import com.example.datalibrary.listener.DBLoadListener;
import com.example.datalibrary.listener.SdkInitListener;
import com.example.datalibrary.model.ImportFeatureResult;
import com.example.datalibrary.model.User;
import com.example.datalibrary.utils.ToastUtils;
import com.example.datalibrary.view.PreviewTexture;
-import com.innohi.YNHAPI;
+import com.mc.enjoysdk.McHome;
+import com.mc.enjoysdk.McSystemUi;
+import com.mc.enjoysdk.transform.McSystemUiFlag;
import com.yanzhenjie.permission.runtime.Permission;
import org.greenrobot.eventbus.EventBus;
@@ -159,6 +166,8 @@
private int downCount = 0;
private Long lastDownTime;
private Long showTime;
+ private McSystemUi mcSystemUi;
+ private McHome mcHome;
private Handler handler = new Handler(){
@Override
@@ -210,14 +219,16 @@
getDB().setModel(getVM());
initRGBCheck();
handler.sendEmptyMessageDelayed(0, 1000);
- //鍚姩蹇冭烦
+ /*//鍚姩蹇冭烦
Intent intent = new Intent(MainActivity.this, HeartbeatService.class);
startService(intent);
//鍚姩鏇存柊浜鸿劯
Intent intent2 = new Intent(MainActivity.this, FaceUpdateService.class);
- startService(intent2);
+ startService(intent2);*/
getPermission();
Timber.tag("====>").d(LMobileInfo.getDeviceUniqueId());
+ mcSystemUi = McSystemUi.getInstance(this);
+ mcHome = McHome.getInstance(this);
}
private void initM(){
@@ -229,10 +240,10 @@
long availableMemory = memoryInfo.availMem/(1024*1024);
long usedMemory = totalMemory - availableMemory;
//getDB().tvM.setText("鎬诲唴瀛橈細"+totalMemory+",浣跨敤鍐呭瓨锛�"+usedMemory+",鍙敤鍐呭瓨锛�"+availableMemory);
- if((availableMemory<400&&showTime!=null&&(System.currentTimeMillis()-showTime>5000))||
+ if((availableMemory<100&&showTime!=null&&(System.currentTimeMillis()-showTime>5000))||
("02:00:00".equals(StringUtil.getHM()))){
//鍙敤鍐呭瓨灏忎簬400M,鎴栬�呮瘡澶╁噷鏅�2鐐癸紝閲嶅惎app
- //restartApp();
+ restartApp();
}
}
@@ -252,6 +263,7 @@
@Override
public void onChanged(List<FaceUserBean> beans) {
//鏇存柊浜鸿劯鏁版嵁
+ getVM().addInfo("鏇存柊浜鸿劯鏁版嵁======銆媌eans = "+beans);
if(beans!=null&&beans.size()>0){
initModel(beans);
}
@@ -316,14 +328,17 @@
getDB().imgLeft.setOnClickListener(new View.OnClickListener() {
@Override
- public void onClick(View v) {
+ public void onClick(View v1) {
//todo 涓存椂浠g爜
if (getDB().nsv.getVisibility()== View.VISIBLE) {
getDB().nsv.setVisibility(View.GONE);
}else {
getDB().nsv.setVisibility(View.VISIBLE);
}
-
+ //鏄剧ず鐘舵�佹爮
+ mcSystemUi.temporarilySwitchStatusBar(true);
+ //鏄剧ず瀵艰埅鏍�
+ mcSystemUi.temporarilySwitchNavigation(true);
}
});
upErrInfo();
@@ -338,6 +353,7 @@
}
setJiuConfig();
initPort();
+ EventBus.getDefault().post(new GetFacesEvent());
}
}
});
@@ -456,6 +472,12 @@
private SpannableString getErrPhoneText(){
String phone = MApplication.getConfigBean().getLinkPhone();
+ if(phone==null){
+ String text = "濡傛湁闂璇疯仈绯荤鐞嗗憳";
+ SpannableString styledText = new SpannableString(text);
+ styledText.setSpan(new TextAppearanceSpan(this, R.style.style_tip3), 0, text.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
+ return styledText;
+ }
String text = "濡傛湁闂璇疯仈绯荤鐞嗗憳"+phone;
SpannableString styledText = new SpannableString(text);
styledText.setSpan(new TextAppearanceSpan(this, R.style.style_tip3), 0, text.length()-phone.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE);
@@ -468,8 +490,9 @@
protected void onResume() {
super.onResume();
isShowing = true;
- YNHAPI mAPI = YNHAPI.getInstance();
- mAPI.setNavigationBarVisibility(YNHAPI.NavigationBarVisibility.ALWAYS_INVISIBLE);
+ getVM().setSubmit(true);
+ MCUtils.hind(mcSystemUi);
+ mcHome.setHomePackage("com.doumee.keyCabinet");
showTime = System.currentTimeMillis();
if(!isFaceOk) {
initLicense();
@@ -509,7 +532,10 @@
if (future != null && !future.isDone()) {
future.cancel(true);
}
- FaceApi.getInstance().cleanRecords();
+ if(isFaceOk) {
+ //婵�娲讳簡鎵嶅鐞�
+ FaceApi.getInstance().cleanRecords();
+ }
handler.removeCallbacksAndMessages(null);
handler = null;
faceHandler.removeCallbacksAndMessages(null);
@@ -540,7 +566,9 @@
@Subscribe
public void GetFacesEvent(GetFacesEvent event){
+ getVM().addInfo("鏌ヨ浜鸿劯鏁版嵁======銆�");
if(!isFinishing()&&!isUpdatingFace){
+ getVM().addInfo("鏌ヨ浜鸿劯鏁版嵁======銆媔sDBLoad = "+isDBLoad);
if(isDBLoad){
isNeedUpdateFace = false;
//鏌ヨ浜鸿劯
@@ -574,7 +602,7 @@
/*
*瑕佹墽琛岀殑鎿嶄綔*/
- startActivity(new Intent(mContext, ActivationActivity.class));
+ startActivity(new Intent(mContext, ChoseActivationActivity.class));
}
};
Timer timer = new Timer();
@@ -636,10 +664,10 @@
@Override
public void run() {
FaceApi.getInstance().setUsers(users);
+ isDBLoad = true;
initFaceSDKManager(null);
if (successCount > 5000 || successCount == 0) {
getDB().progressGroup.setVisibility(View.GONE);
- isDBLoad = true;
isFaceOk = true;
}
}
@@ -685,8 +713,10 @@
private void initModel(List<FaceUserBean> userBeans) {
if (com.example.datalibrary.manager.FaceSDKManager.initStatus == com.example.datalibrary.manager.FaceSDKManager.SDK_MODEL_LOAD_SUCCESS) {
+ getVM().addInfo("鏇存柊浜鸿劯===銆嬪紑濮嬫洿鏂�");
waitUpdate(userBeans);
}else {
+ getVM().addInfo("鏇存柊浜鸿劯===銆嬪垵濮嬪寲");
initFaceSDKManager(userBeans);
}
}
@@ -742,6 +772,7 @@
super.onPause();
showTime = null;
isShowing = false;
+ getVM().setSubmit(false);
}
private int finishCount;
@@ -775,11 +806,9 @@
}
};
- private void waitUpdate(List<FaceUserBean> userBeans){
- if(isUpdatingFace){
- //姝e湪鏇存柊
- waitBeans.addAll(userBeans);
- }else {
+ private UserInfoManager.UserInfoListener mUserListListener = new UserInfoManager.UserInfoListener(){
+ @Override
+ public void userListQuerySuccess(String userName, List<User> listUserInfo) {
selectBeans.clear();
selectBeans.addAll(waitBeans);
waitBeans.clear();
@@ -797,25 +826,37 @@
//鍒犻櫎涓嶅瓨鍦ㄧ敤鎴�
List<User> users = FaceApi.getInstance().getAllUserList();
List<User> dels = new ArrayList<>();
+ StringBuilder sb = new StringBuilder();
for(User u:users){
String key = u.getUserId()+"_"+u.getGroupId();
if(!uMap.containsKey(key)){
+ u.setChecked(true);
dels.add(u);
+ if(sb.length()>0){
+ sb.append(",");
+ }
+ sb.append(u.getUserName());
}
}
+ getVM().addInfo("鏇存柊浜鸿劯銆嬨�嬨�嬨�嬨�嬨�嬨�嬨�嬨�嬨�嬨�嬨�嬨�嬨�嬨�嬨�嬨�嬨��");
if(dels.size()>0){
- UserInfoManager.getInstance().deleteUserListInfo(dels,
- "", new UserInfoManager.UserInfoListener() {
+ getVM().addInfo("鍑嗗鍒犻櫎鐢ㄦ埛锛�"+sb.toString());
+ UserInfoManager.getInstance().deleteUserListInfo(users,
+ "1", new UserInfoManager.UserInfoListener() {
@Override
public void userListDeleteSuccess() {
// 鐢ㄦ埛鍒楄〃鍒犻櫎鎴愬姛
faceHandler.sendEmptyMessage(0);
+ getVM().addInfo("鍒犻櫎鐢ㄦ埛鎴愬姛锛�");
}
@Override
public void userListDeleteFailure(String message) {
// 鐢ㄦ埛鍒楄〃鍒犻櫎澶辫触
faceHandler.sendEmptyMessage(0);
+ getVM().addInfo("鍒犻櫎鐢ㄦ埛澶辫触锛�"+message);
+
+ getVM().addInfo("鍒犻櫎鐢ㄦ埛鍒楄〃锛�"+sb.toString());
}
},
new DBLoadListener() {
@@ -843,11 +884,41 @@
faceHandler.sendEmptyMessage(0);
}
}
+
+ @Override
+ public void userListQueryFailure(String message) {
+
+ }
+
+ @Override
+ public void userListDeleteSuccess() {
+
+ }
+
+ @Override
+ public void userListDeleteFailure(String message) {
+
+ }
+ };
+
+ private List<FaceUserBean> userBeans = new ArrayList<>();
+ private void waitUpdate(List<FaceUserBean> userBeans){
+ if(isUpdatingFace){
+ //姝e湪鏇存柊
+ waitBeans.addAll(userBeans);
+ getVM().addInfo("姝e湪鏇存柊銆佺瓑寰� 銆娿�娿�娿�娿�娿�娿�娿��");
+ }else {
+ getVM().addInfo("鍒濆鍖栦汉鑴稿簱 銆娿�娿�娿�娿�娿�娿�娿��");
+ com.example.datalibrary.manager.FaceSDKManager.getInstance().initDataBases(MainActivity.this);
+ this.userBeans.clear();
+ this.userBeans.addAll(userBeans);
+ UserInfoManager.getInstance().getUserListInfo(null, mUserListListener);
+ }
}
private int repeatCount = 0;
private void updateFace(FaceUserBean bean){
- Timber.d("==UpdatingFace==>瀹屾垚鏁伴噺 "+finishCount);
+ //getVM().addInfo("==UpdatingFace==>瀹屾垚鏁伴噺 " + finishCount);
if (TextUtils.isEmpty(bean.getFaceImg())||bean.getFaceImg().endsWith("null")) {
finishCount++;
faceHandler.sendEmptyMessage(0);
@@ -956,12 +1027,14 @@
isSave = FaceApi.getInstance().registerUserIntoDBmanager(newDo.getGroupId(),
newDo.getUserId(), newDo.getUserName(), newDo.getImageName(), newDo.getUserInfo(), newDo.getFeature());
//System.out.println("==isOk==>淇濆瓨鎴愬姛");
+ //getVM().addInfo("鏂板浜鸿劯==銆�"+newDo.getUserName()+" 缁撴灉锛�"+isSave);
} else {
//鏇存柊
user.setUserName(newDo.getUserName());
user.setImageName(newDo.getImageName());
user.setFeature(newDo.getFeature());
isSave = FaceApi.getInstance().userUpdateOnly(user);
+ //getVM().addInfo("鏇存柊浜鸿劯==銆�"+newDo.getUserName()+" 缁撴灉锛�"+isSave);
//System.out.println("==isOk==>鏇存柊鎴愬姛");
}
@@ -1085,7 +1158,7 @@
SingleBaseConfig.getBaseConfig().setRBGCameraId(index);
SingleBaseConfig.getBaseConfig().setRgbRevert(true);
SingleBaseConfig.getBaseConfig().setRgbDetectDirection(90);
- SingleBaseConfig.getBaseConfig().setRgbVideoDirection(270);
+ SingleBaseConfig.getBaseConfig().setRgbVideoDirection(90);
GateConfigUtils.modityJson();
RegisterConfigUtils.modityJson();
}
@@ -1174,6 +1247,7 @@
//瀹氭椂鎷夊彇鍩烘湰淇℃伅
getVM().devLogin();
getPermission();
+ getVM().devHeart();
}else {
loopDownCount--;
}
@@ -1375,7 +1449,7 @@
EventBus.getDefault().post(new CloseGridOneResultEvent(key,"00".equals(open)?1:0));
if(isShowing&&isShowTip){
//淇敼鏄剧ず鎻愰啋
- doRegister(5,null);
+ getVM().doAction(5);
}
}else if(data.startsWith("80")){
//鏌ヨ鎵�鏈夐棬鐘舵��
@@ -1470,7 +1544,7 @@
keyPreviousData = data;
}else if(data.startsWith("CC02")){
runOnUiThread(() -> {
- //getVM().addInfo("鑾峰彇鍒伴挜鍖欐暟鎹�:" + data);
+ getVM().addInfo("鑾峰彇鍒伴挜鍖欐暟鎹�:" + data);
jxKey(data);
});
keyPreviousData = null;
@@ -1478,7 +1552,7 @@
if(!TextUtils.isEmpty(keyPreviousData)){
String data2 = keyPreviousData+data;
runOnUiThread(() -> {
- //getVM().addInfo("鑾峰彇鍒伴挜鍖欐暟鎹�:" + data2);
+ getVM().addInfo("鑾峰彇鍒伴挜鍖欐暟鎹�:" + data2);
if(data2.contains("CC01")&&data2.contains("CC02")){
String[] sp = data2.split("CC02");
if(sp.length==2){
@@ -1539,15 +1613,9 @@
}
}
}
- //todo 鍘绘帀
- CabinetGridDo gridDo = oldMap.get("0101");
- if(gridDo!=null) {
- EventBus.getDefault().post(new HttpEvent(StringUtil.DateToStrSS(new Date())+
- "=================>鏇存柊鏁版嵁褰撳墠閽ュ寵7锛�" + gridDo.getCurKeyCode()));
- }
getVM().updateGrids(updateList);
- EventBus.getDefault().post(new KeyResultEvent());
+ EventBus.getDefault().post(new KeyResultEvent(bh+""));
}
private SerialPortModel jiuPort;
@@ -1611,20 +1679,28 @@
return;
}
runOnUiThread(() -> {
- getVM().addInfo("鑾峰彇鍒伴棬鏁版嵁:" + SportUtils.bytesToHexSimple(bytes));
+ getVM().addInfo("鑾峰彇鍒版暟鎹�:" + SportUtils.bytesToHexSimple(bytes));
});
+ String data = SportUtils.bytesToHexSimple(bytes);
if(startIndex==1){
- gridPath = path;
- getVM().addInfo("璁剧疆闂ㄤ覆鍙h矾寰�:" + path);
- SpUtil.saveString("port_grid",path);
+ if(data.toLowerCase().startsWith("80")){
+ gridPath = path;
+ getVM().addInfo("璁剧疆闂ㄤ覆鍙h矾寰�:=====XXXXX===>" + path);
+ SpUtil.saveString("port_grid",path);
+ }
}else if(startIndex==2){
- keyPath = path;
- getVM().addInfo("璁剧疆閽ュ寵涓插彛璺緞:" + path);
- SpUtil.saveString("port_key",path);
+ if(data.toLowerCase().startsWith("cc")){
+ keyPath = path;
+ getVM().addInfo("璁剧疆閽ュ寵涓插彛璺緞:====XXXX====>" + path);
+ SpUtil.saveString("port_key",path);
+ }
}else if(startIndex==3){
- jiuPath = path;
- getVM().addInfo("璁剧疆閰掔簿涓插彛璺緞:" + path);
- SpUtil.saveString("port_jiu",path);
+ String data2 = new String(bytes);
+ if(data2.toLowerCase().startsWith("mic")) {
+ jiuPath = path;
+ getVM().addInfo("璁剧疆閰掔簿涓插彛璺緞:====XXXX====>" + path);
+ SpUtil.saveString("port_jiu", path);
+ }
}
}
};
@@ -1643,8 +1719,8 @@
switch (msg.what){
case 0:
if(index>=1&&!checkEnd()){
- path = ports.get(index);
index--;
+ path = ports.get(index);
portHandler.sendEmptyMessage(4);
}else if(checkEnd()){
initPort();
@@ -1748,90 +1824,97 @@
private boolean isInitPort;
//鍒濆鍖栦覆鍙�
private void initPort(){
- SpUtil.setString("port_grid","/dev/ttyS7");
- SpUtil.setString("port_key","/dev/ttyS1");
- SpUtil.setString("port_jiu","/dev/ttyS2");
- gridPath = SpUtil.getString("port_grid");
- //getVM().addInfo("闂ㄤ覆鍙i摼鎺ワ細"+gridPath);
- keyPath = SpUtil.getString("port_key");
- //getVM().addInfo("閽ュ寵涓插彛閾炬帴锛�"+keyPath);
- jiuPath = SpUtil.getString("port_jiu");
- //getVM().addInfo("閰掔簿涓插彛閾炬帴锛�"+jiuPath);
- if(!TextUtils.isEmpty(SpUtil.getString("port_grid"))&&
- !TextUtils.isEmpty(SpUtil.getString("port_key"))&&
- !TextUtils.isEmpty(SpUtil.getString("port_jiu"))){
- if(isInitPort){
- return;
- }
- xhCount=0;
- closePort(chosePort);
- if(!TextUtils.isEmpty(SpUtil.getString("port_grid"))){
- String path = SpUtil.getString("port_grid");
- closePort(gridPort);
- getVM().addInfo("闂ㄤ覆鍙i摼鎺ワ細"+path);
- gridPort = new SerialPortModel(path,9600 ,8
- ,1 , 0,gridReadObserver);
- boolean isSucc = gridPort.open();
- if(isSucc) {
- isInitPort = true;
- getVM().addInfo("闂ㄤ覆鍙i摼鎺ユ垚鍔燂細"+path);
- String msg = isSucc ? "鎴愬姛" : "澶辫触";
- //getVM().append("涓插彛 "+ settingBean.getDevicePath() + " -杩炴帴"+msg);
- gridPort.startRead();
- //鏌ヨ鎵�鏈夋煖鏍奸棬淇℃伅
- checkGridStatus(300);
- }else {
- getVM().addInfo("闂ㄤ覆鍙i摼鎺ュけ璐ワ細"+path);
+ try {
+ /*SpUtil.setString("port_grid","/dev/ttyS0");
+ SpUtil.setString("port_key","/dev/ttyS4");
+ SpUtil.setString("port_jiu","/dev/ttyS9");*/
+
+ gridPath = SpUtil.getString("port_grid");
+ getVM().addInfo("闂ㄤ覆鍙i摼鎺ワ細"+gridPath);
+ keyPath = SpUtil.getString("port_key");
+ getVM().addInfo("閽ュ寵涓插彛閾炬帴锛�"+keyPath);
+ jiuPath = SpUtil.getString("port_jiu");
+ getVM().addInfo("閰掔簿涓插彛閾炬帴锛�"+jiuPath);
+ if(!TextUtils.isEmpty(SpUtil.getString("port_grid"))&&
+ !TextUtils.isEmpty(SpUtil.getString("port_key"))&&
+ !TextUtils.isEmpty(SpUtil.getString("port_jiu"))){
+ if(isInitPort){
+ return;
}
- }
- if(!TextUtils.isEmpty(SpUtil.getString("port_key"))){
- String path = SpUtil.getString("port_key");
- closePort(keyPort);
- keyPort = new SerialPortModel(path,115200 ,8
- ,1 , 0,keyReadObserver);
- boolean isSucc = keyPort.open();
- if(isSucc) {
- isInitPort = true;
- getVM().addInfo("閽ュ寵涓插彛閾炬帴鎴愬姛锛�"+path);
- String msg = isSucc ? "鎴愬姛" : "澶辫触";
- //getVM().append("涓插彛 "+ settingBean.getDevicePath() + " -杩炴帴"+msg);
- keyPort.startRead();
- checkKeyStatus(1500);
- }else {
- getVM().addInfo("閽ュ寵涓插彛閾炬帴澶辫触锛�"+path);
+ xhCount=0;
+ closePort(chosePort);
+ if(!TextUtils.isEmpty(SpUtil.getString("port_grid"))){
+ String path = SpUtil.getString("port_grid");
+ closePort(gridPort);
+ getVM().addInfo("闂ㄤ覆鍙i摼鎺ワ細"+path);
+ gridPort = new SerialPortModel(path,9600 ,8
+ ,1 , 0,gridReadObserver);
+ boolean isSucc = gridPort.open();
+ if(isSucc) {
+ isInitPort = true;
+ getVM().addInfo("闂ㄤ覆鍙i摼鎺ユ垚鍔燂細"+path);
+ String msg = isSucc ? "鎴愬姛" : "澶辫触";
+ //getVM().append("涓插彛 "+ settingBean.getDevicePath() + " -杩炴帴"+msg);
+ gridPort.startRead();
+ //鏌ヨ鎵�鏈夋煖鏍奸棬淇℃伅
+ checkGridStatus(300);
+ }else {
+ getVM().addInfo("闂ㄤ覆鍙i摼鎺ュけ璐ワ細"+path);
+ }
}
- }
- if(!TextUtils.isEmpty(SpUtil.getString("port_jiu"))){
- String path = SpUtil.getString("port_jiu");
- closePort(jiuPort);
- jiuPort = new SerialPortModel(path,9600 ,8
- ,1 , 0,jiuReadObserver);
- boolean isSucc = jiuPort.open();
- if(isSucc) {
- isInitPort = true;
- getVM().addInfo("閰掔簿涓插彛閾炬帴鎴愬姛锛�"+path);
- String msg = isSucc ? "鎴愬姛" : "澶辫触";
- //getVM().append("涓插彛 "+ settingBean.getDevicePath() + " -杩炴帴"+msg);
- jiuPort.startRead();
- }else {
- getVM().addInfo("閰掔簿涓插彛閾炬帴澶辫触锛�"+path);
+ if(!TextUtils.isEmpty(SpUtil.getString("port_key"))){
+ String path = SpUtil.getString("port_key");
+ closePort(keyPort);
+ keyPort = new SerialPortModel(path,115200 ,8
+ ,1 , 0,keyReadObserver);
+ boolean isSucc = keyPort.open();
+ if(isSucc) {
+ isInitPort = true;
+ getVM().addInfo("閽ュ寵涓插彛閾炬帴鎴愬姛锛�"+path);
+ String msg = isSucc ? "鎴愬姛" : "澶辫触";
+ //getVM().append("涓插彛 "+ settingBean.getDevicePath() + " -杩炴帴"+msg);
+ keyPort.startRead();
+ checkKeyStatus(1500);
+ }else {
+ getVM().addInfo("閽ュ寵涓插彛閾炬帴澶辫触锛�"+path);
+ }
}
- }
- }else {
- if(xhCount>2){
- return;
- }
- xhCount++;
- ports = SportUtils.getSerialPortPaths(this);
- if(ports==null){
- getVM().addInfo("鏈煡璇㈠埌涓插彛鍒楄〃");
+ if(!TextUtils.isEmpty(SpUtil.getString("port_jiu"))){
+ String path = SpUtil.getString("port_jiu");
+ closePort(jiuPort);
+ jiuPort = new SerialPortModel(path,9600 ,8
+ ,1 , 0,jiuReadObserver);
+ boolean isSucc = jiuPort.open();
+ if(isSucc) {
+ isInitPort = true;
+ getVM().addInfo("閰掔簿涓插彛閾炬帴鎴愬姛锛�"+path);
+ String msg = isSucc ? "鎴愬姛" : "澶辫触";
+ //getVM().append("涓插彛 "+ settingBean.getDevicePath() + " -杩炴帴"+msg);
+ jiuPort.startRead();
+ }else {
+ getVM().addInfo("閰掔簿涓插彛閾炬帴澶辫触锛�"+path);
+ }
+ }
}else {
- getVM().addInfo("涓插彛鍒楄〃锛�"+ports.size());
+ if(xhCount>2){
+ return;
+ }
+ xhCount++;
+ ports = SportUtils.getSerialPortPaths(this);
+ if(ports==null){
+ getVM().addInfo("鏈煡璇㈠埌涓插彛鍒楄〃");
+ }else {
+ getVM().addInfo("涓插彛鍒楄〃锛�"+ports.size());
+ }
+ if(ports.size()>0){
+ index = ports.size();
+ portHandler.sendEmptyMessage(0);
+ }
}
- if(ports.size()>0){
- index = ports.size()-1;
- portHandler.sendEmptyMessage(0);
- }
+ }catch (RuntimeException e){
+ Toast.makeText(mContext, e.getMessage(), Toast.LENGTH_SHORT).show();
+ }catch (Exception e){
+ Toast.makeText(mContext, e.getMessage(), Toast.LENGTH_SHORT).show();
}
}
@@ -1949,17 +2032,17 @@
private boolean checkEnd(){
if(TextUtils.isEmpty(gridPath)){
- getVM().addInfo("闂ㄩ敊璇�");
+ getVM().addInfo("闂ㄩ敊璇�<<<<<<<<<<<<<<<<<<<");
startIndex=0;
return false;
}
if(TextUtils.isEmpty(keyPath)){
- getVM().addInfo("閽ュ寵閿欒");
+ getVM().addInfo("閽ュ寵閿欒<<<<<<<<<<<<<<<<<<<");
startIndex=1;
return false;
}
if(TextUtils.isEmpty(jiuPath)){
- getVM().addInfo("閰掔簿閿欒");
+ getVM().addInfo("閰掔簿閿欒<<<<<<<<<<<<<<<<<<<");
startIndex=2;
return false;
}
@@ -2035,7 +2118,6 @@
if(handler.hasMessages(2)){
handler.removeMessages(2);
}
-
HashMap<String,String> copyMap = new HashMap<>();
copyMap.putAll(closeMap);
closeMap.clear();
@@ -2072,8 +2154,25 @@
}
if(!isFail){
//鍏抽棬鎴愬姛
- EventBus.getDefault().post(new HttpEvent(StringUtil.DateToStrSS(new Date())+"闂ㄥ叧闂垚鍔�***************************>鐩爣锛�"+gridDo.getKeyCode()+",褰撳墠锛�"+gridDo.getCurKeyCode()));
- getVM().closeGrid(gridDo);
+ boolean isSend = false;
+ String bh = gridDo.getGridKey().substring(0,2);
+ if("1".equals(e.getType())){
+ //1鍙锋澘
+ if("01".equals(bh)){
+ isSend = true;
+ }
+ }else if("2".equals(e.getType())){
+ //2鍙锋澘
+ if("02".equals(bh)){
+ isSend = true;
+ }
+ }else {
+ isSend = true;
+ }
+ if(isSend) {
+ EventBus.getDefault().post(new HttpEvent(StringUtil.DateToStrSS(new Date()) + "闂ㄥ叧闂垚鍔�***************************>鐩爣锛�" + gridDo.getKeyCode() + ",褰撳墠锛�" + gridDo.getCurKeyCode()));
+ getVM().closeGrid(gridDo);
+ }
}
}
}
--
Gitblit v1.9.3