001package jmri;
002
003import java.util.EventListener;
004
005/**
006 * Allow notification of delayed consisting errors.
007 * <p>
008 * This allows a {@link Consist} object to return delayed status.
009 *
010 * <hr>
011 * This file is part of JMRI.
012 * <p>
013 * JMRI is free software; you can redistribute it and/or modify it under the
014 * terms of version 2 of the GNU General Public License as published by the Free
015 * Software Foundation. See the "COPYING" file for a copy of this license.
016 * <p>
017 * JMRI is distributed in the hope that it will be useful, but WITHOUT ANY
018 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR
019 * A PARTICULAR PURPOSE. See the GNU General Public License for more details.
020 *
021 * @author Paul Bender Copyright (C) 2004
022 */
023public interface ConsistListener extends EventListener {
024
025    /**
026     * Receive notification at the end of a consisting operation.
027     *
028     * @param locoaddress Address of specific locomotive involved, if error is
029     *                    locomotive specific.
030     * @param status      Denotes the completion code. Note that this is a
031     *                    bitwise combination of the various status coded
032     *                    defined in this interface.
033     */
034    public void consistReply(LocoAddress locoaddress, int status);
035    /**
036     * Constant denoting that the request completed correctly. Note this is a
037     * specific value; all others are bitwise combinations
038     */
039    public final int OK = 0;
040    /**
041     * Constant denoting that the request failed because it requested some
042     * unimplemented capability. Note that this can also result in an exception
043     * during the original request; which happens is implementation dependent
044     */
045    public final int NotImplemented = 0x01;
046    /**
047     * the Operation Completed successfully.
048     */
049    public final int OPERATION_SUCCESS = 0x02;
050    /**
051     * An Error Occurred.
052     */
053    public final int CONSIST_ERROR = 0x04;
054    /**
055     * All of the slots available for the consist are full Note: This may not be
056     * an error. If the last locomotive added to the consist caused the number
057     * of units in the consist to equal the size limit, the value returned to
058     * the listeners should be OPERATION_SUCCESS | CONSIST_FULL. To indicate an
059     * error, send CONSIST_ERROR | CONSIST_FULL, and to send an information
060     * message, just send CONSIST_FULL
061     */
062    public final int CONSIST_FULL = 0x08;
063    /**
064     * The requested locomotive has not been operated by this device, or is
065     * currently being operated by another device
066     */
067    public final int LOCO_NOT_OPERATED = 0x10;
068    /**
069     * An add request is not valid for this address because the locomotive is
070     * already in a consist.
071     */
072    public final int ALREADY_CONSISTED = 0x20;
073    /**
074     * A remove request is not valid for this address because the locomotive is
075     * not in a consist.
076     */
077    public final int NOT_CONSISTED = 0x40;
078    /**
079     * The operation is not valid because the locomotive's speed is not zero.
080     */
081    public final int NONZERO_SPEED = 0x80;
082    /**
083     * The operation is not valid because the specified address is not a consist
084     * base address
085     */
086    public final int NOT_CONSIST_ADDR = 0x100;
087    /**
088     * The operation failed because it is not possible to delete the locomotive
089     */
090    public final int DELETE_ERROR = 0x200;
091    /**
092     * The operation failed because the command station stack is full
093     */
094    public final int STACK_FULL = 0x400;
095}