001package jmri.jmrix.ecos.networkdriver; 002 003import jmri.jmrix.ecos.EcosPortController; 004import jmri.jmrix.ecos.EcosSystemConnectionMemo; 005import jmri.jmrix.ecos.EcosTrafficController; 006import org.slf4j.Logger; 007import org.slf4j.LoggerFactory; 008 009/** 010 * Implements NetworkPortAdapter for the ECoS system network connection. 011 * <p> 012 * This connects an ECOS command station via a telnet connection. Normally 013 * controlled by the NetworkDriverFrame class. 014 * 015 * @author Bob Jacobsen Copyright (C) 2001, 2002, 2003, 2008, 2021 016 */ 017public class NetworkDriverAdapter extends EcosPortController { 018 019 public NetworkDriverAdapter(EcosSystemConnectionMemo memo) { 020 super(memo); 021 allowConnectionRecovery = true; 022 manufacturerName = jmri.jmrix.ecos.EcosConnectionTypeList.ESU; 023 } 024 025 public NetworkDriverAdapter() { 026 this(new EcosSystemConnectionMemo()); 027 } 028 029 /** 030 * Set up all of the other objects to operate with an ECOS command station 031 * connected to this port. 032 */ 033 @Override 034 public void configure() { 035 // connect to the traffic controller 036 EcosTrafficController control = new EcosTrafficController(); 037 control.connectPort(this); 038 control.setAdapterMemo(this.getSystemConnectionMemo()); 039 this.getSystemConnectionMemo().setEcosTrafficController(control); 040 this.getSystemConnectionMemo().configureManagers(); 041 } 042 043 /** 044 * {@inheritDoc} 045 */ 046 @Override 047 public boolean status() { 048 return opened; 049 } 050 051 @Override 052 protected void resetupConnection() { 053 log.info("reconnected to ECoS after lost connection"); 054 if (opened) { 055 this.getSystemConnectionMemo().getTrafficController().connectPort(this); 056 this.getSystemConnectionMemo().getTurnoutManager().refreshItems(); 057 this.getSystemConnectionMemo().getSensorManager().refreshItems(); 058 this.getSystemConnectionMemo().getLocoAddressManager().refreshItems(); 059 } 060 } 061 062 private final static Logger log = LoggerFactory.getLogger(NetworkDriverAdapter.class); 063 064}