Ejemplo n.º 1
0
        private void AddAccess(eDirection dir, int device, int length, byte[] data)
        {
            if (Counter == null)
            {
                Counter = new HighPerformanceCounter("I²C Debug");
                Counter.Start();
            }
            if (I2CAccesses == null)
            {
                I2CAccesses = new LinkedList <I2CDataEntry>();
            }

            lock (I2CAccesses)
            {
                I2CDataEntry entry = new I2CDataEntry();
                entry.Direction = dir;
                entry.Device    = device;
                entry.Length    = length;
                entry.Data      = data;

                Counter.Stop();
                entry.Timestamp = Counter.Duration;
                Counter.Start();

                I2CAccesses.AddLast(entry);
            }
        }
Ejemplo n.º 2
0
        virtual protected void Execute()
        {
            if (DiffFFTWKISS)
            {
                Counter.Start();
                FFTProcess(VarsKISS.fplan);
                Counter.Stop();
                VarsKISS.totalTime += Counter.Duration;

                Counter.Start();
                fftw.execute(VarsFFTW.fplan);
                Counter.Stop();
                VarsFFTW.totalTime += Counter.Duration;
            }

            if (UseFFTW)
            {
                fftw.execute(VarsFFTW.fplan);
            }
            else
            {
                FFTProcess(VarsKISS.fplan);
            }
        }
Ejemplo n.º 3
0
        private void TransferThreadMain()
        {
            string lastSendString = "";

            try
            {
                lock (TransferLock)
                {
                    while (true)
                    {
                        Monitor.Wait(TransferLock);
                        bool retry = true;

                        for (int tries = 5; retry && (tries > 0); tries--)
                        {
                            /* default: do not retry transmission */
                            retry = false;
                            try
                            {
                                switch (TransferDirection)
                                {
                                case eTransferDirection.Receive:
                                    TransferString = ReceiveInternal();
                                    TransmitDelay.Stop();
                                    TransmitDuration = TransmitDelay.Duration;
                                    lastSendString   = "";
                                    break;

                                case eTransferDirection.Send:
                                    TransmitDelay.Start();
                                    SendInternal(TransferString);
                                    lastSendString = TransferString;
                                    break;

                                case eTransferDirection.None:
                                    break;
                                }
                            }
                            catch (TimeoutException e)
                            {
                                RX_FFT.Components.GDI.Log.AddMessage("[SerialPortTuner] Failure: TIMEOUT");
                                if (tries == 0 || lastSendString == "")
                                {
                                    TransferString  = "TIMEOUT";
                                    TransferFailure = true;
                                }
                                else
                                {
                                    retry = true;
                                    SendInternal(lastSendString);
                                }
                            }
                            catch (Exception e)
                            {
                                RX_FFT.Components.GDI.Log.AddMessage("[SerialPortTuner] Failure: TRANSFER FAILURE (" + e.ToString() + ")");
                                if (tries == 0 || lastSendString == "")
                                {
                                    TransferString  = "TRANSFER FAILURE";
                                    TransferFailure = true;
                                }
                                else
                                {
                                    retry = true;
                                    SendInternal(lastSendString);
                                }
                            }
                        }
                        TransferDirection = eTransferDirection.None;
                        Monitor.Pulse(TransferLock);
                    }
                }
            }
            catch (ThreadAbortException)
            {
            }
            catch (Exception e)
            {
                Log.AddMessage("Exception: " + e.ToString());
            }
        }