|
随手翻译了一下,不成体系。搞清楚合成器的第一个输入端口和其他输入端口的区别可能更容易看懂。/ M: b/ b! l8 u$ O; o( w- f
- /**根据全局表更新合成清单*/
" X' o8 f8 y) q" Q - string tablename ="订单表";
* z0 v8 H6 j- F1 l2 t! h _ - /*6 V/ E9 J9 y6 |; Q/ v+ ?' |- T( o
- This option should only be used on Combiners.
0 x- V. q. d9 l: Q - 这段代码只能用于合成器。
, ~. r* m9 Z6 e/ N2 k6 \4 f8 Y" L - Each column in the GlobalTable is the component list for a single itemtype.
2 a- W; k- \6 C. f! e - 全局表中的每一列是被合成临时实体的清单。$ y. k. k8 k+ g u# p o4 V
- The itemtype of the first flowitem to enter is used to find the correct column.
6 l" z4 ^) L& }3 o) s - 从第一个输入端口进入的临时实体的类型决定了在全局表中的哪一列去查询合成清单。
Y, B. v! j% V# p - It is assumed that the global table has a row for each input port number 2 and higher." y/ j" _/ m6 i7 f
- 全局表的每一行都代表着一个编号大于等于2的输入端口。3 F7 s8 I, Q0 i/ E
- */% P' S; p$ g9 v# x i
9 s( I! e0 d7 l9 {2 e$ c/ F- if(port == 1)1 Q0 W1 G/ X7 y$ p+ }6 x
- { //The trigger on entry code fires each time a flow item enters the combiner.# L6 Y( n1 o. ]
- //For this reason we check to make sure that the port entered is equal to 1
9 T) H' {* k b1 R& b6 l& s9 I2 P - //because only the container will enter through port 1.) _6 l) Q" h; A2 h( {
- //每个临时实体进入合成器都会激活进入触发,所以必须要检查临时实体是否是从第一个端口进入的。
) M3 a) d; J3 N3 g% [7 U5 V - //只有从第一个端口进入的临时实体才是托盘等容器类临时实体。4 m/ G. B. C' B$ O4 j; [
- //在上文已经解释过,第一个端口进入的临时实体的类型决定了采用全局表中的哪一列来设置合成清单。
% `8 A+ {- V2 ~6 c* l - //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( q! i/ G, [" U. X N+ z! `
- //合成清单以表格的形式存在。我们可以使用cell命令来获取数据节点。
% ?4 X9 C6 A* d/ m4 E - //the number of items to retrieve from each port. Once you know what node contains the information you can use the setnodenum* `" U' e. H$ z \3 B2 B6 R6 u$ d
- //command to set the component list number based on the global table.7 c( f3 k8 j7 q1 Y
- //当你知道数据存储于哪个节点之后,你就可以读取全局表中的数据,然后使用setnodenum命令在合成器中设置合成清单。/ w( ~" t# o$ F1 C5 ]& v* t
- 1 W& J' Z" g7 c+ a1 A r
- treenode thelist = getvarnode(current,"componentlist");
- d+ x1 N% J4 c/ {) k- }- n. M b - treenode thesum = getvarnode(current,"targetcomponentsum");" g+ m0 b0 J0 `# Z) m3 u! S: F
- //更改合成清单需要对两个数据节点进行设置。一个是componentlist,这个节点有一列数据,记录了从每个端口输入多少个临时实体。
- u: V* K" e, M' q4 _ - //另一个是targetcomponentsum,记录本次打包的临时实体的总数。
* V# D. h+ u m/ A* m" a4 G+ x: m - setnodenum(thesum,0);
3 g$ B e. G& ?
7 Q; `/ f2 k* r% H3 F1 M- for(int index=1; index<=nrows(thelist); index++)
+ X' l! b) }# ^! z: L. g - //componentlist以表格的形式存在,只有一列。如果合成器有n个输入端口,那么就有n-1行。(第一个输入端口输入的是容器)
4 ?( y6 k5 N. U6 B+ m, g - {- t6 I4 y* {, b0 w1 T2 {) }% K
- setnodenum(cellrowcolumn(thelist,index,1),gettablenum(tablename,index,getitemtype(item)));
7 o' R- o h" `6 ? - //第一输入端口进入的临时实体的类型,决定了使用全局表中的哪一列数据。
5 C, {+ P' \3 \ - //把该列数据全部读取出来,依次写入componentlist。
+ d7 E6 p# l) m) i. X0 E - inc(thesum,gettablenum(tablename,index,getitemtype(item)));0 q5 x# |- S3 O: Y7 A
- //同时更新targetcomponentsum的值。
; F. k5 y e I8 u - }2 b) l6 T, v3 e9 S) Y
- }
复制代码 |
|