001package jmri.jmrit.ctc.ctcserialdata; 002 003import java.util.ArrayList; 004import jmri.*; 005import jmri.jmrit.ctc.*; 006 007/** 008 * This describes a single line of Call On data. The list of call on rules 009 * for each OS section are in the _mCO_GroupingsList variable in {@link CodeButtonHandlerData}. 010 * 011 * During panel loading, the switch indicator names are saved as strings. Once all of the 012 * data is loaded, the NBHSensors are copied from the related CodeButtonHandlerData. 013 * @author Dave Sand Copyright (C) 2020 014 */ 015public class CallOnData { 016 public NBHSignal _mExternalSignal; 017 public String _mSignalFacingDirection; 018 public String _mSignalAspectToDisplay; 019 public NBHSensor _mCalledOnExternalSensor; 020 public NamedBeanHandle<Block> _mExternalBlock; 021 public ArrayList<NBHSensor> _mSwitchIndicators; // Up to 6 entries 022 public ArrayList<String> _mSwitchIndicatorNames; // Temporary names during XML loading 023 024 public CallOnData() { 025 } 026 027 @Override 028 public String toString() { 029 String formattedString = String.format("%s,%s,%s,%s,%s", 030 _mExternalSignal != null ? _mExternalSignal.getHandleName() : "", 031 _mSignalFacingDirection != null ? _mSignalFacingDirection : "", 032 _mSignalAspectToDisplay != null ? _mSignalAspectToDisplay : "", 033 _mCalledOnExternalSensor != null ? _mCalledOnExternalSensor.getHandleName() : "", 034 _mExternalBlock != null ? _mExternalBlock.getName() : ""); 035 StringBuilder buildString = new StringBuilder(formattedString); 036 _mSwitchIndicators.forEach(sw -> { 037 buildString.append(","); 038 buildString.append(sw.getHandleName()); 039 }); 040 return buildString.toString(); 041 } 042}