jmri.jmrit.dispatcher
Class AutoAllocate

java.lang.Object
  extended by jmri.jmrit.dispatcher.AutoAllocate

public class AutoAllocate
extends Object

Handles automatic allocation of Sections for Dispatcher

AutoAllocate.java is an extension of DispatcherFrame.java.

When AutoAllocate is triggered, it scans the list of Allocation Requests, in order of the priorities of ActiveTrains with pending AllocationRequests, testing if a requested allocation can be made. AutoAllocate returns when either: A Section has been allocated -or- All AllocationRequests have been tested, and no allocation is indicated.

If AutoAllocate needs to save information related to a plan requiring multiple allocations, an AllocationPlan object is created. When the plan is complete, the AllocationPlan object is disposed of. Multiple AllocationPlan objects may be active at any one time.

AutoAllocate is triggered by each of the following events: An AllocatedSection has been released, freeing up a Section. A new AllocationRequest has been entered into the queue of AllocationRequests. A Section has been allocated, either by AutoAllocate or manually by the dispatcher.

AutoAllocate requires that AutoRelease is active and that Dispatcher has a LayoutEditor panel.

AutoAllocate operates conservatively, that is, if there is any doubt that a Section should be allocated, it will not allocate the Section.

AutoAllocate develops plans for meets when multiple ActiveTrains are using the same Sections of track. These plans are automatically created and removed. They are stored in AllocationPlan objects to avoid having to continually recreate them, since the logic to create them is rather complicated.

The dispatcher is free to switch AutoAllocate on or off at any tine in DispatcherFrame. When AutoAllocate is switched off, all existing AllocationPlan objects are discarded.

This file is part of JMRI.

JMRI is open source 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) 2011

Constructor Summary
AutoAllocate(DispatcherFrame d)
           
 
Method Summary
protected  Section autoNextSectionChoice(ArrayList<Section> sList, AllocationRequest ar)
          Entered to request a choice of Next Section when a Section is being allocated and there are alternate Section choices for the next Section.
protected  void clearAllocationPlans()
           
protected  void scanAllocationRequestList(ArrayList<AllocationRequest> list)
          This is the entry point to AutoAllocate when it is triggered.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AutoAllocate

public AutoAllocate(DispatcherFrame d)
Method Detail

scanAllocationRequestList

protected void scanAllocationRequestList(ArrayList<AllocationRequest> list)
This is the entry point to AutoAllocate when it is triggered. Returns 'true' if a Section has been allocated, returns 'false' if not.


autoNextSectionChoice

protected Section autoNextSectionChoice(ArrayList<Section> sList,
                                        AllocationRequest ar)
Entered to request a choice of Next Section when a Section is being allocated and there are alternate Section choices for the next Section. sList contains the possible next Sections, and ar is the section being allocated when a choice is needed.


clearAllocationPlans

protected void clearAllocationPlans()


Copyright © 1997 - 2011 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: Get JMRI Model Railroad Interface at SourceForge.net. Fast, secure and Free Open Source software downloads