예제 #1
0
파일: Form1.cs 프로젝트: kill4n/Kuro_ACM
        void mc_MineroEvent(object sender, MineroEventArgs e)
        {
            switch (e.comando)
            {
                case CMD_MINERO.CMD_MODE:

                    break;
                case CMD_MINERO.CMD_FOTO:
                    byte[] da = new byte[921600];

                    mc.sendData(CMD_MINERO.CMD_SND_FOTO, e.data);
                    break;
                case CMD_MINERO.CMD_SND_FOTO:

                    break;
                case CMD_MINERO.CMD_DEF:

                    break;
                default:
                    break;
            }
        }
예제 #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;
            }
        }