- 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 voidaddProvider(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 booleanenabled(Context context)enabled.protected abstract String[]getProviders()Getter for the fieldproviders.PLATFORMinitialize(Context context)initialize.abstract intpriority()The priority in which platforms must be handled.<T extends Provider>
Tprovider(Class<T> providerClass)provider.Map<IOType,Provider>providers()providers.PLATFORMshutdown(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:
providerin interfacePlatform- Specified by:
providerin interfacecom.pi4j.internal.ProviderProvider- Type Parameters:
T- a T object.- Parameters:
providerClass- aClassobject.- 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:
initializein interfaceLifecycle<PLATFORM extends Platform>- Parameters:
context- aContextobject.- 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
Stringobjects.
-
addProvider
protected void addProvider(Context context, String providerId) throws ProviderException
addProvider.
- Parameters:
context- aContextobject.providerId- aStringobject.- Throws:
ProviderException- if any.
-
-