measurement state

This commit is contained in:
Silas Labor Zizou
2024-10-29 14:38:22 +01:00
parent 99fe2ca106
commit cf4e0f2b12
14 changed files with 1469 additions and 319 deletions

View File

@@ -0,0 +1,48 @@
function holdAndShowValue()
% Create the UI figure
fig = uifigure('Name', 'Multi-Channel Power Monitor', 'Position', [100 100 600 150]);
% Create labels to display the power values for each channel in a horizontal layout
powerLabels = gobjects(4, 1);
for i = 1:4
powerLabels(i) = uilabel(fig, 'Position', [50 + (i-1)*130, 70, 120, 30], ...
'FontSize', 18, 'HorizontalAlignment', 'center');
powerLabels(i).Text = sprintf('CH %d: Fetching...', i);
end
% Create the "OK" button
okButton = uibutton(fig, 'push', 'Text', 'OK', 'Position', [250 20 100 40], ...
'ButtonPushedFcn', @(src, event) closeWindow());
% Initialize the timer
updateTimer = timer('ExecutionMode', 'fixedRate', 'Period', 1, ...
'TimerFcn', @(src, event) updatePowerValues());
% Start the timer
start(updateTimer);
% Function to close the window and stop the timer
function closeWindow()
stop(updateTimer);
delete(updateTimer);
delete(fig);
end
% Function to fetch and update power values for all channels
function updatePowerValues()
powerValues = fetchPowerValues(); % Replace with your data-fetching function
for i = 1:4
powerLabels(i).Text = sprintf('CH %d: %.2f dBm', i, powerValues(i));
end
end
% Wait until the figure is closed to resume execution
waitfor(fig);
end
% Example function to simulate fetching power values for four channels
function powerValues = fetchPowerValues()
% Replace this with actual code to get the power values from the power meter
[p1,p2,p3,p4] = OptAtten().readPower();
powerValues = [p1,p2,p3,p4];
end

View File

@@ -41,7 +41,7 @@ function showCurrentMeasurement(varargin)
for i = 1:length(values)
varNameLower = names{i}; % Convert variable name to lowercase for case-insensitive comparison
if isnumeric(values{i})
if any(strcmpi(varNameLower, {'ber','mlse','ffe','db'}))
if any(contains(varNameLower, {'ber','mlse','ffe','db'}))
% Format 'ber' values in exponential notation with two decimal places
values{i} = sprintf('%.2e', values{i});
else

View File

@@ -0,0 +1,20 @@
function waitUntilClick()
% Create the UI figure
fig = uifigure('Name', 'Pause Execution', 'Position', [100 100 300 150]);
% Create a label to inform the user
uilabel(fig, 'Position', [50 80 200 40], 'Text', 'Click "Continue" to proceed', ...
'FontSize', 14, 'HorizontalAlignment', 'center');
% Create the "Continue" button
continueButton = uibutton(fig, 'push', 'Text', 'Continue', 'Position', [100 20 100 40], ...
'ButtonPushedFcn', @(src, event) closeWindow());
% Function to close the window when "Continue" is clicked
function closeWindow()
delete(fig); % Close the figure window
end
% Wait until the figure is closed to resume execution
waitfor(fig);
end