|
随手翻译了一下,不成体系。搞清楚合成器的第一个输入端口和其他输入端口的区别可能更容易看懂。! r* S% n! S8 g7 Q
- /**根据全局表更新合成清单*/+ u- H# ~; u' Q& [5 E2 P& E7 Z6 U8 j$ R
- string tablename ="订单表";
& e! M A' Y" J. y3 k - /*
2 i0 o) ]/ i+ \1 h0 t - This option should only be used on Combiners.7 ]" V7 U$ h1 o% V; K( i9 _/ i
- 这段代码只能用于合成器。- ?( A0 U2 z* e! g' a# `8 W
- Each column in the GlobalTable is the component list for a single itemtype.5 A+ Y. J$ I5 L' p$ V
- 全局表中的每一列是被合成临时实体的清单。
0 ~9 P: F- u# ?+ _* M. L - The itemtype of the first flowitem to enter is used to find the correct column." Q1 `) i. J3 c# Z8 W, J% a
- 从第一个输入端口进入的临时实体的类型决定了在全局表中的哪一列去查询合成清单。1 o5 u6 i* k% Y$ l
- It is assumed that the global table has a row for each input port number 2 and higher.7 c4 E, |; |. Z, |9 @7 J( P4 y
- 全局表的每一行都代表着一个编号大于等于2的输入端口。0 A" C" j! P! ]
- */
( l( F: h- K; Y' u( j. g6 `
+ v; Y( X3 A. i" b/ w! ]- if(port == 1). `1 W% z* |3 b: T! x
- { //The trigger on entry code fires each time a flow item enters the combiner.5 G' @" j, n2 N- ` f
- //For this reason we check to make sure that the port entered is equal to 1
+ m' G; x' y: Y; @0 O S) x n - //because only the container will enter through port 1.0 h9 C/ a1 u' L y4 H
- //每个临时实体进入合成器都会激活进入触发,所以必须要检查临时实体是否是从第一个端口进入的。* {9 O$ i& n7 R' v9 g
- //只有从第一个端口进入的临时实体才是托盘等容器类临时实体。
" b/ @! _- [& _, q# r* m7 @ - //在上文已经解释过,第一个端口进入的临时实体的类型决定了采用全局表中的哪一列来设置合成清单。$ t- j8 I7 h# m) B" B
- //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
2 _3 J r% h3 Y" ~ - //合成清单以表格的形式存在。我们可以使用cell命令来获取数据节点。& }# l8 a1 n. C, S: Q8 a
- //the number of items to retrieve from each port. Once you know what node contains the information you can use the setnodenum
) E9 a. c2 |% k3 {4 i1 S% C& V - //command to set the component list number based on the global table.. F1 |8 ~8 ]4 a$ R/ y! `8 |1 ?
- //当你知道数据存储于哪个节点之后,你就可以读取全局表中的数据,然后使用setnodenum命令在合成器中设置合成清单。
. S0 `. W- h5 k
% |' r' G' W6 q- treenode thelist = getvarnode(current,"componentlist");
! A$ Y$ E# ^& h1 F - treenode thesum = getvarnode(current,"targetcomponentsum");
, W5 P+ c# R" K! s$ f - //更改合成清单需要对两个数据节点进行设置。一个是componentlist,这个节点有一列数据,记录了从每个端口输入多少个临时实体。0 P7 Q5 m" S- `! r1 n
- //另一个是targetcomponentsum,记录本次打包的临时实体的总数。 R0 p/ I$ y" S! A. n
- setnodenum(thesum,0);3 @/ g9 @) V( I8 a) @1 z
- / K0 w& o7 Z4 O" B: o3 J* v) N
- for(int index=1; index<=nrows(thelist); index++)
, `. H- I$ C( S! S$ G - //componentlist以表格的形式存在,只有一列。如果合成器有n个输入端口,那么就有n-1行。(第一个输入端口输入的是容器)
6 g% [( p2 n+ |( s2 L: j' a( \. } - {
* R( [. S& y( C/ [ p! C6 [ - setnodenum(cellrowcolumn(thelist,index,1),gettablenum(tablename,index,getitemtype(item)));
) n: h9 ^; F) |3 n" K6 ^ - //第一输入端口进入的临时实体的类型,决定了使用全局表中的哪一列数据。
$ w4 s! @, R `: n( w) M - //把该列数据全部读取出来,依次写入componentlist。
' ]) U) Q1 h4 i- P7 D y - inc(thesum,gettablenum(tablename,index,getitemtype(item)));9 r4 c! d: d$ D- P5 H" E
- //同时更新targetcomponentsum的值。& c+ @9 }3 h5 q# z
- }/ Q6 p) t# E! H) R* p# c, \3 t2 v) j
- }
复制代码 |
|