classdef PyTorchMaskCallbacks
    % 

    % Copyright 2023 The MathWorks,Inc.


    properties(Constant)
        MLSBName = 'PyTorch Model Block';
    end

    methods(Static)

        % Following properties of 'maskInitContext' are available to use:
        %  - BlockHandle
        %  - MaskObject
        %  - MaskWorkspace - Use get/set APIs to work with mask workspace.
        function MaskInitialization(maskInitContext)

            % disp('MaskInitialization');

            % Update mask param from the load command popup:
            block = gcb;
            val = get_param(block,'LoadCommandPopup');
            maskObj = Simulink.Mask.get(block);
            paramObj = maskObj.getParameter('TorchLoadCommand');
            paramObj.Value = val;

            % Update MLSB from Input and Output tables:
            internal.pycoexblks.updateMLSB(gcb, PyTorchMaskCallbacks.MLSBName);
            internal.pycoexblks.updateSubsystemBlockPorts(gcb, PyTorchMaskCallbacks.MLSBName);   
        end

        % Browsing to PyTorch files:

        function Control2(callbackContext)
            nnet.pycoexblks.browseToPyTorchFile(gcb);
        end

        % The input table:

        function InputTable(callbackContext)
            internal.pycoexblks.updateInputTable(gcb, '');
        end

        function InputNew(callbackContext)
            internal.pycoexblks.updateInputTable(gcb, 'New');
        end

        function InputDelete(callbackContext)
            internal.pycoexblks.updateInputTable(gcb, 'Delete');
        end

        function InputUp(callbackContext)
            internal.pycoexblks.updateInputTable(gcb, 'Up');
        end

        function InputDown(callbackContext)
            internal.pycoexblks.updateInputTable(gcb, 'Down');
        end

        % The output table:

        function OutputTable(callbackContext)
            internal.pycoexblks.updateOutputTable(gcb, '');
        end

        function OutputNew(callbackContext)
            internal.pycoexblks.updateOutputTable(gcb, 'New');
        end

        function OutputDelete(callbackContext)
            internal.pycoexblks.updateOutputTable(gcb, 'Delete');
        end

        function OutputUp(callbackContext)
            internal.pycoexblks.updateOutputTable(gcb, 'Up');
        end

        function OutputDown(callbackContext)
            internal.pycoexblks.updateOutputTable(gcb, 'Down');
        end

        % Pre and Post-processing files:

        function PreprocessControl(callbackContext)
            internal.pycoexblks.browseToPreprocessingFile(gcb);
        end

        function PostprocessControl(callbackContext)
            internal.pycoexblks.browseToPostprocessingFile(gcb);
        end

    end
end