|
随手翻译了一下,不成体系。搞清楚合成器的第一个输入端口和其他输入端口的区别可能更容易看懂。
9 D9 ^3 ^0 T5 K( |3 x- /**根据全局表更新合成清单*/
& m* o$ [0 w, Y! ?" r - string tablename ="订单表";
: q% w, e' |6 d/ U( `% ?1 F3 d; ^9 n - /*- m$ i* C+ A/ ?$ I
- This option should only be used on Combiners.
! W; N% C K3 o; K) F& T - 这段代码只能用于合成器。5 v) u- t! j" F1 P( f
- Each column in the GlobalTable is the component list for a single itemtype.4 J) d* u t- D* |' I. q
- 全局表中的每一列是被合成临时实体的清单。
3 Q9 {- |' v1 J3 m& R0 y - The itemtype of the first flowitem to enter is used to find the correct column.0 Z$ I: c% n) q/ X: L0 C: v6 a7 @
- 从第一个输入端口进入的临时实体的类型决定了在全局表中的哪一列去查询合成清单。% B4 N1 A% s5 \3 Q
- It is assumed that the global table has a row for each input port number 2 and higher.6 x3 ]! Z8 B. \. Z
- 全局表的每一行都代表着一个编号大于等于2的输入端口。: }$ U- m P5 r
- */
' n0 N8 L4 g1 U4 u
( s5 T0 C9 n7 @9 r( M+ h4 p- if(port == 1)* _# t, ~' n$ n+ e$ N. Y
- { //The trigger on entry code fires each time a flow item enters the combiner.
K" k% k4 e, Q, c0 B4 o - //For this reason we check to make sure that the port entered is equal to 1
( h. b5 a! Q" i - //because only the container will enter through port 1.
! ~2 b2 \" }% c& z* X0 Y - //每个临时实体进入合成器都会激活进入触发,所以必须要检查临时实体是否是从第一个端口进入的。
Z4 Q e6 G$ I/ Z - //只有从第一个端口进入的临时实体才是托盘等容器类临时实体。* K/ c- q: d$ j8 d. D/ p b' y
- //在上文已经解释过,第一个端口进入的临时实体的类型决定了采用全局表中的哪一列来设置合成清单。
) ]/ I" ?& e5 `2 t - //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! A" B/ {( p1 g
- //合成清单以表格的形式存在。我们可以使用cell命令来获取数据节点。
, y) I! F) l7 j% T - //the number of items to retrieve from each port. Once you know what node contains the information you can use the setnodenum
3 D$ R/ ^+ v( \( x! }0 S# f3 t - //command to set the component list number based on the global table.
) h2 d- O) Q4 n) M: x - //当你知道数据存储于哪个节点之后,你就可以读取全局表中的数据,然后使用setnodenum命令在合成器中设置合成清单。
' r4 ?! L; K% c9 B9 U+ C - + C6 @9 [6 V- u1 y
- treenode thelist = getvarnode(current,"componentlist");0 n! N# A# } e [! Y
- treenode thesum = getvarnode(current,"targetcomponentsum");8 h. j& q6 h- S% c1 T, E/ `
- //更改合成清单需要对两个数据节点进行设置。一个是componentlist,这个节点有一列数据,记录了从每个端口输入多少个临时实体。
! d }3 }9 Z$ k- m: J - //另一个是targetcomponentsum,记录本次打包的临时实体的总数。/ ^# v; m$ k' w
- setnodenum(thesum,0);
' [) ~" r* q0 N& B - , C5 N j6 a3 o' ~
- for(int index=1; index<=nrows(thelist); index++): [' O2 t e M. U" |
- //componentlist以表格的形式存在,只有一列。如果合成器有n个输入端口,那么就有n-1行。(第一个输入端口输入的是容器)* q" e! H8 [" B% s7 p2 f
- {
0 L& i* o. @7 b. n - setnodenum(cellrowcolumn(thelist,index,1),gettablenum(tablename,index,getitemtype(item)));2 Y) m' f4 V7 M8 l1 G
- //第一输入端口进入的临时实体的类型,决定了使用全局表中的哪一列数据。
7 q, s5 H1 I* F# A8 W) `( K - //把该列数据全部读取出来,依次写入componentlist。! s. B7 N& G& W7 y3 }6 X
- inc(thesum,gettablenum(tablename,index,getitemtype(item)));
- C0 S5 l; T; p) z9 @ - //同时更新targetcomponentsum的值。" v' y1 }6 x! Q. B
- }
" B% b! ]5 Q9 h1 o - }
复制代码 |
|