Repository navigation
feat(hardware): 优化设备列表、协议版本和固件升级 #63
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
KyleHuangFromHZ
merged 1 commit into
main
from
feature/hardware-device-actions-implementation
Nov 18, 2026
+1,659
−385
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
3 changes: 3 additions & 0 deletions
3
...d/crydaq-common/src/main/java/com/opentest/common/model/dto/DeviceProtocolVersionDto.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| package com.opentest.common.model.dto; | ||
|
|
||
| public record DeviceProtocolVersionDto(String name, String version, String status) { } |
11 changes: 11 additions & 0 deletions
11
...kend/crydaq-common/src/main/java/com/opentest/common/model/dto/OfflineDeviceClearDto.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,11 @@ | ||
| package com.opentest.common.model.dto; | ||
|
|
||
| import jakarta.validation.constraints.NotEmpty; | ||
| import jakarta.validation.constraints.NotNull; | ||
| import jakarta.validation.constraints.Size; | ||
| import java.util.List; | ||
|
|
||
| public record OfflineDeviceClearDto( | ||
| @NotNull Long projectId, | ||
| @NotEmpty @Size(max = 100000) List<@NotNull Long> ids, | ||
| Boolean deleteVirtualChannel) { } |
5 changes: 5 additions & 0 deletions
5
...d/crydaq-common/src/main/java/com/opentest/common/model/dto/OfflineDeviceClearResult.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,5 @@ | ||
| package com.opentest.common.model.dto; | ||
|
|
||
| import java.util.List; | ||
|
|
||
| public record OfflineDeviceClearResult(List<String> deletedIds, List<String> skippedIds, List<String> failedIds) { } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
58 changes: 58 additions & 0 deletions
58
...ckend/crydaq-service/src/main/java/com/opentest/service/DeviceProtocolVersionService.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,58 @@ | ||
| package com.opentest.service; | ||
|
|
||
| import com.fasterxml.jackson.databind.JsonNode; | ||
| import com.fasterxml.jackson.databind.ObjectMapper; | ||
| import com.opentest.common.model.dto.DeviceProtocolVersionDto; | ||
| import com.opentest.core.jni.AudioJNIBridge; | ||
| import com.opentest.service.deviceplugin.DevicePluginManagement; | ||
| import java.util.List; | ||
| import java.util.Locale; | ||
| import java.nio.file.Path; | ||
| import org.springframework.stereotype.Service; | ||
|
|
||
| /** Versions belong to the active device integration, not its package manifest. */ | ||
| @Service | ||
| public class DeviceProtocolVersionService { | ||
| private final DevicePluginManagement devices; | ||
| private final AudioJNIBridge bridge; | ||
| private final ObjectMapper json; | ||
|
|
||
| public DeviceProtocolVersionService(DevicePluginManagement devices, AudioJNIBridge bridge, ObjectMapper json) { | ||
| this.devices = devices; | ||
| this.bridge = bridge; | ||
| this.json = json; | ||
| } | ||
|
|
||
| public List<DeviceProtocolVersionDto> versions() { | ||
| JsonNode packages = devices.snapshot(false).path("packages"); | ||
| return List.of(version(packages, "opentest.sonodaq.device", "SonoDAQ SDK", false), | ||
| version(packages, "opentest.nidaq.device", "NI-DAQmx", !System.getProperty("os.name", "").toLowerCase(Locale.ROOT).startsWith("windows"))); | ||
| } | ||
|
|
||
| private DeviceProtocolVersionDto version(JsonNode packages, String id, String name, boolean unsupported) { | ||
| JsonNode installed = null; | ||
| for (JsonNode item : packages) { | ||
| if (id.equals(item.path("packageId").asText()) && item.path("installed").asBoolean()) { | ||
| installed = item; | ||
| break; | ||
| } | ||
| } | ||
| if (installed == null) return new DeviceProtocolVersionDto(name, null, "notInstalled"); | ||
| if (unsupported) return new DeviceProtocolVersionDto(name, null, "unsupported"); | ||
| if (!"active".equals(installed.path("status").asText())) { | ||
| return new DeviceProtocolVersionDto(name, null, installed.path("enabled").asBoolean() ? "unavailable" : "disabled"); | ||
| } | ||
| try { | ||
| Path activeLibrary = devices.activeLibrary(id); | ||
| if (activeLibrary == null) return new DeviceProtocolVersionDto(name, null, "unavailable"); | ||
| JsonNode response = json.readTree(bridge.getDeviceSdkVersion(activeLibrary.toString())); | ||
| if (response != null && response.path("code").isIntegralNumber() && response.path("code").asInt() == 0 | ||
| && response.path("data").isTextual() && !response.path("data").asText().isBlank()) { | ||
| return new DeviceProtocolVersionDto(name, response.path("data").asText(), "ready"); | ||
| } | ||
| } catch (Exception | LinkageError error) { | ||
|
KyleHuangFromHZ marked this conversation as resolved.
Resolved
|
||
| // A missing native entry or one unavailable SDK must not hide the other row. | ||
| } | ||
| return new DeviceProtocolVersionDto(name, null, "failed"); | ||
| } | ||
| } | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.