|
随手翻译了一下,不成体系。搞清楚合成器的第一个输入端口和其他输入端口的区别可能更容易看懂。" Y) {/ J6 r- Y3 A
- /**根据全局表更新合成清单*/4 I) |/ b+ u) e4 W# H T
- string tablename ="订单表";" \* m5 f: v& C% i, D$ {: j; t v
- /*
' `9 N; @) D: o& K, R - This option should only be used on Combiners.' f3 k& K6 ?% F6 O
- 这段代码只能用于合成器。
* o( n2 i, K$ t) [* s) ^" g - Each column in the GlobalTable is the component list for a single itemtype.
! u5 W" F# P1 B0 Z2 C - 全局表中的每一列是被合成临时实体的清单。
$ x$ I1 a+ k! w" f - The itemtype of the first flowitem to enter is used to find the correct column. A+ F0 z+ w, A) L. Y' z
- 从第一个输入端口进入的临时实体的类型决定了在全局表中的哪一列去查询合成清单。; a9 d( W* B6 Y8 `; @) f
- It is assumed that the global table has a row for each input port number 2 and higher.
7 S9 e7 }; M6 _0 J - 全局表的每一行都代表着一个编号大于等于2的输入端口。- {. a. A2 Z( B+ |1 t5 @
- */
, }$ L! O+ l% w% _' p - 3 V/ |2 f: {; K
- if(port == 1)
K# A, F9 E( \- ^; a - { //The trigger on entry code fires each time a flow item enters the combiner.
& a: A* @8 n/ k- _ ^# _8 a6 M - //For this reason we check to make sure that the port entered is equal to 1
* c% h& v8 w) v; T - //because only the container will enter through port 1.* h; l* D/ ^+ e
- //每个临时实体进入合成器都会激活进入触发,所以必须要检查临时实体是否是从第一个端口进入的。
6 t! A+ _; K! y8 I$ D4 _ x - //只有从第一个端口进入的临时实体才是托盘等容器类临时实体。0 n& \0 w$ j0 ^7 P
- //在上文已经解释过,第一个端口进入的临时实体的类型决定了采用全局表中的哪一列来设置合成清单。
; G6 s0 z! n3 u( m& D% H - //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
4 n) F6 a) P9 [; V. i. P - //合成清单以表格的形式存在。我们可以使用cell命令来获取数据节点。
- H; J6 `' V' j% a% v4 n+ S6 E+ } - //the number of items to retrieve from each port. Once you know what node contains the information you can use the setnodenum
+ j* l6 D( M6 u9 ^ - //command to set the component list number based on the global table.5 j7 x3 n0 t' C
- //当你知道数据存储于哪个节点之后,你就可以读取全局表中的数据,然后使用setnodenum命令在合成器中设置合成清单。
8 t3 | q! X7 S) `
, G( S& I& Q. W8 |9 d* C" v0 i1 T- treenode thelist = getvarnode(current,"componentlist");
; Q: B/ s. {6 |7 I% ~ - treenode thesum = getvarnode(current,"targetcomponentsum");6 R5 c3 C- W4 O% v A% F2 k
- //更改合成清单需要对两个数据节点进行设置。一个是componentlist,这个节点有一列数据,记录了从每个端口输入多少个临时实体。1 a6 Q& P, n$ y
- //另一个是targetcomponentsum,记录本次打包的临时实体的总数。
& ?: C% c% d4 W4 z - setnodenum(thesum,0);% E) s' D; o' {2 v, r% \: |0 s: N
# x5 _& K( F( W8 B u9 O$ j- b2 u- for(int index=1; index<=nrows(thelist); index++); \3 R+ E- Y% {# r# K
- //componentlist以表格的形式存在,只有一列。如果合成器有n个输入端口,那么就有n-1行。(第一个输入端口输入的是容器)" e% V5 m! n: O4 j
- {, M: F% I( F7 S
- setnodenum(cellrowcolumn(thelist,index,1),gettablenum(tablename,index,getitemtype(item)));/ V" G% }5 C7 T) u8 \( i* Y
- //第一输入端口进入的临时实体的类型,决定了使用全局表中的哪一列数据。3 L; L) T( n* J+ z, t
- //把该列数据全部读取出来,依次写入componentlist。
7 N) Y$ Y$ j* U+ ` - inc(thesum,gettablenum(tablename,index,getitemtype(item)));
: c+ a6 m. N# x; R# p0 Q3 P - //同时更新targetcomponentsum的值。9 k. r/ j' ]) r5 k9 ~. J
- }+ [& N6 v2 t' S
- }
复制代码 |
|