import 'package:vid/us/vid_us_unit.dart'; /// 测量项配置元信息 class ItemMeta { /// 名称 String name; /// 描述 String description; /// 简介注释 String briefAnnotation; /// 测量类型 String measureType; /// 计算输出元信息 List<ItemOutputMeta> outputs; /// 子项元信息集合 List<ItemMeta> childItems; ItemMeta( this.name, { required this.measureType, required this.description, required this.outputs, this.briefAnnotation = '', this.childItems = const [], }); /// 根据名称获取子项 ItemMeta? getChildByName(String name) { final matchList = childItems.where((e) => e.name == name); if (matchList.isNotEmpty) { return matchList.first; } return null; } /// 根据类型获取子项 ItemMeta? getChildByType(String type) { final matchList = childItems.where((e) => e.measureType == type); if (matchList.isNotEmpty) { return matchList.first; } return null; } } class ItemOutputMeta { /// 名称 String name; /// 描述 String description; /// 单位 VidUsUnit unit; /// 简介注释 String? briefAnnotation; /// 额外注释 String? additionalAnnotation; /// 小数精度 int fractionalDigits; ItemOutputMeta( this.name, this.description, this.unit, { this.briefAnnotation, this.additionalAnnotation, this.fractionalDigits = 2, }); }