コード例 #1
0
        public MainForm(DroneClient droneClient)
        {
            InitializeComponent();

            InitApp();

            //创建新的无人机连接
            _droneClient = droneClient;
            _droneClient.VideoPacketAcquired      += OnVideoPacketAcquired;
            _droneClient.NavigationPacketAcquired += OnNavigationPacketAcquired;
            _droneClient.NavigationDataAcquired   += data => _navigationData = data;
            //视频解码设置
            if (_isVedio)
            {
                _videoPacketDecoderWorker = new VideoPacketDecoderWorker(PixelFormat.BGR24, true, OnVideoPacketDecoded);
                _videoPacketDecoderWorker.Start();
                _videoPacketDecoderWorker.UnhandledException += UnhandledException;
                tmrVideoUpdate.Enabled = true;
            }



            if (_isNavadata)
            {
                //导航数据获取事件,添加事件响应

                //定时器更新允许
                tmrStateUpdate.Enabled = true;
            }


            _playerForms = new List <PlayerForm>();



            //点到点部分
            //数据初始化
            if (_isViconRead)
            {
                _viconClient      = new ViconClient();
                _viconPositionGet = new MyViconPosition(_viconClient);
                _viconPositionGet.OnViconPositionRecieve += OnViconPositionRecieve;

                //写文件线程
                //_pwrite = new PositionWrite(System.Environment.CurrentDirectory, string.Format(@"vicon_{0:yyyy_MM_dd_HH_mm}.txt", DateTime.Now));
            }
            else
            {
                _positionClient   = new PositionClient();
                _viconPositionGet = new MyViconPosition(_positionClient);
                _viconPositionGet.OnViconPositionRecieve += OnViconPositionRecieve;
            }
        }
コード例 #2
0
        /// <summary>
        /// 程序使用到的一些变量的初始化
        /// </summary>
        /// <returns></returns>
        private void InitVariable()
        {
            //初始化默认两个按钮都没有选择
            _isAuto = false;
            _isHand = false;

            //自制Vicon位置获取
            _positionClient   = new PositionClient();
            _viconPositionGet = new MyViconPosition(_positionClient);
            _viconPositionGet.OnViconPositionRecieve += OnViconPositionRecieve;

            //测试文件初始化
            string file = string.Format(@"log_{0:yyyy_MM_dd_HH_mm}.txt", DateTime.Now);

            _logFileStream  = new FileStream(System.Environment.CurrentDirectory + @"/" + file, FileMode.OpenOrCreate);
            _logWriteStream = new StreamWriter(_logFileStream);
        }