Browse Source

X5版本适配

Shangyp 5 months ago
parent
commit
7041a61e38

+ 2 - 1
app/build.gradle

@@ -188,5 +188,6 @@ dependencies {
 
     //日期选择器
     implementation project(':DataPicker')
-
+    //紫鹏X5——jar包
+    implementation files('libs\\YNHAPI-20230413.jar')
 }

BIN
app/libs/YNHAPI-20230413.jar


+ 8 - 6
app/src/main/java/com/hanghui/senic/activity/view/ResultViewManager.java

@@ -63,6 +63,7 @@ import com.hanghui.senic.service.usbserialdemo.utile.SharedPreferencesUtils;
 import com.hanghui.senic.service.usbserialdemo.utile.StringIsNull;
 import com.hanghui.senic.service.usbserialdemo.utile.StringUtils;
 import com.hanghui.senic.service.usbserialdemo.utile.X1.RelaysAndLedUtile;
+import com.hanghui.senic.service.usbserialdemo.utile.X5.X5RelaysAndLedUtile;
 import com.hanghui.senic.service.usbserialdemo.utile.loacat.AppLogUtils;
 import com.hanghui.senic.view.CustomRoundAngleImageView;
 import com.hanghui.senic.view.IEditText;
@@ -1137,7 +1138,7 @@ public class ResultViewManager {
                 SignalNo = "";
                 isSignalRun = false;
                 if (ConfigManager.getAuthenticationBean().getData().get(0).getRelayOpenModel() == 2) {//开 - 门磁 -闭 模式
-                    RelaysAndLedUtile.getInstance().isOpenRelays(0);//1 开门 0关门
+                    X5RelaysAndLedUtile.getInstance().isOpenRelays(0);//1 开门 0关门
                 }
             }
         }
@@ -1165,7 +1166,7 @@ public class ResultViewManager {
         } else {
             if (ConfigManager.getAuthenticationBean().getData().get(0).getRelayOpenModel() == 2) {//开 - 门磁 -闭 模式
                 AppLogUtils.i(true, TAG, "下发继电器开门信号");
-                RelaysAndLedUtile.getInstance().isOpenRelays(1);//1 开门 0关门
+                X5RelaysAndLedUtile.getInstance().isOpenRelays(1);//1 开门 0关门
                 //打开60秒后自动执行下次逻辑的延时器
                 int GateTimeOut = 60;
                 if (ConfigManager.getAuthenticationBean().getData().get(0).getGateTimeOut() > 0) {
@@ -1175,12 +1176,12 @@ public class ResultViewManager {
                 AppHandler.getHandler().postDelayed(DoorMagneticTimerRunnable, GateTimeOut * 1000);
             } else {// 开 - 闭 模式
                 AppLogUtils.i(true, TAG, "下发继电器开门信号");
-                RelaysAndLedUtile.getInstance().isOpenRelays(1);//1 开门 0关门
+                X5RelaysAndLedUtile.getInstance().isOpenRelays(1);//1 开门 0关门
                 TimerTask timerTask = new TimerTask() {
                     @Override
                     public void run() {
                         AppLogUtils.i(true, TAG, "下发继电器关门信号");
-                        RelaysAndLedUtile.getInstance().isOpenRelays(0);//1 开门 0关门
+                        X5RelaysAndLedUtile.getInstance().isOpenRelays(0);//1 开门 0关门
                         int delayMillis = 1;
                         if (ConfigManager.getAuthenticationBean().getData().get(0).getSignalInterval() > 0) {
                             delayMillis = ConfigManager.getAuthenticationBean().getData().get(0).getSignalInterval();
@@ -2473,6 +2474,7 @@ public class ResultViewManager {
             loadingLocally_Text.setText(SucText);
         } else {
             outcomeActivity_OutcomeTextView.setText(SucText);
+            outcomeActivity_LinearLayout.setBackgroundResource(R.mipmap.background);
         }
         MTTSManager.getInstance().speak(ConfigManager.getAuthenticationBean().getData().get(0).getSucVoice());
         openDelay(ConfigManager.getAuthenticationBean().getData().get(0).getSuccessPageTime());
@@ -3204,9 +3206,9 @@ public class ResultViewManager {
     private void resetState() {
         PassportController.getInstance().isPassportIn = false;
         if (ConfigManager.getAuthenticationBean().getData().get(0).getFaceMode().equals("click")) {
-            RelaysAndLedUtile.getInstance().setLedLight(ConfigManager.getAuthenticationBean().getData().get(0).getLightMode(), false);
+            X5RelaysAndLedUtile.getInstance().setLedLight(ConfigManager.getAuthenticationBean().getData().get(0).getLightMode(), false);
         } else {
-            RelaysAndLedUtile.getInstance().setLedLight(ConfigManager.getAuthenticationBean().getData().get(0).getLightMode(), true);
+            X5RelaysAndLedUtile.getInstance().setLedLight(ConfigManager.getAuthenticationBean().getData().get(0).getLightMode(), true);
         }
         //判断是否为键盘
         if (!StringIsNull.IsStringNull(BusinessType) && BusinessType.equals(PAGE_TYPE_ENTERIDNUMBER)) {

+ 5 - 0
app/src/main/java/com/hanghui/senic/baiduface/BaiduFaceMainActivity.java

@@ -54,6 +54,7 @@ import com.hanghui.senic.service.usbserialdemo.utile.PopupWindowManager;
 import com.hanghui.senic.service.usbserialdemo.utile.SharedPreferencesUtils;
 import com.hanghui.senic.service.usbserialdemo.utile.StringIsNull;
 import com.hanghui.senic.service.usbserialdemo.utile.StringUtils;
+import com.hanghui.senic.service.usbserialdemo.utile.X5.GpioUtile;
 import com.hanghui.senic.service.usbserialdemo.utile.devicesUI.BaseDeviceUI;
 import com.hanghui.senic.service.usbserialdemo.utile.devicesUI.IDeviceUI;
 import com.hanghui.senic.service.usbserialdemo.utile.loacat.AppLogUtils;
@@ -376,6 +377,8 @@ public class BaiduFaceMainActivity extends BaseActivity {
         BroadcastManager.getInstance().registerNetworkChangeReceiver(netNetworkCallback);
         BroadcastManager.getInstance().registerUSBroadcastReceiver(usBroadcastCallback);
         PosManager.getInstance().init();
+        //门磁信号注册
+        GpioUtile.getInstance().init();
         //启动应用状态定时上报服务
         RegularReportingService.start(this);
         //ping百度,判断网络连接是否正常
@@ -621,6 +624,8 @@ public class BaiduFaceMainActivity extends BaseActivity {
         IDCardControllerManager.destroy();
 
         PosManager.getInstance().destroy();
+        //关门门磁信号
+        GpioUtile.getInstance().unlistenGpioState();
         //关闭二维码
         QRCodeController.getInstance().destroy();
         //关闭串口

+ 3 - 1
app/src/main/java/com/hanghui/senic/common/CommonUtil.java

@@ -27,6 +27,7 @@ import com.hanghui.senic.MyAppliction;
 import com.hanghui.senic.baiduface.OnePxActivity;
 import com.hanghui.senic.service.usbserialdemo.utile.ConfigManager;
 import com.hanghui.senic.service.usbserialdemo.utile.X1.RelaysAndLedUtile;
+import com.hanghui.senic.service.usbserialdemo.utile.X5.X5RelaysAndLedUtile;
 import com.hanghui.senic.service.usbserialdemo.utile.loacat.AppLogUtils;
 
 import java.net.InetAddress;
@@ -163,7 +164,8 @@ public class CommonUtil {
      */
     public static void setLedLight(boolean isOpenLedLight) {
         if (ConfigManager.getAuthenticationBean() != null && ConfigManager.getAuthenticationBean().getData() != null) {
-            RelaysAndLedUtile.getInstance().setLedLight(ConfigManager.getAuthenticationBean().getData().get(0).getLightMode(), isOpenLedLight);
+//            RelaysAndLedUtile.getInstance().setLedLight(ConfigManager.getAuthenticationBean().getData().get(0).getLightMode(), isOpenLedLight);
+            X5RelaysAndLedUtile.getInstance().setLedLight(ConfigManager.getAuthenticationBean().getData().get(0).getLightMode(), isOpenLedLight);
         }
     }
 

+ 3 - 2
app/src/main/java/com/hanghui/senic/service/usbserialdemo/utile/X1/RelaysAndLedUtile.java

@@ -52,8 +52,7 @@ public class RelaysAndLedUtile {
     //补光灯
     public void setLedLight(String Type, boolean isOpenLedLight) {
         if (DeviceUtils.getDeviceModel().equals(Constants.DeviceModel.ZP) ||
-                DeviceUtils.getDeviceModel().equals(Constants.DeviceModel.ZP_A10) ||
-                DeviceUtils.getDeviceModel().equals(Constants.DeviceModel.ZP_A50)) {
+                DeviceUtils.getDeviceModel().equals(Constants.DeviceModel.ZP_A10)) {
             Intent intent = new Intent();
             switch (Type) {
                 case "open":
@@ -80,6 +79,8 @@ public class RelaysAndLedUtile {
                     break;
             }
             return;
+        } else if (DeviceUtils.getDeviceModel().equals(Constants.DeviceModel.ZP_A50)){
+            CommonUtil.setLedLight(isOpenLedLight);
         }
         switch (Type) {
             case "open":

+ 77 - 0
app/src/main/java/com/hanghui/senic/service/usbserialdemo/utile/X5/GpioUtile.java

@@ -0,0 +1,77 @@
+package com.hanghui.senic.service.usbserialdemo.utile.X5;
+
+import android.preference.Preference;
+
+import com.hanghui.senic.service.usbserialdemo.utile.loacat.AppLogUtils;
+import com.innohi.YNHAPI;
+
+public class GpioUtile implements Preference.OnPreferenceChangeListener{
+    private static GpioUtile instance;
+    private static OnGpioListener listener;
+    private static final String KEY_GPIO_MODE = "gpio_mode";
+    private static final String KEY_SET_GPIO_STATE = "set_gpio_state";
+    private static final String KEY_GPIO_STATE = "gpio_state";
+    private YNHAPI.GpioListenerCallback mCallback = null;
+    private YNHAPI mYNHAPI = YNHAPI.getInstance();
+    private GpioUtile() {
+    }
+    public static GpioUtile getInstance() {
+        synchronized (GpioUtile.class) {
+            if (instance == null) {
+                instance = new GpioUtile();
+            }
+        }
+        return instance;
+    }
+    public void setListener(OnGpioListener listener) {
+        this.listener = listener;
+    }
+    public void init(){
+        YNHAPI.GpioMode mode = mYNHAPI.getGpioMode(YNHAPI.GPIO_5);
+        YNHAPI.GpioState state = mYNHAPI.getGpioState(YNHAPI.GPIO_5);
+        AppLogUtils.i(true,"紫鹏门磁信号初始化","init: mode =" + mode + ", state = " + state);
+        if (mode == YNHAPI.GpioMode.UNKNOWN || state == YNHAPI.GpioState.UNKNOWN) {
+            AppLogUtils.e(true,"紫鹏门磁信号初始化","无法正确获取获取GPIO的模式/状态!");
+            return;
+        }
+        listenInputGpioState();
+    }
+
+    private void listenInputGpioState() {
+        if (mCallback == null) {
+            mCallback = (index, oldState, newState) -> {
+                AppLogUtils.i(true,"紫鹏门磁信号回调","index = YNHAPI.GPIO_5" + ", old state = " + oldState + ", new state = " + newState);
+                //newState 1 - 断开   0 - 短接
+                listener.OnGpioListener(oldState,newState);
+            };
+            mYNHAPI.listenGpio(YNHAPI.GPIO_5, mCallback);
+        }
+    }
+
+    public void unlistenGpioState() {
+        if (mCallback != null) {
+            mYNHAPI.unlistenGpio(YNHAPI.GPIO_5, mCallback);
+            mCallback = null;
+        }
+    }
+
+    @Override
+    public boolean onPreferenceChange(Preference preference, Object newValue) {
+        switch (preference.getKey()) {
+            case KEY_GPIO_MODE:
+                boolean output = "1".equals(String.valueOf(newValue));
+                mYNHAPI.setGpioMode(YNHAPI.GPIO_5,YNHAPI.GpioMode.INPUT);
+                return true;
+
+            case KEY_SET_GPIO_STATE:
+                boolean high = "1".equals(String.valueOf(newValue));
+                mYNHAPI.setGpioState(YNHAPI.GPIO_5, high ? YNHAPI.GpioState.HIGH : YNHAPI.GpioState.LOW);
+                return true;
+        }
+        return false;
+    }
+
+    public interface OnGpioListener {
+        void OnGpioListener(int oldState,int newState);
+    }
+}

+ 76 - 0
app/src/main/java/com/hanghui/senic/service/usbserialdemo/utile/X5/X5RelaysAndLedUtile.java

@@ -0,0 +1,76 @@
+package com.hanghui.senic.service.usbserialdemo.utile.X5;
+
+import com.common.pos.api.util.PosUtil;
+import com.hanghui.senic.service.usbserialdemo.utile.FaceScenicUtile;
+import com.hanghui.senic.service.usbserialdemo.utile.devicesUI.Constants;
+import com.hanghui.senic.service.usbserialdemo.utile.devicesUI.DeviceUtils;
+import com.hanghui.senic.service.usbserialdemo.utile.loacat.AppLogUtils;
+import com.innohi.YNHAPI;
+
+/**
+ * @author David Chow
+ * @since 2021/3/27
+ */
+public class X5RelaysAndLedUtile {
+    private static X5RelaysAndLedUtile instance;
+    protected YNHAPI mYNHAPI;
+    private X5RelaysAndLedUtile() {
+        mYNHAPI = YNHAPI.getInstance();
+    }
+    public static X5RelaysAndLedUtile getInstance() {
+        synchronized (X5RelaysAndLedUtile.class) {
+            if (instance == null) {
+                instance = new X5RelaysAndLedUtile();
+            }
+        }
+        return instance;
+    }
+    //继电器开关
+    public void isOpenRelays(int newValue) {
+        if (DeviceUtils.getDeviceModel().equals(Constants.DeviceModel.ZP)||
+                DeviceUtils.getDeviceModel().equals(Constants.DeviceModel.ZP_A10) ||
+                DeviceUtils.getDeviceModel().equals(Constants.DeviceModel.ZP_A50)) {
+            boolean isOpen = false;
+            if (newValue == 1){
+                isOpen = true;
+            }
+            AppLogUtils.e(false, "硬件处理—X5继电器 ", "继电器开关门  "+isOpen);
+            mYNHAPI.setGpioState(YNHAPI.RELAY, isOpen ? YNHAPI.GpioState.HIGH : YNHAPI.GpioState.LOW);
+        }else {
+            PosUtil.setRelayPower(newValue);//1-开门  or 0-关门
+        }
+    }
+    //补光灯
+    public void setLedLight(String Type, boolean isOpenLedLight){
+        if (DeviceUtils.getDeviceModel().equals(Constants.DeviceModel.ZP)||
+                DeviceUtils.getDeviceModel().equals(Constants.DeviceModel.ZP_A10)||
+                DeviceUtils.getDeviceModel().equals(Constants.DeviceModel.ZP_A50)) {
+            mYNHAPI.setLightBrightness(YNHAPI.LIGHT_WHITE, true ? 0 : 0);
+//            switch (Type) {
+//                case "open":
+//                    mYNHAPI.setLightBrightness(YNHAPI.LIGHT_WHITE, true ? 204 : 0);
+//                    break;
+//                case "auto":
+//                    mYNHAPI.setLightBrightness(YNHAPI.LIGHT_WHITE, isOpenLedLight ? 204 : 0);
+//                    break;
+//                case "close":
+//                default:
+//                    mYNHAPI.setLightBrightness(YNHAPI.LIGHT_WHITE, false ? 204 : 0);
+//                    break;
+//            }
+            return;
+        }
+        switch (Type) {
+            case "open":
+                FaceScenicUtile.setLedLight(true);
+                break;
+            case "auto":
+                FaceScenicUtile.setLedLight(isOpenLedLight);
+                break;
+            case "close":
+            default:
+                FaceScenicUtile.setLedLight(false);
+                break;
+        }
+    }
+}

+ 1 - 1
app/src/main/res/values/strings.xml

@@ -1,5 +1,5 @@
 <resources xmlns:tools="http://schemas.android.com/tools">
-    <string name="app_name">HHFaceScenic</string>
+    <string name="app_name">HHLocal</string>
     <string name="PassportIn_zh" tools:ignore="MissingTranslation">证件识别中(%1$d</string>
 
     <string name="resource_location">values</string>

+ 4 - 4
gatelibrary/src/main/java/com/baidu/idl/main/facesdk/model/BaseConfig.java

@@ -201,11 +201,11 @@ public class BaseConfig {
 
     // 默认为0。可传入0、90、180、270四个选项。
     //private int rgbVideoDirection = 0;
-    private int rgbVideoDirection = 270;
+    private int rgbVideoDirection = 90;
 
     // 默认为0。可传入0、90、180、270四个选项。
     //private int nirVideoDirection = 0;
-    private int nirVideoDirection = 270;
+    private int nirVideoDirection = 90;
 
     // 0:RGB无镜像,1:有镜像
     private int mirrorVideoRGB = 0;
@@ -215,11 +215,11 @@ public class BaseConfig {
 
     // rbg人脸检测角度 默认为0。可传入0、90、180、270四个选项。
     //private int rgbDetectDirection = 0;
-    private int rgbDetectDirection = 270;
+    private int rgbDetectDirection = 90;
 
     // nir人脸检测角度 默认为0。可传入0、90、180、270四个选项。
     //private int nirDetectDirection = 0;
-    private int nirDetectDirection = 270;
+    private int nirDetectDirection = 90;
 
     // rbg人脸检测 0:RGB无镜像,1:有镜像
     private int mirrorDetectRGB = 0;