|
12 | 12 | projectRoot = fileparts(fileparts(fileparts(mfilename('fullpath')))); |
13 | 13 | run(fullfile(projectRoot, 'install.m')); |
14 | 14 |
|
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'); |
17 | 26 | TagRegistry.list(); |
18 | 27 |
|
19 | 28 | %% 2. Retrieve a single sensor by key |
20 | 29 | 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); |
30 | 31 |
|
31 | 32 | %% 3. Retrieve multiple sensors at once |
32 | 33 | keys = {'pressure', 'temperature'}; |
|
0 commit comments