发帖
 找回密码
 立即注册
搜索
16

根据全局表更新合成器的合成清单

历史版块_9 16 16 2015-11-25 11:27:59
随手翻译了一下,不成体系。搞清楚合成器的第一个输入端口和其他输入端口的区别可能更容易看懂。
[code]/**根据全局表更新合成清单*/
string tablename ="订单表";
/*
This option should only be used on Combiners.
这段代码只能用于合成器。
Each column in the GlobalTable is the component list for a single itemtype.
全局表中的每一列是被合成临时实体的清单。
The itemtype of the first flowitem to enter is used to find the correct column.
从第一个输入端口进入的临时实体的类型决定了在全局表中的哪一列去查询合成清单。
It is assumed that the global table has a row for each input port number 2 and higher.
全局表的每一行都代表着一个编号大于等于2的输入端口。
*/

if(port == 1)
{  //The trigger on entry code fires each time a flow item enters the combiner.
   //For this reason we check to make sure that the port entered is equal to 1
   //because only the container will enter through port 1.
        //每个临时实体进入合成器都会激活进入触发,所以必须要检查临时实体是否是从第一个端口进入的。
        //只有从第一个端口进入的临时实体才是托盘等容器类临时实体。
        //在上文已经解释过,第一个端口进入的临时实体的类型决定了采用全局表中的哪一列来设置合成清单。
  //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
  //合成清单以表格的形式存在。我们可以使用cell命令来获取数据节点。
  //the number of items to retrieve from each port.  Once you know what node contains the information you can use the setnodenum
  //command to set the component list number based on the global table.
  //当你知道数据存储于哪个节点之后,你就可以读取全局表中的数据,然后使用setnodenum命令在合成器中设置合成清单。

  treenode thelist = getvarnode(current,"componentlist");
  treenode thesum = getvarnode(current,"targetcomponentsum");
//更改合成清单需要对两个数据节点进行设置。一个是componentlist,这个节点有一列数据,记录了从每个端口输入多少个临时实体。
//另一个是targetcomponentsum,记录本次打包的临时实体的总数。
  setnodenum(thesum,0);

  for(int index=1; index<=nrows(thelist); index++)
  //componentlist以表格的形式存在,只有一列。如果合成器有n个输入端口,那么就有n-1行。(第一个输入端口输入的是容器)
  {
    setnodenum(cellrowcolumn(thelist,index,1),gettablenum(tablename,index,getitemtype(item)));
    //第一输入端口进入的临时实体的类型,决定了使用全局表中的哪一列数据。
    //把该列数据全部读取出来,依次写入componentlist。
    inc(thesum,gettablenum(tablename,index,getitemtype(item)));
    //同时更新targetcomponentsum的值。
  }
}[/code]
2015-11-26 22:31:57
感谢加老师分享,这么详细的解释对初学者来说是巨大的福音啊:lol
2017-3-29 14:40:12
提示: 作者被禁止或删除 内容自动屏蔽
2017-3-30 09:39:17
[b] [url=http://flexsimasia.com/redirect.php?goto=findpost&pid=22312&ptid=5555]3#[/url] [i]草色青青[/i] [/b]
你的问题可以解决呀,所有合成器可以读取同一份全局表,但是读取不同的列就行了
2017-4-18 07:24:37
[i=s] 本帖最后由 zorsite 于 2017-4-18 07:40 编辑 [/i]

[b] [url=http://flexsimasia.com/redirect.php?goto=findpost&pid=22312&ptid=5555]3#[/url] [i]草色青青[/i] [/b]
假设你有3个合成器,分别只接受类型为1、2、3的临时实体进行合成。
[table=288][tr][td=1,1,72][/td][td=1,1,72]托盘类型1[/td][td=1,1,72]托盘类型2[/td][td=1,1,72]托盘类型3[/td][/tr][tr][td]合成器1[/td][td]3[/td][td]2[/td][td]1[/td][/tr][tr][td]合成器2[/td][td]1[/td][td]2[/td][td]3[/td][/tr][tr][td]合成器3[/td][td]2[/td][td]5[/td][td]1[/td][/tr][/table]

以第3行,第2列为例解释一下这个表格的含义:
当第3个合成器(第三行)接收到类型为2(第二列)的托盘时,从上游拉取5个(第三行第二列的值为5)类型为3(合成器3只合成类型为3的临时实体)的临时实体进行加工。

仍然是根据全局表更新组件列表,代码如下:[code]string tablename = "GlobalTable1";
if(port == 1)
{
int row=ipopno(current,2);
int col=getitemtype(item);
double num=gettablenum(tablename,row,col);
treenode thelist = getvarnode(current,"componentlist");
treenode thesum = getvarnode(current,"targetcomponentsum");
setnodenum(cellrowcolumn(thelist,1,1),num);
setnodenum(thesum,num);
}[/code]

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
2017-4-18 07:35:09
[i=s] 本帖最后由 zorsite 于 2017-4-18 07:39 编辑 [/i]

更多的时候,我们使用的是这样的表格:[table=329][tr][td=1,1,113][/td][td=1,1,72]托盘类型1[/td][td=1,1,72]托盘类型2[/td][td=1,1,72]托盘类型3[/td][/tr] [tr][td]临时实体类型1[/td][td]1[/td][td]2[/td][td]3[/td][/tr] [tr][td]临时实体类型2[/td][td]1[/td][td]2[/td][td]1[/td][/tr] [tr][td]临时实体类型3[/td][td]1[/td][td]2[/td][td]1[/td][/tr][/table]

只有一个合成器,进入不同类型的托盘时,拉取不同数量的各种类型的临时实体来进行打包。

本帖子中包含更多资源

您需要 登录 才可以下载或查看,没有账号?立即注册

x
2017-4-18 11:23:57
Mark~
2017-4-21 06:10:24
[b] [url=http://www.flexsimasia.com/redirect.php?goto=findpost&pid=22455&ptid=5555]6#[/url] [i]zorsite[/i] [/b]


刚刚学习了这个例子,第一次发现合成器的上游可以不需要与输入端口个数相同的实体,只需要一个实体多次A连接就形成多个端口。所以在使用合成器的时候有n个输入端口,但很有可能只有有小于n的上游固定实体。感觉很有趣啊。
2017-4-23 14:04:13
谢谢分享,激发了大家的学习兴趣:$
2017-5-7 22:58:21
再次温习合成器代码,谢谢楼主大神的模型及其详细解释!
您需要登录后才可以回帖 立即登录
高级模式
12下一页
历史版块_9