我如何在 DOORS DXL 中显示来自所有模块(打开或关闭)的链接?

How do I display links from all modules (opened or closed) in DOORS DXL?

我正在编写一个 DXL 脚本,它通过多个级别跟踪链接。我注意到当模块打开时,脚本会正确地遍历这些链接。但是,大约有 20 个模块需要迭代,我不想打开所有这些模块。如何在无需手动打开链接模块的情况下查看这些链接?

这是我的代码示例:

// Checks to see if the object exists or not.  If not returns a null.  
//  This will be eventually adapted to make sure the object is from a 
//  specific set of modules, but for now we're just checking for ability
//  to retrieve
Object getObject(Link obj_link) {
    ModuleVersion other_ver = null
    ModName_ other_mod = null
    Object other_obj

    other_ver = sourceVersion obj_link
    other_mod = module(other_ver)
    if (null other_mod || isDeleted other_mod) return null

    other_obj = source obj_link
    if (null other_obj) load(other_ver, true)
    other_obj = source obj_link
    if (isDeleted other_obj) return null

    return other_obj
}

// Displays the object from a specific link module if it's found
void showOut(Object o) {
    Link l_obj_link
    string s = null

    Item linkModItem = itemFromID(MODULE_ID)
    string linkModName = fullName(linkModItem)

    for l_obj_link in all(o <- linkModName) do {

        Object test_obj
        display("Test")
        test_obj = getObject(l_obj_link)
        if (null test_obj){
            display("Null Object Found")
        } else {
            s = probeRichAttr_(test_obj, "Object Identifier", false)
            displayRich(s)
        }
    }
}

// Call showOut for the object
showOut(obj)

同样,将其用作布局 DXL 脚本,当且仅当链接模块打开时,我才能看到对象 ID。

首先,我建议使用 Analysis -> Wizard 并确保 select All Modules 选项而不是 All Open Modules 为您生成所有代码相反,然后修改该代码以显示您想要的内容,如果它没有为您提供您所需要的内容。

但是,如果您只想更新现有代码,则需要更改 getObject 函数以包括静默打开每个模块(以获取模块必须打开的信息,但不需要可见)。

Object getObject(Link obj_link) {
  ModuleVersion other_ver = null
  ModName_ other_mod = null
  Object other_obj

  other_ver = sourceVersion obj_link
  other_mod = module(other_ver)
  Module m = read(fullName(other_ver), false)  // false, tells it to open silently.
  if (null other_mod || isDeleted other_mod) return null

  other_obj = source obj_link
  if (null other_obj) load(other_ver, true)
  other_obj = source obj_link
  if (isDeleted other_obj) return null

  return other_obj
}

这应该也可以,但我仍然建议从分析向导开始,因为它会更干净。

您需要 load 使用 link 引用 (LinkRef) 的模块。这是一个简单的函数,可以为特定的 LinkModule 和 Object 加载所有模块:

// Loads all incoming linked modules for the given link module and Object.  To load from 
//  ALL link modules use the linkModName = "*"
void LoadSourceModules(string linkModName, Object o) {
    ModName_ otherMod = null
    LinkRef lr

    // For each incoming link check to see if the moduel exists, isn't deleted and loaded
    //  if not loaded `(null data(sourceVersion lr))` then load the module.
    for lr in all(o<-linkModName) do {
        otherMod = module(sourceVersion lr)
        if (!null otherMod) {
            if ((!isDeleted otherMod) && (null data(sourceVersion lr))) {
                load((sourceVersion lr), false)
            }
        }
    }
}