Search in sources :

Example 6 with ProgrammerException

use of jmri.ProgrammerException in project JMRI by JMRI.

the class ConsistController method setConsistCVs.

/**
     * set CV 21&22 for consist functions send each CV individually
     *
     * @param message RCF<;> locoAddress <:> CV# <;> value
     */
private void setConsistCVs(String message) {
    DccLocoAddress loco;
    List<String> headerAndCVs = Arrays.asList(message.split("<:>"));
    if (log.isDebugEnabled()) {
        log.debug("setConsistCVs string: " + message);
    }
    try {
        List<String> headerData = Arrays.asList(headerAndCVs.get(0).split("<;>"));
        loco = stringToDcc(headerData.get(1));
        if (checkForBroadcastAddress(loco)) {
            return;
        }
    } catch (NullPointerException e) {
        log.warn("setConsistCVs error for message: " + message);
        return;
    }
    AddressedProgrammer pom = jmri.InstanceManager.getDefault(jmri.ProgrammerManager.class).getAddressedProgrammer(loco.isLongAddress(), loco.getNumber());
    // loco done, now get CVs
    for (int i = 1; i < headerAndCVs.size(); i++) {
        List<String> CVData = Arrays.asList(headerAndCVs.get(i).split("<;>"));
        try {
            int CVNum = Integer.parseInt(CVData.get(0));
            int CVValue = Integer.parseInt(CVData.get(1));
            try {
                pom.writeCV(CVNum, CVValue, this);
            } catch (ProgrammerException e) {
            }
        } catch (NumberFormatException nfe) {
            log.warn("Error in setting CVs: " + nfe);
        }
    }
    jmri.InstanceManager.getDefault(jmri.ProgrammerManager.class).releaseAddressedProgrammer(pom);
}
Also used : ProgrammerException(jmri.ProgrammerException) AddressedProgrammer(jmri.AddressedProgrammer) DccLocoAddress(jmri.DccLocoAddress)

Example 7 with ProgrammerException

use of jmri.ProgrammerException in project JMRI by JMRI.

the class BoosterProgPanel method setStartPushed.

void setStartPushed() {
    getProgrammer();
    status.setText(rb.getString("StatusProgramming"));
    int val = Integer.parseInt(start.getText());
    try {
        p.writeCV(255, val, new ProgListener() {

            @Override
            public void programmingOpReply(int value, int retval) {
                status.setText(rb.getString("StatusOK"));
            }
        });
    } catch (ProgrammerException e) {
        status.setText(rb.getString("StatusError") + e);
    } finally {
        releaseProgrammer();
    }
}
Also used : ProgrammerException(jmri.ProgrammerException) ProgListener(jmri.ProgListener)

Example 8 with ProgrammerException

use of jmri.ProgrammerException in project JMRI by JMRI.

the class BoosterProgPanel method durationPart2.

void durationPart2() {
    status.setText(rb.getString("StatusProgramming"));
    int val = Integer.parseInt(length.getText()) % 256;
    try {
        p.writeCV(254, val, new ProgListener() {

            @Override
            public void programmingOpReply(int value, int retval) {
                status.setText(rb.getString("StatusOK"));
            }
        });
    } catch (ProgrammerException e) {
        status.setText(rb.getString("StatusError") + e);
    } finally {
        releaseProgrammer();
    }
}
Also used : ProgrammerException(jmri.ProgrammerException) ProgListener(jmri.ProgListener)

Example 9 with ProgrammerException

use of jmri.ProgrammerException in project JMRI by JMRI.

the class BoosterProgPanel method setDurationPushed.

void setDurationPushed() {
    getProgrammer();
    status.setText(rb.getString("StatusProgramming"));
    int val = Integer.parseInt(length.getText()) / 256;
    try {
        p.writeCV(253, val, new ProgListener() {

            @Override
            public void programmingOpReply(int value, int retval) {
                synchronized (this) {
                    try {
                        // needed for booster to reset
                        wait(1500);
                    } catch (InterruptedException i) {
                    }
                }
                durationPart2();
            }
        });
    } catch (ProgrammerException e) {
        status.setText(rb.getString("StatusError") + e);
        releaseProgrammer();
    }
}
Also used : ProgrammerException(jmri.ProgrammerException) ProgListener(jmri.ProgListener)

Aggregations

ProgrammerException (jmri.ProgrammerException)9 AddressedProgrammer (jmri.AddressedProgrammer)3 ProgListener (jmri.ProgListener)3 Programmer (jmri.Programmer)3 DccLocoAddress (jmri.DccLocoAddress)1