001package jmri.jmrix.loconet.lnsvf1; 002 003import jmri.jmrit.decoderdefn.DecoderFile; 004import jmri.jmrit.roster.RosterEntry; 005 006//import org.slf4j.Logger; 007//import org.slf4j.LoggerFactory; 008 009/** 010 * A class to hold LocoNet LNSVf1 (LocoIO) device identity information. 011 * See jmri.jmrix.loconet.swing.lnsv1prog.Lnsv1ProgPane 012 * 013 * @author B. Milhaupt 2020 014 * @author Egbert Broerse 2020, 2025 015 */ 016public class Lnsv1Device { 017 private int deviceAddressLow; // Module address in reply, value of -1 is ignored, LNSV1 default address: 88 018 // High byte of the Address is fixed to 0x01 (not displayed as part of board address) 019 // valid deviceAddressLow (aka low byte "Address") is in the range of 0x01 .. 0x4F, 0x51 .. 0x7F 020 // (deviceAddressLow 0x50 is reserved for the LocoBuffer) 021 private int deviceAddressHi; 022 // valid deviceAddressHi (aka "subAddress") is in the range of 0x01 .. 0x7E (0x7F is reserved) 023 private final int deviceAddress; // required by symbolicProgrammer 024 private String deviceName; 025 private String rosterEntryName; 026 private int swVersion; 027 private RosterEntry rosterEntry; 028 private DecoderFile decoderFile; 029 private int cvNum; 030 private int cvValue; 031 032 public Lnsv1Device(int addressL, int addressH, int lastCv, int lastVal, String deviceName, String rosterName, int swVersion) { 033 this.deviceAddressLow = addressL; 034 // Low byte Address must be in the range of 0x01 .. 0x4F, 0x51 .. 0x7F 035 this.deviceAddressHi = addressH; 036 // The subAddress is in the range of 0x01 .. 0x7E (0x7F is reserved) 037 this.deviceAddress = 256 * (addressH - 1) + addressL; // equals: addressH << 7 + addressL 038 cvNum = lastCv; 039 cvValue = lastVal; 040 this.deviceName = deviceName; 041 this.rosterEntryName = rosterName; 042 this.swVersion = swVersion; 043 } 044 045 public int getDestAddr() {return deviceAddress;} 046 public int getDestAddrLow() {return deviceAddressLow;} 047 public int getDestAddrHigh() {return deviceAddressHi;} 048 public String getDeviceName() {return deviceName;} 049 public String getRosterName() {return rosterEntryName;} 050 public int getSwVersion() {return swVersion;} 051 052 /** 053 * Set the table view of the device's low and high address. 054 * This routine does _not_ program the device's destination address. 055 * 056 * @param destAddrL device low address 057 */ 058 public void setDestAddrLow(int destAddrL) {this.deviceAddressLow = destAddrL;} 059 public void setDestAddrHigh(int destAddrH) {this.deviceAddressHi = destAddrH;} 060 public void setDevName(String s) {deviceName = s;} 061 public void setRosterName(String s) {rosterEntryName = s;} 062 public void setSwVersion(int version) {swVersion = version;} 063 public DecoderFile getDecoderFile() { 064 return decoderFile; 065 } 066 public void setDecoderFile(DecoderFile f) { 067 decoderFile = f; 068 } 069 070 public RosterEntry getRosterEntry() { 071 return rosterEntry; 072 } 073 public void setRosterEntry(RosterEntry e) { 074 rosterEntry = e; 075 if (e == null) { 076 setRosterName(""); 077 } else { 078 setRosterName(e.getId()); // is a name (String) 079 } 080 } 081 082 // optional: remember last used CV 083 public int getCvNum() { 084 return cvNum; 085 } 086 public void setCvNum(int num) { 087 cvNum = num; 088 } 089 public int getCvValue() { 090 return cvValue; 091 } 092 public void setCvValue(int val) { 093 cvValue = val; 094 } 095 096 // private final static Logger log = LoggerFactory.getLogger(Lnsv1Device.class); 097 098}