Пример #1
0
 private void button4_Click(object sender, EventArgs e)
 {
     var mod = ((MODELO_TYPE)comboBox2.SelectedItem);
     if (dm.isStarted())
     {
         dm.stopModel();
     }
     switch (mod)
     {
         case MODELO_TYPE.OMNIDIRECCIONAL:
             dm = new OmniModel();
             break;
         case MODELO_TYPE.DIFERENCIAL:
             dm = new DifferModel();
             break;
         case MODELO_TYPE.ACKERMKAN:
             dm = new AckerModel();
             break;
         default:
             break;
     }
     dm.setDeviceIndex(devIndeex);
     dm.startModel();
     button1.Text = "Desconectar";
 }
Пример #2
0
        void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            clientSock = sock.Accept();
            //leer del cliente
            try
            {
                while (clientSock.Connected)
                {
                    byte[] cmd = new byte[1];
                    clientSock.Receive(cmd);
                    byte[] data;
                    MineroEventArgs mEA;
                    MemoryStream ms = new MemoryStream();
                    switch (((CMD_MINERO)cmd[0]))
                    {
                        case CMD_MINERO.CMD_MODE:
                            data = new byte[1];
                            clientSock.Receive(data);
                            mod = (MODELO_TYPE)data[0];
                            if (modeloRobot.isStarted())
                            {
                                modeloRobot.stopModel();
                            }
                            switch (mod)
                            {
                                case MODELO_TYPE.OMNIDIRECCIONAL:
                                    modeloRobot = new OmniModel();
                                    modeloRobot.setModoOperacion(this._modoOperacion);
                                    break;
                                case MODELO_TYPE.DIFERENCIAL:
                                    modeloRobot = new DifferModel();
                                    modeloRobot.setModoOperacion(this._modoOperacion);
                                    break;
                                case MODELO_TYPE.ACKERMKAN:
                                    modeloRobot = new AckerModel();
                                    modeloRobot.setModoOperacion(this._modoOperacion);
                                    break;
                                default:
                                    break;
                            }
                            if (_modoOperacion == GLOBAL_MODE.MINI_MINERO)
                                modeloRobot.setDeviceIndex(3);
                            else
                                modeloRobot.setDeviceIndex(4);

                            modeloRobot.startModel();
                            mEA = new MineroEventArgs(CMD_MINERO.CMD_MODE, data, 1);
                            break;
                        case CMD_MINERO.CMD_FOTO:
                            data = new byte[1];
                            clientSock.Receive(data);

                            bmp = (Bitmap)bmp1.Clone();
                            // Save to memory using the Jpeg format
                            bmp.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
                            // read to end
                            ms.SetLength(921600);
                            //ms.Position = 0;
                            byte[] bmpBytes = ms.ToArray();
                            bmp.Dispose();
                            ms.Close();
                            mEA = new MineroEventArgs(CMD_MINERO.CMD_FOTO, bmpBytes, bmpBytes.Length);
                            break;
                        default:
                            mEA = new MineroEventArgs(CMD_MINERO.CMD_DEF, cmd, 1);
                            break;
                    }
                    if (MineroEvent != null)
                        MineroEvent(this, mEA);
                }
            }
            catch (Exception ex)
            {
                var mes = ex.Message;
            }
        }