|
随手翻译了一下,不成体系。搞清楚合成器的第一个输入端口和其他输入端口的区别可能更容易看懂。( ^' X& r2 R% h- j) z% u. H* g3 g w
- /**根据全局表更新合成清单*/% C: H5 Y& u: X& y* \/ I
- string tablename ="订单表";
8 m- g; Y6 `! @& P4 [ - /*
2 d9 S0 k. \. i6 X* @ - This option should only be used on Combiners." q( k* I% q, ]1 H& z3 m
- 这段代码只能用于合成器。
" Q" ~/ U9 M; k( N s( |" d" @ - Each column in the GlobalTable is the component list for a single itemtype.! Z' L6 t: b/ }5 v G( p
- 全局表中的每一列是被合成临时实体的清单。
6 h$ ^ w, G X# y W/ G - The itemtype of the first flowitem to enter is used to find the correct column.2 D- G8 {* P) u
- 从第一个输入端口进入的临时实体的类型决定了在全局表中的哪一列去查询合成清单。, I: f1 d; C2 _' q" l2 ]0 o- ]' P
- It is assumed that the global table has a row for each input port number 2 and higher.; m2 b) A0 j7 ^2 ?" _" ^
- 全局表的每一行都代表着一个编号大于等于2的输入端口。
4 p% N' b1 x$ e1 R - */
! K8 Q' B6 c: ]7 o" [
+ Q+ N( f4 v$ g1 o7 Z( k- z- if(port == 1)
! U; F8 h& m( ` - { //The trigger on entry code fires each time a flow item enters the combiner.
$ b' Q1 B& n# g3 y# Y0 ]; a0 @6 b) v - //For this reason we check to make sure that the port entered is equal to 17 J7 ^! y% ]$ T! k' c, h1 q; h* x
- //because only the container will enter through port 1.* D# O, _; Q9 M+ O$ R9 J7 P0 P
- //每个临时实体进入合成器都会激活进入触发,所以必须要检查临时实体是否是从第一个端口进入的。" W+ z# y. Y8 B8 X$ @1 i' x
- //只有从第一个端口进入的临时实体才是托盘等容器类临时实体。0 z9 ?' m, U$ Z" ]! T
- //在上文已经解释过,第一个端口进入的临时实体的类型决定了采用全局表中的哪一列来设置合成清单。4 `) Z" @% S1 p2 G! _
- //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
( K* c2 t! ]: k - //合成清单以表格的形式存在。我们可以使用cell命令来获取数据节点。
0 ?- \, _& m& m, g8 j5 V n! u - //the number of items to retrieve from each port. Once you know what node contains the information you can use the setnodenum
u4 f0 H0 R5 B( Y - //command to set the component list number based on the global table.4 q+ }1 I. Y. T7 W% J
- //当你知道数据存储于哪个节点之后,你就可以读取全局表中的数据,然后使用setnodenum命令在合成器中设置合成清单。" j! V: ^9 L/ ]
- 4 W. I, L e. G/ j
- treenode thelist = getvarnode(current,"componentlist");7 U$ _( j2 q9 g$ r: O
- treenode thesum = getvarnode(current,"targetcomponentsum");% A% \% q% V* X Y# {" B, b
- //更改合成清单需要对两个数据节点进行设置。一个是componentlist,这个节点有一列数据,记录了从每个端口输入多少个临时实体。
" u- }0 s' v( f - //另一个是targetcomponentsum,记录本次打包的临时实体的总数。) r. c3 b. D! I
- setnodenum(thesum,0);
( Z) V1 t: `8 G: P) M3 \; [" b5 r
6 M S" ^2 ^5 P) O8 e( f5 |- for(int index=1; index<=nrows(thelist); index++)
# y' j% q( `7 N( t - //componentlist以表格的形式存在,只有一列。如果合成器有n个输入端口,那么就有n-1行。(第一个输入端口输入的是容器)
5 j- o8 V9 C. h* c( _) l; G - {' ^! S! r) o# B6 q% r+ s9 _
- setnodenum(cellrowcolumn(thelist,index,1),gettablenum(tablename,index,getitemtype(item)));
. D! i2 ]- q) d$ r3 g' T+ P2 W3 ] - //第一输入端口进入的临时实体的类型,决定了使用全局表中的哪一列数据。
8 {* T; C; t" Z p1 t A* x( v - //把该列数据全部读取出来,依次写入componentlist。* {5 l2 u/ V0 \; P7 D
- inc(thesum,gettablenum(tablename,index,getitemtype(item)));
6 j) B- T3 @5 T, x+ i* G1 k - //同时更新targetcomponentsum的值。
3 m o; d! C9 E8 ?# p - }. R; `1 \" J& r% Y2 @% V
- }
复制代码 |
|