|
随手翻译了一下,不成体系。搞清楚合成器的第一个输入端口和其他输入端口的区别可能更容易看懂。
& v% N+ |% z5 d" e/ A- /**根据全局表更新合成清单*/$ C3 I( t' R! T& l6 E) w
- string tablename ="订单表";5 v. A% I) k+ o+ ~+ {2 s# b
- /*" w8 v$ H% t h" E: _/ G/ {
- This option should only be used on Combiners.' ^2 _: t7 }% `$ h
- 这段代码只能用于合成器。! o# T/ t# m% i2 ]
- Each column in the GlobalTable is the component list for a single itemtype.+ F/ F, h( X) E* y2 G4 Z
- 全局表中的每一列是被合成临时实体的清单。
6 r$ [% h2 @: m( Q - The itemtype of the first flowitem to enter is used to find the correct column.& W- z% a# K! }" A- Y
- 从第一个输入端口进入的临时实体的类型决定了在全局表中的哪一列去查询合成清单。
9 e+ o/ H) {8 C - It is assumed that the global table has a row for each input port number 2 and higher./ R2 _, L }* w+ p( S: Y' C2 P, p
- 全局表的每一行都代表着一个编号大于等于2的输入端口。7 N c- H5 L, P* ~, e# |. P
- *// e4 ]$ t# `$ W' O
- 8 B# _# O! R+ k( e3 l
- if(port == 1)
0 Q+ q8 \% ^6 I, f5 C, o% i+ l# m - { //The trigger on entry code fires each time a flow item enters the combiner.
+ N0 s% Z5 o* H' r2 d; G - //For this reason we check to make sure that the port entered is equal to 1
. r# g! d) c! {5 m - //because only the container will enter through port 1.
4 q, I7 O, ]( j L9 ~ - //每个临时实体进入合成器都会激活进入触发,所以必须要检查临时实体是否是从第一个端口进入的。
" d/ q2 K9 @2 S5 Y - //只有从第一个端口进入的临时实体才是托盘等容器类临时实体。
3 P j* W) Y) c. E# s# h - //在上文已经解释过,第一个端口进入的临时实体的类型决定了采用全局表中的哪一列来设置合成清单。0 t+ Z5 V( K/ [0 q1 ~0 S5 x- 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. P* z( U+ \+ X5 A+ Q8 u) F% c* U$ m1 L
- //合成清单以表格的形式存在。我们可以使用cell命令来获取数据节点。
& U% l& z5 d4 T$ E- ], x - //the number of items to retrieve from each port. Once you know what node contains the information you can use the setnodenum! q; P" x4 q+ D. j
- //command to set the component list number based on the global table.* G6 |1 }) x" C( _
- //当你知道数据存储于哪个节点之后,你就可以读取全局表中的数据,然后使用setnodenum命令在合成器中设置合成清单。
# m/ g5 g# @0 G; w - ; K, Q& p4 W# P: }% C! O* ]; V4 [
- treenode thelist = getvarnode(current,"componentlist");/ H9 _0 Q$ M+ `( [+ |1 ]( F
- treenode thesum = getvarnode(current,"targetcomponentsum");
9 o2 [) `, Y3 i - //更改合成清单需要对两个数据节点进行设置。一个是componentlist,这个节点有一列数据,记录了从每个端口输入多少个临时实体。+ {7 R* I# }4 S0 {" u C
- //另一个是targetcomponentsum,记录本次打包的临时实体的总数。
! y: g- n+ F$ @) {7 `4 O - setnodenum(thesum,0);
: Q7 ~* G# C7 r0 l C8 K2 S6 I
8 |% Q& Z* A* V9 ]# O. w5 Z- for(int index=1; index<=nrows(thelist); index++)
8 `) |" |; J) ? - //componentlist以表格的形式存在,只有一列。如果合成器有n个输入端口,那么就有n-1行。(第一个输入端口输入的是容器)
4 j2 T$ E0 w1 x8 ~ - {
) `) k1 Q( G w" `* ~+ c" c% a& L - setnodenum(cellrowcolumn(thelist,index,1),gettablenum(tablename,index,getitemtype(item)));* _: {9 i8 a/ q
- //第一输入端口进入的临时实体的类型,决定了使用全局表中的哪一列数据。
X; ^% F% D0 U* k1 k9 c - //把该列数据全部读取出来,依次写入componentlist。
: @* M- w3 Q; f* P# _, W8 M; f2 e - inc(thesum,gettablenum(tablename,index,getitemtype(item)));
6 C1 Y) G2 K" `* Q/ Z# w4 F6 E - //同时更新targetcomponentsum的值。
% O$ v& f7 X3 z' ^ - }
- Y0 r/ L/ r. y" a" B4 L7 |6 {; A - }
复制代码 |
|