|
随手翻译了一下,不成体系。搞清楚合成器的第一个输入端口和其他输入端口的区别可能更容易看懂。
* Y& R# j. ]$ ?6 _7 b- /**根据全局表更新合成清单*/$ @* D+ {: R* }& G' b& ?$ z) h
- string tablename ="订单表";3 b6 @0 l0 g2 ^/ L+ K9 I
- /*
0 }6 L! ?& z& i4 _, p( d4 U8 I - This option should only be used on Combiners.
. h5 l1 u- ~$ K, y) @0 G2 w0 a; K - 这段代码只能用于合成器。
2 E+ u: }' l. o* s, N( T- G6 y1 P - Each column in the GlobalTable is the component list for a single itemtype.
4 Q+ ]9 m; b% R5 a# h" x! `/ `$ i$ D - 全局表中的每一列是被合成临时实体的清单。
5 z' Y5 Q+ d0 R* A) d- l; b - The itemtype of the first flowitem to enter is used to find the correct column.
~: a9 q% F* Q+ T8 G3 t, F - 从第一个输入端口进入的临时实体的类型决定了在全局表中的哪一列去查询合成清单。8 M/ Z# N6 ]6 K! |9 m
- It is assumed that the global table has a row for each input port number 2 and higher.% _( F9 d5 M( J( e& q1 V# f
- 全局表的每一行都代表着一个编号大于等于2的输入端口。
$ K" P4 s( o( R, s1 n - */
( N' [" b, \4 B. H' ^' @- w2 L% V
5 x0 d2 p5 G3 V' t7 [/ r- w- if(port == 1) E! q) n- a; D o. \( t
- { //The trigger on entry code fires each time a flow item enters the combiner." W8 {# U! e' N1 p
- //For this reason we check to make sure that the port entered is equal to 1
x5 q$ k" T6 Z- Z - //because only the container will enter through port 1.# r m! O8 {3 ?' X1 H% y
- //每个临时实体进入合成器都会激活进入触发,所以必须要检查临时实体是否是从第一个端口进入的。' I, u8 i8 h, V# z! q2 [
- //只有从第一个端口进入的临时实体才是托盘等容器类临时实体。
& h& u3 u# n5 K$ r% J- a - //在上文已经解释过,第一个端口进入的临时实体的类型决定了采用全局表中的哪一列来设置合成清单。( L: |3 |* f7 @4 D& h) j/ K( Q
- //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) |( C: ]: D: F9 p
- //合成清单以表格的形式存在。我们可以使用cell命令来获取数据节点。
5 D3 @: x8 c: r9 ^ - //the number of items to retrieve from each port. Once you know what node contains the information you can use the setnodenum
6 E& r! _$ N! @1 ?1 }$ ` - //command to set the component list number based on the global table.2 s" D3 A4 l, B* p
- //当你知道数据存储于哪个节点之后,你就可以读取全局表中的数据,然后使用setnodenum命令在合成器中设置合成清单。0 O j0 ~" r$ L* r3 V. @1 {% L
- . b* p8 \& b* W6 i! @
- treenode thelist = getvarnode(current,"componentlist");, M6 q1 u3 h9 C7 ]/ ?% U( e+ q
- treenode thesum = getvarnode(current,"targetcomponentsum");; [9 E& x8 R# `+ i2 n
- //更改合成清单需要对两个数据节点进行设置。一个是componentlist,这个节点有一列数据,记录了从每个端口输入多少个临时实体。
" v7 h# b4 W. ^% i. e8 u - //另一个是targetcomponentsum,记录本次打包的临时实体的总数。
- p/ Q( k3 [& y) m - setnodenum(thesum,0);+ @8 [& S9 z4 _# r: X Z
- 0 \3 D6 f6 ?2 X+ m0 A' H0 ~
- for(int index=1; index<=nrows(thelist); index++)4 T$ Z7 x# F' ~0 K( U
- //componentlist以表格的形式存在,只有一列。如果合成器有n个输入端口,那么就有n-1行。(第一个输入端口输入的是容器)
& U, `5 h4 s5 ]' T: S {- W1 j( L - {
4 t3 [* Z. m! T4 L - setnodenum(cellrowcolumn(thelist,index,1),gettablenum(tablename,index,getitemtype(item)));
7 t) d. {1 B. C- `* h5 k - //第一输入端口进入的临时实体的类型,决定了使用全局表中的哪一列数据。& x% U1 ^9 V/ w2 z: e
- //把该列数据全部读取出来,依次写入componentlist。
) r# ^2 Q* I2 C& j0 Q& ] - inc(thesum,gettablenum(tablename,index,getitemtype(item)));, b5 w& }2 G" b, P* e# n$ D8 O: @
- //同时更新targetcomponentsum的值。& S2 M1 P+ {3 m& `0 }0 h2 A6 e
- }
& l0 A* r( Q' V h4 `9 h) L - }
复制代码 |
|