1 T4 l7 r7 u, e+ `5 f: P7 Ntreenode/ c0 }; m% r/ t* D
Variable Types7 J$ E: W7 H: N4 E% t: F1 f& A" p
Flexsim uses just four variable types. Each of the four types can also be used in an array structure. The following explains each of these types.% f/ j. S) \/ a0 t; n* F% n% \ r6 w% p
Type Description 3 ^, i P/ h9 s" A3 i0 hint integer type & H* P. X# v, X9 K8 V
double double precision floating point type 2 f9 q$ r1 U" {! C, {- Q( D7 Rstring text string / z3 n. }! V- b' a
treenode reference to a Flexsim node or object % F/ ~3 x5 K1 ` `$ I) V
flexsim中有4种类型的变量:int,double,string,treenode。treenode指的是flexsim中的一个节点或者一个实体。 3 R: P* |- _2 U " R/ c5 t' X& n, d7 I' h4 w1 L8 Zcurrent<no parentheses> ; }9 w/ o6 `* s$ S9 R% E8 g C
Description: 8 o }6 O& h& s
Deprecated. This should not be used as a special command with the setcurrent command anymore. Instead, declare a treenode variable type as current, then use current in your code as any other variable type. 0 a8 [: w% P. y k' a2 a
不建议使用。current和setcurrent不应再被用作命令。如果需要设置某实体为当前实体,应先声明一个名为current的树节点型变量,然后在代码中引用该变量。7 q9 O8 v! ^0 q, u. z; d+ _
不解: & H/ x! d" @ n& W7 F' C' Z9 a6 e1.used...with....是什么意思? h9 K0 ^* \3 j5 P4 @9 |! h) ^以前current是必须和setcurrent一起使用的吗?5 u) z( z) A! n1 K2 T6 S, q: Z
; E! Y3 @1 V/ K+ W% M, B; E% x
2.as any other variable type是什么意思? 8 }: ^8 ?4 _2 R. U, g前面说要声明一个名为current的树结点型变量,然后在代码中可以把current作为任意类型的变量使用?可以用为string型变量吗?6 J/ \+ T8 z6 C" d6 S: p6 c
Example: 5 P9 ?. y. _( p- F
treenode current = rank(model(),3); 5 v% ^/ m* `' ?* h7 A
pt(getname(current));
复制代码
# v1 S/ B5 M$ L4 A+ G7 d$ K: XThis sets the object that is ranked 3 in the model to current and prints its name to the output console. 5 y7 h. Z D; \2 x, @& l' X : z( }$ B' y: R) D8 T, r I% w! U4 d8 u/ b5 M8 H
ownerobject(node thenode)4 F/ p7 E& w4 u0 F. g
Description:; A! A0 ^6 T X
This command returns the node with object data attached to it that is the start of the sub-tree that thenode is in. In other words, it returns the object node that contains thenode.* \4 d* f1 N* t3 D- v3 K# @
This command is used in most code fields and trigger fields to set the access variable current. In these fields, c references the node that contains the code, and ownerobject(c) references the object that "owns" that node. 7 m- Y* r# X/ d- j8 U) M: k该函数返回参数节点所在的实体。 f# w4 R' r0 R2 \ E
/ D6 q7 s. ?& HExample: & J# \$ O5 J- C) [( |/ Z; ]
string objname = getname(ownerobject(c));
复制代码
( I" \2 H, D# e" a+ x* O
This sets objname to the name of the object that contains the node referenced by c. The c usually refers to the node where the code is being written.
treenode current = ownerobject(c);
复制代码
+ M" M5 T0 v5 aThis example is present in most code fields in Flexsim, and retrieves access to the "current" object. * o+ @4 |6 W# S6 r: {' ~这段代码出现在大多数flexsim代码的开头部位,指的是“当前”实体,就是代码所在实体。 6 p/ u/ h; E Q/ T + I6 A1 K4 r) Rc<no parentheses> ; p, {# y4 L l0 p/ oDescription: # z. u- u S5 S+ L2 d
This command is used to reference the active node during a function's execution. ! {3 D: ~! U- m
If the function was called using nodefunction(), c returns a reference to the node on which the function is written. / ]) A( n5 R; iIf the function is an event function, c returns a reference to the object that contains the event. & s. }# u7 G X+ ]3 k7 P
c在函数执行的过程中指向活动实体。 " U% G0 c7 n' J& a% }; O/ G如果是节点型函数,c指向函数所在实体,. Q' w+ D6 b$ Y/ a* r" T
如果是事件型函数,c指向事件所在实体。* n5 C' P' m. U( f: T9 T- ^$ `
Example:
treenode current = ownerobject(c);
复制代码
: J) o( B' k0 B8 J4 G' K2 Q% K- v5 m3 N
setcurrent(thing) 7 y5 X! W9 x d @Description: Deprecated. Do not use. # i2 k! r2 p2 b) L' a0 \Example: / / ~* w0 _% e8 F7 K' |* M2 }此命令不再使用。5 `' D& m' P' A: |
8 v1 G5 z v9 ^9 g7 zitem<no parentheses> . l1 f9 V+ q. H1 g3 Q3 k5 [
Description: ; V1 E6 i. P) a5 \1 S
Deprecated. This should not be used as a special command with the setitem command anymore. Instead, declare a treenode variable type as item, then use item in your code as any other variable type. 6 a" u; v# P# L e" E
不要再使用item和setitem命令了。如果需要指向某一临时实体,应该先声明一个名为item的树节点型变量,然后在代码中引用该变量。: Z9 G/ c7 G) @+ { b
Example:
4 s, `0 V6 z' \( S
This sets the object that is ranked 3 in the model to item and prints its name to the output console. P+ w4 Y" V4 W% j( d- ?4 Z4 O! `
) E/ \* p" _# v% x9 P+ R 8 W4 Q9 f! V' m2 xsetitem(thing)9 s' \3 F1 M2 g# h V9 E0 h
Description: Deprecated. Do not use. $ M( H/ w5 B; T2 v7 l+ T/ K
Example: /+ ~. T# S, N1 M J& M8 N
此命令不再使用。" G; B/ ~/ K2 q% f* H) I
4 u, Y* a' L8 }4 h4 F3 oparnode(num index) ' O0 r1 a2 N$ A. p, n' C
Description: ' u3 u; ]( l% i" \0 [/ s
This command is used inside a function that is called by the nodefunction() command. $ K) `% u+ f" b9 k) m- S( J/ i此命令用在一个被nodefunction调用的函数中。"nodefunction() command"指的是什么?command和function有何不同? + o. ?# y4 o& M: Y) C& Q8 hIt returns the parameter passed to nodefunction specified by index as a node (or treenode). 2 T- h7 R( J4 t( F. E
此命令返回一个节点(或树结点)参数.该参数由序号指定,并会传递给nodefunction. 3 Y, [8 y9 A3 C4 B+ P5 ?4 X节点和树节点有何不同? % |# S5 L9 u- E- l+ HThe first additional parameter passed to nodefunction() is parameter 1, the second is parameter 2, etc.9 y- H9 O( a) g: J
parnode,parval,parstr这三个命令真是让人搞不懂啊..., i% i3 S& {. x# h2 ~7 H6 q3 F. `
Parameters can also be retrieved using parval() and parstr() for casting them as numbers and strings respectively. ! n F; @. g0 F: H) k% yExample: - A! K4 q8 P( _: k9 q1 A3 _
If a trigger/field is called with: # ]/ h* x! t/ jnodefunction(thefuncnode, item) ' Q _: X" M! z: {- [$ Fthen within the trigger/field, getting access to the item passed as the first additional parameter would be done with:
treenode item = parnode(1);
复制代码
9 L4 T! M. q- h0 J+ t7 K" f
( Z4 j. J9 ?) z0 m2 _ E
port<no parentheses> 7 ~* p7 n% k! ]2 B0 D: h* FDescription: ' G1 f. a2 J7 k- X5 z* s4 _Deprecated. This should not be used as a special command with the setport command anymore. Instead, declare an int variable type as port, then use port in your code as any other variable type. 1 g; t, ^- y; i- a: j" ?
Example: * ?, k3 `/ Q1 l; ]% d! _) h
int port = parval(3);# b6 g1 C; a B5 O; }! ?
pd(port);
复制代码
v, h4 m+ N% ~This sets port to parval(3) and then prints the value to the output console.) @+ @. E- J: ?8 x& ?) [
8 y7 e! @" Y$ T1 h
不推荐使用。port和setport都不应再作为命令来使用。如果在代码中需要使用端口,需要声明一个名为port的整数型变量,然后在代码中直接使用port作为变量。作者: 天性518 时间: 2013-9-17 13:56 1#zorsite& C5 Y/ J3 o- a4 h6 w% R