001package jmri.jmrix.openlcb; 002 003import java.util.List; 004import jmri.AddressedProgrammer; 005import jmri.GlobalProgrammerManager; 006import jmri.InstanceManager; 007import jmri.Programmer; 008import jmri.ProgrammingMode; 009 010import javax.annotation.Nonnull; 011 012/** 013 * Get access to available {@link Programmer} objects. 014 * <p> 015 * Programmers come in two types: 016 * <ul> 017 * <li>Global, previously "Service Mode" or on a programming track. Request 018 * these from an instance of {@link GlobalProgrammerManager}. 019 * <li>Addressed, previously "Ops Mode" also known as "programming on the main". Request 020 * these from an instance of this interface. 021 * </ul> 022 * You get a {@link Programmer} object from a ProgrammerManager, which in turn 023 * can be located from the {@link InstanceManager}. 024 * <p> 025 * This interface also provides a reserve/release system for tools that want to 026 * pretend they have exclusive use of a Programmer. This is a cooperative 027 * reservation; both tools (first and second reserver) must be using the 028 * reserve/release interface. 029 * <p> 030 * This file is part of JMRI. 031 * <p> 032 * JMRI is free software; you can redistribute it and/or modify it under the 033 * terms of version 2 of the GNU General Public License as published by the Free 034 * Software Foundation. See the "COPYING" file for a copy of this license. 035 * <p> 036 * JMRI is distributed in the hope that it will be useful, but WITHOUT ANY 037 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR 038 * A PARTICULAR PURPOSE. See the GNU General Public License for more details. 039 * 040 * @see jmri.Programmer 041 * @author Bob Jacobsen Copyright (C) 2015 042 * @since 4.1.1 043 */ 044public class OlcbProgrammerManager extends jmri.managers.DefaultProgrammerManager { 045 046 public OlcbProgrammerManager(Programmer pProgrammer) { 047 super(pProgrammer); 048 } 049 050 public OlcbProgrammerManager(Programmer pProgrammer, jmri.SystemConnectionMemo memo) { 051 super(pProgrammer, memo); 052 } 053 054 055 public static final ProgrammingMode OPENLCBMODE = new ProgrammingMode("OPENLCBMODE", Bundle.getMessage("OPENLCBMODE")); 056 057 /** 058 * Gain access to a Addressed Mode Programmer without reservation. 059 * 060 * @param pLongAddress true if this is a long (14 bit) address, else false 061 * @param pAddress Specific decoder address to use. 062 * @return null only if there isn't an Ops Mode Programmer in the system 063 */ 064 @Override 065 public AddressedProgrammer getAddressedProgrammer(boolean pLongAddress, int pAddress) { return null; } 066 067 /** 068 * Gain access to a (the) Addressed Mode Programmer, in the process 069 * reserving it for yourself. 070 * 071 * @param pLongAddress true if this is a long (14 bit) address, else false 072 * @param pAddress Specific decoder address to use. 073 * @return null if the address is in use by a reserved programmer 074 */ 075 @Override 076 public AddressedProgrammer reserveAddressedProgrammer(boolean pLongAddress, int pAddress) { return null; } 077 078 /** 079 * Return access to an Addressed Mode Programmer, so that it can be used 080 * elsewhere. 081 */ 082 @Override 083 public void releaseAddressedProgrammer(@Nonnull AddressedProgrammer p) {} 084 085 /** 086 * Convenience method to check whether you'll be able to get an Addressed 087 * Mode programmer. 088 * 089 * @return false if there's no chance of getting one 090 */ 091 @Override 092 public boolean isAddressedModePossible() { return false; } 093 094 /** 095 * Get the list of {@link ProgrammingMode} (generally) supported by 096 * Programmers provided by this Manager. 097 * <p> 098 * Use this to enquire about modes before you're ready to request a specific 099 * programmer. 100 * <p> 101 * If the order is significant, earlier modes are better. 102 */ 103 @Nonnull 104 @Override 105 public List<ProgrammingMode> getDefaultModes() { return new java.util.ArrayList<>(); } 106 107 /** 108 * Provides the human-readable representation for including 109 * ProgrammerManagers directly in user interface components, so it should return a 110 * user-provided name for this particular one. 111 */ 112 @Nonnull 113 @Override 114 public String getUserName() { return "OpenLCB"; } 115 116 /** 117 * toString() provides the human-readable representation for including 118 * ProgrammerManagers directly in user interface components, so it should return a 119 * user-provided name for this particular one. 120 */ 121 @Nonnull 122 @Override 123 public String toString() { return "OlcbProgrammerManager"; } 124}