Пример #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
        /// <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;
        }
Пример #3
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);
        }