|
随手翻译了一下,不成体系。搞清楚合成器的第一个输入端口和其他输入端口的区别可能更容易看懂。. E7 O( g$ F5 X d7 h7 r
- /**根据全局表更新合成清单*/3 j; m$ Z7 `4 g6 q
- string tablename ="订单表";
$ l; `' d* i0 X- E; z - /*
; g1 i" U! j( n" P6 _% ?9 b# N O - This option should only be used on Combiners.
; m$ }# u2 m% `; A - 这段代码只能用于合成器。
2 r4 u8 B, T- R: ~ - Each column in the GlobalTable is the component list for a single itemtype.- w: ?% f% e& u3 j9 ]
- 全局表中的每一列是被合成临时实体的清单。
" {0 b8 R, U* ?6 l* ^ - The itemtype of the first flowitem to enter is used to find the correct column.( y9 X9 e3 X3 D! c1 q8 F P
- 从第一个输入端口进入的临时实体的类型决定了在全局表中的哪一列去查询合成清单。
1 c$ u4 ~9 w; y% p - It is assumed that the global table has a row for each input port number 2 and higher.
! j* a2 z2 I E" k( @ - 全局表的每一行都代表着一个编号大于等于2的输入端口。; e# W" k4 l; ?, H# ]
- */
- g& d: g: l. P9 r% z
9 W' e, {! o) g& f- if(port == 1)
& J# i- \: Y+ e2 _/ X - { //The trigger on entry code fires each time a flow item enters the combiner.; P- _* [1 [' p7 k' J$ @" t
- //For this reason we check to make sure that the port entered is equal to 1: }) d% g5 ?. x- G: O, s% K6 n7 A4 n
- //because only the container will enter through port 1." z5 m1 ~0 |9 m G6 k: E! N
- //每个临时实体进入合成器都会激活进入触发,所以必须要检查临时实体是否是从第一个端口进入的。: z) E' ^2 s- Y" Q
- //只有从第一个端口进入的临时实体才是托盘等容器类临时实体。1 d% g+ }/ O4 U' n: o. u
- //在上文已经解释过,第一个端口进入的临时实体的类型决定了采用全局表中的哪一列来设置合成清单。
' t" L7 }% o1 }0 l e9 R( V5 V - //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 contains3 B! z& @ B- @
- //合成清单以表格的形式存在。我们可以使用cell命令来获取数据节点。7 L3 k5 u6 [2 H
- //the number of items to retrieve from each port. Once you know what node contains the information you can use the setnodenum
! b4 _/ }7 {1 J" j1 L. J: X$ i# F - //command to set the component list number based on the global table.
- E* U: Q( n. R' ~& e$ p# o6 l, C - //当你知道数据存储于哪个节点之后,你就可以读取全局表中的数据,然后使用setnodenum命令在合成器中设置合成清单。
" n: P& ]4 ^! x. m: E - & } f4 N E5 z3 j
- treenode thelist = getvarnode(current,"componentlist");
, n* h! C/ E# L' R# ` - treenode thesum = getvarnode(current,"targetcomponentsum");
5 J @5 }' ~0 ~( v - //更改合成清单需要对两个数据节点进行设置。一个是componentlist,这个节点有一列数据,记录了从每个端口输入多少个临时实体。
) t8 T) }- e$ I+ Y( Q4 q, @ - //另一个是targetcomponentsum,记录本次打包的临时实体的总数。
& b/ L5 V+ S, S, r/ L# g - setnodenum(thesum,0);6 }$ {% c/ ~% I2 w0 v- m! i
- * n/ C7 t. a) @' A9 u' ]0 G
- for(int index=1; index<=nrows(thelist); index++)
/ }/ G n: ^9 l7 Y' M - //componentlist以表格的形式存在,只有一列。如果合成器有n个输入端口,那么就有n-1行。(第一个输入端口输入的是容器)
! J- z# b* e( r* S" G+ Z - {* a. ?3 x0 _3 k$ `1 s
- setnodenum(cellrowcolumn(thelist,index,1),gettablenum(tablename,index,getitemtype(item)));
& ^8 E+ w) o2 z( b0 h4 Y/ `3 J5 J - //第一输入端口进入的临时实体的类型,决定了使用全局表中的哪一列数据。
" b( ]! Z; `) e$ X! _4 I - //把该列数据全部读取出来,依次写入componentlist。
' M7 C, g3 L9 m - inc(thesum,gettablenum(tablename,index,getitemtype(item)));- R4 Z6 t& V, ?* O
- //同时更新targetcomponentsum的值。
4 l! W9 H9 A3 m) [5 K" @ - }
5 e* F" C2 X# u - }
复制代码 |
|