|
随手翻译了一下,不成体系。搞清楚合成器的第一个输入端口和其他输入端口的区别可能更容易看懂。
$ b4 _: ]4 t3 n+ o- /**根据全局表更新合成清单*/0 P" n0 O4 ~6 Y0 g
- string tablename ="订单表";
1 R- j" l- j2 d( `* I, ]7 p0 o, y6 F - /*$ u! V* ?0 m/ y; p
- This option should only be used on Combiners.$ \% w& ~. `7 T- ]% N+ \7 O
- 这段代码只能用于合成器。
* W7 L% z: M6 I" Y- U! z - Each column in the GlobalTable is the component list for a single itemtype.
7 _1 L" q' q7 S: m( T - 全局表中的每一列是被合成临时实体的清单。
7 _6 G$ Z) g7 j5 ~: r - The itemtype of the first flowitem to enter is used to find the correct column.
" s# i3 F3 ~. c& u3 y: K! n+ h; h - 从第一个输入端口进入的临时实体的类型决定了在全局表中的哪一列去查询合成清单。
5 {3 |5 `$ o3 H7 T* u5 D - It is assumed that the global table has a row for each input port number 2 and higher.
( p \# p, O1 c$ Y5 S7 b' v9 m - 全局表的每一行都代表着一个编号大于等于2的输入端口。, D) R2 Q2 Q7 e+ x& j0 {
- */4 \0 C! @2 N# g0 ?
- $ P& z, I( d2 d6 t
- if(port == 1)! k- `/ w! e$ _! t
- { //The trigger on entry code fires each time a flow item enters the combiner.9 A6 x. C5 {0 u& ~8 w
- //For this reason we check to make sure that the port entered is equal to 1
' z- u' [: @& T+ P" }% G5 z% r - //because only the container will enter through port 1.( l# ~( ~; h- ?
- //每个临时实体进入合成器都会激活进入触发,所以必须要检查临时实体是否是从第一个端口进入的。; Q0 X" j# y7 g4 m" H) `2 _2 {
- //只有从第一个端口进入的临时实体才是托盘等容器类临时实体。0 F# A2 g! c, d+ X9 ], l. A* r- z
- //在上文已经解释过,第一个端口进入的临时实体的类型决定了采用全局表中的哪一列来设置合成清单。
; H+ m/ n7 L7 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 contains& a# k6 B! U! _0 q) q0 P( G
- //合成清单以表格的形式存在。我们可以使用cell命令来获取数据节点。1 y3 q, F" C3 l
- //the number of items to retrieve from each port. Once you know what node contains the information you can use the setnodenum5 Q2 w6 | S! ~ B8 X( P5 c0 z
- //command to set the component list number based on the global table.5 z5 [# Z1 {& y. x, T7 ?
- //当你知道数据存储于哪个节点之后,你就可以读取全局表中的数据,然后使用setnodenum命令在合成器中设置合成清单。
a' ?. v3 c8 Z7 a7 j
5 U) Q( I4 i: S- treenode thelist = getvarnode(current,"componentlist");" h; W( r# ^8 @% ~7 O( B# v
- treenode thesum = getvarnode(current,"targetcomponentsum");
1 s9 Z2 L- h" a/ g" N* d9 e - //更改合成清单需要对两个数据节点进行设置。一个是componentlist,这个节点有一列数据,记录了从每个端口输入多少个临时实体。
+ _$ D O- x, n - //另一个是targetcomponentsum,记录本次打包的临时实体的总数。
% T. v! s; ~: k' E5 T! h9 {* |/ g# n - setnodenum(thesum,0);2 A% i- K# u a% \, f8 \
- - V$ o4 |6 P- g# h9 T/ u8 O6 {
- for(int index=1; index<=nrows(thelist); index++)
& _3 v& ]* R, ~* u! s - //componentlist以表格的形式存在,只有一列。如果合成器有n个输入端口,那么就有n-1行。(第一个输入端口输入的是容器)
7 m" s m( `+ }; e% C- p- g1 S" J - {1 ~; r& H2 k5 V
- setnodenum(cellrowcolumn(thelist,index,1),gettablenum(tablename,index,getitemtype(item)));
% Q5 d* X* J% m+ o0 T - //第一输入端口进入的临时实体的类型,决定了使用全局表中的哪一列数据。
4 y4 q) Z& ]" M - //把该列数据全部读取出来,依次写入componentlist。( Q( K$ t3 X& b$ t4 @! P1 X
- inc(thesum,gettablenum(tablename,index,getitemtype(item)));5 I# w/ C& D6 E
- //同时更新targetcomponentsum的值。
3 f6 }) Z+ _; U# C# e - }7 L# Y) \$ Y8 `, M* t; u
- }
复制代码 |
|