Package jmri.jmrix.pi
Class RaspberryPiAdapter
java.lang.Object
jmri.jmrix.AbstractPortController
jmri.jmrix.pi.RaspberryPiAdapter
- All Implemented Interfaces:
PortAdapter
Provides an Adapter to allow the system connection memo and multiple
RaspberryPi managers to be handled.
Uses Pi4J 3.x on real Raspberry Pi hardware, or the JMRI-internal
GpioSimulator in simulator mode.
Pin addresses are BCM (Broadcom) numbers; e.g. "PS4" → BCM GPIO 4.
-
Nested Class Summary
Nested classes/interfaces inherited from class jmri.jmrix.AbstractPortController
AbstractPortController.Option -
Field Summary
Fields inherited from class jmri.jmrix.AbstractPortController
allowConnectionRecovery, manufacturerName, opened, option1Name, option2Name, option3Name, option4Name, options, reconnectinterval, reconnectMaxAttempts, reconnectMaxInterval -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidConfigure all of the other jmrix widgets needed to work with this adapter.voidconnect()Open the connection.voiddispose()Clean up before removal.Get the InputStream from the port.Get the outputStream to the port.com.pi4j.context.ContextGet the Pi4J context associated with this adapter.(package private) static com.pi4j.context.ContextReturn the shared Pi4J context, creating it lazily if needed.Get theSystemConnectionMemoassociated with this object.static booleanvoidrecover()This is called when a connection is initially lost.(package private) static voidsetIsSimulator(boolean isSimulator) Package-private setter so tests injmri.jmrix.pican enable simulator mode before constructing sensors or turnouts.Methods inherited from class jmri.jmrix.AbstractPortController
closeConnection, configureOption1, configureOption2, configureOption3, configureOption4, getDisabled, getManufacturer, getOption1Name, getOption2Name, getOption3Name, getOption4Name, getOptionChoices, getOptionDisplayName, getOptions, getOptionState, getReconnectMaxAttempts, getReconnectMaxInterval, getSystemPrefix, getUserName, isDirty, isOptionAdvanced, isOptionTypePassword, isOptionTypeText, isRestartRequired, purgeStream, reconnect, reconnectFromLoop, resetupConnection, safeSleep, setClosed, setDisabled, setManufacturer, setOpened, setOptionState, setReconnectMaxAttempts, setReconnectMaxInterval, setSystemConnectionMemo, setSystemPrefix, setUserName, status
-
Constructor Details
-
RaspberryPiAdapter
public RaspberryPiAdapter()No-arg constructor. Inherits the current value of the static simulator flag so that tests which callsetIsSimulator(boolean)before construction will automatically get a simulator-mode adapter. -
RaspberryPiAdapter
-
-
Method Details
-
isSimulator
-
setIsSimulator
Package-private setter so tests injmri.jmrix.pican enable simulator mode before constructing sensors or turnouts. -
getCurrentPortName
- Specified by:
getCurrentPortNamein interfacePortAdapter- Specified by:
getCurrentPortNamein classAbstractPortController
-
dispose
Description copied from class:AbstractPortControllerClean up before removal. Overriding methods must callsuper.dispose()or document why they are not calling the overridden implementation. In most cases, failure to call the overridden implementation will cause user-visible error.- Specified by:
disposein interfacePortAdapter- Overrides:
disposein classAbstractPortController
-
connect
Description copied from interface:PortAdapterOpen the connection. -
configure
Description copied from interface:PortAdapterConfigure all of the other jmrix widgets needed to work with this adapter. -
getInputStream
Description copied from class:AbstractPortControllerGet the InputStream from the port.- Specified by:
getInputStreamin interfacePortAdapter- Specified by:
getInputStreamin classAbstractPortController- Returns:
- the InputStream from the port
-
getOutputStream
Description copied from class:AbstractPortControllerGet the outputStream to the port.- Specified by:
getOutputStreamin interfacePortAdapter- Specified by:
getOutputStreamin classAbstractPortController- Returns:
- the outputStream to the port
-
getSystemConnectionMemo
Description copied from class:AbstractPortControllerGet theSystemConnectionMemoassociated with this object.This method should only be overridden to ensure that a specific subclass of SystemConnectionMemo is returned. The recommended pattern is:
public MySystemConnectionMemo getSystemConnectionMemo() { return (MySystemConnectionMemo) super.getSystemConnectionMemo(); }- Specified by:
getSystemConnectionMemoin interfacePortAdapter- Overrides:
getSystemConnectionMemoin classAbstractPortController- Returns:
- the currently associated SystemConnectionMemo
-
recover
Description copied from class:AbstractPortControllerThis is called when a connection is initially lost. After checking the allowConnectionRecovery flag, closes the connection, resets the open flag and attempts a reconnection.- Specified by:
recoverin interfacePortAdapter- Overrides:
recoverin classAbstractPortController
-
getPi4JContext
Get the Pi4J context associated with this adapter. Returnsnullin simulator mode or when not running on a Pi.- Returns:
- the Pi4J
Context, ornull
-