|
随手翻译了一下,不成体系。搞清楚合成器的第一个输入端口和其他输入端口的区别可能更容易看懂。
* ]( E% t" B3 X5 w5 O+ Y0 z- /**根据全局表更新合成清单*// H7 s6 r! z) A& S
- string tablename ="订单表";
4 r" F x% v' j$ h: O# M% v. r2 N' e1 [ - /*
$ f: X7 \2 G: p - This option should only be used on Combiners./ O8 x7 J) }5 K* L* n7 C
- 这段代码只能用于合成器。2 y# M9 Q9 F- y& t2 R2 ]
- Each column in the GlobalTable is the component list for a single itemtype.
5 W- A# `6 s" z- V% Y - 全局表中的每一列是被合成临时实体的清单。
4 }2 r$ {0 d% y6 U4 O- t2 H - The itemtype of the first flowitem to enter is used to find the correct column.
: R; K q; E% p1 M) @ - 从第一个输入端口进入的临时实体的类型决定了在全局表中的哪一列去查询合成清单。8 R- t9 D: K n+ i/ L
- It is assumed that the global table has a row for each input port number 2 and higher.
& M9 D. [9 m: o P) I" q% k! c& W - 全局表的每一行都代表着一个编号大于等于2的输入端口。
* s: {& d0 A% n$ B: v, L6 M8 O+ l7 T - */
( i/ W4 r- ^* y" J - ; F. @! }& X* s! G' C1 q2 L
- if(port == 1)) J0 f& f ?" ~% V V# P4 F
- { //The trigger on entry code fires each time a flow item enters the combiner.
: R2 ^3 s: R' T& I0 I; P - //For this reason we check to make sure that the port entered is equal to 1/ o8 x9 c2 L/ I; Z5 ?; o- z
- //because only the container will enter through port 1.* R4 n' W2 b5 y0 C
- //每个临时实体进入合成器都会激活进入触发,所以必须要检查临时实体是否是从第一个端口进入的。7 Y6 |8 f9 y" y4 K+ W( }
- //只有从第一个端口进入的临时实体才是托盘等容器类临时实体。
7 M3 v% Y1 O- ]9 }& O - //在上文已经解释过,第一个端口进入的临时实体的类型决定了采用全局表中的哪一列来设置合成清单。; F) U' P! I/ J) u. ?0 n& L
- //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
; r( L& H( I1 X! { - //合成清单以表格的形式存在。我们可以使用cell命令来获取数据节点。
2 B- c, Z r0 y/ V2 N- ` - //the number of items to retrieve from each port. Once you know what node contains the information you can use the setnodenum
" G6 r% z: m. W6 a, \ D6 l0 Y3 @ - //command to set the component list number based on the global table.; w% f5 T! Z& V* u! H E+ O
- //当你知道数据存储于哪个节点之后,你就可以读取全局表中的数据,然后使用setnodenum命令在合成器中设置合成清单。" f/ }) k% h9 t h% e
- + D4 }- b! r; e2 a
- treenode thelist = getvarnode(current,"componentlist"); s# U( e6 _9 d( y3 j- L1 O) `% B9 C
- treenode thesum = getvarnode(current,"targetcomponentsum");
5 x1 g; n3 r0 m - //更改合成清单需要对两个数据节点进行设置。一个是componentlist,这个节点有一列数据,记录了从每个端口输入多少个临时实体。
) H. Z0 g7 [( i2 H - //另一个是targetcomponentsum,记录本次打包的临时实体的总数。
' J9 e. v9 \! {- d7 |$ P# ? - setnodenum(thesum,0);
; }% C4 ~2 W# i9 O1 `* b
! s1 V5 n1 U& r6 v' v) S( S# E- A7 ^- for(int index=1; index<=nrows(thelist); index++)8 `2 H% v; k! \
- //componentlist以表格的形式存在,只有一列。如果合成器有n个输入端口,那么就有n-1行。(第一个输入端口输入的是容器)8 r3 V7 i# C' }
- {
' X+ N/ A: J5 d: S, G( | - setnodenum(cellrowcolumn(thelist,index,1),gettablenum(tablename,index,getitemtype(item)));% q# E( t: S, l$ C1 f: [6 P* z$ i5 Z
- //第一输入端口进入的临时实体的类型,决定了使用全局表中的哪一列数据。3 ] O* {; H1 N3 [' U) `3 N' b
- //把该列数据全部读取出来,依次写入componentlist。* ]. a( Q1 h6 [, ^+ M/ i* v1 z
- inc(thesum,gettablenum(tablename,index,getitemtype(item)));
2 s U$ N, s& u- e4 B1 L, U3 @ - //同时更新targetcomponentsum的值。
! v/ f/ Y' |6 [' K) g9 e$ E - }
; B; {6 X* @& x) n3 z - }
复制代码 |
|