001package jmri.jmrix.roco.z21.simulator; 002 003/* 004 * This class stores some information for 005 * passing data between the Throttle and the Z21 006 * 007 * @author Paul Bender, Copyright (C) 2016 008 */ 009class Z21SimulatorLocoData { 010 011 byte address_msb; 012 byte address_lsb; 013 byte speed_byte; 014 015 /** 016 * Construct an object of this type with all the data we are recording. 017 * @param addr_msb MSB of address 018 * @param addr_lsb LSB of address 019 * @param speed speed value 020 */ 021 public Z21SimulatorLocoData(byte addr_msb, byte addr_lsb, byte speed){ 022 address_msb = addr_msb; 023 address_lsb = addr_lsb; 024 speed_byte = speed; 025 } 026 027 byte getAddressLsb(){ 028 return address_lsb; 029 } 030 031 byte getAddressMsb(){ 032 if (address_msb == 0) { 033 return address_msb; 034 } else { 035 // this is a long address with an offset added. 036 int address = ( (0xff00 & (address_msb<<8) ) + (0xff & address_lsb)) - 0xC000; 037 return (byte)(( 0xff00 & address)>>8); 038 } 039 } 040 041 byte getSpeed(){ 042 return speed_byte; 043 } 044}