DetectDto.cs 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  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,只对IBS信号有效,默认25KHz)
  36. /// </summary>
  37. [RangeDouble(0, 100)]
  38. public double band { get; set; } = 25;
  39. /// <summary>
  40. /// 是否对信号进行识别(获取调制类型、速率、频偏等)
  41. /// </summary>
  42. public bool SigProc { get; set; } = false;
  43. /// <summary>
  44. /// 超时时间(单位秒,默认30秒)
  45. /// </summary>
  46. [RangeInt(10, 600, IncludeMin = true)]
  47. public int TimeoutSeconds { get; set; } = 30;
  48. /// <summary>
  49. ///
  50. /// </summary>
  51. /// <param name="validationContext"></param>
  52. /// <returns></returns>
  53. public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
  54. {
  55. var fields = typeof(EnumSigCheckTypeDto).GetFields().Where(p => p.FieldType.IsEnum);
  56. bool hasError = true;
  57. foreach (var field in fields)
  58. {
  59. var value = field.GetValue(null);
  60. if (this.dmcType.HasFlag((Enum)value))
  61. {
  62. hasError = false;
  63. break;
  64. }
  65. }
  66. if (hasError)
  67. yield return new ValidationResult("检测类型错误", new[] { nameof(this.dmcType) });
  68. else
  69. {
  70. if (dmcType.HasFlag(EnumSigCheckTypeDto.Normal))
  71. {
  72. yield return new ValidationResult("常规信号不需要检测", new[] { nameof(this.dmcType) });
  73. }
  74. if (dmcType.HasFlag(EnumSigCheckTypeDto.DAMA) && fsHz != 96000)
  75. {
  76. yield return new ValidationResult("DAMA检测采样率只支持96K", new[] { nameof(this.fsHz) });
  77. }
  78. if (dmcType.HasFlag(EnumSigCheckTypeDto.IBS) && band != 5 && band != 25)
  79. {
  80. yield return new ValidationResult("IBS检测信号带宽只支持5K、25K两种", new[] { nameof(this.band) });
  81. }
  82. }
  83. yield return null;
  84. }
  85. }
  86. }