001package jmri.jmrit.withrottle; 002 003import jmri.jmrit.consisttool.ConsistFile; 004import org.slf4j.Logger; 005import org.slf4j.LoggerFactory; 006 007/** 008 * @author Brett Hoffman Copyright (C) 2011 009 * 010 */ 011public class WiFiConsistFile extends ConsistFile { 012 013 public WiFiConsistFile(jmri.ConsistManager cm) { 014 super(); 015 consistMan = cm; 016 loadStoredConsistFile("wifiConsist.xml"); 017 } 018 019 /** 020 * Check to see if wifiConsist.xml file exists. If so load it. If not, check 021 * for consist.xml file and load it. Once a wifiConsist.xml file exists, the 022 * default file will not be loaded by this anymore. 023 */ 024 private void loadStoredConsistFile(String fileName) { 025 if (checkFile(getFileLocation() + fileName)) { 026 log.debug("Has {} file.", fileName); 027 try { 028 readFile(getFileLocation() + fileName); 029 } catch (Exception e) { 030 log.warn("error reading consist file", e); 031 } 032 } else { 033 log.debug("No {} file, will check for default file.", fileName); 034 if (checkFile(defaultConsistFilename())) { 035 log.debug("Has default consist.xml file, will read it."); 036 try { 037 readFile(); 038 } catch (Exception e) { 039 log.warn("error reading consist file", e); 040 } 041 } else { 042 log.debug("No consist files found, will create if needed."); 043 } 044 } 045 } 046 047 private final static Logger log = LoggerFactory.getLogger(WiFiConsistFile.class); 048 049}