001package jmri.jmrit.dispatcher; 002 003public class TaskAllocateRelease { 004 005 TaskAllocateRelease(TaskAction action) { 006 act = action; 007 } 008 009 TaskAllocateRelease(TaskAction action, String trainName) { 010 act = action; 011 this.trainName = trainName; 012 } 013 014 TaskAllocateRelease(TaskAction action, AllocatedSection aSection, boolean termTrain) { 015 act = action; 016 allocatedSection = aSection; 017 terminateingTrain = termTrain; 018 } 019 020 TaskAllocateRelease(TaskAction action, AllocationRequest aRequest) { 021 act = action; 022 allocationRequest = aRequest; 023 } 024 025 TaskAllocateRelease(TaskAction action, Runnable whenReached) { 026 act = action; 027 this.whenReached = whenReached; 028 } 029 030 031 private TaskAction act; 032 private String trainName = null; 033 private AllocatedSection allocatedSection = null; 034 private AllocationRequest allocationRequest = null; 035 private Runnable whenReached = null; 036 037 private boolean terminateingTrain = false; 038 039 public enum TaskAction { 040 SCAN_REQUESTS, 041 RELEASE_RESERVED, 042 RELEASE_ONE, 043 AUTO_RELEASE, 044 ABORT, 045 ALLOCATE_IMMEDIATE, 046 BARRIER; 047 } 048 049 public TaskAction getAction() { 050 return act; 051 } 052 053 public String getTrainName() { 054 return trainName; 055 } 056 057 public AllocatedSection getAllocatedSection() { 058 return allocatedSection; 059 } 060 061 public boolean getTerminatingTrain() { 062 return terminateingTrain; 063 } 064 065 public AllocationRequest getAllocationRequest() { 066 return allocationRequest; 067 } 068 069 /** 070 * Get the action run when a BARRIER task is reached, after every task 071 * queued before it has been completed. 072 * 073 * @return the action, or null 074 */ 075 public Runnable getWhenReached() { 076 return whenReached; 077 } 078 079}