コード例 #1
0
        /// <summary>
        /// Load the files.
        /// </summary>
        /// <param name="files">Files selected.</param>
        private void LoadFiles(string[] files)
        {
            // Set flag
            IsLoading = true;

            if (files.Length > 0)
            {
                // Create the file playback based off the selected file
                // Try to optimize and first load the file into the Binary only codec
                // If this does not work, then try all the codecs
                FilePlayback fp = new FilePlayback();
                fp.FindRtbEnsembles(files);

                // Wait for ensembles to be added
                int timeout = 10;
                while (fp.TotalEnsembles < 0 && timeout >= 0)
                {
                    System.Threading.Thread.Sleep(250);
                    timeout--;
                }

                // Check if any ensembles were found
                if (fp.TotalEnsembles > 0)
                {
                    // Add the ensembles to the project
                    // Create a project if new, or load if old
                    var project = CreateProject(files[0], fp.GetAllEnsembles());

                    // Set the selected playback to the pulsemanager
                    _pm.SelectedProject = project;
                    //_pm.SelectedPlayback = fp;
                }
                else
                {
                    // Find the ensembles using all the codecs
                    fp.FindEnsembles(files);

                    var project = CreateProject(files[0], fp.GetAllEnsembles());

                    // Set the selected playback to the pulsemanager
                    _pm.SelectedProject = project;
                }
            }

            // Reset flag
            IsLoading = false;
        }
コード例 #2
0
ファイル: AdcpImportBinaryFile.cs プロジェクト: 759991469/RTI
        /// <summary>
        /// Import all the files given in the array.
        /// This will open the file.  Read in all the data
        /// and pass the data to the codec.  It will then
        /// close the file and move to the next file.
        /// </summary>
        /// <param name="filenames">Array of file names.</param>
        /// <returns>List of all the ensembles found in the file.</returns>
        public List <FilePlayback.EnsembleData> ImportFiles(string[] filenames)
        {
            try
            {
                // Read in all the information from the file
                using (FilePlayback playback = new FilePlayback())
                {
                    Task.Run(() => playback.FindEnsembles(filenames));

                    // Send an event when complete
                    PublishCompleteEvent();

                    // Return all the ensemble data found
                    return(playback.GetEnsembleDataList());
                }
            }
            catch (Exception e)
            {
                log.Error(string.Format("Error Importing the files: {0}", filenames), e);
                return(new List <FilePlayback.EnsembleData>());
            }
        }
コード例 #3
0
        /// <summary>
        /// Import the RoweTech binary files.
        /// This is optimized for RoweTech Binary files.
        /// </summary>
        /// <param name="files">Files to import to a project.</param>
        private async void ImportRTB(string[] files)
        {
            // If the project does not exist in the list, create it now
            if (!IsProjectExist(_importProjectName))
            {
                // Create the new project based off
                // the project name and project directory
                Project prj = new Project(_importProjectName, RTI.Pulse.Commons.GetProjectDefaultFolderPath(), null);

                // Create the new project based off
                // the project name and project directory
                //System.Windows.Application.Current.Dispatcher.BeginInvoke(new System.Action(() => AddProject(prj)));
                await AddProject(prj);

                prj.Dispose();
            }

            //// Create the importer and an eventhandler to handle the imported data
            //AdcpImportBinaryFile importer = new AdcpImportBinaryFile();
            ////importer.ReceiveBinaryDataEvent += new AdcpImportBinaryFile.ReceiveBinaryDataEventHandler(importer_ReceiveBinaryDataEvent);
            //importer.CompleteEvent += new AdcpImportBinaryFile.CompleteEventHandler(importer_CompleteEvent);

            // Set flag to turn on recording and importing
            // This will tell the recorder to record but since we
            // are importing, do not update all the playback displays
            IsProjectLoading            = true;
            _adcpConnection.IsRecording = true;
            _adcpConnection.IsImporting = true;
            IoC.Get <PlaybackViewModel>().IsRecordEnabled = true;        // Call this to update the display

            // Create the file playback based off the selected file
            List <RTI.FilePlayback.EnsembleData> ensList = new List <FilePlayback.EnsembleData>();

            using (FilePlayback fp = new FilePlayback())
            {
                fp.FindRtbEnsembles(files);
                ensList = fp.GetEnsembleDataList();
            }

            // Publish all the ensembles found from the importer
            //foreach(var ens in list)
            foreach (var ens in ensList)
            {
                //_adcpConnection.PublishEnsembleData(ens.RawData, ens.Ensemble);
                // Check if the serial number is set for the project
                if (_pm.SelectedProject.SerialNumber.IsEmpty())
                {
                    if (ens.Ensemble.IsEnsembleAvail)
                    {
                        _pm.SelectedProject.SerialNumber = ens.Ensemble.EnsembleData.SysSerialNumber;
                    }
                }

                // Record the data
                _pm.SelectedProject.RecordBinaryEnsemble(ens.RawData);
                _pm.SelectedProject.RecordDbEnsemble(ens.Ensemble, AdcpCodec.CodecEnum.Binary);
            }

            // Set the Project Image
            if (_SelectedProjectVM != null)
            {
                await System.Windows.Application.Current.Dispatcher.BeginInvoke(new System.Action(() =>
                {
                    _SelectedProjectVM.RefreshDisplay();
                    this.NotifyOfPropertyChange(() => this.ProjectList);
                }));
            }

            // Turn off recording and importing
            _adcpConnection.IsRecording = false;
            _adcpConnection.IsImporting = false;
            IoC.Get <PlaybackViewModel>().IsRecordEnabled = false;        // Call this to update the display
            IsProjectLoading = false;
        }
コード例 #4
0
        /// <summary>
        /// Import all the files given in the array.
        /// This will open the file.  Read in all the data
        /// and pass the data to the codec.  It will then
        /// close the file and move to the next file.
        /// </summary>
        /// <param name="filenames">Array of file names.</param>
        /// <returns>List of all the ensembles found in the file.</returns>
        public List<FilePlayback.EnsembleData> ImportFiles(string[] filenames)
        {
            try
            {
                // Read in all the information from the file
                using (FilePlayback playback = new FilePlayback())
                {
                    Task.Run(() => playback.FindEnsembles(filenames));

                    // Send an event when complete
                    PublishCompleteEvent();

                    // Return all the ensemble data found
                    return playback.GetEnsembleDataList();
                }
            }
            catch (Exception e)
            {
                log.Error(string.Format("Error Importing the files: {0}", filenames), e);
                return new List<FilePlayback.EnsembleData>();
            }
        }
コード例 #5
0
        /// <summary>
        /// Load the files.
        /// </summary>
        /// <param name="files">Files selected.</param>
        public Project LoadFiles(string[] files)
        {
            // Set flag
            //IsLoading = true;

            Project project = null;

            if (files.Length > 0)
            {
                // Create the file playback based off the selected file
                // Try to optimize and first load the file into the Binary only codec
                // If this does not work, then try all the codecs
                FilePlayback fp = new FilePlayback();
                fp.ProcessFileEvent += Fp_ProcessFileEvent;
                fp.FindRtbEnsembles(files);

                // Wait for ensembles to be added
                int timeout = 10;
                while (fp.TotalEnsembles < 0 && timeout >= 0)
                {
                    System.Threading.Thread.Sleep(250);
                    timeout--;
                }

                // Check if any ensembles were found
                if (fp.TotalEnsembles > 0)
                {
                    // Add the ensembles to the project
                    // Create a project if new, or load if old
                    project = CreateProject(files[0], fp.GetAllEnsembles());

                    // Publish event of found ensembles
                    _eventAggregator.PublishOnUIThread(new PlaybackTotalEnsemblesEvent(fp.TotalEnsembles));
                }
                else
                {
                    // Find the ensembles using all the codecs
                    fp.FindEnsembles(files);
                    project = CreateProject(files[0], fp.GetAllEnsembles());

                    // Publish event of found ensembles
                    _eventAggregator.PublishOnUIThread(new PlaybackTotalEnsemblesEvent(fp.TotalEnsembles));
                }

                fp.ProcessFileEvent -= Fp_ProcessFileEvent;
                fp.Dispose();
            }

            // Reset flag
            //IsLoading = false;

            // Pass the data to all Screen layers
            foreach (var vm in IoC.GetAllInstances(typeof(IProjectLayer)))
            {
                ((IProjectLayer)vm).LoadProject(project);
            }

            project.Dispose();

            return(project);
        }