/// <summary> /// Változott a Brp, Tseg1, Tseg2, Sjw /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void customBaudrateView1_ParameterChanged(object sender, EventArgs e) { cbrc.Calculate(view.Brp, view.Tseg1, view.Tseg2, view.Sjw); view.SmaplePoint = cbrc.SamplePoint; view.Baudrate = cbrc.Baudrate; view.CalculateDetails = cbrc.GetCalculateDetails; view.BaudratAbsError = cbrc.GetBaudrateAbsoluteError(view.ExpectedBaudrate); view.BaudrateRelError = cbrc.GetBaudrateRealtiveError(view.ExpectedBaudrate); view.CustomBaudrateValue = cbrc.GetCustomBaudRateValue().ToString(); }
public void _0004_Vamosnak() { var calc = new BaudrateCalculator(); calc.Calculate(15, 6, 3, 1); Assert.AreEqual(280000, calc.Baudrate); Assert.AreEqual(3520.0d, calc.GetBaudrateAbsoluteError(276480)); Assert.AreEqual(1.2731481481481481d, calc.GetBaudrateRealtiveError(276480)); }
public void _0009_Max_SegmentsToCustomBaudRateValue() { var calc = new BaudrateCalculator(); calc.Calculate(1024, 16, 8, 4); var target = calc.GetCustomBaudRateValue(); Assert.AreEqual("B007FFFF", target); }
public void _0008_250kBaud_SegmentsToCustomBaudRateValue() { var calc = new BaudrateCalculator(); calc.Calculate(8, 16, 4, 3); var target = calc.GetCustomBaudRateValue(); Assert.AreEqual("B003F807", target); }
public void _0007_Default_SegmentsToCustomBaudRateValue() { var calc = new BaudrateCalculator(); calc.Calculate(1, 1, 1, 1); var target = calc.GetCustomBaudRateValue(); Assert.AreEqual("B0000000", target); }
public void _0011_250kBaud_CustomBaudRateValueToSegments() { var calc = new BaudrateCalculator(); calc.Calculate("B003F807"); Assert.AreEqual(8, calc.Segments.Brp); Assert.AreEqual(16, calc.Segments.Tseg1); Assert.AreEqual(4, calc.Segments.Tseg2); Assert.AreEqual(3, calc.Segments.Sjw); Assert.AreEqual(42000000.0d, calc.Segments.SystemClock); }
public void _0010_Default_CustomBaudRateValueToSegments() { var calc = new BaudrateCalculator(); calc.Calculate("B0000000"); Assert.AreEqual(1, calc.Segments.Brp); Assert.AreEqual(1, calc.Segments.Tseg1); Assert.AreEqual(1, calc.Segments.Tseg2); Assert.AreEqual(1, calc.Segments.Sjw); Assert.AreEqual(42000000.0d, calc.Segments.SystemClock); }
public void _0005_250KBaud_PCLK42MHz() { var calc = new BaudrateCalculator(); calc.Calculate(42000000, 8, 16, 4, 3); foreach (var line in calc.GetCalculateDetails) { Console.WriteLine(line); } Assert.AreEqual(249999.99999999997d, calc.Baudrate); Assert.AreEqual("B003F807", calc.GetCustomBaudRateValue()); }
public void _0003_500KBaud() { var calc = new BaudrateCalculator(); calc.Calculate(4, 16, 4, 3); foreach (var line in calc.GetCalculateDetails) { Console.WriteLine(line); } Assert.AreEqual(499999.99999999994d, calc.Baudrate); }
public void _0002_250KBaud() { var calc = new BaudrateCalculator(); calc.Calculate(8, 16, 4, 3); foreach (var line in calc.GetCalculateDetails) { Console.WriteLine(line); } Assert.AreEqual((double)249999.99999999997d, (double)calc.Baudrate); }
public void _0006_250KBaud_PCLK36MHz() { var calc = new BaudrateCalculator(); calc.Calculate(36000000, 9, 11, 4, 1); foreach (var line in calc.GetCalculateDetails) { Console.WriteLine(line); } Assert.AreEqual(250000, calc.Baudrate); }