|
随手翻译了一下,不成体系。搞清楚合成器的第一个输入端口和其他输入端口的区别可能更容易看懂。
# x* `/ c1 x& G6 s- /**根据全局表更新合成清单*/5 g% v" H7 C; z% X' N
- string tablename ="订单表";
' E( P% |+ x+ P( _7 Q - /*1 D" V8 q' M; H. B& I0 P+ p' C
- This option should only be used on Combiners.
2 w3 o6 X, |& y8 n0 F - 这段代码只能用于合成器。
3 A+ p- r4 S: W9 ] p$ ]. p - Each column in the GlobalTable is the component list for a single itemtype.
( c6 m7 C @* g4 O3 R8 J - 全局表中的每一列是被合成临时实体的清单。
+ E: z- D4 \$ Y* @ C9 [8 p - The itemtype of the first flowitem to enter is used to find the correct column.
' l* [+ C. H) b) B1 H0 U. w+ R& L# R - 从第一个输入端口进入的临时实体的类型决定了在全局表中的哪一列去查询合成清单。
, [2 e) E( W2 o7 ` j+ `. h - It is assumed that the global table has a row for each input port number 2 and higher.3 a% |/ [$ I$ X
- 全局表的每一行都代表着一个编号大于等于2的输入端口。
) u Z9 @# J" n6 L! v. H- z6 f# s - */- Q7 A% f8 M( y$ ]5 ?/ x5 ^! a
- |# b- e2 m: _9 Y% P2 {0 M, E% i
- if(port == 1)
) t! z: ~, a9 [7 _$ q, o# }9 x - { //The trigger on entry code fires each time a flow item enters the combiner.
- w5 U% I, q% G$ `0 Q - //For this reason we check to make sure that the port entered is equal to 13 c2 }% e! _( U4 w3 E4 h, {+ X
- //because only the container will enter through port 1.
# ]0 |2 o; b5 `# x% a& `! O! | - //每个临时实体进入合成器都会激活进入触发,所以必须要检查临时实体是否是从第一个端口进入的。
H& @% _. T8 `' u( S, { - //只有从第一个端口进入的临时实体才是托盘等容器类临时实体。
4 B$ t5 \, u% o& b) P1 Q - //在上文已经解释过,第一个端口进入的临时实体的类型决定了采用全局表中的哪一列来设置合成清单。
/ P& e, b+ O# j# Z. }% d - //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
' b+ ]3 K6 i' J; O8 [ a! x - //合成清单以表格的形式存在。我们可以使用cell命令来获取数据节点。
- i* F( ?/ z7 h7 h" h$ _ - //the number of items to retrieve from each port. Once you know what node contains the information you can use the setnodenum$ K! @" b8 G8 A$ o& m* F) c
- //command to set the component list number based on the global table.6 I1 n9 S2 V: V+ x( y1 Z" I; o# y# t
- //当你知道数据存储于哪个节点之后,你就可以读取全局表中的数据,然后使用setnodenum命令在合成器中设置合成清单。
1 } j" H2 B0 ]9 I - s. ` M, y. `4 y8 g. c- h8 o4 E
- treenode thelist = getvarnode(current,"componentlist");
8 F: \ `2 i5 ^& R! I - treenode thesum = getvarnode(current,"targetcomponentsum");
- z+ p. j5 G* [7 H8 z - //更改合成清单需要对两个数据节点进行设置。一个是componentlist,这个节点有一列数据,记录了从每个端口输入多少个临时实体。
* p" X2 c, U7 I/ c( U4 L - //另一个是targetcomponentsum,记录本次打包的临时实体的总数。/ d* [1 O* s# r3 {) g$ P! [
- setnodenum(thesum,0);
* s: i0 d V0 b, U+ f - + H+ O% q9 r: u" R$ \
- for(int index=1; index<=nrows(thelist); index++)! |2 Z& M& e: D5 O/ [- R8 X4 o
- //componentlist以表格的形式存在,只有一列。如果合成器有n个输入端口,那么就有n-1行。(第一个输入端口输入的是容器)8 I% _. W4 y! N( `1 l9 t& a
- {, b1 W, d/ m% h
- setnodenum(cellrowcolumn(thelist,index,1),gettablenum(tablename,index,getitemtype(item)));4 g' q) g: v4 ?- T* h* g
- //第一输入端口进入的临时实体的类型,决定了使用全局表中的哪一列数据。
( A0 J$ {( p' Y1 i" t - //把该列数据全部读取出来,依次写入componentlist。
( `7 M) w1 P& E1 \: v+ ^9 v - inc(thesum,gettablenum(tablename,index,getitemtype(item)));
o# H3 o9 d0 N" j - //同时更新targetcomponentsum的值。# P; M+ l: p0 o; g3 y1 p9 h
- }7 d* |2 Q# s; \' M/ C6 ?) G
- }
复制代码 |
|