|
@ -200,17 +200,11 @@ public class ABGateManager { |
|
|
public boolean ABPeopleCheck() { |
|
|
public boolean ABPeopleCheck() { |
|
|
LogManager.logInfo(TAG, "执行AB门内人数检查"); |
|
|
LogManager.logInfo(TAG, "执行AB门内人数检查"); |
|
|
|
|
|
|
|
|
if (callback == null) { |
|
|
|
|
|
LogManager.logError(TAG, "ABPeopleCheck回调参数为空"); |
|
|
|
|
|
return; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// 检查485是否启用 |
|
|
// 检查485是否启用 |
|
|
if (!ox485.isGateCamera485OxOn()) { |
|
|
if (!ox485.isGateCamera485OxOn()) { |
|
|
String errorMsg = "485摄像头模式未启用"; |
|
|
String errorMsg = "485摄像头模式未启用"; |
|
|
LogManager.logError(TAG, errorMsg); |
|
|
LogManager.logError(TAG, errorMsg); |
|
|
callback.onError(errorMsg); |
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
throw new RuntimeException(errorMsg); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
try { |
|
|
try { |
|
@ -219,6 +213,9 @@ public class ABGateManager { |
|
|
String sceneType = isLeaveScene ? "离场" : "进场"; |
|
|
String sceneType = isLeaveScene ? "离场" : "进场"; |
|
|
LogManager.logInfo(TAG, "当前场景类型: " + sceneType); |
|
|
LogManager.logInfo(TAG, "当前场景类型: " + sceneType); |
|
|
|
|
|
|
|
|
|
|
|
// 创建超时控制的CompletableFuture |
|
|
|
|
|
CompletableFuture<Boolean> peopleCheckFuture = new CompletableFuture<>(); |
|
|
|
|
|
|
|
|
// 异步获取485人数 |
|
|
// 异步获取485人数 |
|
|
ox485.sendHex485ForPeopleNum(new Ox485.PeopleNumCallback() { |
|
|
ox485.sendHex485ForPeopleNum(new Ox485.PeopleNumCallback() { |
|
|
@Override |
|
|
@Override |
|
@ -241,41 +238,25 @@ public class ABGateManager { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
LogManager.logInfo(TAG, "人数检查结果: " + checkResult); |
|
|
LogManager.logInfo(TAG, "人数检查结果: " + checkResult); |
|
|
|
|
|
|
|
|
final boolean result = peopleCheckPassed; |
|
|
|
|
|
mainHandler.post(new Runnable() { |
|
|
|
|
|
@Override |
|
|
|
|
|
public void run() { |
|
|
|
|
|
callback.onSuccess(result); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
peopleCheckFuture.complete(peopleCheckPassed); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@Override |
|
|
@Override |
|
|
public void onError(String errorMessage) { |
|
|
public void onError(String errorMessage) { |
|
|
LogManager.logError(TAG, "485人数获取失败: " + errorMessage); |
|
|
LogManager.logError(TAG, "485人数获取失败: " + errorMessage); |
|
|
mainHandler.post(new Runnable() { |
|
|
|
|
|
@Override |
|
|
|
|
|
public void run() { |
|
|
|
|
|
callback.onError("485人数获取失败: " + errorMessage); |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
peopleCheckFuture.completeExceptionally(new RuntimeException("485人数获取失败: " + errorMessage)); |
|
|
} |
|
|
} |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
// 设置超时处理 |
|
|
|
|
|
mainHandler.postDelayed(new Runnable() { |
|
|
|
|
|
@Override |
|
|
|
|
|
public void run() { |
|
|
|
|
|
LogManager.logError(TAG, "人数检查超时"); |
|
|
|
|
|
callback.onError("人数检查超时"); |
|
|
|
|
|
} |
|
|
|
|
|
}, PEOPLE_CHECK_TIMEOUT); |
|
|
|
|
|
|
|
|
// 同步等待结果,设置超时 |
|
|
|
|
|
boolean result = peopleCheckFuture.get(PEOPLE_CHECK_TIMEOUT, TimeUnit.MILLISECONDS); |
|
|
|
|
|
LogManager.logInfo(TAG, "人数检查完成,结果: " + result); |
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
String errorMsg = "人数检查异常: " + e.getMessage(); |
|
|
String errorMsg = "人数检查异常: " + e.getMessage(); |
|
|
LogManager.logError(TAG, errorMsg, e); |
|
|
LogManager.logError(TAG, errorMsg, e); |
|
|
callback.onError(errorMsg); |
|
|
|
|
|
|
|
|
throw new RuntimeException(errorMsg); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|