DetectDto.cs 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel;
  4. using System.ComponentModel.DataAnnotations;
  5. using System.Linq;
  6. using System.Text;
  7. using System.Threading.Tasks;
  8. using XdCxRhDW.Dto.Attribute;
  9. namespace XdCxRhDW.Dto
  10. {
  11. /// <summary>
  12. /// 检测计算模型
  13. /// </summary>
  14. public class DetectDto : IValidatableObject
  15. {
  16. /// <summary>
  17. /// 调用Upload接口上传文件后返回的文件名
  18. /// </summary>
  19. [FileMustExist]
  20. public string file1 { get; set; }
  21. /// <summary>
  22. /// 检测类型
  23. /// </summary>
  24. public EnumSigCheckTypeDto dmcType { get; set; }
  25. /// <summary>
  26. /// 多个检测类型时是否合并检测结果(重叠的信号只算一个,重叠区域超过500样点则认为是同一个)
  27. /// </summary>
  28. public bool mergeRes { get; set; } = false;
  29. /// <summary>
  30. /// 采样率 Hz
  31. /// </summary>
  32. [RangeDouble(0, 100e6, IncludeMin = true)]
  33. public double fsHz { get; set; }
  34. /// <summary>
  35. /// 信号带宽(KHz),会对检测文件进行滤波处理
  36. /// </summary>
  37. [RangeDouble(0, 96,IncludeMax =false)]
  38. public double band { get; set; } = 25;
  39. /// <summary>
  40. /// 是否对信号进行识别(获取调制类型、速率、频偏等)
  41. /// </summary>
  42. public bool SigProc { get; set; } = false;
  43. /// <summary>
  44. ///
  45. /// </summary>
  46. /// <param name="validationContext"></param>
  47. /// <returns></returns>
  48. public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
  49. {
  50. var fields = typeof(EnumSigCheckTypeDto).GetFields().Where(p => p.FieldType.IsEnum);
  51. bool hasError = true;
  52. foreach (var field in fields)
  53. {
  54. var value = field.GetValue(null);
  55. if (this.dmcType.HasFlag((Enum)value))
  56. {
  57. hasError = false;
  58. break;
  59. }
  60. }
  61. if (hasError)
  62. yield return new ValidationResult("检测类型错误", new[] { nameof(this.dmcType) });
  63. else
  64. {
  65. if (dmcType.HasFlag(EnumSigCheckTypeDto.Normal))
  66. {
  67. yield return new ValidationResult("常规信号不需要检测", new[] { nameof(this.dmcType) });
  68. }
  69. if (dmcType.HasFlag(EnumSigCheckTypeDto.DAMA) && fsHz != 96000)
  70. {
  71. yield return new ValidationResult("DAMA检测采样率只支持96K", new[] { nameof(this.fsHz) });
  72. }
  73. if (dmcType.HasFlag(EnumSigCheckTypeDto.IBS) && band != 5 && band != 25)
  74. {
  75. yield return new ValidationResult("IBS检测信号带宽只支持5K、25K两种", new[] { nameof(this.band) });
  76. }
  77. }
  78. yield return null;
  79. }
  80. }
  81. }