Block callback functions simulink

本文详细介绍了Simulink环境中各种块回调函数的功能及其执行时机,包括复制、删除、初始化等操作时触发的不同回调函数,并解释了它们如何帮助用户定制模型的行为。

 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 the DeleteChildFcn.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.The DeleteFcn 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. The OpenFcn 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 (see new_system in the online Simulink softwarereference) or the Create Subsystem itemin model editor's Edit menu. The ParentCloseFcn 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 the error commandeither explicitly or via a command used in anyPreCopyFcn.The PreCopyFcn 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. The PreDeleteFcn is not called whenthe model containing the block is closed. The block'sDeleteFcn iscalled after the PreDeleteFcn unless the PreDeleteFcn invokestheerror command either explicitly or via a commandused in the PreDeleteFcn.

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's mdlProcessParameters 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. See S-Function Callback Methods for more information.

UndoDeleteFcn

When a block deletion is undone.


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值