Exemplo n.º 1
0
        public bool InitializeOmnis(string LeftOmniName, string RightOmniName)
        {
            bool success = false;

            if (HasOmnis)
            {
                try
                {
                    LeftOmni  = new Device(LeftOmniName);
                    RightOmni = new Device(RightOmniName);
                    LeftOmni.Start();
                    RightOmni.Start();
                    SetOmniForce(new OmniPosition());
                    LeftOmni.SetpointEnabled  = true;
                    RightOmni.SetpointEnabled = true;
                    success = true;
                }
                catch (Exception ex)
                {
                    Main.ShowError(ex.Message, ex.ToString());
                }
            }

            return(success);
        }
Exemplo n.º 2
0
 private void ProcessFrame(object sender, EventArgs arg)
 {
     try
     {
         Image <Bgr, byte> frame = new Image <Bgr, byte>(100, 100);
         if (_capture != null)
         {
             frame = _capture.RetrieveBgrFrame();
         }
         if (frame != null)
         {
             frame = frame.Resize(((double)Main.CaptureImageBox.Width / (double)frame.Width), Emgu.CV.CvEnum.INTER.CV_INTER_LINEAR);
             frame = addMarkup(frame);
             Main.ShowVideoFrame(frame);
             sendVideoStream(frame);
         }
     }
     catch (AccessViolationException ave)
     {
         Main.ShowError(ave.Message, ave.ToString());
     }
     catch (Exception ex)
     {
         Main.ShowError(ex.Message, ex.ToString());
     }
 }
Exemplo n.º 3
0
        private void AssignButtons_FormClosing(object sender, FormClosingEventArgs e)
        {
            if (lb_AvailableEmergencyBtns.SelectedIndex.Equals(lb_AvailableFollowingBtns.SelectedIndex))
            {
                MessageBox.Show("Please select different buttons for each input.", "Inputs must be bound to different buttons.", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
            else
            {
                //Save on exit
                try
                {
                    //Emergency Switch
                    string selectedButton = (string)lb_AvailableEmergencyBtns.SelectedItem;
                    _main.User.EmergencySwitchBoundBtn   = selectedButton;
                    _main.User.EmergencySwitchBoundValue = getButtonValue(lb_AvailableEmergencyBtns);

                    //Following Button
                    selectedButton = (string)lb_AvailableFollowingBtns.SelectedItem;
                    _main.User.FollowingBoundBtn   = selectedButton;
                    _main.User.FollowingBoundValue = getButtonValue(lb_AvailableFollowingBtns);

                    //Freeze Button
                    selectedButton              = (string)lb_AvailableFreezeBtns.SelectedItem;
                    _main.User.FreezeBoundBtn   = selectedButton;
                    _main.User.FreezeBoundValue = getButtonValue(lb_AvailableFreezeBtns);
                }
                catch (Exception ex)
                {
                    _main.ShowError(ex.Message, ex.ToString());
                }
            }
        }
Exemplo n.º 4
0
        public void MasterSendData(int index)
        {
            Socket s = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);

            try
            {
                foreach (User user in Main.Surgery.ConnectedClients)
                {
                    if (!user.MyIPAddress.Equals(Main.User.MyIPAddress))
                    {
                        s.SendTo(CreateMessageToSend(index), new IPEndPoint(IPAddress.Parse(user.MyIPAddress), dataPort));
                    }
                }
            }
            catch (Exception ex)
            {
                Main.ShowError(ex.Message, ex.ToString());
            }
        }
Exemplo n.º 5
0
        public void ListenForMarkup()
        {
            try
            {
                if (markingsListener == null)
                {
                    markingsListener = new UdpClient(markingsPort);
                }

                markingsListener.BeginReceive(new AsyncCallback(markingsReceived), null);
            }
            catch (Exception ex)
            {
                Main.ShowError(ex.Message, ex.ToString());
            }
        }
Exemplo n.º 6
0
 private void btn_laser_Click(object sender, EventArgs e)
 {
     try
     {
         // Create a request using a URL that can receive a post.
         WebRequest request = WebRequest.Create("https://api.particle.io/v1/devices/3c002d000c47343432313031/led?access_token=623b6d6ba0fcd4715c7c60d80f802e522f32903b");
         // Set the Method property of the request to POST.
         request.Method = "POST";
         // Create POST data and convert it to a byte array.
         string postData  = "LED";
         byte[] byteArray = Encoding.UTF8.GetBytes(postData);
         // Set the ContentLength property of the WebRequest.
         request.ContentLength = byteArray.Length;
         // Get the request stream.
         Stream dataStream = request.GetRequestStream();
         // Write the data to the request stream.
         dataStream.Write(byteArray, 0, byteArray.Length);
         // Close the Stream object.
         dataStream.Close();
         // Get the response.
         WebResponse response = request.GetResponse();
         // Display the status.
         //MessageBox.Show(((HttpWebResponse)response).StatusDescription);
         // Get the stream containing content returned by the server.
         dataStream = response.GetResponseStream();
         // Open the stream using a StreamReader for easy access.
         StreamReader reader = new StreamReader(dataStream);
         // Read the content.
         string responseFromServer = reader.ReadToEnd();
         // Display the content.
         //MessageBox.Show(responseFromServer);
         // Clean up the streams.
         reader.Close();
         dataStream.Close();
         response.Close();
     }
     catch (Exception ex)
     {
         _main.ShowError(ex.Message, ex.ToString());
     }
 }