123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 |
- using System;
- using System.Collections.Generic;
- using System.Drawing;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows.Forms;
- using Uestc.Auto6.Dso.ComModel;
- using Uestc.Auto6.Dso.Core;
- using Uestc.Auto6.Dso.Core.Decode;
- using Uni_Trend.MSO7000X.Common.Helper;
- namespace Uestc.Auto6.Dso.Protocol.SPI
- {
- internal class SPI : DecodeView
- {
- public override IProtocolView ProtocolView => new SPISetControl();
- public override ITriggerSerialView TriggerSerialView => new SPITriggerSetControl();
- public override SerialProtocolType ProtocolType => SerialProtocolType.SPI;
- public override void DrawDecodeInfo(Graphics graphics, Rectangle rectangle, IProtocolPrsnt prsnt, Color foreColor, Font font)
- {
- if(prsnt is SPIDecodePrsnt spiDecode)
- {
- String msg = spiDecode.FramingMode.ToString();
- Rectangle rec = GetRowRectangle(0);
- rec.X -= 20;
- TextRenderer.DrawText(graphics, msg, font,rec , foreColor, TextFormatFlags.HorizontalCenter | TextFormatFlags.Top);
- if(spiDecode.FramingMode == ProtocolSPI.FramingMode.Idle)
- {
- rec.X += 20;
- msg = SIHelper.ValueChangeToSI(spiDecode.IdleTime, 2, "s");
- TextRenderer.DrawText(graphics, msg, font, rec, foreColor, TextFormatFlags.Right | TextFormatFlags.Top);
- }
- if(spiDecode.DecodeChannel == ProtocolSPI.DecodeChannel.MISO|| spiDecode.DecodeChannel == ProtocolSPI.DecodeChannel.MOMI)
- {
- msg = $"{nameof(ProtocolSPI.DecodeChannel.MISO)}->{spiDecode.MISO}{(spiDecode.MISOPolarity == ProtocolSPI.Polarity.Pos?"":"↓")} {SIHelper.ValueChangeToSI(spiDecode.MISOThreshold,2,"V")}";
- TextRenderer.DrawText(graphics, msg, font, GetRowRectangle(1), foreColor, TextFormatFlags.Left | TextFormatFlags.Top);
- }
- if (spiDecode.DecodeChannel == ProtocolSPI.DecodeChannel.MOSI || spiDecode.DecodeChannel == ProtocolSPI.DecodeChannel.MOMI)
- {
- msg = $"{nameof(ProtocolSPI.DecodeChannel.MOSI)}->{spiDecode.MOSI}{(spiDecode.MOSIPolarity == ProtocolSPI.Polarity.Pos ? "" : "↓")} {SIHelper.ValueChangeToSI(spiDecode.MOSIThreshold, 2, "V")}";
- TextRenderer.DrawText(graphics, msg, font, GetRowRectangle(2), foreColor, TextFormatFlags.Left | TextFormatFlags.Top);
- }
- }
- }
-
- }
- }
|