DetectDto.cs 2.9 KB

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