Skip to content

Commit 7eb9aac

Browse files
committed
Update generators and regenerate interface
1 parent 571b025 commit 7eb9aac

File tree

3 files changed

+404
-233
lines changed

3 files changed

+404
-233
lines changed

Generators/Generators.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
<FirmwarePath>..\Firmware\Harp.AudioSwitch</FirmwarePath>
1616
</PropertyGroup>
1717
<ItemGroup>
18-
<PackageReference Include="Harp.Generators" Version="0.1.0-build032704" GeneratePathProperty="true" />
18+
<PackageReference Include="Harp.Generators" Version="0.3.0" GeneratePathProperty="true" />
1919
</ItemGroup>
2020
<Target Name="TextTransform" BeforeTargets="AfterBuild">
2121
<PropertyGroup>

Interface/Harp.AudioSwitch/AsyncDevice.Generated.cs

Lines changed: 101 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
using Bonsai.Harp;
2+
using System.Threading;
23
using System.Threading.Tasks;
34

45
namespace Harp.AudioSwitch
@@ -47,249 +48,309 @@ internal AsyncDevice(string portName)
4748
/// <summary>
4849
/// Asynchronously reads the contents of the ControlMode register.
4950
/// </summary>
51+
/// <param name="cancellationToken">
52+
/// A <see cref="CancellationToken"/> which can be used to cancel the operation.
53+
/// </param>
5054
/// <returns>
5155
/// A task that represents the asynchronous read operation. The <see cref="Task{TResult}.Result"/>
5256
/// property contains the register payload.
5357
/// </returns>
54-
public async Task<ControlSource> ReadControlModeAsync()
58+
public async Task<ControlSource> ReadControlModeAsync(CancellationToken cancellationToken = default)
5559
{
56-
var reply = await CommandAsync(HarpCommand.ReadByte(ControlMode.Address));
60+
var reply = await CommandAsync(HarpCommand.ReadByte(ControlMode.Address), cancellationToken);
5761
return ControlMode.GetPayload(reply);
5862
}
5963

6064
/// <summary>
6165
/// Asynchronously reads the timestamped contents of the ControlMode register.
6266
/// </summary>
67+
/// <param name="cancellationToken">
68+
/// A <see cref="CancellationToken"/> which can be used to cancel the operation.
69+
/// </param>
6370
/// <returns>
6471
/// A task that represents the asynchronous read operation. The <see cref="Task{TResult}.Result"/>
6572
/// property contains the timestamped register payload.
6673
/// </returns>
67-
public async Task<Timestamped<ControlSource>> ReadTimestampedControlModeAsync()
74+
public async Task<Timestamped<ControlSource>> ReadTimestampedControlModeAsync(CancellationToken cancellationToken = default)
6875
{
69-
var reply = await CommandAsync(HarpCommand.ReadByte(ControlMode.Address));
76+
var reply = await CommandAsync(HarpCommand.ReadByte(ControlMode.Address), cancellationToken);
7077
return ControlMode.GetTimestampedPayload(reply);
7178
}
7279

7380
/// <summary>
7481
/// Asynchronously writes a value to the ControlMode register.
7582
/// </summary>
7683
/// <param name="value">The value to be stored in the register.</param>
84+
/// <param name="cancellationToken">
85+
/// A <see cref="CancellationToken"/> which can be used to cancel the operation.
86+
/// </param>
7787
/// <returns>The task object representing the asynchronous write operation.</returns>
78-
public async Task WriteControlModeAsync(ControlSource value)
88+
public async Task WriteControlModeAsync(ControlSource value, CancellationToken cancellationToken = default)
7989
{
8090
var request = ControlMode.FromPayload(MessageType.Write, value);
81-
await CommandAsync(request);
91+
await CommandAsync(request, cancellationToken);
8292
}
8393

8494
/// <summary>
8595
/// Asynchronously reads the contents of the EnableChannels register.
8696
/// </summary>
97+
/// <param name="cancellationToken">
98+
/// A <see cref="CancellationToken"/> which can be used to cancel the operation.
99+
/// </param>
87100
/// <returns>
88101
/// A task that represents the asynchronous read operation. The <see cref="Task{TResult}.Result"/>
89102
/// property contains the register payload.
90103
/// </returns>
91-
public async Task<AudioChannels> ReadEnableChannelsAsync()
104+
public async Task<AudioChannels> ReadEnableChannelsAsync(CancellationToken cancellationToken = default)
92105
{
93-
var reply = await CommandAsync(HarpCommand.ReadUInt16(EnableChannels.Address));
106+
var reply = await CommandAsync(HarpCommand.ReadUInt16(EnableChannels.Address), cancellationToken);
94107
return EnableChannels.GetPayload(reply);
95108
}
96109

97110
/// <summary>
98111
/// Asynchronously reads the timestamped contents of the EnableChannels register.
99112
/// </summary>
113+
/// <param name="cancellationToken">
114+
/// A <see cref="CancellationToken"/> which can be used to cancel the operation.
115+
/// </param>
100116
/// <returns>
101117
/// A task that represents the asynchronous read operation. The <see cref="Task{TResult}.Result"/>
102118
/// property contains the timestamped register payload.
103119
/// </returns>
104-
public async Task<Timestamped<AudioChannels>> ReadTimestampedEnableChannelsAsync()
120+
public async Task<Timestamped<AudioChannels>> ReadTimestampedEnableChannelsAsync(CancellationToken cancellationToken = default)
105121
{
106-
var reply = await CommandAsync(HarpCommand.ReadUInt16(EnableChannels.Address));
122+
var reply = await CommandAsync(HarpCommand.ReadUInt16(EnableChannels.Address), cancellationToken);
107123
return EnableChannels.GetTimestampedPayload(reply);
108124
}
109125

110126
/// <summary>
111127
/// Asynchronously writes a value to the EnableChannels register.
112128
/// </summary>
113129
/// <param name="value">The value to be stored in the register.</param>
130+
/// <param name="cancellationToken">
131+
/// A <see cref="CancellationToken"/> which can be used to cancel the operation.
132+
/// </param>
114133
/// <returns>The task object representing the asynchronous write operation.</returns>
115-
public async Task WriteEnableChannelsAsync(AudioChannels value)
134+
public async Task WriteEnableChannelsAsync(AudioChannels value, CancellationToken cancellationToken = default)
116135
{
117136
var request = EnableChannels.FromPayload(MessageType.Write, value);
118-
await CommandAsync(request);
137+
await CommandAsync(request, cancellationToken);
119138
}
120139

121140
/// <summary>
122141
/// Asynchronously reads the contents of the DigitalInputState register.
123142
/// </summary>
143+
/// <param name="cancellationToken">
144+
/// A <see cref="CancellationToken"/> which can be used to cancel the operation.
145+
/// </param>
124146
/// <returns>
125147
/// A task that represents the asynchronous read operation. The <see cref="Task{TResult}.Result"/>
126148
/// property contains the register payload.
127149
/// </returns>
128-
public async Task<DigitalInputs> ReadDigitalInputStateAsync()
150+
public async Task<DigitalInputs> ReadDigitalInputStateAsync(CancellationToken cancellationToken = default)
129151
{
130-
var reply = await CommandAsync(HarpCommand.ReadByte(DigitalInputState.Address));
152+
var reply = await CommandAsync(HarpCommand.ReadByte(DigitalInputState.Address), cancellationToken);
131153
return DigitalInputState.GetPayload(reply);
132154
}
133155

134156
/// <summary>
135157
/// Asynchronously reads the timestamped contents of the DigitalInputState register.
136158
/// </summary>
159+
/// <param name="cancellationToken">
160+
/// A <see cref="CancellationToken"/> which can be used to cancel the operation.
161+
/// </param>
137162
/// <returns>
138163
/// A task that represents the asynchronous read operation. The <see cref="Task{TResult}.Result"/>
139164
/// property contains the timestamped register payload.
140165
/// </returns>
141-
public async Task<Timestamped<DigitalInputs>> ReadTimestampedDigitalInputStateAsync()
166+
public async Task<Timestamped<DigitalInputs>> ReadTimestampedDigitalInputStateAsync(CancellationToken cancellationToken = default)
142167
{
143-
var reply = await CommandAsync(HarpCommand.ReadByte(DigitalInputState.Address));
168+
var reply = await CommandAsync(HarpCommand.ReadByte(DigitalInputState.Address), cancellationToken);
144169
return DigitalInputState.GetTimestampedPayload(reply);
145170
}
146171

147172
/// <summary>
148173
/// Asynchronously reads the contents of the DO0State register.
149174
/// </summary>
175+
/// <param name="cancellationToken">
176+
/// A <see cref="CancellationToken"/> which can be used to cancel the operation.
177+
/// </param>
150178
/// <returns>
151179
/// A task that represents the asynchronous read operation. The <see cref="Task{TResult}.Result"/>
152180
/// property contains the register payload.
153181
/// </returns>
154-
public async Task<EnableFlag> ReadDO0StateAsync()
182+
public async Task<EnableFlag> ReadDO0StateAsync(CancellationToken cancellationToken = default)
155183
{
156-
var reply = await CommandAsync(HarpCommand.ReadByte(DO0State.Address));
184+
var reply = await CommandAsync(HarpCommand.ReadByte(DO0State.Address), cancellationToken);
157185
return DO0State.GetPayload(reply);
158186
}
159187

160188
/// <summary>
161189
/// Asynchronously reads the timestamped contents of the DO0State register.
162190
/// </summary>
191+
/// <param name="cancellationToken">
192+
/// A <see cref="CancellationToken"/> which can be used to cancel the operation.
193+
/// </param>
163194
/// <returns>
164195
/// A task that represents the asynchronous read operation. The <see cref="Task{TResult}.Result"/>
165196
/// property contains the timestamped register payload.
166197
/// </returns>
167-
public async Task<Timestamped<EnableFlag>> ReadTimestampedDO0StateAsync()
198+
public async Task<Timestamped<EnableFlag>> ReadTimestampedDO0StateAsync(CancellationToken cancellationToken = default)
168199
{
169-
var reply = await CommandAsync(HarpCommand.ReadByte(DO0State.Address));
200+
var reply = await CommandAsync(HarpCommand.ReadByte(DO0State.Address), cancellationToken);
170201
return DO0State.GetTimestampedPayload(reply);
171202
}
172203

173204
/// <summary>
174205
/// Asynchronously writes a value to the DO0State register.
175206
/// </summary>
176207
/// <param name="value">The value to be stored in the register.</param>
208+
/// <param name="cancellationToken">
209+
/// A <see cref="CancellationToken"/> which can be used to cancel the operation.
210+
/// </param>
177211
/// <returns>The task object representing the asynchronous write operation.</returns>
178-
public async Task WriteDO0StateAsync(EnableFlag value)
212+
public async Task WriteDO0StateAsync(EnableFlag value, CancellationToken cancellationToken = default)
179213
{
180214
var request = DO0State.FromPayload(MessageType.Write, value);
181-
await CommandAsync(request);
215+
await CommandAsync(request, cancellationToken);
182216
}
183217

184218
/// <summary>
185219
/// Asynchronously reads the contents of the DI4Trigger register.
186220
/// </summary>
221+
/// <param name="cancellationToken">
222+
/// A <see cref="CancellationToken"/> which can be used to cancel the operation.
223+
/// </param>
187224
/// <returns>
188225
/// A task that represents the asynchronous read operation. The <see cref="Task{TResult}.Result"/>
189226
/// property contains the register payload.
190227
/// </returns>
191-
public async Task<DI4TriggerConfig> ReadDI4TriggerAsync()
228+
public async Task<DI4TriggerConfig> ReadDI4TriggerAsync(CancellationToken cancellationToken = default)
192229
{
193-
var reply = await CommandAsync(HarpCommand.ReadByte(DI4Trigger.Address));
230+
var reply = await CommandAsync(HarpCommand.ReadByte(DI4Trigger.Address), cancellationToken);
194231
return DI4Trigger.GetPayload(reply);
195232
}
196233

197234
/// <summary>
198235
/// Asynchronously reads the timestamped contents of the DI4Trigger register.
199236
/// </summary>
237+
/// <param name="cancellationToken">
238+
/// A <see cref="CancellationToken"/> which can be used to cancel the operation.
239+
/// </param>
200240
/// <returns>
201241
/// A task that represents the asynchronous read operation. The <see cref="Task{TResult}.Result"/>
202242
/// property contains the timestamped register payload.
203243
/// </returns>
204-
public async Task<Timestamped<DI4TriggerConfig>> ReadTimestampedDI4TriggerAsync()
244+
public async Task<Timestamped<DI4TriggerConfig>> ReadTimestampedDI4TriggerAsync(CancellationToken cancellationToken = default)
205245
{
206-
var reply = await CommandAsync(HarpCommand.ReadByte(DI4Trigger.Address));
246+
var reply = await CommandAsync(HarpCommand.ReadByte(DI4Trigger.Address), cancellationToken);
207247
return DI4Trigger.GetTimestampedPayload(reply);
208248
}
209249

210250
/// <summary>
211251
/// Asynchronously writes a value to the DI4Trigger register.
212252
/// </summary>
213253
/// <param name="value">The value to be stored in the register.</param>
254+
/// <param name="cancellationToken">
255+
/// A <see cref="CancellationToken"/> which can be used to cancel the operation.
256+
/// </param>
214257
/// <returns>The task object representing the asynchronous write operation.</returns>
215-
public async Task WriteDI4TriggerAsync(DI4TriggerConfig value)
258+
public async Task WriteDI4TriggerAsync(DI4TriggerConfig value, CancellationToken cancellationToken = default)
216259
{
217260
var request = DI4Trigger.FromPayload(MessageType.Write, value);
218-
await CommandAsync(request);
261+
await CommandAsync(request, cancellationToken);
219262
}
220263

221264
/// <summary>
222265
/// Asynchronously reads the contents of the DO0Sync register.
223266
/// </summary>
267+
/// <param name="cancellationToken">
268+
/// A <see cref="CancellationToken"/> which can be used to cancel the operation.
269+
/// </param>
224270
/// <returns>
225271
/// A task that represents the asynchronous read operation. The <see cref="Task{TResult}.Result"/>
226272
/// property contains the register payload.
227273
/// </returns>
228-
public async Task<DO0SyncConfig> ReadDO0SyncAsync()
274+
public async Task<DO0SyncConfig> ReadDO0SyncAsync(CancellationToken cancellationToken = default)
229275
{
230-
var reply = await CommandAsync(HarpCommand.ReadByte(DO0Sync.Address));
276+
var reply = await CommandAsync(HarpCommand.ReadByte(DO0Sync.Address), cancellationToken);
231277
return DO0Sync.GetPayload(reply);
232278
}
233279

234280
/// <summary>
235281
/// Asynchronously reads the timestamped contents of the DO0Sync register.
236282
/// </summary>
283+
/// <param name="cancellationToken">
284+
/// A <see cref="CancellationToken"/> which can be used to cancel the operation.
285+
/// </param>
237286
/// <returns>
238287
/// A task that represents the asynchronous read operation. The <see cref="Task{TResult}.Result"/>
239288
/// property contains the timestamped register payload.
240289
/// </returns>
241-
public async Task<Timestamped<DO0SyncConfig>> ReadTimestampedDO0SyncAsync()
290+
public async Task<Timestamped<DO0SyncConfig>> ReadTimestampedDO0SyncAsync(CancellationToken cancellationToken = default)
242291
{
243-
var reply = await CommandAsync(HarpCommand.ReadByte(DO0Sync.Address));
292+
var reply = await CommandAsync(HarpCommand.ReadByte(DO0Sync.Address), cancellationToken);
244293
return DO0Sync.GetTimestampedPayload(reply);
245294
}
246295

247296
/// <summary>
248297
/// Asynchronously writes a value to the DO0Sync register.
249298
/// </summary>
250299
/// <param name="value">The value to be stored in the register.</param>
300+
/// <param name="cancellationToken">
301+
/// A <see cref="CancellationToken"/> which can be used to cancel the operation.
302+
/// </param>
251303
/// <returns>The task object representing the asynchronous write operation.</returns>
252-
public async Task WriteDO0SyncAsync(DO0SyncConfig value)
304+
public async Task WriteDO0SyncAsync(DO0SyncConfig value, CancellationToken cancellationToken = default)
253305
{
254306
var request = DO0Sync.FromPayload(MessageType.Write, value);
255-
await CommandAsync(request);
307+
await CommandAsync(request, cancellationToken);
256308
}
257309

258310
/// <summary>
259311
/// Asynchronously reads the contents of the EnableEvents register.
260312
/// </summary>
313+
/// <param name="cancellationToken">
314+
/// A <see cref="CancellationToken"/> which can be used to cancel the operation.
315+
/// </param>
261316
/// <returns>
262317
/// A task that represents the asynchronous read operation. The <see cref="Task{TResult}.Result"/>
263318
/// property contains the register payload.
264319
/// </returns>
265-
public async Task<AudioSwitchEvents> ReadEnableEventsAsync()
320+
public async Task<AudioSwitchEvents> ReadEnableEventsAsync(CancellationToken cancellationToken = default)
266321
{
267-
var reply = await CommandAsync(HarpCommand.ReadByte(EnableEvents.Address));
322+
var reply = await CommandAsync(HarpCommand.ReadByte(EnableEvents.Address), cancellationToken);
268323
return EnableEvents.GetPayload(reply);
269324
}
270325

271326
/// <summary>
272327
/// Asynchronously reads the timestamped contents of the EnableEvents register.
273328
/// </summary>
329+
/// <param name="cancellationToken">
330+
/// A <see cref="CancellationToken"/> which can be used to cancel the operation.
331+
/// </param>
274332
/// <returns>
275333
/// A task that represents the asynchronous read operation. The <see cref="Task{TResult}.Result"/>
276334
/// property contains the timestamped register payload.
277335
/// </returns>
278-
public async Task<Timestamped<AudioSwitchEvents>> ReadTimestampedEnableEventsAsync()
336+
public async Task<Timestamped<AudioSwitchEvents>> ReadTimestampedEnableEventsAsync(CancellationToken cancellationToken = default)
279337
{
280-
var reply = await CommandAsync(HarpCommand.ReadByte(EnableEvents.Address));
338+
var reply = await CommandAsync(HarpCommand.ReadByte(EnableEvents.Address), cancellationToken);
281339
return EnableEvents.GetTimestampedPayload(reply);
282340
}
283341

284342
/// <summary>
285343
/// Asynchronously writes a value to the EnableEvents register.
286344
/// </summary>
287345
/// <param name="value">The value to be stored in the register.</param>
346+
/// <param name="cancellationToken">
347+
/// A <see cref="CancellationToken"/> which can be used to cancel the operation.
348+
/// </param>
288349
/// <returns>The task object representing the asynchronous write operation.</returns>
289-
public async Task WriteEnableEventsAsync(AudioSwitchEvents value)
350+
public async Task WriteEnableEventsAsync(AudioSwitchEvents value, CancellationToken cancellationToken = default)
290351
{
291352
var request = EnableEvents.FromPayload(MessageType.Write, value);
292-
await CommandAsync(request);
353+
await CommandAsync(request, cancellationToken);
293354
}
294355
}
295356
}

0 commit comments

Comments
 (0)