Skip to content

Commit

Permalink
Merge pull request #50 from AllenNeuralDynamics/feat-zaber-connection…
Browse files Browse the repository at this point in the history
…-commands

Bind GenericCommands to Connection class
  • Loading branch information
bruno-f-cruz authored Jun 25, 2024
2 parents 6365a99 + a6a88b5 commit 546ac44
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
<PackageTags>Bonsai Rx Zaber AllenNeuralDynamics</PackageTags>
<TargetFramework>net472</TargetFramework>
<Features>strict</Features>
<Version>0.4.2</Version>
<Version>0.5.0</Version>
</PropertyGroup>

<ItemGroup>
Expand Down
2 changes: 1 addition & 1 deletion src/AllenNeuralDynamics.Zaber/GenericCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class GenericCommand : Combinator<string, Response>
/// Gets or sets the device to be controlled. Defaults to 0.
/// </summary>
[Description("The axis index to be actuated.")]
public int Device { get; set; } = 0;
public int? Device { get; set; }

/// <summary>
/// Gets or sets the axis of the manipulator to be controlled.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class GenericCommandMultiResponse : Combinator<string, Response[]>
/// Gets or sets the device to be controlled. Defaults to 0.
/// </summary>
[Description("The axis index to be actuated.")]
public int Device { get; set; } = 0;
public int? Device { get; set; }

/// <summary>
/// Gets or sets the axis of the manipulator to be controlled.
Expand Down
2 changes: 1 addition & 1 deletion src/AllenNeuralDynamics.Zaber/GenericCommandNoResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public class GenericCommandNoResponse : Sink<string>
/// Gets or sets the device to be controlled. Defaults to 0.
/// </summary>
[Description("The axis index to be actuated.")]
public int Device { get; set; } = 0;
public int? Device { get; set; }

/// <summary>
/// Gets or sets the axis of the manipulator to be controlled.
Expand Down
17 changes: 11 additions & 6 deletions src/AllenNeuralDynamics.Zaber/ZaberDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -89,8 +89,9 @@ public void Home(int? deviceIndex, int? axis)

public void GenericCommandNoResponse(int? deviceIndex, int? axis, string command)
{
var device = devices[deviceIndex.HasValue ? deviceIndex.Value : 0];
device.GenericCommandNoResponseAsync(command, axis.HasValue? axis.Value : 0);
comm.GenericCommandNoResponseAsync(command,
deviceIndex.HasValue ? deviceIndex.Value : 0,
axis.HasValue? axis.Value : 0);
}

public async Task<double> GetPosition(int? deviceIndex, int axis, Units unit)
Expand Down Expand Up @@ -127,14 +128,18 @@ public async Task<Unit> WaitUntilIdle(int? deviceIndex, int? axis)

public async Task<Response[]> GenericCommandMultiResponse(int? deviceIndex, int? axis, string command)
{
var device = devices[deviceIndex.HasValue ? deviceIndex.Value : 0];
return await device.GenericCommandMultiResponseAsync(command, axis.HasValue? axis.Value : 0);
return await comm.GenericCommandMultiResponseAsync(
command,
deviceIndex.HasValue ? deviceIndex.Value : 0,
axis.HasValue ? axis.Value : 0);
}

public async Task<Response> GenericCommand(int? deviceIndex, int? axis, string command)
{
var device = devices[deviceIndex.HasValue ? deviceIndex.Value : 0];
return await device.GenericCommandAsync(command, axis.HasValue ? axis.Value : 0);
return await comm.GenericCommandAsync(
command,
deviceIndex.HasValue ? deviceIndex.Value : 0,
axis.HasValue ? axis.Value : 0);
}

/// <summary>
Expand Down

0 comments on commit 546ac44

Please sign in to comment.