99 lines
5.9 KiB
Markdown
99 lines
5.9 KiB
Markdown
|
|
---
|
||
|
|
source_files:
|
||
|
|
- DataPRO/CanFDApiProxy/Protocol.cs
|
||
|
|
- DataPRO/CanFDApiProxy/CanApiException.cs
|
||
|
|
- DataPRO/CanFDApiProxy/HttpClientFactory.cs
|
||
|
|
- DataPRO/CanFDApiProxy/CommandName.cs
|
||
|
|
- DataPRO/CanFDApiProxy/RESTWrapper.cs
|
||
|
|
- DataPRO/CanFDApiProxy/CANFD.cs
|
||
|
|
generated_at: "2026-04-17T15:51:33.293330+00:00"
|
||
|
|
model: "zai-org/GLM-5-FP8"
|
||
|
|
schema_version: 1
|
||
|
|
sha256: "149776114a3cb89f"
|
||
|
|
---
|
||
|
|
|
||
|
|
# Documentation: CANFDApiProxy Module
|
||
|
|
|
||
|
|
## 1. Purpose
|
||
|
|
|
||
|
|
The `CANFDApiProxy` module serves as a client-side SDK for interacting with a CAN-FD hardware device's REST API. It abstracts the underlying HTTP communication, serialization, and endpoint management into a singleton service (`CANFD`). The module allows developers to query device state (battery, serial, CAN bus statistics), configure hardware settings (LEDs, network, clocks), and perform file operations (upload/download logs) via strongly typed C# methods.
|
||
|
|
|
||
|
|
## 2. Public Interface
|
||
|
|
|
||
|
|
### Class: `CANFDApiProxy.CANFD`
|
||
|
|
A `sealed` class implementing the singleton pattern to provide access to the API.
|
||
|
|
|
||
|
|
* **Property**: `public static CANFD API`
|
||
|
|
* Returns the singleton instance of the `CANFD` client.
|
||
|
|
* **Constructor**: `private CANFD()`
|
||
|
|
* Private constructor to enforce singleton access via the `API` property.
|
||
|
|
|
||
|
|
#### Device Information & Status Methods
|
||
|
|
* `Task<UsbTreeMessage> GetUsbTree(string deviceHost, CancellationToken cancellationToken)`
|
||
|
|
* `Task<BatteryMessage> GetBattery(string deviceHost, CancellationToken cancellationToken)`
|
||
|
|
* `Task<DiagnosticMessageRow[]> GetBIST(string deviceHost, CancellationToken cancellationToken)`
|
||
|
|
* Retrieves Built-In Self-Test results. Parses CSV response into an array of `DiagnosticMessageRow`.
|
||
|
|
* `Task<CalibrationMessage> GetCalibrationDate(string deviceHost, CancellationToken cancellationToken)`
|
||
|
|
* `Task<SerialMessage> GetSerial(string deviceHost, CancellationToken cancellationToken)`
|
||
|
|
* `Task<LEDsMessage> GetLEDs(string deviceHost, CancellationToken cancellationToken)`
|
||
|
|
* `Task<DeviceInfoMessage> GetDeviceInfo(string deviceHost, CancellationToken cancellationToken)`
|
||
|
|
* `Task<NtpMessage> GetNtp(string deviceHost, CancellationToken cancellationToken)`
|
||
|
|
* `Task<PowerMessage> GetPower(string deviceHost, CancellationToken cancellationToken)`
|
||
|
|
* `Task<ServicesMessage> GetServices(string deviceHost, CancellationToken cancellationToken)`
|
||
|
|
* `Task<NetworkMessage> GetNetwork(string deviceHost, CancellationToken cancellationToken)`
|
||
|
|
* `Task<ClocksMessage> GetClocks(string deviceHost, CancellationToken cancellationToken)`
|
||
|
|
* `Task<EventPinMessage> GetEventPin(string deviceHost, CancellationToken cancellationToken)`
|
||
|
|
* `Task<RecordingMessage> GetRecording(string deviceHost, CancellationToken cancellationToken)`
|
||
|
|
* `Task<UsbStatsMessage> GetUsbStats(string deviceHost, CancellationToken cancellationToken)`
|
||
|
|
|
||
|
|
#### CAN Bus Methods
|
||
|
|
* `Task<CANInfoMessage> GetCANInfo(string deviceHost, CancellationToken cancellationToken)`
|
||
|
|
* `Task<CANStateMessage> GetCANState(string deviceHost, CancellationToken cancellationToken)`
|
||
|
|
* `Task<CANStatsMessage> GetCANStats(string deviceHost, CancellationToken cancellationToken)`
|
||
|
|
* `Task<CANConfigMessage> GetCANConfig(string deviceHost, CancellationToken cancellationToken)`
|
||
|
|
|
||
|
|
#### Control/Setter Methods
|
||
|
|
* `Task<SerialMessage> SetSerial(string deviceHost, SerialRequest serialRequest, CancellationToken cancellationToken)`
|
||
|
|
* `Task<PowerMessage> SetPowerOff(string deviceHost, CancellationToken cancellationToken)`
|
||
|
|
* `Task<PowerMessage> SetPowerReboot(string deviceHost, CancellationToken cancellationToken)`
|
||
|
|
* `Task<CANConfigMessage> SetCANConfig(string deviceHost, CANConfigRequest canConfigRequest, CancellationToken cancellationToken)`
|
||
|
|
* `Task<LEDsPostMessage> SetLEDs(string deviceHost, LedName led, LedCmd cmd, LedColor color, CancellationToken cancellationToken)`
|
||
|
|
* `Task<ClocksMessage> SetClocks(string deviceHost, DateTime dateTime, CancellationToken cancellationToken)`
|
||
|
|
* `Task<ClocksMessage> SyncClocks(string deviceHost, CancellationToken cancellationToken)`
|
||
|
|
* `Task<RecordingMessage> SetRecordingStart(string deviceHost, CancellationToken cancellationToken)`
|
||
|
|
* `Task<RecordingMessage> SetRecordingTriggerCheck_Quick(string deviceHost, CancellationToken cancellationToken)`
|
||
|
|
* `Task<RecordingMessage> SetRecordingStop(string deviceHost, CancellationToken cancellationToken)`
|
||
|
|
* `Task<NetworkMessage> SetNetwork(string deviceHost, NetworkRequest networkRequest, CancellationToken cancellationToken)`
|
||
|
|
* `Task<EventPinMessage> SetEventPinArm(string deviceHost, CancellationToken cancellationToken)`
|
||
|
|
* `Task<EventPinMessage> SetEventPinDisarm(string deviceHost, CancellationToken cancellationToken)`
|
||
|
|
|
||
|
|
#### File Operations
|
||
|
|
* `Task<StatusMessage> Delete(string deviceHost, string usbPath, CancellationToken cancellationToken)`
|
||
|
|
* Deletes a file or directory on the device.
|
||
|
|
* `Task Download(string deviceHost, string usbPath, string destinationDirectory, TimeSpan timeOut, CancellationToken cancellationToken)`
|
||
|
|
* Downloads a file or directory (zipped) from the device to a local directory.
|
||
|
|
* `Task<StatusMessage> Upload(string deviceHost, string uploadUsbPath, string sourcefile, TimeSpan timeOut, CancellationToken cancellationToken)`
|
||
|
|
* Uploads a local file to the device.
|
||
|
|
|
||
|
|
### Class: `CANFDApiProxy.CanApiException`
|
||
|
|
Custom exception for API errors.
|
||
|
|
|
||
|
|
* **Property**: `public int? StatusCode { get; set; }`
|
||
|
|
* **Constructors**:
|
||
|
|
* `public CanApiException(string message, Exception inner)`
|
||
|
|
* `public CanApiException(string message, int statusCode)`
|
||
|
|
|
||
|
|
### Class: `CANFDApiProxy.HttpClientFactory`
|
||
|
|
Static factory for creating HTTP clients.
|
||
|
|
|
||
|
|
* `public static HttpClient CreateHttpClient()`
|
||
|
|
* Creates a client configured to accept JSON.
|
||
|
|
|
||
|
|
### Enum: `CANFDApiProxy.Protocol`
|
||
|
|
* `http`
|
||
|
|
* `https`
|
||
|
|
|
||
|
|
## 3. Invariants
|
||
|
|
|
||
|
|
* **Singleton Pattern**: The `CANFD` class is sealed and has a private constructor. It must be accessed via the static property `CANFD.API`.
|
||
|
|
*
|