Search in sources :

Example 56 with SuppressFBWarnings

use of edu.umd.cs.findbugs.annotations.SuppressFBWarnings in project JMRI by JMRI.

the class SimDriverAdapter method configure.

/**
     * set up all of the other objects to operate connected to this port
     */
@SuppressFBWarnings(value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD", justification = "Access to 'self' OK until multiple instance pattern installed")
@Override
public void configure() {
    // install a traffic controller that doesn't time out
    SerialTrafficController tc = new SerialTrafficController() {

        // timeout doesn't do anything
        @SuppressFBWarnings(value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD", justification = "only until multi-connect update done")
        @Override
        protected void handleTimeout(jmri.jmrix.AbstractMRMessage m, jmri.jmrix.AbstractMRListener l) {
        }
    };
    // connect to the traffic controller
    tc.connectPort(this);
    ((CMRISystemConnectionMemo) getSystemConnectionMemo()).setTrafficController(tc);
    ((CMRISystemConnectionMemo) getSystemConnectionMemo()).configureManagers();
}
Also used : SerialTrafficController(jmri.jmrix.cmri.serial.SerialTrafficController) CMRISystemConnectionMemo(jmri.jmrix.cmri.CMRISystemConnectionMemo) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 57 with SuppressFBWarnings

use of edu.umd.cs.findbugs.annotations.SuppressFBWarnings in project JMRI by JMRI.

the class StackMonFrame method requestFunctionStatus.

/*
     * Request the momentary/continuous status of functions for the 
     * current address.
     */
@SuppressWarnings("unused")
@SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", justification = "This is part of work in progress code to allow display of all information about the locomotives in the stack.")
private void requestFunctionStatus() {
    int address = 0;
    if (!adrTextField.getText().equals("")) {
        address = Integer.parseInt(adrTextField.getText());
        XNetMessage msg = XNetMessage.getLocomotiveFunctionStatusMsg(address);
        tc.sendXNetMessage(msg, this);
    }
}
Also used : XNetMessage(jmri.jmrix.lenz.XNetMessage) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 58 with SuppressFBWarnings

use of edu.umd.cs.findbugs.annotations.SuppressFBWarnings in project JMRI by JMRI.

the class StackMonFrame method requestStatus.

/*
     * Request the status of the current address
     */
@SuppressWarnings("unused")
@SuppressFBWarnings(value = "UPM_UNCALLED_PRIVATE_METHOD", justification = "This is part of work in progress code to allow display of all information about the locomotives in the stack.")
private void requestStatus() {
    int address = 0;
    if (!adrTextField.getText().equals("")) {
        address = Integer.parseInt(adrTextField.getText());
        XNetMessage msg = XNetMessage.getLocomotiveInfoRequestMsg(address);
        tc.sendXNetMessage(msg, this);
    }
}
Also used : XNetMessage(jmri.jmrix.lenz.XNetMessage) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 59 with SuppressFBWarnings

use of edu.umd.cs.findbugs.annotations.SuppressFBWarnings in project JMRI by JMRI.

the class Z21TrafficController method handleOneIncomingReply.

/**
     * Handle each reply when complete.
     * <P>
     * (This is public for testing purposes) Runs in the "Receive" thread.
     */
@SuppressFBWarnings(value = { "UW_UNCOND_WAIT", "WA_NOT_IN_LOOP", "NO_NOTIFY_NOT_NOTIFYALL" }, justification = "Wait is for external hardware, which doesn't necessarilly respond, to process the data.  Notify is used because Having more than one thread waiting on xmtRunnable is an error.")
@Override
public void handleOneIncomingReply() throws java.io.IOException {
    // we sit in this until the message is complete, relying on
    // threading to let other stuff happen
    // create a buffer to hold the incoming data.
    // the size here just needs to be longer
    byte[] buffer = new byte[100];
    // than the longest protocol message.  
    // Otherwise, the receive will truncate.
    // create the packet.
    DatagramPacket receivePacket = new DatagramPacket(buffer, 100, host, port);
    // and wait to receive data in the packet.
    try {
        ((Z21Adapter) controller).getSocket().receive(receivePacket);
    } catch (java.net.SocketException | NullPointerException se) {
        // if we are waiting when the controller is disposed,
        // a socket exception will be thrown.
        log.debug("Socket exception during receive.  Connection Closed?");
        rcvException = true;
        return;
    }
    // create the reply from the received data.
    Z21Reply msg = new Z21Reply(buffer, receivePacket.getLength());
    // message is complete, dispatch it !!
    replyInDispatch = true;
    if (log.isDebugEnabled()) {
        log.debug("dispatch reply of length " + msg.getNumDataElements() + " contains " + msg.toString() + " state " + mCurrentState);
    }
    // forward the message to the registered recipients,
    // which includes the communications monitor
    // return a notification via the Swing event queue to ensure proper thread
    Runnable r = new RcvNotifier(msg, mLastSender, this);
    try {
        javax.swing.SwingUtilities.invokeAndWait(r);
    } catch (Exception e) {
        log.error("Unexpected exception in invokeAndWait:" + e);
        e.printStackTrace();
    }
    if (log.isDebugEnabled()) {
        log.debug("dispatch thread invoked");
    }
    if (!msg.isUnsolicited()) {
        // effect on transmit:
        switch(mCurrentState) {
            case WAITMSGREPLYSTATE:
                {
                    // message, otherwise go on to the next message
                    if (msg.isRetransmittableErrorMsg()) {
                        if (log.isDebugEnabled()) {
                            log.debug("Automatic Recovery from Error Message: +msg.toString()");
                        }
                        synchronized (xmtRunnable) {
                            mCurrentState = AUTORETRYSTATE;
                            replyInDispatch = false;
                            xmtRunnable.notify();
                        }
                    } else {
                        // update state, and notify to continue
                        synchronized (xmtRunnable) {
                            mCurrentState = NOTIFIEDSTATE;
                            replyInDispatch = false;
                            xmtRunnable.notify();
                        }
                    }
                    break;
                }
            case WAITREPLYINPROGMODESTATE:
                {
                    // entering programming mode
                    mCurrentMode = PROGRAMINGMODE;
                    replyInDispatch = false;
                    // check to see if we need to delay to allow decoders to become
                    // responsive
                    int warmUpDelay = enterProgModeDelayTime();
                    if (warmUpDelay != 0) {
                        try {
                            synchronized (xmtRunnable) {
                                xmtRunnable.wait(warmUpDelay);
                            }
                        } catch (InterruptedException e) {
                            // retain if needed later
                            Thread.currentThread().interrupt();
                        }
                    }
                    // update state, and notify to continue
                    synchronized (xmtRunnable) {
                        mCurrentState = OKSENDMSGSTATE;
                        xmtRunnable.notify();
                    }
                    break;
                }
            case WAITREPLYINNORMMODESTATE:
                {
                    // entering normal mode
                    mCurrentMode = NORMALMODE;
                    replyInDispatch = false;
                    // update state, and notify to continue
                    synchronized (xmtRunnable) {
                        mCurrentState = OKSENDMSGSTATE;
                        xmtRunnable.notify();
                    }
                    break;
                }
            default:
                {
                    replyInDispatch = false;
                    if (allowUnexpectedReply == true) {
                        if (log.isDebugEnabled()) {
                            log.debug("Allowed unexpected reply received in state: " + mCurrentState + " was " + msg.toString());
                        }
                        synchronized (xmtRunnable) {
                            // The transmit thread sometimes gets stuck
                            // when unexpected replies are received.  Notify
                            // it to clear the block without a timeout.
                            // (do not change the current state)
                            //if(mCurrentState!=IDLESTATE)
                            xmtRunnable.notify();
                        }
                    } else {
                        log.error("reply complete in unexpected state: " + mCurrentState + " was " + msg.toString());
                    }
                }
        }
    // Unsolicited message
    } else {
        if (log.isDebugEnabled()) {
            log.debug("Unsolicited Message Received " + msg.toString());
        }
        replyInDispatch = false;
    }
}
Also used : DatagramPacket(java.net.DatagramPacket) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Example 60 with SuppressFBWarnings

use of edu.umd.cs.findbugs.annotations.SuppressFBWarnings in project JMRI by JMRI.

the class Apps3 method setButtonSpace.

/**
     * For compatability with adding in buttons to the toolbar using the
     * existing createbuttonmodel
     */
@SuppressFBWarnings(value = "ST_WRITE_TO_STATIC_FROM_INSTANCE_METHOD", justification = "only one application at a time")
protected static void setButtonSpace() {
    _buttonSpace = new JPanel();
    _buttonSpace.setLayout(new FlowLayout(FlowLayout.LEFT));
}
Also used : JPanel(javax.swing.JPanel) FlowLayout(java.awt.FlowLayout) SuppressFBWarnings(edu.umd.cs.findbugs.annotations.SuppressFBWarnings)

Aggregations

SuppressFBWarnings (edu.umd.cs.findbugs.annotations.SuppressFBWarnings)169 ArrayList (java.util.ArrayList)29 PreparedStatement (java.sql.PreparedStatement)27 File (java.io.File)24 IOException (java.io.IOException)24 SQLException (java.sql.SQLException)22 Connection (java.sql.Connection)21 APIMgtDAOException (org.wso2.carbon.apimgt.core.exception.APIMgtDAOException)21 JPanel (javax.swing.JPanel)14 RollingStock (jmri.jmrit.operations.rollingstock.RollingStock)13 ScriptException (org.jaggeryjs.scriptengine.exceptions.ScriptException)13 ResultSet (java.sql.ResultSet)12 HashMap (java.util.HashMap)12 Map (java.util.Map)10 FlowLayout (java.awt.FlowLayout)8 BoxLayout (javax.swing.BoxLayout)7 Dimension (java.awt.Dimension)5 FileOutputStream (java.io.FileOutputStream)5 Iterator (java.util.Iterator)5 List (java.util.List)5