AdcFile.cs 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131
  1. //using System;
  2. //using System.Collections.Generic;
  3. //using System.Globalization;
  4. //using System.IO;
  5. //using System.Text;
  6. //using System.Text.RegularExpressions;
  7. //namespace Ips.Library.Entity
  8. //{
  9. // public class AdcFile
  10. // {
  11. // public static string FolderFormatString = "yyyyMMdd_HH";
  12. // public static string FileTimeFormatString = "yyyyMMddHHmmss";
  13. // public static string DefaultFileNameFmt = "{0:yyyyMMddHHmmss}_T{1}_F{2}_B{3:###0000000}_N{4}.dat";
  14. // public AdcFile() { }
  15. // public AdcFile(
  16. // DateTime sigTime,
  17. // int chNum,
  18. // long freqPoint,
  19. // int bandWidth,
  20. // string sigName)
  21. // {
  22. // SigTime = sigTime;
  23. // ChNum = chNum;
  24. // FreqPoint = freqPoint;
  25. // BandWidth = bandWidth;
  26. // SigName = sigName;
  27. // }
  28. // /// <summary>
  29. // /// 信号时间
  30. // /// </summary>
  31. // public DateTime SigTime { get; set; }
  32. // /// <summary>
  33. // /// 通道编号
  34. // /// </summary>
  35. // public int ChNum { get; set; }
  36. // /// <summary>
  37. // /// 信号频点(Hz)
  38. // /// </summary>
  39. // public long FreqPoint { get; set; }
  40. // /// <summary>
  41. // /// 信号带宽(Hz)
  42. // /// </summary>
  43. // public int BandWidth { get; set; }
  44. // /// <summary>
  45. // /// 信号名称
  46. // /// </summary>
  47. // public string SigName { get; set; }
  48. // public string GetFolderName() => SigTime.ToString(FolderFormatString);
  49. // public virtual string GetFileName()
  50. // {
  51. // StringBuilder sb = new StringBuilder(SigTime.ToString(FileTimeFormatString));
  52. // if (ChNum > 0)
  53. // {
  54. // sb.AppendFormat("_T{0}", ChNum);
  55. // }
  56. // if (FreqPoint > 0)
  57. // {
  58. // sb.AppendFormat("_F{0}", FreqPoint);
  59. // }
  60. // if (BandWidth > 0)
  61. // {
  62. // sb.AppendFormat("_B{0:###0000000}", BandWidth);
  63. // }
  64. // if (!string.IsNullOrWhiteSpace(SigName))
  65. // {
  66. // sb.AppendFormat("_N{0}", SigName);
  67. // }
  68. // sb.Append(".dat");
  69. // return sb.ToString();
  70. // }
  71. // public string GetFullName(string rootDir)
  72. // {
  73. // string fullName;
  74. // string folderName = GetFolderName();
  75. // string fileName = GetFileName();
  76. // if (string.IsNullOrWhiteSpace(rootDir))
  77. // {
  78. // fullName = Path.Combine(folderName, fileName);
  79. // }
  80. // else
  81. // {
  82. // fullName = Path.Combine(rootDir, folderName, fileName);
  83. // }
  84. // return fullName;
  85. // }
  86. // public static AdcFile Parse(string fileName)
  87. // {
  88. // if (string.IsNullOrWhiteSpace(fileName)) return null;
  89. // var nameItems = fileName.Split("_", StringSplitOptions.RemoveEmptyEntries);
  90. // if (nameItems.Length == 0) return null;
  91. // var result = new AdcFile();
  92. // if (DateTime.TryParseExact(nameItems[0], FileTimeFormatString, CultureInfo.CurrentCulture, DateTimeStyles.None, out DateTime sigTime))
  93. // {
  94. // result.SigTime = sigTime;
  95. // }
  96. // foreach (var item in nameItems)
  97. // {
  98. // char key = item[0];
  99. // string val = item.Substring(1);
  100. // switch (key)
  101. // {
  102. // case 'T':
  103. // result.ChNum = int.TryParse(val, out int _chnum) ? _chnum : 0;
  104. // break;
  105. // case 'F':
  106. // result.FreqPoint = long.TryParse(val, out long _freqpoint) ? _freqpoint : 0;
  107. // break;
  108. // case 'B':
  109. // result.BandWidth = int.TryParse(val, out int _bandwidth) ? _bandwidth : 0;
  110. // break;
  111. // case 'N':
  112. // result.SigName = val;
  113. // break;
  114. // }
  115. // }
  116. // return result;
  117. // }
  118. // }
  119. //}