AbstractAcquirer_AnalogChannel.cs 80 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.IO;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using System.Diagnostics;
  8. using System.Threading;
  9. using Uestc.Auto6.Dso.ComModel;
  10. using Uestc.Auto6.Dso.Hardware.Calibration.Data.Base;
  11. using Uestc.Auto6.Dso.MathExt;
  12. using System.Diagnostics.CodeAnalysis;
  13. namespace Uestc.Auto6.Dso.Hardware.Driver
  14. {
  15. /// <summary>
  16. /// 模拟通道波形采集
  17. /// </summary>
  18. public abstract class AbstractAcquirer_AnalogChannel : AbstractAcquirer
  19. {
  20. internal Abstract_LongStorage? LongStorage
  21. {
  22. get;
  23. init;
  24. }
  25. /// <summary>
  26. /// 正在采集的采集参数
  27. /// </summary>
  28. internal readonly AcquireAttribute AcquingParameters = new AcquireAttribute();
  29. /// <summary>
  30. /// 已经采集的数据的采集参数。在读回数据后赋值
  31. /// </summary>
  32. internal readonly AcquireAttribute AcquedParameters = new AcquireAttribute();
  33. Dictionary<DbiCoefficientsTablesType, List<DBI_CoefTableSendItem>> EmptyAcqBdCoefTablesSendDefine = new Dictionary<DbiCoefficientsTablesType, List<DBI_CoefTableSendItem>>();
  34. /// <summary>
  35. /// 获取采集板各种系数表的发送配置。只有DBI项目存在!!!
  36. /// </summary>
  37. internal virtual Dictionary<DbiCoefficientsTablesType, List<DBI_CoefTableSendItem>> AcqBdCoefTablesSendDefine
  38. {
  39. get => EmptyAcqBdCoefTablesSendDefine;
  40. }
  41. internal virtual Dictionary<string, AmpCoefficientFileInfo>? ChannelPerScaleAmpFreqCoefficientsDefine
  42. {
  43. get => ourChannelPerScaleAmpFreqCoefficientsDefine;
  44. }
  45. private readonly Dictionary<string, AmpCoefficientFileInfo>? ourChannelPerScaleAmpFreqCoefficientsDefine = new()
  46. {
  47. ["C1_1"] = new AmpCoefficientFileInfo() { FileName = $@".\AfcCaliDataFiles\Afc_C1_1mV.txt" },
  48. ["C1_2"] = new AmpCoefficientFileInfo() { FileName = $@".\AfcCaliDataFiles\Afc_C1_2mV.txt" },
  49. ["C1_5"] = new AmpCoefficientFileInfo() { FileName = $@".\AfcCaliDataFiles\Afc_C1_5mV.txt" },
  50. ["C1_10"] = new AmpCoefficientFileInfo() { FileName = $@".\AfcCaliDataFiles\Afc_C1_10mV.txt" },
  51. ["C1_20"] = new AmpCoefficientFileInfo() { FileName = $@".\AfcCaliDataFiles\Afc_C1_20mV.txt" },
  52. ["C1_50"] = new AmpCoefficientFileInfo() { FileName = $@".\AfcCaliDataFiles\Afc_C1_50mV.txt" },
  53. ["C1_100"] = new AmpCoefficientFileInfo() { FileName = $@".\AfcCaliDataFiles\Afc_C1_100mV.txt" },
  54. ["C1_200"] = new AmpCoefficientFileInfo() { FileName = $@".\AfcCaliDataFiles\Afc_C1_200mV.txt" },
  55. ["C1_500"] = new AmpCoefficientFileInfo() { FileName = $@".\AfcCaliDataFiles\Afc_C1_500mV.txt" },
  56. ["C1_1000"] = new AmpCoefficientFileInfo() { FileName = $@".\AfcCaliDataFiles\Afc_C1_1000mV.txt" },
  57. ["C2_1"] = new AmpCoefficientFileInfo() { FileName = $@".\AfcCaliDataFiles\Afc_C2_1mV.txt" },
  58. ["C2_2"] = new AmpCoefficientFileInfo() { FileName = $@".\AfcCaliDataFiles\Afc_C2_2mV.txt" },
  59. ["C2_5"] = new AmpCoefficientFileInfo() { FileName = $@".\AfcCaliDataFiles\Afc_C2_5mV.txt" },
  60. ["C2_10"] = new AmpCoefficientFileInfo() { FileName = $@".\AfcCaliDataFiles\Afc_C2_10mV.txt" },
  61. ["C2_20"] = new AmpCoefficientFileInfo() { FileName = $@".\AfcCaliDataFiles\Afc_C2_20mV.txt" },
  62. ["C2_50"] = new AmpCoefficientFileInfo() { FileName = $@".\AfcCaliDataFiles\Afc_C2_50mV.txt" },
  63. ["C2_100"] = new AmpCoefficientFileInfo() { FileName = $@".\AfcCaliDataFiles\Afc_C2_100mV.txt" },
  64. ["C2_200"] = new AmpCoefficientFileInfo() { FileName = $@".\AfcCaliDataFiles\Afc_C2_200mV.txt" },
  65. ["C2_500"] = new AmpCoefficientFileInfo() { FileName = $@".\AfcCaliDataFiles\Afc_C2_500mV.txt" },
  66. ["C2_1000"] = new AmpCoefficientFileInfo() { FileName = $@".\AfcCaliDataFiles\Afc_C2_1000mV.txt" },
  67. ["C3_1"] = new AmpCoefficientFileInfo() { FileName = $@".\AfcCaliDataFiles\Afc_C3_1mV.txt" },
  68. ["C3_2"] = new AmpCoefficientFileInfo() { FileName = $@".\AfcCaliDataFiles\Afc_C3_2mV.txt" },
  69. ["C3_5"] = new AmpCoefficientFileInfo() { FileName = $@".\AfcCaliDataFiles\Afc_C3_5mV.txt" },
  70. ["C3_10"] = new AmpCoefficientFileInfo() { FileName = $@".\AfcCaliDataFiles\Afc_C3_10mV.txt" },
  71. ["C3_20"] = new AmpCoefficientFileInfo() { FileName = $@".\AfcCaliDataFiles\Afc_C3_20mV.txt" },
  72. ["C3_50"] = new AmpCoefficientFileInfo() { FileName = $@".\AfcCaliDataFiles\Afc_C3_50mV.txt" },
  73. ["C3_100"] = new AmpCoefficientFileInfo() { FileName = $@".\AfcCaliDataFiles\Afc_C3_100mV.txt" },
  74. ["C3_200"] = new AmpCoefficientFileInfo() { FileName = $@".\AfcCaliDataFiles\Afc_C3_200mV.txt" },
  75. ["C3_500"] = new AmpCoefficientFileInfo() { FileName = $@".\AfcCaliDataFiles\Afc_C3_500mV.txt" },
  76. ["C3_1000"] = new AmpCoefficientFileInfo() { FileName = $@".\AfcCaliDataFiles\Afc_C3_1000mV.txt" },
  77. ["C4_1"] = new AmpCoefficientFileInfo() { FileName = $@".\AfcCaliDataFiles\Afc_C4_1mV.txt" },
  78. ["C4_2"] = new AmpCoefficientFileInfo() { FileName = $@".\AfcCaliDataFiles\Afc_C4_2mV.txt" },
  79. ["C4_5"] = new AmpCoefficientFileInfo() { FileName = $@".\AfcCaliDataFiles\Afc_C4_5mV.txt" },
  80. ["C4_10"] = new AmpCoefficientFileInfo() { FileName = $@".\AfcCaliDataFiles\Afc_C4_10mV.txt" },
  81. ["C4_20"] = new AmpCoefficientFileInfo() { FileName = $@".\AfcCaliDataFiles\Afc_C4_20mV.txt" },
  82. ["C4_50"] = new AmpCoefficientFileInfo() { FileName = $@".\AfcCaliDataFiles\Afc_C4_50mV.txt" },
  83. ["C4_100"] = new AmpCoefficientFileInfo() { FileName = $@".\AfcCaliDataFiles\Afc_C4_100mV.txt" },
  84. ["C4_200"] = new AmpCoefficientFileInfo() { FileName = $@".\AfcCaliDataFiles\Afc_C4_200mV.txt" },
  85. ["C4_500"] = new AmpCoefficientFileInfo() { FileName = $@".\AfcCaliDataFiles\Afc_C4_500mV.txt" },
  86. ["C4_1000"] = new AmpCoefficientFileInfo() { FileName = $@".\AfcCaliDataFiles\Afc_C4_1000mV.txt" },
  87. };
  88. internal virtual List<List<ChannelBdAdcInputDefine>>? FirstInitChannelBdAdcInputDefines => null;
  89. #region 触发深度等
  90. internal virtual void DiscardDotAtTriggerTypeIsSerialMode()
  91. {
  92. if ((!Hd.CurrDebugVarints.bEnable_DigitTrigger) || Hd.CurrDebugVarints.bEnable_AdcDataDebugMode)
  93. return;
  94. if (Hd.CurrHdMessage!.Trigger!.TrigType != TriggerType.Serial)
  95. return;
  96. UInt32 trigSource = Hd.currProduct.Ctrl_Trigger!.CurrentTrigSource();
  97. if (trigSource >= ChannelIdExt.AnaChnlNum)
  98. return;
  99. ChannelBdAdcInputDefine channelBdAdcInputDefine = GetChannelAcqBdAdcInputCorresponding((int)trigSource) ?? new ChannelBdAdcInputDefine() { BdNo = AcqBdNo.B3 };
  100. UInt32 skipcount = (UInt32)(Hd.currProduct!.AcqBd!.ReadReg(AcqBdReg.R.Decoder_TimeDelaycntlock, channelBdAdcInputDefine.BdNo));
  101. UInt32 skipcount_bound = (UInt32)(Hd.currProduct?.Acquirer_AnalogChannel?.AcquingParameters.HardwareExtractNum) - 1;
  102. if (skipcount < skipcount_bound)
  103. {
  104. skipcount = skipcount +(UInt32) (Hd.currProduct?.Acquirer_AnalogChannel?.AcquingParameters.HardwareExtractNum);
  105. }
  106. SerialProtocolType protocolType = Hd.CurrHdMessage!.Trigger!.TrigDecoder!.ProtocolType;
  107. if ((Hd.CurrHdMessage!.Trigger!.TrigDecoder.ProtocolOptions is HdMessage.ProtocolUSBOptions usb && usb.SignalRate == ProtocolUSB.SignalRate.HighRate ) || protocolType == SerialProtocolType.PCIe || protocolType == SerialProtocolType.SATA || Hd.CurrHdMessage!.Timebase!.TmbScaleIndex <= (int)AnaChnlTimebaseIndex.Lv100n)
  108. skipcount = 0;
  109. long mergeRoadCount = 40;
  110. if (Hd.currProduct.ProductType == ProductType.B21_DBI16G || Hd.currProduct.ProductType == ProductType.B21_DBI20G || Hd.currProduct.ProductType == ProductType.B21_MD8G || Hd.currProduct.ProductType == ProductType.B21_HB8G)
  111. mergeRoadCount = 80;
  112. skipcount = (UInt32)(mergeRoadCount * skipcount / ((long)(Hd.currProduct?.Acquirer_AnalogChannel?.AcquingParameters.HardwareExtractNum ?? 1U)));
  113. if (skipcount > 0 && (skipcount<500)) //500????????
  114. {
  115. for (int displayChIndex = 0; displayChIndex < ChannelIdExt.AnaChnlNum; displayChIndex++)
  116. AcqedDataPool.AnalogChData.AllChannelData[displayChIndex].RemoveRange(0, (int)skipcount);
  117. }
  118. }
  119. internal virtual UInt32 DefaultTrigSensitivity
  120. {
  121. get => 100;
  122. }
  123. internal virtual Int32 Trig_LS_TrigOffset
  124. {
  125. get
  126. {
  127. return 8 * 15;
  128. }
  129. }
  130. internal virtual Int32 Trig_LS_DiscardNumMax
  131. {
  132. get
  133. {
  134. return 4096;
  135. }
  136. }
  137. internal virtual ChannelBdAdcInputDefine? GetChannelAcqBdAdcInputCorresponding(int channelIndex) => null;
  138. internal const int Trig_XDepthFixedAddDots = 400;
  139. internal virtual TrigSourceParams GetTrigSourceParams(UInt32 trigChannelFromSoft)
  140. {
  141. UInt32 AcqBd_TrigCtrl_1st_SourceWhichAdcStartWith0 = 0;
  142. UInt32 ProcBd_TrigCtrl_1st_SourceWhichAcqBdStartWith0 = 0;
  143. UInt32 ProcBd_TrigCtrl_2nd_SourceWhichChannelStartWith0 = 0;
  144. //1.判断触发信号来自于采集板哪个ADC,所有采集板配置相同,所有被选中通道的触发信号都送到处理板做二次选择
  145. //相当于对应一个采集板上的哪个ADC。以触发的物理通道接入的那个ADC为准。ADC1:发0,ADC2:发1,两片:发0
  146. if (trigChannelFromSoft < ChannelIdExt.AnaChnlNum)
  147. {
  148. if (Hd.currProduct!.Acquirer_AnalogChannel!.ChannelBdAdcInputDefines != null)
  149. AcqBd_TrigCtrl_1st_SourceWhichAdcStartWith0 = (UInt32)Hd.currProduct!.Acquirer_AnalogChannel!.ChannelBdAdcInputDefines![0][(int)trigChannelFromSoft][0].AdcIndex;
  150. }
  151. //2.一级触发源:表示来自于那个采集板的信号。用0,1,2,表示。
  152. if (trigChannelFromSoft < ChannelIdExt.AnaChnlNum)
  153. {
  154. uint acqBdIndex = 0;
  155. if (Hd.currProduct!.Acquirer_AnalogChannel!.ChannelBdAdcInputDefines != null)
  156. {
  157. AcqBdNo acqBd = Hd.currProduct!.Acquirer_AnalogChannel!.ChannelBdAdcInputDefines![0][(int)trigChannelFromSoft][0].BdNo;
  158. for (AcqBdNo acqBdNo = AcqBdNo.B1; acqBdNo <= AcqBdNo.B8; acqBdNo++)
  159. {
  160. if (Hd.currProduct?.AcqBd?.ExistsDefines?[(int)acqBdNo] ?? false)
  161. {
  162. if (acqBd == acqBdNo)
  163. break;
  164. acqBdIndex++;
  165. }
  166. }
  167. }
  168. ProcBd_TrigCtrl_1st_SourceWhichAcqBdStartWith0 = acqBdIndex;
  169. }
  170. //二级触发,表示对应的物理通道,与DMA中的数据路数一致
  171. if (trigChannelFromSoft < ChannelIdExt.AnaChnlNum)
  172. ProcBd_TrigCtrl_2nd_SourceWhichChannelStartWith0 = trigChannelFromSoft;
  173. else
  174. ProcBd_TrigCtrl_2nd_SourceWhichChannelStartWith0 = (uint)(trigChannelFromSoft % ChannelIdExt.AnaChnlNum);//乱整
  175. return new TrigSourceParams()
  176. {
  177. AcqBd_TrigCtrl_1st_SourceWhichAdcStartWith0 = AcqBd_TrigCtrl_1st_SourceWhichAdcStartWith0,
  178. ProcBd_TrigCtrl_1st_SourceWhichAcqBdStartWith0 = ProcBd_TrigCtrl_1st_SourceWhichAcqBdStartWith0,
  179. ProcBd_TrigCtrl_2nd_SourceWhichChannelStartWith0 = ProcBd_TrigCtrl_2nd_SourceWhichChannelStartWith0
  180. };
  181. }
  182. private Boolean IsInterpolation()
  183. {
  184. return Hd.currProduct?.Acquirer_AnalogChannel?.AcquingParameters.InterpolationNum > 1 ? true : false;
  185. }
  186. internal virtual Int64 GetTrigXDepth()
  187. {
  188. double tmbScale = Hd.CurrHdMessage?.Timebase?.TmbScale ?? 1.0;
  189. double tmbPosition = Hd.CurrHdMessage?.Timebase?.TmbPosition ?? 0;
  190. double perDataByfs_AtStorage = (Hd.currProduct?.Acquirer_AnalogChannel?.AcquingParameters.PerDataByfs_AtStorage ?? 50_000_000); //20G sample,50_000_000
  191. Int64 depth = (Int64)((tmbScale * Constants.VIS_XDIVS_NUM / 2 - tmbPosition) * 1_000_000_000 / perDataByfs_AtStorage);
  192. if (!Hd.AnalogChannel?.IsNeedPostProcessByMatlab ?? false)
  193. return depth;
  194. else
  195. return depth + Trig_XDepthFixedAddDots;
  196. }
  197. //point 1
  198. /// <summary>
  199. /// 应该这样计算
  200. /// </summary>
  201. /// <param name="xdepth"></param>
  202. /// <param name="trigSource"></param>
  203. /// <returns></returns>
  204. internal virtual UInt32 GetAcqBdTrigDiscardColumnNums(Int64 xdepth, UInt32 trigSource)
  205. {
  206. if (xdepth < 0)
  207. return 0;
  208. double mergeRoadCount = 40d;
  209. UInt64 discard_tmp = (UInt64)(xdepth % mergeRoadCount); ;
  210. if (IsInterpolation())
  211. {
  212. AnaChnlTimebaseIndex TmbScaleIndex = (AnaChnlTimebaseIndex)(Hd.CurrHdMessage?.Timebase?.TmbScaleIndex ?? (int)AnaChnlTimebaseIndex.Lv10n);//20220218
  213. if (discard_tmp == 0)
  214. return (uint)(discard_tmp + mergeRoadCount * (ulong)Hd.currProduct.Ctrl_Trigger!.InterpolationLevelDiscardNumTable![TmbScaleIndex] - 2 + 20);
  215. else
  216. return (uint)((mergeRoadCount - discard_tmp) * (ulong)Hd.currProduct.Ctrl_Trigger!.InterpolationLevelDiscardNumTable![TmbScaleIndex] + mergeRoadCount - 2 + 20);
  217. }
  218. else
  219. {
  220. if (discard_tmp == 0)
  221. return (uint)(discard_tmp - 2 + 20);
  222. else
  223. return (uint)(mergeRoadCount - discard_tmp - 2 + 20);
  224. }
  225. }
  226. //point 2
  227. internal virtual UInt32 ourGetSigProDiscardNum() //计算总的数字信号处理丢点数
  228. {
  229. int LengthOfInterpFilter_1st = Hd.currProduct!.HardwareConfig!.LocalCoefficientsTableMeanings[Calibration.Data.Base.CoefficientsTableType.Coefficients1].LengthOfPartA; //一级插值滤波器阶数
  230. int LengthOfInterpFilter_2nd = Hd.currProduct!.HardwareConfig!.LocalCoefficientsTableMeanings[Calibration.Data.Base.CoefficientsTableType.Coefficients1].LengthOfPartB; //二级插值滤波器阶数
  231. //int LengthOfTiadc = Hd.currProduct!.HardwareConfig!.LocalCoefficientsTableMeanings[Calibration.Data.Base.CoefficientsTableType.Coefficients2].Length; //TIADC滤波器阶数
  232. UInt32 TiADCDiscard = 256; //进入TIADC模块会丢掉256个点
  233. int LengthOfAfc = 0;
  234. if (Hd.currProduct!.HardwareConfig!.LocalCoefficientsTableMeanings.ContainsKey(Calibration.Data.Base.CoefficientsTableType.Coefficients3))
  235. LengthOfAfc = Hd.currProduct!.HardwareConfig!.LocalCoefficientsTableMeanings[Calibration.Data.Base.CoefficientsTableType.Coefficients3].Length; //AFC滤波器阶数
  236. int LengthOfPfc = 0;
  237. if (Hd.currProduct!.HardwareConfig!.LocalCoefficientsTableMeanings.ContainsKey(Calibration.Data.Base.CoefficientsTableType.Coefficients4))
  238. LengthOfPfc = Hd.currProduct!.HardwareConfig!.LocalCoefficientsTableMeanings[Calibration.Data.Base.CoefficientsTableType.Coefficients4].Length; //PFC滤波器阶数
  239. UInt32 InterpDiscard = ourGetInterpDiscardNum(LengthOfInterpFilter_1st, LengthOfInterpFilter_2nd);
  240. //UInt32 Discard = (uint)(InterpDiscard + LengthOfTiadc / 2 + LengthOfAfc / 2 + LengthOfPfc / 2);
  241. UInt32 Discard = (uint)(InterpDiscard + TiADCDiscard + LengthOfAfc / 2 + 2 * LengthOfPfc / 5);
  242. return Discard;
  243. }
  244. internal virtual UInt32 ourGetInterpDiscardNum(int LengthOfInterpFilter_1st, int LengthOfInterpFilter_2nd) //计算总的插值滤波器丢点数
  245. {
  246. AnaChnlTimebaseIndex currAnaChnlTimebaseIndex = (AnaChnlTimebaseIndex)(Hd.CurrHdMessage?.Timebase?.TmbScaleIndex ?? (int)AnaChnlTimebaseIndex.Lv100u);
  247. UInt32 ExtractNum = (UInt32)(Hd.currProduct?.Acquirer_AnalogChannel?.AcquingParameters.HardwareExtractNum ?? 1U);
  248. UInt32 InterpNum = (UInt32)(Hd.currProduct?.Acquirer_AnalogChannel?.AcquingParameters.InterpolationNum ?? 1U);
  249. UInt32 Max_1stInterpRatio = 10; //一级最大插值倍率
  250. UInt32 DiscardBforeInterp = 2; //进入插值模块之前丢掉两个点
  251. UInt32 InterpDiscard = 0;
  252. if (InterpNum > Max_1stInterpRatio)
  253. InterpDiscard = (UInt32)(DiscardBforeInterp * InterpNum + LengthOfInterpFilter_1st / ExtractNum / 2);
  254. else
  255. InterpDiscard = (UInt32)((DiscardBforeInterp * InterpNum + LengthOfInterpFilter_1st / ExtractNum / 2) * InterpNum + LengthOfInterpFilter_2nd / ExtractNum / 2);
  256. return InterpDiscard;
  257. }
  258. internal virtual UInt64 GetProcBd_LA_TrigCtrl_1st_PreDepth(Int64 xdepth, uint trigSource)
  259. {
  260. return GetProcBdTrigCtrl_1st_PreDepth(xdepth, trigSource);
  261. }
  262. internal virtual UInt64 GetProcBdTrigCtrl_1st_PreDepth(Int64 xdepth, uint trigSource)
  263. {
  264. //计算触发信号板间通信偏移量
  265. uint trigChannel = (uint)trigSource;
  266. UInt32 SigProDiscardNum = ourGetSigProDiscardNum();
  267. AnaChnlTimebaseIndex curTimeBase = (AnaChnlTimebaseIndex)(Hd.CurrHdMessage?.Timebase?.TmbScaleIndex ?? (Int32)AnaChnlTimebaseIndex.Lv5n);
  268. //if (!adjustnumTableNew.ContainsKey(curTimeBase))
  269. // throw new Exception("adjustnumTableNew not contain curTimeBase:" + curTimeBase.ToString());
  270. UInt32 adjust_num = 0;// adjustnumTableNew[curTimeBase];
  271. UInt32 xdpeth_fix;
  272. double mergeRoadCount;//并行路数
  273. // ulong hardwareExtractNum = Hd.currProduct?.Acquirer_AnalogChannel?.AcquingParameters.HardwareExtractNum ?? 1; 硬件抽取数
  274. if (Hd.CurrHdMessage!.Analog![trigSource].InputSource == AnaChnlIpnutSource.BNC)
  275. {
  276. mergeRoadCount = 40d;
  277. }
  278. else
  279. {
  280. mergeRoadCount = 80d;
  281. }
  282. bool condition = false;
  283. if (condition == true)
  284. {
  285. xdpeth_fix = (UInt32)xdepth + SigProDiscardNum + adjust_num;
  286. }
  287. else
  288. {
  289. xdpeth_fix = (UInt32)xdepth + adjust_num;
  290. }
  291. UInt32 PreDepth = (UInt32)Math.Floor(xdpeth_fix / mergeRoadCount) + (UInt32)SysAutoCalibration.Default.Trig_AcqProcBdLooptimBySysClockCount((int)trigChannel);
  292. return PreDepth;
  293. }
  294. //point 3
  295. internal virtual UInt64 GetProcBdTrigCtrl_1st_PosDepth(Int64 xdepth, UInt32 trigSource)
  296. {
  297. if (xdepth > 0)
  298. return 0;
  299. ulong hardwareExtractNum = Hd.currProduct?.Acquirer_AnalogChannel?.AcquingParameters.HardwareExtractNum ?? 1;
  300. double mergeRoadCount = 40d;
  301. UInt64 result = (UInt64)Math.Floor(-xdepth / mergeRoadCount) * hardwareExtractNum;
  302. return result;
  303. }
  304. //point 4
  305. internal virtual UInt32 GetProcBdTrigCtrl_2nd_PreDepth(Int64 xdepth, UInt32 trigSource)
  306. {
  307. UInt32 result = 0;
  308. if (xdepth > 0)
  309. result = (uint)(xdepth);
  310. return result;
  311. }
  312. //point 5
  313. internal virtual UInt32 GetProcBdTrigCtrl_2nd_SearchRange(Int64 xdepth, UInt32 trigSource)
  314. {
  315. UInt32 result = 0;
  316. if (xdepth < 0)
  317. result = 0;
  318. else if (IsInterpolation())
  319. result = (uint)(16 * 1024 - (1000 - xdepth) - 1000);
  320. else
  321. result = 5000;
  322. return result;
  323. }
  324. internal virtual (UInt32 Up, UInt32 Dn, UInt32 Edge) GetDigitTrigCompVolt()
  325. {
  326. UInt32 compVolt;
  327. int trigSource = (int)Hd.currProduct!.Ctrl_Trigger!.CurrentTrigSource();
  328. int trigSourceYPos = AbstractController_Trigger.AdcCenterValue;
  329. bool isPositive = true;
  330. if (trigSource < ChannelIdExt.AnaChnlNum)
  331. {
  332. HdMessage.AnalogOptions analogParameters = Hd.CurrHdMessage!.Analog![trigSource];
  333. trigSourceYPos = (int)(Constants.SAMPS_PER_YDIV * analogParameters.Position / analogParameters.Scale + AbstractController_Trigger.AdcCenterValue);
  334. }
  335. else
  336. return (0, 0, (UInt32)(((Hd.CurrHdMessage!.Trigger!.TrigType == TriggerType.Edge && ChannelIdExt.IsDigital((ChannelId)trigSource) ? 1 : 0) << 1) | ((Hd.CurrHdMessage!.Trigger!.Edge!.Slope == EdgeSlope.Rise ? 1 : 0))));//LA
  337. switch (Hd.CurrHdMessage?.Trigger?.TrigType)
  338. {
  339. case TriggerType.Edge:
  340. compVolt = (UInt32)((Hd.CurrHdMessage!.Trigger!.Edge!.PosIndex) / Constants.IDX_PER_YDIV * AbstractController_Trigger.PerYDivAdcSamples + trigSourceYPos);
  341. isPositive = Hd.CurrHdMessage!.Trigger!.Edge!.Slope == EdgeSlope.Rise;
  342. break;
  343. case TriggerType.PulseWidth:
  344. compVolt = (UInt32)((Hd.CurrHdMessage!.Trigger!.Pulse!.PosIndex) / Constants.IDX_PER_YDIV * AbstractController_Trigger.PerYDivAdcSamples + trigSourceYPos);//正脉宽以下降沿为判断基准,反之亦然
  345. isPositive = Hd.CurrHdMessage!.Trigger!.Pulse!.Polarity == PulsePolarity.Positive;
  346. break;
  347. case TriggerType.Runt:
  348. compVolt = (UInt32)((Hd.CurrHdMessage!.Trigger!.Runt!.LowerPosIndex) / Constants.IDX_PER_YDIV * AbstractController_Trigger.PerYDivAdcSamples + trigSourceYPos);//同上
  349. isPositive = Hd.CurrHdMessage!.Trigger!.Runt!.Polarity == PulsePolarity.Positive;
  350. break;
  351. case TriggerType.Transition:
  352. compVolt = (UInt32)((Hd.CurrHdMessage!.Trigger!.Transition!.LowerPosIndex) / Constants.IDX_PER_YDIV * AbstractController_Trigger.PerYDivAdcSamples + trigSourceYPos);
  353. isPositive = Hd.CurrHdMessage!.Trigger!.Transition!.Slope == EdgeSlope.Rise;
  354. break;
  355. case TriggerType.TimeOut:
  356. compVolt = (UInt32)((Hd.CurrHdMessage!.Trigger!.TimeOut!.PosIndex) / Constants.IDX_PER_YDIV * AbstractController_Trigger.PerYDivAdcSamples + trigSourceYPos);
  357. isPositive = Hd.CurrHdMessage!.Trigger!.TimeOut!.Polarity == LevelPolarity.Positive;
  358. break;
  359. case TriggerType.Glitch:
  360. compVolt = (UInt32)((Hd.CurrHdMessage!.Trigger!.Glitch!.PosIndex) / Constants.IDX_PER_YDIV * AbstractController_Trigger.PerYDivAdcSamples + trigSourceYPos);
  361. isPositive = Hd.CurrHdMessage!.Trigger!.Glitch!.Polarity == PulsePolarity.Positive;
  362. break;
  363. case TriggerType.SetupHold:
  364. compVolt = (UInt32)((Hd.CurrHdMessage!.Trigger!.SetupHold!.ClkPosition.Value) * 10 / Constants.IDX_PER_YDIV * AbstractController_Trigger.PerYDivAdcSamples + trigSourceYPos);
  365. break;
  366. case TriggerType.Pattern:
  367. //10是换算
  368. compVolt = (UInt32)((Hd.CurrHdMessage?.Trigger?.Pattern.Positions[trigSource].Value) * 10 / Constants.IDX_PER_YDIV * AbstractController_Trigger.PerYDivAdcSamples + trigSourceYPos);
  369. isPositive = Hd.CurrHdMessage!.Trigger!.Pattern!.Positions[trigSource].Condition == PatLevelCondition.GreaterThan;
  370. break;
  371. case TriggerType.State:
  372. compVolt = (UInt32)((Hd.CurrHdMessage?.Trigger?.State?.Positions[trigSource].Value) * 10 / Constants.IDX_PER_YDIV * AbstractController_Trigger.PerYDivAdcSamples + trigSourceYPos);
  373. break;
  374. case TriggerType.Interval:
  375. compVolt = (UInt32)((Hd.CurrHdMessage!.Trigger!.Interval!.PosIndex) / Constants.IDX_PER_YDIV * AbstractController_Trigger.PerYDivAdcSamples + AbstractController_Trigger.AdcCenterValue);
  376. isPositive = Hd.CurrHdMessage!.Trigger!.Interval!.Polarity == PulsePolarity.Positive;
  377. break;
  378. case TriggerType.Window:
  379. compVolt = (UInt32)((Hd.CurrHdMessage!.Trigger!.Window!.LowerPosIndex) / Constants.IDX_PER_YDIV * AbstractController_Trigger.PerYDivAdcSamples + AbstractController_Trigger.AdcCenterValue);
  380. isPositive = (Hd.CurrHdMessage?.Trigger?.Window?.Range ?? WindowRange.Inside) == WindowRange.Outside;
  381. break;
  382. default:
  383. compVolt = (UInt32)((Hd.CurrHdMessage!.Trigger!.Edge!.PosIndex) / Constants.IDX_PER_YDIV * AbstractController_Trigger.PerYDivAdcSamples + trigSourceYPos);
  384. isPositive = Hd.CurrHdMessage!.Trigger!.Edge!.Slope == EdgeSlope.Rise;
  385. break;
  386. }
  387. uint currDefaultTrigSensitivity = DefaultTrigSensitivity;
  388. if ((TriggerCoupling)(Hd.CurrHdMessage?.Trigger?.Edge?.Coupling ?? TriggerCoupling.DC) == TriggerCoupling.NR)
  389. currDefaultTrigSensitivity /= 2;
  390. switch (Hd.CurrHdMessage?.Trigger?.TrigType)
  391. {
  392. case TriggerType.PulseWidth:
  393. case TriggerType.Runt:
  394. case TriggerType.TimeOut:
  395. case TriggerType.Glitch:
  396. case TriggerType.Pattern:
  397. case TriggerType.Window:
  398. if (isPositive)
  399. {
  400. if ((compVolt - DefaultTrigSensitivity) < 0)
  401. compVolt = DefaultTrigSensitivity;
  402. return (Up: compVolt + DefaultTrigSensitivity, Dn: compVolt, 1);
  403. }
  404. else
  405. {
  406. if ((compVolt + DefaultTrigSensitivity) > 4095)
  407. compVolt = 4095 - DefaultTrigSensitivity;
  408. return (Up: compVolt, Dn: compVolt - DefaultTrigSensitivity, 0);
  409. }
  410. break;
  411. default:
  412. if (isPositive)
  413. {
  414. if ((compVolt - DefaultTrigSensitivity) < 0)
  415. compVolt = DefaultTrigSensitivity;
  416. return (Up: compVolt, Dn: compVolt - DefaultTrigSensitivity, 1);
  417. }
  418. else
  419. {
  420. if ((compVolt + DefaultTrigSensitivity) > 4095)
  421. compVolt = 4095 - DefaultTrigSensitivity;
  422. return (Up: compVolt + DefaultTrigSensitivity, Dn: compVolt, 0);
  423. }
  424. break;
  425. }
  426. }
  427. internal virtual void Trig_SpecailConfig(Int64 xdepth, UInt32 trigSource)
  428. {
  429. if (Hd.CurrHdMessage?.Timebase?.TmbScaleIndex! > (int)AnaChnlTimebaseIndex.Lv5n)
  430. {
  431. HdIO.WriteReg(ProcBdReg.W.TrigCtrl_2nd_SerialTrigEnable, Hd.CurrDebugVarints.bEnable_DigitTrigger ? 9U : 0);
  432. Hd.currProduct?.AcqBd?.WriteToAllFpga(AcqBdReg.W.TrigCtrl_Location_TrigDiscardColumnEn, Hd.CurrDebugVarints.bEnable_DigitTrigger ? 1U : 0U);
  433. }
  434. else
  435. {
  436. HdIO.WriteReg(ProcBdReg.W.TrigCtrl_2nd_SerialTrigEnable, Hd.CurrDebugVarints.bEnable_DigitTrigger ? 9U : 0);
  437. Hd.currProduct?.AcqBd?.WriteToAllFpga(AcqBdReg.W.TrigCtrl_Location_TrigDiscardColumnEn, Hd.CurrDebugVarints.bEnable_DigitTrigger ? 1U : 0U);
  438. }
  439. }
  440. #endregion
  441. protected virtual UInt64 MaxPerDataByps
  442. {
  443. get;
  444. set;
  445. } = 50;//20G 采样
  446. protected const long uS2fs = 1_000_000_000;
  447. internal record ExtractNumInterpolationNumPair(UInt64 ExtractNum, UInt32 InterpolationNum, UInt32 HardwareFifoLen, UInt32 SoftwareFifoLen);
  448. #region LA 抽取插值表
  449. internal virtual Dictionary<AnaChnlTimebaseIndex, ExtractNumInterpolationNumPair> LA_ExtractInterpolationNumTable => standardLA_ExtractInterpolationNumTable;
  450. private static Dictionary<AnaChnlTimebaseIndex, ExtractNumInterpolationNumPair> standardLA_ExtractInterpolationNumTable = new()
  451. {
  452. //小于80,必须能够整除,大于80,10的倍数就可以
  453. // ExtractNum,InterpolationNum,HardwareFifoLen,SoftwareFifoLen
  454. [AnaChnlTimebaseIndex.Lv20p] = new ExtractNumInterpolationNumPair(1, 400, 800, 800),
  455. [AnaChnlTimebaseIndex.Lv50p] = new ExtractNumInterpolationNumPair(1, 200, 1000, 1000),
  456. [AnaChnlTimebaseIndex.Lv100p] = new ExtractNumInterpolationNumPair(1, 100, 1000, 1000),
  457. [AnaChnlTimebaseIndex.Lv200p] = new ExtractNumInterpolationNumPair(1, 40, 800, 800),
  458. [AnaChnlTimebaseIndex.Lv500p] = new ExtractNumInterpolationNumPair(1, 20, 1000, 1000),
  459. [AnaChnlTimebaseIndex.Lv1n] = new ExtractNumInterpolationNumPair(1, 10, 1000, 1000),
  460. [AnaChnlTimebaseIndex.Lv2n] = new ExtractNumInterpolationNumPair(1, 5, 1000, 1000), //50/I * L=scale *10
  461. [AnaChnlTimebaseIndex.Lv5n] = new ExtractNumInterpolationNumPair(1, 2, 1000, 1000),//5ns时10G才开始需要插值,20G这里刚好不需要插值
  462. [AnaChnlTimebaseIndex.Lv10n] = new ExtractNumInterpolationNumPair(1, 1, 1000, 1000),
  463. [AnaChnlTimebaseIndex.Lv20n] = new ExtractNumInterpolationNumPair(1, 1, 2000, 2000),
  464. [AnaChnlTimebaseIndex.Lv50n] = new ExtractNumInterpolationNumPair(1, 1, 5000, 5000),//以上采用20G,也可采用10G
  465. [AnaChnlTimebaseIndex.Lv100n] = new ExtractNumInterpolationNumPair(1, 1, 10_000, 10_000),//以下必须采用10G
  466. [AnaChnlTimebaseIndex.Lv200n] = new ExtractNumInterpolationNumPair(2, 1, 10_000, 10_000),
  467. [AnaChnlTimebaseIndex.Lv500n] = new ExtractNumInterpolationNumPair(5, 1, 10_000, 10_000),
  468. [AnaChnlTimebaseIndex.Lv1u] = new ExtractNumInterpolationNumPair(10, 1, 10_000, 10_000),
  469. [AnaChnlTimebaseIndex.Lv2u] = new ExtractNumInterpolationNumPair(20, 1, 10_000, 10_000),
  470. [AnaChnlTimebaseIndex.Lv5u] = new ExtractNumInterpolationNumPair(50, 1, 10_000, 10_000),
  471. [AnaChnlTimebaseIndex.Lv10u] = new ExtractNumInterpolationNumPair(100, 1, 10_000, 10_000),
  472. [AnaChnlTimebaseIndex.Lv20u] = new ExtractNumInterpolationNumPair(200, 1, 10_000, 10_000),
  473. [AnaChnlTimebaseIndex.Lv50u] = new ExtractNumInterpolationNumPair(500, 1, 10_000, 10_000),
  474. [AnaChnlTimebaseIndex.Lv100u] = new ExtractNumInterpolationNumPair(1_000, 1, 10_000, 10_000),
  475. [AnaChnlTimebaseIndex.Lv200u] = new ExtractNumInterpolationNumPair(2_000, 1, 10_000, 10_000),
  476. [AnaChnlTimebaseIndex.Lv500u] = new ExtractNumInterpolationNumPair(5_000, 1, 10_000, 10_000),
  477. [AnaChnlTimebaseIndex.Lv1m] = new ExtractNumInterpolationNumPair(10_000, 1, 10_000, 10_000),
  478. [AnaChnlTimebaseIndex.Lv2m] = new ExtractNumInterpolationNumPair(20_000, 1, 10_000, 10_000),
  479. [AnaChnlTimebaseIndex.Lv5m] = new ExtractNumInterpolationNumPair(50_000, 1, 10_000, 10_000),
  480. [AnaChnlTimebaseIndex.Lv10m] = new ExtractNumInterpolationNumPair(100_000, 1, 10_000, 10_000),
  481. [AnaChnlTimebaseIndex.Lv20m] = new ExtractNumInterpolationNumPair(200_000, 1, 10_000, 10_000),
  482. [AnaChnlTimebaseIndex.Lv50m] = new ExtractNumInterpolationNumPair(500_000, 1, 10_000, 10_000),
  483. [AnaChnlTimebaseIndex.Lv100m] = new ExtractNumInterpolationNumPair(1_000_000, 1, 10_000, 10_000),
  484. [AnaChnlTimebaseIndex.Lv200m] = new ExtractNumInterpolationNumPair(2_000_000, 1, 10_000, 10_000),
  485. [AnaChnlTimebaseIndex.Lv500m] = new ExtractNumInterpolationNumPair(5_000_000, 1, 10_000, 10_000),
  486. [AnaChnlTimebaseIndex.Lv1] = new ExtractNumInterpolationNumPair(10_000_000, 1, 10_000, 10_000),
  487. [AnaChnlTimebaseIndex.Lv2] = new ExtractNumInterpolationNumPair(20_000_000, 1, 10_000, 10_000),
  488. [AnaChnlTimebaseIndex.Lv5] = new ExtractNumInterpolationNumPair(50_000_000, 1, 10_000, 10_000),
  489. };
  490. #endregion
  491. internal UInt32 DDR_TrigAddrTableStartAddr { get => 1000; }//与硬件协商
  492. public virtual int ReadTriggerStatus()
  493. {
  494. return 0;
  495. }
  496. internal override void Init()
  497. {
  498. InitPhyAnalogChAmplitudeTemperaturesCompensationCoefficient();
  499. LongStorage?.Init();
  500. InitAmpCoefficientFile();
  501. }
  502. internal virtual void InitAmpCoefficientFile()
  503. {
  504. if (ChannelPerScaleAmpFreqCoefficientsDefine == null)
  505. return;
  506. foreach(var v in ChannelPerScaleAmpFreqCoefficientsDefine)
  507. {
  508. var info = v.Value;
  509. int[]? dataArray = Misc.ReadCaliCoefDataFronmFile(info.FileName);
  510. if (dataArray == null)
  511. {
  512. info.CRCCode = 0; info.bOk = false;
  513. continue;
  514. }
  515. info.CRCCode = Misc.GenerateCRCCode(dataArray!);
  516. info.bOk = true;
  517. }
  518. }
  519. internal virtual HdCmd ResponseSpecialScpiCmd(string message)
  520. {
  521. return HdCmd.None;
  522. }
  523. protected virtual bool bOpenAverageModule
  524. {
  525. get
  526. {
  527. if (Hd.CurrDebugVarints.bEnable_ProcBd_Average)
  528. {
  529. if (AcquingParameters.HardwareExtractNum > 1)
  530. return false;
  531. if (Hd.CurrHdMessage!.Timebase!.AcqLength == AnaChnlStorageMode.Long)
  532. return false;
  533. if (Hd.CurrHdMessage!.Trigger!.Mode != TriggerMode.Auto)
  534. return false;
  535. if (Hd.CurrHdMessage!.Timebase!.AcqLength == AnaChnlStorageMode.Fast)
  536. return false;
  537. return true;
  538. }
  539. else
  540. return false;
  541. }
  542. }
  543. internal override void InitAcq()
  544. {
  545. Hd.currProduct?.AcqBd?.WriteToAllFpga(AcqBdReg.W.LSCtrl_StorageMode, AcquingParameters.bIsLongStorageMode ? 1 : 0U);
  546. //Acquisition.SwitchDataPathMuxTo(DMAReadSourceMuxType.AnalogChanneData);
  547. HdIO.WriteReg(ProcBdReg.W.Average_Enable, bOpenAverageModule ? 1U : 0);
  548. if (!AcquingParameters.bIsLongStorageMode)
  549. {
  550. HdIO.WriteReg(PcieBdReg.W.DataPath_pcie_linkdemux_select, (UInt32)DMAReadSourceMuxType.AnalogChanneData);
  551. HdIO.WriteReg(ProcBdReg.W.DataPath_pro_linkdemux_select, (UInt32)DMAReadSourceMuxType.AnalogChanneData);
  552. HdIO.WriteReg(ProcBdReg.W.DataPath_pro_linkmux_select, (UInt32)DMAReadSourceMuxType.AnalogChanneData);
  553. //Hd.currProduct?.AcqBd?.WriteToAllFpga(AcqBdReg.W.FifoCtrl_FullProgDepth, 1024);//采集板并行FIFO深度
  554. Hd.currProduct?.AcqBd?.WriteToAllFpga(AcqBdReg.W.FifoCtrl_FullProgDepth, 500);//采集板并行FIFO深度
  555. Hd.currProduct?.AcqBd?.WriteToAllFpga(AcqBdReg.W.LSCtrl_StorageMode, AcquingParameters.bIsLongStorageMode ? 1u : 0);
  556. HdIO.WriteReg(PcieBdReg.W.DataPath_pcie_linkdemux_select, (UInt32)DMAReadSourceMuxType.AnalogChanneData);
  557. #region 发送FIFO深度
  558. //在DPX模式下,可能更改此参数,故需要重发
  559. HdIO.WriteReg(ProcBdReg.W.DataPath_pro_linkdemux_select, (UInt32)DMAReadSourceMuxType.AnalogChanneData);
  560. bool bEnableInterpolation = Hd.CurrDebugVarints.bEnable_AcqbdInterpolation;
  561. if (bEnableInterpolation)
  562. bEnableInterpolation = AcquingParameters.InterpolationNum > 1;
  563. Hd.currProduct?.AcqBd?.WriteToAllFpga(AcqBdReg.W.Interpolate_Enable, bEnableInterpolation ? 1U : 0);
  564. bool bFast = (Hd.CurrHdMessage?.Timebase?.AcqLength ?? AnaChnlStorageMode.Normal) == AnaChnlStorageMode.Fast;
  565. if (bFast) return;
  566. Hd.currProduct?.AcqBd?.WriteToAllFpga(AcqBdReg.W.DataPath_acq_linkmux_select, 0);
  567. //Hd.currProduct?.AcqBd?.WriteToAllFpga(AcqBdReg.W.TrigCtrl_AcqSerialFIFODepth, 16000);//采集板串行FIFO深度 16000 -->25600 zy0830 --> 53248
  568. HdIO.WriteReg(ProcBdReg.W.FifoCtrl_FullProgDepth, 12288);//12288 -->22528 --> 53248
  569. HdIO.WriteReg(PcieBdReg.W.FifoCtrl_FullProgDepth, 12288);
  570. HdIO.WriteReg(PcieBdReg.W.FifoCtrl_ReadFromFIFO_Num, 15000);//zy0830 15000-->25000--> 53248
  571. #endregion
  572. }
  573. else
  574. {
  575. LongStorage?.InitAcq();
  576. }
  577. }
  578. protected virtual void AnalogChannelDataSplit(int dotCount)
  579. {
  580. for (int curr_channelIndex = 0; curr_channelIndex < ChannelIdExt.AnaChnlNum; curr_channelIndex++)
  581. {
  582. for (int dotIndex = 0; dotIndex < dotCount; dotIndex++)//0
  583. {
  584. ushort data = curr_channelIndex switch
  585. {
  586. 0 => (UInt16)((AcqedDataPool.AnalogChData.DMAData[8 * dotIndex]) | ((AcqedDataPool.AnalogChData.DMAData[8 * dotIndex + 1] & 0x0F) << 8)),
  587. 1 => (UInt16)(((AcqedDataPool.AnalogChData.DMAData[8 * dotIndex + 1] & 0xF0) >> 4 | AcqedDataPool.AnalogChData.DMAData[8 * dotIndex + 2] << 4)),
  588. 2 => (UInt16)((AcqedDataPool.AnalogChData.DMAData[8 * dotIndex + 3] | (AcqedDataPool.AnalogChData.DMAData[8 * dotIndex + 4] & 0x0F) << 8)),
  589. 3 => (UInt16)(((AcqedDataPool.AnalogChData.DMAData[8 * dotIndex + 4] & 0xF0) >> 4 | AcqedDataPool.AnalogChData.DMAData[8 * dotIndex + 5] << 4)),
  590. _ => 0,
  591. };
  592. AcqedDataPool.AnalogChData.AllChannelData[curr_channelIndex].Add(data);
  593. }
  594. }
  595. DiscardDotAtTriggerTypeIsSerialMode();
  596. AbstractController_AnalogChannel.SoftwareBandwidthProcess();
  597. }
  598. internal override bool ReadAcqData()
  599. {
  600. bDataVaild = false;
  601. bool bOk = false;
  602. if (Hd.CurrHdMessage == null)
  603. return bOk;
  604. AcquingParameters.CloneTo(AcquedParameters);
  605. Int32 scanExistDots = 0;
  606. if (HdIO.CurrDriver == null || !HdIO.CurrDriver.bOpen || Hd.bPowerOff)
  607. {
  608. if (Hd.CurrHdMessage?.Timebase?.IsScan ?? false)
  609. {
  610. //模拟
  611. Random random = new Random();
  612. int a = random.Next(100, 1000);
  613. AcqAnalogChannelSimulateWaveform();
  614. for (int iChannelID = 0; iChannelID < ChannelIdExt.AnaChnlNum; iChannelID++)
  615. AcqedDataPool.AnalogChData.AllChannelData[iChannelID].RemoveRange(a, AcqedDataPool.AnalogChData.AllChannelData[iChannelID].Count - a);
  616. return true;
  617. }
  618. else
  619. return AcqAnalogChannelSimulateWaveform();
  620. }
  621. if (!AcquingParameters.bIsLongStorageMode)
  622. {
  623. if (Hd.CurrHdMessage!.Timebase!.IsScan)
  624. {
  625. scanExistDots = (Int32)HdIO.ReadReg(ProcBdReg.R.Scan_DatacountUploading);
  626. HdIO.WriteReg(ProcBdReg.W.Scan_DatacountPassback, (UInt32)(scanExistDots | 0x0 << 14));
  627. HdIO.WriteReg(ProcBdReg.W.Scan_DatacountPassback, (UInt32)(scanExistDots | 0x1 << 14));
  628. HdIO.CheckRegisterValue((UInt32)PcieBdReg.R.FifoCtrl_FullFlag, 0x01, 1, 4);
  629. bOk = HdIO.DMARead(DMAReadDataTypes.AnalogChannelFifo, (uint)AcquingParameters.AnaWaveDMALength, ref AcqedDataPool.AnalogChData.DMAData);
  630. HdIO.WriteReg(ProcBdReg.W.Scan_DatacountPassback, (UInt32)(scanExistDots | 0x0 << 14));
  631. }
  632. else
  633. {
  634. bool bFast = (Hd.CurrHdMessage?.Timebase?.AcqLength ?? AnaChnlStorageMode.Normal) == AnaChnlStorageMode.Fast;
  635. if (!bFast)
  636. {
  637. HdIO.WriteReg((uint)PcieBdReg.W.ReadFromAcqOrDpo, 0);
  638. HdIO.WriteReg((uint)PcieBdReg.W.ReadTotalBytes, (uint)AcquingParameters.AnaWaveDMALength);
  639. bOk = HdIO.DMARead(0, (uint)AcquingParameters.AnaWaveDMALength, ref AcqedDataPool.AnalogChData.DMAData);
  640. }
  641. else
  642. {
  643. Int64 currPerXDivByps = (Int64)((Hd.CurrHdMessage?.Timebase?.TmbScale ?? 1) * 1_000_000);//TmbScale 以us为单位,*1_000_000,us==>ps
  644. UInt32 length = 0;
  645. if (ChannelIdExt.AnaChnlNum <= 4)
  646. length = (UInt32)(((currPerXDivByps * Constants.VIS_XDIVS_NUM) * 8 * 1000 + AcquingParameters.PerDataByfs_AtStorage - 1) / ((long)AcquingParameters.PerDataByfs_AtStorage));
  647. else
  648. length = (UInt32)(((currPerXDivByps * Constants.VIS_XDIVS_NUM) * 16 * 1000 + AcquingParameters.PerDataByfs_AtStorage - 1) / ((long)AcquingParameters.PerDataByfs_AtStorage));
  649. // UInt32 length = 8192;//须归一化256byte整除
  650. length = ((length / 1024 + 1) * 1024);
  651. HdIO.WriteReg(PcieBdReg.W.DataPath_pcie_linkdemux_select, (UInt32)DMAReadSourceMuxType.AnalogChanneData);
  652. HdIO.WriteReg((uint)PcieBdReg.W.ReadFromAcqOrDpo, 0);
  653. HdIO.WriteReg((uint)PcieBdReg.W.ReadTotalBytes, length);
  654. bOk = HdIO.DMARead(0, length, ref AcqedDataPool.AnalogChData.DMAData);
  655. }
  656. }
  657. }
  658. else
  659. {
  660. LongStorage?.SwitchPingpong();
  661. bOk = LongStorage?.ReadTrigPosTable() ?? false;
  662. bOk = LongStorage?.ReadAcqedData() ?? false;
  663. return bOk;
  664. }
  665. bDataVaild = bOk;
  666. if (!bOk)
  667. return bOk;
  668. #region 数据拆分 本拆分方法是按通道交替组织数据的方式进行拆分的。不同的硬件的数据组织方式,需要修改此拆分方法。
  669. Monitor.Enter(AcqedDataPool.UpdateDataLock);
  670. int channelCount = ChannelIdExt.AnaChnlNum;
  671. if (Hd.currProduct.ProductType == ProductType.B21_DBI16G)
  672. channelCount = 4;
  673. while (AcqedDataPool.AnalogChData.AllChannelData.Count < channelCount)
  674. AcqedDataPool.AnalogChData.AllChannelData.Add(new List<ushort>());
  675. for (int iChannelID = 0; iChannelID < channelCount; iChannelID++)
  676. AcqedDataPool.AnalogChData.AllChannelData[iChannelID].Clear();
  677. int channelDotCount = 0;
  678. if (Hd.CurrHdMessage?.Timebase?.IsScan ?? false)
  679. {
  680. channelDotCount = scanExistDots > Constants.CHNL_DATA_NUM ? Constants.CHNL_DATA_NUM : scanExistDots;
  681. }
  682. else
  683. channelDotCount = Constants.CHNL_DATA_NUM;
  684. AnalogChannelDataSplit(channelDotCount);
  685. Monitor.Exit(AcqedDataPool.UpdateDataLock);
  686. #endregion
  687. return bOk;
  688. }
  689. internal override void PostProcess()
  690. {
  691. if (!AcquingParameters.bIsLongStorageMode)
  692. {
  693. if (IsNeedPostProcessByMatlab)
  694. {
  695. #region 需要MATLAB处理
  696. #endregion
  697. }
  698. }
  699. else
  700. {
  701. //长存储时的处理
  702. LongStorage?.PostProcess();
  703. }
  704. }
  705. #region Core->U2调用函数
  706. public virtual bool TryTakeWave(Int32 channelIndex, [NotNullWhen(true)] out List<ushort> waveData, [NotNullWhen(true)] out WfmSampleInfo wfmSampleInfo)
  707. {
  708. waveData = new List<ushort>();
  709. wfmSampleInfo = new WfmSampleInfo();
  710. wfmSampleInfo.SampleIntervalByus = AcquedParameters.PerDataByfs_AfterPostProcess * 1.0 / 1E9;//1_000:fs==>ps
  711. if ((channelIndex < 0) || (channelIndex > ChannelIdExt.AnaChnlNum - 1))
  712. return false;
  713. if ((Hd.CurrHdMessage?.Timebase?.AcqLength ?? AnaChnlStorageMode.Normal) == AnaChnlStorageMode.Long)
  714. {
  715. Hd.bAcqedNewData = LongStorage?.TakeWave() ?? false;
  716. if (Hd.bAcqedNewData)
  717. wfmSampleInfo.SampleIntervalByus = AcquedParameters.PerDataByfs_AfterPostProcess * 1.0 / 1E9;//1_000:fs==>ps
  718. }
  719. if (AcqedDataPool.AnalogChData.AllChannelData.Count <= channelIndex)
  720. return false;
  721. Monitor.Enter(AcqedDataPool.UpdateDataLock);
  722. waveData.AddRange(AcqedDataPool.AnalogChData.AllChannelData[channelIndex]);
  723. Monitor.Exit(AcqedDataPool.UpdateDataLock);
  724. return Hd.bAcqedNewData;
  725. }
  726. public virtual Double TakeSamplingRate()
  727. {
  728. return 1E15 / AcquingParameters.PerDataByfs_AtStorage;
  729. }
  730. public virtual bool TryTakeDdrSourceWave(Int32 channel, double startTimeBySecond, double totalTime, [NotNullWhen(true)] out List<ushort> waveData, [NotNullWhen(true)] out WfmSampleInfo wfmSampleInfo)
  731. {
  732. if (LongStorage != null)
  733. return LongStorage!.TryTakeDdrSourceWave(channel, startTimeBySecond, totalTime, out waveData, out wfmSampleInfo);
  734. else
  735. {
  736. waveData = new List<ushort>();
  737. wfmSampleInfo = new WfmSampleInfo() { SampleIntervalByus = 0.5 };
  738. return false;
  739. }
  740. }
  741. public bool TryTakeSegmentWave(Int32 channelIndex, Int32 segmentIndex, out List<ushort> waveData, out WfmSampleInfo wfmSampleInfo, out Double SecondByps)
  742. {
  743. waveData = new List<ushort>();
  744. wfmSampleInfo = new WfmSampleInfo();
  745. wfmSampleInfo.SampleIntervalByus = AcquedParameters.PerDataByfs_AfterPostProcess * 1.0 / 1E9;
  746. if (segmentIndex < (LongStorage?.TrigAddressTable.Count ?? 0))
  747. SecondByps = LongStorage?.TrigAddressTable[segmentIndex].FrameTimeByns ?? 0.0;
  748. else
  749. SecondByps = 0.0;
  750. return LongStorage?.TryTakeSegmentWave(channelIndex, segmentIndex, out waveData) ?? false;
  751. }
  752. public Int32 TryTakeCollectedSegmentCnt()
  753. {
  754. return LongStorage?.ReadCollectedFrameCnt() ?? 0;
  755. }
  756. #endregion
  757. protected virtual bool AcqAnalogChannelSimulateWaveform()
  758. {
  759. //AcqedDataPool.AnalogChData.AllChannelData.Clear();
  760. //ushort[] list = { 2048, 1648, 1248, 2448 };
  761. //for (int channelID = 0; channelID < ChannelIdExt.AnaChnlNum; channelID++)
  762. //{
  763. // AcqedDataPool.AnalogChData.AllChannelData.Add(new List<ushort>());
  764. // for (int i = 0; i < 10000; i++)
  765. // AcqedDataPool.AnalogChData.AllChannelData[channelID].Add(list[channelID]);
  766. //}
  767. Monitor.Enter(AcqedDataPool.UpdateDataLock);
  768. AcqedDataPool.AnalogChData.AllChannelData.Clear();
  769. int Length = Constants.CHNL_DATA_NUM;
  770. double SampIntByns = Hd.CurrHdMessage?.Timebase?.TmbScale * Constants.VIS_XDIVS_NUM * 1000 / Constants.CHNL_DATA_NUM ?? 0.5;
  771. //var cycles = Length * (SampIntByns * 1E-9) * (Constants.AWG_SIN_FRQ_DEF * 1E-6);
  772. double cycles = 10;
  773. double NoiseByPercent = 0.05;
  774. ArbWfmType[] allChannelArbWfmType;
  775. if (!Hd.bPowerOff)
  776. allChannelArbWfmType = new ArbWfmType[] { ArbWfmType.Sinc, ArbWfmType.Square, ArbWfmType.Ramp, ArbWfmType.DC, ArbWfmType.Sinc, ArbWfmType.Square, ArbWfmType.Ramp, ArbWfmType.Haversine };
  777. else
  778. allChannelArbWfmType = new ArbWfmType[] { ArbWfmType.DC, ArbWfmType.DC, ArbWfmType.DC, ArbWfmType.DC, ArbWfmType.DC, ArbWfmType.DC, ArbWfmType.DC, ArbWfmType.DC };
  779. int channelCount = ChannelIdExt.AnaChnlNum;
  780. if (Hd.currProduct.ProductType == ProductType.B21_DBI16G || Hd.currProduct.ProductType == ProductType.B21_DBI20G)
  781. channelCount = 4;//按子带数来处理,而不是物理通道数
  782. for (int channelID = 0; channelID < channelCount; channelID++)
  783. {
  784. double anaChannelPosition = 0;// Constants.IDX_PER_YDIV * 5;// Hd.CurrHdMessage?.Analog?[channelID].PositionIndex ?? 0;
  785. double amplitude = 1.0;// (Hd.CurrHdMessage?.Analog?[channelID].Scale ?? 0) * 6;
  786. ArbWfmType arbWfmType = allChannelArbWfmType[channelID];
  787. IEnumerable<Double> y = arbWfmType switch
  788. {
  789. ArbWfmType.Pulse or ArbWfmType.Square => Generator.Rectangular(anaChannelPosition, amplitude, cycles / Length, Length, 0.05, NoiseByPercent, 0.1),
  790. ArbWfmType.DC => Generator.DirectCurrent(anaChannelPosition, amplitude, Length, 0.05),
  791. ArbWfmType.Haversine => Generator.Haversine(anaChannelPosition, amplitude, cycles / Length, Length, NoiseByPercent, 0.05),
  792. _ => Generator.Sine(anaChannelPosition, amplitude, cycles / Length, Length, 0.02, 0.0),
  793. };
  794. y = y.Select(o => o * 1E3);
  795. double pos0 = 0;
  796. if (channelID < ChannelIdExt.AnaChnlNum)//因为DBI的缘故,子带模式与物理通道模式不一样
  797. pos0 = (Hd.CurrHdMessage?.Analog?[channelID].PositionIndex ?? 0) / Constants.IDX_PER_YDIV * Constants.SAMPS_PER_YDIV + Constants.MAX_ADC_RES / 2;
  798. else
  799. pos0 = (Hd.CurrHdMessage?.Analog?[ChannelIdExt.AnaChnlNum - 1].PositionIndex ?? 0) / Constants.IDX_PER_YDIV * Constants.SAMPS_PER_YDIV + Constants.MAX_ADC_RES / 2;
  800. y = y.Select((o) => o /*(Hd.CurrHdMessage?.Analog?[channelID].Scale ?? 100)*/ / Constants.IDX_PER_YDIV * Constants.SAMPS_PER_YDIV + pos0);
  801. Double[] data = y.ToArray();// .ToRowVector();
  802. AcqedDataPool.AnalogChData.AllChannelData.Add(new List<ushort>());
  803. for (int i = 0; i < Length; i++)
  804. AcqedDataPool.AnalogChData.AllChannelData[channelID].Add((ushort)(data[i]));
  805. }
  806. AcquedParameters.PerDataByfs_AfterPostProcess = (Hd.CurrHdMessage?.Timebase?.TmbScale * Constants.VIS_XDIVS_NUM * 1000_000_000 / Constants.CHNL_DATA_NUM ?? 50 * 1000);
  807. AbstractController_AnalogChannel.SoftwareBandwidthProcess();
  808. Monitor.Exit(AcqedDataPool.UpdateDataLock);
  809. return true;
  810. }
  811. #region Cali Tool 调用函数
  812. public virtual bool TakeAllChannelWaveform(out List<List<ushort>> waveData)
  813. {
  814. waveData = new List<List<ushort>>();
  815. Monitor.Enter(AcqedDataPool.UpdateDataLock);
  816. for (int channelIndex = 0; channelIndex < ChannelIdExt.AnaChnlNum; channelIndex++)
  817. {
  818. List<ushort> oneChannelData = new List<ushort>();
  819. oneChannelData.AddRange(AcqedDataPool.AnalogChData.AllChannelData[channelIndex].ToArray());
  820. if (oneChannelData.Count < Constants.CHNL_DATA_NUM)
  821. oneChannelData.AddRange(new ushort[Constants.CHNL_DATA_NUM - oneChannelData.Count]);//补齐数据长度,否则Tool端可能不能读到数据
  822. waveData.Add(oneChannelData);
  823. }
  824. Monitor.Exit(AcqedDataPool.UpdateDataLock);
  825. return true;
  826. }
  827. public virtual bool TakeAdcWaveform(out List<List<ushort>> waveData)
  828. {
  829. waveData = new List<List<ushort>>();
  830. int totalCoreCount = ChannelIdExt.AnaChnlNum * Constants.ADC_NUM * Constants.ADC_CORE_NUM;
  831. for (int coreIndex = 0; coreIndex < totalCoreCount; coreIndex++)
  832. waveData.Add(new List<ushort>());
  833. Monitor.Enter(AcqedDataPool.UpdateDataLock);
  834. int totalCoreIndex = 0;
  835. for (int channelIndex = 0; channelIndex < ChannelIdExt.AnaChnlNum; channelIndex++)
  836. {
  837. for (int adcIndex = 0; adcIndex < Constants.ADC_NUM; adcIndex++)
  838. {
  839. for (int coreIndex = 0; coreIndex < Constants.ADC_CORE_NUM; coreIndex++)
  840. {
  841. for (int dotIndex = 0; dotIndex < Constants.CORE_DATA_NUM; dotIndex++)
  842. {
  843. ushort data = (adcIndex % Constants.ADC_NUM, coreIndex) switch
  844. {
  845. (0, 0) => AcqedDataPool.AnalogChData.AllChannelData[channelIndex][dotIndex * 4],
  846. (0, 1) => AcqedDataPool.AnalogChData.AllChannelData[channelIndex][dotIndex * 4 + 2],
  847. (1, 0) => AcqedDataPool.AnalogChData.AllChannelData[channelIndex][dotIndex * 4 + 1],
  848. (1, 1) => AcqedDataPool.AnalogChData.AllChannelData[channelIndex][dotIndex * 4 + 3],
  849. _ => 0,
  850. };
  851. waveData[totalCoreIndex].Add(data);
  852. }
  853. totalCoreIndex++;
  854. }
  855. }
  856. }
  857. Monitor.Exit(AcqedDataPool.UpdateDataLock);
  858. return true;
  859. }
  860. #endregion
  861. internal virtual bool IsNeedPostProcessByMatlab => false;
  862. internal virtual void AnalogChannelActiveChanged() { }
  863. private Dictionary<UInt64, UInt32> _ExtramTable = new Dictionary<UInt64, UInt32>()
  864. {
  865. // 抽取倍数 下发参数
  866. {1, 0 },
  867. {2, 1 },
  868. {4, 2 },
  869. {5, 3 },
  870. {8, 4 },
  871. {10, 5 },
  872. {20, 6 },
  873. {40, 7 },
  874. };
  875. /// <summary>
  876. /// 根据抽取模式和并行路数下发抽取参数
  877. /// </summary>
  878. /// <param name="extramNum">抽取倍数:最大是36位</param>
  879. /// <param name="parallelRoads">并行路数:40/80</param>
  880. /// <param name="extramMode"></param>
  881. internal void ConfigExtramNum(UInt64 extramNum, UInt32 parallelRoads, AnaChnlAcqMode extramMode)
  882. {
  883. if (_ExtramTable.ContainsKey(extramNum) && extramNum < parallelRoads)
  884. {
  885. Hd.currProduct?.AcqBd?.WriteToAllFpga(AcqBdReg.W.Decimation_Decimation_Multiple_Pattern, _ExtramTable[extramNum]);
  886. Hd.currProduct?.AcqBd?.WriteToAllFpga(AcqBdReg.W.Decimation_Decimation_quotient_L16, 0);
  887. Hd.currProduct?.AcqBd?.WriteToAllFpga(AcqBdReg.W.Decimation_Decimation_quotient_M16, 0);
  888. Hd.currProduct?.AcqBd?.WriteToAllFpga(AcqBdReg.W.Decimation_Decimation_quotient_H4, 0);
  889. Hd.currProduct?.AcqBd?.WriteToAllFpga(AcqBdReg.W.Decimation_Decimation_remainder_additional_Processing, 0);
  890. return;
  891. }
  892. Hd.currProduct?.AcqBd?.WriteToAllFpga(AcqBdReg.W.Decimation_Decimation_Multiple_Pattern, 8);
  893. UInt64 decimationQuotient;
  894. UInt64 remainderAdditional;
  895. switch (extramMode)
  896. {
  897. case AnaChnlAcqMode.Normal:
  898. decimationQuotient = extramNum / parallelRoads;
  899. remainderAdditional = (extramNum / (parallelRoads / 4)) % 4;
  900. break;
  901. case AnaChnlAcqMode.Peak:
  902. decimationQuotient = extramNum * 2 / parallelRoads;
  903. if (extramNum * 2 % parallelRoads == 0)
  904. remainderAdditional = 0x1 << 7;
  905. else
  906. remainderAdditional = parallelRoads / (extramNum * 2 % parallelRoads);
  907. break;
  908. case AnaChnlAcqMode.HighRes:
  909. decimationQuotient = extramNum / parallelRoads;
  910. if (extramNum % parallelRoads == 0)
  911. remainderAdditional = 0x1 << 7;
  912. else
  913. remainderAdditional = parallelRoads / (extramNum % parallelRoads);
  914. break;
  915. default:
  916. return;
  917. }
  918. Hd.currProduct?.AcqBd?.WriteToAllFpga(AcqBdReg.W.Decimation_Decimation_remainder_additional_Processing, (UInt32)remainderAdditional);
  919. Hd.currProduct?.AcqBd?.WriteToAllFpga(AcqBdReg.W.Decimation_Decimation_quotient_L16, (UInt32)(decimationQuotient & 0xffff));
  920. Hd.currProduct?.AcqBd?.WriteToAllFpga(AcqBdReg.W.Decimation_Decimation_quotient_M16, (UInt32)(decimationQuotient >> 16 & 0xffff));
  921. Hd.currProduct?.AcqBd?.WriteToAllFpga(AcqBdReg.W.Decimation_Decimation_quotient_H4, (UInt32)(decimationQuotient >> 32 & 0xf));
  922. }
  923. struct ExtramPara
  924. {
  925. internal UInt32 Multiple_Pattern;
  926. internal UInt64 RemainderAdditional;
  927. internal UInt64 DecimationQuotient;
  928. }
  929. private ExtramPara GetExtramPara(UInt64 extramNum, UInt32 parallelRoads, AnaChnlAcqMode extramMode)
  930. {
  931. ExtramPara ectram = new ExtramPara();
  932. if (_ExtramTable.ContainsKey(extramNum) && extramNum < parallelRoads)
  933. {
  934. ectram.Multiple_Pattern = _ExtramTable[extramNum];
  935. ectram.RemainderAdditional = 0;
  936. ectram.DecimationQuotient = 0;
  937. }
  938. else
  939. {
  940. ectram.Multiple_Pattern = 8;
  941. switch (extramMode)
  942. {
  943. case AnaChnlAcqMode.Normal:
  944. ectram.DecimationQuotient = extramNum / parallelRoads;
  945. ectram.RemainderAdditional = (extramNum / (parallelRoads / 4)) % 4;
  946. break;
  947. case AnaChnlAcqMode.Peak:
  948. ectram.DecimationQuotient = extramNum * 2 / parallelRoads;
  949. if (extramNum * 2 % parallelRoads == 0)
  950. ectram.RemainderAdditional = 0x1 << 7;
  951. else
  952. ectram.RemainderAdditional = parallelRoads / (extramNum * 2 % parallelRoads);
  953. break;
  954. case AnaChnlAcqMode.HighRes:
  955. ectram.DecimationQuotient = extramNum / parallelRoads;
  956. if (extramNum % parallelRoads == 0)
  957. ectram.RemainderAdditional = 0x1 << 7;
  958. else
  959. ectram.RemainderAdditional = parallelRoads / (extramNum % parallelRoads);
  960. break;
  961. default:
  962. break;
  963. }
  964. }
  965. return ectram;
  966. }
  967. internal void ConfigExtramNum(UInt64 extramNum, UInt32 parallelRoads, AnaChnlAcqMode extramMode, AcqBdNo acqBd)
  968. {
  969. ExtramPara ectramPara = GetExtramPara(extramNum, parallelRoads, extramMode);
  970. Hd.currProduct?.AcqBd?.WriteReg(AcqBdReg.W.Decimation_Decimation_Multiple_Pattern, acqBd, ectramPara.Multiple_Pattern);
  971. Hd.currProduct?.AcqBd?.WriteReg(AcqBdReg.W.Decimation_Decimation_remainder_additional_Processing, acqBd, (UInt32)ectramPara.RemainderAdditional);
  972. Hd.currProduct?.AcqBd?.WriteReg(AcqBdReg.W.Decimation_Decimation_quotient_L16, acqBd, (UInt32)(ectramPara.DecimationQuotient & 0xffff));
  973. Hd.currProduct?.AcqBd?.WriteReg(AcqBdReg.W.Decimation_Decimation_quotient_M16, acqBd, (UInt32)(ectramPara.DecimationQuotient >> 16 & 0xffff));
  974. Hd.currProduct?.AcqBd?.WriteReg(AcqBdReg.W.Decimation_Decimation_quotient_H4, acqBd, (UInt32)(ectramPara.DecimationQuotient >> 32 & 0xf));
  975. }
  976. internal virtual void ConfigLongStorage()
  977. {
  978. Hd.currProduct?.AcqBd?.WriteToAllFpga(AcqBdReg.W.LSCtrl_StorageMode, AcquingParameters.bIsLongStorageMode ? 1 : 0U);
  979. Hd.currProduct?.AcqBd?.WriteToAllFpga(AcqBdReg.W.LSCtrl_RcdRstEnable, AcquingParameters.LS_SegmentCount > 1 ? 1u : 0);
  980. }
  981. internal virtual void FilterChannelAtSpecailBandwidth(ChannelId channelId)
  982. {
  983. //Uestc.Auto6.Dso.MathExt.Filter.
  984. }
  985. internal virtual void ConfigExtractProcessRoadParameters()
  986. {
  987. //要使FIFO 满,在确保ADC工作正常的情况下,需要正确配置的参数包括:
  988. //采集板
  989. //1、FifoCtrl_OutSpeed 串并转换CH_MODE_SamplingMode
  990. //2、CH_MODE_SamplingMode
  991. //3、Interpolate_Enable 、Interpolate_Ratio
  992. //4、Decimation_Hardware、Decimation_HighResolution、Decimation_Peak等整个采集板处理路径
  993. //5、FIFO深度FifoCtrl_FullProgDepth(可以在初始化时一次性设置)
  994. //处理板
  995. //FifoCtrl_ParallelFifoDepth、FifoCtrl_FullProgDepth(可以在初始化时一次性设置)
  996. //PCIE 板
  997. //FifoCtrl_ProgEmpty、FifoCtrl_FullProgDepth、FifoCtrl_ReadFromFIFO_Num(可以在初始化时一次性设置)
  998. //FifoCtrl_ChannelMode
  999. //modifyNote20220117 1、原来的不同模式采用不同的寄存器,现在呢?
  1000. bool bEnableInterpolation = Hd.CurrDebugVarints.bEnable_AcqbdInterpolation;
  1001. if (bEnableInterpolation)
  1002. {
  1003. if ((Hd.currProduct?.Acquirer_AnalogChannel?.AcquingParameters.InterpolationNum ?? 1) <= 1)
  1004. bEnableInterpolation = false;
  1005. }
  1006. Hd.currProduct?.AcqBd?.WriteToAllFpga(AcqBdReg.W.Interpolate_Enable, bEnableInterpolation ? 1U : 0U);
  1007. UInt32 acqMode = (Hd.CurrHdMessage?.Timebase?.AcqMode ?? AnaChnlAcqMode.Normal) switch
  1008. {
  1009. AnaChnlAcqMode.Peak => 1,
  1010. AnaChnlAcqMode.HighRes => 3,
  1011. _ => 0,
  1012. };
  1013. HdIO.WriteReg(ProcBdReg.W.ext_10m_ext_10m_sel, Hd.CurrHdMessage!.Timebase!.ClockSrc==AnaChnlClkSrc.Inner ? 0U : 1U);
  1014. UInt64 extractNum = (UInt64)(Hd.currProduct?.Acquirer_AnalogChannel?.AcquingParameters.HardwareExtractNum ?? 1U);
  1015. Hd.currProduct?.AcqBd?.WriteToAllFpga(AcqBdReg.W.Interpolate_Ratio, (UInt32)(Hd.currProduct?.Acquirer_AnalogChannel?.AcquingParameters.InterpolationNum ?? 1));
  1016. Hd.currProduct?.AcqBd?.WriteToAllFpga(AcqBdReg.W.Decimation_Decimation_L16, (UInt32)(extractNum & 0xffff));
  1017. Hd.currProduct?.AcqBd?.WriteToAllFpga(AcqBdReg.W.Decimation_Decimation_M16, (UInt32)((extractNum >> 16) & 0xffff));
  1018. Hd.currProduct?.AcqBd?.WriteToAllFpga(AcqBdReg.W.Decimation_Decimation_H16, (UInt32)(extractNum >> 32) & 0xffff);
  1019. Hd.currProduct?.AcqBd?.WriteToAllFpga(AcqBdReg.W.Decimation_DecimationMode, acqMode & 0xffff);
  1020. ConfigExtramNum(extractNum, Hd.currProduct!.Acquirer_AnalogChannel!.AcquingParameters.AcqAdcMergeRoadCount, (Hd.CurrHdMessage?.Timebase?.AcqMode ?? AnaChnlAcqMode.Normal));
  1021. Hd.currProduct?.AcqBd?.WriteToAllFpga(AcqBdReg.W.FifoCtrl_OutSpeed, 1U);
  1022. AnaChnlStorageMode anaChnlAcqLength = (Hd.CurrHdMessage?.Timebase?.AcqLength ?? AnaChnlStorageMode.Normal);
  1023. Hd.currProduct?.AcqBd?.WriteToAllFpga(AcqBdReg.W.LSCtrl_StorageMode, anaChnlAcqLength == AnaChnlStorageMode.Long ? 1U : 0U);
  1024. if (anaChnlAcqLength == AnaChnlStorageMode.Long)
  1025. {
  1026. //merged modify
  1027. //Hd.currProduct?.AcqBd?.WriteToAllFpga(AcqBdReg.W.LSCtrl_SegmentCount, (UInt32)(Hd.currProduct?.Acquirer_AnalogChannel?.AcquingParameters.LS_SegmentCount ?? 1));
  1028. //end merged modify
  1029. UInt32 tmp = (UInt32)(Hd.currProduct?.Acquirer_AnalogChannel?.AcquingParameters.LS_Addr_FirstSegment ?? 0);
  1030. Hd.currProduct?.AcqBd?.WriteToAllFpga(AcqBdReg.W.LSCtrl_SegmentBeginAddr_L, (UInt32)(tmp) & 0xffff);
  1031. Hd.currProduct?.AcqBd?.WriteToAllFpga(AcqBdReg.W.LSCtrl_SegmentBeginAddr_L, (UInt32)(tmp >> 16) & 0xffff);
  1032. tmp = (UInt32)(Hd.currProduct?.Acquirer_AnalogChannel?.AcquingParameters.LS_Addr_PreTrig ?? 0);
  1033. Hd.currProduct?.AcqBd?.WriteToAllFpga(AcqBdReg.W.LSCtrl_TrigAddrTableStartAddr_L, (UInt32)tmp & 0xffff);
  1034. Hd.currProduct?.AcqBd?.WriteToAllFpga(AcqBdReg.W.LSCtrl_TrigAddrTableStartAddr_H, (UInt32)(tmp >> 16) & 0xffff);
  1035. tmp = (UInt32)(Hd.currProduct?.Acquirer_AnalogChannel?.AcquingParameters.LS_SegmentAddrCount ?? 0);
  1036. Hd.currProduct?.AcqBd?.WriteToAllFpga(AcqBdReg.W.LSCtrl_SegmentBeginAddr_L, (UInt32)tmp & 0xffff);
  1037. Hd.currProduct?.AcqBd?.WriteToAllFpga(AcqBdReg.W.LSCtrl_SegmentBeginAddr_H, (UInt32)(tmp >> 16) & 0xffff);
  1038. tmp = (UInt32)(Hd.currProduct?.Acquirer_AnalogChannel?.AcquingParameters.LS_Addr_TrigTable ?? 0);
  1039. Hd.currProduct?.AcqBd?.WriteToAllFpga(AcqBdReg.W.LSCtrl_TrigAddrTableStartAddr_L, (UInt32)tmp & 0xffff);
  1040. Hd.currProduct?.AcqBd?.WriteToAllFpga(AcqBdReg.W.LSCtrl_TrigAddrTableStartAddr_H, (UInt32)(tmp >> 16) & 0xffff);
  1041. AnaChnlAcqMode anaChnlAcqMode = Hd.CurrHdMessage?.Timebase?.AcqMode ?? AnaChnlAcqMode.Normal;
  1042. //Hd.currProduct?.AcqBd?.WriteToAllFpga(AcqBdReg.W.LSCtrl_PickMode, anaChnlAcqMode == AnaChnlAcqMode.Peak ? 0U : 1U);
  1043. //Hd.currProduct?.AcqBd?.WriteToAllFpga(AcqBdReg.W.LSCtrl_PickMode, anaChnlAcqMode == AnaChnlAcqMode.Peak ? 0U : 1U);
  1044. }
  1045. }
  1046. internal virtual Dictionary<int /*mergeMode*/, List<List<ChannelBdAdcInputDefine>>>? ChannelBdAdcInputDefines
  1047. {
  1048. get;
  1049. }
  1050. internal virtual Int32 Dpx_AcqFifoDepth()
  1051. {
  1052. Int64 currPerXDivByps = (Int64)((Hd.CurrHdMessage?.Timebase?.TmbScale ?? 1) * 1_000_000);//TmbScale 以us为单位,*1_000_000,us==>ps
  1053. return (Int32)((currPerXDivByps * 1000 * Constants.VIS_XDIVS_NUM / Hd.currProduct!.Acquirer_AnalogChannel!.AcquingParameters.PerDataByfs_AtStorage + 200) / 40);
  1054. }
  1055. #region AFC(幅频特性) 系数
  1056. private Dictionary<ChannelId, AnaChnlScaleIndex> lastChannelYScale = new Dictionary<ChannelId, AnaChnlScaleIndex>()
  1057. {
  1058. [ChannelId.C1] = AnaChnlScaleIndex.Lv100,
  1059. [ChannelId.C2] = AnaChnlScaleIndex.Lv100,
  1060. [ChannelId.C3] = AnaChnlScaleIndex.Lv100,
  1061. [ChannelId.C4] = AnaChnlScaleIndex.Lv100,
  1062. [ChannelId.C5] = AnaChnlScaleIndex.Lv100,
  1063. [ChannelId.C6] = AnaChnlScaleIndex.Lv100,
  1064. [ChannelId.C7] = AnaChnlScaleIndex.Lv100,
  1065. [ChannelId.C8] = AnaChnlScaleIndex.Lv100,
  1066. };
  1067. protected virtual void CheckResendAfc()
  1068. {
  1069. Calibration.Data.Base.CoefficientsTableType coefficientsTableType = CoefficientsTableType.Coefficients8;
  1070. bool bFound = false;
  1071. foreach (var v in Hd.currProduct!.HardwareConfig!.LocalCoefficientsTableMeanings)
  1072. {
  1073. if (v.Value.CoeffType == CommCoefficientsTableType.AcqBd_AFC)
  1074. {
  1075. coefficientsTableType = v.Key;
  1076. bFound = true;
  1077. break;
  1078. }
  1079. }
  1080. if (!bFound)
  1081. return;
  1082. bFound = false;
  1083. for (int channelId = (int)ChannelId.C1; channelId < ChannelIdExt.AnaChnlNum; channelId++)
  1084. {
  1085. if (lastChannelYScale[(ChannelId)channelId] != (AnaChnlScaleIndex)Hd.CurrHdMessage!.Analog![channelId]!.ScaleIndex)
  1086. {
  1087. lastChannelYScale[(ChannelId)channelId] = (AnaChnlScaleIndex)Hd.CurrHdMessage!.Analog![channelId]!.ScaleIndex;
  1088. bFound = true;
  1089. }
  1090. }
  1091. if (bFound)
  1092. {
  1093. CaliDataManager.DataChangedCoefficientsTableType.Add(coefficientsTableType);
  1094. Hd.LocalCommands |= (long)HdCmd.CaliDataChanged;
  1095. }
  1096. }
  1097. internal virtual bool Afc_Sender_ByRegisterMode(CoefficientsTableType coefficientsTableType, int[] dataArray, AcqBdNo acqBdNo, ChannelId channelId)
  1098. {
  1099. int partALength = Hd.currProduct!.HardwareConfig!.LocalCoefficientsTableMeanings[coefficientsTableType].LengthOfPartA;
  1100. int dataCount = dataArray.Length;
  1101. for (int i = 0; i < dataCount; i++)
  1102. {
  1103. Hd.currProduct!.AcqBd!.WriteReg(AcqBdReg.W.Fir_FactorTableWriteEnable, acqBdNo, 0);
  1104. if (i < partALength) //10G系数
  1105. Hd.currProduct!.AcqBd!.WriteReg(AcqBdReg.W.Fir_FactorTableWriteAddr, acqBdNo, (UInt32)i);
  1106. else //20G系数(修改系数长度后需要修改此处)
  1107. Hd.currProduct!.AcqBd!.WriteReg(AcqBdReg.W.Fir_FactorTableWriteAddr, acqBdNo, (UInt32)(i + 0b00100000000 - partALength));//(适用200阶)下发地址11位,通过高位为1下发的则是20G的系数
  1108. Int32 data = dataArray[i];
  1109. //低16位
  1110. Hd.currProduct!.AcqBd!.WriteReg(AcqBdReg.W.Fir_FactorTableWriteData_L, acqBdNo, (UInt32)data & 0xffff);
  1111. //高位
  1112. Hd.currProduct!.AcqBd!.WriteReg(AcqBdReg.W.Fir_FactorTableWriteData_H, acqBdNo, (UInt32)(data >> 16) & 0xff);
  1113. HdIO.DelayByUs(10);
  1114. Hd.currProduct!.AcqBd!.WriteReg(AcqBdReg.W.Fir_FactorTableWriteEnable, acqBdNo, 1);
  1115. }
  1116. Hd.currProduct!.AcqBd!.WriteReg(AcqBdReg.W.Fir_FactorTableWriteEnable, acqBdNo, 0);
  1117. Hd.currProduct!.AcqBd!.WriteReg(AcqBdReg.W.Fir_Enable, acqBdNo, Hd.CurrDebugVarints.bEnable_AcqBd_Afc ? 1U : 0);
  1118. return true;
  1119. }
  1120. internal virtual bool Afc_Sender_ByDMAMode(CoefficientsTableType coefficientsTableType, int[] dataArray, AcqBdNo acqBdNo, ChannelId channelId)
  1121. {
  1122. return false;
  1123. }
  1124. /// <summary>
  1125. /// Key = $"{acqBdNo}_{((ChannelId)channelId)}",Value=crcCode
  1126. /// </summary>
  1127. protected Dictionary<string, int> AfcSendHistory = new Dictionary<string, int>();
  1128. internal virtual void ClearSendHistory() => AfcSendHistory.Clear();
  1129. internal virtual void SendCoefficients_Afc(CoefficientsTableType coefficientsTableType, bool bForce)
  1130. {
  1131. if (Hd.currProduct!.Acquirer_AnalogChannel!.ChannelPerScaleAmpFreqCoefficientsDefine == null)
  1132. return;
  1133. Dictionary<int /*mergeMode*/, List<List<ChannelBdAdcInputDefine>>>? channelBdAdcInputDefines = Hd.currProduct?.Acquirer_AnalogChannel?.ChannelBdAdcInputDefines;
  1134. if (channelBdAdcInputDefines == null)
  1135. return;
  1136. for (int channelId = (int)ChannelId.C1; channelId < ChannelIdExt.AnaChnlNum; channelId++)
  1137. {
  1138. string key = ((ChannelId)channelId).ToString() + "_" + ((int)Hd.CurrHdMessage!.Analog![channelId].Scale).ToString();
  1139. if (Hd.currProduct!.Acquirer_AnalogChannel!.ChannelPerScaleAmpFreqCoefficientsDefine.TryGetValue(key, out var info))
  1140. {
  1141. if (!info.bOk)
  1142. continue;
  1143. AcqBdNo acqBdNo = channelBdAdcInputDefines[1][(int)channelId][0].BdNo;//1=20G, 0=只取第一条记录,与ADC的顺序无关
  1144. string SendHistoryKey = $"{acqBdNo}_{((ChannelId)channelId)}";
  1145. if (AfcSendHistory.ContainsKey(SendHistoryKey))
  1146. {
  1147. if (AfcSendHistory[SendHistoryKey] == info.CRCCode)
  1148. continue;
  1149. AfcSendHistory[SendHistoryKey] = info.CRCCode;
  1150. }
  1151. else
  1152. AfcSendHistory.Add(SendHistoryKey, info.CRCCode);
  1153. int[]? dataArray = Misc.ReadCaliCoefDataFronmFile(info.FileName);
  1154. if (Hd.currProduct!.HardwareConfig!.DownloadBlockDataMode == DownloadBlockDataMode.DMA)
  1155. Afc_Sender_ByDMAMode(coefficientsTableType, dataArray!, acqBdNo, (ChannelId)channelId);
  1156. else
  1157. Afc_Sender_ByRegisterMode(coefficientsTableType, dataArray!, acqBdNo, (ChannelId)channelId);
  1158. }
  1159. }
  1160. return;
  1161. }
  1162. #endregion
  1163. internal virtual bool AutoCaliAtInit(HdMessage? hdMessage) => false;
  1164. internal virtual Boolean IsInterpolation_LS(Int32 channelId)
  1165. {
  1166. return false;
  1167. }
  1168. #region 模拟通道幅度增益温度补偿
  1169. protected DateTime LastPhyAnalogChAmplitudeTemperaturesCompensationCalced_Datetime = DateTime.Now;
  1170. Dictionary<ChannelId, string> PhyAnalogChAmplitudeTemperaturesCompensationCoefficientFile = new Dictionary<ChannelId, string>()
  1171. {
  1172. {ChannelId.C1,$@".\CaliData\CoeFiles\AnalogChannelTemperatureCompensation_C1.txt" },
  1173. {ChannelId.C2,$@".\CaliData\CoeFiles\AnalogChannelTemperatureCompensation_C2.txt" },
  1174. {ChannelId.C3,$@".\CaliData\CoeFiles\AnalogChannelTemperatureCompensation_C3.txt" },
  1175. {ChannelId.C4,$@".\CaliData\CoeFiles\AnalogChannelTemperatureCompensation_C4.txt" },
  1176. {ChannelId.C5,$@".\CaliData\CoeFiles\AnalogChannelTemperatureCompensation_C5.txt" },
  1177. {ChannelId.C6,$@".\CaliData\CoeFiles\AnalogChannelTemperatureCompensation_C6.txt" },
  1178. };
  1179. Dictionary<ChannelId, Dictionary<double, double>> allChannelAmplitudeTemperaturesCompensationCoefficient = new Dictionary<ChannelId, Dictionary<double, double>>();
  1180. protected List<double> LastPhyAnalogChAmplitudeTemperaturesCompensationCoefficient = new List<double>() { 1, 1, 1, 1, 1, 1, 1, 1 };
  1181. protected List<double> PhyAnalogChAmplitudeBaselineTemperature = new List<double>() { 40, 40, 40, 40, 40, 40, 40, 40 };//校准基准温度
  1182. internal virtual void InitPhyAnalogChAmplitudeTemperaturesCompensationCoefficient()
  1183. {
  1184. allChannelAmplitudeTemperaturesCompensationCoefficient.Clear();
  1185. string rootPath = AppDomain.CurrentDomain.BaseDirectory;
  1186. for (ChannelId channelId = ChannelId.C1; channelId <= ChannelId.C8; channelId++)
  1187. {
  1188. if (PhyAnalogChAmplitudeTemperaturesCompensationCoefficientFile.ContainsKey(channelId))
  1189. {
  1190. var result = Misc.ReadAmplitudeTemperaturesCompensationCoefficientFile(PhyAnalogChAmplitudeTemperaturesCompensationCoefficientFile[channelId], out double baselineTemperature);
  1191. if (result.Count > 0)
  1192. {
  1193. if (allChannelAmplitudeTemperaturesCompensationCoefficient.ContainsKey(channelId))
  1194. allChannelAmplitudeTemperaturesCompensationCoefficient[channelId] = result;
  1195. else
  1196. allChannelAmplitudeTemperaturesCompensationCoefficient.Add(channelId, result);
  1197. PhyAnalogChAmplitudeBaselineTemperature[(int)channelId] = baselineTemperature;
  1198. }
  1199. }
  1200. }
  1201. }
  1202. internal virtual bool GetPhyAnalogChAmplitudeTemperaturesCompensationCoefficient(out List<double> Coefficient)
  1203. {
  1204. Coefficient = LastPhyAnalogChAmplitudeTemperaturesCompensationCoefficient;
  1205. if ((DateTime.Now - LastPhyAnalogChAmplitudeTemperaturesCompensationCalced_Datetime).TotalMilliseconds < Acquisition.PhyAnalogChAmplitudeTemperaturesCompensationIntervalByMs)
  1206. return false;
  1207. double currTemperature = SysMonitor.Default.AnalogChannelTemperatures[0];//只有一个通道板
  1208. for (ChannelId channelId = ChannelId.C1; channelId <= ChannelIdExt.MaxAChId; channelId++)
  1209. {
  1210. ChannelId key = channelId;
  1211. if (allChannelAmplitudeTemperaturesCompensationCoefficient.ContainsKey(key))
  1212. {
  1213. double result = 1;
  1214. KeyValuePair<double, double> first;
  1215. try
  1216. {
  1217. first = allChannelAmplitudeTemperaturesCompensationCoefficient[key].First((o) => o.Key <= currTemperature);
  1218. }
  1219. catch
  1220. {
  1221. first = (allChannelAmplitudeTemperaturesCompensationCoefficient[key].First());
  1222. result = first.Value;
  1223. if (allChannelAmplitudeTemperaturesCompensationCoefficient[key].ContainsKey(PhyAnalogChAmplitudeBaselineTemperature[(int)key]))
  1224. result = result / allChannelAmplitudeTemperaturesCompensationCoefficient[key][PhyAnalogChAmplitudeBaselineTemperature[(int)key]];
  1225. LastPhyAnalogChAmplitudeTemperaturesCompensationCoefficient[(int)channelId] = result;
  1226. return true;
  1227. }
  1228. KeyValuePair<double, double> last;
  1229. try
  1230. {
  1231. last = allChannelAmplitudeTemperaturesCompensationCoefficient[key].First((o) => o.Key >= currTemperature);
  1232. }
  1233. catch
  1234. {
  1235. last = allChannelAmplitudeTemperaturesCompensationCoefficient[key].Last();
  1236. result = last.Value;
  1237. if (allChannelAmplitudeTemperaturesCompensationCoefficient[key].ContainsKey(PhyAnalogChAmplitudeBaselineTemperature[(int)key]))
  1238. result = result / allChannelAmplitudeTemperaturesCompensationCoefficient[key][PhyAnalogChAmplitudeBaselineTemperature[(int)key]];
  1239. LastPhyAnalogChAmplitudeTemperaturesCompensationCoefficient[(int)channelId] = result;
  1240. return true; ;
  1241. }
  1242. if (Math.Abs(first.Key - currTemperature) < 0.01)//==
  1243. result = first.Value;
  1244. else if (Math.Abs(last.Key - currTemperature) < 0.01)//==
  1245. result = last.Value;
  1246. else if (first.Key != last.Key)
  1247. result = first.Value + (last.Value - first.Value) * (currTemperature - first.Key) / (last.Key - first.Key);//局部线性插值
  1248. if (allChannelAmplitudeTemperaturesCompensationCoefficient[channelId].ContainsKey(PhyAnalogChAmplitudeBaselineTemperature[(int)channelId]))
  1249. result = result / allChannelAmplitudeTemperaturesCompensationCoefficient[channelId][PhyAnalogChAmplitudeBaselineTemperature[(int)channelId]];
  1250. LastPhyAnalogChAmplitudeTemperaturesCompensationCoefficient[(int)channelId] = result;
  1251. }
  1252. }
  1253. LastPhyAnalogChAmplitudeTemperaturesCompensationCalced_Datetime = DateTime.Now;
  1254. return true;
  1255. }
  1256. #endregion
  1257. #region Dpx
  1258. internal virtual DpxAcqParameters CreateDpxAcqParameters()
  1259. {
  1260. bool bInterpolation = Hd.currProduct?.Acquirer_AnalogChannel?.AcquingParameters.InterpolationNum > 1 ? true : false;//修改为真正得读取插值
  1261. bool bEdgeTrig = Hd.CurrHdMessage?.Trigger?.TrigType == TriggerType.Edge;
  1262. bool bSerialDpx = (bInterpolation | (!bEdgeTrig));
  1263. Int64 currPerXDivByps = (Int64)((Hd.CurrHdMessage?.Timebase?.TmbScale ?? 1) * 1_000_000);//TmbScale 以us为单位,*1_000_000,us==>ps
  1264. Int32 ParallelMapFifoDepth = (Int32)(currPerXDivByps * 1000 * Constants.VIS_XDIVS_NUM / (long)AcquingParameters.PerDataByfs_AtStorage / 5 / 4);//PerDataByfs_AtStorage 或者Dpx_PerDataByfs_AtStorage
  1265. Int32 SoftFifoDepth = (Int32)(currPerXDivByps * 1024 * Constants.VIS_XDIVS_NUM / (long)AcquingParameters.PerDataByfs_AtStorage / 4 + 15);
  1266. return new DpxAcqParameters()
  1267. {
  1268. bSerialDpx = bSerialDpx
  1269. };
  1270. }
  1271. #endregion
  1272. }
  1273. internal class ChannelBdAdcInputDefine
  1274. {
  1275. public AcqBdNo BdNo { get; set; }
  1276. public Int32 AdcIndex { get; set; }
  1277. public int InputPort_AIs1 { get; set; }
  1278. public bool bIs20GMode { get; set; } = false;
  1279. }
  1280. internal class AmpCoefficientFileInfo
  1281. {
  1282. public string FileName = "";
  1283. public int CRCCode = 0;
  1284. public bool bOk=false;
  1285. }
  1286. }