|
随手翻译了一下,不成体系。搞清楚合成器的第一个输入端口和其他输入端口的区别可能更容易看懂。, c% J9 r8 f1 v/ v" P) t
- /**根据全局表更新合成清单*/
0 J8 T) X2 @: d; ^- |( O - string tablename ="订单表";. ~* a+ A7 L8 m' s/ h
- /*( D7 }3 f+ x8 R; e" z: j
- This option should only be used on Combiners.
" u! m4 {. @& }2 B0 l0 t; r7 u9 O - 这段代码只能用于合成器。' }3 I* G J* h" E( j! d7 u8 w; H
- Each column in the GlobalTable is the component list for a single itemtype.$ \8 k0 z) r- o( v, p2 y3 _
- 全局表中的每一列是被合成临时实体的清单。
, R5 l: Y8 M- S {8 Q2 U# N, J - The itemtype of the first flowitem to enter is used to find the correct column.
8 X/ X" `3 R6 d/ u6 ? - 从第一个输入端口进入的临时实体的类型决定了在全局表中的哪一列去查询合成清单。7 p; g8 D1 ]$ e9 R
- It is assumed that the global table has a row for each input port number 2 and higher.: N; s# B. x% s* x. T1 y6 X5 s" {& @
- 全局表的每一行都代表着一个编号大于等于2的输入端口。! ~: A9 Q/ T1 Q; |, F
- */
' }( |, `4 D3 ?% ] c# ]2 k4 b9 v - 7 q( @0 U. R9 A
- if(port == 1); z6 S) s6 n% w4 K! D9 M7 ^
- { //The trigger on entry code fires each time a flow item enters the combiner.
1 d$ H0 }0 r" H+ t& p - //For this reason we check to make sure that the port entered is equal to 1# d4 J, s9 a% S5 W7 i0 `$ ~
- //because only the container will enter through port 1.7 z. J" e* e1 Q7 k8 {; S5 w
- //每个临时实体进入合成器都会激活进入触发,所以必须要检查临时实体是否是从第一个端口进入的。$ c+ @. x" T6 Y7 a. @- ~1 W
- //只有从第一个端口进入的临时实体才是托盘等容器类临时实体。
. _: U# a& q9 X7 ]* f% v% F9 B9 t - //在上文已经解释过,第一个端口进入的临时实体的类型决定了采用全局表中的哪一列来设置合成清单。
+ a8 h1 W; t& s6 ] - //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# S" B* Y! Q4 Y3 J" E
- //合成清单以表格的形式存在。我们可以使用cell命令来获取数据节点。
0 i9 [% {+ d& p' S. S( `) P) E - //the number of items to retrieve from each port. Once you know what node contains the information you can use the setnodenum
6 k) }5 v! f8 r! a% [ - //command to set the component list number based on the global table.
5 F/ j `+ k7 B& l7 _ - //当你知道数据存储于哪个节点之后,你就可以读取全局表中的数据,然后使用setnodenum命令在合成器中设置合成清单。7 B8 }/ O, ]/ c; d8 ]' V! }* @
- ?: {" G, j' k! a2 q7 v3 {& `* e- treenode thelist = getvarnode(current,"componentlist");1 Z9 K* `2 ?, U' |
- treenode thesum = getvarnode(current,"targetcomponentsum");% L, T7 ]' i! U; T
- //更改合成清单需要对两个数据节点进行设置。一个是componentlist,这个节点有一列数据,记录了从每个端口输入多少个临时实体。
0 N3 f* _3 w1 J/ {6 o - //另一个是targetcomponentsum,记录本次打包的临时实体的总数。
5 m6 b0 W! ?$ l, Q; F - setnodenum(thesum,0);& l4 T3 @- R& w$ F( A: N4 t
- 9 P, O# u1 l9 Y& n, N
- for(int index=1; index<=nrows(thelist); index++)
! k( e* g: O: i' I! ?& B - //componentlist以表格的形式存在,只有一列。如果合成器有n个输入端口,那么就有n-1行。(第一个输入端口输入的是容器)
6 @! n7 q, Q( v" F9 d& | - {
7 M$ i* [5 b6 |5 W7 [# w0 Z* D - setnodenum(cellrowcolumn(thelist,index,1),gettablenum(tablename,index,getitemtype(item)));
) h4 d4 ^7 y2 a) l - //第一输入端口进入的临时实体的类型,决定了使用全局表中的哪一列数据。
M3 ~; O% X8 U: s6 J7 t - //把该列数据全部读取出来,依次写入componentlist。
8 q$ H% {. ?2 C - inc(thesum,gettablenum(tablename,index,getitemtype(item)));7 t' A' d+ I# [" |
- //同时更新targetcomponentsum的值。1 S. \, y" O: M0 G
- }
8 y# ~ w8 i8 |1 g - }
复制代码 |
|