001package jmri.jmrix.lenz.messageformatters;
002
003import jmri.jmrix.Message;
004import jmri.jmrix.lenz.XNetConstants;
005import jmri.jmrix.lenz.XNetReply;
006import jmri.jmrix.lenz.XPressNetMessageFormatter;
007/**
008 * Format replies for XPressNet Command Station reply for Loco Info MU Address.
009 *
010 * @author Paul Bender Copyright (C) 2025
011 */
012public class XNetLocoInfoMUAddressFormatter implements XPressNetMessageFormatter {
013
014    @Override
015    public boolean handlesMessage(Message m) {
016        return m instanceof XNetReply &&
017                m.getElement(0) == XNetConstants.LOCO_INFO_MU_ADDRESS;
018    }
019
020    @Override
021    public String formatMessage(Message m) {
022        if (!handlesMessage(m)) {
023            throw new IllegalArgumentException("Message is not supported");
024        }
025        return Bundle.getMessage("XNetReplyLocoMUBaseLabel") + "," +
026            XNetLocoInfoReplyUtilities.parseSpeedAndDirection(m.getElement(1), m.getElement(2)) + " ";
027
028    }
029
030}