1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.ComponentModel.DataAnnotations;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace DW5S.DTO
- {
- /// <summary>
- /// 检测计算模型
- /// </summary>
- public class DetectDto : IValidatableObject
- {
- /// <summary>
- /// 调用Upload接口上传文件后返回的文件名
- /// </summary>
- public string file1 { get; set; }
- /// <summary>
- /// 检测类型
- /// </summary>
- public EnumSigCheckTypeDto dmcType { get; set; }
- /// <summary>
- /// 多个检测类型时是否合并检测结果(重叠的信号只算一个,重叠区域超过500样点则认为是同一个)
- /// </summary>
- public bool mergeRes { get; set; } = false;
- /// <summary>
- /// 采样率 Hz
- /// </summary>
- [Range(0, 100e6)]
- public double fsHz { get; set; }
- /// <summary>
- /// 信号带宽(KHz),会对检测文件进行滤波处理
- /// </summary>
- [Range(0, 96d)]
- public double band { get; set; } = 25;
- /// <summary>
- /// 是否对信号进行识别(获取调制类型、速率、频偏等)
- /// </summary>
- public bool SigProc { get; set; } = false;
- /// <summary>
- ///
- /// </summary>
- /// <param name="validationContext"></param>
- /// <returns></returns>
- public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
- {
- var fields = typeof(EnumSigCheckTypeDto).GetFields().Where(p => p.FieldType.IsEnum);
- bool hasError = true;
- foreach (var field in fields)
- {
- var value = field.GetValue(null);
- if (this.dmcType.HasFlag((Enum)value))
- {
- hasError = false;
- break;
- }
- }
- if (hasError)
- yield return new ValidationResult("检测类型错误", new[] { nameof(this.dmcType) });
- else
- {
- if (dmcType.HasFlag(EnumSigCheckTypeDto.Normal))
- {
- yield return new ValidationResult("常规信号不需要检测", new[] { nameof(this.dmcType) });
- }
- if (dmcType.HasFlag(EnumSigCheckTypeDto.DAMA) && fsHz != 96000)
- {
- yield return new ValidationResult("DAMA检测采样率只支持96K", new[] { nameof(this.fsHz) });
- }
- if (dmcType.HasFlag(EnumSigCheckTypeDto.IBS) && band != 5 && band != 25)
- {
- yield return new ValidationResult("IBS检测信号带宽只支持5K、25K两种", new[] { nameof(this.band) });
- }
- }
- yield return null;
- }
- }
- }
|