|
随手翻译了一下,不成体系。搞清楚合成器的第一个输入端口和其他输入端口的区别可能更容易看懂。
5 n3 k. G7 X( r- /**根据全局表更新合成清单*/
: l( l- r+ c) T- F - string tablename ="订单表";
. ?1 G' z1 ^1 y. o - /*
; u' S5 a+ `7 |& h& z2 }5 G) y7 X - This option should only be used on Combiners.: F1 t2 r- v" ^' t1 W; h
- 这段代码只能用于合成器。3 ~: {# q! A/ ?) O! B6 I' c) Q
- Each column in the GlobalTable is the component list for a single itemtype.
' a* N) {! J7 K3 N" m: c1 l. X - 全局表中的每一列是被合成临时实体的清单。
4 c. {! b; D: |( v - The itemtype of the first flowitem to enter is used to find the correct column.8 w- U7 v. Y& i# F! O2 q
- 从第一个输入端口进入的临时实体的类型决定了在全局表中的哪一列去查询合成清单。
7 S5 V/ f) B1 s& K# Q4 B2 c - It is assumed that the global table has a row for each input port number 2 and higher.
, b, v/ d+ C8 G: t7 w# i' ^ - 全局表的每一行都代表着一个编号大于等于2的输入端口。
" q' H7 Q# `* E* l - */, n2 z' V* K' e7 ]2 H
- ) i" }. U9 l& L* A
- if(port == 1)& M( F. b- L0 Z/ z% w: j
- { //The trigger on entry code fires each time a flow item enters the combiner. @# ]2 x* _$ A
- //For this reason we check to make sure that the port entered is equal to 1
. v: v" P4 E0 q1 \& m9 D! S - //because only the container will enter through port 1.; k5 \& r: S5 Z
- //每个临时实体进入合成器都会激活进入触发,所以必须要检查临时实体是否是从第一个端口进入的。0 V, f# R' p. @1 a0 z' k9 {/ \( m3 d& T
- //只有从第一个端口进入的临时实体才是托盘等容器类临时实体。
7 t6 C; ~. A, a! }3 f6 A - //在上文已经解释过,第一个端口进入的临时实体的类型决定了采用全局表中的哪一列来设置合成清单。1 K( t0 ^/ F. v. S% ]0 d+ v4 Y( J$ q2 s
- //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" w5 p0 j$ m% i+ v6 c# n6 h! C2 a1 i
- //合成清单以表格的形式存在。我们可以使用cell命令来获取数据节点。6 m. i6 A6 J. C% }8 m, X
- //the number of items to retrieve from each port. Once you know what node contains the information you can use the setnodenum
7 S4 S7 _0 b# P - //command to set the component list number based on the global table.
- m( K* R! F4 C' v7 O& p$ U3 q - //当你知道数据存储于哪个节点之后,你就可以读取全局表中的数据,然后使用setnodenum命令在合成器中设置合成清单。
% x5 [- E% q# M4 u9 ~9 q8 s; B. m
- d, q9 k4 g# p; `4 `- treenode thelist = getvarnode(current,"componentlist");
2 f8 y/ A3 Z# j3 K" _% ? - treenode thesum = getvarnode(current,"targetcomponentsum");
& U8 x/ F `5 ?7 ^2 `/ o3 t - //更改合成清单需要对两个数据节点进行设置。一个是componentlist,这个节点有一列数据,记录了从每个端口输入多少个临时实体。6 L3 q- ^' S; n
- //另一个是targetcomponentsum,记录本次打包的临时实体的总数。
y4 l$ m% L8 ` - setnodenum(thesum,0);4 d$ K% T8 ~# d1 R& [
- 7 G+ \! ^/ J9 g" w: j: E, r
- for(int index=1; index<=nrows(thelist); index++)) P; A& b# i6 Z4 i
- //componentlist以表格的形式存在,只有一列。如果合成器有n个输入端口,那么就有n-1行。(第一个输入端口输入的是容器)
9 p8 s9 V: E$ a7 L; y4 ^- M - {
" C6 H: U, j& r - setnodenum(cellrowcolumn(thelist,index,1),gettablenum(tablename,index,getitemtype(item)));: w6 s7 S6 o5 q$ j, X, j
- //第一输入端口进入的临时实体的类型,决定了使用全局表中的哪一列数据。
4 }! M0 h2 m& ]8 i - //把该列数据全部读取出来,依次写入componentlist。
5 }' v* i; I, T$ t- y9 g - inc(thesum,gettablenum(tablename,index,getitemtype(item)));
( ~# X% ? G2 E: k" Y - //同时更新targetcomponentsum的值。
7 F6 O) p7 l1 n7 A3 c - }& y7 {0 Q$ L( Y1 |3 e3 B
- }
复制代码 |
|