|
随手翻译了一下,不成体系。搞清楚合成器的第一个输入端口和其他输入端口的区别可能更容易看懂。, Q# U" n' J; [! u$ W6 {
- /**根据全局表更新合成清单*/6 `% {6 i. I; j0 k; n. @
- string tablename ="订单表";
6 j1 A" w, k2 n3 F! X& e+ I - /* B F% u6 v' w
- This option should only be used on Combiners.
* _3 E0 p( N* i* [) M8 O - 这段代码只能用于合成器。
' T' C* E8 H: C9 _1 L6 H8 f - Each column in the GlobalTable is the component list for a single itemtype. @; A2 r8 v- i( r2 O+ U
- 全局表中的每一列是被合成临时实体的清单。
1 f3 w6 A: r3 \( z; J* ` - The itemtype of the first flowitem to enter is used to find the correct column.# s$ h! {4 H+ D$ a2 E j( Y% `
- 从第一个输入端口进入的临时实体的类型决定了在全局表中的哪一列去查询合成清单。7 x( B) r( K8 g* l
- It is assumed that the global table has a row for each input port number 2 and higher.. K' W' x" c o% V
- 全局表的每一行都代表着一个编号大于等于2的输入端口。
: d) j( N8 b g" g& D - */. C% R/ e) N( \8 k: o. h
. b- Q" g) g& p9 r/ Z3 [- if(port == 1)
6 D5 f( s, p }$ a+ p3 H" ] - { //The trigger on entry code fires each time a flow item enters the combiner.
: b9 L) h" @+ p4 C, U - //For this reason we check to make sure that the port entered is equal to 1, [8 q* e/ _' m$ i
- //because only the container will enter through port 1.
3 {! V! N( Q+ i2 B - //每个临时实体进入合成器都会激活进入触发,所以必须要检查临时实体是否是从第一个端口进入的。) F; r& t, p1 N2 K! C7 K
- //只有从第一个端口进入的临时实体才是托盘等容器类临时实体。
: m/ y; ~0 C2 R+ a" u; U - //在上文已经解释过,第一个端口进入的临时实体的类型决定了采用全局表中的哪一列来设置合成清单。
+ f# C3 J+ M2 q. O% s f* n! T- X* C - //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 contains1 X5 l3 ~2 R/ @) h# F8 v u/ U4 I
- //合成清单以表格的形式存在。我们可以使用cell命令来获取数据节点。- T: b6 G( y8 b
- //the number of items to retrieve from each port. Once you know what node contains the information you can use the setnodenum
5 Z6 S0 O3 u8 e' c# R - //command to set the component list number based on the global table.
# q3 S, E3 M; w/ b: C1 ^ - //当你知道数据存储于哪个节点之后,你就可以读取全局表中的数据,然后使用setnodenum命令在合成器中设置合成清单。8 w7 G4 g5 y* c/ p$ ?
- 9 |: @2 I( g/ t Z {7 ?
- treenode thelist = getvarnode(current,"componentlist");; v* m) J* n2 m
- treenode thesum = getvarnode(current,"targetcomponentsum");4 }. }6 `4 K3 I
- //更改合成清单需要对两个数据节点进行设置。一个是componentlist,这个节点有一列数据,记录了从每个端口输入多少个临时实体。
& s' }3 ^# X2 B7 `5 v2 @/ \5 q - //另一个是targetcomponentsum,记录本次打包的临时实体的总数。
+ \: @1 A; R8 L0 Y! n$ T! l - setnodenum(thesum,0);( q7 e/ f: m, T: \
- 4 r* g. U" |6 E
- for(int index=1; index<=nrows(thelist); index++)
% Q! ~3 s! C/ l; r+ v6 M0 N - //componentlist以表格的形式存在,只有一列。如果合成器有n个输入端口,那么就有n-1行。(第一个输入端口输入的是容器)
/ G8 Y; p) `. H' h3 t. J; k* [% S+ [ - {( @( M- _* U' ]3 K8 |/ s
- setnodenum(cellrowcolumn(thelist,index,1),gettablenum(tablename,index,getitemtype(item)));- D# Z2 q2 `5 ^
- //第一输入端口进入的临时实体的类型,决定了使用全局表中的哪一列数据。7 ~% L; O* @+ ^- P+ q& G( i
- //把该列数据全部读取出来,依次写入componentlist。
7 V; z, D! I4 z8 ~7 I& }$ V$ f - inc(thesum,gettablenum(tablename,index,getitemtype(item)));& V+ q' ^" ?0 x" H
- //同时更新targetcomponentsum的值。8 }' z# {+ V& C% e _
- }/ K: I9 j$ C& p) a- v6 g8 B: K6 c' [$ F
- }
复制代码 |
|