|
随手翻译了一下,不成体系。搞清楚合成器的第一个输入端口和其他输入端口的区别可能更容易看懂。6 p% n. x4 l& p/ `
- /**根据全局表更新合成清单*/
& P7 U: y$ _$ o; F - string tablename ="订单表";
8 V6 e$ {2 t+ Y0 E - /*
9 Y* J1 z( ^! }; K - This option should only be used on Combiners.3 @' n1 r @) G" H3 _- ^
- 这段代码只能用于合成器。
# T! }/ t$ [" c: K, K, X& c - Each column in the GlobalTable is the component list for a single itemtype.: }/ ^# ^% d2 e" v E
- 全局表中的每一列是被合成临时实体的清单。
8 g3 [; X% B+ ?6 G* ^! _% ? - The itemtype of the first flowitem to enter is used to find the correct column.
; k, X9 Z5 i. _& } k2 x - 从第一个输入端口进入的临时实体的类型决定了在全局表中的哪一列去查询合成清单。
& Q4 f. x( j! U% q" Z9 A1 u0 b& a - It is assumed that the global table has a row for each input port number 2 and higher.
4 ]0 M: M" Z2 R7 ~0 \+ H; I- ] - 全局表的每一行都代表着一个编号大于等于2的输入端口。
/ e2 u1 d" d( `/ S4 L3 S - */' z! Q w6 D, R: S( J+ E" q
- Q7 A- B( @7 b( `" E
- if(port == 1), G4 w5 [- T* l( @# Y
- { //The trigger on entry code fires each time a flow item enters the combiner.
6 u) \& Q/ w1 y# Q - //For this reason we check to make sure that the port entered is equal to 1
3 h' f j0 ^; q8 k- I2 I; r - //because only the container will enter through port 1.
9 i( G0 D" F3 |: I0 m* Q- D - //每个临时实体进入合成器都会激活进入触发,所以必须要检查临时实体是否是从第一个端口进入的。
$ a# B: A) ?( C7 u# s6 k# h - //只有从第一个端口进入的临时实体才是托盘等容器类临时实体。# w( S: n/ z& x2 ?4 h; n
- //在上文已经解释过,第一个端口进入的临时实体的类型决定了采用全局表中的哪一列来设置合成清单。 Z* P# Q7 a7 o- v0 p& S$ W2 d2 w2 Q
- //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
5 B: `0 W7 C* ]$ F' S* q - //合成清单以表格的形式存在。我们可以使用cell命令来获取数据节点。7 |& {% O% D, b5 i+ b9 C/ [
- //the number of items to retrieve from each port. Once you know what node contains the information you can use the setnodenum
. f: N8 o5 {; g2 B G4 q2 x - //command to set the component list number based on the global table.
7 h" J3 u; D; E - //当你知道数据存储于哪个节点之后,你就可以读取全局表中的数据,然后使用setnodenum命令在合成器中设置合成清单。
$ }0 N& N# e- a4 E" l
; q& B4 Y7 j! r M2 M; o- treenode thelist = getvarnode(current,"componentlist");) [$ w& X% J% _9 R% `1 @) k+ F
- treenode thesum = getvarnode(current,"targetcomponentsum");$ U# P( i m3 @( d! ] t
- //更改合成清单需要对两个数据节点进行设置。一个是componentlist,这个节点有一列数据,记录了从每个端口输入多少个临时实体。; m: a& i. L. P
- //另一个是targetcomponentsum,记录本次打包的临时实体的总数。$ _% n1 w* K9 p; `6 {8 ^, ]& Z
- setnodenum(thesum,0);& ]( d# [; ?5 }4 ~. f: {4 O' e
& v1 J% R, g" K3 ?& i- for(int index=1; index<=nrows(thelist); index++)0 ~' C$ b1 k1 l* g& p, ^$ b+ o
- //componentlist以表格的形式存在,只有一列。如果合成器有n个输入端口,那么就有n-1行。(第一个输入端口输入的是容器)
4 G; `2 f3 h1 T+ i6 Q, C# K0 M - {5 i7 ] ]2 \6 u: F7 X: W. I* X
- setnodenum(cellrowcolumn(thelist,index,1),gettablenum(tablename,index,getitemtype(item)));/ @+ X* R! h! m3 J
- //第一输入端口进入的临时实体的类型,决定了使用全局表中的哪一列数据。+ N5 f/ j, l* G( `, v/ K
- //把该列数据全部读取出来,依次写入componentlist。
2 a& t4 E1 K4 k9 Y6 f# B - inc(thesum,gettablenum(tablename,index,getitemtype(item)));
$ M) a9 H0 R) k9 i9 @8 i - //同时更新targetcomponentsum的值。
7 s! x: `. r! D0 J: n& v& h4 J - }% z$ A( L- X9 l
- }
复制代码 |
|