|
随手翻译了一下,不成体系。搞清楚合成器的第一个输入端口和其他输入端口的区别可能更容易看懂。2 J$ m$ x0 g" B3 O4 f# [
- /**根据全局表更新合成清单*/
- ?4 w, y" g( ]8 L9 v - string tablename ="订单表";' J/ l$ S8 M l: O& i
- /*0 o3 \" K6 K* t, ^% E7 ]- n! V
- This option should only be used on Combiners.
# B. l2 }' h8 C A w8 }1 a; v - 这段代码只能用于合成器。4 k0 @5 S1 g. L+ o
- Each column in the GlobalTable is the component list for a single itemtype.
" b, v5 {, v8 ~' s8 ` - 全局表中的每一列是被合成临时实体的清单。
7 r) @7 I8 v7 y( D - The itemtype of the first flowitem to enter is used to find the correct column.
% Q5 e, y$ D# a( V; }/ N, | - 从第一个输入端口进入的临时实体的类型决定了在全局表中的哪一列去查询合成清单。. C) ~" P' h% z+ l, L; P
- It is assumed that the global table has a row for each input port number 2 and higher.- d0 G' Z4 C1 ?/ O* S3 v6 ~! m- l" g
- 全局表的每一行都代表着一个编号大于等于2的输入端口。
% f: d% K) v+ a( K - */
3 e8 F( ~' r# H' c Z9 }
6 C7 Q& e1 o. Q) a- if(port == 1)3 F5 }% Q# L, G, c8 P8 g
- { //The trigger on entry code fires each time a flow item enters the combiner.
. a( ^- U% Z0 x' I6 ~0 C8 d# S - //For this reason we check to make sure that the port entered is equal to 1
6 S: N4 U: s+ |, f; U' B - //because only the container will enter through port 1.3 m+ [7 }4 r% J/ C; _9 S8 C0 M/ I
- //每个临时实体进入合成器都会激活进入触发,所以必须要检查临时实体是否是从第一个端口进入的。0 q! o9 ]% c+ |9 K
- //只有从第一个端口进入的临时实体才是托盘等容器类临时实体。. B0 J6 I# C% o& I. D( f: T: ~
- //在上文已经解释过,第一个端口进入的临时实体的类型决定了采用全局表中的哪一列来设置合成清单。
' J) l1 r$ a2 l3 J - //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: ]; w0 e4 f& u - //合成清单以表格的形式存在。我们可以使用cell命令来获取数据节点。! |7 R: m4 y3 z' S& y6 i
- //the number of items to retrieve from each port. Once you know what node contains the information you can use the setnodenum
9 N/ H6 f2 q0 X5 } - //command to set the component list number based on the global table.
. Z4 v, j1 H W% [* Q. g( ^ - //当你知道数据存储于哪个节点之后,你就可以读取全局表中的数据,然后使用setnodenum命令在合成器中设置合成清单。
& _. |0 z4 z* X! {1 J - . W6 ^/ X' y% u5 z5 U+ W+ t$ e
- treenode thelist = getvarnode(current,"componentlist");
! _5 ^6 [& L6 L" N8 v5 L - treenode thesum = getvarnode(current,"targetcomponentsum");
) G) b9 e- c6 _2 ?# F; _ - //更改合成清单需要对两个数据节点进行设置。一个是componentlist,这个节点有一列数据,记录了从每个端口输入多少个临时实体。9 E4 Q$ Q" ]/ v5 V# t6 U; Y
- //另一个是targetcomponentsum,记录本次打包的临时实体的总数。# D* i0 W4 y% O2 }' D
- setnodenum(thesum,0);
- v& Q L! g) g. n9 t% J/ h
1 p0 o8 ~" ?! m- ?- for(int index=1; index<=nrows(thelist); index++)
) }6 i5 B4 E# ]4 ^+ q; n, K* w* \, b - //componentlist以表格的形式存在,只有一列。如果合成器有n个输入端口,那么就有n-1行。(第一个输入端口输入的是容器)- {% R! P# T/ u2 r7 J
- {
5 V7 z9 Y! X5 T7 j. f# K - setnodenum(cellrowcolumn(thelist,index,1),gettablenum(tablename,index,getitemtype(item)));9 x3 z7 G/ U( U3 D0 n8 c. R( P
- //第一输入端口进入的临时实体的类型,决定了使用全局表中的哪一列数据。8 s3 d: E+ L' ^4 o/ S a6 r
- //把该列数据全部读取出来,依次写入componentlist。. ]1 z4 q/ e- i" ~
- inc(thesum,gettablenum(tablename,index,getitemtype(item)));) v/ X0 O, [/ j4 k+ M
- //同时更新targetcomponentsum的值。
6 b: o+ p% ~* w3 @8 b - }7 d) G: ?# R. Q$ \
- }
复制代码 |
|