Browse Source

算法更新

develop
白凤吉 2 months ago
parent
commit
b22a25a127
  1. 13
      app/src/main/assets/web/asset-manifest.json
  2. BIN
      app/src/main/assets/web/audio/alert_left.mp3
  3. BIN
      app/src/main/assets/web/audio/begin_left.mp3
  4. BIN
      app/src/main/assets/web/audio/begin_right.mp3
  5. BIN
      app/src/main/assets/web/audio/end_left.mp3
  6. BIN
      app/src/main/assets/web/audio/end_right.mp3
  7. BIN
      app/src/main/assets/web/audio/measure_end.mp3
  8. BIN
      app/src/main/assets/web/audio/measuring.mp3
  9. BIN
      app/src/main/assets/web/audio/ready.mp3
  10. BIN
      app/src/main/assets/web/audio/side_end.mp3
  11. 2
      app/src/main/assets/web/index.html
  12. 4
      app/src/main/assets/web/static/css/main.b5101f43.css
  13. 1
      app/src/main/assets/web/static/css/main.b5101f43.css.map
  14. 4
      app/src/main/assets/web/static/css/main.f112be1c.css
  15. 1
      app/src/main/assets/web/static/css/main.f112be1c.css.map
  16. 6
      app/src/main/assets/web/static/js/main.58833ad2.js
  17. 0
      app/src/main/assets/web/static/js/main.58833ad2.js.LICENSE.txt
  18. 1
      app/src/main/assets/web/static/js/main.58833ad2.js.map
  19. 1
      app/src/main/assets/web/static/js/main.d8dcad23.js.map
  20. 1
      app/src/main/assets/web/static/media/power.544f6ce9a5b3e930a515cf130f9f9551.svg
  21. 3
      app/src/main/java/com/iflytop/profilometer/ProfilometerApplication.java
  22. 9
      app/src/main/java/com/iflytop/profilometer/api/ble/BleApi.java
  23. 30
      app/src/main/java/com/iflytop/profilometer/api/system/SystemApi.java
  24. 6
      app/src/main/java/com/iflytop/profilometer/common/constant/LogTag.java
  25. 3
      app/src/main/java/com/iflytop/profilometer/core/bluetooth/BleDeviceListener.java
  26. 64
      app/src/main/java/com/iflytop/profilometer/core/bluetooth/BleManager.java
  27. 4
      app/src/main/java/com/iflytop/profilometer/core/bluetooth/BlePingManager.java
  28. 2
      app/src/main/java/com/iflytop/profilometer/core/migration/algo/ProfilometerPulleyPointPreProcesser.java
  29. 4
      app/src/main/java/com/iflytop/profilometer/core/migration/algo/ProfilometerRecorder.java
  30. 2
      app/src/main/java/com/iflytop/profilometer/core/migration/algo/type/ProfilometerAlgoConfig.java
  31. 2
      app/src/main/java/com/iflytop/profilometer/core/migration/algo/type/Version.java
  32. 3
      app/src/main/java/com/iflytop/profilometer/core/migration/channel/BleDeviceUartChannel.java
  33. 19
      app/src/main/java/com/iflytop/profilometer/service/RailProfileDrawerService.java

13
app/src/main/assets/web/asset-manifest.json

@ -1,7 +1,7 @@
{
"files": {
"main.css": "/static/css/main.b5101f43.css",
"main.js": "/static/js/main.d8dcad23.js",
"main.css": "/static/css/main.f112be1c.css",
"main.js": "/static/js/main.58833ad2.js",
"static/js/453.e7f11a48.chunk.js": "/static/js/453.e7f11a48.chunk.js",
"static/media/icon_leftR.svg": "/static/media/icon_leftR.76cd3e03bb846b0bacb0a84808f24c36.svg",
"static/media/icon_tab3_u.svg": "/static/media/icon_tab3_u.6d18cbd7c4dc6a54f745fdfcc7716050.svg",
@ -24,13 +24,14 @@
"static/media/icon_tab4_s.svg": "/static/media/icon_tab4_s.0f67ddc554b55cdcf7f678a0820bc9e4.svg",
"static/media/icon_tab4_u.svg": "/static/media/icon_tab4_u.43586d94d1ed2577d962f54171ad0160.svg",
"static/media/icon_bluetooth.svg": "/static/media/icon_bluetooth.a48021d03233ba0570bf3960cddf6a65.svg",
"static/media/power.svg": "/static/media/power.544f6ce9a5b3e930a515cf130f9f9551.svg",
"static/media/icon_check_s_u.svg": "/static/media/icon_check_s_u.2c5e20bec088338dc1cb2161b5cba37d.svg",
"main.b5101f43.css.map": "/static/css/main.b5101f43.css.map",
"main.d8dcad23.js.map": "/static/js/main.d8dcad23.js.map",
"main.f112be1c.css.map": "/static/css/main.f112be1c.css.map",
"main.58833ad2.js.map": "/static/js/main.58833ad2.js.map",
"453.e7f11a48.chunk.js.map": "/static/js/453.e7f11a48.chunk.js.map"
},
"entrypoints": [
"static/css/main.b5101f43.css",
"static/js/main.d8dcad23.js"
"static/css/main.f112be1c.css",
"static/js/main.58833ad2.js"
]
}

BIN
app/src/main/assets/web/audio/alert_left.mp3

BIN
app/src/main/assets/web/audio/begin_left.mp3

BIN
app/src/main/assets/web/audio/begin_right.mp3

BIN
app/src/main/assets/web/audio/end_left.mp3

BIN
app/src/main/assets/web/audio/end_right.mp3

BIN
app/src/main/assets/web/audio/measure_end.mp3

BIN
app/src/main/assets/web/audio/measuring.mp3

BIN
app/src/main/assets/web/audio/ready.mp3

BIN
app/src/main/assets/web/audio/side_end.mp3

2
app/src/main/assets/web/index.html

@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no"/><title>廓形仪</title><script defer="defer" src="/static/js/main.d8dcad23.js"></script><link href="/static/css/main.b5101f43.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>function setupWebViewJavascriptBridge(e){if(window.WebViewJavascriptBridge)return e(WebViewJavascriptBridge);if(/android/i.test(navigator.userAgent))document.addEventListener("WebViewJavascriptBridgeReady",(function(){e(WebViewJavascriptBridge)}),!1);else{if(window.WVJBCallbacks)return window.WVJBCallbacks.push(e);window.WVJBCallbacks=[e];var i=document.createElement("iframe");i.style.display="none",i.src="https://__bridge_loaded__",document.documentElement.appendChild(i),setTimeout((function(){document.documentElement.removeChild(i)}),0)}}setupWebViewJavascriptBridge((function(e){window.bridge=e}));var SyncBridgeJS={call:function(e,i){return prompt("sync/syncBridge/"+e,i)}}</script></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=no"/><title>廓形仪</title><script defer="defer" src="/static/js/main.58833ad2.js"></script><link href="/static/css/main.f112be1c.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>function setupWebViewJavascriptBridge(e){if(window.WebViewJavascriptBridge)return e(WebViewJavascriptBridge);if(/android/i.test(navigator.userAgent))document.addEventListener("WebViewJavascriptBridgeReady",(function(){e(WebViewJavascriptBridge)}),!1);else{if(window.WVJBCallbacks)return window.WVJBCallbacks.push(e);window.WVJBCallbacks=[e];var i=document.createElement("iframe");i.style.display="none",i.src="https://__bridge_loaded__",document.documentElement.appendChild(i),setTimeout((function(){document.documentElement.removeChild(i)}),0)}}setupWebViewJavascriptBridge((function(e){window.bridge=e}));var SyncBridgeJS={call:function(e,i){return prompt("sync/syncBridge/"+e,i)}}</script></body></html>

4
app/src/main/assets/web/static/css/main.b5101f43.css
File diff suppressed because it is too large
View File

1
app/src/main/assets/web/static/css/main.b5101f43.css.map
File diff suppressed because it is too large
View File

4
app/src/main/assets/web/static/css/main.f112be1c.css
File diff suppressed because it is too large
View File

1
app/src/main/assets/web/static/css/main.f112be1c.css.map
File diff suppressed because it is too large
View File

6
app/src/main/assets/web/static/js/main.58833ad2.js
File diff suppressed because it is too large
View File

0
app/src/main/assets/web/static/js/main.d8dcad23.js.LICENSE.txt → app/src/main/assets/web/static/js/main.58833ad2.js.LICENSE.txt

1
app/src/main/assets/web/static/js/main.58833ad2.js.map
File diff suppressed because it is too large
View File

1
app/src/main/assets/web/static/js/main.d8dcad23.js.map
File diff suppressed because it is too large
View File

1
app/src/main/assets/web/static/media/power.544f6ce9a5b3e930a515cf130f9f9551.svg

@ -0,0 +1 @@
<?xml version="1.0" standalone="no"?><!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.1//EN" "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd"><svg t="1749353079688" class="icon" viewBox="0 0 1024 1024" version="1.1" xmlns="http://www.w3.org/2000/svg" p-id="7537" width="48" height="48" xmlns:xlink="http://www.w3.org/1999/xlink"><path d="M467.301105 179.2821l-190.958547 373.403017h229.636774l-103.020311 291.911153 407.824207-452.827176h-255.422259l124.427129-212.486994H467.301105z" fill="#fff" p-id="7538"></path></svg>

3
app/src/main/java/com/iflytop/profilometer/ProfilometerApplication.java

@ -10,6 +10,7 @@ import androidx.annotation.NonNull;
import com.iflytop.profilometer.api.ws.DeviceStateWebsocketManager;
import com.iflytop.profilometer.common.constant.BaseDataType;
import com.iflytop.profilometer.common.constant.LogTag;
import com.iflytop.profilometer.common.constant.SystemConfigType;
import com.iflytop.profilometer.core.system.SystemService;
import com.iflytop.profilometer.dao.BaseDataDao;
@ -36,7 +37,7 @@ public class ProfilometerApplication extends Application {
super.onCreate();
Thread.setDefaultUncaughtExceptionHandler((thread, e) -> {
Log.e("UncaughtException", "Uncaught exception in thread " + thread.getName(), e);
Log.e(LogTag.PROFILOMENTER, "Uncaught exception in thread " + thread.getName(), e);
// 可选择上报日志或预处理
});

9
app/src/main/java/com/iflytop/profilometer/api/ble/BleApi.java

@ -5,6 +5,7 @@ import android.content.Context;
import android.util.Log;
import com.iflytop.profilometer.api.ws.BleWebsocketManager;
import com.iflytop.profilometer.common.constant.LogTag;
import com.iflytop.profilometer.common.result.Result;
import com.iflytop.profilometer.core.bluetooth.BleDeviceDriver;
import com.iflytop.profilometer.core.bluetooth.BleManager;
@ -34,7 +35,7 @@ public class BleApi {
BleWebsocketManager.getInstance().startWsPush();
return Result.success();
} catch (Exception e) {
Log.e(TAG, "开始获取蓝牙列表失败", e);
Log.e(LogTag.PROFILOMENTER, "开始获取蓝牙列表失败", e);
return Result.failed("获取蓝牙列表失败");
}
}
@ -48,7 +49,7 @@ public class BleApi {
BleManager.getInstance().stopScan();
return Result.success();
} catch (Exception e) {
Log.e(TAG, "结束获取蓝牙设备列表失败", e);
Log.e(LogTag.PROFILOMENTER, "结束获取蓝牙设备列表失败", e);
return Result.failed();
}
}
@ -73,7 +74,7 @@ public class BleApi {
BleWebsocketManager.getInstance().startWsPush();//链接失败后继续扫描并推送
BleManager.getInstance().startScan();
BlePingManager.getInstance().stopPing();
Log.e(TAG, "链接蓝牙设备失败", e);
Log.e(LogTag.PROFILOMENTER, "链接蓝牙设备失败", e);
return Result.failed("链接蓝牙设备失败");
}
}
@ -95,7 +96,7 @@ public class BleApi {
BleWebsocketManager.getInstance().stopWsPush();//断开连接失败
BleManager.getInstance().stopScan();
BlePingManager.getInstance().startPing();
Log.e(TAG, "断开蓝牙设备链接失败", e);
Log.e(LogTag.PROFILOMENTER, "断开蓝牙设备链接失败", e);
return Result.failed("断开蓝牙设备链接失败");
}
}

30
app/src/main/java/com/iflytop/profilometer/api/system/SystemApi.java

@ -3,6 +3,7 @@ package com.iflytop.profilometer.api.system;
import android.content.Context;
import android.util.Log;
import com.iflytop.profilometer.common.constant.LogTag;
import com.iflytop.profilometer.common.constant.SystemConfigType;
import com.iflytop.profilometer.common.result.Result;
import com.iflytop.profilometer.core.bluetooth.BleDeviceDriver;
@ -28,21 +29,16 @@ public class SystemApi {
SystemConfigVO systemConfigVO = new SystemConfigVO();
if (serverConfig != null) {
systemConfigVO.setServer(serverConfig.getConfigValue());
try {
if (BleManager.getInstance().isConnected()) {
BleDeviceDriver bleDeviceDriver = SystemService.getInstance().getBleDeviceDriver();
Integer standbyMinutesByDevice = bleDeviceDriver.getStandbyInactiveTime();
systemConfigVO.setStandbyMinutes(standbyMinutesByDevice / 60 / 1000);
}
} catch (Exception e) {
e.printStackTrace();
Log.e("SYSTEM API", "获取设备自动待机时间出错");
if (BleManager.getInstance().isConnected()) {
BleDeviceDriver bleDeviceDriver = SystemService.getInstance().getBleDeviceDriver();
Integer standbyMinutesByDevice = bleDeviceDriver.getStandbyInactiveTime();
systemConfigVO.setStandbyMinutes(standbyMinutesByDevice / 60 / 1000);
}
}
try {
if (BleManager.getInstance().isConnected()) {
BleDeviceDriver bleDeviceDriver = SystemService.getInstance().getBleDeviceDriver();
Integer standbyMinutesByDevice = bleDeviceDriver.getStandbyInactiveTime();
systemConfigVO.setStandbyMinutes(standbyMinutesByDevice / 60 / 1000);
}
} catch (Exception e) {
e.printStackTrace();
Log.e(LogTag.PROFILOMENTER, "获取设备自动待机时间出错");
}
return Result.success(systemConfigVO);
}
@ -63,11 +59,7 @@ public class SystemApi {
}
} catch (Exception e) {
e.printStackTrace();
Log.e("SYSTEM API", "保存设备自动待机时间出错");
if (BleManager.getInstance().isConnected()) {
BleDeviceDriver bleDeviceDriver = SystemService.getInstance().getBleDeviceDriver();
bleDeviceDriver.setStandbyInactiveTime(standbyMinutes * 60 * 1000);
}
Log.e(LogTag.PROFILOMENTER, "保存设备自动待机时间出错");
}
return Result.success();
}

6
app/src/main/java/com/iflytop/profilometer/common/constant/LogTag.java

@ -0,0 +1,6 @@
package com.iflytop.profilometer.common.constant;
public class LogTag {
public static final String PROFILOMENTER = "PROFILOMENTER";
}

3
app/src/main/java/com/iflytop/profilometer/core/bluetooth/BleDeviceListener.java

@ -2,6 +2,7 @@ package com.iflytop.profilometer.core.bluetooth;
import android.util.Log;
import com.iflytop.profilometer.common.constant.LogTag;
import com.iflytop.profilometer.core.migration.algo.ProfilometerRecorder;
import com.iflytop.profilometer.core.migration.type.protocol.TPMIBasicReport;
import com.iflytop.profilometer.core.migration.type.protocol.TPMIPacket;
@ -15,7 +16,7 @@ public class BleDeviceListener implements BleDeviceOnReportListener {
@Override
public void onBasicReport(TPMIBasicReport report) {
Log.i(TAG, "基础上报包:" + report);
Log.i(LogTag.PROFILOMENTER, "基础上报包:" + report);
DeviceState deviceState = SystemService.getInstance().getDeviceState();
deviceState.setTemperature(report.getTemperature());
deviceState.setInclinatorX(report.getInclinatorX());

64
app/src/main/java/com/iflytop/profilometer/core/bluetooth/BleManager.java

@ -30,6 +30,7 @@ import android.widget.Toast;
import androidx.core.content.ContextCompat;
import com.iflytop.profilometer.common.constant.LogTag;
import com.iflytop.profilometer.core.migration.channel.BleDeviceUartChannel;
import com.iflytop.profilometer.core.system.DeviceState;
import com.iflytop.profilometer.core.system.SystemService;
@ -172,7 +173,7 @@ public class BleManager {
*/
public void promptAndEnableBluetooth(Activity activity) {
if (bluetoothAdapter == null) {
Log.e(TAG, "该设备不支持蓝牙");
Log.e(LogTag.PROFILOMENTER, "该设备不支持蓝牙");
return;
}
if (bluetoothAdapter.isEnabled()) {
@ -213,33 +214,33 @@ public class BleManager {
public void startScan() {
// 检查蓝牙是否开启
if (!isBluetoothEnabled()) {
Log.e(TAG, "蓝牙未开启,请先开启蓝牙");
Log.e(LogTag.PROFILOMENTER, "蓝牙未开启,请先开启蓝牙");
Toast.makeText(context, "蓝牙未开启,请先开启蓝牙", Toast.LENGTH_LONG).show();
return;
}
// 检查是否支持 BLE
if (!isBleSupported()) {
Log.e(TAG, "该设备不支持BLE");
Log.e(LogTag.PROFILOMENTER, "该设备不支持BLE");
Toast.makeText(context, "该设备不支持BLE", Toast.LENGTH_LONG).show();
return;
}
// 检查定位服务是否开启
if (!isLocationEnabled()) {
Log.e(TAG, "定位服务未开启,请开启定位服务");
Log.e(LogTag.PROFILOMENTER, "定位服务未开启,请开启定位服务");
Toast.makeText(context, "定位服务未开启,请开启定位服务", Toast.LENGTH_LONG).show();
return;
}
if (bluetoothAdapter == null || !bluetoothAdapter.isEnabled()) {
Log.e(TAG, "蓝牙未开启或不可用");
Log.e(LogTag.PROFILOMENTER, "蓝牙未开启或不可用");
return;
}
if (!hasPermission(Manifest.permission.BLUETOOTH_SCAN)) {
Log.e(TAG, "BLUETOOTH_SCAN 权限未授予");
Log.e(LogTag.PROFILOMENTER, "BLUETOOTH_SCAN 权限未授予");
return;
}
bluetoothLeScanner = bluetoothAdapter.getBluetoothLeScanner();
if (bluetoothLeScanner == null) {
Log.e(TAG, "获取 BluetoothLeScanner 失败");
Log.e(LogTag.PROFILOMENTER, "获取 BluetoothLeScanner 失败");
return;
}
// 清空之前的数据
@ -264,6 +265,7 @@ public class BleManager {
if (!isConnected()) {
stopScan();
connectToDeviceSync(address);
BlePingManager.getInstance().startPing();
}
return;
}
@ -302,7 +304,7 @@ public class BleManager {
@Override
public void onScanFailed(int errorCode) {
Log.e(TAG, "BLE 扫描失败,错误码:" + errorCode);
Log.e(LogTag.PROFILOMENTER, "BLE 扫描失败,错误码:" + errorCode);
}
};
@ -314,7 +316,7 @@ public class BleManager {
bluetoothLeScanner.startScan(null, settings, scanCallback);
cleanupHandler.postDelayed(cleanupRunnable, CLEANUP_INTERVAL);
Log.i(TAG, "开始扫描蓝牙列表");
Log.i(LogTag.PROFILOMENTER, "开始扫描蓝牙列表");
}
/**
@ -323,11 +325,11 @@ public class BleManager {
@SuppressLint("MissingPermission")
public void stopScan() {
if (bluetoothAdapter == null || !bluetoothAdapter.isEnabled()) {
Log.e(TAG, "蓝牙未开启或不可用");
Log.e(LogTag.PROFILOMENTER, "蓝牙未开启或不可用");
return;
}
if (!hasPermission(Manifest.permission.BLUETOOTH_SCAN)) {
Log.e(TAG, "BLUETOOTH_SCAN 权限未授予");
Log.e(LogTag.PROFILOMENTER, "BLUETOOTH_SCAN 权限未授予");
return;
}
if (bluetoothLeScanner != null && scanCallback != null) {
@ -335,7 +337,7 @@ public class BleManager {
scanCallback = null;
}
cleanupHandler.removeCallbacks(cleanupRunnable);
Log.i(TAG, "结束扫描蓝牙列表");
Log.i(LogTag.PROFILOMENTER, "结束扫描蓝牙列表");
}
/**
@ -361,11 +363,11 @@ public class BleManager {
@SuppressLint("MissingPermission")
public boolean connectToDeviceSync(String macAddress) {
if (macAddress == null || macAddress.isEmpty()) {
Log.e(TAG, "MAC 地址为空");
Log.e(LogTag.PROFILOMENTER, "MAC 地址为空");
return false;
}
if (!hasPermission(Manifest.permission.BLUETOOTH_CONNECT)) {
Log.e(TAG, "BLUETOOTH_CONNECT 权限未授予");
Log.e(LogTag.PROFILOMENTER, "BLUETOOTH_CONNECT 权限未授予");
return false;
}
@ -395,8 +397,9 @@ public class BleManager {
gatt.discoverServices();
} else if (newState == BluetoothProfile.STATE_DISCONNECTED) {
Log.d(TAG, "设备已断开连接");
disconnect();
if (status != BluetoothGatt.GATT_SUCCESS) {
Log.e(TAG, "连接失败,错误码:" + status);
Log.e(LogTag.PROFILOMENTER, "连接失败,错误码:" + status);
connectionSuccess.set(false);
}
if (!latchTriggered.getAndSet(true)) {
@ -425,15 +428,15 @@ public class BleManager {
descriptor.setValue(BluetoothGattDescriptor.ENABLE_NOTIFICATION_VALUE);
gatt.writeDescriptor(descriptor);
} else {
Log.e(TAG, "未发现描述符 " + CLIENT_CHARACTERISTIC_CONFIG_UUID);
Log.e(LogTag.PROFILOMENTER, "未发现描述符 " + CLIENT_CHARACTERISTIC_CONFIG_UUID);
}
} else {
Log.e(TAG, "未发现通知特征 " + NOTIFY_CHARACTERISTIC_UUID);
Log.e(LogTag.PROFILOMENTER, "未发现通知特征 " + NOTIFY_CHARACTERISTIC_UUID);
}
}
connectionSuccess.set(true);
} else {
Log.e(TAG, "服务发现失败,错误码:" + status);
Log.e(LogTag.PROFILOMENTER, "服务发现失败,错误码:" + status);
connectionSuccess.set(false);
}
if (!latchTriggered.getAndSet(true)) {
@ -454,9 +457,9 @@ public class BleManager {
@Override
public void onCharacteristicWrite(BluetoothGatt gatt, BluetoothGattCharacteristic characteristic, int status) {
if (status != BluetoothGatt.GATT_SUCCESS) {
Log.i(TAG, "数据写入失败,错误码:" + status);
Log.i(LogTag.PROFILOMENTER, "数据写入失败,错误码:" + status);
} else {
Log.i(TAG, "数据写入成功" + status);
Log.i(LogTag.PROFILOMENTER, "数据写入成功" + status);
}
}
};
@ -465,19 +468,19 @@ public class BleManager {
BluetoothDevice device = bluetoothAdapter.getRemoteDevice(macAddress);
bluetoothGatt = device.connectGatt(context, USE_AUTO_CONNECT, syncGattCallback);
} catch (IllegalArgumentException e) {
Log.e(TAG, "无效的 MAC 地址: " + macAddress, e);
Log.e(LogTag.PROFILOMENTER, "无效的 MAC 地址: " + macAddress, e);
return false;
}
// 同步等待最大 15
try {
if (!latch.await(15, TimeUnit.SECONDS)) {
Log.e(TAG, "连接超时");
Log.e(LogTag.PROFILOMENTER, "连接超时");
disconnect();
return false;
}
} catch (InterruptedException e) {
Log.e(TAG, "等待连接过程中被中断", e);
Log.e(LogTag.PROFILOMENTER, "等待连接过程中被中断", e);
disconnect();
return false;
}
@ -512,23 +515,24 @@ public class BleManager {
@SuppressLint("MissingPermission")
public void sendMessage(byte[] rawpacket) {
if (bluetoothGatt == null) {
Log.e(TAG, "没有连接的设备,无法发送消息");
Log.e(LogTag.PROFILOMENTER, "没有连接的设备,无法发送消息");
disconnect();
return;
}
BluetoothGattService service = bluetoothGatt.getService(SERVICE_UUID);
if (service == null) {
Log.e(TAG, "未发现目标服务,请确认服务 UUID 是否正确");
Log.e(LogTag.PROFILOMENTER, "未发现目标服务,请确认服务 UUID 是否正确");
return;
}
BluetoothGattCharacteristic writeCharacteristic = service.getCharacteristic(WRITE_CHARACTERISTIC_UUID);
if (writeCharacteristic == null) {
Log.e(TAG, "未发现写特征,请确认写特征 UUID 是否正确");
Log.e(LogTag.PROFILOMENTER, "未发现写特征,请确认写特征 UUID 是否正确");
return;
}
writeCharacteristic.setValue(rawpacket);
boolean result = bluetoothGatt.writeCharacteristic(writeCharacteristic);
if (!result) {
Log.e(TAG, "调用 writeCharacteristic 失败");
Log.e(LogTag.PROFILOMENTER, "调用 writeCharacteristic 失败");
}
}
@ -544,6 +548,12 @@ public class BleManager {
bluetoothGatt = null;
DeviceState deviceState = SystemService.getInstance().getDeviceState();
deviceState.setConnected(false);
deviceState.setTemperature(null);
deviceState.setInclinatorX(null);
deviceState.setInclinatorY(null);
deviceState.setPower(null);
deviceState.setFlag(null);
deviceState.setState(null);
SharedPreferences prefs = context.getSharedPreferences("profilometer", MODE_PRIVATE);
SharedPreferences.Editor editor = prefs.edit();

4
app/src/main/java/com/iflytop/profilometer/core/bluetooth/BlePingManager.java

@ -4,11 +4,13 @@ import android.annotation.SuppressLint;
import android.bluetooth.BluetoothDevice;
import android.util.Log;
import com.iflytop.profilometer.common.constant.LogTag;
import com.iflytop.profilometer.core.migration.type.protocol.TPMIPacket;
import com.iflytop.profilometer.core.system.SystemService;
import com.iflytop.profilometer.core.websocket.WebSocketManager;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.concurrent.Executors;
@ -43,6 +45,7 @@ public class BlePingManager {
scheduledTask = scheduler.scheduleWithFixedDelay(() -> {
BleDeviceDriver bleDeviceDriver = SystemService.getInstance().getBleDeviceDriver();
bleDeviceDriver.ping();
Log.i(LogTag.PROFILOMENTER,"PING>..");
}, 0, 1000, TimeUnit.MILLISECONDS);
}
@ -51,6 +54,7 @@ public class BlePingManager {
*/
public void stopPing() {
if (scheduledTask != null && !scheduledTask.isCancelled()) {
Log.i(LogTag.PROFILOMENTER,"STOP>..");
scheduledTask.cancel(false);
}
}

2
app/src/main/java/com/iflytop/profilometer/core/migration/algo/ProfilometerPulleyPointPreProcesser.java

@ -86,6 +86,8 @@ public class ProfilometerPulleyPointPreProcesser {
outline2 = filterTheClosedPoint(config, outline2, line2side);
outline2 = filterTheTails(config, outline2, line2side);
outline2.add(0, outline1.get(0));
ProfilometerPulleyPointPreProcesseReport report = new ProfilometerPulleyPointPreProcesseReport();
report.outline1 = outline1;
report.outline1Side = line1side;

4
app/src/main/java/com/iflytop/profilometer/core/migration/algo/ProfilometerRecorder.java

@ -45,6 +45,8 @@ public class ProfilometerRecorder {
XYPoint runDirection = null;
int speedNow = 0; // 0->100(+) 用户移动滑轮的速度速度为接近100时图像可能会发生失真需要警告用户,大于100时需要停止测量
static public double recordRedundancy = 5;
ProfilometerDrawerListener listener;
ProfilometerAlgoConfig cfg = new ProfilometerAlgoConfig();
DeviceProfile deviceProfile;
@ -397,7 +399,7 @@ public class ProfilometerRecorder {
*
*/
if ((leftSideReady && newPoint.x >= firstSideXVal) || rightSideReady && newPoint.x <= firstSideXVal) {
if ((leftSideReady && newPoint.x >= firstSideXVal - recordRedundancy) || rightSideReady && newPoint.x <= firstSideXVal + recordRedundancy) {
//开始测量第二条曲线
status = RailProfileMeasureTaskStatus.RECORD_THE_2ND_SIDE;
loginfo("开始测量第二条曲线 {}", firstSide.getOpposite());

2
app/src/main/java/com/iflytop/profilometer/core/migration/algo/type/ProfilometerAlgoConfig.java

@ -6,7 +6,7 @@ public class ProfilometerAlgoConfig {
public int startOutlineRecordingTimingJudgmentAreaWeight = 90; // 开始采样静止时间判定区域权重单位mm
public double precision = 0.10; // 采样精度(mm) 当其等于0.12mm,满足测量长度13cm的情况下1500个点.
public double overSamplePrecision = 0.03; // 过采样精度(mm) 0.03mm
public double displayPrecision = 0.3; // 显示精度(影响采样时候的回调的次数)
public double displayPrecision = 1.5; // 显示精度(影响采样时候的回调的次数)
public double stillJudgeThreshold = 0.5; // 静止判断阈值(mm),当前点与上一个点的距离小于该值认为静止
public double outlineComputeRefPointDistance = 0.2; // (mm) 计算轮廓线时两个参考点距离
public double directionJudgePointDistance = 1;// (mm) 方向判断点距离,该值越大方向判定越准确结束条件判定也就更准确但是错误的采样点数也会增加

2
app/src/main/java/com/iflytop/profilometer/core/migration/algo/type/Version.java

@ -1,7 +1,7 @@
package com.iflytop.profilometer.core.migration.algo.type;
public class Version {
static public final Integer VERSION_MAIN = 27;
static public final Integer VERSION_MAIN = 29;
static public String getVersion() {
return String.format("V%d", VERSION_MAIN);

3
app/src/main/java/com/iflytop/profilometer/core/migration/channel/BleDeviceUartChannel.java

@ -2,6 +2,7 @@ package com.iflytop.profilometer.core.migration.channel;
import android.util.Log;
import com.iflytop.profilometer.common.constant.LogTag;
import com.iflytop.profilometer.core.bluetooth.BleDeviceOnReportListener;
import com.iflytop.profilometer.core.bluetooth.BleManager;
import com.iflytop.profilometer.core.migration.factory.TPMIPacketFactory;
@ -76,7 +77,7 @@ public class BleDeviceUartChannel {
}
public synchronized TPMIPacket sendCommand(TPMIPacket tx, Integer timeoutMs) {
Log.i("BLE", "TX PACKET: " + tx);
Log.i(LogTag.PROFILOMENTER, "TX PACKET: " + tx);
ctCxt.newCtCxt(tx);
BleManager.getInstance().sendMessage(tx.rawpacket);
try {

19
app/src/main/java/com/iflytop/profilometer/service/RailProfileDrawerService.java

@ -1,6 +1,10 @@
package com.iflytop.profilometer.service;
import android.util.Log;
import com.iflytop.profilometer.common.constant.LogTag;
import com.iflytop.profilometer.core.bluetooth.BleDeviceDriver;
import com.iflytop.profilometer.core.bluetooth.BlePingManager;
import com.iflytop.profilometer.core.migration.algo.ProfilometerPulleyPointPreProcesser;
import com.iflytop.profilometer.core.migration.algo.ProfilometerRecorder;
import com.iflytop.profilometer.core.migration.algo.type.MeasureSide;
@ -65,6 +69,7 @@ public class RailProfileDrawerService implements ProfilometerDrawerListener {
map.put("type", "measure-point");
map.put("data", xyPoint);
WebSocketManager.send(JSONUtil.toJsonStr(map));
Log.i(LogTag.PROFILOMENTER,"新点:" + xyPoint);
}
}
@ -166,6 +171,8 @@ public class RailProfileDrawerService implements ProfilometerDrawerListener {
RailProfileMeasureTaskState taskState = SystemService.getInstance().getTaskState();
taskState.setTaskStatus(RailProfileMeasureTaskStatus.FINISHED);
BlePingManager.getInstance().startPing();
Map<String, Object> map = new HashMap<>();
map.put("type", "measure-event");
if (side == MeasureSide.LEFT) {
@ -202,14 +209,14 @@ public class RailProfileDrawerService implements ProfilometerDrawerListener {
List<XYPoint> allList = new ArrayList<>();
if (report.outline1Side == MeasureSide.LEFT) {
allList.addAll(report.outline1);
List<XYPoint> rightList = new ArrayList<>(report.outline2);
Collections.reverse(rightList);
allList.addAll(rightList);
List<XYPoint> outline2List = new ArrayList<>(report.outline2);
Collections.reverse(outline2List);
allList.addAll(outline2List);
} else {
allList.addAll(report.outline2);
List<XYPoint> leftList = new ArrayList<>(report.outline1);
Collections.reverse(leftList);
allList.addAll(leftList);
List<XYPoint> outline1List = new ArrayList<>(report.outline1);
Collections.reverse(outline1List);
allList.addAll(outline1List);
}
Map<String, Object> finishMap = new HashMap<>();

Loading…
Cancel
Save