Search in sources :

Example 1 with DownloadManagerStats

use of com.biglybt.core.download.DownloadManagerStats in project BiglyBT by BiglySoftware.

the class SystemTraySWT method updateUI.

// @see UIUpdatable#updateUI()
@Override
public void updateUI(boolean is_visible) {
    if (interval++ % 10 > 0) {
        return;
    }
    if (trayItem.isDisposed()) {
        uiFunctions.getUIUpdater().removeUpdater(this);
        return;
    }
    if (core == null || !core.isStarted()) {
        return;
    }
    if (enableTooltip) {
        GlobalManagerStats stats = gm.getStats();
        StringBuilder toolTip = new StringBuilder();
        int seeding = 0;
        int downloading = 0;
        DownloadManager next_download = null;
        long next_download_eta = Long.MAX_VALUE;
        TagManager tm = TagManagerFactory.getTagManager();
        if (tm != null && tm.isEnabled()) {
            TagType tt = tm.getTagType(TagType.TT_DOWNLOAD_STATE);
            if (tt != null) {
                TagDownload dl_tag = (TagDownload) tt.getTag(1);
                downloading = dl_tag.getTaggedCount();
                seeding = tt.getTag(2).getTaggedCount();
                if (enableTooltipNextETA && downloading > 0) {
                    for (DownloadManager dl : dl_tag.getTaggedDownloads()) {
                        DownloadManagerStats dl_stats = dl.getStats();
                        long eta = dl_stats.getSmoothedETA();
                        if (eta < next_download_eta) {
                            next_download_eta = eta;
                            next_download = dl;
                        }
                    }
                }
            }
        } else {
        // OMG this must be slow on 10k lists
        /*
		  		List<?> managers = gm.getDownloadManagers();
		  		for (int i = 0; i < managers.size(); i++) {
		  			DownloadManager manager = (DownloadManager) managers.get(i);
		  			int state = manager.getState();
		  			if (state == DownloadManager.STATE_DOWNLOADING)
		  				downloading++;
		  			if (state == DownloadManager.STATE_SEEDING)
		  				seeding++;
		  		}
		  		*/
        }
        String seeding_text = seedingKeyVal.replaceAll("%1", "" + seeding);
        String downloading_text = downloadingKeyVal.replaceAll("%1", "" + downloading);
        toolTip.append(seeding_text).append(downloading_text).append("\n");
        if (next_download != null) {
            String dl_name = next_download.getDisplayName();
            if (dl_name.length() > 80) {
                dl_name = dl_name.substring(0, 77) + "...";
            }
            dl_name = dl_name.replaceAll("&", "&&");
            toolTip.append("  ");
            toolTip.append(dl_name);
            toolTip.append(": ");
            toolTip.append(etaKeyVal);
            toolTip.append("=");
            toolTip.append(DisplayFormatters.formatETA(next_download_eta));
            toolTip.append("\n");
        }
        toolTip.append(dlAbbrKeyVal).append(" ");
        toolTip.append(DisplayFormatters.formatDataProtByteCountToKiBEtcPerSec(stats.getDataReceiveRate(), stats.getProtocolReceiveRate()));
        toolTip.append(", ").append(ulAbbrKeyVal).append(" ");
        toolTip.append(DisplayFormatters.formatDataProtByteCountToKiBEtcPerSec(stats.getDataSendRate(), stats.getProtocolSendRate()));
        int alerts = Alerts.getUnviewedLogAlertCount();
        if (alerts > 0) {
            toolTip.append("\n");
            toolTip.append(alertsKeyVal.replaceAll("%1", "" + alerts));
        }
        trayItem.setToolTipText(toolTip.toString());
    }
    if (Constants.isUnix && gm != null) {
        GlobalManagerStats stats = gm.getStats();
        long l = (stats.getDataReceiveRate() + stats.getDataSendRate()) / 1024;
        if (l != lastUnixVal) {
            lastUnixVal = l;
            trayItem.setMenu(menu, menuBuilder);
        }
    }
    // Why should we refresh the image? it never changes ...
    // and is a memory bottleneck for some non-obvious reasons.
    // trayItem.setImage(ImageLoader.getInstance().getImage("logo16"));
    trayItem.setVisible(true);
}
Also used : TagType(com.biglybt.core.tag.TagType) TagManager(com.biglybt.core.tag.TagManager) GlobalManagerStats(com.biglybt.core.global.GlobalManagerStats) DownloadManagerStats(com.biglybt.core.download.DownloadManagerStats) DownloadManager(com.biglybt.core.download.DownloadManager) TagDownload(com.biglybt.core.tag.TagDownload)

Example 2 with DownloadManagerStats

use of com.biglybt.core.download.DownloadManagerStats in project BiglyBT by BiglySoftware.

the class TagDownloadWithState method updateStuff.

private void updateStuff() {
    long now = SystemTime.getCurrentTime();
    if (now - last_rate_update > 2500) {
        int new_up = 0;
        int new_down = 0;
        long new_agg_up = 0;
        long new_agg_down = 0;
        Set<DownloadManager> dms = getTaggedDownloads();
        if (dms.size() == 0) {
            new_up = -1;
            new_down = -1;
        } else {
            new_up = 0;
            new_down = 0;
            for (DownloadManager dm : dms) {
                DownloadManagerStats stats = dm.getStats();
                new_up += stats.getDataSendRate() + stats.getProtocolSendRate();
                new_down += stats.getDataReceiveRate() + stats.getProtocolReceiveRate();
                long downloaded = stats.getTotalGoodDataBytesReceived();
                long uploaded = stats.getTotalDataBytesSent();
                if (downloaded > 0) {
                    new_agg_down += downloaded;
                }
                if (uploaded > 0) {
                    new_agg_up += uploaded;
                }
            }
        }
        upload_rate = new_up;
        download_rate = new_down;
        aggregate_sr = new_agg_down <= 0 ? 0 : (int) ((1000 * new_agg_up) / new_agg_down);
        last_rate_update = now;
    }
}
Also used : DownloadManagerStats(com.biglybt.core.download.DownloadManagerStats) DownloadManager(com.biglybt.core.download.DownloadManager)

Example 3 with DownloadManagerStats

use of com.biglybt.core.download.DownloadManagerStats in project BiglyBT by BiglySoftware.

the class DiskManagerImpl method fixupSkippedCalculation.

private void fixupSkippedCalculation() {
    if (skipped_file_set_changed) {
        DiskManagerFileInfoImpl[] current_files = files;
        if (current_files != null) {
            skipped_file_set_changed = false;
            try {
                file_piece_mon.enter();
                long skipped = 0;
                long downloaded = 0;
                for (int i = 0; i < current_files.length; i++) {
                    DiskManagerFileInfoImpl file = current_files[i];
                    if (file.isSkipped()) {
                        skipped += file.getLength();
                        downloaded += file.getDownloaded();
                    }
                }
                skipped_file_set_size = skipped;
                skipped_but_downloaded = downloaded;
            } finally {
                file_piece_mon.exit();
            }
            DownloadManagerStats stats = download_manager.getStats();
            if (stats instanceof DownloadManagerStatsImpl) {
                ((DownloadManagerStatsImpl) stats).setSkippedFileStats(skipped_file_set_size, skipped_but_downloaded);
            }
        }
    }
}
Also used : DownloadManagerStatsImpl(com.biglybt.core.download.impl.DownloadManagerStatsImpl) DownloadManagerStats(com.biglybt.core.download.DownloadManagerStats)

Example 4 with DownloadManagerStats

use of com.biglybt.core.download.DownloadManagerStats in project BiglyBT by BiglySoftware.

the class TrayWindow method updateUI.

// @see UIUpdatable#updateUI()
@Override
public void updateUI() {
    if (minimized.isDisposed() || !minimized.isVisible())
        return;
    StringBuilder toolTip = new StringBuilder();
    // $NON-NLS-1$
    String separator = "";
    try {
        managers_mon.enter();
        for (int i = 0; i < managers.size(); i++) {
            DownloadManager manager = (DownloadManager) managers.get(i);
            DownloadManagerStats stats = manager.getStats();
            String name = manager.getDisplayName();
            String completed = DisplayFormatters.formatPercentFromThousands(stats.getPercentDoneExcludingDND());
            toolTip.append(separator);
            toolTip.append(name);
            toolTip.append(" -- C: ");
            toolTip.append(completed);
            toolTip.append(", D : ");
            toolTip.append(DisplayFormatters.formatDataProtByteCountToKiBEtcPerSec(stats.getDataReceiveRate(), stats.getProtocolReceiveRate()));
            toolTip.append(", U : ");
            toolTip.append(DisplayFormatters.formatDataProtByteCountToKiBEtcPerSec(stats.getDataSendRate(), stats.getProtocolSendRate()));
            // $NON-NLS-1$
            separator = "\n";
        }
    } finally {
        managers_mon.exit();
    }
// label.setToolTipText(toolTip.toString());
// minimized.moveAbove(null);
}
Also used : DownloadManagerStats(com.biglybt.core.download.DownloadManagerStats) DownloadManager(com.biglybt.core.download.DownloadManager) Point(org.eclipse.swt.graphics.Point)

Example 5 with DownloadManagerStats

use of com.biglybt.core.download.DownloadManagerStats in project BiglyBT by BiglySoftware.

the class DownloadBar method refresh0.

@Override
protected void refresh0() {
    DownloadManagerStats stats = download.getStats();
    download_name.setText(download.getDisplayName());
    int percent = stats.getPercentDoneExcludingDND();
    this.updateSpeedLabel(down_speed, stats.getDataReceiveRate(), stats.getProtocolReceiveRate());
    this.updateSpeedLabel(up_speed, stats.getDataSendRate(), stats.getProtocolSendRate());
    eta.setText(DisplayFormatters.formatETA(stats.getSmoothedETA()));
    if (progress_bar.getSelection() != percent) {
        progress_bar.setSelection(percent);
        progress_bar.redraw();
    }
}
Also used : DownloadManagerStats(com.biglybt.core.download.DownloadManagerStats)

Aggregations

DownloadManagerStats (com.biglybt.core.download.DownloadManagerStats)17 DownloadManager (com.biglybt.core.download.DownloadManager)12 DiskManagerFileInfo (com.biglybt.core.disk.DiskManagerFileInfo)4 List (java.util.List)4 PEPeerManager (com.biglybt.core.peer.PEPeerManager)3 ArrayList (java.util.ArrayList)3 Category (com.biglybt.core.category.Category)2 DiskManager (com.biglybt.core.disk.DiskManager)2 DownloadManagerStatsImpl (com.biglybt.core.download.impl.DownloadManagerStatsImpl)2 GlobalManager (com.biglybt.core.global.GlobalManager)2 GlobalManagerStats (com.biglybt.core.global.GlobalManagerStats)2 TOTorrent (com.biglybt.core.torrent.TOTorrent)2 Core (com.biglybt.core.Core)1 CoreRunningListener (com.biglybt.core.CoreRunningListener)1 ParameterListener (com.biglybt.core.config.ParameterListener)1 DownloadManagerListener (com.biglybt.core.download.DownloadManagerListener)1 DownloadManagerOptionsHandler (com.biglybt.core.download.DownloadManagerOptionsHandler)1 GlobalManagerEvent (com.biglybt.core.global.GlobalManagerEvent)1 GlobalManagerEventListener (com.biglybt.core.global.GlobalManagerEventListener)1 GlobalManagerListener (com.biglybt.core.global.GlobalManagerListener)1