全球FlexSim系统仿真中文论坛

搜索
查看: 3623|回复: 1

createcopy、createinstance、insertcopy的区别

[复制链接]
zorsite 发表于 2019-5-24 12:31:08 | 显示全部楼层 |阅读模式
共同点:
: Y, g/ `+ ?% A& P三个函数的本质都是插入节点。+ `1 k+ Z4 u; e. U# I; x* W4 r; Y
不同点:: o% S1 j# W. k* u. \
createcopy是复制节点,可以将任意节点复制到任意节点,比如复制暂存区到模型,复制A实体标签至B实体。6 G! i. S4 L0 ^# _  A
createinstance是实例化类,可以将类实例化。
6 A( E+ Z: J; {; Uinsertcopy是复制临时实体到某个实体之中。
- u" c7 o# I, X  M
- v4 ~/ Z  _! x8 k8 ^比如要在模型中插入一个暂存区:8 S$ Y! r6 N5 t
如果使用createcopy函数,会将复制对象的颜色、位置、标签、触发等属性完全复制,原暂存区内的临时实体也会完全复制,甚至连名字都可以一模一样,这就是“copy”。
+ i# I) [$ k0 y; A8 M+ }如果使用createinstance,效果等同于从library拖一个暂存区到模型中,在程序中我们称之为“将Queue类实例化”,也就是在模型中创建一个崭新的暂存区对象。
% G8 z) {0 {! `/ ]: s. g- [insertcopy无法复制固定实体,只能复制临时实体,并且会激活OnReceive事件和OnEntry触发。
- L2 O, g# _2 ?  h
6 Z9 a5 r3 Z4 l. }7 ]createcopy
createcopy (node thenode, node container [,num samename, num inobject, num cached, num replace])
Copies thenode into the specified container
Description
Copy thenode into the node specified ascontainer. This command is different from createinstance() in that it does notattempt to establish any links between thenode and any class. If aninstantiation is required, use createinstance() instead.
createinstance
createinstance (obj class, obj location)
Description
This command creates an instance of theclass specified as class and places it in the object specified as location. Theinstance will be given a name that is the name of the class followed by anumber. The instance will have all of the variables and attributes of class andit's superclasses. Nodes in the behavior node will not be copied into theinstance, as they apply to all instances of the class. The object passed asclass should be in the library. Generally, location is the model. The libraryand the model can be easily referenced using the library() and model()commands.
insertcopy
insertcopy (obj originalobject, objcontainerobject)
Creates a copy of the flowitem and moves itinto the container object
Description
Creates a copy of the flowitem and moves itinto the container object, causing the OnReceive event of the container toexecute.
7 K1 K' c0 [8 h/ h

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有帐号?立即注册

x

评分

参与人数 1威望 +10 收起 理由
慧娴亚伦 + 10 很给力!

查看全部评分

 楼主| zorsite 发表于 2019-5-24 12:37:07 | 显示全部楼层
注意:因为是在脚本窗口编写代码,无法有效引用临时实体,只能点击临时实体,将其指定为so。
; v: \! P: p* i# F: l
% ]' w; _; r& `
  1. createcopy(node("Queue3", model()),model);
    6 p; K9 \& E& z' M9 g
  2. createinstance(node("/fixedresources/Queue",library),model);5 ?6 A8 e) @4 c% P- d, z! s
  3. insertcopy(node("Queue3", model()),model);//不能复制固定实体
      M; H$ z0 s( C1 }
  4. insertcopy(so,node("Queue77", model()));//只能复制临时实体
复制代码
/ F# F! R. d! m* f& S
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|小黑屋|手机版|Archiver|全球FlexSim系统仿真中文论坛 ( 京ICP备14043114号-2 )

GMT+8, 2024-3-29 20:38 , Processed in 0.071723 second(s), 19 queries .

Powered by Discuz! X3.3© 2001-2013 Comsenz Inc.

快速回复 返回顶部 返回列表