- java.lang.Object
-
- com.pi4j.common.IdentityBase<T>
-
- com.pi4j.extension.ExtensionBase<Platform>
-
- com.pi4j.platform.PlatformBase<PLATFORM>
-
- All Implemented Interfaces:
Describable
,Identity
,Lifecycle<Platform>
,Extension<Platform>
,com.pi4j.internal.IOCreator
,com.pi4j.internal.ProviderAliases
,com.pi4j.internal.ProviderProvider
,Platform
public abstract class PlatformBase<PLATFORM extends Platform> extends ExtensionBase<Platform> implements Platform
Abstract PlatformBase class.
- Version:
- $Id: $Id
- Author:
- Robert Savage (http://www.savagehomeautomation.com)
-
-
Constructor Summary
Constructors Constructor Description PlatformBase()
Constructor for PlatformBase.PlatformBase(String id)
Constructor for PlatformBase.PlatformBase(String id, String name)
Constructor for PlatformBase.PlatformBase(String id, String name, String description)
Constructor for PlatformBase.
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected void
addProvider(Context context, String providerId)
addProvider.<I extends IO>
Icreate(IOConfig config, IOType ioType)
<T extends IO>
Tcreate(String id)
<T extends IO>
Tcreate(String id, IOType ioType)
abstract boolean
enabled(Context context)
enabled.protected abstract String[]
getProviders()
Getter for the fieldproviders
.PLATFORM
initialize(Context context)
initialize.abstract int
priority()
The priority in which platforms must be handled.<T extends Provider>
Tprovider(Class<T> providerClass)
provider.Map<IOType,Provider>
providers()
providers.PLATFORM
shutdown(Context context)
shutdown.-
Methods inherited from class com.pi4j.common.IdentityBase
description, id, metadata, name
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface com.pi4j.common.Identity
description, getDescription, getId, getMetadata, getName, id, metadata, name
-
Methods inherited from interface com.pi4j.internal.IOCreator
create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create, create
-
Methods inherited from interface com.pi4j.platform.Platform
describe, hasProvider, hasProvider, hasProvider, provider, provider, provider
-
Methods inherited from interface com.pi4j.internal.ProviderAliases
ain, analogInput, analogOutput, aout, digitalInput, digitalOutput, din, dout, getAnalogInputProvider, getAnalogOutputProvider, getDigitalInputProvider, getDigitalOutputProvider, getI2CProvider, getPwmProvider, getSerialProvider, getSpiProvider, i2c, pwm, serial, spi
-
-
-
-
Method Detail
-
provider
public <T extends Provider> T provider(Class<T> providerClass) throws ProviderNotFoundException, ProviderInterfaceException
provider.
- Specified by:
provider
in interfacePlatform
- Specified by:
provider
in interfacecom.pi4j.internal.ProviderProvider
- Type Parameters:
T
- a T object.- Parameters:
providerClass
- aClass
object.- Returns:
- a T object.
- Throws:
ProviderNotFoundException
- if any.ProviderInterfaceException
- if any.
-
priority
public abstract int priority()
The priority in which platforms must be handled. This will be used to determine which one to use if multiple are provided with the same providers.
- Negative number: used e.g. for a Mock provider
- Low number: very unlikely to be used
- Higher number: very likely to be used
-
enabled
public abstract boolean enabled(Context context)
enabled.
-
initialize
public PLATFORM initialize(Context context) throws InitializeException
initialize.
- Specified by:
initialize
in interfaceLifecycle<PLATFORM extends Platform>
- Parameters:
context
- aContext
object.- Returns:
- a T object.
- Throws:
InitializeException
- if an error occurs during initialization.
-
shutdown
public PLATFORM shutdown(Context context) throws ShutdownException
shutdown.
-
getProviders
protected abstract String[] getProviders()
Getter for the field
providers
.- Returns:
- an array of
String
objects.
-
addProvider
protected void addProvider(Context context, String providerId) throws ProviderException
addProvider.
- Parameters:
context
- aContext
object.providerId
- aString
object.- Throws:
ProviderException
- if any.
-
-