|
随手翻译了一下,不成体系。搞清楚合成器的第一个输入端口和其他输入端口的区别可能更容易看懂。
( \% b. w" j0 s5 L7 [- t- /**根据全局表更新合成清单*/7 t! h, m; a, O6 F
- string tablename ="订单表";6 n5 F& n) _2 |) k' p
- /*; B. O6 `$ e" E$ Q- b0 ]9 d) D; {$ I
- This option should only be used on Combiners.
) P8 d; v* J" o2 |9 j- u$ D1 c - 这段代码只能用于合成器。
5 _9 e! T7 k5 V, }$ b - Each column in the GlobalTable is the component list for a single itemtype.0 P* m$ P* ? e* O4 [+ q
- 全局表中的每一列是被合成临时实体的清单。# H0 Y- R' c6 v
- The itemtype of the first flowitem to enter is used to find the correct column.
& M6 O h7 k( |) a* v/ ` - 从第一个输入端口进入的临时实体的类型决定了在全局表中的哪一列去查询合成清单。& A% i; ^* W" @5 @4 i$ _' }# _
- It is assumed that the global table has a row for each input port number 2 and higher.
$ E) \2 e2 P4 I7 P6 ]& {6 x - 全局表的每一行都代表着一个编号大于等于2的输入端口。+ s' N/ [6 f: p
- */4 I+ a! E6 h( p9 n
- 5 F8 Q' d5 B. @: |
- if(port == 1)1 i6 p7 G% A# x, U' p7 f
- { //The trigger on entry code fires each time a flow item enters the combiner.: w$ Q. ]1 k! G) i5 Q
- //For this reason we check to make sure that the port entered is equal to 1- j+ [& K+ f. n/ a: [
- //because only the container will enter through port 1.
- {, X, [. f$ E5 y/ x - //每个临时实体进入合成器都会激活进入触发,所以必须要检查临时实体是否是从第一个端口进入的。, f+ P0 J" E& h1 n. ]' {* |' Q3 E
- //只有从第一个端口进入的临时实体才是托盘等容器类临时实体。+ q, p7 M2 Z1 ]
- //在上文已经解释过,第一个端口进入的临时实体的类型决定了采用全局表中的哪一列来设置合成清单。0 T" z# h. {& s# K
- //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 contains9 ?0 I2 b# ^: x3 ? c9 o. ]6 Q2 B
- //合成清单以表格的形式存在。我们可以使用cell命令来获取数据节点。
: H" e- G2 w1 {/ [2 U) c - //the number of items to retrieve from each port. Once you know what node contains the information you can use the setnodenum
* E9 i8 z# y$ l. K - //command to set the component list number based on the global table.
; V% X, F+ W* S3 R& C - //当你知道数据存储于哪个节点之后,你就可以读取全局表中的数据,然后使用setnodenum命令在合成器中设置合成清单。
q0 P O2 Z: D N& b( Z; t2 ~- z - 5 g6 r) F) {* v, T9 [9 c
- treenode thelist = getvarnode(current,"componentlist");" Z( f7 @% ]: m; W8 S4 e
- treenode thesum = getvarnode(current,"targetcomponentsum");6 \% v! P6 }9 M! S0 o
- //更改合成清单需要对两个数据节点进行设置。一个是componentlist,这个节点有一列数据,记录了从每个端口输入多少个临时实体。
9 S X0 K( }. z7 o4 f - //另一个是targetcomponentsum,记录本次打包的临时实体的总数。 B9 a! \& u1 S5 Q
- setnodenum(thesum,0);0 @' e4 p0 h( f
- " Q; y5 w* b1 T- ~
- for(int index=1; index<=nrows(thelist); index++)
& W1 ~6 \6 j' }; e - //componentlist以表格的形式存在,只有一列。如果合成器有n个输入端口,那么就有n-1行。(第一个输入端口输入的是容器)& Z5 Y. a5 o: j4 L' z. ?/ `8 d
- {
7 a( J/ O8 s/ ~4 r8 \ - setnodenum(cellrowcolumn(thelist,index,1),gettablenum(tablename,index,getitemtype(item)));" a! M% J. t& U2 p% q5 \3 y" t
- //第一输入端口进入的临时实体的类型,决定了使用全局表中的哪一列数据。, B) e" P- U# d
- //把该列数据全部读取出来,依次写入componentlist。5 `8 @5 F4 C6 _! q
- inc(thesum,gettablenum(tablename,index,getitemtype(item)));0 k7 a8 R; R( P$ t" ^, c
- //同时更新targetcomponentsum的值。
4 }1 C4 ?& A3 s - }
3 D* o3 t F; m3 N) g" z3 H& s1 e - }
复制代码 |
|