You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
124 lines
4.7 KiB
124 lines
4.7 KiB
using AIK.Common.Enum;
|
|
using AIK.Common.Event;
|
|
using AIK.Models.HidModels;
|
|
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
|
|
namespace AIK.Service.IService
|
|
{
|
|
public interface IHidCommunicationService
|
|
{
|
|
bool IsConnected { get; }
|
|
TransferState State { get; }
|
|
|
|
event EventHandler<HidResponseReceivedEventArgs>? ResponseReceived;
|
|
event EventHandler<HidLogMessageEventArgs>? LogMessage;
|
|
event EventHandler<ConnectionStateChangedEventArgs>? ConnectionStateChanged;
|
|
|
|
Task<bool> ConnectAsync(int vendorId = 0x28E9, int productId = 0xFFF0);
|
|
Task<bool> ReconnectNowAsync();
|
|
Task DisconnectAsync();
|
|
/// <summary>
|
|
/// 发送设备分包基础帧(头帧/数据帧/结束帧等)
|
|
/// </summary>
|
|
/// <param name="data"></param>
|
|
/// <returns></returns>
|
|
Task SendAsync(byte[] data);
|
|
|
|
/// <summary>
|
|
/// 根据本地路径烧录文件
|
|
/// </summary>
|
|
/// <param name="filePath"></param>
|
|
/// <param name="progress"></param>
|
|
/// <param name="ct"></param>
|
|
/// <returns></returns>
|
|
Task<(bool, string)> SendFileAsync(string filePath, IProgress<double> progress, CancellationToken ct);
|
|
/// <summary>
|
|
/// 根据文件名称和文件二进制数据烧录文件
|
|
/// </summary>
|
|
/// <param name="fileName"></param>
|
|
/// <param name="filebin"></param>
|
|
/// <param name="progress"></param>
|
|
/// <param name="ct"></param>
|
|
/// <returns></returns>
|
|
Task<(bool, string)> SendFileAsync(string fileName, byte[] filebin, IProgress<double> progress, CancellationToken ct);
|
|
|
|
/// <summary>
|
|
/// 附加烧录流程阶段(连接/生成/写入)
|
|
/// </summary>
|
|
/// <param name="fileName"></param>
|
|
/// <param name="filebin"></param>
|
|
/// <param name="progress"></param>
|
|
/// <param name="ct"></param>
|
|
/// <returns></returns>
|
|
Task<(bool, string)> SendFileProcessAsync(string fileName, byte[] filebin, IProgress<double> progress, CancellationToken ct);
|
|
|
|
/// <summary>
|
|
/// 附加烧录流程阶段-固件升级(连接/生成/写入)
|
|
/// </summary>
|
|
/// <param name="fileName"></param>
|
|
/// <param name="filebin"></param>
|
|
/// <param name="progress"></param>
|
|
/// <param name="ct"></param>
|
|
/// <returns></returns>
|
|
Task<(bool, string)> SendFileProcessAsync(string fileName, byte[] filebin, HidOperationTypeEnum hidOperationType, IProgress<double> progress, CancellationToken ct);
|
|
|
|
Task<(bool, string)> GetDeviceVersion(HidOperationTypeEnum hidOperationType);
|
|
|
|
/// <summary>
|
|
/// K3Tool盘符获取
|
|
/// </summary>
|
|
/// <param name="vendorId"></param>
|
|
/// <param name="productId"></param>
|
|
/// <returns></returns>
|
|
Task<string> FindAssociatedUsbDisk(int vendorId = 0x28E9, int productId = 0xFFF0);
|
|
|
|
/// <summary>
|
|
/// 复制文件或文件夹到U盘
|
|
/// </summary>
|
|
/// <param name="sourcePath"></param>
|
|
/// <param name="isDirectory"></param>
|
|
/// <returns></returns>
|
|
Task<(bool, string)> CopyToUdiskAsync(string sourcePath, bool isDirectory, IProgress<double> progress, CancellationToken cts);
|
|
/// <summary>
|
|
/// 打开U盘并检测盘符
|
|
/// </summary>
|
|
/// <param name="maxWaitSeconds"></param>
|
|
/// <param name="pollIntervalMs"></param>
|
|
/// <param name="cancellationToken"></param>
|
|
/// <returns></returns>
|
|
Task<string> OpenUDiskAndDetectDriveAsync(int maxWaitSeconds = 15, int pollIntervalMs = 500, CancellationToken cancellationToken = default);
|
|
|
|
/// <summary>
|
|
/// 关闭U盘
|
|
/// </summary>
|
|
/// <param name="targetDrive"></param>
|
|
/// <returns></returns>
|
|
Task CloseUDiskSafeDriveAsync(string targetDrive = "");
|
|
|
|
Task KeepDeviceAliveAsync();
|
|
|
|
public Task CopyDeltaDirectoryToUdiskAsync(
|
|
string localRootDir,
|
|
IProgress<double> progress,
|
|
CancellationToken ct);
|
|
|
|
public Task<Dictionary<string, FileInfo>> ScanUdiskFilesAsync(CancellationToken ct);
|
|
|
|
public Dictionary<string, FileInfo> ScanLocalFiles(string localRootDir);
|
|
|
|
public List<string> GetChangedFiles(
|
|
Dictionary<string, FileInfo> localFiles,
|
|
Dictionary<string, FileInfo> udiskFiles);
|
|
|
|
public Task<(string zipPath, int count)> CreateDeltaZipAsync(
|
|
string localRootDir,
|
|
List<string> changedRelativePaths,
|
|
CancellationToken ct);
|
|
}
|
|
}
|
|
|