|
随手翻译了一下,不成体系。搞清楚合成器的第一个输入端口和其他输入端口的区别可能更容易看懂。
/ _% X* A, G0 ?1 q- /**根据全局表更新合成清单*/
1 K0 v Y& f* s+ k - string tablename ="订单表";
A8 S5 M1 _8 _& I( R$ P8 y9 Y - /*8 u/ u- T! o/ ?( J$ g
- This option should only be used on Combiners.
( C7 {: O+ T. T' Q& j - 这段代码只能用于合成器。
0 n6 p; i; @. ^8 G4 w( x, L - Each column in the GlobalTable is the component list for a single itemtype./ D. V0 O! S0 Z
- 全局表中的每一列是被合成临时实体的清单。
, J. j! t: z* ]# O2 b/ S9 L% h - The itemtype of the first flowitem to enter is used to find the correct column. g5 d: d0 f% x) G* ^* o
- 从第一个输入端口进入的临时实体的类型决定了在全局表中的哪一列去查询合成清单。
& _; M) {- U. S0 Y. j - It is assumed that the global table has a row for each input port number 2 and higher.& ]4 \/ G: p* W: s8 m9 H" H8 }
- 全局表的每一行都代表着一个编号大于等于2的输入端口。
8 {- S: U9 I4 Q: r) G$ z ]' d - */1 z/ ?1 X) P8 Q- N
: D( h8 V* u" x/ e- if(port == 1)
+ d8 K: N O# u5 S$ I - { //The trigger on entry code fires each time a flow item enters the combiner.4 M/ a5 A$ `8 a9 v
- //For this reason we check to make sure that the port entered is equal to 1! `7 c6 o/ u- l M
- //because only the container will enter through port 1.4 O6 ^' K" W9 v" ~/ V! u
- //每个临时实体进入合成器都会激活进入触发,所以必须要检查临时实体是否是从第一个端口进入的。6 W, S" l; [/ `
- //只有从第一个端口进入的临时实体才是托盘等容器类临时实体。) a' H2 P% R3 z5 O/ V! ]& ^9 q
- //在上文已经解释过,第一个端口进入的临时实体的类型决定了采用全局表中的哪一列来设置合成清单。8 q' s7 c. o( y1 \5 `
- //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& t, Q, [; W; `2 X2 X' n# {
- //合成清单以表格的形式存在。我们可以使用cell命令来获取数据节点。
+ l Y) @/ f3 Y* W. K% E) ? - //the number of items to retrieve from each port. Once you know what node contains the information you can use the setnodenum' J7 ?* G3 G {' V8 e, l+ Z! @
- //command to set the component list number based on the global table." x. F: u: J3 A' X
- //当你知道数据存储于哪个节点之后,你就可以读取全局表中的数据,然后使用setnodenum命令在合成器中设置合成清单。" V" B$ D, E$ n4 [
/ j% i) \" y3 h* H- treenode thelist = getvarnode(current,"componentlist");
# l$ C9 P" V) f - treenode thesum = getvarnode(current,"targetcomponentsum");3 ]; b! _ ~4 B5 ?3 s
- //更改合成清单需要对两个数据节点进行设置。一个是componentlist,这个节点有一列数据,记录了从每个端口输入多少个临时实体。
! } h- I2 n6 c7 [/ o5 N5 _8 h - //另一个是targetcomponentsum,记录本次打包的临时实体的总数。
, g: X2 x' u+ h4 o5 b - setnodenum(thesum,0);
4 s" V- ~/ [3 k4 S( D. a: C8 ?1 | - # v2 G2 C7 T6 L0 \- D3 m3 }
- for(int index=1; index<=nrows(thelist); index++)
! n' w2 q! \2 W' F/ ^8 x - //componentlist以表格的形式存在,只有一列。如果合成器有n个输入端口,那么就有n-1行。(第一个输入端口输入的是容器)
0 n( Q, Q# b- a2 ~- g! D - {
: u8 D' n; F7 [( v1 ~ - setnodenum(cellrowcolumn(thelist,index,1),gettablenum(tablename,index,getitemtype(item)));; Z' N/ D- B% _& w1 f
- //第一输入端口进入的临时实体的类型,决定了使用全局表中的哪一列数据。! F! }7 I" q& G* S$ q
- //把该列数据全部读取出来,依次写入componentlist。0 n9 ]* S2 t, X! r- {
- inc(thesum,gettablenum(tablename,index,getitemtype(item)));' F3 ~, M# J. H: Z1 e
- //同时更新targetcomponentsum的值。 ^# {8 t2 v0 i7 D5 l# M4 [
- }
D$ Z( n: o4 g3 f/ i - }
复制代码 |
|