jmri.jmrix.sprog
Class SprogCommandStation

java.lang.Object
  extended by jmri.jmrix.sprog.SprogCommandStation
All Implemented Interfaces:
Runnable, EventListener, CommandStation, SprogListener

public class SprogCommandStation
extends Object
implements CommandStation, SprogListener, Runnable

Controls a collection of slots, acting as a soft command station for SPROG

A SlotListener can register to hear changes. By registering here, the SlotListener is saying that it wants to be notified of a change in any slot. Alternately, the SlotListener can register with some specific slot, done via the SprogSlot object itself.

This Programmer implementation is single-user only. It's not clear whether the command stations can have multiple programming requests outstanding (e.g. service mode and ops mode, or two ops mode) at the same time, but this code definitely can't.

Updated by Andrew Berridge, January 2010 - state management code now safer, uses enum, etc. Amalgamated with Sprog Slot Manager into a single class - reduces code duplication

Author:
Bob Jacobsen Copyright (C) 2001, 2003 Andrew Crosland (C) 2006 ported to SPROG

Constructor Summary
SprogCommandStation()
           
 
Method Summary
 void addSlotListener(SprogSlotListener l)
           
 void estopAll()
          Send emergency stop to all slots
 void forwardCommandChangeToLayout(int address, boolean closed)
           
 void function0Through4Packet(int address, boolean f0, boolean f0Momentary, boolean f1, boolean f1Momentary, boolean f2, boolean f2Momentary, boolean f3, boolean f3Momentary, boolean f4, boolean f4Momentary)
           
 void function5Through8Packet(int address, boolean f5, boolean f5Momentary, boolean f6, boolean f6Momentary, boolean f7, boolean f7Momentary, boolean f8, boolean f8Momentary)
           
 void function9Through12Packet(int address, boolean f9, boolean f9Momentary, boolean f10, boolean f10Momentary, boolean f11, boolean f11Momentary, boolean f12, boolean f12Momentary)
           
 int getInUseCount()
          Provide a count of the slots in use
static SprogCommandStation instance()
          method to find the existing SlotManager object, if need be creating one
 boolean isBusy()
           
 void notifyMessage(SprogMessage m)
           
 void notifyReply(SprogReply m)
           
 void opsModepacket(int address, boolean longAddr, int cv, int val)
           
 void release(int address)
           
 void removeSlotListener(SprogSlotListener l)
           
 void run()
           
 void sendPacket(byte[] packet, int repeats)
          Send a specific packet to the rails.
 void setSpeed(int address, int spd, boolean isForward)
           
 SprogSlot slot(int i)
          Return contents of Queue slot i
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SprogCommandStation

public SprogCommandStation()
Method Detail

sendPacket

public void sendPacket(byte[] packet,
                       int repeats)
Send a specific packet to the rails.

Specified by:
sendPacket in interface CommandStation
Parameters:
packet - Byte array representing the packet, including the error-correction byte. Must not be null.
repeats - number of times to repeat the packet

slot

public SprogSlot slot(int i)
Return contents of Queue slot i

Parameters:
i - int
Returns:
SprogSlot

forwardCommandChangeToLayout

public void forwardCommandChangeToLayout(int address,
                                         boolean closed)

function0Through4Packet

public void function0Through4Packet(int address,
                                    boolean f0,
                                    boolean f0Momentary,
                                    boolean f1,
                                    boolean f1Momentary,
                                    boolean f2,
                                    boolean f2Momentary,
                                    boolean f3,
                                    boolean f3Momentary,
                                    boolean f4,
                                    boolean f4Momentary)

function5Through8Packet

public void function5Through8Packet(int address,
                                    boolean f5,
                                    boolean f5Momentary,
                                    boolean f6,
                                    boolean f6Momentary,
                                    boolean f7,
                                    boolean f7Momentary,
                                    boolean f8,
                                    boolean f8Momentary)

function9Through12Packet

public void function9Through12Packet(int address,
                                     boolean f9,
                                     boolean f9Momentary,
                                     boolean f10,
                                     boolean f10Momentary,
                                     boolean f11,
                                     boolean f11Momentary,
                                     boolean f12,
                                     boolean f12Momentary)

setSpeed

public void setSpeed(int address,
                     int spd,
                     boolean isForward)

opsModepacket

public void opsModepacket(int address,
                          boolean longAddr,
                          int cv,
                          int val)

release

public void release(int address)

estopAll

public void estopAll()
Send emergency stop to all slots


instance

public static final SprogCommandStation instance()
method to find the existing SlotManager object, if need be creating one


addSlotListener

public void addSlotListener(SprogSlotListener l)

removeSlotListener

public void removeSlotListener(SprogSlotListener l)

run

public void run()
Specified by:
run in interface Runnable

notifyMessage

public void notifyMessage(SprogMessage m)
Specified by:
notifyMessage in interface SprogListener

notifyReply

public void notifyReply(SprogReply m)
Specified by:
notifyReply in interface SprogListener

getInUseCount

public int getInUseCount()
Provide a count of the slots in use


isBusy

public boolean isBusy()
Returns:
a boolean if the command station is busy - i.e. it has at least one occupied slot


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