|
随手翻译了一下,不成体系。搞清楚合成器的第一个输入端口和其他输入端口的区别可能更容易看懂。
l! x0 {3 k, ?$ p5 t- /**根据全局表更新合成清单*/. s+ j! E/ x4 c. v) a
- string tablename ="订单表";; n/ [0 t4 C. c& x" H# T9 v2 h
- /*# K! l! G8 X E3 U. S
- This option should only be used on Combiners./ n3 v R# M1 G! S, k: T
- 这段代码只能用于合成器。8 z }8 |9 l; a% y0 h; K- D: J
- Each column in the GlobalTable is the component list for a single itemtype.* d* S( l$ e" k/ N! }8 y
- 全局表中的每一列是被合成临时实体的清单。0 Q- c1 L# u% |4 J$ _
- The itemtype of the first flowitem to enter is used to find the correct column.
7 O) p+ i0 V( f2 c) H - 从第一个输入端口进入的临时实体的类型决定了在全局表中的哪一列去查询合成清单。+ L) V& a( R$ Q) \$ H" G
- It is assumed that the global table has a row for each input port number 2 and higher., _5 `* J5 \# y' D
- 全局表的每一行都代表着一个编号大于等于2的输入端口。
% Y/ U M9 F2 d n% U$ ^1 {$ A. s - */
% d" L0 A7 ], d/ q% n# C - * O$ u7 Y- J7 Z. U+ j
- if(port == 1)2 M# P- ^' J5 m |
- { //The trigger on entry code fires each time a flow item enters the combiner.- A+ g2 }: Y4 D5 @9 {; A. q9 J1 V% R
- //For this reason we check to make sure that the port entered is equal to 1
) h& e* p3 T3 ?6 p* Z2 Y1 R - //because only the container will enter through port 1.
/ g, X b6 |$ O - //每个临时实体进入合成器都会激活进入触发,所以必须要检查临时实体是否是从第一个端口进入的。2 T: @" v" U1 _/ A6 @ U n; K
- //只有从第一个端口进入的临时实体才是托盘等容器类临时实体。+ C Z! H& d$ |* @
- //在上文已经解释过,第一个端口进入的临时实体的类型决定了采用全局表中的哪一列来设置合成清单。
! p7 a+ x- y& J# y9 |# ? - //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
; U8 E! b4 }$ |2 m9 N$ S - //合成清单以表格的形式存在。我们可以使用cell命令来获取数据节点。$ M) b0 z$ ~$ }$ r" a/ X* h3 a
- //the number of items to retrieve from each port. Once you know what node contains the information you can use the setnodenum
+ L. i8 v+ W% E1 C3 N6 e" d - //command to set the component list number based on the global table.
3 \: F$ Y3 s$ ~9 d: ?: l3 y - //当你知道数据存储于哪个节点之后,你就可以读取全局表中的数据,然后使用setnodenum命令在合成器中设置合成清单。- E; C- G T! t
$ B; c* V5 I J( f* I4 z w- treenode thelist = getvarnode(current,"componentlist");) N3 s9 c J- M( D ^0 l0 R7 J
- treenode thesum = getvarnode(current,"targetcomponentsum");' U2 Q. `" @6 w0 |( h, V
- //更改合成清单需要对两个数据节点进行设置。一个是componentlist,这个节点有一列数据,记录了从每个端口输入多少个临时实体。" a6 X% o4 {$ s$ {/ f G$ r/ [- S, x( g
- //另一个是targetcomponentsum,记录本次打包的临时实体的总数。 }+ g5 f# O& R4 |9 w1 R& d. x
- setnodenum(thesum,0);% Y8 a: R( x/ \" Q3 i
- + s0 w2 i+ f" P0 M& ?
- for(int index=1; index<=nrows(thelist); index++)/ _+ Y1 J0 A0 |, J) y! o! R
- //componentlist以表格的形式存在,只有一列。如果合成器有n个输入端口,那么就有n-1行。(第一个输入端口输入的是容器)# _- H; m8 i' l) h+ `
- {' W3 u s& {& J& }; \$ ~( u
- setnodenum(cellrowcolumn(thelist,index,1),gettablenum(tablename,index,getitemtype(item)));0 L3 x2 Q f' p) ]5 L3 u4 F
- //第一输入端口进入的临时实体的类型,决定了使用全局表中的哪一列数据。
7 q# I4 C" e) T% T! B4 Y - //把该列数据全部读取出来,依次写入componentlist。- B/ C3 x8 O- [% n) v4 W
- inc(thesum,gettablenum(tablename,index,getitemtype(item)));
$ P6 W& T8 ~) D7 I - //同时更新targetcomponentsum的值。+ c; s0 ]% d3 x2 m2 h% ~' n
- }- L8 ]' O( f) X5 }/ F
- }
复制代码 |
|