|
随手翻译了一下,不成体系。搞清楚合成器的第一个输入端口和其他输入端口的区别可能更容易看懂。1 h7 S3 E; x/ {2 J0 r2 z) j
- /**根据全局表更新合成清单*/: w) _0 j8 s/ M
- string tablename ="订单表";, q2 r- V1 ?9 l" C
- /*
* r4 w$ P8 @2 q - This option should only be used on Combiners.( N" Y2 D8 @' l/ s8 x3 O. W
- 这段代码只能用于合成器。
2 } B- u# N. f7 z a6 s. x; I0 Y - Each column in the GlobalTable is the component list for a single itemtype.
( Y3 D7 @& I; @ - 全局表中的每一列是被合成临时实体的清单。
4 @' e! z$ C+ |1 c: \3 | - The itemtype of the first flowitem to enter is used to find the correct column.2 F/ N' ~8 x* R. }% A$ T1 ~6 P6 Z
- 从第一个输入端口进入的临时实体的类型决定了在全局表中的哪一列去查询合成清单。4 g+ N2 r" f0 s* _
- It is assumed that the global table has a row for each input port number 2 and higher.# h5 x4 p! }: {% M) p2 O
- 全局表的每一行都代表着一个编号大于等于2的输入端口。, b, t! d. m0 \/ l
- */7 a! h. t* J4 z, m4 ~" j0 D) S" O
- 7 O g! G5 z( Q, {! ^3 Q
- if(port == 1)* r7 Q% b! c9 q
- { //The trigger on entry code fires each time a flow item enters the combiner.* [9 n4 g) u9 p+ ?4 G. s% |
- //For this reason we check to make sure that the port entered is equal to 1( |* }$ U- |* E5 {
- //because only the container will enter through port 1.
, g" V% B5 }$ Q% S! J: U! } - //每个临时实体进入合成器都会激活进入触发,所以必须要检查临时实体是否是从第一个端口进入的。" H6 p' q$ W1 l+ q% M
- //只有从第一个端口进入的临时实体才是托盘等容器类临时实体。
9 k! G/ C: R2 }6 e0 Z$ c - //在上文已经解释过,第一个端口进入的临时实体的类型决定了采用全局表中的哪一列来设置合成清单。) r1 h8 U# x* I( _* ?$ P, ~$ i, p
- //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% q) p9 X/ n" C! t
- //合成清单以表格的形式存在。我们可以使用cell命令来获取数据节点。; M4 ?1 m# U6 s7 _
- //the number of items to retrieve from each port. Once you know what node contains the information you can use the setnodenum
( e4 ?, r- N7 o7 } - //command to set the component list number based on the global table.
7 B$ B( e6 C* W2 \+ ~8 Q - //当你知道数据存储于哪个节点之后,你就可以读取全局表中的数据,然后使用setnodenum命令在合成器中设置合成清单。$ h" J% v# E [$ M, j e
`. \! ~, d+ U, f- treenode thelist = getvarnode(current,"componentlist");8 t" s( G. p! k5 _, m& f
- treenode thesum = getvarnode(current,"targetcomponentsum");3 A: G+ P- Y7 B9 m2 ]
- //更改合成清单需要对两个数据节点进行设置。一个是componentlist,这个节点有一列数据,记录了从每个端口输入多少个临时实体。9 z6 S! J) b" A; \1 Q/ l( _- [) i5 M
- //另一个是targetcomponentsum,记录本次打包的临时实体的总数。
6 h% O: E" O; H% a, V3 P - setnodenum(thesum,0);
8 }9 P" e( u$ s( H3 [2 U - / `' ~, p2 W; @
- for(int index=1; index<=nrows(thelist); index++): R" q1 j0 r2 X h% S7 r
- //componentlist以表格的形式存在,只有一列。如果合成器有n个输入端口,那么就有n-1行。(第一个输入端口输入的是容器)0 |% T8 q2 o& W; ]) r
- {
. D8 k% ~3 U" W' _ - setnodenum(cellrowcolumn(thelist,index,1),gettablenum(tablename,index,getitemtype(item)));
7 W& L8 P1 Y+ |2 k& s, ]; y - //第一输入端口进入的临时实体的类型,决定了使用全局表中的哪一列数据。
! S7 |, d8 T; T' J0 F - //把该列数据全部读取出来,依次写入componentlist。! q/ [, u) F. m
- inc(thesum,gettablenum(tablename,index,getitemtype(item)));
. {/ @5 t7 }7 E9 A, w5 {- `: } - //同时更新targetcomponentsum的值。
+ A. s- A/ K. o8 Q" t) O - }8 G+ G2 {* m+ |4 U+ b8 I! T* c
- }
复制代码 |
|