示例#1
0
 public RoboUSBLinkApp()
 {
     MainThreadQueue = new Queue<RoboUSBLinkComm.VoidFunc>();
     AsyncResults = new List<IAsyncResult>();
     Application.EnableVisualStyles();
     Application.Idle += new EventHandler(this.InvokeApplicationThreadItems);
     Comm = new RoboUSBLinkComm("/dev/ttyACM0", this.MarshalToMainThread);
     MainForm = new RoboUSBLinkForm(Comm);
     MainForm.FormClosing += HandleMainFormFormClosing;
       MainForm.Load += (sender, e) => Comm.Start();
     MainForm.Show(null);
 }
示例#2
0
 public RoboUSBLinkForm(RoboUSBLinkComm comm)
 {
     Comm = comm;
     this.Size = new Size(800, 600);
     //this.DoubleBuffered = true;
     this.Text = "Robot Status";
     InitFonts();
     InitControls();
     Data = new RoboDataModel(comm);
     Data.BoardData += HandleDataBoardData;
     Data.BoardOffline += HandleDataBoardOffline;
     Data.CommOffline += HandleCommOffline;
     Data.CommOnline += HandleCommOnline;
     Data.RangeChanged += HandleRangeChanged;
     Data.VoltageChanged += HandleVoltageChanged;
     Data.DebugMessage += HandleDebugMessage;
 }
示例#3
0
 private void MarshalToMainThread(RoboUSBLinkComm.VoidFunc func)
 {
     lock(MainThreadQueue)
     {
         MainThreadQueue.Enqueue(func);
         if (!isMarshaling)
         {
             isMarshaling = true;
             //	if this generates too much garbage collection pressure, fix it then
             IAsyncResult ar = MainForm.BeginInvoke(new RoboUSBLinkComm.VoidFunc(this.InvokeOnMainThread));
             AsyncResults.Add(ar);
         }
     }
     for (int i = 0; i < AsyncResults.Count; ++i)
     {
         IAsyncResult ar = AsyncResults[i];
         if (ar.IsCompleted)
         {
             MainForm.EndInvoke(ar);
             AsyncResults.RemoveAt(i);
             --i;
         }
     }
 }
示例#4
0
 private void AttachToComm(RoboUSBLinkComm comm)
 {
 }