|
随手翻译了一下,不成体系。搞清楚合成器的第一个输入端口和其他输入端口的区别可能更容易看懂。
) X% B( m( `/ e. M- /**根据全局表更新合成清单*/
: ]/ B9 `7 H: ^* y0 b - string tablename ="订单表";
- p! m: z) {& Y" N - /*
8 v3 k! y# j+ d. l - This option should only be used on Combiners.
% L/ s Q% J# ?; \ z1 R: b5 m% { - 这段代码只能用于合成器。& ?9 y, H2 h* ]4 x
- Each column in the GlobalTable is the component list for a single itemtype.
' M! c7 T* U% a2 j& c2 _, h$ L - 全局表中的每一列是被合成临时实体的清单。. F' P. j" m4 }: G. w3 @1 s' C
- The itemtype of the first flowitem to enter is used to find the correct column., Z7 Q6 }8 w6 c1 S7 r( q
- 从第一个输入端口进入的临时实体的类型决定了在全局表中的哪一列去查询合成清单。2 m, j# s6 G+ _( `: c7 v
- It is assumed that the global table has a row for each input port number 2 and higher.
, ~9 h) G% }+ ~4 V - 全局表的每一行都代表着一个编号大于等于2的输入端口。
0 v3 Z% L8 \6 f& L% h$ R - */
( z t, C0 ]# e+ W2 I" V
. M% l7 C. Z" N' r- Z3 c$ ]- if(port == 1)
; U. a. i2 x: V! i4 N - { //The trigger on entry code fires each time a flow item enters the combiner.( P5 h0 W# M8 J' z6 V" l
- //For this reason we check to make sure that the port entered is equal to 10 L0 U P( r9 P1 F% S
- //because only the container will enter through port 1.
3 K5 R: C* H5 w- k, o: a( g0 x( U! B - //每个临时实体进入合成器都会激活进入触发,所以必须要检查临时实体是否是从第一个端口进入的。6 ?& _$ L9 U# j1 e
- //只有从第一个端口进入的临时实体才是托盘等容器类临时实体。
0 F. _: [2 k$ H9 M - //在上文已经解释过,第一个端口进入的临时实体的类型决定了采用全局表中的哪一列来设置合成清单。 S% l! C) r( [( w2 v8 Y
- //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
7 b" M- @4 \$ ]: N% R6 Z - //合成清单以表格的形式存在。我们可以使用cell命令来获取数据节点。7 J! {" X& o: x) b: h6 b6 i* l
- //the number of items to retrieve from each port. Once you know what node contains the information you can use the setnodenum, u: |$ u% g! B+ ]3 w; ^4 J8 |5 o
- //command to set the component list number based on the global table.
. Z" Q0 c! F: e5 j - //当你知道数据存储于哪个节点之后,你就可以读取全局表中的数据,然后使用setnodenum命令在合成器中设置合成清单。
7 o P, _4 }) v2 E1 J0 x - ; m; x! H3 N, d" y0 C2 C6 \
- treenode thelist = getvarnode(current,"componentlist");2 D8 ]* ?! S9 ]! M
- treenode thesum = getvarnode(current,"targetcomponentsum");9 k9 N) Q/ \; z% J# |0 u
- //更改合成清单需要对两个数据节点进行设置。一个是componentlist,这个节点有一列数据,记录了从每个端口输入多少个临时实体。" w- N6 u a1 _& h$ g
- //另一个是targetcomponentsum,记录本次打包的临时实体的总数。( [% {0 a3 h! s/ j
- setnodenum(thesum,0);8 ?: ^# @: e0 c4 l
- 5 s& F! m* m1 ^
- for(int index=1; index<=nrows(thelist); index++)7 f4 A) K1 Q# l% W) n% e! U
- //componentlist以表格的形式存在,只有一列。如果合成器有n个输入端口,那么就有n-1行。(第一个输入端口输入的是容器)
/ U. x- E1 q1 y1 ^ - {8 L: p$ V) O! J) C
- setnodenum(cellrowcolumn(thelist,index,1),gettablenum(tablename,index,getitemtype(item)));) g2 K$ e+ M. }- M
- //第一输入端口进入的临时实体的类型,决定了使用全局表中的哪一列数据。1 O3 x2 f0 r$ T+ {* _- W
- //把该列数据全部读取出来,依次写入componentlist。
2 u" t' g$ S3 c& {( d! u! q - inc(thesum,gettablenum(tablename,index,getitemtype(item)));' A0 C- b* n+ ]8 U' l) v2 j
- //同时更新targetcomponentsum的值。
( j p2 a1 }1 T6 Z8 S1 N - }/ g# _' [; [/ [; }8 u2 I% W/ K
- }
复制代码 |
|