Пример #1
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="body"></param>
        public void wait_start(EquipmentParameters body)
        {
            //スタート待ち
            var dialogSTART = new InfoDialog("Touch to START", false);
            dialogSTART.Show(); // Wait for enter to be pressed

            MicroStopwatch stopwatch = new MicroStopwatch();
            stopwatch.Start();
            int counter = 0;
            Thread.Sleep(2000);

            while (!body.TouchSensors.IsPressed())
            {
                TailMoter.tailControl(body, EquipmentParameters.TAIL_ANGLE_STAND_UP); //完全停止用角度に制御
                if (btConnectionLibrary.CheckRemoteCommand(EquipmentParameters.REMOTE_COMMAND_START))
                    break;  // PC で 'g' キーが押された

                // 電圧を取得
                int battery = Brick.GetVoltageMilliVolt();
                int reflection = body.LightSensors.Read();
                int gyroNow = body.GyroSensors.Read();
                int thetaL = body.MpLeft.GetTachoCount();
                int theTaR = body.MpRight.GetTachoCount();
                
                SensorData sendData = new SensorData();
                sendData.AddAPower(builder, 0);
                sendData.AddBPower(builder, 0);
                sendData.AddBOdometer(builder, thetaL);
                sendData.AddBattery(builder, battery);
                sendData.AddCPower (builder, 0);
                sendData.AddCOdometer (builder, theTaR);
                sendData.AddGyroSensor(builder, gyroNow);
                sendData.AddReflectionSensor(builder, reflection);
                sendData.AddSonerSensor(builder, 0);
                sendData.AddTouchSenser(builder, 0);
                sendData.AddTaskProcessTime(builder, stopwatch.ElapsedMicroseconds);
                btConnectionLibrary.SensorDataContainer.Enqueue(sendData);

                if (++counter >= 100 / 4)
                {

                     btConnectionLibrary.SendQueueData2();
                     counter = 0;
                }

                Thread.Sleep(4);
            }

            while (body.TouchSensors.IsPressed())
            {
                TailMoter.tailControl(body, EquipmentParameters.TAIL_ANGLE_STAND_UP); //完全停止用角度に制御
                Thread.Sleep(4);
            }
        }
Пример #2
0
 public static SensorData GetRootAsSensorData(ByteBuffer _bb, SensorData obj) { return (obj.__init(_bb.GetInt(_bb.Position) + _bb.Position, _bb)); }
        /// <summary>
        /// Queue にデータを追加
        /// </summary>
        /// <param name="data"></param>
        public void Enqueue(SensorData data)
        {
            try
            {
                lock (_syncObject)
                {
                    senserQueueDataContainer.Enqueue(data);
                }
            }
            catch (Exception e)
            {
                throw;
            }

            return ;
        }