|
随手翻译了一下,不成体系。搞清楚合成器的第一个输入端口和其他输入端口的区别可能更容易看懂。
8 M* [2 ^: R' B6 ^( J# I- /**根据全局表更新合成清单*/
, Z; \7 G/ L# q h/ q - string tablename ="订单表";
2 h k2 r) C; V6 {- B - /*0 m' `) T3 l9 f* D2 j$ a
- This option should only be used on Combiners.
& x8 l! d+ u. D* q% I2 F$ I - 这段代码只能用于合成器。* K) G+ G3 y5 `$ m
- Each column in the GlobalTable is the component list for a single itemtype.: s; z3 D+ a* g; E9 a J
- 全局表中的每一列是被合成临时实体的清单。: _6 I$ ]/ Z% [
- The itemtype of the first flowitem to enter is used to find the correct column.
* B2 Q& F7 C4 b9 ]0 r - 从第一个输入端口进入的临时实体的类型决定了在全局表中的哪一列去查询合成清单。. E( I, K" l1 ^0 ]5 g* Q+ |" `0 f
- It is assumed that the global table has a row for each input port number 2 and higher.2 l4 X- ~3 j' R5 X
- 全局表的每一行都代表着一个编号大于等于2的输入端口。9 H" s) Y: F- Z7 t! U# ?
- */. g8 j' p* Y* }! P% P" b
$ c3 h, U& K/ \) I- if(port == 1)
- g5 l7 i; ~' R/ E- x - { //The trigger on entry code fires each time a flow item enters the combiner.
- u6 Q" n3 D1 {/ N6 c: C0 @% a - //For this reason we check to make sure that the port entered is equal to 1
: i/ t0 P7 R, r, Q0 g - //because only the container will enter through port 1.+ y4 E F. l' n2 e5 B" k( B
- //每个临时实体进入合成器都会激活进入触发,所以必须要检查临时实体是否是从第一个端口进入的。
" c* F# z. l+ W - //只有从第一个端口进入的临时实体才是托盘等容器类临时实体。
1 q9 C. G( j' h: l - //在上文已经解释过,第一个端口进入的临时实体的类型决定了采用全局表中的哪一列来设置合成清单。
% @- L- J- S e8 Q; n5 p3 I# ^ - //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
* }2 h: X% X- b( z4 W3 t - //合成清单以表格的形式存在。我们可以使用cell命令来获取数据节点。
( f& T# ?* p: Y) ^ - //the number of items to retrieve from each port. Once you know what node contains the information you can use the setnodenum
' J0 \( t1 H) A - //command to set the component list number based on the global table.$ P* {2 I2 p0 o' p8 E/ [" e# U
- //当你知道数据存储于哪个节点之后,你就可以读取全局表中的数据,然后使用setnodenum命令在合成器中设置合成清单。
+ R( @' E) ^- \" u9 j) ^) G
& I$ m% V3 [9 K0 A1 w- treenode thelist = getvarnode(current,"componentlist");8 c6 @; R5 d: [& o3 \6 W
- treenode thesum = getvarnode(current,"targetcomponentsum");4 @7 G, p4 ` S+ k4 u( _- c6 e
- //更改合成清单需要对两个数据节点进行设置。一个是componentlist,这个节点有一列数据,记录了从每个端口输入多少个临时实体。$ T9 ?4 b9 D; L& U' D
- //另一个是targetcomponentsum,记录本次打包的临时实体的总数。8 w" x1 a0 T0 I4 r/ G+ P
- setnodenum(thesum,0);
! E& h# m u. x; I; l; p" G) t - 9 Q4 }) n# n3 J8 r1 d) h E- l
- for(int index=1; index<=nrows(thelist); index++)
* N% v s% [3 t9 _+ @9 N - //componentlist以表格的形式存在,只有一列。如果合成器有n个输入端口,那么就有n-1行。(第一个输入端口输入的是容器)' J. R+ N% ]( I! B% Y
- {
6 }2 l" d* w+ g' @) K/ r& s - setnodenum(cellrowcolumn(thelist,index,1),gettablenum(tablename,index,getitemtype(item)));
! }- f Q! p+ l' d - //第一输入端口进入的临时实体的类型,决定了使用全局表中的哪一列数据。* T% k, E0 g, N* h* C: x. L$ q
- //把该列数据全部读取出来,依次写入componentlist。1 e$ A/ S. v$ ?3 |4 h( @9 G
- inc(thesum,gettablenum(tablename,index,getitemtype(item)));
. M( s9 Y" g$ ?2 w - //同时更新targetcomponentsum的值。6 V' L# s% g$ H. N
- }
9 L6 D; I; @* C4 w4 l - }
复制代码 |
|