|
随手翻译了一下,不成体系。搞清楚合成器的第一个输入端口和其他输入端口的区别可能更容易看懂。) I# T" r5 ^" j( T3 c$ [1 s
- /**根据全局表更新合成清单*/9 Y/ k7 |( p2 J1 ?; `' l8 l: f
- string tablename ="订单表";- c5 B5 {0 P. K5 M6 F# l
- /*
- M3 x. d1 K( O5 F$ u+ { - This option should only be used on Combiners.6 L+ s8 ]8 a& ~: Q* m( D, i+ {
- 这段代码只能用于合成器。; j/ o" W6 W! V. `- d& H& n
- Each column in the GlobalTable is the component list for a single itemtype.
! \: l- Q* r7 }. ]6 v# s8 F4 n$ K1 S6 R - 全局表中的每一列是被合成临时实体的清单。
( V& \6 k* a3 |# x - The itemtype of the first flowitem to enter is used to find the correct column., S6 X8 c3 t$ o5 K# A
- 从第一个输入端口进入的临时实体的类型决定了在全局表中的哪一列去查询合成清单。
& K$ e. M2 c3 I0 }% V: T. X7 c - It is assumed that the global table has a row for each input port number 2 and higher.
$ L4 Y: D. F/ `& n _ - 全局表的每一行都代表着一个编号大于等于2的输入端口。
- V, A1 k5 h3 ~ - */
: y# C4 i7 m: {9 m
/ ?* J' f* N4 A# Q4 W$ G2 g- if(port == 1) I% O+ a8 h5 X8 c
- { //The trigger on entry code fires each time a flow item enters the combiner.
' G. F' M* u4 q/ T - //For this reason we check to make sure that the port entered is equal to 1) z3 @4 w7 A% c
- //because only the container will enter through port 1.5 A* n. r+ s3 ^, x% V0 n0 A
- //每个临时实体进入合成器都会激活进入触发,所以必须要检查临时实体是否是从第一个端口进入的。0 o2 L: N- f7 S
- //只有从第一个端口进入的临时实体才是托盘等容器类临时实体。+ m( O- {! Z0 v
- //在上文已经解释过,第一个端口进入的临时实体的类型决定了采用全局表中的哪一列来设置合成清单。% x2 n* v* V$ l4 R
- //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
* U- ^8 h9 Y5 H. a8 C - //合成清单以表格的形式存在。我们可以使用cell命令来获取数据节点。
5 X/ V4 j0 m0 a: S - //the number of items to retrieve from each port. Once you know what node contains the information you can use the setnodenum, m C4 ?. ^6 U* S
- //command to set the component list number based on the global table.) i/ G5 z' Y: R
- //当你知道数据存储于哪个节点之后,你就可以读取全局表中的数据,然后使用setnodenum命令在合成器中设置合成清单。/ M. T$ g" e8 L5 x
& `8 r" f8 r2 L5 R* w& `2 p0 ?- treenode thelist = getvarnode(current,"componentlist");
1 \# c% N9 Y. @2 }- [& ?% @ - treenode thesum = getvarnode(current,"targetcomponentsum");( ? m$ c& [, E, R
- //更改合成清单需要对两个数据节点进行设置。一个是componentlist,这个节点有一列数据,记录了从每个端口输入多少个临时实体。" D5 A) m: B4 P* O1 b$ Z
- //另一个是targetcomponentsum,记录本次打包的临时实体的总数。
* u2 m( ?- e1 W+ U7 c: p - setnodenum(thesum,0);
$ v. B) ~* d5 d% n$ _$ M- V. R0 a
3 g, j+ v( Z7 T% w: x- x3 ]# C! Q- for(int index=1; index<=nrows(thelist); index++)
; _0 n, W0 V' u - //componentlist以表格的形式存在,只有一列。如果合成器有n个输入端口,那么就有n-1行。(第一个输入端口输入的是容器)6 A& U8 d2 v* O
- {/ R/ D+ ^- }3 H
- setnodenum(cellrowcolumn(thelist,index,1),gettablenum(tablename,index,getitemtype(item)));$ k2 C M& A/ G$ `# Y
- //第一输入端口进入的临时实体的类型,决定了使用全局表中的哪一列数据。" I9 D2 Y- A5 [) k1 q
- //把该列数据全部读取出来,依次写入componentlist。
; L* Q9 ?" Y, U( l0 y- ~# I m - inc(thesum,gettablenum(tablename,index,getitemtype(item)));0 f: O$ c$ p8 G# m: r
- //同时更新targetcomponentsum的值。
- v2 o& _: w' z4 h' b: W, p3 h - }4 `( B$ \1 e* ?0 j7 O0 ^
- }
复制代码 |
|