Exemple #1
0
        /// <summary>
        /// Create the backup writer.
        /// </summary>
        /// <param name="name">File names.</param>
        /// <param name="folderPath">Folder path.</param>
        /// <param name="serialNum">Serial number.</param>
        /// <param name="maxFileSize">Maximum file size.</param>
        public void CreateBackupWriter(string name, string folderPath, string serialNum, long maxFileSize)
        {
            _ensembleWriterBackup = new AdcpBinaryWriter(name, folderPath, serialNum, maxFileSize);
            _ensembleWriterBackup.EnsembleWriteEvent += new AdcpBinaryWriter.EnsembleWriteEventHandler(_binaryWriterBackup_EnsembleWriteEvent);

            BackupProjectFolderPath = folderPath;

            // Create the directory if it does not exist
            if (!string.IsNullOrEmpty(BackupProjectFolderPath))
            {
                Directory.CreateDirectory(BackupProjectFolderPath);
            }
        }
Exemple #2
0
        /// <summary>
        /// Record the binary data to the project.
        /// This will take the binary data and add it
        /// to the projects buffer to written to the file.
        /// </summary>
        /// <param name="data">Data to write.</param>
        /// <returns>TRUE = Data written to binary file.</returns>
        public bool RecordGps2(byte[] data)
        {
            // Create the writer if it does not exist
            if (_gps2Writer == null)
            {
                _gps2Writer = new AdcpBinaryWriter(this, Options.MaxFileSize, AdcpBinaryWriter.FileType.GPS2);
                _gps2Writer.SerialNumber = SerialNumber.ToString();
                _gps2Writer.ResetFileName();
            }

            // Add the data to the writer
            if (_gps2Writer != null)
            {
                _gps2Writer.AddIncomingData(data);
                return true;
            }

            return false;
        }
Exemple #3
0
        /// <summary>
        /// Initialize the object
        /// </summary>
        private void Initialize()
        {
            // Create reader and writers
            _ensembleWriter = new AdcpBinaryWriter(this);
            _dbWriter = new AdcpDatabaseWriter() { SelectedProject = this };
            _dbReader = new AdcpDatabaseReader();

            // Subscribe to the events of the writer
            _dbWriter.EnsembleWriteEvent += new AdcpDatabaseWriter.EnsembleWriteEventHandler(_dbWriter_EnsembleWriteEvent);
            _ensembleWriter.EnsembleWriteEvent += new AdcpBinaryWriter.EnsembleWriteEventHandler(_binaryWriter_EnsembleWriteEvent);

            // Get the options from the db
            Options = GetProjectOptions();

            // If a backup project folder path is given, create the backup writer
            if (!string.IsNullOrEmpty(Options.BackupProjectFolderPath))
            {
                CreateBackupWriter(Options.ProjectName, Options.BackupProjectFolderPath, SerialNumber.ToString(), GetMaxBinaryFileSize());
            }

            //SetMaxBinaryFileSize(Options.MaxFileSize);
            if (_ensembleWriter != null)
            {
                _ensembleWriter.MaxFileSize = Options.MaxFileSize;
            }

            if (_ensembleWriterBackup != null)
            {
                _ensembleWriterBackup.MaxFileSize = Options.MaxFileSize;
            }

            // Check the if the serial number can
            // be set from the first ensemble if it is empty
            CheckSerialNumber();

            // Write the current project options to the database
            //WriteProjectOptions();
        }