| 31 | } |
| 32 | |
| 33 | bool MdfConverter::InitMeasurement() { |
| 34 | write_cache_.Exit(); |
| 35 | |
| 36 | if (IsOpen()) { |
| 37 | Close(); |
| 38 | } |
| 39 | |
| 40 | if (!mdf_file_) { |
| 41 | MDF_ERROR() << "The MDF file is not created. Invalid use of the function."; |
| 42 | return false; |
| 43 | } |
| 44 | |
| 45 | // Set up internal sample buffers so the last channel values can be stored |
| 46 | const bool prep = PrepareForWriting(); |
| 47 | if (!prep) { |
| 48 | MDF_ERROR() << "Failed to prepare the file for writing. File: " |
| 49 | << filename_; |
| 50 | return false; |
| 51 | } |
| 52 | // 1: Save ID, HD, DG, AT, CG and CN blocks to the file. |
| 53 | |
| 54 | Open( write_state_ == WriteState::Create ? |
| 55 | std::ios_base::out | std::ios_base::trunc | std::ios_base::binary |
| 56 | : std::ios_base::out | std::ios_base::binary); |
| 57 | if (!IsOpen()) { |
| 58 | MDF_ERROR() << "Failed to open the file for writing. File: " << filename_; |
| 59 | return false; |
| 60 | } |
| 61 | |
| 62 | // Save the configuration to disc |
| 63 | const bool write = mdf_file_->Write(*file_); |
| 64 | //SetDataPosition(); // Set up data position to end of file |
| 65 | |
| 66 | // Keep the file open to save conversion time |
| 67 | |
| 68 | start_time_ = 0; // Zero indicate not started |
| 69 | stop_time_ = 0; // Zero indicate not stopped |
| 70 | // Start the working thread that handles the samples |
| 71 | write_cache_.Init(); |
| 72 | return write; |
| 73 | } |
| 74 | |
| 75 | bool MdfConverter::FinalizeMeasurement() { |
| 76 | write_cache_.Exit(); |