item_metas.dart 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. import 'package:vid/us/vid_us_unit.dart';
  2. /// 测量项配置元信息
  3. class ItemMeta {
  4. /// 名称
  5. String name;
  6. /// 描述
  7. String description;
  8. /// 简介注释
  9. String briefAnnotation;
  10. /// 测量类型
  11. String measureType;
  12. /// 计算输出元信息
  13. List<ItemOutputMeta> outputs;
  14. /// 子项元信息集合
  15. List<ItemMeta> childItems;
  16. ItemMeta(
  17. this.name, {
  18. required this.measureType,
  19. required this.description,
  20. required this.outputs,
  21. this.briefAnnotation = '',
  22. this.childItems = const [],
  23. });
  24. /// 根据名称获取子项
  25. ItemMeta? getChildByName(String name) {
  26. final matchList = childItems.where((e) => e.name == name);
  27. if (matchList.isNotEmpty) {
  28. return matchList.first;
  29. }
  30. return null;
  31. }
  32. }
  33. class ItemOutputMeta {
  34. /// 名称
  35. String name;
  36. /// 描述
  37. String description;
  38. /// 单位
  39. VidUsUnit unit;
  40. /// 简介注释
  41. String? briefAnnotation;
  42. /// 额外注释
  43. String? additionalAnnotation;
  44. /// 小数精度
  45. int fractionalDigits;
  46. ItemOutputMeta(
  47. this.name,
  48. this.description,
  49. this.unit, {
  50. this.briefAnnotation,
  51. this.additionalAnnotation,
  52. this.fractionalDigits = 2,
  53. });
  54. }