繁体   English   中英

Yang 建模语言 - 在位类型中选择/取消选择一个或多个选项

[英]Yang modeling language - select / deselect one or multiple options within bits type

YANG语言是否有可能在位类型叶中选择一个选项,这将取消选择所有其他位? 我想要做的是,默认情况下选择了整个平台,但是当用户选择其他选项时,将取消选择整个平台。 否则,当用户选择 Whole-Platform 时,应取消选择所有其他选项。

leaf check-type {
            type bits {
              bit Whole-platform;
              bit NSO-checks;
              bit ESC-checks;
            }
            default "Whole-platform";
 }

位

不,YANG 位类型不会让您这样做,因为默认情况下各个位之间不存在任何关系 - 除了所有这些都属于同一组“可配置标志”的概念。

这是联合类型将成为可行的建模决策的地方。

leaf check-type {
  type union {
    type enumeration {
      enum Whole-platform;
    }
    type bits {
      bit NSO-checks;
      bit ESC-checks;
    }
  }
  default Whole-platform;
}

这样做意味着值Whole-platform和读者的剩余位值集之间的 XOR(互斥)。

有效值:

<check-type>Whole-platform</check-type>
<check-type>NSO-checks</check-type>
<check-type>NSO-checks ESC-checks</check-type>

无效的:

<check-type>Whole-platform ESC-checks</check-type>

您可以保留您的类型并处理其中的一位以在描述中将它们全部规则,因为那只是人类可读的规范文本。

description "Implementations must ensure an XOR relationship between
             'Whole-platform' bit value and the other bit values of this
             leaf. When the former is used it means that 
             ...";

注意:您要实现的是实现细节。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM