Main Content

systemcomposer.arch.Function

Software architecture function

    Description

    A Function object represents a function in a software architecture model.

    Use the Functions Editor from the toolstrip on a software architecture model, to edit the simulation execution order and sample time of functions with inherited sample time (-1) in your software architecture.

    Creation

    Get functions in a software architecture model.

    model = systemcomposer.openModel('ThrottleControlComposition');
    sim('ThrottleControlComposition');
    functions = model.Architecture.Functions

    Properties

    expand all

    Architecture model where element belongs, specified as a systemcomposer.arch.Model object.

    Execution order of functions, specified as a row vector of numeric values.

    Example: [model.Architecture.Functions.ExecutionOrder]

    Data Types: uint64

    Name of function, specified as a character vector.

    Data Types: char

    Component where function is defined, specified as a systemcomposer.arch.Component object.

    Parent architecture of element where function is defined, specified as a systemcomposer.arch.Architecture object.

    Period of function, specified as a numeric value convertible to a string, or a string of valid MATLAB® variables. The Period property of aperiodic functions is editable. Editing the Period property of a periodic function will result in an error.

    Universal unique identifier for function, specified as a character vector.

    Example: '91d5de2c-b14c-4c76-a5d6-5dd0037c52df'

    Data Types: char

    Unique external identifier for function, specified as a character vector. The external ID is preserved over the lifespan of the function and through all operations that preserve the UUID.

    Data Types: char

    Object Functions

    increaseExecutionOrderChange function execution order to later
    decreaseExecutionOrderChange function execution order to earlier

    Examples

    collapse all

    This example shows the software architecture of a throttle position control system and how to schedule the execution order of the root level functions.

    model = systemcomposer.openModel('ThrottleControlComposition');

    Simulate the model to populate it with functions.

    sim('ThrottleControlComposition');

    View the function names ordered by execution order.

    functions = {model.Architecture.Functions.Name}'
    functions = 6x1 cell
        {'Actuator_output_5ms'   }
        {'Controller_run_5ms'    }
        {'TPS_Primary_read_5ms'  }
        {'TPS_Secondary_read_5ms'}
        {'TP_Monitor_D1'         }
        {'APP_Sensor_read_10ms'  }
    
    

    Decrease the execution order of the third function.

    decreaseExecutionOrder(model.Architecture.Functions(3))

    View the function names ordered by execution order.

    functions = {model.Architecture.Functions.Name}'
    functions = 6x1 cell
        {'Actuator_output_5ms'   }
        {'TPS_Primary_read_5ms'  }
        {'Controller_run_5ms'    }
        {'TPS_Secondary_read_5ms'}
        {'TP_Monitor_D1'         }
        {'APP_Sensor_read_10ms'  }
    
    

    The third function is now moved up in execution order, executing earlier.

    Increase the execution order of the second function.

    increaseExecutionOrder(model.Architecture.Functions(2))

    View the function names ordered by execution order.

    functions = {model.Architecture.Functions.Name}'
    functions = 6x1 cell
        {'Actuator_output_5ms'   }
        {'Controller_run_5ms'    }
        {'TPS_Primary_read_5ms'  }
        {'TPS_Secondary_read_5ms'}
        {'TP_Monitor_D1'         }
        {'APP_Sensor_read_10ms'  }
    
    

    The second function is now moved down in execution order, executing later.

    More About

    expand all

    Introduced in R2021b