@@ -0,0 +1,2748 @@
+package com.cisco.trex.stl.gui.services.capture;%0A%0Aimport com.cisco.trex.stateless.TRexClient;%0Aimport com.cisco.trex.stateless.model.TRexClientResult;%0Aimport com.cisco.trex.stateless.model.capture.CaptureInfo;%0Aimport com.cisco.trex.stateless.model.capture.CaptureMonitor;%0Aimport com.cisco.trex.stateless.model.capture.CapturedPackets;%0Aimport com.exalttech.trex.application.TrexApp;%0Aimport javafx.concurrent.ScheduledService;%0Aimport javafx.concurrent.Task;%0Aimport org.apache.log4j.Logger;%0A%0Aimport java.util.List;%0A%0Apublic class PktCaptureService extends ScheduledService%3CCapturedPackets%3E%0A    private static Logger LOG = Logger.getLogger(PktCaptureService.class);%0A    %0A    private int currentActiveMonitorId = 0;%0A    %0A    private TRexClient tRexClient = TrexApp.injector.getInstance(TRexClient.class);%0A    %0A    @Override%0A    protected Task%3CCapturedPackets%3E createTask() %7B%0A        return new Task%3CCapturedPackets%3E() %7B%0A            @Override%0A            protected CapturedPackets call() throws Exception %7B%0A                if (currentActiveMonitorId == 0) %7B%0A                    return null;%0A                %7D%0A                try %7B%0A                    return fetchCapturedPkts(currentActiveMonitorId, 10);%0A                %7D catch (PktCaptureServiceException e) %7B%0A                    LOG.error(%22Unable to fetch pkts from monitor.%22, e);%0A                    return null;%0A                %7D%0A                %0A            %7D%0A        %7D;%0A    %7D%0A    %0A    public boolean startMonitor(List%3CInteger%3E rx, List%3CInteger%3E tx) throws PktCaptureServiceException %7B%0A        TRexClientResult%3CCaptureMonitor%3E result = tRexClient.captureMonitorStart(rx, tx);%0A        guardNotFailed(result);%0A        currentActiveMonitorId = result.get().getCaptureId();%0A        return true;%0A    %7D%0A    %0A    public CapturedPackets fetchCapturedPkts(int captureId, int chunkSize) throws PktCaptureServiceException %7B%0A        TRexClientResult%3CCapturedPackets%3E result = tRexClient.captureFetchPkts(captureId, chunkSize);%0A        guardNotFailed(result);%0A        return result.get();%0A    %7D%0A    %0A    public CaptureMonitor addRecorder(List%3CInteger%3E rx, List%3CInteger%3E tx, int bufferSize) throws PktCaptureServiceException %7B%0A        TRexClientResult%3CCaptureMonitor%3E result = tRexClient.captureRecorderStart(rx, tx, bufferSize);%0A        guardNotFailed(result);%0A        return result.get();%0A    %7D%0A    %0A    public void getActiveCaptures() throws PktCaptureServiceException %7B%0A        TRexClientResult%3CCaptureInfo%5B%5D%3E result = tRexClient.getActiveCaptures();%0A        guardNotFailed(result);%0A    %7D%0A    %0A    private void guardNotFailed(TRexClientResult%3C?%3E result) throws PktCaptureServiceException %7B%0A        if (result.isFailed()) %7B%0A            throw new PktCaptureServiceException(result.getError());%0A        %7D%0A    %7D%0A%7D%0A

Add PktCaptureService