|
随手翻译了一下,不成体系。搞清楚合成器的第一个输入端口和其他输入端口的区别可能更容易看懂。
$ t5 ]( R1 R& W2 m, _. ?, j- /**根据全局表更新合成清单*/
* S, p% |! I, W6 H# d - string tablename ="订单表";
& w& |( }% @) Z8 K* h7 R. _5 X - /*
- f! y( s: I7 G" E u - This option should only be used on Combiners., D# e5 R* T7 P8 G# r; k
- 这段代码只能用于合成器。
; u: C( l: D8 v: l, j/ z - Each column in the GlobalTable is the component list for a single itemtype.
' [9 P5 N8 _, ?8 G$ K- \ - 全局表中的每一列是被合成临时实体的清单。
4 D7 p2 X! d4 r$ E' {3 | - The itemtype of the first flowitem to enter is used to find the correct column.% V( ?" y7 j7 f" h! g6 N( p
- 从第一个输入端口进入的临时实体的类型决定了在全局表中的哪一列去查询合成清单。
$ u, o* ?- B0 ^4 D( H: B - It is assumed that the global table has a row for each input port number 2 and higher.! V( y N( E5 T0 ~0 O. i Z
- 全局表的每一行都代表着一个编号大于等于2的输入端口。+ {" `$ H, A! S
- */. Q$ l* D w6 L3 x. [4 F8 ]
- 6 C& u4 O% p8 n
- if(port == 1)6 y. D4 D; q) t9 o
- { //The trigger on entry code fires each time a flow item enters the combiner.# v! ?6 p9 v2 k1 b$ B/ y7 {: ~
- //For this reason we check to make sure that the port entered is equal to 10 G+ X. i$ G4 y1 `+ b9 N+ f0 W
- //because only the container will enter through port 1.
# \& [) ^: F F5 u4 y - //每个临时实体进入合成器都会激活进入触发,所以必须要检查临时实体是否是从第一个端口进入的。# j" w) y; J6 D0 ?$ I
- //只有从第一个端口进入的临时实体才是托盘等容器类临时实体。
1 q! @6 ^2 i7 Q% S; O# y, ?& g, b - //在上文已经解释过,第一个端口进入的临时实体的类型决定了采用全局表中的哪一列来设置合成清单。) V" X; C. |: i" d( z' 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, {% u+ U5 ~: }3 [+ k
- //合成清单以表格的形式存在。我们可以使用cell命令来获取数据节点。
5 \1 b0 N- Q) t `) T2 ~5 q - //the number of items to retrieve from each port. Once you know what node contains the information you can use the setnodenum
# e6 _+ g, n+ T3 m: j( q7 d - //command to set the component list number based on the global table.2 Y: v U: _& V) d- u$ T
- //当你知道数据存储于哪个节点之后,你就可以读取全局表中的数据,然后使用setnodenum命令在合成器中设置合成清单。: ]* Y' N$ c- S; Y- ?; i' ~0 C8 C
# w! R0 `+ P1 z- treenode thelist = getvarnode(current,"componentlist");
5 B( _8 M8 B1 P( }. q! { - treenode thesum = getvarnode(current,"targetcomponentsum");5 S, \( F' ~+ j0 [9 k
- //更改合成清单需要对两个数据节点进行设置。一个是componentlist,这个节点有一列数据,记录了从每个端口输入多少个临时实体。6 Y, _) t- G4 o) a
- //另一个是targetcomponentsum,记录本次打包的临时实体的总数。
$ D$ g% ], j) ?7 l. g0 }5 ?/ p - setnodenum(thesum,0);' I$ c3 J/ k: Y: L" @* g
/ e' }( l( I. v# |( |. \: C" n% _- for(int index=1; index<=nrows(thelist); index++); { U: A. b( k0 b* a r' _
- //componentlist以表格的形式存在,只有一列。如果合成器有n个输入端口,那么就有n-1行。(第一个输入端口输入的是容器)
+ w: n) p, N2 r% @0 Y# T - {9 j3 T. }, F. e3 C& X z1 j
- setnodenum(cellrowcolumn(thelist,index,1),gettablenum(tablename,index,getitemtype(item)));
; J8 j/ U5 R+ S6 c - //第一输入端口进入的临时实体的类型,决定了使用全局表中的哪一列数据。
# U, J6 q3 Q j6 \ - //把该列数据全部读取出来,依次写入componentlist。3 a) A- q. x9 Q0 I. ~4 S) H2 }6 ~
- inc(thesum,gettablenum(tablename,index,getitemtype(item)));+ Z# }# g: s. K U. h5 `4 z
- //同时更新targetcomponentsum的值。1 N7 z: o/ V- R& A1 U$ _+ T( R
- }. ?) G2 z j& S
- }
复制代码 |
|