|
随手翻译了一下,不成体系。搞清楚合成器的第一个输入端口和其他输入端口的区别可能更容易看懂。
" Y( M) @3 j/ l! Y* p. ]- /**根据全局表更新合成清单*/ I9 i; v. t6 E8 \* j, s+ Y1 B5 m; V
- string tablename ="订单表";, J h* P: h# C
- /*
8 f9 Z& c! @. |; {1 M5 I- O2 E - This option should only be used on Combiners.
- h5 s+ C4 M0 S. N( n/ ] - 这段代码只能用于合成器。3 ^% x9 h. u$ f0 Q# m
- Each column in the GlobalTable is the component list for a single itemtype.
" p2 z, P$ ~2 X1 m1 D - 全局表中的每一列是被合成临时实体的清单。( e. |+ @: d" A9 X7 ?! i# x o& u
- The itemtype of the first flowitem to enter is used to find the correct column.
, v9 N5 m( K- Z8 n2 x G - 从第一个输入端口进入的临时实体的类型决定了在全局表中的哪一列去查询合成清单。
8 l! H- z( f8 O - It is assumed that the global table has a row for each input port number 2 and higher.( L+ M# y q2 O: `5 t
- 全局表的每一行都代表着一个编号大于等于2的输入端口。9 I" |1 w6 ?9 b& g8 ^
- */
/ z3 F% e! K* ?4 w
$ Z7 i2 {3 t( G+ J: d" I- if(port == 1)5 o2 v3 t+ [5 ~
- { //The trigger on entry code fires each time a flow item enters the combiner.
& A! @! H5 |; N - //For this reason we check to make sure that the port entered is equal to 1
4 b7 u5 f! X3 P3 E$ g. f$ s - //because only the container will enter through port 1.2 ~# |# m$ O' l8 \9 {$ X! F7 y; l) ^
- //每个临时实体进入合成器都会激活进入触发,所以必须要检查临时实体是否是从第一个端口进入的。
4 ~/ w8 J* t4 I; O2 J( b8 ` - //只有从第一个端口进入的临时实体才是托盘等容器类临时实体。, w+ a4 I4 G9 \( x
- //在上文已经解释过,第一个端口进入的临时实体的类型决定了采用全局表中的哪一列来设置合成清单。
7 L0 ?! o' w% [7 T# x; h3 J; u - //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
9 X# d+ _6 k2 h0 \ - //合成清单以表格的形式存在。我们可以使用cell命令来获取数据节点。- o |( X6 s' Y2 _% U
- //the number of items to retrieve from each port. Once you know what node contains the information you can use the setnodenum
, z$ K* v" { Y; x8 n1 b4 x" x - //command to set the component list number based on the global table.' ~* N) E- k, Z+ |- ]4 R/ A$ ?
- //当你知道数据存储于哪个节点之后,你就可以读取全局表中的数据,然后使用setnodenum命令在合成器中设置合成清单。2 p) J4 E) I4 [, ]: d2 X6 U4 j+ a
9 V1 C1 g; E! o5 k) z- treenode thelist = getvarnode(current,"componentlist");
$ {& S) P! @" S F) v - treenode thesum = getvarnode(current,"targetcomponentsum");4 n. {$ J3 d; F( R* e: y7 \( I' F
- //更改合成清单需要对两个数据节点进行设置。一个是componentlist,这个节点有一列数据,记录了从每个端口输入多少个临时实体。
! Z$ q$ @# P: h! N! q2 c$ H2 [" p - //另一个是targetcomponentsum,记录本次打包的临时实体的总数。
% S$ J9 \2 d/ l* r. Y - setnodenum(thesum,0);! P& k/ ?% z5 P/ o7 N- K3 s) s+ a
* V. d1 v* I3 B& U/ t6 O- for(int index=1; index<=nrows(thelist); index++)
8 z) h3 [! W" _ - //componentlist以表格的形式存在,只有一列。如果合成器有n个输入端口,那么就有n-1行。(第一个输入端口输入的是容器)
2 J, x. Y6 _* f0 p) O) W - {* g3 s# Y6 P7 x; c
- setnodenum(cellrowcolumn(thelist,index,1),gettablenum(tablename,index,getitemtype(item)));
3 ^0 Z: N/ L+ _, i+ h( D - //第一输入端口进入的临时实体的类型,决定了使用全局表中的哪一列数据。4 b( n7 b1 v8 S4 N A7 o
- //把该列数据全部读取出来,依次写入componentlist。
5 w; |5 r# l# m - inc(thesum,gettablenum(tablename,index,getitemtype(item)));
) r, m. l* C3 T7 S - //同时更新targetcomponentsum的值。+ \( S) t. P" U! _# Y8 s
- }
% [# Z4 h, E+ `4 o - }
复制代码 |
|