public USBRXDevice() { ReadTimer = new AccurateTimer(); ReadTimer.Interval = 50; // ReadTimer.Type = AccurateTimer.eEventType.Wait; ReadTimer.Timer += new EventHandler(ReadTimer_Timer); }
static void Main(string[] args) { //Application.SetCompatibleTextRenderingDefault(false); Application.EnableVisualStyles(); Application.ThreadException += new ThreadExceptionEventHandler(Application_ThreadException); AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException); _serialPortInterface.MessageReadCallback = new SerialPortInterface.MessageReadHandler(InterpretMessage); _dataGraph.UserSentFloatValue = new Form1.UserInputFloatDelegate(SendFloatCommandToDrone); _dataGraph.UserSentUInt32Value = new Form1.UserInputUInt32Delegate(SendUInt32CommandToDrone); _dataGraph.UserSentInt32Value = new Form1.UserInputInt32Delegate(SendInt32CommandToDrone); bool result; result = _serialPortInterface.Open(); if (result == false) { Console.WriteLine("port openning failed!"); } else { Console.WriteLine("port openning successful!"); } transmissionTimer = new AccurateTimer(_dataGraph, new Action(SendMessages), 10); Application.Run(_dataGraph); _serialPortInterface.Close(); }
protected D3DApp(Control control) { IsPaused = false; Timer = new AccurateTimer(); ControlWindow = control; _fps = 0; _frameCount = 0; _lastFpsSecond = 0; _lastRenderSecond = 0; _hasRun = false; }
public void Start() { sw.Start(); queue = new Queue <TimeSpan>(2000); int delay = 20; // In milliseconds. 10 = 1/100th second. mTimer1 = new AccurateTimer(this, new Action(TimerTick1), delay); delay = 100; // 100 = 1/10th second. mTimer2 = new AccurateTimer(this, new Action(TimerTick2), delay); //Stop(); }
public LogFileDaily(string name, string _pathFormat, bool autoFlush = false, int verbosity = -1) { pathFormat = _pathFormat; AutoFlush = autoFlush; ChangeLogFile(); Verbosity = verbosity; var dueTime = DateTime.Now.AddDays(1).Date; var interval = TimeSpan.FromDays(1); timer = new AccurateTimer(ChangeLogFile, dueTime, interval); }
public LogFileHourly(string name, string _pathFormat, bool autoFlush = false, int verbosity = -1) { pathFormat = _pathFormat; AutoFlush = autoFlush; ChangeLogFile(); Verbosity = verbosity; var dueTime = DateTime.Parse(DateTime.Now.AddHours(1).ToString("yyyy-MM-ddTHH:00:00")); var interval = TimeSpan.FromHours(1); timer = new AccurateTimer(ChangeLogFile, dueTime, interval); }
public DirectXWaterfallFFTDisplay() { InitializeComponent(); FpsUpdateTimer = new AccurateTimer(); FpsUpdateTimer.Interval = 1000; FpsUpdateTimer.Timer += FpsUpdateTimer_Timer; FpsUpdateTimer.Start(); /* we work with already squared FFT values for performance reasons */ FFTDisplay.SquaredFFTData = true; WaterfallDisplay.SquaredFFTData = true; /* handle some actions ourselves */ FFTDisplay.UserEventCallback = UserEventCallbackFunc; WaterfallDisplay.UserEventCallback = UserEventCallbackFunc; /* when dragging in Y-direction in FFTDisplay, update offset */ FFTDisplay.EventActions[eUserEvent.MouseDragY] = eUserAction.YOffset; FFTDisplay.EventActions[eUserEvent.MouseDragYShift] = eUserAction.YOffset; /* when zooming in X direction in FFTDisplay, update waterfall view also */ FFTDisplay.EventActions[eUserEvent.MouseWheelUpShift] = eUserAction.UserCallback; FFTDisplay.EventActions[eUserEvent.MouseWheelDownShift] = eUserAction.UserCallback; /* to force "show cursor" in other graph */ AddUserEventCallback(eUserEvent.MouseEnter); AddUserEventCallback(eUserEvent.MouseLeave); /* when dragging, drag other view also */ AddUserEventCallback(eUserEvent.MouseDragX); AddUserEventCallback(eUserEvent.MouseDragXShift); /* when zooming in? */ //FFTDisplay.EventActions[eUserEvent.MouseWheelUp] = eUserAction.UserCallback; //FFTDisplay.EventActions[eUserEvent.MouseWheelDown] = eUserAction.UserCallback; /* configure update speed */ //WaterfallDisplay.EventActions[eUserEvent.MouseWheelUpAlt] = eUserAction.UserCallback; //WaterfallDisplay.EventActions[eUserEvent.MouseWheelDownAlt] = eUserAction.UserCallback; }
public FileSourceDeviceControl(string fileName, int oversampling) { InitializeComponent(); InternalOversampling = oversampling; if (fileName == null) { FileDialog dlg = new OpenFileDialog(); if (dlg.ShowDialog() == DialogResult.OK) { fileName = dlg.FileName; } } Timer = new AccurateTimer(); Timer.Periodic = true; Timer.Timer += new EventHandler(Timer_Timer); if (fileName != null) { FileName = fileName; Source = new FileSampleSource(FileName, InternalOversampling); Source.ForwardEnabled = true; Source.SamplesPerBlock = (int)Math.Min(ReadFrameRate * Source.InputSamplingRate, 32768); trackBar.Maximum = (int)(Source.GetTotalTime() / 0.01f); if (trackBar.Maximum < 0) { trackBar.Maximum = int.MaxValue; } Timer.Interval = (uint)((double)(Source.OutputBlockSize * 1000.0f) / Source.OutputSamplingRate); UpdateDisplay(); Timer.Start(); } }
public string FormatLabel(IDataPacket dataPacket) { StringBuilder stringBuilder = new StringBuilder(); if (dataPacket.Exception != null) { stringBuilder.Append("EXC"); } else if (dataPacket.Data == null || dataPacket.Data.Length == 0) { stringBuilder.Append("SHT"); } else { stringBuilder.Append(dataPacket.Direction == DataDirection.Received ? "RCV" : "SND"); } stringBuilder.Append(dataPacket.Direction == DataDirection.Received ? " < " : " > "); stringBuilder.Append(AccurateTimer.FormatAbsolute(dataPacket.TimeStamp)); if (dataPacket.Data != null && dataPacket.Data.Length > 0) { stringBuilder.Append(" (" + dataPacket.Data.Length.ToString() + " bytes)"); } return(stringBuilder.ToString()); }
private void Form1_Load(object sender, EventArgs e) { this.timer = new AccurateTimer(this, new Action(TimerCallback), 16); }
public GameLoop() { movementTimer = new AccurateTimer(); //thisThread = new StoppableThread( new StoppableThread.WhileRunning( MainLoop ) ); }