|
随手翻译了一下,不成体系。搞清楚合成器的第一个输入端口和其他输入端口的区别可能更容易看懂。
4 s3 y9 L0 L; i2 q' X- /**根据全局表更新合成清单*/
' i! p5 d0 ~1 j- b- _, Q# \ - string tablename ="订单表";8 C8 {0 z% y- t" T
- /*; ^3 V4 A/ n N5 X/ o
- This option should only be used on Combiners.2 t0 Y" K$ W. s6 c8 z0 v0 C
- 这段代码只能用于合成器。- \3 M' j4 V7 U$ R- o' g+ b* y; ]
- Each column in the GlobalTable is the component list for a single itemtype.
& J; ^, c& k1 E9 ^+ o3 j" ~4 ` - 全局表中的每一列是被合成临时实体的清单。$ k) r, \6 N G2 f8 ^
- The itemtype of the first flowitem to enter is used to find the correct column.
! R3 F/ u9 t, Q' t9 R# j, e - 从第一个输入端口进入的临时实体的类型决定了在全局表中的哪一列去查询合成清单。3 D, x7 N7 _0 F7 [% A
- It is assumed that the global table has a row for each input port number 2 and higher.
K4 _; h9 u6 G' W - 全局表的每一行都代表着一个编号大于等于2的输入端口。- `5 [7 l* K J( O3 x( c+ X; Z; Y
- */
( ~ T0 v6 v# U+ S( |5 i3 J. F% D - 9 R8 T: Y9 t: E) L- n
- if(port == 1)% J/ ?8 {# @8 \6 a2 @5 H
- { //The trigger on entry code fires each time a flow item enters the combiner.
0 r% K% k1 c! Y _8 D6 | - //For this reason we check to make sure that the port entered is equal to 1
& A$ i3 r: C$ J# _* ~. z - //because only the container will enter through port 1.; \# R$ [+ M9 G+ E, }
- //每个临时实体进入合成器都会激活进入触发,所以必须要检查临时实体是否是从第一个端口进入的。
3 V) K9 C% d5 B1 I4 _& a1 @ - //只有从第一个端口进入的临时实体才是托盘等容器类临时实体。
4 k# J, a- ]0 m' P$ U: n* z6 K7 k - //在上文已经解释过,第一个端口进入的临时实体的类型决定了采用全局表中的哪一列来设置合成清单。
0 O6 I* x) c" i w: ^3 q3 c' W- b - //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 D% Y' z. f& j6 k3 |$ U
- //合成清单以表格的形式存在。我们可以使用cell命令来获取数据节点。
! l$ K6 u6 h4 T8 O4 G; g- R - //the number of items to retrieve from each port. Once you know what node contains the information you can use the setnodenum- t# Q* m& Q. a" H3 S+ r! ?+ q! X
- //command to set the component list number based on the global table.
7 H/ P$ J8 [8 x) V* x, P5 ] - //当你知道数据存储于哪个节点之后,你就可以读取全局表中的数据,然后使用setnodenum命令在合成器中设置合成清单。
?, g% f) T ^* y - 1 B3 u7 c/ r8 q2 o
- treenode thelist = getvarnode(current,"componentlist");/ e+ V& p: M& [, D5 w
- treenode thesum = getvarnode(current,"targetcomponentsum");
: e9 k# D6 y) Q# j - //更改合成清单需要对两个数据节点进行设置。一个是componentlist,这个节点有一列数据,记录了从每个端口输入多少个临时实体。) B, b0 A6 M1 d5 Y
- //另一个是targetcomponentsum,记录本次打包的临时实体的总数。6 h- V) _( S3 J# x. D- {' h
- setnodenum(thesum,0);
: P# N5 F5 x1 ?# s7 |- B - ; s0 \* K; l! Q! }9 g" j1 C
- for(int index=1; index<=nrows(thelist); index++)
0 p b& w3 w B- @, E: n - //componentlist以表格的形式存在,只有一列。如果合成器有n个输入端口,那么就有n-1行。(第一个输入端口输入的是容器) V- G, M' Q8 g
- {
. m; i7 k& U" q Y' ] - setnodenum(cellrowcolumn(thelist,index,1),gettablenum(tablename,index,getitemtype(item)));' p5 {0 [- B8 P; \6 ^) ^- z! k
- //第一输入端口进入的临时实体的类型,决定了使用全局表中的哪一列数据。
* [$ Z( \$ j3 ]$ Y0 { - //把该列数据全部读取出来,依次写入componentlist。8 l; G( L1 t4 n7 s! C3 y
- inc(thesum,gettablenum(tablename,index,getitemtype(item)));
, r& i; V2 q( E \% J - //同时更新targetcomponentsum的值。, |- Q* \$ z7 s9 a
- }0 I$ J0 u# T3 V5 v3 ~- Y" [! W
- }
复制代码 |
|