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 015 private final String blockName; 016 private final float entranceSpeed; 017 private final float exitSpeed; 018 private final long time; 019 private final float pathDist; 020 private final float calcDist; 021 private final int firstIdx; 022 private final int lastIdx; 023 024 BlockSpeedInfo( @Nonnull String n, float ens, float exs, long t, float d, float c, int fi, int li) { 025 blockName = n; 026 entranceSpeed = ens; 027 exitSpeed = exs; 028 time = t; 029 pathDist = d; 030 calcDist = c; 031 firstIdx = fi; 032 lastIdx = li; 033 } 034 035 String getBlockDisplayName() { 036 return blockName; 037 } 038 // Throttle setting at entrance of block 039 float getEntranceSpeed() { 040 return entranceSpeed; 041 } 042 043 // Throttle setting at exit of block 044 float getExitSpeed() { 045 return exitSpeed; 046 } 047 048 long getTimeInBlock() { 049 return time; 050 } 051 052 // Path length in block 053 float getPathLen() { 054 return pathDist; 055 } 056 057 // Calculated path length in block according to speedProfile 058 float getCalcLen() { 059 return calcDist; 060 } 061 int getFirstIndex() { 062 return firstIdx; 063 } 064 065 int getLastIndex() { 066 return lastIdx; 067 } 068 069 @Override 070 @Nonnull 071 public String toString() { 072 StringBuilder sb = new StringBuilder(" \""); 073 sb.append(blockName); 074 sb.append("\" entranceSpeed "); 075 sb.append(entranceSpeed); 076 sb.append(", exitSpeed "); 077 sb.append(exitSpeed); 078 sb.append(", time "); 079 sb.append(time); 080 sb.append(", pathDist "); 081 sb.append(pathDist); 082 sb.append(", calcDist "); 083 sb.append(calcDist); 084 sb.append(", from "); 085 sb.append(firstIdx); 086 sb.append(" to "); 087 sb.append(lastIdx); 088 return sb.toString(); 089 } 090}