|
随手翻译了一下,不成体系。搞清楚合成器的第一个输入端口和其他输入端口的区别可能更容易看懂。
/ a3 W, D; m% p' n$ B6 f c/ j- /**根据全局表更新合成清单*/5 c; _! Y( ]# W8 O1 |
- string tablename ="订单表";
3 `) h0 e$ B: S - /*
7 u. t6 q' K3 e# [, W4 K: W - This option should only be used on Combiners.3 M' [4 f* Z a" _+ l& M3 |; o
- 这段代码只能用于合成器。$ D# a5 X% z% v1 d# P3 H
- Each column in the GlobalTable is the component list for a single itemtype.
. \ a4 H9 M, i - 全局表中的每一列是被合成临时实体的清单。
& _% J* G4 l* V - The itemtype of the first flowitem to enter is used to find the correct column.
- Q" [8 C6 @1 P9 S$ {0 i: e - 从第一个输入端口进入的临时实体的类型决定了在全局表中的哪一列去查询合成清单。
( z. |! |- B0 b, Z( H: e' J) Q - It is assumed that the global table has a row for each input port number 2 and higher.2 u9 [; x" n" Z! u$ Z; l
- 全局表的每一行都代表着一个编号大于等于2的输入端口。+ l. I- Q3 W$ p0 {4 U8 }
- */% ~3 P( |3 H6 I+ ]; z
" L) V" J9 F3 K- if(port == 1)) z7 O. d/ `( e9 _5 U I d
- { //The trigger on entry code fires each time a flow item enters the combiner.
- C* J5 J; ^) y V - //For this reason we check to make sure that the port entered is equal to 1
4 e3 D7 F, ]8 L - //because only the container will enter through port 1.
: N/ \5 v+ N+ n" f1 j0 ^; F3 |4 H - //每个临时实体进入合成器都会激活进入触发,所以必须要检查临时实体是否是从第一个端口进入的。$ u0 C# g4 ]/ Q6 W. B) v) z
- //只有从第一个端口进入的临时实体才是托盘等容器类临时实体。
/ y% W5 ^9 R8 {7 E( D - //在上文已经解释过,第一个端口进入的临时实体的类型决定了采用全局表中的哪一列来设置合成清单。
& b) h! \# F5 N% U1 O - //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
8 B- Q: k/ P& o7 O: c2 }2 a - //合成清单以表格的形式存在。我们可以使用cell命令来获取数据节点。
/ A9 U+ `& u# W% z - //the number of items to retrieve from each port. Once you know what node contains the information you can use the setnodenum& }0 E' {% [ m5 w. |0 f$ h
- //command to set the component list number based on the global table.: X0 L; d) g# c3 S
- //当你知道数据存储于哪个节点之后,你就可以读取全局表中的数据,然后使用setnodenum命令在合成器中设置合成清单。
- F' A# Z& W3 D5 @, {: ~6 q
7 l/ k7 R; \4 K& d5 z" q' A- treenode thelist = getvarnode(current,"componentlist");
$ W* F5 P. k) C% j2 I - treenode thesum = getvarnode(current,"targetcomponentsum");
' @6 k7 l5 {2 _: W4 ^% U+ \) y' O - //更改合成清单需要对两个数据节点进行设置。一个是componentlist,这个节点有一列数据,记录了从每个端口输入多少个临时实体。( ~0 F D. c8 Y5 z6 }) V8 t _ \
- //另一个是targetcomponentsum,记录本次打包的临时实体的总数。! ]' ?1 j: q2 o0 R6 N
- setnodenum(thesum,0);. R* c; @( Z1 _0 I5 [
- ; V2 X5 M1 B. a H8 X0 a( M6 P8 Y& [% a9 M3 Q
- for(int index=1; index<=nrows(thelist); index++)
- h/ F1 c2 H7 M4 u1 e - //componentlist以表格的形式存在,只有一列。如果合成器有n个输入端口,那么就有n-1行。(第一个输入端口输入的是容器)
* C, Q6 _! L$ _ A8 M! @/ s# h8 ^ - {
/ ^: ?1 |" U, W/ \ - setnodenum(cellrowcolumn(thelist,index,1),gettablenum(tablename,index,getitemtype(item)));
+ {! |; ~+ A& f: W" M - //第一输入端口进入的临时实体的类型,决定了使用全局表中的哪一列数据。* m* D7 w/ i$ c
- //把该列数据全部读取出来,依次写入componentlist。+ ~7 ?) s- e! b
- inc(thesum,gettablenum(tablename,index,getitemtype(item)));) I, B7 M9 x: ~$ x* g
- //同时更新targetcomponentsum的值。
! m/ u! V2 Q( E- O - }
; x1 X7 ? g" A, x" z - }
复制代码 |
|