|
随手翻译了一下,不成体系。搞清楚合成器的第一个输入端口和其他输入端口的区别可能更容易看懂。
& `; r6 i8 q+ H8 H1 M- /**根据全局表更新合成清单*/' z& \0 o1 M9 H
- string tablename ="订单表";8 I% H: M* F) V3 F3 C4 R; V
- /*8 t4 t( i4 G( y0 k* c( u
- This option should only be used on Combiners.3 h. w1 `- O( s
- 这段代码只能用于合成器。
2 n9 J7 W0 |( ^ - Each column in the GlobalTable is the component list for a single itemtype.
\3 J8 P( Q) Q% U7 ]' U) ] - 全局表中的每一列是被合成临时实体的清单。
' f9 I% k7 X. b- X! K0 U/ L - The itemtype of the first flowitem to enter is used to find the correct column.
$ ?, f* ~+ H! S; }& { - 从第一个输入端口进入的临时实体的类型决定了在全局表中的哪一列去查询合成清单。4 s8 |5 P" }7 I$ |( p0 b3 }
- It is assumed that the global table has a row for each input port number 2 and higher.
6 M6 |7 z! `3 R2 R+ X/ m - 全局表的每一行都代表着一个编号大于等于2的输入端口。% ~2 H7 x# z# Y
- */
. ?: ~8 V: ^5 y; c1 m
4 k" R$ U% K7 `, W! X- if(port == 1)7 C2 w* a, l! o! A; _: n
- { //The trigger on entry code fires each time a flow item enters the combiner." [3 ^$ L$ x1 z. _8 e$ Z
- //For this reason we check to make sure that the port entered is equal to 1$ k$ K) ?/ M$ U8 `8 y9 O
- //because only the container will enter through port 1.. G# `' x# t% I% h
- //每个临时实体进入合成器都会激活进入触发,所以必须要检查临时实体是否是从第一个端口进入的。8 @2 Y3 V9 V1 B3 ?
- //只有从第一个端口进入的临时实体才是托盘等容器类临时实体。2 }* U" g* A/ n
- //在上文已经解释过,第一个端口进入的临时实体的类型决定了采用全局表中的哪一列来设置合成清单。6 D+ e7 f5 c% W7 Y$ ? C$ ]
- //The component list in a combiner is set up as a table. This allows us to use the cell commands to obtain the node that contains
2 P: u* Q/ K6 [) U- K9 v - //合成清单以表格的形式存在。我们可以使用cell命令来获取数据节点。
" {( s7 ~7 F+ Y - //the number of items to retrieve from each port. Once you know what node contains the information you can use the setnodenum9 _. j9 Q `; W. V6 h
- //command to set the component list number based on the global table.
, p5 Q* Y* v; M, R! P S6 n. v - //当你知道数据存储于哪个节点之后,你就可以读取全局表中的数据,然后使用setnodenum命令在合成器中设置合成清单。) y8 [4 y# A6 e1 H, h0 ?1 G
- . F% L4 `2 n) [7 [6 ?$ o7 v @
- treenode thelist = getvarnode(current,"componentlist");8 e3 \7 P7 s! O, v2 t
- treenode thesum = getvarnode(current,"targetcomponentsum");) {( Y/ B( l9 a' j, y6 J
- //更改合成清单需要对两个数据节点进行设置。一个是componentlist,这个节点有一列数据,记录了从每个端口输入多少个临时实体。
- K/ M+ q- M2 P; X0 o0 x& A - //另一个是targetcomponentsum,记录本次打包的临时实体的总数。
& F) z- A$ z$ ]: D - setnodenum(thesum,0);5 M# A4 K A8 s5 d* ^
- , r7 A. s: U1 _% z0 G$ | p
- for(int index=1; index<=nrows(thelist); index++)
7 G' b; o/ T1 J Q* F. M) ~ - //componentlist以表格的形式存在,只有一列。如果合成器有n个输入端口,那么就有n-1行。(第一个输入端口输入的是容器)3 e$ D6 `5 [7 A7 t! F! q
- {
+ Q, d7 h( G" ]5 D+ J s2 p - setnodenum(cellrowcolumn(thelist,index,1),gettablenum(tablename,index,getitemtype(item)));
& w6 T5 T% ~( Y - //第一输入端口进入的临时实体的类型,决定了使用全局表中的哪一列数据。) k; I! @4 a$ k) A1 I/ u+ h6 Y
- //把该列数据全部读取出来,依次写入componentlist。
8 q- X& a0 b0 B - inc(thesum,gettablenum(tablename,index,getitemtype(item)));8 X, g0 }: S; Z3 `" Z# i
- //同时更新targetcomponentsum的值。4 B* [' c' S8 h% X$ B
- }+ `3 F5 z' `% ~( V* j
- }
复制代码 |
|