Beispiel #1
0
        private void DisconnectButton_Click(object sender, EventArgs e)
        {
            try
            {
                //if something goes wrong, close the ports that may be open
                SDMC1SerialPort.Close();
                ArduinoSerialPort.Close();

                //Change connection interaction
                SDMC1Port.Enabled        = true;
                SDMC1BaudRate.Enabled    = true;
                ArduinoPort.Enabled      = true;
                ArduinoBaudRate.Enabled  = true;
                ConnectButton.Enabled    = true;
                DisconnectButton.Enabled = false;

                //Change controller interaction
                ArduinoSendText.Enabled   = false;
                ArduinoSendButton.Enabled = false;

                SDMC1SendText.Enabled   = false;
                SDMC1SendButton.Enabled = false;

                HomeButton.Enabled = false;
                ScanButton.Enabled = false;
            }
            catch (Exception error)
            {
                MessageText.Text = error.Message;
            }
        }
Beispiel #2
0
        public KinectTester()
        {
            InitializeComponent();

            sensor       = new SmartKinectSensor();
            renderCanvas = new RenderCanvas(TimeSpan.FromSeconds(10));
            sensor.EnableSkeletonRenderingSensor();

            renderCanvas.ImageRendered += DisplayRenderedImage;

            capturedLabel.Visible = false;

            jointController   = new JointController();
            gestureController = new GestureController();
            skeletonRender    = new SkeletonRenderer(sensor.Sensor);

            sensor.SkeletonController.AddFunction(jointController);
            sensor.SkeletonController.AddFunction(gestureController);
            sensor.SkeletonController.AddFunction(skeletonRender);

            skeletonRender.SkeletonRendered       += renderCanvas.SkeletonFrameCaptured;
            gestureController.GestureCaptured     += GestureCaptured;
            jointController.JointTrackingCaptured += JointTrackingCaptured;

            ArduinoSerialPort serialPort = new ArduinoSerialPort("COM5", 115200);

            serialPort.Open();
            bodyTracker = new KinectBodyTracker(sensor, serialPort);

            GestureBuilderForm test = new GestureBuilderForm(sensor);

            test.Show();

            // InitializeArduino();
        }
Beispiel #3
0
        private void ArduinoSetup()
        {
            ledON = false;
            toggleLED.BackColor = Color.Red;

            serialPort = new ArduinoSerialPort("COM5", 115200);
            serialPort.Open();

            cwAnalogPinMapping  = new PinMapping(11);
            ccwAnalogPinMapping = new PinMapping(10);
            pinMapping          = new PinMapping(13);
            eStop = new PinMapping(8);
            serialPort.ComponentMappings.Add(cwAnalogPinMapping);
            serialPort.ComponentMappings.Add(ccwAnalogPinMapping);
            serialPort.ComponentMappings.Add(pinMapping);
            serialPort.ComponentMappings.Add(eStop);
            cwAnalogPinMapping.SetPinMode(SetPinModeStateCodes.OutputStateCode);
            cwAnalogPinMapping.SetPinMode(SetPinModeStateCodes.OutputStateCode);
            pinMapping.SetPinMode(SetPinModeStateCodes.OutputStateCode);
            eStop.SetPinMode(SetPinModeStateCodes.OutputStateCode);
            pinMapping.FeedbackEvent += new SkynetUtilities.FeedbackRecievedEventHandler(ResponsePackageRecieved);

            this.replyPackageTextBox.Text = "0";

            eStop.SetPin(true);
            stopped = false;
        }
        private void LoginSimpleButton_Click(object sender, EventArgs e)
        {
            username = UsernameTextBox.Text;

            password = PasswordTextBox.Text;

            using (SqlConnection connection = new SqlConnection(HandVeinPattern.Properties.Settings.Default.HandVeinPatternConnectionString))
            {
                using (SqlCommand command = new SqlCommand("AUTHENTICATE_ADMIN"))
                {
                    command.CommandType = CommandType.StoredProcedure;

                    command.Parameters.AddWithValue("@username", username);

                    command.Parameters.AddWithValue("@password", password);

                    command.Connection = connection;

                    connection.Open();

                    SqlDataReader reader = command.ExecuteReader();

                    reader.Read();

                    Details.AdminLoginID = reader["AdminID"].ToString();

                    connection.Close();
                }
                switch (Details.AdminLoginID)
                {
                case "-1":

                    //ArduinoSerialPort.WriteLine("0");

                    MessageBox.Show("Invalid Username Or Password", "Authentication Failed", MessageBoxButtons.OK);

                    clear();

                    break;

                default:

                    clear();

                    //ArduinoSerialPort.WriteLine("1");

                    Dashboard dashboard = new Dashboard();

                    dashboard.Show();

                    ArduinoSerialPort.Close();

                    this.Hide();

                    break;
                }
            }
        }
Beispiel #5
0
        public KinectBodyTracker(SmartKinectSensor smartSensor, ArduinoSerialPort arduinoSerialPort)
        {
            this.skeletonController = smartSensor.SkeletonController;
            this.arduinoSerialPort  = arduinoSerialPort;
            this.joints             = new Joints();
            this.previousTimeStamp  = DateTime.MinValue;
            this.frameCount         = 0;

            CreateEmergencyStop();
            LoadJointProfiles();
            ConnectSkeletonController();
        }
Beispiel #6
0
        private void InitSerialPort(Config config)
        {
            _arduinoSerialPort              = new ArduinoSerialPort();
            _arduinoSerialPort.DataArrived += ArduinoSerialPort_DataArrived;

            try
            {
                _arduinoSerialPort.Open(config.SerialPort, config.BaudRate);
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Beispiel #7
0
 private void ScanArduino_DataReceived(object sender, SerialDataReceivedEventArgs e)
 {
     try
     {
         ArduinoMessage += ArduinoSerialPort.ReadExisting();
         ArduinoReadText.Invoke(new MethodInvoker(delegate
         {
             ArduinoReadText.Text += ArduinoMessage;
         }));
         if (ArduinoMessage.Contains("\n"))
         {
             measurementData.Add(Convert.ToInt32(ArduinoMessage));
             ArduinoMessage = "";
             ScanProgress.Invoke(new MethodInvoker(delegate
             {
                 ScanProgress.Value = 1 / scanLength;
             }));
             if (measurementData.Count < scanLength)
             {
                 SDMC1SerialPort.Write("+1\r");
             }
             else
             {
                 SDMC1SerialPort.DataReceived   -= ScanSDMC1_DataReceived;
                 SDMC1SerialPort.DataReceived   += SDMC1SerialPort_DataReceived;
                 ArduinoSerialPort.DataReceived -= ScanArduino_DataReceived;
                 ArduinoSerialPort.DataReceived += ArduinoSerialPort_DataReceived;
                 SDMC1SerialPort.Write("R" + scanStartPosition + "\r");
                 HomeButton.Invoke(new MethodInvoker(delegate
                 {
                     HomeButton.Enabled = true;
                 }));
                 ScanButton.Invoke(new MethodInvoker(delegate
                 {
                     ScanButton.Enabled = true;
                 }));
             }
             moves++;
         }
     }
     catch (Exception error)
     {
         MessageText.Invoke(new MethodInvoker(delegate
         {
             MessageText.Text = error.Message;
         }));
         ArduinoMessage = "";
     }
 }
Beispiel #8
0
        public void InitializeArduino()
        {
            serialPort = new ArduinoSerialPort("COM5", 115200);
            serialPort.Open();

            cwAnalogPinMapping  = new PinMapping(11);
            ccwAnalogPinMapping = new PinMapping(10);
            eStop = new PinMapping(8);
            serialPort.ComponentMappings.Add(cwAnalogPinMapping);
            serialPort.ComponentMappings.Add(ccwAnalogPinMapping);
            serialPort.ComponentMappings.Add(eStop);
            cwAnalogPinMapping.SetPinMode(SetPinModeStateCodes.OutputStateCode);
            cwAnalogPinMapping.SetPinMode(SetPinModeStateCodes.OutputStateCode);
            eStop.SetPinMode(SetPinModeStateCodes.OutputStateCode);
            eStop.SetPin(true);
        }
Beispiel #9
0
        public MainWindow()
        {
            InitializeComponent();

            ArduinoSerialPort            = new ArduinoSerialPort();
            ArduinoSerialPort.MainWindow = this;

            COMPortInfoListView.PortComboBox.SelectionChanged += PortComboBox_SelectionChanged;

            SerialCommunicationViewModel serialCommunicationViewModel = ArduinoSerialPortView.DataContext as SerialCommunicationViewModel;

            serialCommunicationViewModel.ArduinoSerialPort = ArduinoSerialPort;

            ManualControlViewModel manualControlViewModel = ManualControlView.DataContext as ManualControlViewModel;

            manualControlViewModel.ArduinoSerialPort = ArduinoSerialPort;
        }
Beispiel #10
0
        private bool shut_down = false; // выключение программы

        public Form1()
        {
            InitializeComponent();
            arduino = new ArduinoSerialPort();
            PortsComboBox.Items.AddRange(arduino.Ports);
            if (arduino.Connected)
            {
                PortsComboBox.SelectedText = arduino.PortName;
                ConnectContextMenu.Enabled = false;
            }
            else
            {
                PortsComboBox.SelectedText    = "";
                DisconnectContextMenu.Enabled = false;
                DisableModes();
            }
        }
Beispiel #11
0
 private void ArduinoSerialPort_DataReceived(object sender, SerialDataReceivedEventArgs e)
 {
     try
     {
         String reply = ArduinoSerialPort.ReadExisting();
         ArduinoReadText.Invoke(new MethodInvoker(delegate
         {
             ArduinoReadText.Text = ArduinoReadText.Text + reply;
         }));
     }
     catch (Exception error)
     {
         MessageText.Invoke(new MethodInvoker(delegate
         {
             MessageText.Text = error.Message;
         }));
     }
 }
Beispiel #12
0
 private void ScanSDMC1_DataReceived(object sender, SerialDataReceivedEventArgs e)
 {
     try
     {
         SDMC1Message += SDMC1SerialPort.ReadExisting();
         SDMC1ReadText.Invoke(new MethodInvoker(delegate
         {
             SDMC1ReadText.Text += SDMC1Message;
         }));
         if (SDMC1Message.Contains("\r"))
         {
             ArduinoSerialPort.WriteLine("read");
             SDMC1Message = "";
         }
     }
     catch (Exception error)
     {
         MessageText.Invoke(new MethodInvoker(delegate
         {
             MessageText.Text = error.Message;
         }));
         SDMC1Message = "";
     }
 }
Beispiel #13
0
        private void ConnectButton_Click(object sender, EventArgs e)
        {
            if (SDMC1BaudRate.SelectedItem == "" || SDMC1Port.SelectedItem == "" || ArduinoPort.SelectedItem == "" || ArduinoBaudRate.SelectedItem == "")
            {
                MessageText.Text = "Specify ports and baudrates";
            }
            else
            {
                try
                {
                    //Connect to SDMC1
                    SDMC1SerialPort.PortName    = SDMC1Port.SelectedItem.ToString();
                    SDMC1SerialPort.BaudRate    = Convert.ToInt32(SDMC1BaudRate.SelectedItem.ToString());
                    SDMC1SerialPort.ReadTimeout = timeoutMS;
                    SDMC1SerialPort.DataBits    = 8;
                    SDMC1SerialPort.StopBits    = StopBits.One;
                    SDMC1SerialPort.Parity      = Parity.None;
                    SDMC1SerialPort.Open();

                    //Connect to Arduino
                    ArduinoSerialPort.PortName    = ArduinoPort.SelectedItem.ToString();
                    ArduinoSerialPort.BaudRate    = Convert.ToInt32(ArduinoBaudRate.SelectedItem.ToString());
                    ArduinoSerialPort.ReadTimeout = timeoutMS;
                    ArduinoSerialPort.Open();

                    //Change connection interaction
                    DisconnectButton.Enabled = true;
                    SDMC1Port.Enabled        = false;
                    SDMC1BaudRate.Enabled    = false;
                    ArduinoPort.Enabled      = false;
                    ArduinoBaudRate.Enabled  = false;
                    ConnectButton.Enabled    = false;

                    //Change controller interaction
                    ArduinoSendText.Enabled   = true;
                    ArduinoSendButton.Enabled = true;

                    SDMC1SendText.Enabled   = true;
                    SDMC1SendButton.Enabled = true;

                    HomeButton.Enabled = true;
                }
                catch (Exception error)
                {
                    MessageText.Text = error.Message;

                    //if something goes wrong, close the ports that may be open
                    SDMC1SerialPort.Close();
                    ArduinoSerialPort.Close();

                    //Change connection interaction
                    SDMC1Port.Enabled        = true;
                    SDMC1BaudRate.Enabled    = true;
                    ArduinoPort.Enabled      = true;
                    ArduinoBaudRate.Enabled  = true;
                    ConnectButton.Enabled    = true;
                    DisconnectButton.Enabled = false;

                    //Change controller interaction
                    ArduinoSendText.Enabled   = false;
                    ArduinoSendButton.Enabled = false;

                    SDMC1SendText.Enabled   = false;
                    SDMC1SendButton.Enabled = false;

                    HomeButton.Enabled = false;
                    ScanButton.Enabled = false;
                }
            }
        }
Beispiel #14
0
 private void ArduinoSendButton_Click(object sender, EventArgs e)
 {
     ArduinoSerialPort.Write(ArduinoSendText.Text + '\n');
     ArduinoSendText.Text = "";
 }
Beispiel #15
0
    // =================== Methods ====================


    void Awake()
    {
        DontDestroyOnLoad(this);
        arduino = new ArduinoSerialPort(portName, Baudrates.GetBaudrateToInt(baudRate));
    }