|
随手翻译了一下,不成体系。搞清楚合成器的第一个输入端口和其他输入端口的区别可能更容易看懂。
/ ]- E) Y( g9 d7 k- /**根据全局表更新合成清单*/' j9 q; z8 K% T
- string tablename ="订单表";
% P1 k. u' \5 P0 g5 d5 ] - /*
5 c S7 }& U* J2 r" U; ~+ N5 \/ ? - This option should only be used on Combiners.
3 t% P9 g" f( \% g- _% R% Z5 B; \ - 这段代码只能用于合成器。7 U" G7 V- R- L+ P7 i
- Each column in the GlobalTable is the component list for a single itemtype.7 y* M5 V4 e4 |$ x* C1 d
- 全局表中的每一列是被合成临时实体的清单。+ @: H/ [* h0 t% b% t+ K4 |6 A- t+ W4 u
- The itemtype of the first flowitem to enter is used to find the correct column.& q! m. ^" S* d+ }- c" h
- 从第一个输入端口进入的临时实体的类型决定了在全局表中的哪一列去查询合成清单。# Z- X: X" V9 J3 {5 J
- It is assumed that the global table has a row for each input port number 2 and higher.8 {/ i1 J1 w, p# q0 X9 X* F
- 全局表的每一行都代表着一个编号大于等于2的输入端口。
2 A9 T0 v9 c' u$ b/ D - */ |' b3 m7 c" J# K7 ^# n( Z
h% q7 T5 q& p p6 F- if(port == 1)
( X# Q: O% S2 v; H, R1 ~0 } - { //The trigger on entry code fires each time a flow item enters the combiner.8 C: V+ A% L* }
- //For this reason we check to make sure that the port entered is equal to 1
3 x2 b9 F. T) G% b, a4 U - //because only the container will enter through port 1.% k2 {2 P0 J& N/ ]3 N, b
- //每个临时实体进入合成器都会激活进入触发,所以必须要检查临时实体是否是从第一个端口进入的。" X: J2 r2 s' A' J* \6 D" F5 N
- //只有从第一个端口进入的临时实体才是托盘等容器类临时实体。
' x$ L0 E+ ~) O9 x4 S3 I7 s$ a - //在上文已经解释过,第一个端口进入的临时实体的类型决定了采用全局表中的哪一列来设置合成清单。$ X. f! K, F7 E x7 _" \
- //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 R7 y9 K2 Z) E* w- {
- //合成清单以表格的形式存在。我们可以使用cell命令来获取数据节点。
8 D1 a. k) X0 [1 |, m: _& m% r$ [! k - //the number of items to retrieve from each port. Once you know what node contains the information you can use the setnodenum
" a0 t$ Q7 n5 Q& e f9 r7 L - //command to set the component list number based on the global table.
( h6 m" w8 [; x' ]8 q - //当你知道数据存储于哪个节点之后,你就可以读取全局表中的数据,然后使用setnodenum命令在合成器中设置合成清单。
) T' X, N2 V" ]5 x& t
- h6 h- b2 x3 [2 g- treenode thelist = getvarnode(current,"componentlist");
" S. X$ ], o8 {" M - treenode thesum = getvarnode(current,"targetcomponentsum");$ c, f/ Y2 F7 m6 T) Z
- //更改合成清单需要对两个数据节点进行设置。一个是componentlist,这个节点有一列数据,记录了从每个端口输入多少个临时实体。
1 [+ ]8 ~6 `$ b! |) w. X, x% D% c# Q+ v - //另一个是targetcomponentsum,记录本次打包的临时实体的总数。
9 A% a3 l$ _' q - setnodenum(thesum,0);% k3 [5 i" H9 R! h' k- K
- + `3 V# u+ r7 H' V" {: d& r" ?
- for(int index=1; index<=nrows(thelist); index++). S) s5 e# ~4 k+ @
- //componentlist以表格的形式存在,只有一列。如果合成器有n个输入端口,那么就有n-1行。(第一个输入端口输入的是容器)
8 m* N2 y' }! R' w) V. I - {
1 d& c' Z* N8 P+ L4 O+ {5 J' b. B - setnodenum(cellrowcolumn(thelist,index,1),gettablenum(tablename,index,getitemtype(item)));
9 j9 y& n1 v/ ^5 Y# @ - //第一输入端口进入的临时实体的类型,决定了使用全局表中的哪一列数据。% A" U. K/ Q* S& I7 L/ a7 a' u; V
- //把该列数据全部读取出来,依次写入componentlist。
( X4 Y0 z ]+ i! q$ v; D0 W - inc(thesum,gettablenum(tablename,index,getitemtype(item)));4 {" J4 @5 K I
- //同时更新targetcomponentsum的值。, t6 W5 F" R/ [' n0 e
- }+ w4 O4 Z5 n1 }9 W
- }
复制代码 |
|