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.
54 lines
2.6 KiB
54 lines
2.6 KiB
using Peak.Can.Basic; |
|
using IOModuleTestBlazor.Models; |
|
|
|
namespace IOModuleTestBlazor.Services; |
|
|
|
public interface ICanService |
|
{ |
|
bool IsConnected { get; } |
|
string ChannelName { get; } |
|
Bitrate CurrentBitrate { get; } |
|
|
|
/// <summary> |
|
/// Raised on the worker thread each time a CAN message passes all filters. |
|
/// Subscribers must marshal UI updates with InvokeAsync(StateHasChanged). |
|
/// </summary> |
|
event Action<CanMessageDto> MessageReceived; |
|
|
|
// ── Filters ─────────────────────────────────────────────────────────────── |
|
IReadOnlyList<CanFilter> Filters { get; } |
|
CanFilter AddFilter(CanFilter filter); |
|
bool RemoveFilter(Guid id); |
|
void ClearFilters(); |
|
|
|
// ── Bitmasks ────────────────────────────────────────────────────────────── |
|
IReadOnlyList<CanBitmask> Bitmasks { get; } |
|
CanBitmask AddBitmask(CanBitmask bitmask); |
|
bool RemoveBitmask(Guid id); |
|
void ClearBitmasks(); |
|
|
|
// ── Helpers used by the worker ──────────────────────────────────────────── |
|
bool PassesFilter(uint messageId); |
|
IReadOnlyDictionary<string, double> ExtractSignals(uint messageId, byte[] data); |
|
void PublishMessage(CanMessageDto dto); |
|
|
|
// ── Channel management ──────────────────────────────────────────────────── |
|
|
|
/// <summary>Returns all PCAN USB channels that are currently available.</summary> |
|
IReadOnlyList<PcanChannel> GetAvailableChannels(); |
|
|
|
/// <summary> |
|
/// Asks the worker to reinitialise on the next loop iteration. |
|
/// Non-blocking — the actual reconnect happens asynchronously. |
|
/// </summary> |
|
void RequestReinitialize(PcanChannel channel, Bitrate bitrate); |
|
|
|
/// <summary>Called by the worker to pick up a pending reinit request.</summary> |
|
bool TryConsumePendingReinit(out PcanChannel channel, out Bitrate bitrate); |
|
|
|
// ── PCAN passthrough ────────────────────────────────────────────────────── |
|
void Initialize(PcanChannel channel, Bitrate bitrate); |
|
void Uninitialize(); |
|
PcanStatus Read(out PcanMessage msg, out ulong timestamp); |
|
PcanStatus Write(PcanMessage msg); |
|
}
|
|
|