Skip to content

Commit

Permalink
Update get methods for Dependent properties
Browse files Browse the repository at this point in the history
Signed-off-by: Apelete Seketeli <[email protected]>
  • Loading branch information
apelete committed Sep 26, 2023
1 parent 82b9b21 commit 793b899
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 12 deletions.
28 changes: 17 additions & 11 deletions +adi/+AD2S1210/Rx.m
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,28 @@
SamplesPerFrame = 4096
end

properties
properties (Dependent)
% Angle
% Resolver angle in Degrees.
Angle = 0
Angle

% AngleScale Angular Scale
% Resolver angle scale.
AngleScale = 0
AngleScale

% Velocity Angular Velocity
% Resolver velocity in revolutions per second.
Velocity = 0
Velocity

% VelocityScale Velocity Angular Scale
% Resolver velocityscale.
VelocityScale = 0
VelocityScale
end

properties
% ExcitationFrequency Excitation Frequency
% Resolver excitation frequency in Hertz.
ExcitationFrequency = 0
ExcitationFrequency = 0;
end

properties (Hidden)
Expand Down Expand Up @@ -82,31 +84,35 @@
function rValue = get.Angle(obj)
if obj.ConnectedToDevice
rValue = obj.getAttributeRAW('angl0', 'raw', obj.isOutput);
obj.Angle = rValue;
else
rValue = NaN;
end
end

%% Check Angular Scale
function rValue = get.AngleScale(obj)
if obj.ConnectedToDevice
rValue = obj.getAttributeDouble('angl0', 'scale', obj.isOutput);
obj.AngleScale = rValue;
else
rValue = NaN;
end
end

%% Check Velocity
function rValue = get.Velocity(obj)
if obj.ConnectedToDevice
rValue = obj.getAttributeRAW('anglvel0','raw', obj.isOutput);
obj.Velocity = rValue;
else
rValue = NaN;
end
end

%% Check Velocity Scale
function rValue = get.VelocityScale(obj)
if obj.ConnectedToDevice
rValue = obj.getAttributeDouble('anglvel0', 'scale', obj.isOutput);
obj.VelocityScale = rValue;
else
rValue = NaN;
end
end
end
Expand All @@ -115,7 +121,7 @@
methods (Hidden, Access = protected)

function setupInit(obj)
% Read excitation frequency attribute from device once connected.
% Write excitation frequency attribute from device once connected.

obj.ExcitationFrequency = obj.getDeviceAttributeLongLong('excitation_frequency');
end
Expand Down
2 changes: 1 addition & 1 deletion examples/ad2s1210_DataCapture.m
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
% Connect to device and initialize data
rx();

% Retrieve and print resolver angle, angular velocity and scale
% Retrieve resolver angle, velocity and associated scales
rx.Angle();
rx.AngleScale();
rx.Velocity();
Expand Down

0 comments on commit 793b899

Please sign in to comment.