release 1.0

This commit is contained in:
2025-06-14 19:51:05 +03:00
commit 1bd5009b9d
25 changed files with 3386 additions and 0 deletions

104
McuLib/m/asynchManage.m Normal file
View File

@@ -0,0 +1,104 @@
classdef asynchManage < handle
properties (Access = private)
modelName % Имя модели
maskBlockPath % Полный путь к блоку с маской
timerSave
timerUpdate
timerConfigUpdate
end
methods
function obj = asynchManage(modelName, maskBlockPath)
% Конструктор принимает имя модели и путь к блоку с маской
obj.modelName = modelName;
if nargin < 2
obj.maskBlockPath = ''; % если не передали, оставляем пустым
else
obj.maskBlockPath = maskBlockPath;
end
end
function saveAndUpdateModel(obj)
obj.timerSave = timer(...
'StartDelay', 0.01, ...
'ExecutionMode', 'singleShot', ...
'TimerFcn', @(~,~) obj.saveCallback());
start(obj.timerSave);
end
function updateGUIfromConfig(obj)
obj.timerConfigUpdate = timer(...
'StartDelay', 0.01, ...
'ExecutionMode', 'singleShot', ...
'TimerFcn', @(~,~) obj.GUIconfigCallback());
start(obj.timerConfigUpdate);
end
end
methods (Access = private)
function saveCallback(obj)
try
mcuMask.saveAndClose(obj.maskBlockPath);
save_system(obj.modelName);
catch ME
warning('progr:Nneg', 'Ошибка при сохранении модели: %s', ME.message);
end
stop(obj.timerSave);
delete(obj.timerSave);
obj.timerSave = [];
obj.timerUpdate = timer(...
'StartDelay', 0.05, ...
'ExecutionMode', 'singleShot', ...
'TimerFcn', @(~,~) obj.updateCallback());
start(obj.timerUpdate);
end
function updateCallback(obj)
try
set_param(obj.modelName, 'SimulationCommand', 'update');
save_system(obj.modelName);
catch ME
warning('progr:Nneg', 'Ошибка при обновлении модели: %s', ME.message);
end
% Открываем маску, если задан путь к блоку
if ~isempty(obj.maskBlockPath)
try
mcuMask.open(obj.maskBlockPath, 1);
fprintf('Mask opened for block %s\n', obj.maskBlockPath);
catch ME
warning('progr:Nneg', 'Не удалось открыть маску: %s', ME.message);
end
end
stop(obj.timerUpdate);
delete(obj.timerUpdate);
obj.timerUpdate = [];
end
function GUIconfigCallback(obj)
try
mcuMask.saveAndClose(obj.maskBlockPath);
mexing(0);
catch ME
warning('progr:Nneg', 'Ошибка при обновлении модели: %s', ME.message);
end
% Открываем маску, если задан путь к блоку
if ~isempty(obj.maskBlockPath)
try
mcuMask.open(obj.maskBlockPath, 1);
catch ME
warning('progr:Nneg', 'Не удалось открыть маску: %s', ME.message);
end
end
stop(obj.timerConfigUpdate);
delete(obj.timerConfigUpdate);
obj.timerConfigUpdate = [];
end
end
end