|
随手翻译了一下,不成体系。搞清楚合成器的第一个输入端口和其他输入端口的区别可能更容易看懂。
2 g p5 f8 p8 e% E8 c5 Q- /**根据全局表更新合成清单*/
7 H/ }" E# P& I1 @ - string tablename ="订单表";% [3 X6 v# a& @7 f6 Q
- /*" D( N: j6 h6 m' p( f1 K
- This option should only be used on Combiners.; {4 o0 K/ J' J. a# m- z
- 这段代码只能用于合成器。
' A) I m9 D9 C$ o; y5 K4 E4 M - Each column in the GlobalTable is the component list for a single itemtype.! r" |& `$ y# a5 v8 l: d9 K# \
- 全局表中的每一列是被合成临时实体的清单。" J; B4 c6 m- @* v# \3 ]! m* |9 o
- The itemtype of the first flowitem to enter is used to find the correct column.( ~/ O. \# d+ m4 E" S/ Y
- 从第一个输入端口进入的临时实体的类型决定了在全局表中的哪一列去查询合成清单。
* V% N7 T9 q1 h% H - It is assumed that the global table has a row for each input port number 2 and higher.: g/ i1 D0 o$ t) K4 k% V
- 全局表的每一行都代表着一个编号大于等于2的输入端口。
9 {. }1 e' d* }9 Y$ i$ l! g% W - */
! E+ g7 w+ F( a( Y
0 I L% e) i. s, q3 j( t5 O( c- if(port == 1)
5 e- r3 R3 R9 z$ U, K' } - { //The trigger on entry code fires each time a flow item enters the combiner.
8 X) R- `* @; N$ S$ j - //For this reason we check to make sure that the port entered is equal to 16 P3 K' j+ Z% m: X
- //because only the container will enter through port 1.8 D; {; U* P4 b" L* C. S
- //每个临时实体进入合成器都会激活进入触发,所以必须要检查临时实体是否是从第一个端口进入的。
6 E4 w B! q; {# R+ @& Q* r - //只有从第一个端口进入的临时实体才是托盘等容器类临时实体。! \; A9 H; ^6 N' ?. d7 w5 I6 ?( U
- //在上文已经解释过,第一个端口进入的临时实体的类型决定了采用全局表中的哪一列来设置合成清单。
+ Z% q7 _ f) H - //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
0 ~+ U1 R; C+ v. p! e - //合成清单以表格的形式存在。我们可以使用cell命令来获取数据节点。
- E6 c1 @; P7 _, p- j6 c - //the number of items to retrieve from each port. Once you know what node contains the information you can use the setnodenum) `$ e, d; T* M5 o
- //command to set the component list number based on the global table.3 I3 }" u9 p; y$ ^5 U3 v
- //当你知道数据存储于哪个节点之后,你就可以读取全局表中的数据,然后使用setnodenum命令在合成器中设置合成清单。4 {) v; c' _1 J" w! v
$ \% E5 M6 M* N& G- treenode thelist = getvarnode(current,"componentlist");
5 O+ {" T0 h: I2 j - treenode thesum = getvarnode(current,"targetcomponentsum");
3 B0 f5 Q5 \9 M' H2 o, F - //更改合成清单需要对两个数据节点进行设置。一个是componentlist,这个节点有一列数据,记录了从每个端口输入多少个临时实体。
; g: A# j# Y% f9 |) a+ p5 j - //另一个是targetcomponentsum,记录本次打包的临时实体的总数。3 o/ U) E9 G3 e6 K
- setnodenum(thesum,0);
! r! [9 u% r# ^/ _! j
1 [9 y P4 c b5 W+ ^ x! A+ o- for(int index=1; index<=nrows(thelist); index++)# w4 A- ^& U( F
- //componentlist以表格的形式存在,只有一列。如果合成器有n个输入端口,那么就有n-1行。(第一个输入端口输入的是容器)
# ?& i3 F0 l7 q- ~- z6 j - {6 P$ o- E8 ^! h; \$ {0 t
- setnodenum(cellrowcolumn(thelist,index,1),gettablenum(tablename,index,getitemtype(item)));
, N) B, H6 M# l' B0 P3 P: E - //第一输入端口进入的临时实体的类型,决定了使用全局表中的哪一列数据。1 e$ A3 ~ b! Q! c. c
- //把该列数据全部读取出来,依次写入componentlist。
6 Z! g: h0 }6 N7 K/ ? - inc(thesum,gettablenum(tablename,index,getitemtype(item)));
) ~$ _9 K* x7 z. T3 P9 J - //同时更新targetcomponentsum的值。( K0 x9 u5 ^% d* o
- }
' T/ [! S) {" C3 ^/ @$ @ - }
复制代码 |
|