|
随手翻译了一下,不成体系。搞清楚合成器的第一个输入端口和其他输入端口的区别可能更容易看懂。
2 C+ U9 m( e- M1 i9 C- /**根据全局表更新合成清单*/
" D u6 `9 M- F0 p - string tablename ="订单表";/ i- R' L+ f/ H- d u+ X0 h3 F
- /*7 E+ u! P& M6 D% z% d
- This option should only be used on Combiners.
' y0 A% C3 k, t. m0 v" B - 这段代码只能用于合成器。) E9 z" L {" M! t6 q& H1 ]/ ^
- Each column in the GlobalTable is the component list for a single itemtype.
* y( o/ s! V/ ~9 Y9 ?" R& w+ {, c - 全局表中的每一列是被合成临时实体的清单。
2 R9 P8 ^; o$ q1 u: T - The itemtype of the first flowitem to enter is used to find the correct column.
( \% ~5 r2 R: U; L - 从第一个输入端口进入的临时实体的类型决定了在全局表中的哪一列去查询合成清单。
& l- }8 |# {# s. O# J# W; } - It is assumed that the global table has a row for each input port number 2 and higher.6 U8 h1 I! n5 F; p7 `. X
- 全局表的每一行都代表着一个编号大于等于2的输入端口。) S* x v F6 N0 \' s" r
- */
; r4 Q( r) a6 i5 l o, k, O
- a2 f3 h d& K7 n% |; [- if(port == 1)
) r2 J ~& Y9 p, u* z' i - { //The trigger on entry code fires each time a flow item enters the combiner.
6 W' u! L- R2 W9 N% i - //For this reason we check to make sure that the port entered is equal to 1
& \" D6 H! u9 F0 h. B. z - //because only the container will enter through port 1.5 F. T& \% j. y/ `: P$ q
- //每个临时实体进入合成器都会激活进入触发,所以必须要检查临时实体是否是从第一个端口进入的。
9 P" f1 D; P5 [% @ L - //只有从第一个端口进入的临时实体才是托盘等容器类临时实体。6 k4 F3 \, j/ z- N/ B1 V: B+ Y7 m
- //在上文已经解释过,第一个端口进入的临时实体的类型决定了采用全局表中的哪一列来设置合成清单。
9 I, R* E+ L( K9 ~0 o; Q* r1 ~ - //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; `4 o7 u, l$ C# a* [/ c
- //合成清单以表格的形式存在。我们可以使用cell命令来获取数据节点。" v9 O2 K, d q' q& D* G. P0 J V
- //the number of items to retrieve from each port. Once you know what node contains the information you can use the setnodenum: m& a9 e- z8 o6 w5 o; c2 i
- //command to set the component list number based on the global table.
# U6 g/ w6 G% Q' _& h, O - //当你知道数据存储于哪个节点之后,你就可以读取全局表中的数据,然后使用setnodenum命令在合成器中设置合成清单。
6 H0 f' W4 o3 b% z. u
6 D* l! X& z9 c* j- treenode thelist = getvarnode(current,"componentlist");
1 V) `# ?$ n+ l - treenode thesum = getvarnode(current,"targetcomponentsum");
# ]& W. w: h, k4 a6 ^2 O - //更改合成清单需要对两个数据节点进行设置。一个是componentlist,这个节点有一列数据,记录了从每个端口输入多少个临时实体。6 j6 _. ^% Y' W& d0 r# N
- //另一个是targetcomponentsum,记录本次打包的临时实体的总数。
. P0 s$ A) C+ H. q - setnodenum(thesum,0);
. ]! K+ b7 b& S: \$ ~
: b2 _3 Z' y; O" X7 ?- for(int index=1; index<=nrows(thelist); index++)- X2 q2 |& J! l, p* C
- //componentlist以表格的形式存在,只有一列。如果合成器有n个输入端口,那么就有n-1行。(第一个输入端口输入的是容器)
( w Q$ Y. \- [# y( g- p% e0 t, I! |2 B - {. J6 m- s7 l& w7 Z. t" U Y0 x
- setnodenum(cellrowcolumn(thelist,index,1),gettablenum(tablename,index,getitemtype(item)));
: c/ z' \$ ^% G - //第一输入端口进入的临时实体的类型,决定了使用全局表中的哪一列数据。
1 E( }+ A, H3 G6 ^ - //把该列数据全部读取出来,依次写入componentlist。7 f# n1 d# w2 c9 w0 G
- inc(thesum,gettablenum(tablename,index,getitemtype(item)));# }8 O1 R5 N' h% q
- //同时更新targetcomponentsum的值。
9 }( }" j% v5 S) P6 T3 S$ d - }
# h* O# ] _6 K/ t0 z' \ - }
复制代码 |
|