001package jmri.jmrix.loconet.uhlenbrock;
002
003import jmri.jmrit.roster.RosterEntry;
004import jmri.jmrit.decoderdefn.DecoderFile;
005
006/**
007 * A class to hold LocoNet LNCV device identity information.
008 * See jmri.jmrix.loconet.lnsvf2.Sv2DiscoverPane
009 *
010 * @author B. Milhaupt 2020
011 * @author Egbert Broerse 2020
012 */
013public class LncvDevice {
014    private int deviceAddress; // Module address in reply, value of -1 is ignored, LNCV default address : 1
015    private final int artNum; // used as LNCV ProductID, must be int to pass as part of CV "art.cv", usually 4 digits
016    private String deviceName;
017    private String rosterEntryName;
018    private int swVersion;
019    private RosterEntry rosterEntry;
020    private DecoderFile decoderFile;
021    private int cvNum;
022    private int cvValue;
023
024    public LncvDevice(int productID, int address, int lastCv, int lastVal, String deviceName, String rosterName, int swVersion) {
025        this.artNum = productID;
026        this.deviceAddress = address;
027        cvNum = lastCv;
028        cvValue = lastVal;
029        this.deviceName = deviceName;
030        this.rosterEntryName = rosterName;
031        this.swVersion = swVersion;
032    }
033
034    public int getProductID() {return artNum;}
035    public int getDestAddr() {return deviceAddress;}
036    public String getDeviceName() {return deviceName;}
037    public String getRosterName() {return rosterEntryName;}
038    public int getSwVersion() {return swVersion;}
039
040    /**
041     * Set the table view of the device's destination address.
042     * This routine does _not_ program the device's destination address.
043     *
044     * @param destAddr device destination address
045     */
046    public void setDestAddr(int destAddr) {this.deviceAddress = destAddr;}
047    public void setDevName(String s) {deviceName = s;}
048    public void setRosterName(String s) {rosterEntryName = s;}
049    public void setSwVersion(int version) {swVersion = version;}
050    public DecoderFile getDecoderFile() {
051        return decoderFile;
052    }
053    public void setDecoderFile(DecoderFile f) {
054        decoderFile = f;
055    }
056
057    public RosterEntry getRosterEntry() {
058        return rosterEntry;
059    }
060    public void setRosterEntry(RosterEntry e) {
061        rosterEntry = e;
062        setRosterName(e.getId()); // is a name (String)
063    }
064
065    // optional: remember last used CV
066    public int getCvNum() {
067        return cvNum;
068    }
069    public void setCvNum(int num) {
070        cvNum = num;
071    }
072    public int getCvValue() {
073        return cvValue;
074    }
075    public void setCvValue(int val) {
076        cvValue = val;
077    }
078
079    //private final static Logger log = LoggerFactory.getLogger(LncvDevice.class);
080
081}