001package jmri.jmrix.ipocs.protocol.packets; 002 003import java.nio.ByteBuffer; 004 005import jmri.jmrix.ipocs.protocol.enums.RqPointsLockState; 006 007/** 008 * Points Lock object status. 009 * 010 * @author Fredrik Elestedt Copyright (C) 2020 011 * @since 4.21.2 012 */ 013@org.openide.util.lookup.ServiceProvider(service = Packet.class) 014public class ElectricalPointsLockStatusPacket extends Packet { 015 public final static byte IDENT = 21; 016 private RqPointsLockState state = null; 017 018 @Override 019 public byte getId() { 020 return IDENT; 021 } 022 023 @Override 024 protected void parseSpecific(ByteBuffer buffer) { 025 state = RqPointsLockState.valueOf(buffer.get()); 026 } 027 028 @Override 029 protected byte[] serializeSpecific() { 030 ByteBuffer buffer = ByteBuffer.allocate(1); 031 buffer.put(state.value); 032 buffer.rewind(); 033 return buffer.array(); 034 } 035 036 public RqPointsLockState getState() { 037 return state; 038 } 039 040 public void setState(RqPointsLockState state) { 041 this.state = state; 042 } 043}