HdMessage.Protocol.cs 39 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6. namespace Uestc.Auto6.Dso.ComModel
  7. {
  8. public partial record HdMessage
  9. {
  10. #region 解码触发结构参数
  11. public record TrigDecoderOptions(SerialProtocolType ProtocolType)
  12. {
  13. public ITrigDecoderConditionsOptions? DecoderConditionsOptions
  14. {
  15. get;
  16. init;
  17. }
  18. public IDecoderOptions? ProtocolOptions
  19. {
  20. get;
  21. init;
  22. }
  23. }
  24. public interface ITrigDecoderConditionsOptions
  25. {
  26. }
  27. public record TrigCloseConditionsOptions() : ITrigDecoderConditionsOptions
  28. {
  29. }
  30. public record TrigNRZConditionOptions(ProtocolNRZ.Condition Condition):ITrigDecoderConditionsOptions
  31. {
  32. public ProtocolNRZ.DataRelation Relation { get; init; }
  33. public Byte Data { get; init; }
  34. }
  35. public record TrigFlexRayConditionOptions(ProtocolFlexRay.Condition Condition):ITrigDecoderConditionsOptions
  36. {
  37. public ProtocolFlexRay.Realtion Relation
  38. {
  39. get;
  40. init;
  41. }
  42. public UInt16 ID
  43. {
  44. get;
  45. init;
  46. }
  47. public Byte[]? Data
  48. {
  49. get;
  50. init;
  51. }
  52. public Byte CycleData
  53. {
  54. get;
  55. init;
  56. }
  57. public Byte ByteCount
  58. {
  59. get;init;
  60. }
  61. public ProtocolFlexRay.Indicator Indicator
  62. {
  63. get;
  64. init;
  65. }
  66. public ProtocolFlexRay.FrameError FrameError
  67. {
  68. get;init;
  69. }
  70. public ProtocolFlexRay.FrameTail FrameTail
  71. {
  72. get;init;
  73. }
  74. }
  75. public record TrigEthernetConditionsOptions(ProtocolEthernet.Condition Condition):ITrigDecoderConditionsOptions
  76. {
  77. public Byte Data
  78. {
  79. get;
  80. init;
  81. }
  82. public Byte[]? SrcMAC
  83. {
  84. get;
  85. init;
  86. }
  87. public Byte[]? DestMAC
  88. {
  89. get;
  90. init;
  91. }
  92. public ProtocolEthernet.DataRelation Relation
  93. {
  94. get;
  95. init;
  96. }
  97. }
  98. public record TrigLINConditionsOptions(ProtocolLIN.Condition Condition) : ITrigDecoderConditionsOptions
  99. {
  100. public ProtocolLIN.DataRelation DataRelation
  101. {
  102. get;
  103. init ;
  104. }
  105. public Byte ID
  106. {
  107. get;
  108. init;
  109. }
  110. public Byte Data
  111. {
  112. get; init;
  113. }
  114. }
  115. public record TrigRS232ConditionsOptions(ProtocolRS232.Conditions Conditions) : ITrigDecoderConditionsOptions
  116. {
  117. public PulseCondition Compare
  118. {
  119. get;
  120. init;
  121. }
  122. public Char Data
  123. {
  124. get;
  125. init;
  126. }
  127. public Char EOPChar
  128. {
  129. get;
  130. init;
  131. }
  132. }
  133. public record TrigPCIeConditionsOptions(ProtocolPCIe.Condition Condition):ITrigDecoderConditionsOptions
  134. {
  135. public ProtocolPCIe.TLPType TLPType
  136. {
  137. get;
  138. init;
  139. }
  140. public UInt16 SeqID
  141. {
  142. get;
  143. init;
  144. }
  145. public Byte TCData
  146. {
  147. get;
  148. init;
  149. }
  150. public Byte ATData
  151. {
  152. get;
  153. init;
  154. }
  155. public Byte TagData
  156. {
  157. get;
  158. init;
  159. }
  160. public UInt16 ReqIDData
  161. {
  162. get;
  163. init;
  164. }
  165. public Byte MsgCodeData
  166. {
  167. get;
  168. init;
  169. }
  170. public Byte DataLenght
  171. {
  172. get;
  173. init;
  174. }
  175. public Int64 Data
  176. {
  177. get;
  178. init;
  179. }
  180. public Int64 AddressData
  181. {
  182. get;
  183. init;
  184. }
  185. public ProtocolPCIe.DataRelation DataRelation
  186. {
  187. get;init;
  188. }
  189. }
  190. public record TrigMILConditionsOptions(ProtocolMIL.Condition Condition):ITrigDecoderConditionsOptions
  191. {
  192. }
  193. public record TrigI2SConditionsOptions(ProtocolAudioBus.Condition Condition):ITrigDecoderConditionsOptions
  194. {
  195. public UInt32 Data
  196. {
  197. get;init;
  198. }
  199. public ProtocolAudioBus.DataRelation DataRelation
  200. {
  201. get;init;
  202. }
  203. }
  204. public record TrigSPMIConditionsOptions(ProtocolSPMI.Condition Condition):ITrigDecoderConditionsOptions
  205. {
  206. }
  207. public record TrigI2CConditionsOptions(ProtocolI2C.Condition Condition) : ITrigDecoderConditionsOptions
  208. {
  209. /// <summary>
  210. /// 数据方向
  211. /// 当<see cref="Condition"/>的值为<see cref="ProtocolI2C.I2CCondition.Address"/>时有效
  212. /// </summary>
  213. public ProtocolI2C.DataDirection Direction
  214. {
  215. get;
  216. init;
  217. }
  218. /// <summary>
  219. /// 地址值
  220. /// </summary>
  221. public UInt16 AddressData
  222. {
  223. get;
  224. init;
  225. }
  226. /// <summary>
  227. /// 比较方式
  228. /// </summary>
  229. public ProtocolI2C.DataRelation Relation
  230. {
  231. get;
  232. init;
  233. }
  234. /// <summary>
  235. /// 字节数
  236. /// 当<see cref="Condition"/>的值为<see cref="ProtocolI2C.I2CCondition.Data"/>时有效
  237. /// </summary>
  238. public Byte DataBytesCount
  239. {
  240. get;
  241. init;
  242. }
  243. /// <summary>
  244. /// 字节号,从0开始
  245. /// 当<see cref="Condition"/>的值为<see cref="ProtocolI2C.I2CCondition.Data"/>时有效
  246. /// </summary>
  247. public Int32 DataByteIndex
  248. {
  249. get;
  250. init;
  251. }
  252. /// <summary>
  253. /// 数据
  254. /// 当<see cref="Condition"/>的值为<see cref="ProtocolI2C.I2CCondition.Data"/>时有效
  255. /// </summary>
  256. public Int64 Data
  257. {
  258. get;
  259. init;
  260. }
  261. }
  262. public record TrigSATAConditionsOptions(ProtocolSATA.Condition Condition) :ITrigDecoderConditionsOptions
  263. {
  264. public Int64 Data
  265. {
  266. get;init;
  267. }
  268. public ProtocolSATA.DataRelation Relation
  269. {
  270. get;init;
  271. }
  272. public Byte DataCount { get; init; }
  273. public ProtocolSATA.FISTypeFlag FISType
  274. {
  275. get; init;
  276. }
  277. }
  278. public record TrigSPIConditionsOptions(ComModel.ProtocolSPI.Condition Condition) : ITrigDecoderConditionsOptions
  279. {
  280. public ComModel.ProtocolSPI.DataTriggerSource DataSource
  281. {
  282. get;
  283. init;
  284. }
  285. public Int32 FrameCount
  286. {
  287. get;
  288. init;
  289. }
  290. public Int64 FrameData
  291. {
  292. get;
  293. init;
  294. }
  295. }
  296. public record TrigARINC429ConditionsOptions(ProtocolARINC429.Condition Condition) : ITrigDecoderConditionsOptions
  297. {
  298. public UInt32 SSM
  299. {
  300. get;
  301. init;
  302. }
  303. public UInt32 SDI
  304. {
  305. get;
  306. init;
  307. }
  308. public UInt32 Label
  309. {
  310. get;
  311. init;
  312. }
  313. public UInt32 Data
  314. {
  315. get;
  316. init;
  317. }
  318. public ProtocolARINC429.DataRelation DataRelation
  319. {
  320. get;
  321. init;
  322. }
  323. }
  324. public record TrigCANFDConditionsOptions(ProtocolCANFD.Condition Condition) : ITrigDecoderConditionsOptions
  325. {
  326. public ProtocolCANFD.FrameType FrameType
  327. {
  328. get;
  329. init;
  330. }
  331. public ProtocolCANFD.IDStandard IDStandard
  332. {
  333. get;
  334. init;
  335. }
  336. public ProtocolCANFD.IDFrameDirection IDFrameDirection
  337. {
  338. get;
  339. init;
  340. }
  341. public Int32 StandardID
  342. {
  343. get;
  344. init;
  345. }
  346. public Int32 ExtendedID
  347. {
  348. get; init;
  349. }
  350. public Int32 ByteCount
  351. {
  352. get; init;
  353. }
  354. public Int32 ByteIndex
  355. {
  356. get; init;
  357. }
  358. public Int64 Data
  359. {
  360. get; init;
  361. }
  362. public ProtocolCANFD.DataRelation DataRelation
  363. {
  364. get; init;
  365. }
  366. public ProtocolCANFD.ErrorPacketType ErrorPacketType
  367. {
  368. get;init;
  369. }
  370. }
  371. public record TrigUSBConditionsOptions(ProtocolUSB.Condition Condition):ITrigDecoderConditionsOptions
  372. {
  373. public ProtocolUSB.DataRelation DataRelation
  374. {
  375. get;init;
  376. }
  377. public UInt16 Data
  378. {
  379. get;init;
  380. }
  381. public ProtocolUSB.TokenPackageType TokenPackageType
  382. {
  383. get;init;
  384. }
  385. public ProtocolUSB.HandshakePackageType HandshakePackageType
  386. {
  387. get;init;
  388. }
  389. public ProtocolUSB.DataPackageType DataPackageType
  390. {
  391. get;init;
  392. }
  393. public ProtocolUSB.ErrorPackageType ErrorPackageType
  394. {
  395. get;init;
  396. }
  397. public ProtocolUSB.SpecialPacketType SpecialPacketType
  398. {
  399. get;init;
  400. }
  401. }
  402. public record TrigCANConditionsOptions(ProtocolCAN.Condition Condition) : ITrigDecoderConditionsOptions
  403. {
  404. public ProtocolCAN.FrameType FrameType
  405. {
  406. get;
  407. init;
  408. }
  409. public ProtocolCAN.IDStandard IDStandard
  410. {
  411. get;
  412. init;
  413. }
  414. public ProtocolCAN.IDFrameDirection IDFrameDirection
  415. {
  416. get;
  417. init;
  418. }
  419. public Int32 StandardID
  420. {
  421. get; init;
  422. }
  423. public Int32 ExtendedID
  424. {
  425. get; init;
  426. }
  427. public ProtocolCAN.DataRelation DataRelation
  428. {
  429. get; init;
  430. }
  431. public Int32 ByteIndex
  432. {
  433. get; init;
  434. }
  435. public Int32 ByteCount
  436. {
  437. get; init;
  438. }
  439. public Int64 Data
  440. {
  441. get; init;
  442. }
  443. public ProtocolCAN.ErrorPacketType ErrorPacketType
  444. {
  445. get;init;
  446. }
  447. }
  448. public record TrigJTAGConditionsOptions(ComModel.ProtocolJTAG.Condition Condition) : ITrigDecoderConditionsOptions
  449. {
  450. public ComModel.ProtocolJTAG.DataRelation DataRelation
  451. {
  452. get;
  453. init;
  454. }
  455. public Byte[]? Data
  456. {
  457. get;
  458. init;
  459. }
  460. }
  461. public record TrigSENTConditionsOptions(ProtocolSENT.Condition Condition) : ITrigDecoderConditionsOptions
  462. {
  463. public ProtocolSENT.DataRelation DataRelation
  464. {
  465. get;
  466. init;
  467. }
  468. public UInt32 Data
  469. {
  470. get;
  471. init;
  472. }
  473. }
  474. #endregion 解码触发结构参数
  475. #region 解码结构参数
  476. public record DecoderOptions(Boolean Active, SerialProtocolType ProtocolType)
  477. {
  478. public Double Position
  479. {
  480. get;
  481. init;
  482. }
  483. public IDecoderOptions? ProtocolOptions
  484. {
  485. get;
  486. init;
  487. }
  488. }
  489. public interface IDecoderOptions
  490. {
  491. public List<(ChannelId ChannelId, Double Threshold1, Double Threshold2)> GetThresholdInfos();
  492. }
  493. public record ProtocolCloseOptions() : IDecoderOptions
  494. {
  495. //无参数
  496. public List<(ChannelId ChannelId, Double Threshold1, Double Threshold2)> GetThresholdInfos()
  497. {
  498. return new List<(ChannelId ChannelId, Double Threshold1, Double Threshold2)>();
  499. }
  500. }
  501. public record ProtocolEthernetOptions():IDecoderOptions
  502. {
  503. public ProtocolEthernet.EthernetVersion Version
  504. {
  505. get;
  506. init;
  507. }
  508. /// <summary>
  509. /// 数据源的阈值
  510. /// </summary>
  511. public Double Signal1ThresholdH
  512. {
  513. get;
  514. init;
  515. }
  516. /// <summary>
  517. /// 数据源的阈值
  518. /// </summary>
  519. public Double Signal1ThresholdL
  520. {
  521. get;
  522. init;
  523. }
  524. public ChannelId SignalInput1
  525. {
  526. get;
  527. init;
  528. }
  529. public ChannelId SignalInput2
  530. {
  531. get;
  532. init;
  533. }
  534. public ProtocolEthernet.SignalType SignalType
  535. {
  536. get;
  537. init;
  538. }
  539. public ProtocolEthernet.EthernetSpeed Speed
  540. {
  541. get;
  542. init;
  543. }
  544. public Double Signal1Threshold
  545. {
  546. get;
  547. init;
  548. }
  549. public Double Signal2Threshold
  550. {
  551. get;
  552. init;
  553. }
  554. public Byte QFlag
  555. {
  556. get;
  557. init;
  558. }
  559. public List<(ChannelId ChannelId, Double Threshold1, Double Threshold2)> GetThresholdInfos()
  560. {
  561. var tempinfos = new List<(ChannelId ChannelId, Double Threshold1, Double Threshold2)>();
  562. if(SignalType == ProtocolEthernet.SignalType.Single)
  563. {
  564. tempinfos.Add((SignalInput1, Signal1Threshold, 0));
  565. tempinfos.Add((SignalInput2, Signal2Threshold, 0));
  566. }
  567. else
  568. {
  569. tempinfos.Add((SignalInput1, Signal1ThresholdH, Signal1ThresholdL));
  570. }
  571. return tempinfos;
  572. }
  573. }
  574. public record ProtocolUSBOptions():IDecoderOptions
  575. {
  576. public List<(ChannelId ChannelId, Double Threshold1, Double Threshold2)> GetThresholdInfos()
  577. {
  578. return new List<(ChannelId ChannelId, Double Threshold1, Double Threshold2)>()
  579. {
  580. (Source1,Source1Threshold,0),
  581. (Source2,Source2Threshold,0),
  582. };
  583. }
  584. public ChannelId Source1
  585. {
  586. get;init;
  587. }
  588. public ChannelId Source2
  589. {
  590. get;init;
  591. }
  592. public Double Source1Threshold
  593. {
  594. get;init;
  595. }
  596. public Double Source2Threshold
  597. {
  598. get;init;
  599. }
  600. public ProtocolUSB.SignalRate SignalRate
  601. {
  602. get;init;
  603. }
  604. public UInt16 ByteCount
  605. {
  606. get;init;
  607. }
  608. }
  609. public record ProtocolRS232Options() : IDecoderOptions
  610. {
  611. public List<(ChannelId ChannelId, Double Threshold1, Double Threshold2)> GetThresholdInfos()
  612. {
  613. var tempinfos = new List<(ChannelId ChannelId, Double Threshold1, Double Threshold2)>();
  614. if (SignalType == ProtocolRS232.SignalType.Single)
  615. {
  616. tempinfos.Add((Source, Threshold, 0));
  617. }
  618. else
  619. {
  620. tempinfos.Add((Source, Threshold, 0));
  621. tempinfos.Add((SourceL, Threshold, 0));
  622. }
  623. return tempinfos;
  624. }
  625. public ChannelId Source
  626. {
  627. get;
  628. init;
  629. }
  630. public ChannelId SourceL
  631. {
  632. get;
  633. init;
  634. }
  635. public ProtocolRS232.DataBitWidth DataBitWidth
  636. {
  637. get;
  638. init;
  639. }
  640. public ProtocolRS232.OddEvenCheck OddEvenCheck
  641. {
  642. get;
  643. init;
  644. }
  645. public ProtocolRS232.StopBit StopBit
  646. {
  647. get;
  648. init;
  649. }
  650. public ProtocolRS232.MSB_LSB BitSeq
  651. {
  652. get;
  653. init;
  654. }
  655. public ProtocolRS232.Polarity Polarity
  656. {
  657. get;
  658. init;
  659. }
  660. public UInt32 Baud
  661. {
  662. get;
  663. init;
  664. }
  665. public ProtocolRS232.SignalType SignalType
  666. {
  667. get;
  668. init;
  669. }
  670. public Double Threshold
  671. {
  672. get;init;
  673. }
  674. }
  675. public record ProtocolPCIeOptions():IDecoderOptions
  676. {
  677. public List<(ChannelId ChannelId, Double Threshold1, Double Threshold2)> GetThresholdInfos()
  678. {
  679. var tempinfos = new List<(ChannelId ChannelId, Double Threshold1, Double Threshold2)>();
  680. if (SignalType == ProtocolPCIe.SignalType.Single)
  681. {
  682. tempinfos.Add((SignalInput, Threshold, 0));
  683. }
  684. else
  685. {
  686. tempinfos.Add((SignalInput, Threshold, 0));
  687. tempinfos.Add((SignalIutput1, Threshold, 0));
  688. }
  689. return tempinfos;
  690. }
  691. public ChannelId SignalInput
  692. {
  693. get;init;
  694. }
  695. public ChannelId SignalIutput1
  696. {
  697. get;init;
  698. }
  699. public ProtocolPCIe.PCIeVersion Version
  700. {
  701. get;init;
  702. }
  703. public ProtocolPCIe.SignalType SignalType
  704. {
  705. get;init;
  706. }
  707. public Double Threshold
  708. {
  709. get;init;
  710. }
  711. public UInt16 ByetsCount
  712. {
  713. get;init;
  714. }
  715. }
  716. public record ProtocolI2SOptions():IDecoderOptions
  717. {
  718. public List<(ChannelId ChannelId, Double Threshold1, Double Threshold2)> GetThresholdInfos()
  719. {
  720. return new List<(ChannelId ChannelId, Double Threshold1, Double Threshold2)>()
  721. {
  722. (SCL,SCLThreshold,0),
  723. (WS,WSThreshold,0),
  724. (SDA,SDAThreshold,0),
  725. };
  726. }
  727. public ProtocolAudioBus.SubType SubType
  728. {
  729. get;
  730. init;
  731. }
  732. public ProtocolAudioBus.SyncPolarity SyncPolarity
  733. {
  734. get;
  735. init;
  736. }
  737. public ProtocolAudioBus.ClockEdge ClockEdge
  738. {
  739. get; init;
  740. }
  741. public ProtocolAudioBus.DataPolarity DataPolarity
  742. {
  743. get; init;
  744. }
  745. public ProtocolAudioBus.MSB_LSB MSB_LSB
  746. {
  747. get; init;
  748. }
  749. public ProtocolAudioBus.SoundChannel SoundChannel
  750. {
  751. get; init;
  752. }
  753. public Int32 BitDelayCount
  754. {
  755. get; init;
  756. }
  757. public Int32 DataBitCount
  758. {
  759. get; init;
  760. }
  761. public Int32 ClockBitCount
  762. {
  763. get; init;
  764. }
  765. public Int32 SoundChannelCount
  766. {
  767. get; init;
  768. }
  769. public ChannelId SCL
  770. {
  771. get;init;
  772. }
  773. public ChannelId WS
  774. {
  775. get;init;
  776. }
  777. public ChannelId SDA
  778. {
  779. get;init;
  780. }
  781. public Double SCLThreshold
  782. {
  783. get;init;
  784. }
  785. public Double WSThreshold
  786. {
  787. get;init;
  788. }
  789. public Double SDAThreshold
  790. {
  791. get;init;
  792. }
  793. }
  794. public record ProtocolI2COptions() : IDecoderOptions
  795. {
  796. public List<(ChannelId ChannelId, Double Threshold1, Double Threshold2)> GetThresholdInfos()
  797. {
  798. return new List<(ChannelId ChannelId, Double Threshold1, Double Threshold2)>()
  799. {
  800. (SCLK,SCLKThreshold,0),
  801. (SDA,SDAThreshold,0),
  802. };
  803. }
  804. public ChannelId SCLK
  805. {
  806. get;
  807. init;
  808. }
  809. public ChannelId SDA
  810. {
  811. get;
  812. init;
  813. }
  814. public Double SCLKThreshold
  815. {
  816. get;
  817. init;
  818. }
  819. public Double SDAThreshold
  820. {
  821. get;
  822. init;
  823. }
  824. public ProtocolI2C.AddrBitWidth BitWidth
  825. {
  826. get;init;
  827. }
  828. }
  829. public record ProtocolSPIOptions() : IDecoderOptions
  830. {
  831. public List<(ChannelId ChannelId, Double Threshold1, Double Threshold2)> GetThresholdInfos()
  832. {
  833. var tempinfos = new List<(ChannelId ChannelId, Double Threshold1, Double Threshold2)>();
  834. tempinfos.Add((CLK, CLKThreshold, 0));
  835. if(FramingMode == ProtocolSPI.FramingMode.Slave)
  836. {
  837. tempinfos.Add((CS, CSThreshold, 0));
  838. }
  839. switch(DecodeChannel)
  840. {
  841. case ProtocolSPI.DecodeChannel.MOMI:
  842. tempinfos.Add((MISO, MISOThreshold, 0));
  843. tempinfos.Add((MOSI, MISOThreshold, 0));
  844. break;
  845. case ProtocolSPI.DecodeChannel.MOSI:
  846. tempinfos.Add((MOSI, MOSIThreshold, 0));
  847. break;
  848. case ProtocolSPI.DecodeChannel.MISO:
  849. tempinfos.Add((MISO, MISOThreshold, 0));
  850. break;
  851. }
  852. return tempinfos;
  853. }
  854. public ComModel.ProtocolSPI.FramingMode FramingMode
  855. {
  856. get;
  857. init;
  858. }
  859. public ComModel.ProtocolSPI.DecodeChannel DecodeChannel
  860. {
  861. get;
  862. init;
  863. }
  864. public Int32 FrameCount
  865. {
  866. get;
  867. init;
  868. }
  869. public ComModel.ChannelId CLK
  870. {
  871. get;
  872. init;
  873. }
  874. public ComModel.ChannelId MOSI
  875. {
  876. get;
  877. init;
  878. }
  879. public ComModel.ChannelId MISO
  880. {
  881. get;
  882. init;
  883. }
  884. public ComModel.ChannelId CS
  885. {
  886. get;
  887. init;
  888. }
  889. public Double IdleTime
  890. {
  891. get;
  892. init;
  893. }
  894. public Double CLKThreshold
  895. {
  896. get;
  897. init;
  898. }
  899. public Double MOSIThreshold
  900. {
  901. get;
  902. init;
  903. }
  904. public Double MISOThreshold
  905. {
  906. get;
  907. init;
  908. }
  909. public ComModel.ProtocolSPI.MSB_LSB ByteOrder
  910. {
  911. get;
  912. init;
  913. }
  914. public ComModel.ProtocolSPI.Polarity MISOPolarity
  915. {
  916. get;
  917. init;
  918. }
  919. public ComModel.ProtocolSPI.Polarity MOSIPolarity
  920. {
  921. get;
  922. init;
  923. }
  924. public ComModel.ProtocolSPI.LevelState CSLevelState
  925. {
  926. get;
  927. init;
  928. }
  929. public ComModel.ProtocolSPI.EdgeState CLKState
  930. {
  931. get;
  932. init;
  933. }
  934. public Double CSThreshold
  935. {
  936. get;
  937. init;
  938. }
  939. }
  940. public record ProtocolSATAOptions():IDecoderOptions
  941. {
  942. public List<(ChannelId ChannelId, Double Threshold1, Double Threshold2)> GetThresholdInfos()
  943. {
  944. var tempinfos = new List<(ChannelId ChannelId, Double Threshold1, Double Threshold2)>();
  945. tempinfos.Add((Source, Threshold, 0));
  946. return tempinfos;
  947. }
  948. public ProtocolSATA.SATAVersion Version
  949. {
  950. get;init;
  951. }
  952. public ChannelId Source
  953. {
  954. get;init;
  955. }
  956. public ChannelId Source1
  957. {
  958. get;init;
  959. }
  960. public Double Threshold
  961. {
  962. get;init;
  963. }
  964. public UInt16 BytesCount
  965. {
  966. get;init;
  967. }
  968. }
  969. public record ProtocolARIN429Options() : IDecoderOptions
  970. {
  971. public List<(ChannelId ChannelId, Double Threshold1, Double Threshold2)> GetThresholdInfos()
  972. {
  973. var tempinfos = new List<(ChannelId ChannelId, Double Threshold1, Double Threshold2)>();
  974. tempinfos.Add((SignalInputA, ThresholdH, ThresholdL));
  975. if (InputMode == ProtocolARINC429.InputMode.Diff)
  976. {
  977. tempinfos.Add((SignalInputB, ThresholdH, ThresholdL));
  978. }
  979. return tempinfos;
  980. }
  981. public ProtocolARINC429.DecodeMode DecodeMode
  982. {
  983. get;
  984. init;
  985. }
  986. public ChannelId SignalInputA
  987. {
  988. get; init;
  989. }
  990. public ProtocolARINC429.InputMode InputMode
  991. {
  992. get;init;
  993. }
  994. public ChannelId SignalInputB
  995. {
  996. get;init;
  997. }
  998. public Int32 Baud//自定义速率
  999. {
  1000. get; init;
  1001. }
  1002. /// <summary>
  1003. /// 数据源的阈值
  1004. /// </summary>
  1005. public Double ThresholdH
  1006. {
  1007. get; init;
  1008. }
  1009. public Double ThresholdL
  1010. {
  1011. get; init;
  1012. }
  1013. }
  1014. public record ProtocolSPMIOptions() : IDecoderOptions
  1015. {
  1016. public List<(ChannelId ChannelId, Double Threshold1, Double Threshold2)> GetThresholdInfos()
  1017. {
  1018. return new List<(ChannelId ChannelId, Double Threshold1, Double Threshold2)>()
  1019. {
  1020. (SCLK,CLKThreshold,0),
  1021. (SData,DataThreshold,0),
  1022. };
  1023. }
  1024. public Double CLKThreshold { get; init; }
  1025. public Double DataThreshold { get; init; }
  1026. public ChannelId SData { get; init; }
  1027. public ChannelId SCLK { get; init; }
  1028. public ProtocolSPMI.Version Version { get; init; }
  1029. public ProtocolSPMI.CheckType CheckType { get; init; }
  1030. }
  1031. public record ProtocolMILOptions():IDecoderOptions
  1032. {
  1033. public List<(ChannelId ChannelId, Double Threshold1, Double Threshold2)> GetThresholdInfos()
  1034. {
  1035. return new List<(ChannelId ChannelId, Double Threshold1, Double Threshold2)>()
  1036. {
  1037. (Source,Threshold,0),
  1038. };
  1039. }
  1040. public Int32 SignalRate { get; init; }
  1041. public Double Threshold { get; init; }
  1042. public ChannelId Source { get; init; }
  1043. public ProtocolMIL.Polarity Polarity { get; init; }
  1044. }
  1045. public record ProtocolNRZOptions():IDecoderOptions
  1046. {
  1047. public List<(ChannelId ChannelId, Double Threshold1, Double Threshold2)> GetThresholdInfos()
  1048. {
  1049. var tempinfos = new List<(ChannelId ChannelId, Double Threshold1, Double Threshold2)>();
  1050. if(SignalType == ProtocolNRZ.SignalType.Single)
  1051. {
  1052. tempinfos.Add((Source1, Threshold, 0));
  1053. }
  1054. else
  1055. {
  1056. tempinfos.Add((Source1, Threshold, 0));
  1057. tempinfos.Add((Source2, Threshold, 0));
  1058. }
  1059. return tempinfos;
  1060. }
  1061. public Int64 SignalRate { get; init; }
  1062. public ProtocolNRZ.SignalType SignalType { get; init; }
  1063. public ChannelId Source1 { get; init; }
  1064. public ChannelId Source2 { get; init; }
  1065. public Double Threshold { get; init; }
  1066. public ProtocolNRZ.MSB_LSB MSB_LSB { get; init; }
  1067. public UInt32 IdleTime { get; init; }
  1068. public ProtocolNRZ.IdleLevel IdleLevel { get; init; }
  1069. public ProtocolNRZ.Mode Mode { get; init; }
  1070. }
  1071. public record ProtocolCANOptions() : IDecoderOptions
  1072. {
  1073. public List<(ChannelId ChannelId, Double Threshold1, Double Threshold2)> GetThresholdInfos()
  1074. {
  1075. var tempinfos = new List<(ChannelId ChannelId, Double Threshold1, Double Threshold2)>();
  1076. if (SignalType == ProtocolCAN.SignalType.Diff)
  1077. {
  1078. tempinfos.Add((SignalInput1, SDAThreshold, 0));
  1079. tempinfos.Add((SignalInput2, SDAThreshold, 0));
  1080. }
  1081. else
  1082. {
  1083. tempinfos.Add((SignalInput1, SDAThreshold, 0));
  1084. }
  1085. return tempinfos;
  1086. }
  1087. public Int64 SignalRate
  1088. {
  1089. get;
  1090. init;
  1091. }
  1092. //信号类型
  1093. public ProtocolCAN.SignalType SignalType
  1094. {
  1095. get;
  1096. init;
  1097. }
  1098. //输入1
  1099. public ChannelId SignalInput1
  1100. {
  1101. get; init;
  1102. }
  1103. //输入2(信号类型选择"差分"时使用)
  1104. public ChannelId SignalInput2
  1105. {
  1106. get; init;
  1107. }
  1108. //采样点
  1109. public Int32 SamplePoint
  1110. {
  1111. get; init;
  1112. }
  1113. /// <summary>
  1114. /// 数据源的阈值
  1115. /// </summary>
  1116. public Double SDAThreshold
  1117. {
  1118. get; init;
  1119. }
  1120. }
  1121. public record ProtocolCANFDOptions() : IDecoderOptions
  1122. {
  1123. public List<(ChannelId ChannelId, Double Threshold1, Double Threshold2)> GetThresholdInfos()
  1124. {
  1125. var tempinfos = new List<(ChannelId ChannelId, Double Threshold1, Double Threshold2)>();
  1126. if (SignalType == ProtocolCANFD.SignalType.Diff)
  1127. {
  1128. tempinfos.Add((SignalInput1, SDAThreshold, 0));
  1129. tempinfos.Add((SignalInput2, SDAThreshold, 0));
  1130. }
  1131. else
  1132. {
  1133. tempinfos.Add((SignalInput1, SDAThreshold, 0));
  1134. }
  1135. return tempinfos;
  1136. }
  1137. public Int64 SDSignalRate
  1138. {
  1139. get;
  1140. init;
  1141. }
  1142. public Int64 FDSignalRate
  1143. {
  1144. get;
  1145. init;
  1146. }
  1147. //信号类型
  1148. public ProtocolCANFD.SignalType SignalType
  1149. {
  1150. get;
  1151. init;
  1152. }
  1153. //输入1
  1154. public ChannelId SignalInput1
  1155. {
  1156. get; init;
  1157. }
  1158. //输入2(信号类型选择"差分"时使用)
  1159. public ChannelId SignalInput2
  1160. {
  1161. get; init;
  1162. }
  1163. //采样点
  1164. public Int32 SamplePoint
  1165. {
  1166. get; init;
  1167. }
  1168. /// <summary>
  1169. /// 数据源的阈值
  1170. /// </summary>
  1171. public Double SDAThreshold
  1172. {
  1173. get; init;
  1174. }
  1175. }
  1176. public record ProtocolJTAGOptions : IDecoderOptions
  1177. {
  1178. public List<(ChannelId ChannelId, Double Threshold1, Double Threshold2)> GetThresholdInfos()
  1179. {
  1180. var tempinfos = new List<(ChannelId ChannelId, Double Threshold1, Double Threshold2)>();
  1181. tempinfos.Add((TCK, TCKThreshold, 0));
  1182. tempinfos.Add((TDI, TDIThreshold, 0));
  1183. tempinfos.Add((TDO, TDOThreshold, 0));
  1184. tempinfos.Add((TMS, TMSThreshold, 0));
  1185. return tempinfos;
  1186. }
  1187. public ChannelId TCK
  1188. {
  1189. get;
  1190. init;
  1191. }
  1192. public Double TCKThreshold
  1193. {
  1194. get;
  1195. init;
  1196. }
  1197. public ChannelId TMS
  1198. {
  1199. get; init;
  1200. }
  1201. public Double TMSThreshold
  1202. {
  1203. get; init;
  1204. }
  1205. public ChannelId TDI
  1206. {
  1207. get; init;
  1208. }
  1209. public Double TDIThreshold
  1210. {
  1211. get; init;
  1212. }
  1213. public ChannelId TDO
  1214. {
  1215. get; init;
  1216. }
  1217. public Double TDOThreshold
  1218. {
  1219. get; init;
  1220. }
  1221. public ComModel.ProtocolJTAG.DecodeChannel DecodeChannel
  1222. {
  1223. get; init;
  1224. }
  1225. public UInt32 BitRate
  1226. {
  1227. get; init;
  1228. }
  1229. }
  1230. public record ProtocolLINOptions:IDecoderOptions
  1231. {
  1232. public List<(ChannelId ChannelId, Double Threshold1, Double Threshold2)> GetThresholdInfos()
  1233. {
  1234. var tempinfos = new List<(ChannelId ChannelId, Double Threshold1, Double Threshold2)>();
  1235. tempinfos.Add((Source, Threshold, 0));
  1236. return tempinfos;
  1237. }
  1238. public ChannelId Source
  1239. {
  1240. get;
  1241. init ;
  1242. }
  1243. public ProtocolLIN.Standard Standard
  1244. {
  1245. get;
  1246. init ;
  1247. }
  1248. public ProtocolLIN.Polarity Polarity
  1249. {
  1250. get; init;
  1251. }
  1252. public ProtocolLIN.PIncludeOddEven PIncludeOddEven
  1253. {
  1254. get; init;
  1255. }
  1256. public Double Threshold
  1257. {
  1258. get; init;
  1259. }
  1260. public Int32 BPS
  1261. {
  1262. get; init;
  1263. }
  1264. public Int32 DataCount
  1265. {
  1266. get;init;
  1267. }
  1268. }
  1269. public record ProtocolFlexRayOptions : IDecoderOptions
  1270. {
  1271. public List<(ChannelId ChannelId, Double Threshold1, Double Threshold2)> GetThresholdInfos()
  1272. {
  1273. var tempinfos = new List<(ChannelId ChannelId, Double Threshold1, Double Threshold2)>();
  1274. if (SourceType == ProtocolFlexRay.SourceType.BDiff)
  1275. {
  1276. tempinfos.Add((Source, Threshold, 0));
  1277. tempinfos.Add((SourceL, Threshold, 0));
  1278. }
  1279. else
  1280. {
  1281. tempinfos.Add((Source, Threshold, 0));
  1282. }
  1283. return tempinfos;
  1284. }
  1285. public ChannelId Source
  1286. {
  1287. get;
  1288. init;
  1289. }
  1290. public ChannelId SourceL
  1291. {
  1292. get;init;
  1293. }
  1294. public ProtocolFlexRay.ChannelType ChannelType
  1295. {
  1296. get;
  1297. init;
  1298. }
  1299. public ProtocolFlexRay.SourceType SourceType
  1300. {
  1301. get; init;
  1302. }
  1303. public Int64 SignalRate
  1304. {
  1305. get; init;
  1306. }
  1307. public Double Threshold
  1308. {
  1309. get; init;
  1310. }
  1311. public Int32 ByteOffset
  1312. {
  1313. get;init;
  1314. }
  1315. public Int32 PayLoadLength
  1316. {
  1317. get;init;
  1318. }
  1319. }
  1320. public record ProtocolSENTOptions : IDecoderOptions
  1321. {
  1322. public List<(ChannelId ChannelId, Double Threshold1, Double Threshold2)> GetThresholdInfos()
  1323. {
  1324. var tempinfos = new List<(ChannelId ChannelId, Double Threshold1, Double Threshold2)>();
  1325. tempinfos.Add((Source, Threshold, 0));
  1326. return tempinfos;
  1327. }
  1328. public ComModel.ChannelId Source
  1329. {
  1330. get;
  1331. init;
  1332. }
  1333. public ProtocolSENT.PauseBit PauseBit
  1334. {
  1335. get;
  1336. init;
  1337. }
  1338. public ProtocolSENT.SENTCRC CRC
  1339. {
  1340. get; init;
  1341. }
  1342. public ProtocolSENT.DataLength DataLength
  1343. {
  1344. get; init;
  1345. }
  1346. public ProtocolSENT.Polarity Polarity
  1347. {
  1348. get; init;
  1349. }
  1350. public Int64 SignalRate
  1351. {
  1352. get; init;
  1353. }
  1354. public Double Threshold
  1355. {
  1356. get; init;
  1357. }
  1358. }
  1359. #endregion 解码结构参数
  1360. }
  1361. }