Skip to content

Commit baa2041

Browse files
authored
Merge pull request #53 from HanSur94/claude/reverent-bohr
fix(examples): ShowThresholds removal + registry construction + dead code cleanup
2 parents 64060c3 + 000ef51 commit baa2041

6 files changed

Lines changed: 23 additions & 41 deletions

examples/02-sensors/example_dynamic_thresholds_100M.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@
142142
%% Plot first sensor as demo
143143
fprintf('\nPlotting first sensor with FastSense...\n');
144144
fp = FastSense();
145-
fp.addTag(sensors{1}, 'ShowThresholds', true);
145+
fp.addTag(sensors{1});
146146
fp.render();
147147
title(fp.hAxes, sprintf('%s — 100M pts, 6 Dynamic Thresholds', ...
148148
sensors{1}.Name));

examples/02-sensors/example_sensor_dashboard.m

Lines changed: 7 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -15,23 +15,20 @@
1515
scMachine = StateTag('machine', 'X', [0 20 50 80], 'Y', [0 1 2 1]);
1616

1717
% ========================================================
18-
% Sensor 1: Chamber Pressure (from registry, add thresholds)
18+
% Sensor 1: Chamber Pressure
1919
% ========================================================
20-
s1 = TagRegistry.get('pressure');
21-
s1.Units = 'mbar';
2220
t1 = linspace(0, 100, 10000);
23-
s1.updateData(t1, 40 + 20*sin(2*pi*t1/25) + 4*randn(1, numel(t1)));
24-
21+
s1 = SensorTag('pressure', 'Name', 'Chamber Pressure', 'Units', 'mbar', ...
22+
'X', t1, 'Y', 40 + 20*sin(2*pi*t1/25) + 4*randn(1, numel(t1)));
2523

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

3633

3734
% ========================================================

examples/02-sensors/example_sensor_multi_state.m

Lines changed: 1 addition & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -47,25 +47,9 @@
4747
fprintf(' machine state at t=35: %d (running)\n', scMachine.valueAt(35));
4848
fprintf(' zone at t=50: %s\n', scZone.valueAt(50));
4949

50-
% --- Query active thresholds at specific time points ---
51-
fprintf('\n=== Active thresholds at specific times ===\n');
52-
queryTimes = [10, 35, 50, 65, 95];
53-
for i = 1:numel(queryTimes)
54-
tq = queryTimes(i);
55-
fprintf(' t = %3.0f s:', tq);
56-
if isempty(active)
57-
fprintf(' (none)\n');
58-
else
59-
for j = 1:numel(active)
60-
fprintf(' [%s] %.0f (%s)', active(j).Label, active(j).Value, active(j).Direction);
61-
end
62-
fprintf('\n');
63-
end
64-
end
65-
6650
% --- Plot with FastSense ---
6751
fp = FastSense();
68-
fp.addTag(s, 'ShowThresholds', true);
52+
fp.addTag(s);
6953
fp.render();
7054
title('Gas Flow — Multi-State Dynamic Thresholds');
7155
xlabel('Time [s]');

examples/02-sensors/example_sensor_registry.m

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,22 @@
1212
projectRoot = fileparts(fileparts(fileparts(mfilename('fullpath'))));
1313
run(fullfile(projectRoot, 'install.m'));
1414

15-
%% 1. List all sensors in the catalog
16-
fprintf('=== All registered sensors ===');
15+
%% 1. Register sensors in the catalog
16+
t = linspace(0, 80, 15000);
17+
pressure = SensorTag('pressure', 'Name', 'Pressure Sensor', 'Units', 'bar', ...
18+
'X', t, 'Y', 45 + 18*sin(2*pi*t/20) + 4*randn(1, numel(t)));
19+
temperature = SensorTag('temperature', 'Name', 'Temperature Sensor', 'Units', 'C', ...
20+
'X', t, 'Y', 72 + 8*sin(2*pi*t/30) + 2*randn(1, numel(t)));
21+
22+
TagRegistry.register('pressure', pressure);
23+
TagRegistry.register('temperature', temperature);
24+
25+
fprintf('=== All registered sensors ===\n');
1726
TagRegistry.list();
1827

1928
%% 2. Retrieve a single sensor by key
2029
s = TagRegistry.get('pressure');
21-
fprintf('Retrieved sensor: key="%s", name="%s", ID=%d\n', s.Key, s.Name, s.ID);
22-
23-
% Populate with synthetic data
24-
t = linspace(0, 80, 15000);
25-
s.updateData(t, 45 + 18*sin(2*pi*t/20) + 4*randn(1, numel(t)));
26-
27-
% Add state channel and state-dependent thresholds
28-
sc = StateTag('machine', 'X', [0 20 40 60], 'Y', [0 1 2 1]);
29-
30+
fprintf('Retrieved sensor: key="%s", name="%s"\n', s.Key, s.Name);
3031

3132
%% 3. Retrieve multiple sensors at once
3233
keys = {'pressure', 'temperature'};

examples/02-sensors/example_sensor_static.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828

2929
% --- Plot ---
3030
fp = FastSense();
31-
fp.addTag(s, 'ShowThresholds', true);
31+
fp.addTag(s);
3232
fp.render();
3333
title('Motor Vibration — Static Upper & Lower Thresholds');
3434
xlabel('Time [s]');

examples/02-sensors/example_sensor_threshold.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@
2424

2525
% --- Plot with FastSense ---
2626
fp = FastSense();
27-
fp.addTag(s, 'ShowThresholds', true);
27+
fp.addTag(s);
2828
fp.render();
2929
title('Chamber Pressure with Dynamic Thresholds');
3030
xlabel('Time');

0 commit comments

Comments
 (0)