|
随手翻译了一下,不成体系。搞清楚合成器的第一个输入端口和其他输入端口的区别可能更容易看懂。
/ P- {; z+ f3 q+ ?- /**根据全局表更新合成清单*/
; i; U+ b/ v4 \7 _, O% a - string tablename ="订单表";
' [6 w. i. d3 _- ^$ f' U - /*
0 t3 @" {. K7 c- `' j - This option should only be used on Combiners.' U/ ^' B( r1 s6 D4 @- D
- 这段代码只能用于合成器。
/ Q/ B4 Q v3 d: L; K7 k3 `( b; I - Each column in the GlobalTable is the component list for a single itemtype.
0 T+ o) g# E$ o% ?% {6 }: o - 全局表中的每一列是被合成临时实体的清单。
( Z+ p4 h& q0 | `0 l - The itemtype of the first flowitem to enter is used to find the correct column.
1 Q+ ? K4 v+ R - 从第一个输入端口进入的临时实体的类型决定了在全局表中的哪一列去查询合成清单。
; Q; M/ q0 v" u - It is assumed that the global table has a row for each input port number 2 and higher.
2 D! W6 u0 P0 h/ Y7 l' O! } - 全局表的每一行都代表着一个编号大于等于2的输入端口。
4 ^. L& G, t3 R' y% Q - */0 N' V0 m) r6 B
- w; W4 c7 g7 ~8 l
- if(port == 1)" s$ \0 v4 ]6 d6 f" a% V5 t
- { //The trigger on entry code fires each time a flow item enters the combiner.7 @2 m6 v7 g- F- [( V! d
- //For this reason we check to make sure that the port entered is equal to 1. S: U( J7 a" i. G' t( F6 [
- //because only the container will enter through port 1. W; s+ U; z N# a4 H
- //每个临时实体进入合成器都会激活进入触发,所以必须要检查临时实体是否是从第一个端口进入的。
3 f( p! t- }9 H, S& L" Z! I - //只有从第一个端口进入的临时实体才是托盘等容器类临时实体。
2 Y/ J- ^& _0 m' s - //在上文已经解释过,第一个端口进入的临时实体的类型决定了采用全局表中的哪一列来设置合成清单。- w) @! q: R9 t* y
- //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; F, n/ }9 s, t1 R8 S
- //合成清单以表格的形式存在。我们可以使用cell命令来获取数据节点。
! I5 z% f1 I* }, G- e6 t - //the number of items to retrieve from each port. Once you know what node contains the information you can use the setnodenum
" L2 `4 H ]: z \! e - //command to set the component list number based on the global table.
: L+ F+ i+ U, P& Y$ F - //当你知道数据存储于哪个节点之后,你就可以读取全局表中的数据,然后使用setnodenum命令在合成器中设置合成清单。( r' Q. n: }! @: C- G- n; b# V
- 5 y( _# L% Y6 r
- treenode thelist = getvarnode(current,"componentlist");/ h/ |& ]& N; n
- treenode thesum = getvarnode(current,"targetcomponentsum");3 S7 J7 ]( L9 u6 k
- //更改合成清单需要对两个数据节点进行设置。一个是componentlist,这个节点有一列数据,记录了从每个端口输入多少个临时实体。+ J% g4 S/ Y5 m4 Y/ V, T, b/ f; b
- //另一个是targetcomponentsum,记录本次打包的临时实体的总数。& q4 [' r8 y* O3 l
- setnodenum(thesum,0);
5 `+ o' z2 q K, P# h/ `4 t! X8 Q+ g - , R2 P) O6 k) Q6 T1 J
- for(int index=1; index<=nrows(thelist); index++)
. N& H& m9 O: a& k: c' Z - //componentlist以表格的形式存在,只有一列。如果合成器有n个输入端口,那么就有n-1行。(第一个输入端口输入的是容器)4 l( P. |) X( P; d6 J
- {
" ~8 l7 h( L, y- N0 }& [! d - setnodenum(cellrowcolumn(thelist,index,1),gettablenum(tablename,index,getitemtype(item)));
2 l( H# {7 |, {. O) m& U { - //第一输入端口进入的临时实体的类型,决定了使用全局表中的哪一列数据。
# y9 L+ P: a2 F$ J - //把该列数据全部读取出来,依次写入componentlist。' Y/ B' \! ?0 b0 v' \* g* v. C
- inc(thesum,gettablenum(tablename,index,getitemtype(item)));7 q8 U9 B e0 \/ @ Y
- //同时更新targetcomponentsum的值。
) i* h$ `* e+ N - }3 j, g1 @$ q# U! g& I
- }
复制代码 |
|