|
随手翻译了一下,不成体系。搞清楚合成器的第一个输入端口和其他输入端口的区别可能更容易看懂。0 ^) n' w/ q: A
- /**根据全局表更新合成清单*/% U- e7 Z- d2 A9 A; L5 S
- string tablename ="订单表";$ _: I/ p* A3 ~- K2 ~
- /*
% C1 q0 j- x' V T - This option should only be used on Combiners.
7 D# `6 U% k: A+ p$ e; d. ` - 这段代码只能用于合成器。
# W4 R4 r* p g) i: f; O5 ] - Each column in the GlobalTable is the component list for a single itemtype., h! [1 S/ k0 c* C
- 全局表中的每一列是被合成临时实体的清单。
4 ~( m, Z) m! c/ D8 r - The itemtype of the first flowitem to enter is used to find the correct column.+ o4 W: T% p4 q" q# k
- 从第一个输入端口进入的临时实体的类型决定了在全局表中的哪一列去查询合成清单。" s( P$ r% Z! ^5 M
- It is assumed that the global table has a row for each input port number 2 and higher.8 w. e7 J7 i7 i% E
- 全局表的每一行都代表着一个编号大于等于2的输入端口。
# \: O3 F9 z. V. B; } - */
3 f" e1 [+ N, n2 S5 H4 k - + x; D: r$ ~# r/ m) r0 a1 Z7 ~
- if(port == 1)' C5 y$ p& k& h6 F% [( z4 j
- { //The trigger on entry code fires each time a flow item enters the combiner.
; X% }2 [& n0 Y* B2 c - //For this reason we check to make sure that the port entered is equal to 1
* t* }' \! w3 z1 C& O Y5 W - //because only the container will enter through port 1.
/ y" G) b8 r+ s. L8 S4 h; W( o - //每个临时实体进入合成器都会激活进入触发,所以必须要检查临时实体是否是从第一个端口进入的。, `' x0 ?; D3 X
- //只有从第一个端口进入的临时实体才是托盘等容器类临时实体。
4 V: n) d* {; t/ z - //在上文已经解释过,第一个端口进入的临时实体的类型决定了采用全局表中的哪一列来设置合成清单。" Y& T9 [2 L3 \$ N- q: Y4 `
- //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 contains0 t( m6 t* F( N" O: p
- //合成清单以表格的形式存在。我们可以使用cell命令来获取数据节点。
' t- @5 \0 C, w9 L/ y& R6 @ - //the number of items to retrieve from each port. Once you know what node contains the information you can use the setnodenum: g6 E8 r8 C: f( {$ Q K7 h
- //command to set the component list number based on the global table.4 ]! s4 ~' Y0 R" x! R+ c
- //当你知道数据存储于哪个节点之后,你就可以读取全局表中的数据,然后使用setnodenum命令在合成器中设置合成清单。
( Q' y3 P+ m, p3 n8 [, b- B - ! `% ]/ j6 t8 N
- treenode thelist = getvarnode(current,"componentlist");8 z3 K: z8 |2 }- Q9 ?: c1 `
- treenode thesum = getvarnode(current,"targetcomponentsum");
# D! V1 f8 F, A0 w - //更改合成清单需要对两个数据节点进行设置。一个是componentlist,这个节点有一列数据,记录了从每个端口输入多少个临时实体。
+ x2 z* H: u& X. v - //另一个是targetcomponentsum,记录本次打包的临时实体的总数。
( o% n2 n0 |5 Z/ G+ Y0 M - setnodenum(thesum,0);7 M Z2 j& M; A8 u* H y( U
% T0 ^9 B/ K. s- for(int index=1; index<=nrows(thelist); index++)* q q4 C0 }' m/ p; G
- //componentlist以表格的形式存在,只有一列。如果合成器有n个输入端口,那么就有n-1行。(第一个输入端口输入的是容器)
6 Q; y7 p0 |! h3 W$ W( u1 k) ~- F - {
2 H( f' i# Y; A% _: H x( {+ L - setnodenum(cellrowcolumn(thelist,index,1),gettablenum(tablename,index,getitemtype(item)));
. B& d8 @3 c. b6 R. d - //第一输入端口进入的临时实体的类型,决定了使用全局表中的哪一列数据。 q q& k- T: i" G5 @, d
- //把该列数据全部读取出来,依次写入componentlist。3 Y: o# q6 k, T6 p. c1 E2 y* C
- inc(thesum,gettablenum(tablename,index,getitemtype(item)));
2 f# G" `3 [( ^4 Q7 B, M - //同时更新targetcomponentsum的值。
' s2 X7 H0 j: ]. ^5 w. [ y& l - }
/ Y" u: O T: T% N9 G, L3 Z2 T - }
复制代码 |
|