001package jmri.jmrit.logix; 002 003 004/** 005 * A TrainOrder has information about a required speed change of 006 * the warrant. This class is returned when a BlockOrder attempts 007 * to set the warrant's path through its block. 008 * 009 * @author Pete Cressman Copyright (C) 2022 010 */ 011 class TrainOrder { 012 013 public enum Cause { 014 NONE("None"), 015 WARRANT("Warrant"), 016 OCCUPY("Occupancy"), 017 SIGNAL("Signal"), 018 ERROR("Error"); 019 020 String _bundleKey; 021 022 Cause(String bundleName) { 023 _bundleKey = bundleName; 024 } 025 026 @Override 027 public String toString() { 028 return Bundle.getMessage(_bundleKey); 029 } 030 } 031 032 protected String _speedType; // speedTyps name of speed change ahead. 033 protected Cause _cause; // case of speed change 034 protected int _idxContrlBlock; // index of BlockOrder whose condition is cause of speed change 035 protected int _idxEnterBlock; // index of BlockOrder where entry requires speed change 036 protected String _message; // message why speed change is needed 037 038 protected TrainOrder(String speedType, Cause cause, int idxControl, int idxEnter, String msg) { 039 _speedType = speedType; 040 _cause = cause; 041 _idxContrlBlock = idxControl; 042 _idxEnterBlock = idxEnter; 043 _message = msg; 044 } 045 046 @Override 047 public String toString() { 048 StringBuilder sb = new StringBuilder("TrainOrder: speedType \""); 049 sb.append(_speedType); 050 sb.append("\", cause \""); 051 sb.append(_cause.toString()); 052 sb.append("\", idxContrlBlock= "); 053 sb.append(_idxContrlBlock); 054 sb.append(", idxEnterBlock= "); 055 sb.append(_idxEnterBlock); 056 sb.append(", _message "); 057 sb.append(_message); 058 return sb.toString(); 059 } 060}