Block callback functions simulink

来源:互联网 发布:相机特效软件 编辑:程序博客网 时间:2024/05/01 16:50

 Creating Model Callback Functions



Block Callback Parameters

This table lists the parameters for which you can define blockcallback routines, and indicates when those callback routines areexecuted. Routines that are executed before or after actions takeplace occur immediately before or after the action.

ParameterWhen Executed

ClipboardFcn

When the block is copied or cut to the system clipboard.

CloseFcn

When the block is closed using the close_system command.The CloseFcn is not called when you interactivelyclose the block, when you interactively close the subsystem or modelcontaining the block, or when you close the subsystem or model containingthe block using close_system.

ContinueFcn

Before the simulation continues.

CopyFcn

After a block is copied. The callback is recursive forSubsystem blocks (that is, if you copy a Subsystem block that containsa block for which theCopyFcn parameter is defined,the routine is also executed). The routine is also executed if anadd_block commandis used to copy the block.

DeleteChildFcn

After a block or line is deleted in a subsystem. If theblock has a DeleteFcn orDestroyFcn,those functions are executed prior to theDeleteChildFcn.Only Subsystem blocks have aDeleteChildFcn callback.

DeleteFcn

After a block is graphically deleted, e.g., when yougraphically delete the block, invokedelete_block onthe block, or close the model containing the block. When theDeleteFcn iscalled, the block handle is still valid and can be accessed usingget_param.TheDeleteFcn callback is recursive for Subsystemblocks. If the block is graphically deleted by invokingdelete_block orby closing the model, after deletion the block is destroyed from memoryand the block'sDestroyFcn is called.

DestroyFcn

When the block has been destroyed from memory, e.g.,when you invoke delete_block on either the blockor a subsystem containing the block or close the model containingthe block. If the block was not previously graphically deleted, theblock'sDeleteFcn is called prior to the DestroyFcn.When the DestroyFcn is called, the block handleis no longer valid.

ErrorFcn

When an error has occurred in a subsystem. Only Subsystemblocks have an ErrorFcn callback. For more information,seeSubsystem Error Function Callback.

InitFcn

Before the block diagram is compiled and before blockparameters are evaluated.

LoadFcn

After the block diagram is loaded. This callback is recursivefor Subsystem blocks.

ModelCloseFcn

Before the block diagram is closed. When the model isclosed, the block's ModelCloseFcn is called priorto itsDeleteFcn. This callback is recursive forSubsystem blocks.

MoveFcn

When the block is moved or resized.

NameChangeFcn

After a block's name and/or path changes. When a Subsystemblock's path is changed, it recursively calls this function for allblocks it contains after calling its ownNameChangeFcn routine.

OpenFcn

When the block is opened. This parameter is generallyused with Subsystem blocks. The routine is executed when you double-clickthe block or when anopen_system command is calledwith the block as an argument. TheOpenFcn parameteroverrides the normal behavior associated with opening a block, whichis to display the block's dialog box or to open the subsystem.

ParentCloseFcn

Before closing a subsystem containing the block or whenthe block is made part of a new subsystem using thenew_system command (seenew_system in the online Simulink softwarereference) or theCreate Subsystem itemin model editor's Edit menu. TheParentCloseFcn ofblocks at the root model level is not called when the model is closed.

PauseFcn

After the simulation pauses.

PostSaveFcn

After the block diagram is saved. This callback is recursivefor Subsystem blocks.

PreCopyFcnBefore a block is copied. The callback is recursive for Subsystemblocks (that is, if you copy a Subsystem block that contains a blockfor which thePreCopyFcn parameter is defined,that routine is also executed). The block'sCopyFcn iscalled after all PreCopyFcn callbacks are executed,unless thePreCopyFcn invokes theerror commandeither explicitly or via a command used in anyPreCopyFcn.ThePreCopyFcn is also executed if an add_block commandis used to copy the block.PreDeleteFcnBefore a block is graphically deleted, e.g., when the usergraphically deletes the block or invokesdelete_block onthe block. ThePreDeleteFcn is not called whenthe model containing the block is closed. The block'sDeleteFcn iscalled after thePreDeleteFcn unless the PreDeleteFcn invokestheerror command either explicitly or via a commandused in thePreDeleteFcn.

PreSaveFcn

Before the block diagram is saved. This callback is recursivefor Subsystem blocks.

StartFcn

After the block diagram is compiled and before the simulationstarts. In the case of an S-Function block,StartFcn executesimmediately before the first execution of the block'smdlProcessParameters function.See S-Function Callback Methods for more information.

StopFcn

At any termination of the simulation. In the case ofan S-Function block, StopFcn executes after theblock'smdlTerminate function executes. SeeS-Function Callback Methods for more information.

UndoDeleteFcn

When a block deletion is undone.