|
随手翻译了一下,不成体系。搞清楚合成器的第一个输入端口和其他输入端口的区别可能更容易看懂。) h$ e+ J' J0 X
- /**根据全局表更新合成清单*/
. B5 W* z: e8 M4 T - string tablename ="订单表";
: r* U8 Q: H& m& G - /*+ Y# b+ k: Q$ q& r! a/ T
- This option should only be used on Combiners.
4 o# a9 X! J$ u' D - 这段代码只能用于合成器。, c. J m* Y) {3 A* @+ i& v
- Each column in the GlobalTable is the component list for a single itemtype.
4 y' t+ W. g+ T3 h, s - 全局表中的每一列是被合成临时实体的清单。
6 }- T7 x% s' I* n7 r5 C - The itemtype of the first flowitem to enter is used to find the correct column.
7 ~. @* r7 O! M2 y - 从第一个输入端口进入的临时实体的类型决定了在全局表中的哪一列去查询合成清单。, b- Z& O. G8 G8 v% b
- It is assumed that the global table has a row for each input port number 2 and higher.' s0 J( Z. ?1 e* ?
- 全局表的每一行都代表着一个编号大于等于2的输入端口。0 F; C+ H+ O- q0 o) A
- */
2 q/ f; p! n: M- y
5 S! G a { ~+ z6 A- if(port == 1)) k% C3 a5 b" |& `, y
- { //The trigger on entry code fires each time a flow item enters the combiner.8 m0 a) Z1 Z" M+ j1 \) U" S
- //For this reason we check to make sure that the port entered is equal to 10 \4 z- }& m# r; z2 k }, V( M5 y
- //because only the container will enter through port 1.; a1 D7 D' B; ] j0 n a
- //每个临时实体进入合成器都会激活进入触发,所以必须要检查临时实体是否是从第一个端口进入的。- r" Q. b0 @4 n( E
- //只有从第一个端口进入的临时实体才是托盘等容器类临时实体。
# F+ p" o1 {. c+ s/ ^* A( v9 U, `( B - //在上文已经解释过,第一个端口进入的临时实体的类型决定了采用全局表中的哪一列来设置合成清单。
0 G4 h* Y) F7 Q6 m - //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
. o. T6 Q. }8 N7 F% ]' L/ I# g - //合成清单以表格的形式存在。我们可以使用cell命令来获取数据节点。; z! z# N3 [0 P: x l6 H
- //the number of items to retrieve from each port. Once you know what node contains the information you can use the setnodenum0 H3 y: V" v& s6 S4 q* R3 ]3 T" l
- //command to set the component list number based on the global table.
; z' X0 L- X& P - //当你知道数据存储于哪个节点之后,你就可以读取全局表中的数据,然后使用setnodenum命令在合成器中设置合成清单。
5 _3 e( |& s' a2 | - [9 G. Y u+ G @7 o7 O6 D! ^
- treenode thelist = getvarnode(current,"componentlist");' Q5 w+ H8 _2 [6 N Z
- treenode thesum = getvarnode(current,"targetcomponentsum");) C9 ^( Y6 u& `
- //更改合成清单需要对两个数据节点进行设置。一个是componentlist,这个节点有一列数据,记录了从每个端口输入多少个临时实体。
* I2 n8 R7 S! O$ B$ H7 N - //另一个是targetcomponentsum,记录本次打包的临时实体的总数。9 ?! F# o z: q. i& ^* o
- setnodenum(thesum,0);
a8 @( B% C/ H8 x p - ( E6 ?; h9 N, H- K* V
- for(int index=1; index<=nrows(thelist); index++)
1 S! X, f% Z2 r, w4 k3 S; Y# p9 p. s; y - //componentlist以表格的形式存在,只有一列。如果合成器有n个输入端口,那么就有n-1行。(第一个输入端口输入的是容器)" }* K5 G9 W; Y9 S
- {1 d6 j3 J }. l% n
- setnodenum(cellrowcolumn(thelist,index,1),gettablenum(tablename,index,getitemtype(item)));
0 e5 C+ N# t. W4 G/ J - //第一输入端口进入的临时实体的类型,决定了使用全局表中的哪一列数据。
/ g& I+ T6 w8 I* {1 A - //把该列数据全部读取出来,依次写入componentlist。( R5 I6 p! h7 o9 F$ I5 z; f
- inc(thesum,gettablenum(tablename,index,getitemtype(item)));: i) b7 G- I) Z& n$ R" b
- //同时更新targetcomponentsum的值。4 Q! a; R2 A2 w# W. Z# p
- }
4 }' x4 M$ L( M" l$ a3 B - }
复制代码 |
|