コード例 #1
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="segments"></param>
        public void Calculate(TimeSegemnts segments)
        {
            GetCalculateDetails.Clear();

            //_txtRes = new System.Resources.ResourceManager("Konvolucio.Project.Localization.TextResource", typeof(BaudrateCalculator).Assembly);

            if (_txtRes != null)
            {
                /*text_BaudrateSystemClock*/
                /*"System Clock[PCLK]: {0:N4} MHz"*/
                /*Rendszer órajel[PCLK]: {0:N4} MHz*/
                GetCalculateDetails.Add(string.Format(_txtRes.GetString("text_BaudrateSystemClock"), (segments.SystemClock / 1000000)));
                /*text_BaudRatePrescaler*/
                /*Baud Rate Prescaler[BRP]: {0}*/
                /*Átviteli sebesség osztó[BRP]: {0}*/
                GetCalculateDetails.Add(string.Format(_txtRes.GetString("text_BaudRatePrescaler"), segments.Brp));
            }
            else
            {
                GetCalculateDetails.Add("System Clock[PCLK]: " + (segments.SystemClock / 1000000).ToString("N4") + " MHz");
                GetCalculateDetails.Add("Baud Rate Prescaler[BRP]: " + segments.Brp.ToString() + "");
                GetCalculateDetails.Add("Time Segments Before Sample[TSEG1]: " + segments.Tseg1.ToString() + " Tq");
                GetCalculateDetails.Add("Time Segments After Sample[TSEG2]: " + segments.Tseg2.ToString() + " Tq");
                GetCalculateDetails.Add("Max Sync Jump Width[SJW]: " + segments.Sjw.ToString() + " Tq");
            }

            TotalNumberOfTimeQuanta = segments.Tseg1 + segments.Tseg2;

            GetCalculateDetails.Add("Total Number Of Time Quanta[tbit]: " + TotalNumberOfTimeQuanta.ToString());

            TimeQuanta = (1 / segments.SystemClock) * segments.Brp * 1000000; /*sec -> usec*/
            GetCalculateDetails.Add("Time Quanta[Tq]: " + TimeQuanta.ToString("N5") + " us");

            TimeBeforeSample = segments.Tseg1 * TimeQuanta;
            GetCalculateDetails.Add("Time Before Sample[tseg1]: " + TimeBeforeSample.ToString("N5") + " us");

            TimeAfterSample = segments.Tseg2 * TimeQuanta;
            GetCalculateDetails.Add("Time After Sample[tseg2]: " + TimeAfterSample.ToString("N5") + " us");

            NominalBitTime = 1 * TimeQuanta + TimeBeforeSample + TimeAfterSample; /* Mindig bele kell számolni a SYNC-et! ami 1 Tq */
            GetCalculateDetails.Add("Nominal Bit Time: " + NominalBitTime.ToString("N5") + " us");

            Baudrate = 1 / (NominalBitTime / 1000000); /* osztva ezerrel a usec -> sec miatt*/
            GetCalculateDetails.Add("Baud Rate: " + Baudrate.ToString("N") + " Buad");

            SamplePoint = ((1.0 + segments.Tseg1) / (double)(segments.Tseg1 + segments.Tseg2 + 1.0)) * 100.0;
            GetCalculateDetails.Add("Sample Point: " + SamplePoint.ToString("N") + " %");
        }
コード例 #2
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="systemClock">System Clock [Hz]</param>
 /// <param name="brp">Baudrate Rate Prescaler [1..1024]</param>
 /// <param name="tseg1">Time Segment1 [1..16] </param>
 /// <param name="tseg2">Time Segment2 [1..8]</param>
 /// <param name="sjw">Sync Jump Width [1..4]</param>
 public void Calculate(double systemClock, int brp, int tseg1, int tseg2, int sjw)
 {
     Segments = new TimeSegemnts(systemClock, brp, tseg1, tseg2, sjw);
     Calculate(Segments);
 }
コード例 #3
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="brp">Baudrate Rate Prescaler [1..1024]</param>
 /// <param name="tseg1">Time Segment1 [1..16] </param>
 /// <param name="tseg2">Time Segment2 [1..8]</param>
 /// <param name="sjw">Sync Jump Width [1..4]</param>
 public void Calculate(int brp, int tseg1, int tseg2, int sjw)
 {
     Segments = new TimeSegemnts(MCAN120803SystemClock, brp, tseg1, tseg2, sjw);
     Calculate(Segments);
 }