|
随手翻译了一下,不成体系。搞清楚合成器的第一个输入端口和其他输入端口的区别可能更容易看懂。
$ H5 |- R; \* T- x7 V' q- /**根据全局表更新合成清单*/. M9 q% f F( R$ f
- string tablename ="订单表";% \) v- ~) Q. u1 U0 r" K
- /*3 g6 ~5 X* P) w+ f% e# S, {( D
- This option should only be used on Combiners.4 ]# B: ?! F. y% |
- 这段代码只能用于合成器。
1 b, h$ p0 h: O - Each column in the GlobalTable is the component list for a single itemtype./ n/ P! m5 g4 g0 r. ?
- 全局表中的每一列是被合成临时实体的清单。
( `! `: X" j+ m# A) z; G - The itemtype of the first flowitem to enter is used to find the correct column.1 S% T2 `7 b' [6 g( d+ v) m
- 从第一个输入端口进入的临时实体的类型决定了在全局表中的哪一列去查询合成清单。
6 G+ o4 U0 E* w# w, ? - It is assumed that the global table has a row for each input port number 2 and higher.
5 T: P- C- ?8 W8 x) e3 v& w# p - 全局表的每一行都代表着一个编号大于等于2的输入端口。
1 Z8 Z& c' R* E9 l$ P. P - */5 I2 {, W0 y$ {# G
# i5 P- i7 \; n3 C" H- if(port == 1)
% Z/ c* l3 j1 N/ X" |% ` - { //The trigger on entry code fires each time a flow item enters the combiner. y: h, p9 b6 U+ U. A+ }/ A5 s
- //For this reason we check to make sure that the port entered is equal to 1
: d; C( w0 F2 G$ e0 W4 x - //because only the container will enter through port 1.+ e1 [3 b6 v2 P2 P& ?
- //每个临时实体进入合成器都会激活进入触发,所以必须要检查临时实体是否是从第一个端口进入的。
& l/ b, s2 q. f2 p) q* x5 J - //只有从第一个端口进入的临时实体才是托盘等容器类临时实体。$ p+ V3 ?; p% |+ W/ k
- //在上文已经解释过,第一个端口进入的临时实体的类型决定了采用全局表中的哪一列来设置合成清单。# ] x% _+ l) F5 ?7 `( ]9 n
- //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
/ `* Z2 B: [) C - //合成清单以表格的形式存在。我们可以使用cell命令来获取数据节点。3 K9 O% x9 M5 R' P) Z( h6 G! u
- //the number of items to retrieve from each port. Once you know what node contains the information you can use the setnodenum
6 t* S1 A* F5 Z! {: q. t - //command to set the component list number based on the global table.
0 x, q" {+ F7 |% `# @: E - //当你知道数据存储于哪个节点之后,你就可以读取全局表中的数据,然后使用setnodenum命令在合成器中设置合成清单。# \' r- S: G; P' D) Q1 v
- 8 _ A/ P2 P+ v, Z6 u$ U' ?
- treenode thelist = getvarnode(current,"componentlist");
7 Y1 a7 s- `5 ~! i6 ]6 ^% G* b& D0 C) I - treenode thesum = getvarnode(current,"targetcomponentsum");
! X/ p6 V* n4 ?; _ - //更改合成清单需要对两个数据节点进行设置。一个是componentlist,这个节点有一列数据,记录了从每个端口输入多少个临时实体。
2 J5 V& n+ X5 _7 k; x2 q - //另一个是targetcomponentsum,记录本次打包的临时实体的总数。
" n t6 s" H4 @ s7 n - setnodenum(thesum,0);) f# S! K- J3 U! _; U4 [5 E% n
- ) I2 d( `- P5 D* s+ a$ i& G
- for(int index=1; index<=nrows(thelist); index++)/ y \) ^ K$ H% f1 r% b: |
- //componentlist以表格的形式存在,只有一列。如果合成器有n个输入端口,那么就有n-1行。(第一个输入端口输入的是容器)9 Z2 ^* E6 k1 P+ q( |4 a
- {/ {. \ H, C) y0 h8 n: R6 j8 d
- setnodenum(cellrowcolumn(thelist,index,1),gettablenum(tablename,index,getitemtype(item)));
* v2 ?" P- K- T0 m4 ?# `# @ - //第一输入端口进入的临时实体的类型,决定了使用全局表中的哪一列数据。
; ]& A, ~# g' ]- v - //把该列数据全部读取出来,依次写入componentlist。8 P1 L3 S) x# u( U/ v) p
- inc(thesum,gettablenum(tablename,index,getitemtype(item)));. H) U* j; P% D' {% o, n% n E
- //同时更新targetcomponentsum的值。: U* g1 F$ l0 Z5 A' m4 @8 D/ o
- }2 D6 v" Z; Z: u: n; }
- }
复制代码 |
|