001package jmri.jmrix.loconet.sdf;
002
003/**
004 * Implement the END_SOUND macro from the Digitrax sound definition language.
005 *
006 * This carries no additional information.
007 *
008 * @author Bob Jacobsen Copyright (C) 2007
009 */
010public class EndSound extends SdfMacro {
011
012    public EndSound(int byte1, int byte2) {
013        this.byte1 = byte1;
014        this.byte2 = byte2;
015    }
016
017    int byte1, byte2;
018
019    @Override
020    public String name() {
021        return "END_SOUND"; // NOI18N
022    }
023
024    @Override
025    public int length() {
026        return 2;
027    }
028
029    static public SdfMacro match(SdfBuffer buff) {
030        if ((buff.getAtIndex() & 0xFF) != 0x00) {
031            return null;
032        }
033        int byte1 = buff.getAtIndexAndInc();
034        int byte2 = buff.getAtIndexAndInc(); // skip bytes
035        return new EndSound(byte1, byte2);
036    }
037
038    /**
039     * Store into a buffer.
040     */
041    @Override
042    public void loadByteArray(SdfBuffer buffer) {
043        // data
044        buffer.setAtIndexAndInc(byte1);
045        buffer.setAtIndexAndInc(byte2);
046
047        // store children
048        super.loadByteArray(buffer);
049    }
050
051    @Override
052    public String toString() {
053        return "End Sequence\n"; // NOI18N
054    }
055
056    @Override
057    public String oneInstructionString() {
058        return name() + '\n';
059    }
060
061    @Override
062    public String allInstructionString(String indent) {
063        return indent + oneInstructionString();
064    }
065}