|
随手翻译了一下,不成体系。搞清楚合成器的第一个输入端口和其他输入端口的区别可能更容易看懂。. d" q. s2 D# G* E6 w& k
- /**根据全局表更新合成清单*/
0 e' R" U1 \% [# }& y - string tablename ="订单表";
4 U& t7 Y$ ]* _5 ? - /*
9 q9 X. B1 J7 R. D - This option should only be used on Combiners.
0 Y6 }; ^/ g; X5 x: p0 W - 这段代码只能用于合成器。
& p5 K) Q$ X; R; h7 ]$ X6 f - Each column in the GlobalTable is the component list for a single itemtype." v8 E+ z! k7 g
- 全局表中的每一列是被合成临时实体的清单。9 Q: \( J2 A6 u) w7 o3 m) U
- The itemtype of the first flowitem to enter is used to find the correct column.4 ~1 R+ m# f( z1 i# r, F3 r/ A
- 从第一个输入端口进入的临时实体的类型决定了在全局表中的哪一列去查询合成清单。0 O+ E* z q4 t- X% f5 A9 _
- It is assumed that the global table has a row for each input port number 2 and higher.
/ B" C% c' H; ]' c& v' D& v+ @ - 全局表的每一行都代表着一个编号大于等于2的输入端口。 Z5 ]; J7 M3 g3 z9 @
- */
$ V5 I. r+ C; F* ^
- ^8 U3 A% `, w( X& D- if(port == 1)
* G% R7 p; Y+ k- _ - { //The trigger on entry code fires each time a flow item enters the combiner.; W# n1 a7 \5 T3 t" C
- //For this reason we check to make sure that the port entered is equal to 1! D; Y& h/ G7 J
- //because only the container will enter through port 1." N- b& ?9 {' \+ e5 e
- //每个临时实体进入合成器都会激活进入触发,所以必须要检查临时实体是否是从第一个端口进入的。 g* d) W7 q& ?! ~% d8 [- K, T
- //只有从第一个端口进入的临时实体才是托盘等容器类临时实体。- w, F3 @+ z7 u5 G, L$ N; t' C+ k- g+ S
- //在上文已经解释过,第一个端口进入的临时实体的类型决定了采用全局表中的哪一列来设置合成清单。# V( k- }8 A' K. f5 z
- //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
( D) A0 X9 P2 x$ |; I8 c, o( v. g - //合成清单以表格的形式存在。我们可以使用cell命令来获取数据节点。# A: e }, y: \6 A3 z/ N
- //the number of items to retrieve from each port. Once you know what node contains the information you can use the setnodenum
7 `% N% v2 H' {. v0 C( P) M& V2 @ - //command to set the component list number based on the global table.
1 d9 C1 y$ |6 ^: i+ I% K6 ` - //当你知道数据存储于哪个节点之后,你就可以读取全局表中的数据,然后使用setnodenum命令在合成器中设置合成清单。
# h9 _; j' w- _& F% y
' }% [% z) _+ l2 e6 n- treenode thelist = getvarnode(current,"componentlist");
) w- F) Y, J* `7 z - treenode thesum = getvarnode(current,"targetcomponentsum");
1 R2 ~$ l/ F) s+ p% @$ P - //更改合成清单需要对两个数据节点进行设置。一个是componentlist,这个节点有一列数据,记录了从每个端口输入多少个临时实体。$ P. k+ H9 O" u3 ~" C c+ I4 T
- //另一个是targetcomponentsum,记录本次打包的临时实体的总数。9 P0 Q, E u% U) J6 c' f0 l; E- ^2 {
- setnodenum(thesum,0);) U" V( u% d9 I: u% F/ e
- % R3 F- W; x. a2 v5 u4 ]9 u2 E
- for(int index=1; index<=nrows(thelist); index++)
# N0 U7 {. f' M( ]2 p - //componentlist以表格的形式存在,只有一列。如果合成器有n个输入端口,那么就有n-1行。(第一个输入端口输入的是容器)
' J* J4 Z9 D8 T c8 ?3 I T1 l/ _/ C - {
- Z+ `) L' M7 ~2 i' P6 E [6 s - setnodenum(cellrowcolumn(thelist,index,1),gettablenum(tablename,index,getitemtype(item)));6 s, f8 y$ g& }. c0 o% ?3 {
- //第一输入端口进入的临时实体的类型,决定了使用全局表中的哪一列数据。5 C- p3 L) E+ H! U% r9 Q2 y
- //把该列数据全部读取出来,依次写入componentlist。
5 v8 I; {" h: t1 F/ j8 |5 E: g - inc(thesum,gettablenum(tablename,index,getitemtype(item)));2 ~& j3 \! s" _# C! Y M
- //同时更新targetcomponentsum的值。 S; S- }9 L9 X
- } u- W/ \' \$ I1 K4 Q
- }
复制代码 |
|