Search in sources :

Example 6 with AssignedProfile

use of com.exalttech.trex.ui.views.models.AssignedProfile in project trex-stateless-gui by cisco-system-traffic-generator.

the class MainViewController method updateHeaderBtnStat.

/**
 * Update header stream buttons state
 */
private void updateHeaderBtnStat() {
    int portIndex = getSelectedPortIndex();
    resetBtnState();
    if (portIndex != -1) {
        Port port = portManager.getPortByIndex(portIndex);
        PortState state = PortState.getPortStatus(port.getStatus());
        // enable state btn btn according to owner
        boolean isOwner = portManager.isCurrentUserOwner(portIndex);
        switch(state) {
            case STREAMS:
                startStream.setDisable(!isOwner || !portManager.getPortModel(portIndex).isStreamLoaded());
                break;
            case TX:
                pauseStream.setDisable(!isOwner);
                stopStream.setDisable(!isOwner);
                break;
            case PAUSE:
                startStream.setDisable(!isOwner);
                pauseStream.setDisable(!isOwner);
                stopStream.setDisable(!isOwner);
                pauseStream.getStyleClass().add("pauseIconPressed");
                break;
            case IDLE:
                AssignedProfile portProfile = assignedPortProfileMap.get(portIndex);
                if (portProfile != null) {
                    startStream.setDisable(!(isOwner && portProfile.isProfileAssigned()));
                }
                break;
            default:
                break;
        }
    }
}
Also used : AssignedProfile(com.exalttech.trex.ui.views.models.AssignedProfile) PortState(com.exalttech.trex.ui.PortState) Port(com.exalttech.trex.ui.models.Port)

Example 7 with AssignedProfile

use of com.exalttech.trex.ui.views.models.AssignedProfile in project trex-stateless-gui by cisco-system-traffic-generator.

the class MainViewController method doUpdateAssignedProfile.

/**
 * Update current port
 */
private void doUpdateAssignedProfile() {
    try {
        if (needReassignProfile) {
            needReassignProfile = false;
            String assignedProfile = String.valueOf(profileListBox.getValue());
            assignProfile(assignedProfile, multiplierView.getSliderValue(), true, lastSelectedPortIndex);
        } else {
            serverRPCMethods.updateTraffic(lastSelectedPortIndex, false, MultiplierType.pps.name(), multiplierView.getPPSValue());
            // update assigned profile multiplier
            AssignedProfile assignedProf = assignedPortProfileMap.get(lastSelectedPortIndex);
            updateMultiplierValues(assignedProf);
        }
        updateHeaderBtnStat();
    } catch (TrafficException ex) {
        LOG.error("Error updating port", ex);
    }
    enableUpdateBtn(false, false);
}
Also used : AssignedProfile(com.exalttech.trex.ui.views.models.AssignedProfile) TrafficException(com.exalttech.trex.remote.exceptions.TrafficException)

Example 8 with AssignedProfile

use of com.exalttech.trex.ui.views.models.AssignedProfile in project trex-stateless-gui by cisco-system-traffic-generator.

the class MainViewController method updateCurrentProfile.

/**
 * Update current loaded profile
 */
private void updateCurrentProfile() {
    // TODO get rid of this method and implement with tryUpdateProfile(...)
    profileLoaded = false;
    AssignedProfile assignedProf = assignedPortProfileMap.get(lastSelectedPortIndex);
    if (assignedProf != null) {
        assignedProf.setHasDuration(multiplierView.isDurationEnable());
        updateMultiplierValues(assignedProf);
    }
    if (isWaitingUpdate()) {
        tryUpdateProfile(false, true);
    }
}
Also used : AssignedProfile(com.exalttech.trex.ui.views.models.AssignedProfile)

Example 9 with AssignedProfile

use of com.exalttech.trex.ui.views.models.AssignedProfile in project trex-stateless-gui by cisco-system-traffic-generator.

the class MainViewController method assignProfile.

/**
 * Assign profile to selected port
 *
 * @param profileName
 */
private void assignProfile(String profileName, double currentBandwidth, boolean assignPrevBandwidth, int portID) {
    try {
        // update selected profile
        AssignedProfile assignedProf = assignedPortProfileMap.get(portID);
        if (assignedProf == null) {
            return;
        }
        assignedProf.setProfileName(profileName);
        assignedProf.setAllStreamsWithLatency(allStreamWithLatency);
        PortModel port = PortsManager.getInstance().getPortModel(portID);
        String portState = port.getPortStatus();
        StreamValidation streamValidationGraph = serverRPCMethods.assignTrafficProfile(portID, loadedProfiles);
        portManager.getPortModel(portID).setStreamLoaded(true);
        startStream.setDisable(false);
        // update current multiplier data
        assignedProf.setRate(streamValidationGraph.getResult().getRate());
        multiplierView.assignNewProfile(assignedProf);
        // update multiplier value according to previous bandwidth value
        if (assignPrevBandwidth) {
            multiplierView.setSliderValue(currentBandwidth);
        }
        updateMultiplierValues(assignedProf);
        if (portState.equalsIgnoreCase("tx")) {
            startTraffic(portID);
        }
    } catch (IOException | InvalidRPCResponseException | IncorrectRPCMethodException ex) {
        startStream.setDisable(true);
        portManager.getPortModel(portID).setStreamLoaded(false);
        LOG.error("Failed to load Stream", ex);
    } catch (Exception ex) {
        java.util.logging.Logger.getLogger(MainViewController.class.getName()).log(Level.SEVERE, null, ex);
    } finally {
        portManager.updatedPorts(Arrays.asList(portID));
    }
}
Also used : AssignedProfile(com.exalttech.trex.ui.views.models.AssignedProfile) PortModel(com.exalttech.trex.ui.models.PortModel) IOException(java.io.IOException) StreamValidation(com.exalttech.trex.remote.models.validate.StreamValidation) IncorrectRPCMethodException(com.exalttech.trex.remote.exceptions.IncorrectRPCMethodException) InvalidRPCResponseException(com.exalttech.trex.remote.exceptions.InvalidRPCResponseException) TrafficException(com.exalttech.trex.remote.exceptions.TrafficException) UnsupportedEncodingException(java.io.UnsupportedEncodingException) InvalidRPCResponseException(com.exalttech.trex.remote.exceptions.InvalidRPCResponseException) IncorrectRPCMethodException(com.exalttech.trex.remote.exceptions.IncorrectRPCMethodException) PortAcquireException(com.exalttech.trex.remote.exceptions.PortAcquireException) IOException(java.io.IOException)

Aggregations

AssignedProfile (com.exalttech.trex.ui.views.models.AssignedProfile)9 TrafficException (com.exalttech.trex.remote.exceptions.TrafficException)5 IncorrectRPCMethodException (com.exalttech.trex.remote.exceptions.IncorrectRPCMethodException)2 InvalidRPCResponseException (com.exalttech.trex.remote.exceptions.InvalidRPCResponseException)2 PortAcquireException (com.exalttech.trex.remote.exceptions.PortAcquireException)2 IOException (java.io.IOException)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)2 TRexClient (com.cisco.trex.stateless.TRexClient)1 StreamValidation (com.exalttech.trex.remote.models.validate.StreamValidation)1 PortState (com.exalttech.trex.ui.PortState)1 Port (com.exalttech.trex.ui.models.Port)1 PortModel (com.exalttech.trex.ui.models.PortModel)1 Task (javafx.concurrent.Task)1