001package jmri.jmrix.can.adapters.gridconnect.sproggen5.serialdriver.configurexml;
002
003import org.jdom2.Element;
004
005import jmri.jmrix.PortAdapter;
006import jmri.jmrix.can.adapters.gridconnect.sproggen5.serialdriver.*;
007import jmri.jmrix.configurexml.AbstractSerialConnectionConfigXml;
008
009/**
010 * Handle XML persistance of layout connections by persistening the
011 * SerialDriverAdapter (and connections). Note this is named as the XML version
012 * of a ConnectionConfig object, but it's actually persisting the
013 * SerialDriverAdapter.
014 * <p>
015 * This class is invoked from jmrix.JmrixConfigPaneXml on write, as that class
016 * is the one actually registered. Reads are brought here directly via the class
017 * attribute in the XML.
018 *
019 * @author Bob Jacobsen Copyright: Copyright (c) 2003
020 * @author Andrew Crosland Copyright (C) 2008, 2019, 2021
021 */
022public class PiSprog3v2ConnectionConfigXml extends AbstractSerialConnectionConfigXml {
023
024    public PiSprog3v2ConnectionConfigXml() {
025        super();
026    }
027
028    @Override
029    protected void getInstance() {
030        adapter = new PiSprog3v2SerialDriverAdapter();
031    }
032
033    @Override
034    protected void getInstance(Object object) {
035        adapter = ((PiSprog3v2ConnectionConfig) object).getAdapter();
036    }
037
038    @Override
039    protected void register() {
040        this.register(new PiSprog3v2ConnectionConfig(adapter));
041    }
042
043    @Override
044    protected void loadOptions(Element shared, Element perNode, PortAdapter adapter) {
045        super.loadOptions(shared, perNode, adapter);
046
047        jmri.jmrix.openlcb.configurexml.ConnectionConfigXml.maybeLoadOlcbProfileSettings(
048                shared.getParentElement(), perNode.getParentElement(), adapter);
049    }
050
051    @Override
052    protected void extendElement(Element e) {
053        jmri.jmrix.openlcb.configurexml.ConnectionConfigXml.maybeSaveOlcbProfileSettings(
054                e, adapter);
055    }
056}