public class Scene extends java.lang.Object implements java.lang.Iterable<ResourceAction>
Resources to a state defined by the user.
User can manually trigger scene or add scene as a scene action in a rule.
Simply, scene is a list of Commands encapsulated using ResourceActions,
which will be executed on calling execute()
Scene class acts as blueprint for scenes present in a Network.
User can have any scenes as a part of his/her network.
Scenes can be added using
Network.createScene(String, Network.NetworkManagementStatusListener),
removed using Network.deleteScene(Scene, Network.NetworkManagementStatusListener),
modified using Network.SaveSceneResourceActions by the user.
Rule.getSceneActions()| Modifier and Type | Field and Description |
|---|---|
static int |
DEFAULT_SCENE_ID
Default ID of a scene.
|
| Modifier | Constructor and Description |
|---|---|
protected |
Scene(int sceneId,
Network parent)
The constructor for the current class.
|
| Modifier and Type | Method and Description |
|---|---|
void |
addResourceActions(ResourceAction[] resourceActions,
Network.NetworkManagementStatusListener listener)
A function to add
ResourceAction's to scene. |
boolean |
containsResourceAction(int resourceActionId)
A function to check if a
ResourceAction exists with given ID. |
void |
execute()
A function to execute the scene.
|
int |
getId()
A function to get the ID of the scene.
|
java.lang.String |
getMetadata()
A function to return the metadata of the scene.
|
java.lang.String |
getName()
A function to get the name of the scene.
|
Network |
getParent()
A function to get the parent network of the current scene.
|
ResourceAction |
getResourceAction(int resourceActionId)
A function to get
ResourceAction given the ID. |
java.util.Map<java.lang.Integer,ResourceAction> |
getResourceActionMap()
A function to get the map of
ResourceAction's and there ID's. |
int |
hashCode() |
protected void |
internalAddResourceAction(ResourceAction resourceAction)
A function that would be triggered when
ResourceAction is added to scene. |
protected void |
internalMarkAsReady()
A function that would be triggered to mark this scene as ready.
|
protected void |
internalRemoveResourceAction(int resourceActionId)
A function that would be triggered when
ResourceAction is remove from scene. |
protected void |
internalSetMetadata(java.lang.String metadata)
A function that would be triggered when
metadata is updated. |
protected void |
internalSetName(java.lang.String name)
A function that would be triggered when
name is updated. |
protected void |
internalSetParent(Network parent)
A function would be triggered when parent of the scene is updated.
|
protected void |
internalUpdateResourceAction(ResourceAction resourceAction)
A function that would be triggered when a
ResourceAction is updated. |
boolean |
isReady()
A function suggesting if the scene is created from
NativeCallbacks.sceneInfoCallback(boolean, java.lang.String, int, java.lang.String, java.lang.String, java.lang.String[], java.lang.Object)
or retrieved from cache. |
java.util.Iterator<ResourceAction> |
iterator() |
void |
removeResourceActions(ResourceAction[] resourceActions,
Network.NetworkManagementStatusListener listener)
A function to remove
ResourceAction's from scene. |
void |
saveResourceActions(ResourceAction[] resourceActions,
Network.NetworkManagementStatusListener listener)
A function to save
ResourceAction's to the scene. |
void |
setMetadata(java.lang.String metadata,
Network.NetworkManagementStatusListener listener)
A function to set the metadata of the current scene.
|
void |
setName(java.lang.String name,
Network.NetworkManagementStatusListener listener)
A function to set the name of the scene.
|
java.lang.String |
toString() |
void |
updateResourceActions(int[] resourceActionIds,
ResourceAction[] resourceActions,
Network.NetworkManagementStatusListener listener)
A function to update
ResourceAction's of the scene. |
public static final int DEFAULT_SCENE_ID
protected Scene(int sceneId,
Network parent)
sceneId - The unique identifier of the objectparent - The parent network of the scenepublic int getId()
public java.lang.String getName()
public void setName(java.lang.String name,
Network.NetworkManagementStatusListener listener)
johnNetwork
.setName(newName,
(commandStatus, throwable) -> {
if (null != throwable) {
// client specific code
}
});
name - The name that has to be assignedlistener - The listener that will be triggered with
CallbacksInterface.networkManagementCommandCallback(buzz.getcoco.iot.Network, buzz.getcoco.iot.CommandResponse<?>)public void addResourceActions(ResourceAction[] resourceActions, Network.NetworkManagementStatusListener listener)
ResourceAction's to scene.
Let r1, r2, r2 be three ResourceAction's that are to be added.
scene.addResourceAction(new ResourceAction[]{r1, r2, r3},
(response, throwable) -> {
if (null != throwable) {
// client specific code.
}
});
resourceActions - Resource actions that are to be added to this scene.listener - The listener that will be triggered
#networkManagementCommandCallback(Network, CommandResponse)public void updateResourceActions(int[] resourceActionIds,
ResourceAction[] resourceActions,
Network.NetworkManagementStatusListener listener)
ResourceAction's of the scene.resourceActionIds - Ids of resource action that are to be updated.resourceActions - Resource actions that are to be updated.listener - The listener that will be triggered
#networkManagementCommandCallback(Network, CommandResponse).public void saveResourceActions(ResourceAction[] resourceActions, Network.NetworkManagementStatusListener listener)
ResourceAction's to the scene.resourceActions - Resource actions that are to be saved.listener - The listener that will be triggeredpublic void removeResourceActions(ResourceAction[] resourceActions, Network.NetworkManagementStatusListener listener)
ResourceAction's from scene.
Let r1, r2, r2 be three ResourceAction's that are to be removed.
scene.removeResourceAction(new ResourceAction[]{r1, r2, r2},
(command, throwable) -> {
if (null != )
});
resourceActions - Resource actions that are to be removedlistener - The listener that will be triggered
(Network, CommandResponse)public void setMetadata(java.lang.String metadata,
Network.NetworkManagementStatusListener listener)
scene.setMetaData(metaData, (commandResponse, throwable) -> {
if (null != throwable) {
// client specific code.
}
});
metadata - The metadata to be assignedlistener - The listener that will be triggered with
CallbacksInterface.networkManagementCommandCallback(buzz.getcoco.iot.Network, buzz.getcoco.iot.CommandResponse<?>)public void execute()
java.lang.RuntimeException - on connection failures and other similar errorspublic java.lang.String getMetadata()
public Network getParent()
public java.util.Map<java.lang.Integer,ResourceAction> getResourceActionMap()
ResourceAction's and there ID's.public ResourceAction getResourceAction(int resourceActionId)
ResourceAction given the ID.resourceActionId - ID of the ResourceActionResourceAction associated with the ID.protected void internalAddResourceAction(ResourceAction resourceAction)
ResourceAction is added to scene.resourceAction - Resource action that is added.public boolean containsResourceAction(int resourceActionId)
ResourceAction exists with given ID.resourceActionId - ID of the ResourceAction that needs to be looked up.ResourceAction exists with given ID.protected void internalUpdateResourceAction(ResourceAction resourceAction)
ResourceAction is updated.resourceAction - ResourceAction that is updated.protected void internalRemoveResourceAction(int resourceActionId)
ResourceAction is remove from scene.resourceActionId - ID of the resource action.public final int hashCode()
hashCode in class java.lang.Objectpublic boolean isReady()
NativeCallbacks.sceneInfoCallback(boolean, java.lang.String, int, java.lang.String, java.lang.String, java.lang.String[], java.lang.Object)
or retrieved from cache.NativeCallbacks.sceneInfoCallback(boolean, String,
int, String, String, String[], Object).protected void internalSetName(java.lang.String name)
name is updated.name - Updated name of the scene.protected void internalSetMetadata(java.lang.String metadata)
metadata is updated.metadata - Updated metadata of scene.protected void internalSetParent(Network parent)
parent - Network which is the parent of the scene.protected void internalMarkAsReady()
public java.lang.String toString()
toString in class java.lang.Objectpublic java.util.Iterator<ResourceAction> iterator()
iterator in interface java.lang.Iterable<ResourceAction>