@@ -29,6 +29,13 @@ public class CanOpenDevice : ICanOpenDevice, IDisposable
|
||||
/// When enabled, State will be updated automatically when heartbeat is received
|
||||
/// </summary>
|
||||
public bool AutoVerifyStateViaHeartbeat { get; set; } = false;
|
||||
|
||||
/// <summary>
|
||||
/// Lock cho trình tự cấu hình cấp node (PDO config, NMT state, tham số chung).
|
||||
/// Nhiều facade dùng chung một node vật lý (vd. 2 trục của ZLAC8015D) phải giữ lock này
|
||||
/// trong suốt trình tự connect để không xen kẽ NMT/PDO của nhau.
|
||||
/// </summary>
|
||||
public SemaphoreSlim ConfigurationLock { get; } = new(1, 1);
|
||||
|
||||
// Expose các services để user có thể truy cập
|
||||
public PdoManager Pdo => _pdoManager;
|
||||
@@ -154,7 +161,20 @@ public class CanOpenDevice : ICanOpenDevice, IDisposable
|
||||
{
|
||||
await WriteObjectAsync(index, subIndex, BitConverter.GetBytes(value), cancellationToken);
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Ghi nhiều giá trị int32 trong một lần giữ kênh SDO liên tục — không giao dịch nào
|
||||
/// khác chen được vào giữa các lệnh. Dùng cho lệnh cần đi liền nhau (vd vận tốc 2 bánh).
|
||||
/// </summary>
|
||||
public async Task WriteInt32BatchAsync(IReadOnlyList<(ushort Index, byte SubIndex, int Value)> items, CancellationToken cancellationToken = default)
|
||||
{
|
||||
var batch = new (ushort, byte, byte[])[items.Count];
|
||||
for (int i = 0; i < items.Count; i++)
|
||||
batch[i] = (items[i].Index, items[i].SubIndex, BitConverter.GetBytes(items[i].Value));
|
||||
|
||||
await _sdoClient.DownloadBatchAsync(batch, cancellationToken);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
||||
#region NMT Operations
|
||||
|
||||
Reference in New Issue
Block a user