示例#1
0
文件: Bowling.cs 项目: toanGa/LAB
        void SerialProc()
        {
            String datain;// = serial.GetDataIncome();

            while (true)
            {
                if (serial.IsDataIn())
                {
                    datain = serial.GetDataIncome();
                    if (datain == SERIAL_UP)
                    {
                        if (systemState == PLAY)
                        {
                            if (speed == SPEED_MIN)
                            {
                            }
                            else
                            {
                                speed--;
                                timer1.Interval = speed * 100;
                            }
                        }
                        MessageBox.Show("up speed" + speed);
                        //while (serial.GetDataIncome() == SERIAL_UP) ;
                    }
                    else if (datain == SERIAL_DOWN)
                    {
                        if (systemState == PLAY)
                        {
                            if (speed == SPEED_MAX)
                            {
                            }
                            else
                            {
                                speed++;
                                timer1.Interval = speed * 100;
                            }
                        }
                        MessageBox.Show("up down" + speed);
                        //while (serial.GetDataIncome() == SERIAL_DOWN) ;
                    }
                    else if (datain == SERIAL_OK)
                    {
                    }
                    else if (datain == SERIAL_RESET)
                    {
                    }
                    else if (datain == SERIAL_PAUSE)
                    {
                    }

                    serial.ResetFlag();
                }
            }
        }
示例#2
0
        void SerialProc()
        {
            String datain;// = serial.GetDataIncome();

            while (true)
            {
                if (serial.IsDataIn())
                {
                    datain = serial.GetDataIncome();
                    if (datain == SERIAL_UP)
                    {
                        if (systemState == PLAY)
                        {
                            if (speed == SPEED_MIN)
                            {
                            }
                            else
                            {
                                lock (syncObj1)
                                {
                                    speed--;
                                    timer1.Interval = speed * 100;
                                }
                            }
                        }
                        //MessageBox.Show("up speed" + speed);


                        //while (serial.GetDataIncome() == SERIAL_UP) ;
                    }
                    else if (datain == SERIAL_DOWN)
                    {
                        if (systemState == PLAY)
                        {
                            if (speed == SPEED_MAX)
                            {
                            }
                            else
                            {
                                speed++;
                                timer1.Interval = speed * 100;
                            }
                        }
                        //MessageBox.Show("up down" + speed);
                        //while (serial.GetDataIncome() == SERIAL_DOWN) ;
                    }
                    else if (datain == SERIAL_OK)
                    {
                        //ok_Event();
                        if (bollState == BOLL_READY)
                        {
                            timer2.Enabled = true;
                            bollState      = BOLL_RUNNING;
                            //MessageBox.Show("nem xong");
                        }
                    }
                    else if (datain == SERIAL_RESET)
                    {
                    }
                    else if (datain == SERIAL_PAUSE)
                    {
                    }

                    serial.ResetFlag();
                }
                Thread.Sleep(500);
            }
        }