|
随手翻译了一下,不成体系。搞清楚合成器的第一个输入端口和其他输入端口的区别可能更容易看懂。
# s) U7 _# V6 v- /**根据全局表更新合成清单*/( N$ K3 F& E* t5 P! B( i
- string tablename ="订单表";
) }. \& t0 D C a8 u* _9 W! y - /*7 Q* D7 w1 e" e
- This option should only be used on Combiners.. a+ D, \# k- ~: _ S, N
- 这段代码只能用于合成器。
" h; Q$ j, {2 @; r; E- E6 M - Each column in the GlobalTable is the component list for a single itemtype.
3 h( }8 v: m) p - 全局表中的每一列是被合成临时实体的清单。! ]' M: Q6 {- \
- The itemtype of the first flowitem to enter is used to find the correct column.- Z8 f! e1 m( C( ^* p7 z( M! J7 [
- 从第一个输入端口进入的临时实体的类型决定了在全局表中的哪一列去查询合成清单。
5 F9 e1 f0 H+ n+ M, O - It is assumed that the global table has a row for each input port number 2 and higher.
1 h: I9 ~% C+ w: `$ ]' p2 _' e - 全局表的每一行都代表着一个编号大于等于2的输入端口。
% X5 e" O( @1 y* |+ ^7 d9 r9 Q1 E - */
! l$ E+ L* C$ @- h - ) k; ?8 g2 Z7 I/ T7 T7 U
- if(port == 1)
2 t% d; W2 b {+ d7 E( Y - { //The trigger on entry code fires each time a flow item enters the combiner.; V0 ]4 T( Z7 ~4 K
- //For this reason we check to make sure that the port entered is equal to 1
8 G* j; z$ s, `+ a, n - //because only the container will enter through port 1.# f3 y* g' I' C2 S$ k; h/ a
- //每个临时实体进入合成器都会激活进入触发,所以必须要检查临时实体是否是从第一个端口进入的。
( ~9 Z9 S l0 P/ h* u. s, j3 Z( Z2 y - //只有从第一个端口进入的临时实体才是托盘等容器类临时实体。
. Y1 S1 G$ Z2 K% ?2 W1 N - //在上文已经解释过,第一个端口进入的临时实体的类型决定了采用全局表中的哪一列来设置合成清单。, `$ ^! b: K' S$ u* A
- //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! c9 [$ _, U) C& q) K7 N6 x
- //合成清单以表格的形式存在。我们可以使用cell命令来获取数据节点。
" C m; z3 j% Q* V8 L; `9 ~ - //the number of items to retrieve from each port. Once you know what node contains the information you can use the setnodenum
5 w* U' I1 Y4 q* t' X - //command to set the component list number based on the global table.
6 f( U7 T6 k# g2 F9 c8 V - //当你知道数据存储于哪个节点之后,你就可以读取全局表中的数据,然后使用setnodenum命令在合成器中设置合成清单。5 X0 e$ x. j. E" U' q' v
- # N2 ? n; n: F6 z4 F( K
- treenode thelist = getvarnode(current,"componentlist");& ^* K4 Q4 `4 y, V" n; o
- treenode thesum = getvarnode(current,"targetcomponentsum");
+ d, @4 ?+ i% W, P( S( f - //更改合成清单需要对两个数据节点进行设置。一个是componentlist,这个节点有一列数据,记录了从每个端口输入多少个临时实体。
# t2 z$ i# u8 i1 ] - //另一个是targetcomponentsum,记录本次打包的临时实体的总数。6 C1 c, s- h' f% V# U0 S' z( a
- setnodenum(thesum,0);
" H; K; \- {5 h& D7 Y! W
$ h8 j8 T6 |8 R# |, o' l1 e- for(int index=1; index<=nrows(thelist); index++)
) ^, Y# d5 W4 W$ K - //componentlist以表格的形式存在,只有一列。如果合成器有n个输入端口,那么就有n-1行。(第一个输入端口输入的是容器)
: o: z* l1 U& B7 B - {& |! X& z- K* I, G7 y, Y
- setnodenum(cellrowcolumn(thelist,index,1),gettablenum(tablename,index,getitemtype(item)));
* x: t+ q( a0 c( u% a - //第一输入端口进入的临时实体的类型,决定了使用全局表中的哪一列数据。2 r' Y/ r/ L+ u o' O4 H1 W- A
- //把该列数据全部读取出来,依次写入componentlist。
/ G* I: @ U) T) ?, }5 X; q {, M9 { - inc(thesum,gettablenum(tablename,index,getitemtype(item)));
, ~8 h1 I( Y/ f" p& X - //同时更新targetcomponentsum的值。. \9 X$ h9 F# A$ A1 V p! f
- }/ ~7 ?) L0 q) n6 I# i8 V
- }
复制代码 |
|