|
随手翻译了一下,不成体系。搞清楚合成器的第一个输入端口和其他输入端口的区别可能更容易看懂。1 A0 W: W+ \- V% q r( {; e7 z0 m
- /**根据全局表更新合成清单*/& c, K5 o9 D4 ~0 G1 g. q
- string tablename ="订单表"; J( u) p; ^+ [4 X- o; G, X
- /*
' c3 t0 j: s5 _2 |! N - This option should only be used on Combiners.- \* C& U) f. t8 |' d0 P2 T2 o% J
- 这段代码只能用于合成器。
- L( F& N) `8 G9 B - Each column in the GlobalTable is the component list for a single itemtype.: i+ t% R( E) q2 ^% H
- 全局表中的每一列是被合成临时实体的清单。
' \* y( A# [4 l( f& s - The itemtype of the first flowitem to enter is used to find the correct column.) H7 X5 K n1 F8 I1 u9 \" R. v6 ~
- 从第一个输入端口进入的临时实体的类型决定了在全局表中的哪一列去查询合成清单。
. T' s5 R! O2 @5 T - It is assumed that the global table has a row for each input port number 2 and higher.8 X8 s1 G5 M( K. t$ B( @0 f M) F$ ]
- 全局表的每一行都代表着一个编号大于等于2的输入端口。2 i* f C2 w, M
- */. A* ~9 W" b2 X, l: L+ o
- / {% t; t9 k+ J. r: \
- if(port == 1)6 M* f' Y" v+ a' b, G# h
- { //The trigger on entry code fires each time a flow item enters the combiner.
& H& w5 V/ F" e/ C - //For this reason we check to make sure that the port entered is equal to 1 ?. b s. Y( M; A( Z( G* n
- //because only the container will enter through port 1.& G& s- d, F' f% c5 h& r2 U! f; X
- //每个临时实体进入合成器都会激活进入触发,所以必须要检查临时实体是否是从第一个端口进入的。6 k- e) p- G/ v+ d; a
- //只有从第一个端口进入的临时实体才是托盘等容器类临时实体。
* C ^0 d! J7 B" L% g2 k- v" j - //在上文已经解释过,第一个端口进入的临时实体的类型决定了采用全局表中的哪一列来设置合成清单。, Y9 X, C: }; s2 P/ D# 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 contains8 V$ t; B6 }4 E% x/ T/ W' U
- //合成清单以表格的形式存在。我们可以使用cell命令来获取数据节点。0 T1 J( N+ @% {& V/ B) h
- //the number of items to retrieve from each port. Once you know what node contains the information you can use the setnodenum0 @7 |2 g- s1 W% }% N+ f
- //command to set the component list number based on the global table.
4 b8 h! P8 C! X$ P- t# Q( F - //当你知道数据存储于哪个节点之后,你就可以读取全局表中的数据,然后使用setnodenum命令在合成器中设置合成清单。
& ^+ R& H. f2 U. A - ( j7 @1 y# z' ]& ?! D
- treenode thelist = getvarnode(current,"componentlist");2 h; C8 G+ h( z0 X; @, }
- treenode thesum = getvarnode(current,"targetcomponentsum");7 c& f" ?% K6 y1 K7 c `$ a8 ~, T
- //更改合成清单需要对两个数据节点进行设置。一个是componentlist,这个节点有一列数据,记录了从每个端口输入多少个临时实体。
. X) [4 o& o& L, J* l9 a( ]- N. F$ k - //另一个是targetcomponentsum,记录本次打包的临时实体的总数。
* @# q: Z5 ^* T2 R - setnodenum(thesum,0);
4 U ?0 E: |7 ]" m - ; `( p5 i e2 o0 ^+ Y7 G
- for(int index=1; index<=nrows(thelist); index++)3 n+ w) K% b! y3 O$ k# A
- //componentlist以表格的形式存在,只有一列。如果合成器有n个输入端口,那么就有n-1行。(第一个输入端口输入的是容器)7 |$ A6 ?! s z1 t
- {! h% e$ D6 }0 _3 @" j% J; A
- setnodenum(cellrowcolumn(thelist,index,1),gettablenum(tablename,index,getitemtype(item)));/ g2 v1 x7 u9 c! P, q* b+ {
- //第一输入端口进入的临时实体的类型,决定了使用全局表中的哪一列数据。
4 q& o8 D+ H. r0 D$ ? \ - //把该列数据全部读取出来,依次写入componentlist。
s9 q4 H% `0 H3 J& h7 C - inc(thesum,gettablenum(tablename,index,getitemtype(item)));/ ]+ G" i9 ^% I! _
- //同时更新targetcomponentsum的值。5 D6 o1 i/ `% W$ I6 |2 A3 c
- }4 k) F# N) ? J+ r
- }
复制代码 |
|