网淘吧Visual Components、Flexsim 仿真技术博客 | Python、C#、Delphi xe 机器人编程教程 - 网淘吧

如何阻止产品或控制需求/供料匹配 - Process Modeling - visual compents 疑难解答

2026-04-03 新闻来源:网淘吧 围观:1266
电脑广告
手机广告

如何阻止产品或控制需求/供料匹配

流程建模

大家好,

问题描述:
一个设备从输入节点流入系统,经过一个或多个测试站点,最后根据以下规则在输出节点离开:

  1. 如果设备在到达终点前未通过测试,则必须重新测试。
  2. 不能使用已经访问过的同一测试站点。

系统的物料流如下所示:


问题:
在我描述已经尝试过的方法之前,先明确一下我的问题:

  1. 如何阻止具有特定属性值的产品?
  2. 如何使用 Python API 管理匹配的需求供料连接?
  3. 另外,是否可以创建一个自定义的vcProductFilter对象,允许我们根据自己的逻辑接受或拒绝产品实例?

我尝试过的方法…

根据 VC 帮助文档中关于vcProductMatcher的内容,它说:

如果需求与供料的流程组 ID 匹配,需求接受产品类型(在 vcProductFilter 中定义),并且在运输节点之间存在有效的运输解决方案,则可以建立匹配。

基于此,我尝试在设备上创建一个名为Use_Site的属性,用于记录它已经使用过的测试站点。
然后,我在每个站点的流程语句中设置了一个产品过滤器

然而,我不确定如何编写正确的表达式,甚至不知道应该使用哪种类型的过滤器。
似乎过滤器表达式不允许像 "str" not in "str" 这样的语法。




在语句过滤器中使用表达式时,我遇到了一个错误。提示信息如下:

Error in . Expression '"Test Site #22" not in Product.Component.Use_Site' refers to the variable itself.

我还尝试通过 Python API 处理需求/供料匹配。
我调用了 match.tryCancelMatch(),但它返回了 None,并且匹配状态仍然保持在已创建

嗯… 看起来匹配并不能像我希望的那样被取消。

def register_match(new_):
  """
  Register a match event for need/feed and handle the match logic.
  """
  def need_feed_match(match):  # type: (vcProductNeedFeedMatch) -> Any
    transport_ = next(x for x in transport_items if x.need_item == new_ or x.feed_item == new_) # type: TransportItem
    if not transport_:
      error('No TransportItem found!')
      return
    #mo
    print("==========================================")
    if match.State == VC_MATCH_STATE_CREATED:
      match_state = "Created"
    elif match.State == VC_MATCH_STATE_CANCELLED:
      match_state = "Cancelled"
    elif match.State == VC_MATCH_STATE_FINALIZED:
      match_state = "Finalized"
    elif match.State == VC_MATCH_STATE_DISPOSED:
      match_state = "Disposed"
    print("This Match Object Type: {}".format(match_state))
    print("Matched Need's "
          "Target Node: {}".format(match.MatchedNeed.TargetNode.Component.Name))
    print("Matched Feed's "
          "Source Node: {}".format(match.MatchedFeed.SourceNode.Component.Name))
    print("Matched Product Instance:\n\t"
          "Product's Mark: {}\n\t"
          "Product's Used Site: {}".format(match.MatchedFeed.Product.Component.Mark,
                                         match.MatchedFeed.Product.Component.Use_Site))
    if comp.Name in match.MatchedFeed.Product.Component.Use_Site and transport_.type == 'need':
      print("This matched need feed should be canceled!")
      print(match.tryCancelMatch())
      print("This Match Object Type: {}".format(match_state))
      print("==========================================")
      return
    else:
      print("==========================================")
      
    transport_.need_item = match.MatchedNeed
    transport_.feed_item = match.MatchedFeed
    transport_.match_item = match
    transport_.match_time = sim.SimTime
    transport_.product = match.MatchedFeed.Product
    create_transport_target(transport_, match.MatchedFeed.Product, transport_.type)
    if transport_.type == 'feed':
      solution = transport_system.findSolution(
        transport_.feed_item.SourceNode,
        transport_.need_item.TargetNode,
        transport_.product.ProductType.FlowGroup
      )
      transport_.product.TransportSolution = solution
      transport_node.beginTransportOut(transport_.product)
    match.finalizeMatch()
  return need_feed_match
VC OUTPUT PANEL:
==========================================
This Match Object Type: Created
Matched Need's Target Node: SLT Trolley Test Unit #22
Matched Feed's Source Node: PlatformBase
Matched Product Instance:
	Product's Mark: R0
	Product's Used Site: SLT Trolley Test Unit #22,
This matched need feed should be canceled!
None
This Match Object Type: Created
==========================================

表达式语言/语法在帮助文档中有定义。字符串和列表上的操作是有限的。

请参阅“表达式”主题下的不同子页面,而不仅仅是这个函数页面。

据我所知,在 VC 4.10 中,产品匹配取消功能从设计角度来看并不能完全按预期/有用方式工作,如果你的逻辑取消了一个匹配,原生语句不会尝试寻找另一个匹配。

这种“每个测试站点最多访问一次”的通用需求,听起来可以使用流程访问限制功能来解决,至少如果你将每个站点设为独立的流程,但在一个流程步骤中将它们作为替代选项。

我以前没有注意到这些限制,但现在我明白了。
也许我会尝试在动态组件上设置多个属性,分别记录已使用的站点。这样我就可以使用类似 Product.Component.<prop> == <site name> ? True : False 来接受或拒绝特定产品,然后用 && 运算符组合这些过滤器。

谢谢 TSy 分享你的知识。
我有点担心使用“独立的流程但在流程组中作为替代选项”,因为实际上并不像我画的例子中只有 3 个站点——实际上有 18 个,每个设备在失效(测试失败)前有 5 次生命,哈哈。但我会试试:sweat_smile:,或者我可能需要另一种方法来建立我的模型。

免责申明
部分文章来自各大搜索引擎,如有侵权,请与我联系删除。
打赏

文章底部电脑广告
手机广告位-内容正文底部

相关文章

上网淘巴领天猫淘宝优惠券,一年省好几千。

广告  ×

您是本站第853495名访客 今日有0篇新文章/评论