jmri
Interface LightManager

All Superinterfaces:
Manager
All Known Implementing Classes:
AbstractLightManager, AcelaLightManager, LnLightManager, ProxyLightManager, SerialLightManager, SerialLightManager, SerialLightManager, SerialLightManager, SerialLightManager, SerialLightManager, SpecificLightManager, SpecificLightManager, XNetLightManager

public interface LightManager
extends Manager

Interface for obtaining Lights.

This doesn't have a "new" method, as Lights are separately implemented, instead of being system-specific.

Based on SignalHeadManager.java


This file is part of JMRI.

JMRI is free software; you can redistribute it and/or modify it under the terms of version 2 of the GNU General Public License as published by the Free Software Foundation. See the "COPYING" file for a copy of this license.

JMRI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.

Author:
Dave Duchamp Copyright (C) 2004

Method Summary
 void activateAllLights()
          Activate the control mechanism for each Light controlled by this LightManager.
 String convertSystemNameToAlternate(String systemName)
          Convert the system name to a normalized alternate name This routine is to allow testing to ensure that two Lights with alternate names that refer to the same output bit are not created.
 void dispose()
          Free resources when no longer used.
 Light getBySystemName(String s)
          Locate a Light by its system name
 Light getByUserName(String s)
          Locate a Light by its user name
 Light getLight(String name)
          Locate via user name, then system name if needed.
 List getSystemNameList()
          Get a list of all Light system names.
 Light newLight(String systemName, String userName)
          Return an instance with the specified system and user names.
 String normalizeSystemName(String systemName)
          Normalize the system name This routine is used to ensure that each system name is uniquely linked to one C/MRI bit, by removing extra zeros inserted by the user.
 Light provideLight(String name)
          Locate via user name, then system name if needed.
 boolean validSystemNameConfig(String systemName)
          Validate system name for the current hardware configuration returns 'true' if system name has a valid meaning in current configuration, else returns 'false'
 boolean validSystemNameFormat(String systemName)
          Validate system name format returns 'true' if system name has a valid format, else returns 'false'
 
Methods inherited from interface jmri.Manager
addPropertyChangeListener, deregister, makeSystemName, register, removePropertyChangeListener, systemLetter, typeLetter
 

Method Detail

provideLight

Light provideLight(String name)
Locate via user name, then system name if needed. If that fails, create a new Light: If the name is a valid system name, it will be used for the new Light. Otherwise, the makeSystemName method will attempt to turn it into a valid system name.

Parameters:
name -
Returns:
Never null under normal circumstances

dispose

void dispose()
Description copied from interface: Manager
Free resources when no longer used. Specifically, remove all references to and from this object, so it can be garbage-collected.

Specified by:
dispose in interface Manager

getLight

Light getLight(String name)
Locate via user name, then system name if needed. Does not create a new one if nothing found

Parameters:
name -
Returns:
null if no match found

newLight

Light newLight(String systemName,
               String userName)
Return an instance with the specified system and user names. Note that two calls with the same arguments will get the same instance; there is only one Light object representing a given physical Light and therefore only one with a specific system or user name.

This will always return a valid object reference; a new object will be created if necessary. In that case:

Note that it is possible to make an inconsistent request if both addresses are provided, but the given values are associated with different objects. This is a problem, and we don't have a good solution except to issue warnings. This will mostly happen if you're creating Lights when you should be looking them up.

Returns:
requested Light object (never null)

getByUserName

Light getByUserName(String s)
Locate a Light by its user name


getBySystemName

Light getBySystemName(String s)
Locate a Light by its system name


validSystemNameFormat

boolean validSystemNameFormat(String systemName)
Validate system name format returns 'true' if system name has a valid format, else returns 'false'


validSystemNameConfig

boolean validSystemNameConfig(String systemName)
Validate system name for the current hardware configuration returns 'true' if system name has a valid meaning in current configuration, else returns 'false'


normalizeSystemName

String normalizeSystemName(String systemName)
Normalize the system name

This routine is used to ensure that each system name is uniquely linked to one C/MRI bit, by removing extra zeros inserted by the user.

This routine is implemented in AbstractLightManager to return the same name. If a system implementation has names that could be normalized, the system-specific Light Manager should override this routine and supply a normalized system name.


convertSystemNameToAlternate

String convertSystemNameToAlternate(String systemName)
Convert the system name to a normalized alternate name

This routine is to allow testing to ensure that two Lights with alternate names that refer to the same output bit are not created.

This routine is implemented in AbstractLightManager to return "". If a system implementation has alternate names, the system specific Light Manager should override this routine and supply the alternate name.


getSystemNameList

List getSystemNameList()
Get a list of all Light system names.

Specified by:
getSystemNameList in interface Manager

activateAllLights

void activateAllLights()
Activate the control mechanism for each Light controlled by this LightManager. Note that some Lights don't require any activation. The activateLight method in AbstractLight.java determines what needs to be done for each Light.



Copyright © 1997 - 2008 JMRI Community.
JMRI, DecoderPro, PanelPro, SoundPro, DispatcherPro and associated logos are our trademarks.

Additional information on copyright, trademarks and licenses is linked here.
Site hosted by: SourceForge_Logo