001package jmri.jmrit.logix; 002 003import javax.annotation.Nonnull; 004 005/** 006 * This class holds speed data for a block of a warrant's route. The data is 007 * gathered when a warrant is about to be executed and uses speed information 008 * of the locomotive running the warrant. 009 * 010 * @author Pete Cressman Copyright (C) 2019 011*/ 012 013class BlockSpeedInfo { 014 String blockName; 015 float entranceSpeed; 016 float exitSpeed; 017 long time; 018 float pathDist; 019 float calcDist; 020 int firstIdx; 021 int lastIdx; 022 023 BlockSpeedInfo(String n, float ens, float exs, long t, float d, float c, int fi, int li) { 024 blockName = n; 025 entranceSpeed = ens; 026 exitSpeed = exs; 027 time = t; 028 pathDist = d; 029 calcDist = c; 030 firstIdx = fi; 031 lastIdx = li; 032 } 033 034 String getBlockDisplayName() { 035 return blockName; 036 } 037 // Throttle setting at entrance of block 038 float getEntranceSpeed() { 039 return entranceSpeed; 040 } 041 042 // Throttle setting at exit of block 043 float getExitSpeed() { 044 return exitSpeed; 045 } 046 047 long getTimeInBlock() { 048 return time; 049 } 050 051 // Path length in block 052 float getPathLen() { 053 return pathDist; 054 } 055 056 // Calculated path length in block according to speedProfile 057 float getCalcLen() { 058 return calcDist; 059 } 060 int getFirstIndex() { 061 return firstIdx; 062 } 063 064 int getLastIndex() { 065 return lastIdx; 066 } 067 068 @Override 069 @Nonnull 070 public String toString() { 071 StringBuilder sb = new StringBuilder("BlockSpeedInfo \""); 072 sb.append(blockName); 073 sb.append("\" entranceSpeed "); 074 sb.append(entranceSpeed); 075 sb.append(", exitSpeed "); 076 sb.append(exitSpeed); 077 sb.append(", time "); 078 sb.append(time); 079 sb.append(", pathDist "); 080 sb.append(pathDist); 081 sb.append(", calcDist "); 082 sb.append(calcDist); 083 sb.append(", from "); 084 sb.append(firstIdx); 085 sb.append(" to "); 086 sb.append(lastIdx); 087 return sb.toString(); 088 } 089}