Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/02-sensors/example_dynamic_thresholds_100M.m
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@
%% Plot first sensor as demo
fprintf('\nPlotting first sensor with FastSense...\n');
fp = FastSense();
fp.addTag(sensors{1}, 'ShowThresholds', true);
fp.addTag(sensors{1});
fp.render();
title(fp.hAxes, sprintf('%s — 100M pts, 6 Dynamic Thresholds', ...
sensors{1}.Name));
Expand Down
17 changes: 7 additions & 10 deletions examples/02-sensors/example_sensor_dashboard.m
Original file line number Diff line number Diff line change
Expand Up @@ -15,23 +15,20 @@
scMachine = StateTag('machine', 'X', [0 20 50 80], 'Y', [0 1 2 1]);

% ========================================================
% Sensor 1: Chamber Pressure (from registry, add thresholds)
% Sensor 1: Chamber Pressure
% ========================================================
s1 = TagRegistry.get('pressure');
s1.Units = 'mbar';
t1 = linspace(0, 100, 10000);
s1.updateData(t1, 40 + 20*sin(2*pi*t1/25) + 4*randn(1, numel(t1)));

s1 = SensorTag('pressure', 'Name', 'Chamber Pressure', 'Units', 'mbar', ...
'X', t1, 'Y', 40 + 20*sin(2*pi*t1/25) + 4*randn(1, numel(t1)));

% ========================================================
% Sensor 2: Chamber Temperature (from registry, static thresholds)
% Sensor 2: Chamber Temperature
% ========================================================
s2 = TagRegistry.get('temperature');
s2.Units = [char(176) 'C'];
t2 = linspace(0, 100, 8000);
t2 = linspace(0, 100, 10000);
s2_y_ = 22 + 5*sin(2*pi*t2/40) + 1.5*randn(1, numel(t2));
s2_y_(3000:3100) = s2_y_(3000:3100) + 12; % spike
s2.updateData(t2, s2_y_);
s2 = SensorTag('temperature', 'Name', 'Chamber Temperature', 'Units', [char(176) 'C'], ...
'X', t2, 'Y', s2_y_);


% ========================================================
Expand Down
18 changes: 1 addition & 17 deletions examples/02-sensors/example_sensor_multi_state.m
Original file line number Diff line number Diff line change
Expand Up @@ -47,25 +47,9 @@
fprintf(' machine state at t=35: %d (running)\n', scMachine.valueAt(35));
fprintf(' zone at t=50: %s\n', scZone.valueAt(50));

% --- Query active thresholds at specific time points ---
fprintf('\n=== Active thresholds at specific times ===\n');
queryTimes = [10, 35, 50, 65, 95];
for i = 1:numel(queryTimes)
tq = queryTimes(i);
fprintf(' t = %3.0f s:', tq);
if isempty(active)
fprintf(' (none)\n');
else
for j = 1:numel(active)
fprintf(' [%s] %.0f (%s)', active(j).Label, active(j).Value, active(j).Direction);
end
fprintf('\n');
end
end

% --- Plot with FastSense ---
fp = FastSense();
fp.addTag(s, 'ShowThresholds', true);
fp.addTag(s);
fp.render();
title('Gas Flow — Multi-State Dynamic Thresholds');
xlabel('Time [s]');
Expand Down
23 changes: 12 additions & 11 deletions examples/02-sensors/example_sensor_registry.m
Original file line number Diff line number Diff line change
Expand Up @@ -12,21 +12,22 @@
projectRoot = fileparts(fileparts(fileparts(mfilename('fullpath'))));
run(fullfile(projectRoot, 'install.m'));

%% 1. List all sensors in the catalog
fprintf('=== All registered sensors ===');
%% 1. Register sensors in the catalog
t = linspace(0, 80, 15000);
pressure = SensorTag('pressure', 'Name', 'Pressure Sensor', 'Units', 'bar', ...
'X', t, 'Y', 45 + 18*sin(2*pi*t/20) + 4*randn(1, numel(t)));
temperature = SensorTag('temperature', 'Name', 'Temperature Sensor', 'Units', 'C', ...
'X', t, 'Y', 72 + 8*sin(2*pi*t/30) + 2*randn(1, numel(t)));

TagRegistry.register('pressure', pressure);
TagRegistry.register('temperature', temperature);

fprintf('=== All registered sensors ===\n');
TagRegistry.list();

%% 2. Retrieve a single sensor by key
s = TagRegistry.get('pressure');
fprintf('Retrieved sensor: key="%s", name="%s", ID=%d\n', s.Key, s.Name, s.ID);

% Populate with synthetic data
t = linspace(0, 80, 15000);
s.updateData(t, 45 + 18*sin(2*pi*t/20) + 4*randn(1, numel(t)));

% Add state channel and state-dependent thresholds
sc = StateTag('machine', 'X', [0 20 40 60], 'Y', [0 1 2 1]);

fprintf('Retrieved sensor: key="%s", name="%s"\n', s.Key, s.Name);

%% 3. Retrieve multiple sensors at once
keys = {'pressure', 'temperature'};
Expand Down
2 changes: 1 addition & 1 deletion examples/02-sensors/example_sensor_static.m
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@

% --- Plot ---
fp = FastSense();
fp.addTag(s, 'ShowThresholds', true);
fp.addTag(s);
fp.render();
title('Motor Vibration — Static Upper & Lower Thresholds');
xlabel('Time [s]');
Expand Down
2 changes: 1 addition & 1 deletion examples/02-sensors/example_sensor_threshold.m
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@

% --- Plot with FastSense ---
fp = FastSense();
fp.addTag(s, 'ShowThresholds', true);
fp.addTag(s);
fp.render();
title('Chamber Pressure with Dynamic Thresholds');
xlabel('Time');
Expand Down
Loading