Search in sources :

Example 1 with AddressedProgrammerManager

use of jmri.AddressedProgrammerManager in project JMRI by JMRI.

the class RosterFrame method updateProgrammerStatus.

/*
     * Handle setting up and updating the GUI for the types of progDebugger
     * available.
     */
protected void updateProgrammerStatus() {
    log.debug("Updating Programmer Status");
    ConnectionConfig oldServMode = serModeProCon;
    ConnectionConfig oldOpsMode = opsModeProCon;
    // Find the connection that goes with the global programmer
    GlobalProgrammerManager gpm = InstanceManager.getNullableDefault(GlobalProgrammerManager.class);
    if (gpm != null) {
        String serviceModeProgrammerName = gpm.getUserName();
        log.debug("GlobalProgrammerManager found of class {} name {} ", gpm.getClass(), serviceModeProgrammerName);
        for (ConnectionConfig connection : InstanceManager.getDefault(ConnectionConfigManager.class)) {
            log.debug("Checking connection name {}", connection.getConnectionName());
            if (connection.getConnectionName() != null && connection.getConnectionName().equals(serviceModeProgrammerName)) {
                log.debug("Connection found for GlobalProgrammermanager");
                serModeProCon = connection;
            }
        }
    }
    // Find the connection that goes with the addressed programmer
    AddressedProgrammerManager apm = InstanceManager.getNullableDefault(AddressedProgrammerManager.class);
    if (apm != null) {
        String opsModeProgrammerName = apm.getUserName();
        log.debug("AddressedProgrammerManager found of class {} name {} ", apm.getClass(), opsModeProgrammerName);
        for (ConnectionConfig connection : InstanceManager.getDefault(ConnectionConfigManager.class)) {
            log.debug("Checking connection name {}", connection.getConnectionName());
            if (connection.getConnectionName() != null && connection.getConnectionName().equals(opsModeProgrammerName)) {
                log.debug("Connection found for AddressedProgrammermanager");
                opsModeProCon = connection;
            }
        }
    }
    if (serModeProCon != null && gpm.isGlobalProgrammerAvailable()) {
        if (ConnectionStatus.instance().isConnectionOk(serModeProCon.getConnectionName(), serModeProCon.getInfo())) {
            log.debug("GPM Connection online");
            serviceModeProgrammerLabel.setText(Bundle.getMessage("ServiceModeProgOnline", serModeProCon.getConnectionName()));
            serviceModeProgrammerLabel.setForeground(new Color(0, 128, 0));
        } else {
            log.debug("GPM Connection onffline");
            serviceModeProgrammerLabel.setText(Bundle.getMessage("ServiceModeProgOffline", serModeProCon.getConnectionName()));
            serviceModeProgrammerLabel.setForeground(Color.red);
        }
        if (oldServMode == null) {
            contextService.setEnabled(true);
            contextService.setVisible(true);
            service.setEnabled(true);
            service.setVisible(true);
            firePropertyChange("setprogservice", "setEnabled", true);
        }
    } else if (gpm != null && gpm.isGlobalProgrammerAvailable()) {
        if (ConnectionStatus.instance().isSystemOk(gpm.getUserName())) {
            log.debug("GPM Connection online");
            serviceModeProgrammerLabel.setText(Bundle.getMessage("ServiceModeProgOnline", gpm.getUserName()));
            serviceModeProgrammerLabel.setForeground(new Color(0, 128, 0));
        } else {
            log.debug("GPM Connection onffline");
            serviceModeProgrammerLabel.setText(Bundle.getMessage("ServiceModeProgOffline", gpm.getUserName()));
            serviceModeProgrammerLabel.setForeground(Color.red);
        }
        if (oldServMode == null) {
            contextService.setEnabled(true);
            contextService.setVisible(true);
            service.setEnabled(true);
            service.setVisible(true);
            firePropertyChange("setprogservice", "setEnabled", true);
        }
    } else {
        // No service programmer available, disable interface sections not available
        serviceModeProgrammerLabel.setText(Bundle.getMessage("NoServiceProgrammerAvailable"));
        serviceModeProgrammerLabel.setForeground(Color.red);
        if (oldServMode != null) {
            contextService.setEnabled(false);
            contextService.setVisible(false);
            service.setEnabled(false);
            service.setVisible(false);
            firePropertyChange("setprogservice", "setEnabled", false);
        }
        // Disable Identify in toolBar
        // This relies on it being the 2nd item in the tool bar, as defined in xml//config/parts/jmri/jmrit/roster/swing/RosterFrameToolBar.xml
        // Because of I18N, we don't look for a particular Action name here
        getToolBar().getComponents()[1].setEnabled(false);
    }
    if (opsModeProCon != null && apm.isAddressedModePossible()) {
        if (ConnectionStatus.instance().isConnectionOk(opsModeProCon.getConnectionName(), opsModeProCon.getInfo())) {
            log.debug("Ops Mode Connection online");
            operationsModeProgrammerLabel.setText(Bundle.getMessage("OpsModeProgOnline", opsModeProCon.getConnectionName()));
            operationsModeProgrammerLabel.setForeground(new Color(0, 128, 0));
        } else {
            log.debug("Ops Mode Connection offline");
            operationsModeProgrammerLabel.setText(Bundle.getMessage("OpsModeProgOffline", opsModeProCon.getConnectionName()));
            operationsModeProgrammerLabel.setForeground(Color.red);
        }
        if (oldOpsMode == null) {
            contextOps.setEnabled(true);
            contextOps.setVisible(true);
            ops.setEnabled(true);
            ops.setVisible(true);
            firePropertyChange("setprogops", "setEnabled", true);
        }
    } else if (apm != null && apm.isAddressedModePossible()) {
        if (ConnectionStatus.instance().isSystemOk(apm.getUserName())) {
            log.debug("Ops Mode Connection online");
            operationsModeProgrammerLabel.setText(Bundle.getMessage("OpsModeProgOnline", apm.getUserName()));
            operationsModeProgrammerLabel.setForeground(new Color(0, 128, 0));
        } else {
            log.debug("Ops Mode Connection offline");
            operationsModeProgrammerLabel.setText(Bundle.getMessage("OpsModeProgOffline", apm.getUserName()));
            operationsModeProgrammerLabel.setForeground(Color.red);
        }
        if (oldOpsMode == null) {
            contextOps.setEnabled(true);
            contextOps.setVisible(true);
            ops.setEnabled(true);
            ops.setVisible(true);
            firePropertyChange("setprogops", "setEnabled", true);
        }
    } else {
        operationsModeProgrammerLabel.setText(Bundle.getMessage("NoOpsProgrammerAvailable"));
        operationsModeProgrammerLabel.setForeground(Color.red);
        if (oldOpsMode != null) {
            contextOps.setEnabled(false);
            contextOps.setVisible(false);
            ops.setEnabled(false);
            ops.setVisible(false);
            firePropertyChange("setprogops", "setEnabled", false);
        }
    }
    String strProgMode;
    if (service.isEnabled()) {
        contextService.setSelected(true);
        service.setSelected(true);
        strProgMode = "setprogservice";
        modePanel.setVisible(true);
    } else if (ops.isEnabled()) {
        contextOps.setSelected(true);
        ops.setSelected(true);
        strProgMode = "setprogops";
        modePanel.setVisible(false);
    } else {
        contextEdit.setSelected(true);
        edit.setSelected(true);
        modePanel.setVisible(false);
        strProgMode = "setprogedit";
    }
    firePropertyChange(strProgMode, "setSelected", true);
}
Also used : Color(java.awt.Color) AddressedProgrammerManager(jmri.AddressedProgrammerManager) ConnectionConfig(jmri.jmrix.ConnectionConfig) GlobalProgrammerManager(jmri.GlobalProgrammerManager)

Example 2 with AddressedProgrammerManager

use of jmri.AddressedProgrammerManager in project JMRI by JMRI.

the class ProgOpsModePane method getProgrammer.

/**
     * Get the selected programmer
     */
@Override
public Programmer getProgrammer() {
    log.debug("getProgrammer mLongAddrCheck.isSelected()={}, oldLongAddr={}, mAddrField.getValue()={}, oldAddrValue={}, opsAccyMode={}, oldOpsAccyMode={})", longAddrButton.isSelected(), oldLongAddr, mAddrField.getValue(), oldAddrValue, opsAccyMode, oldOpsAccyMode);
    if ((longAddrButton.isSelected() == oldLongAddr) && mAddrField.getValue().equals(oldAddrValue) && opsAccyMode == oldOpsAccyMode) {
        log.debug("getProgrammer hasn't changed");
        // hasn't changed
        if (opsAccyMode) {
            return facadeProgrammer;
        } else {
            return programmer;
        }
    }
    // here values have changed, try to create a new one
    AddressedProgrammerManager pm = ((AddressedProgrammerManager) progBox.getSelectedItem());
    oldLongAddr = longAddrButton.isSelected();
    oldAddrValue = (Integer) mAddrField.getValue();
    oldOpsAccyMode = opsAccyMode;
    setAddrParams();
    if (pm != null) {
        int address = 3;
        try {
            address = (Integer) mAddrField.getValue();
        } catch (java.lang.NumberFormatException e) {
            log.error("loco address \"{}\" not correct", mAddrField.getValue());
            programmer = null;
        }
        boolean longAddr = longAddrButton.isSelected();
        log.debug("ops programmer for address " + address + ", long address " + longAddr);
        programmer = pm.getAddressedProgrammer(longAddr, address);
        log.debug("   programmer: {}", programmer);
        // whole point is to get mode...
        setProgrammerFromGui(programmer);
    } else {
        log.warn("request for ops mode programmer with no ProgrammerManager configured");
        programmer = null;
    }
    if (opsAccyMode) {
        log.debug("   getting AccessoryOpsModeProgrammerFacade");
        facadeProgrammer = new AccessoryOpsModeProgrammerFacade(programmer, longAddrButton.isSelected() ? "accessory" : "decoder");
        return facadeProgrammer;
    }
    return programmer;
}
Also used : AddressedProgrammerManager(jmri.AddressedProgrammerManager) AccessoryOpsModeProgrammerFacade(jmri.implementation.AccessoryOpsModeProgrammerFacade)

Example 3 with AddressedProgrammerManager

use of jmri.AddressedProgrammerManager in project JMRI by JMRI.

the class DeferringProgrammerManager method releaseAddressedProgrammer.

@Override
public void releaseAddressedProgrammer(AddressedProgrammer p) {
    AddressedProgrammerManager ap = InstanceManager.getNullableDefault(AddressedProgrammerManager.class);
    if (ap == null) {
        return;
    }
    ap.releaseAddressedProgrammer(p);
}
Also used : AddressedProgrammerManager(jmri.AddressedProgrammerManager)

Aggregations

AddressedProgrammerManager (jmri.AddressedProgrammerManager)3 Color (java.awt.Color)1 GlobalProgrammerManager (jmri.GlobalProgrammerManager)1 AccessoryOpsModeProgrammerFacade (jmri.implementation.AccessoryOpsModeProgrammerFacade)1 ConnectionConfig (jmri.jmrix.ConnectionConfig)1