diff --git a/examples/02-sensors/example_dynamic_thresholds_100M.m b/examples/02-sensors/example_dynamic_thresholds_100M.m index 313e058d..49872322 100644 --- a/examples/02-sensors/example_dynamic_thresholds_100M.m +++ b/examples/02-sensors/example_dynamic_thresholds_100M.m @@ -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)); diff --git a/examples/02-sensors/example_sensor_dashboard.m b/examples/02-sensors/example_sensor_dashboard.m index fd765a6d..f3ad8439 100644 --- a/examples/02-sensors/example_sensor_dashboard.m +++ b/examples/02-sensors/example_sensor_dashboard.m @@ -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_); % ======================================================== diff --git a/examples/02-sensors/example_sensor_multi_state.m b/examples/02-sensors/example_sensor_multi_state.m index e8d6a071..9a99950e 100644 --- a/examples/02-sensors/example_sensor_multi_state.m +++ b/examples/02-sensors/example_sensor_multi_state.m @@ -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]'); diff --git a/examples/02-sensors/example_sensor_registry.m b/examples/02-sensors/example_sensor_registry.m index c879036e..a8c5642f 100644 --- a/examples/02-sensors/example_sensor_registry.m +++ b/examples/02-sensors/example_sensor_registry.m @@ -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'}; diff --git a/examples/02-sensors/example_sensor_static.m b/examples/02-sensors/example_sensor_static.m index 3d3a4297..95a0e492 100644 --- a/examples/02-sensors/example_sensor_static.m +++ b/examples/02-sensors/example_sensor_static.m @@ -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]'); diff --git a/examples/02-sensors/example_sensor_threshold.m b/examples/02-sensors/example_sensor_threshold.m index bd5f99ba..9f31b5c3 100644 --- a/examples/02-sensors/example_sensor_threshold.m +++ b/examples/02-sensors/example_sensor_threshold.m @@ -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');