|
随手翻译了一下,不成体系。搞清楚合成器的第一个输入端口和其他输入端口的区别可能更容易看懂。
+ B$ [* v1 F$ V6 R( m0 y4 @- /**根据全局表更新合成清单*/
9 i+ f3 h9 T4 e6 v' z# ] - string tablename ="订单表";0 Z$ t8 [" X; _( J+ P4 U
- /*( W, F3 Y% E9 p1 N
- This option should only be used on Combiners.1 m" _0 q/ P/ M8 n
- 这段代码只能用于合成器。8 ~- l' O! ]# x* @
- Each column in the GlobalTable is the component list for a single itemtype.8 l2 H( u# i- N- L! Y H% _
- 全局表中的每一列是被合成临时实体的清单。, k' `9 o; Y/ Z/ S7 A. w
- The itemtype of the first flowitem to enter is used to find the correct column.4 O+ }6 d& P. Z# j! [" q
- 从第一个输入端口进入的临时实体的类型决定了在全局表中的哪一列去查询合成清单。" U$ j. h2 W2 e0 ?, ]: E6 u
- It is assumed that the global table has a row for each input port number 2 and higher.) ?! p( V$ E+ ~- D2 L/ e1 d. h
- 全局表的每一行都代表着一个编号大于等于2的输入端口。5 D' Y, F4 }% s6 R
- */
, E' a# K1 g3 |8 S - & B# C# B+ x* s4 x6 o' t
- if(port == 1)
$ S4 X5 A$ ? ?1 U- l - { //The trigger on entry code fires each time a flow item enters the combiner.
, D/ p% H6 ]% z" p0 W - //For this reason we check to make sure that the port entered is equal to 1* p+ t6 |& {7 X( x
- //because only the container will enter through port 1.( H: K9 I# J* m9 v9 W+ Y; R
- //每个临时实体进入合成器都会激活进入触发,所以必须要检查临时实体是否是从第一个端口进入的。* ]# V' F) |' \. [* T
- //只有从第一个端口进入的临时实体才是托盘等容器类临时实体。- O* A$ S3 P! D# Y+ V
- //在上文已经解释过,第一个端口进入的临时实体的类型决定了采用全局表中的哪一列来设置合成清单。/ C, W1 P! e, o. @* E3 G/ w- K) {8 E
- //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/ {, p' v& C) @" n
- //合成清单以表格的形式存在。我们可以使用cell命令来获取数据节点。
& H2 C" `" E, I+ A! A9 y2 x! d - //the number of items to retrieve from each port. Once you know what node contains the information you can use the setnodenum
/ l2 {) H8 W) q2 H& r - //command to set the component list number based on the global table.
: k s: P2 m# u0 V1 f( | h - //当你知道数据存储于哪个节点之后,你就可以读取全局表中的数据,然后使用setnodenum命令在合成器中设置合成清单。9 R* u, _( D. W$ B9 l: D
- 5 E8 c, X$ o0 w8 H+ k
- treenode thelist = getvarnode(current,"componentlist");
1 C; c0 e$ U2 d/ C) h- ]: ]0 Z - treenode thesum = getvarnode(current,"targetcomponentsum");4 C/ P, `* o* c& u" ~3 m, u* r6 s; S
- //更改合成清单需要对两个数据节点进行设置。一个是componentlist,这个节点有一列数据,记录了从每个端口输入多少个临时实体。- D$ S( c! ?, _
- //另一个是targetcomponentsum,记录本次打包的临时实体的总数。% H7 Z# S/ I2 u% ?- O
- setnodenum(thesum,0);
3 L" m- _2 n/ [$ u! L9 ^
8 I9 i9 b: b, R" W' `- for(int index=1; index<=nrows(thelist); index++)
% [, W. I- Z# v, f2 q! i3 L" ]3 O( d - //componentlist以表格的形式存在,只有一列。如果合成器有n个输入端口,那么就有n-1行。(第一个输入端口输入的是容器)5 H- E4 `* }8 ?. ~5 J2 K# t5 V
- {( K/ l9 \+ x! U! m/ |. T+ q
- setnodenum(cellrowcolumn(thelist,index,1),gettablenum(tablename,index,getitemtype(item)));
4 g; L$ [% Q0 ~ - //第一输入端口进入的临时实体的类型,决定了使用全局表中的哪一列数据。
& ^8 \5 G _* m# `) w/ a* U3 b - //把该列数据全部读取出来,依次写入componentlist。
' @$ I% B& Z+ B7 U" o; d - inc(thesum,gettablenum(tablename,index,getitemtype(item)));
T7 r' v( F. Z - //同时更新targetcomponentsum的值。
& N7 ~9 Y8 Z3 q5 k- ?* M" Y - }3 a6 H1 X* H9 J5 p
- }
复制代码 |
|