|
随手翻译了一下,不成体系。搞清楚合成器的第一个输入端口和其他输入端口的区别可能更容易看懂。
. a" n( h( U7 g( D9 g! z+ b- /**根据全局表更新合成清单*/8 ^. I+ K, c6 U6 {* ^( C4 Y( @) R, G
- string tablename ="订单表";
; q# V# P0 G$ e3 N8 C' c# A q - /*
# _- u v3 E) B& G$ S- E6 ? - This option should only be used on Combiners.( W+ o; f+ A( F& M& Q
- 这段代码只能用于合成器。3 J( ]) u) e6 S; K3 s
- Each column in the GlobalTable is the component list for a single itemtype.1 L3 m6 J2 y/ U0 D+ @9 h; W
- 全局表中的每一列是被合成临时实体的清单。
* }& `( I1 s% f4 |4 v, M+ g" T - The itemtype of the first flowitem to enter is used to find the correct column.
+ E! {1 ^( O- ^, Y! G/ ]0 ]! d8 t+ }2 J - 从第一个输入端口进入的临时实体的类型决定了在全局表中的哪一列去查询合成清单。6 Z+ ^( [$ O2 N/ c( `: s9 K$ M9 y
- It is assumed that the global table has a row for each input port number 2 and higher.
: v; ?* W. b) U) _* l+ ` - 全局表的每一行都代表着一个编号大于等于2的输入端口。
$ Z. E( R: ?) V( F4 n - */
* U% U8 Y7 o- y& ~4 _
4 R9 N! P7 Y( M, m! _- if(port == 1)
% A/ L2 E4 L1 C( B! g! e - { //The trigger on entry code fires each time a flow item enters the combiner.
$ h9 X3 U3 |, H6 f - //For this reason we check to make sure that the port entered is equal to 11 r7 F- o t; ?- q) c
- //because only the container will enter through port 1.0 ?6 K6 {/ P2 k5 S. [
- //每个临时实体进入合成器都会激活进入触发,所以必须要检查临时实体是否是从第一个端口进入的。
- I* a( e* P; K4 a+ N - //只有从第一个端口进入的临时实体才是托盘等容器类临时实体。) V4 g9 [7 ~9 B0 d i) T$ H8 V$ U+ |
- //在上文已经解释过,第一个端口进入的临时实体的类型决定了采用全局表中的哪一列来设置合成清单。
' q9 j$ e8 o" s) y' p - //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 contains5 `& S# e. z* X# V2 ^
- //合成清单以表格的形式存在。我们可以使用cell命令来获取数据节点。
. ?3 s. O- L a/ G, I - //the number of items to retrieve from each port. Once you know what node contains the information you can use the setnodenum( ~6 j/ ?6 X- _5 y
- //command to set the component list number based on the global table.' O9 r$ e+ n: Y2 Y/ s6 }
- //当你知道数据存储于哪个节点之后,你就可以读取全局表中的数据,然后使用setnodenum命令在合成器中设置合成清单。
/ `( j4 f" d' s7 Q! z
$ Q. W6 e: j0 ]) Q) {- treenode thelist = getvarnode(current,"componentlist");
" m. Y0 D! _4 _0 T/ N1 \- B9 H( u - treenode thesum = getvarnode(current,"targetcomponentsum");. U5 n7 e4 y0 q5 F$ {
- //更改合成清单需要对两个数据节点进行设置。一个是componentlist,这个节点有一列数据,记录了从每个端口输入多少个临时实体。8 t% n/ D! |* U' ?5 i, J- v
- //另一个是targetcomponentsum,记录本次打包的临时实体的总数。
* {1 P# O5 f' ^! {7 n x4 D - setnodenum(thesum,0); j- k. \( z6 E- T( n% h- V: K! [
- ' U4 e9 P' Q2 p
- for(int index=1; index<=nrows(thelist); index++)
- o5 e- W- K9 }4 } - //componentlist以表格的形式存在,只有一列。如果合成器有n个输入端口,那么就有n-1行。(第一个输入端口输入的是容器)
9 x* a6 L3 u- ?( h - {* }! |( o2 A8 G* c7 L
- setnodenum(cellrowcolumn(thelist,index,1),gettablenum(tablename,index,getitemtype(item)));7 T# H) \ k9 E0 Y5 f( m6 I
- //第一输入端口进入的临时实体的类型,决定了使用全局表中的哪一列数据。
$ V P& s% b. t/ I' e' C - //把该列数据全部读取出来,依次写入componentlist。6 k# F+ m9 |0 p/ t0 D, ?
- inc(thesum,gettablenum(tablename,index,getitemtype(item)));
& u- g4 S9 J/ g5 g5 A" c - //同时更新targetcomponentsum的值。
1 a% o8 K' a# j - }( D5 Z" \. Y2 W: R& D9 o
- }
复制代码 |
|