1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283 |
- using System;
- using System.Collections.Generic;
- using System.ComponentModel;
- using System.ComponentModel.DataAnnotations;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using XdCxRhDW.Dto.Attribute;
- namespace XdCxRhDW.Dto
- {
- /// <summary>
- /// 检测计算模型
- /// </summary>
- public class DetectDto : IValidatableObject
- {
- /// <summary>
- /// 调用Upload接口上传文件后返回的文件名
- /// </summary>
- [FileMustExist]
- public string file1 { get; set; }
- /// <summary>
- /// 检测类型
- /// </summary>
- public DmcType dmcType { get; set; }
- /// <summary>
- /// 采样率 Hz
- /// </summary>
- [RangeDouble(0, 100e6)]
- public double fsHz { get; set; }
- /// <summary>
- /// 信号带宽(KHz,只对IBS信号有效,默认25KHz)
- /// </summary>
- [RangeDouble(0, 100)]
- public double? band { get; set; } = 25;
- public IEnumerable<ValidationResult> Validate(ValidationContext validationContext)
- {
- var fields = typeof(DmcType).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
- yield return null;
- }
- }
- /// <summary>
- /// 检测类型
- /// </summary>
- [Flags]
- public enum DmcType
- {
- /// <summary>
- /// DAMA检测
- /// </summary>
- [Display(Name = "DAMA检测")]
- DAMA = 1,
- /// <summary>
- /// IBS检测
- /// </summary>
- [Display(Name = "IBS检测")]
- IBS = 2,
- /// <summary>
- /// 能量检测
- /// </summary>
- [Display(Name = "能量检测")]
- Ky5758 = 4
- }
- }
|