|
随手翻译了一下,不成体系。搞清楚合成器的第一个输入端口和其他输入端口的区别可能更容易看懂。
2 N# b3 w) N7 \+ \% M: P4 s3 Z- /**根据全局表更新合成清单*/6 R2 u% Q, P7 h0 I9 o+ t; f
- string tablename ="订单表";9 c1 B) [% F0 p" \) k+ D. G5 \ q. P
- /*
" g9 ]# }3 R& P. C - This option should only be used on Combiners.
6 D" Z9 j) U7 P1 O; @, Z - 这段代码只能用于合成器。
9 g( `3 O2 c& [! S7 _% t) m# V - Each column in the GlobalTable is the component list for a single itemtype.
2 t+ o# s; z: j - 全局表中的每一列是被合成临时实体的清单。5 S; q& n& |8 `8 ]$ F
- The itemtype of the first flowitem to enter is used to find the correct column.: x8 ^" z; j# J* C/ `' v# g
- 从第一个输入端口进入的临时实体的类型决定了在全局表中的哪一列去查询合成清单。- U4 u7 k4 o" T
- It is assumed that the global table has a row for each input port number 2 and higher./ L2 l% O5 N: Y/ W! I% K0 j
- 全局表的每一行都代表着一个编号大于等于2的输入端口。- C/ q* n4 o* e( c" ^2 n+ j
- */
$ C m5 K2 I% f% e0 v - , ? Z+ k C3 J9 o l1 a
- if(port == 1)8 i: B/ g' K0 ^4 g0 _( G
- { //The trigger on entry code fires each time a flow item enters the combiner.
3 I1 b6 O* M% D - //For this reason we check to make sure that the port entered is equal to 1
1 q; R3 u/ Q9 e8 ]& W" W - //because only the container will enter through port 1.! e9 n( I, A) x; d. L) O" g7 ~
- //每个临时实体进入合成器都会激活进入触发,所以必须要检查临时实体是否是从第一个端口进入的。% u+ a# G1 @( X0 U
- //只有从第一个端口进入的临时实体才是托盘等容器类临时实体。
8 F4 z+ X5 v7 S! C! b3 F - //在上文已经解释过,第一个端口进入的临时实体的类型决定了采用全局表中的哪一列来设置合成清单。. h+ M$ g& c; J! j: z: `
- //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
- N7 p- \' |* _/ [ i - //合成清单以表格的形式存在。我们可以使用cell命令来获取数据节点。" J# G$ j/ u' b* A
- //the number of items to retrieve from each port. Once you know what node contains the information you can use the setnodenum
5 x# ]( I- M J5 S3 _8 i - //command to set the component list number based on the global table.
6 ^: C8 l% q0 r - //当你知道数据存储于哪个节点之后,你就可以读取全局表中的数据,然后使用setnodenum命令在合成器中设置合成清单。
+ P5 ^8 @2 G+ @' @; M. c; c; V - ) b+ W* Y5 k( U4 g
- treenode thelist = getvarnode(current,"componentlist");9 u$ R% \3 M1 F- p9 G# f! K
- treenode thesum = getvarnode(current,"targetcomponentsum");3 l I5 b# i; d( H
- //更改合成清单需要对两个数据节点进行设置。一个是componentlist,这个节点有一列数据,记录了从每个端口输入多少个临时实体。
/ R# w' R1 ?( o9 @4 m; O4 ~ - //另一个是targetcomponentsum,记录本次打包的临时实体的总数。! T" u' U G& l' k* U% g: ~
- setnodenum(thesum,0);
4 Y, ^: q4 e& m1 D
/ q( r0 m" O: l- for(int index=1; index<=nrows(thelist); index++); r; P2 `$ V3 I
- //componentlist以表格的形式存在,只有一列。如果合成器有n个输入端口,那么就有n-1行。(第一个输入端口输入的是容器)9 |. x: K' o' y& _+ ~) A5 w
- {( `5 P: a% L6 S2 m
- setnodenum(cellrowcolumn(thelist,index,1),gettablenum(tablename,index,getitemtype(item)));
( f$ z! b# }/ G4 I3 c4 g - //第一输入端口进入的临时实体的类型,决定了使用全局表中的哪一列数据。: j2 m, f6 S' w) c
- //把该列数据全部读取出来,依次写入componentlist。' P% r8 L2 }2 u$ V& i6 c: R9 h
- inc(thesum,gettablenum(tablename,index,getitemtype(item)));
1 z- P* v& n3 p/ P; v% y, m9 _ - //同时更新targetcomponentsum的值。
6 i* \; t- X x2 E! A% w- Y - }
: ~7 r& P' I2 P. ~! V9 d - }
复制代码 |
|