Search in sources :

Example 1 with PortModel

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

the class MainViewController method loadPortModel.

/**
     * Build port detail table
     */
private void loadPortModel() {
    PortModel model = portManager.getPortModel(getSelectedPortIndex());
    portManager.updatedPorts(Arrays.asList(getSelectedPortIndex()));
    Optional<Integer> optional = portManager.getOwnedPortIndexes().stream().filter(idx -> idx.equals(getSelectedPortIndex())).findFirst();
    optional.ifPresent(val -> model.setIsOwned(true));
    portView.loadModel(model);
}
Also used : EventHandler(javafx.event.EventHandler) JsonObject(com.google.gson.JsonObject) Initializable(javafx.fxml.Initializable) javafx.scene.control(javafx.scene.control) URL(java.net.URL) AsyncResponseManager(com.exalttech.trex.core.AsyncResponseManager) CountdownService(com.exalttech.trex.ui.views.services.CountdownService) LogType(com.exalttech.trex.ui.views.logs.LogType) TrexApp(com.exalttech.trex.application.TrexApp) TrafficException(com.exalttech.trex.remote.exceptions.TrafficException) Logger(org.apache.log4j.Logger) Task(javafx.concurrent.Task) PortModel(com.exalttech.trex.ui.models.PortModel) com.exalttech.trex.ui.views(com.exalttech.trex.ui.views) Gson(com.google.gson.Gson) WindowEvent(javafx.stage.WindowEvent) Pane(javafx.scene.layout.Pane) Profile(com.exalttech.trex.remote.models.profiles.Profile) StatsTableGenerator(com.exalttech.trex.ui.views.statistics.StatsTableGenerator) PortView(com.exalttech.trex.ui.controllers.ports.PortView) PortState(com.exalttech.trex.ui.PortState) Util(com.exalttech.trex.util.Util) ProfileManager(com.exalttech.trex.util.ProfileManager) DialogManager(com.exalttech.trex.ui.dialog.DialogManager) Platform(javafx.application.Platform) FXML(javafx.fxml.FXML) SystemInfoReq(com.exalttech.trex.ui.models.SystemInfoReq) JsonArray(com.google.gson.JsonArray) BooleanProperty(javafx.beans.property.BooleanProperty) Duration(javafx.util.Duration) PortManagerEventHandler(com.exalttech.trex.ui.PortManagerEventHandler) AnchorPane(javafx.scene.layout.AnchorPane) Constants(com.exalttech.trex.util.Constants) StatsStorage(com.exalttech.trex.ui.views.storages.StatsStorage) WorkerStateEvent(javafx.concurrent.WorkerStateEvent) UnsupportedEncodingException(java.io.UnsupportedEncodingException) TreeItemType(com.exalttech.trex.ui.components.CustomTreeItem.TreeItemType) RefreshingService(com.exalttech.trex.ui.views.services.RefreshingService) java.util(java.util) Connection(com.exalttech.trex.ui.models.datastore.Connection) MultiplierType(com.exalttech.trex.ui.MultiplierType) ConnectionManager(com.exalttech.trex.core.ConnectionManager) TrexEvent(com.exalttech.trex.core.TrexEvent) NotificationPanel(com.exalttech.trex.ui.components.NotificationPanel) FXCollections(javafx.collections.FXCollections) Level(java.util.logging.Level) ProfileMultiplier(com.exalttech.trex.ui.views.models.ProfileMultiplier) EventBus(com.google.common.eventbus.EventBus) InvalidRPCResponseException(com.exalttech.trex.remote.exceptions.InvalidRPCResponseException) PortsManager(com.exalttech.trex.ui.PortsManager) Subscribe(com.google.common.eventbus.Subscribe) StreamValidation(com.exalttech.trex.remote.models.validate.StreamValidation) InitPacketEditorEvent(com.xored.javafx.packeteditor.events.InitPacketEditorEvent) LogsController(com.exalttech.trex.ui.views.logs.LogsController) TRexClient(com.cisco.trex.stateless.TRexClient) CustomTreeItem(com.exalttech.trex.ui.components.CustomTreeItem) ConnectionsWrapper(com.exalttech.trex.ui.models.datastore.ConnectionsWrapper) RPCMethods(com.exalttech.trex.core.RPCMethods) javafx.scene.input(javafx.scene.input) XMLFileManager(com.exalttech.trex.util.files.XMLFileManager) AssignedProfile(com.exalttech.trex.ui.views.models.AssignedProfile) IncorrectRPCMethodException(com.exalttech.trex.remote.exceptions.IncorrectRPCMethodException) PortAcquireException(com.exalttech.trex.remote.exceptions.PortAcquireException) ScapyClientNeedConnectEvent(com.xored.javafx.packeteditor.events.ScapyClientNeedConnectEvent) IOException(java.io.IOException) Port(com.exalttech.trex.ui.models.Port) File(java.io.File) StatsLoader(com.exalttech.trex.ui.views.statistics.StatsLoader) Consumer(java.util.function.Consumer) ActionEvent(javafx.event.ActionEvent) SimpleBooleanProperty(javafx.beans.property.SimpleBooleanProperty) ImageView(javafx.scene.image.ImageView) ObservableValue(javafx.beans.value.ObservableValue) ChangeListener(javafx.beans.value.ChangeListener) Image(javafx.scene.image.Image) DialogWindow(com.exalttech.trex.ui.dialog.DialogWindow) PortModel(com.exalttech.trex.ui.models.PortModel)

Example 2 with PortModel

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

the class MainViewController method initialize.

@Override
public void initialize(URL url, ResourceBundle rb) {
    portManager = PortsManager.getInstance();
    portManager.setPortManagerHandler(this);
    statsTableGenerator = new StatsTableGenerator();
    leftArrow = new Image("/icons/arrow_left.png");
    rightArrow = new Image("/icons/arrow_right.png");
    initializeInlineComponent();
    logsContainer.setDisable(false);
    eventBus = TrexApp.injector.getInstance(EventBus.class);
    portView.visibleProperty().bind(portViewVisibilityProperty);
    statTableContainer.visibleProperty().bindBidirectional(systemInfoVisibilityProperty);
    // Handle update port state event
    AsyncResponseManager.getInstance().asyncEventObjectProperty().addListener((observable, oldValue, newVal) -> {
        TrexEvent event = newVal;
        int portId = event.getData().getAsJsonPrimitive("port_id").getAsInt();
        PortModel portModel = portManager.getPortModel(portId);
        switch(event.getType()) {
            case PORT_RELEASED:
            case PORT_ACQUIRED:
            case PORT_ATTR_CHANGED:
            case PORT_STARTED:
            case PORT_STOPPED:
                if (ConnectionManager.getInstance().isConnected()) {
                    Platform.runLater(() -> {
                        portManager.updatedPorts(Arrays.asList(portModel.getIndex()));
                        onPortListUpdated(true);
                    });
                    boolean isAllPortsStopped = true;
                    for (final Port port : portManager.getPortList()) {
                        if (port.getIndex() == port.getIndex()) {
                            continue;
                        }
                        final String portStatus = port.getStatus();
                        if (portStatus.equals("TX") || portStatus.equals("PAUSE")) {
                            isAllPortsStopped = false;
                            break;
                        }
                    }
                }
                break;
            case SERVER_STOPPED:
                resetApplication(true);
                break;
        }
    });
}
Also used : TrexEvent(com.exalttech.trex.core.TrexEvent) PortModel(com.exalttech.trex.ui.models.PortModel) Port(com.exalttech.trex.ui.models.Port) StatsTableGenerator(com.exalttech.trex.ui.views.statistics.StatsTableGenerator) EventBus(com.google.common.eventbus.EventBus) Image(javafx.scene.image.Image)

Example 3 with PortModel

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

the class PortsManager method getPortModel.

public PortModel getPortModel(int portIndex) {
    PortModel model = portModels.get(portIndex);
    if (model == null) {
        model = PortModel.createModelFrom(portList.get(portIndex));
        portModels.put(portIndex, model);
    }
    return model;
}
Also used : PortModel(com.exalttech.trex.ui.models.PortModel)

Aggregations

PortModel (com.exalttech.trex.ui.models.PortModel)3 TrexEvent (com.exalttech.trex.core.TrexEvent)2 Port (com.exalttech.trex.ui.models.Port)2 StatsTableGenerator (com.exalttech.trex.ui.views.statistics.StatsTableGenerator)2 EventBus (com.google.common.eventbus.EventBus)2 Image (javafx.scene.image.Image)2 TRexClient (com.cisco.trex.stateless.TRexClient)1 TrexApp (com.exalttech.trex.application.TrexApp)1 AsyncResponseManager (com.exalttech.trex.core.AsyncResponseManager)1 ConnectionManager (com.exalttech.trex.core.ConnectionManager)1 RPCMethods (com.exalttech.trex.core.RPCMethods)1 IncorrectRPCMethodException (com.exalttech.trex.remote.exceptions.IncorrectRPCMethodException)1 InvalidRPCResponseException (com.exalttech.trex.remote.exceptions.InvalidRPCResponseException)1 PortAcquireException (com.exalttech.trex.remote.exceptions.PortAcquireException)1 TrafficException (com.exalttech.trex.remote.exceptions.TrafficException)1 Profile (com.exalttech.trex.remote.models.profiles.Profile)1 StreamValidation (com.exalttech.trex.remote.models.validate.StreamValidation)1 MultiplierType (com.exalttech.trex.ui.MultiplierType)1 PortManagerEventHandler (com.exalttech.trex.ui.PortManagerEventHandler)1 PortState (com.exalttech.trex.ui.PortState)1