@@ -761,6 +761,9 @@ bool RigolOscilloscope::AcquireData()
761761 lock_guard<recursive_mutex> lock (m_transport->GetMutex ());
762762 LogIndenter li;
763763
764+ // Notify about download operation start
765+ ChannelsDownloadStarted ();
766+
764767 // Rigol scopes do not have a capture time so we fake it
765768 double now = GetTime ();
766769
@@ -854,7 +857,12 @@ bool RigolOscilloscope::AcquireData()
854857 cap->m_triggerPhase = 0 ;
855858 cap->m_startTimestamp = floor (now);
856859 cap->m_startFemtoseconds = (now - floor (now)) * FS_PER_SECOND;
857-
860+
861+ // Determine the size of one percent of the data to be downloaded
862+ int percent = (m_highDefinition ? 2 * npoints : npoints)/100 ;
863+ int percentage = 0 ;
864+ int restPercentage = 0 ;
865+
858866 // Downloading the waveform is a pain in the butt, because we can only pull 250K points at a time! (Unless you have a MSO5)
859867 for (size_t npoint = 0 ; npoint < npoints;)
860868 {
@@ -933,7 +941,29 @@ bool RigolOscilloscope::AcquireData()
933941
934942 // Read actual block content and decode it
935943 // Scale: (value - Yorigin - Yref) * Yinc
936- m_transport->ReadRawData (header_blocksize_bytes + 1 , temp_buf); // trailing newline after data block
944+
945+ // Read it in slice so that we can smoothly update download progress bar
946+ size_t bytesToRead = header_blocksize_bytes + 1 ; // trailing newline after data block
947+ int slices = bytesToRead / percent;
948+ int sliceRest = bytesToRead % percent;
949+ size_t bytesRead = 0 ;
950+ for (int s = 0 ; s < slices ; s++)
951+ { // Read each block corresponding to one percent of the total waveform
952+ bytesRead += m_transport->ReadRawData (percent, (temp_buf+bytesRead));
953+ percentage++;
954+ UpdateChannelDownloadState (i,percentage);
955+ }
956+ if (bytesRead < bytesToRead)
957+ { // For the rest (bytesToRead % slices)
958+ m_transport->ReadRawData (bytesToRead-bytesRead, (temp_buf+bytesRead));
959+ restPercentage += sliceRest;
960+ if (restPercentage>=percent && percentage < OscilloscopeChannel::DownloadState::DOWNLOAD_FINISHED)
961+ { // Accumulate leftover bytes untill we get a whole percent
962+ percentage++;
963+ UpdateChannelDownloadState (i,percentage);
964+ restPercentage = 0 ;
965+ }
966+ }
937967
938968 double ydelta = yorigin + yreference;
939969 cap->Resize (cap->m_samples .size () + header_blocksize);
@@ -962,6 +992,8 @@ bool RigolOscilloscope::AcquireData()
962992
963993 npoint += header_blocksize;
964994 }
995+ // Notify about end of download for this channel
996+ UpdateChannelDownloadState (i,OscilloscopeChannel::DownloadState::DOWNLOAD_FINISHED);
965997
966998 // Done, update the data
967999 if (cap)
0 commit comments