|  |  |  | 
|---|
|  |  |  | import com.doumee.keyCabinet.databinding.MainActivityBinding; | 
|---|
|  |  |  | import com.doumee.keyCabinet.event.CLGridEvent; | 
|---|
|  |  |  | import com.doumee.keyCabinet.event.CLKeyEvent; | 
|---|
|  |  |  | import com.doumee.keyCabinet.event.CheckGridStatusEvent; | 
|---|
|  |  |  | import com.doumee.keyCabinet.event.CloseGridOneResultEvent; | 
|---|
|  |  |  | import com.doumee.keyCabinet.event.GetFacesEvent; | 
|---|
|  |  |  | import com.doumee.keyCabinet.event.GetKeyStatusEvent; | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.doumee.keyCabinet.ui.face.UserManagerActivity; | 
|---|
|  |  |  | import com.doumee.keyCabinet.ui.view.BannerViewImageHolder; | 
|---|
|  |  |  | import com.doumee.keyCabinet.utils.BraceletLogUtils; | 
|---|
|  |  |  | import com.doumee.keyCabinet.utils.CircularQueue; | 
|---|
|  |  |  | import com.doumee.keyCabinet.utils.CrashHandler; | 
|---|
|  |  |  | import com.doumee.keyCabinet.utils.LMobileInfo; | 
|---|
|  |  |  | import com.doumee.keyCabinet.utils.TimeUtils; | 
|---|
|  |  |  | 
|---|
|  |  |  | import com.doumee.lib_coremodel.http.utils.GsonTools; | 
|---|
|  |  |  | import com.doumee.lib_coremodel.util.SpUtil; | 
|---|
|  |  |  | import com.doumee.lib_coremodel.util.StringUtil; | 
|---|
|  |  |  | import com.doumee.lib_coremodel.view.ToastView; | 
|---|
|  |  |  | import com.example.datalibrary.api.FaceApi; | 
|---|
|  |  |  | 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.yanzhenjie.permission.runtime.Permission; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 
|---|
|  |  |  | getDB().tvId.setOnClickListener(new View.OnClickListener() { | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void onClick(View v) { | 
|---|
|  |  |  | startActivity(ManageLoginActivity.class); | 
|---|
|  |  |  | //更改url | 
|---|
|  |  |  | if(lastDownTime2!=null){ | 
|---|
|  |  |  | if(System.currentTimeMillis()-lastDownTime2>1000){ | 
|---|
|  |  |  | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | getDB().banner.stopTurning(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | unCloseGrid(); | 
|---|
|  |  |  | //检查所有柜格门、钥匙状态 | 
|---|
|  |  |  | checkKeyStatus(0); | 
|---|
|  |  |  | checkGridStatus(900); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private void unCloseGrid(){ | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private void initRGBCheck(){ | 
|---|
|  |  |  | String index = SpUtil.getString("rbgCameraId"); | 
|---|
|  |  |  | if(!"1".equals(index)){ | 
|---|
|  |  |  | index = "0"; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | String index = SpUtil.getString("rbgCameraId","0"); | 
|---|
|  |  |  | setRgbCameraId(Integer.parseInt(index)); | 
|---|
|  |  |  | /*if (isSetCameraId()){ | 
|---|
|  |  |  | setRgbCameraId(SingleBaseConfig.getBaseConfig().getRBGCameraId()); | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private int tipDownCount = 10; | 
|---|
|  |  |  | private int loopDownCount = 30; | 
|---|
|  |  |  | private boolean isShowTip; | 
|---|
|  |  |  | @Subscribe | 
|---|
|  |  |  | public void TimeClockEvent(TimeClockEvent e){ | 
|---|
|  |  |  | if(!isFinishing()) { | 
|---|
|  |  |  | if(isShowTip){ | 
|---|
|  |  |  | if(tipDownCount==0){ | 
|---|
|  |  |  | isShowTip = false; | 
|---|
|  |  |  | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | tipDownCount--; | 
|---|
|  |  |  | getDB().tvDjs.setText(tipDownCount+"s"); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if(loopDownCount==0){ | 
|---|
|  |  |  | loopDownCount = SpUtil.getInt("loop_time",30); | 
|---|
|  |  |  | //定时拉取基本信息 | 
|---|
|  |  |  | getVM().devLogin(); | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | loopDownCount--; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | !TextUtils.isEmpty(gridDo.getKeyCode())&& | 
|---|
|  |  |  | !gridDo.getCurKeyCode().equals(gridDo.getKeyCode())){ | 
|---|
|  |  |  | //钥匙不一样,开门 | 
|---|
|  |  |  | Toast.makeText(mContext, "钥匙存放位置错误", Toast.LENGTH_SHORT).show(); | 
|---|
|  |  |  | ToastView.show(MApplication.mContext,gridDo.getCabinetName()+"钥匙存放位置错误"); | 
|---|
|  |  |  | EventBus.getDefault().post(new OpenGridEvent(Integer.parseInt(e.getKey().substring(2,4), 16)+"", | 
|---|
|  |  |  | Integer.parseInt(e.getKey().substring(0,2), 16)+"")); | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | 
|---|
|  |  |  | });*/ | 
|---|
|  |  |  | String key = bh+tdh; | 
|---|
|  |  |  | CabinetGridDo gridDo = DaoManager.getCabinetGridDao().getGridByKey(key); | 
|---|
|  |  |  | if(gridDo==null){ | 
|---|
|  |  |  | //新增 | 
|---|
|  |  |  | gridDo = new CabinetGridDo(); | 
|---|
|  |  |  | gridDo.setIsOpen("00".equals(open)?1:0); | 
|---|
|  |  |  | gridDo.setGridKey(key); | 
|---|
|  |  |  | gridDo.setUpdateTime(StringUtil.DateToStr(new Date())); | 
|---|
|  |  |  | DaoManager.getCabinetGridDao().insert(gridDo); | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | if(gridDo!=null){ | 
|---|
|  |  |  | gridDo.setIsOpen("00".equals(open)?1:0); | 
|---|
|  |  |  | gridDo.setUpdateTime(StringUtil.DateToStr(new Date())); | 
|---|
|  |  |  | //todo 去掉 | 
|---|
|  |  |  | EventBus.getDefault().post(new HttpEvent(StringUtil.DateToStrSS(new Date())+"=================>更新数据当前钥匙3:"+gridDo.getCurKeyCode())); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | DaoManager.getCabinetGridDao().update(gridDo); | 
|---|
|  |  |  | EventBus.getDefault().post(new ManageOpenGridResultEvent()); | 
|---|
|  |  |  | if(gridDo.getIsOpen()==0) { | 
|---|
|  |  |  | //开门失败 | 
|---|
|  |  |  | if (isShowing) { | 
|---|
|  |  |  | //首页开门失败,钥匙不对 | 
|---|
|  |  |  | if (!TextUtils.isEmpty(gridDo.getCurKeyCode()) && | 
|---|
|  |  |  | !TextUtils.isEmpty(gridDo.getKeyCode()) && | 
|---|
|  |  |  | !gridDo.getCurKeyCode().equals(gridDo.getKeyCode())) { | 
|---|
|  |  |  | //钥匙不一样,开门 | 
|---|
|  |  |  | ToastView.show(MApplication.mContext, gridDo.getCabinetName() + "钥匙存放位置错误"); | 
|---|
|  |  |  | EventBus.getDefault().post(new OpenGridEvent(Integer.parseInt(gridDo.getGridKey().substring(2, 4), 16) + "", | 
|---|
|  |  |  | Integer.parseInt(gridDo.getGridKey().substring(0, 2), 16) + "")); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | //开门成功 | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //开门返回 | 
|---|
|  |  |  | EventBus.getDefault().post(new OpenGridOneResultEvent(key,gridDo.getIsOpen())); | 
|---|
|  |  |  | if(!portHandler.hasMessages(1)){ | 
|---|
|  |  |  | EventBus.getDefault().post(new ManageOpenGridResultEvent()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | EventBus.getDefault().post(new OpenGridOneResultEvent(key,"00".equals(open)?1:0)); | 
|---|
|  |  |  | }else if(data.length()==16){ | 
|---|
|  |  |  | //批量 | 
|---|
|  |  |  | //8A 02 00 00 00 00 11 99 | 
|---|
|  |  |  | 
|---|
|  |  |  | for(CabinetGridDo d:gridDos){ | 
|---|
|  |  |  | oldMap.put(d.getGridKey(),d); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | List<CabinetGridDo> addList = new ArrayList<>(); | 
|---|
|  |  |  | List<CabinetGridDo> updateList = new ArrayList<>(); | 
|---|
|  |  |  | String finalDm = dm; | 
|---|
|  |  |  | /*runOnUiThread(() -> { | 
|---|
|  |  |  | getVM().addInfo("批量查询返回:" +bh+","+ finalDm+",总数据:"+oldMap.size()); | 
|---|
|  |  |  | });*/ | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | for(int i=1;i<=dm.length();i++){ | 
|---|
|  |  |  | String key = bh+SportUtils.intToHex(i); | 
|---|
|  |  |  | 
|---|
|  |  |  | gridDo.setIsOpen("1".equals(dm.substring(i-1,i))?0:1); | 
|---|
|  |  |  | gridDo.setUpdateTime(StringUtil.DateToStr(new Date())); | 
|---|
|  |  |  | updateList.add(gridDo); | 
|---|
|  |  |  | }/*else { | 
|---|
|  |  |  | getVM().addInfo("新增key:" +key); | 
|---|
|  |  |  | CabinetGridDo gridDo = new CabinetGridDo(); | 
|---|
|  |  |  | gridDo.setGridKey(key); | 
|---|
|  |  |  | gridDo.setIsOpen("1".equals(dm.substring(i-1,i))?0:1); | 
|---|
|  |  |  | gridDo.setUpdateTime(StringUtil.DateToStr(new Date())); | 
|---|
|  |  |  | addList.add(gridDo); | 
|---|
|  |  |  | }*/ | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | runOnUiThread(() -> { | 
|---|
|  |  |  | getVM().addInfo("批量开门更新库数据:版号:" +bh+","+ addList.size()+","+updateList.size()); | 
|---|
|  |  |  | getVM().addInfo("批量开门更新库数据:版号:" +bh+","+updateList.size()); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | getVM().updateGrids(updateList); | 
|---|
|  |  |  | if(!portHandler.hasMessages(1)){ | 
|---|
|  |  |  | EventBus.getDefault().post(new ManageOpenGridResultEvent()); | 
|---|
|  |  |  | //todo 去掉 | 
|---|
|  |  |  | CabinetGridDo gridDo = oldMap.get("0101"); | 
|---|
|  |  |  | if(gridDo!=null) { | 
|---|
|  |  |  | EventBus.getDefault().post(new HttpEvent(StringUtil.DateToStrSS(new Date())+"=================>更新数据当前钥匙6:" + gridDo.getCurKeyCode())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | getVM().updateGrids(updateList); | 
|---|
|  |  |  | EventBus.getDefault().post(new ManageOpenGridResultEvent()); | 
|---|
|  |  |  | }catch (Exception exception){ | 
|---|
|  |  |  | runOnUiThread(() -> { | 
|---|
|  |  |  | getVM().addInfo("批量开门报错:" +exception.getMessage()); | 
|---|
|  |  |  | 
|---|
|  |  |  | String open = data.substring(6,8); | 
|---|
|  |  |  | String key = bh+tdh; | 
|---|
|  |  |  | CabinetGridDo gridDo = DaoManager.getCabinetGridDao().getGridByKey(key); | 
|---|
|  |  |  | if(gridDo==null){ | 
|---|
|  |  |  | //新增 | 
|---|
|  |  |  | gridDo = new CabinetGridDo(); | 
|---|
|  |  |  | gridDo.setIsOpen("00".equals(open)?1:0); | 
|---|
|  |  |  | gridDo.setGridKey(key); | 
|---|
|  |  |  | gridDo.setUpdateTime(StringUtil.DateToStr(new Date())); | 
|---|
|  |  |  | DaoManager.getCabinetGridDao().insert(gridDo); | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | if(gridDo!=null){ | 
|---|
|  |  |  | gridDo.setIsOpen("00".equals(open)?1:0); | 
|---|
|  |  |  | gridDo.setUpdateTime(StringUtil.DateToStr(new Date())); | 
|---|
|  |  |  | //todo 去掉 | 
|---|
|  |  |  | EventBus.getDefault().post(new HttpEvent(StringUtil.DateToStrSS(new Date())+"=================>更新数据当前钥匙3:"+gridDo.getCurKeyCode())); | 
|---|
|  |  |  |  | 
|---|
|  |  |  | DaoManager.getCabinetGridDao().update(gridDo); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //关门返回 | 
|---|
|  |  |  | EventBus.getDefault().post(new CloseGridOneResultEvent(key,gridDo.getIsOpen())); | 
|---|
|  |  |  | EventBus.getDefault().post(new CloseGridOneResultEvent(key,"00".equals(open)?1:0)); | 
|---|
|  |  |  | if(isShowing&&isShowTip){ | 
|---|
|  |  |  | //修改显示提醒 | 
|---|
|  |  |  | doRegister(5,null); | 
|---|
|  |  |  | 
|---|
|  |  |  | runOnUiThread(() -> { | 
|---|
|  |  |  | getVM().addInfo("更新库数据:版号:" +bh+","+ addList.size()+","+updateList.size()); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | //todo 去掉 | 
|---|
|  |  |  | CabinetGridDo gridDo = oldMap.get("0101"); | 
|---|
|  |  |  | if(gridDo!=null){ | 
|---|
|  |  |  | EventBus.getDefault().post(new HttpEvent(StringUtil.DateToStrSS(new Date())+ | 
|---|
|  |  |  | "=================>更新数据当前钥匙5:"+gridDo.getCurKeyCode())); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | getVM().updateGrids(updateList); | 
|---|
|  |  |  | if(isShowing){ | 
|---|
|  |  |  | unCloseGrid(); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }catch (Exception exception){ | 
|---|
|  |  |  | runOnUiThread(() -> { | 
|---|
|  |  |  | getVM().addInfo("报错:" +exception.getMessage()); | 
|---|
|  |  |  | 
|---|
|  |  |  | String data2 = keyPreviousData+data; | 
|---|
|  |  |  | runOnUiThread(() -> { | 
|---|
|  |  |  | getVM().addInfo("获取到钥匙数据:" + data2); | 
|---|
|  |  |  | if(data2.contains("CC01")&&data2.contains("CC02")){ | 
|---|
|  |  |  | String[] sp = data2.split("CC02"); | 
|---|
|  |  |  | if(sp.length==2){ | 
|---|
|  |  |  | jxKey(sp[0]); | 
|---|
|  |  |  | jxKey("CC02"+sp[1]); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | jxKey(data2); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | keyPreviousData = null; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | }else { | 
|---|
|  |  |  | gridDo.setCurKeyCode(""); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if("0101".equals(key)) { | 
|---|
|  |  |  | getVM().addInfo(key+" , "+isHaveKey+"  "+keyCode); | 
|---|
|  |  |  | getVM().addInfo(key + "设置钥匙:" + gridDo.getCurKeyCode()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | gridDo.setUpdateTime(StringUtil.DateToStr(new Date())); | 
|---|
|  |  |  | updateList.add(gridDo); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | //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()); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | try { | 
|---|
|  |  |  | runOnUiThread(() -> { | 
|---|
|  |  |  | getVM().addInfo("获取到酒精检测数据:"+StringUtil.DateToStrSS(new Date())+" " + new String(bytes)); | 
|---|
|  |  |  | //getVM().addInfo("获取到酒精检测数据:"+StringUtil.DateToStrSS(new Date())+" " + new String(bytes)); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | String data = new String(bytes); | 
|---|
|  |  |  | runOnUiThread(() -> { | 
|---|
|  |  |  | getVM().addInfo("获取到酒精检测是否检测失败:" + (data.contains("blow fail"))); | 
|---|
|  |  |  | //getVM().addInfo("获取到酒精检测是否检测失败:" + (data.contains("blow fail"))); | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | if(data.contains("blow fail")){ | 
|---|
|  |  |  | //检测失败 | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }; | 
|---|
|  |  |  |  | 
|---|
|  |  |  | @Subscribe(threadMode = ThreadMode.MAIN) | 
|---|
|  |  |  | public void CheckGridStatusEvent(CheckGridStatusEvent e){ | 
|---|
|  |  |  | if(!isFinishing()){ | 
|---|
|  |  |  | checkGridStatus(0); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | //检查所有门状态 | 
|---|
|  |  |  | private void checkGridStatus(long time){ | 
|---|
|  |  |  | sendPortHandlerMsg(1,"80010033B2",time+100); | 
|---|
|  |  |  | 
|---|
|  |  |  | portHandler.sendMessageDelayed(mc,time); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | 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("门串口链接:"+gridPath); | 
|---|
|  |  |  | //getVM().addInfo("门串口链接:"+gridPath); | 
|---|
|  |  |  | keyPath = SpUtil.getString("port_key"); | 
|---|
|  |  |  | getVM().addInfo("钥匙串口链接:"+keyPath); | 
|---|
|  |  |  | //getVM().addInfo("钥匙串口链接:"+keyPath); | 
|---|
|  |  |  | jiuPath = SpUtil.getString("port_jiu"); | 
|---|
|  |  |  | getVM().addInfo("酒精串口链接:"+jiuPath); | 
|---|
|  |  |  | //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"))){ | 
|---|
|  |  |  | 
|---|
|  |  |  | ,1 , 0,gridReadObserver); | 
|---|
|  |  |  | boolean isSucc = gridPort.open(); | 
|---|
|  |  |  | if(isSucc) { | 
|---|
|  |  |  | isInitPort = true; | 
|---|
|  |  |  | getVM().addInfo("门串口链接成功:"+path); | 
|---|
|  |  |  | String msg = isSucc ? "成功" : "失败"; | 
|---|
|  |  |  | //getVM().append("串口 "+ settingBean.getDevicePath() + " -连接"+msg); | 
|---|
|  |  |  | 
|---|
|  |  |  | ,1 , 0,keyReadObserver); | 
|---|
|  |  |  | boolean isSucc = keyPort.open(); | 
|---|
|  |  |  | if(isSucc) { | 
|---|
|  |  |  | isInitPort = true; | 
|---|
|  |  |  | getVM().addInfo("钥匙串口链接成功:"+path); | 
|---|
|  |  |  | String msg = isSucc ? "成功" : "失败"; | 
|---|
|  |  |  | //getVM().append("串口 "+ settingBean.getDevicePath() + " -连接"+msg); | 
|---|
|  |  |  | 
|---|
|  |  |  | ,1 , 0,jiuReadObserver); | 
|---|
|  |  |  | boolean isSucc = jiuPort.open(); | 
|---|
|  |  |  | if(isSucc) { | 
|---|
|  |  |  | isInitPort = true; | 
|---|
|  |  |  | getVM().addInfo("酒精串口链接成功:"+path); | 
|---|
|  |  |  | String msg = isSucc ? "成功" : "失败"; | 
|---|
|  |  |  | //getVM().append("串口 "+ settingBean.getDevicePath() + " -连接"+msg); | 
|---|
|  |  |  | 
|---|
|  |  |  | portHandler.sendEmptyMessageDelayed(0,0); | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | private CircularQueue openGridQueue = new CircularQueue(); | 
|---|
|  |  |  | private void send485(int type,String code){ | 
|---|
|  |  |  | runOnUiThread(new Runnable() { | 
|---|
|  |  |  | @Override | 
|---|
|  |  |  | public void run() { | 
|---|
|  |  |  | //todo 去掉 | 
|---|
|  |  |  | if(type==2){ | 
|---|
|  |  |  | return; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | getVM().addInfo("发送指令:"+StringUtil.DateToStrSS(new Date())+"==>"+code); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | }); | 
|---|
|  |  |  | if(type==0){ | 
|---|
|  |  |  | if(gridPort!=null){ | 
|---|
|  |  |  | if(code.startsWith("8A")){ | 
|---|
|  |  |  | openGridQueue.enqueue(code); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | byte[] sendByte = SportUtils.hexToByteArray(code); | 
|---|
|  |  |  | gridPort.write(sendByte); | 
|---|
|  |  |  | } | 
|---|