Class CipObject
- java.lang.Object
-
- com.automation_pros.odva.cip.types.CipTree
-
- com.automation_pros.odva.cip.types.CipTreeCtx
-
- com.automation_pros.odva.cip.types.CipObject
-
- All Implemented Interfaces:
DataContext
- Direct Known Subclasses:
CipAttribute
,CipClass
,CipDevice
,CipInstance
,CipObjectMirror
public abstract class CipObject extends CipTreeCtx
A generic node in a CIP object hierarchy.The CIP specification describes a hierarchy of protocol objects, with a
Device
at the root of the tree, containingClass
objects providing management of various functional categories, andInstance
objects with the corresponding implementations. BothClass
objects andInstance
objects haveAttribute
objects with the runtime data used by the specified functionality.Objects in the hierarchy are addressed from parent to child with
Path Segment
objects, under the control of the specificservice
called on the rootDevice
.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected class
CipObject.FutureMultipleReply
-
Nested classes/interfaces inherited from class com.automation_pros.odva.cip.types.CipTree
CipTree.ChildMap
-
-
Field Summary
Fields Modifier and Type Field Description protected org.slf4j.Logger
iLogger
protected java.lang.String
name
-
Fields inherited from class com.automation_pros.odva.cip.types.CipTree
children, objEPath, parent, segment
-
Fields inherited from interface com.automation_pros.odva.cip.data.DataContext
emptyContext
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
CipObject(PathSegment seg)
protected
CipObject(PathSegment seg, CipObject parent)
protected
CipObject(PathSegment seg, CipObject parent, java.lang.String displayName)
protected
CipObject(CipObject parent)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description java.util.concurrent.ExecutorService
executor()
Services and packet handlers may need to perform extended calculations or communicate with other systems in an unbounded way.CipObject
getChild(PathSegment seg)
Lookup a child for a particular segment.CipDevice
getDevice()
CipObjects are expected to be organized as a tree, typically with a CipDevice at the root.java.lang.String
getDisplayName()
java.lang.String
getName()
CipObject
getParent()
boolean
isShutdown()
org.slf4j.Logger
logger()
To the extent possible, CIP objects should not fail other than in predefined ways with CIPExceptions.protected void
onReplacement(CipObject replacement)
When one object is replaced by another as a specific child segment of a specific parent, before the old object is shut down, this method provides an opportunity for the old object to interact with its replacement.void
removeChildSymbol(CipObject child)
java.util.concurrent.ScheduledExecutorService
scheduler()
CIP connections that produce data at intervals need a way to schedule the transmissions, and may need significant time to assemble the data needed.void
service(CipObject appContext, CipRequest request, int nesting)
Execute a CIP service on the object, using the request supplied.CipObject
setChild(CipTree child, PathSegment seg)
Assign a given CipTree as a child of this CipTree identified by a specific PathSegment.CipObject
setChildSymbol(CipObject child, CipObject oldChild)
Some CipObject types have symbolic names that are alternative means to select them via their parent or some other CipObject (typically the containing CipDevice).void
setName(java.lang.String name)
CipObject
setParent(CipTree parent)
Set or remove the parent of this CipTree, possibly removing this object from a previous parent before assigning to the new parent.void
shutdown()
java.lang.String
toString()
-
Methods inherited from class com.automation_pros.odva.cip.types.CipTreeCtx
getCtxDataImpl, getNamedDef, getParentDataCtx, getTypeByCRC, getTypeByName, getTypesImpl
-
Methods inherited from class com.automation_pros.odva.cip.types.CipTree
cleanup, entrySet, follow, getChildren, getEPath, getEPathImpl, getSegment, keySet, removeChild, setSegment
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface com.automation_pros.odva.cip.data.DataContext
fromEnum, getCtxData, getCtxDataOrNull, getTypes, makeHosted, makeUnhosted, toEnum
-
-
-
-
Constructor Detail
-
CipObject
protected CipObject(PathSegment seg)
-
CipObject
protected CipObject(CipObject parent)
-
CipObject
protected CipObject(PathSegment seg, CipObject parent)
-
CipObject
protected CipObject(PathSegment seg, CipObject parent, java.lang.String displayName)
-
-
Method Detail
-
isShutdown
public boolean isShutdown()
-
shutdown
public void shutdown()
-
setParent
public CipObject setParent(CipTree parent)
Description copied from class:CipTree
Set or remove the parent of this CipTree, possibly removing this object from a previous parent before assigning to the new parent. Override this method if additional housekeeping is required when assigning or removing parents.
-
getDevice
public CipDevice getDevice()
CipObjects are expected to be organized as a tree, typically with a CipDevice at the root. (CipDevices can have a parent too, if an implementer chooses to represent a virtual chassis that way.)By default, any CipObject will simply ask its parent for the device if asked for the device. A CipDevice returns itself.
- Returns:
- The CipDevice found in the parents of this object, if any.
-
onReplacement
protected void onReplacement(CipObject replacement)
When one object is replaced by another as a specific child segment of a specific parent, before the old object is shut down, this method provides an opportunity for the old object to interact with its replacement.- Parameters:
replacement
- The object taking this object's place.
-
getName
public java.lang.String getName()
-
setName
public void setName(java.lang.String name)
-
getDisplayName
public java.lang.String getDisplayName()
-
setChildSymbol
public CipObject setChildSymbol(CipObject child, CipObject oldChild)
Some CipObject types have symbolic names that are alternative means to select them via their parent or some other CipObject (typically the containing CipDevice). This helper is called on the holder of the symbolic children by the parent's setChild() override.This routine is given the old child from the non-symbol lookup in order to ensure that it's symbol, if different, is unregistered.
- Parameters:
child
- The new child for the given symbol.oldChild
- The old child of the parent retrieved with the non-symbol segment.- Returns:
- The previous child registered to the symbol, if any.
-
removeChildSymbol
public void removeChildSymbol(CipObject child)
-
getChild
public CipObject getChild(PathSegment seg)
Description copied from class:CipTree
Lookup a child for a particular segment.
-
setChild
public CipObject setChild(CipTree child, PathSegment seg)
Description copied from class:CipTree
Assign a given CipTree as a child of this CipTree identified by a specific PathSegment. If that path segment is already registered to a different child CipTree, replace it and return that old child.
-
service
public void service(CipObject appContext, CipRequest request, int nesting)
Execute a CIP service on the object, using the request supplied. Supply a reply to the request and/or throw an appropriate CipException. Replies are not required before this routine returns.
Direct service() calls MUST NOT BLOCK. Any operation that will take any significant time must be delegated to an executor. "Significant" may vary by application, but typically would be in the fractional millisecond range.
- Parameters:
appContext
- Root object for application path lookups. Generally aMirrored Device
from a port context.request
- What to do and where to reply. Services to be handled by child objects are to be passed to their service() method with nesting+1.nesting
- How many leading path segments items to skip when processing this request. Avoids copying the balance of an application path into a new request when passing a request to a child object.
-
executor
public java.util.concurrent.ExecutorService executor()
Services and packet handlers may need to perform extended calculations or communicate with other systems in an unbounded way. This can be a resource management problem for devices, so the host device must make an appropriate executor service available.The base CIP object implementation simply retrieves the executor from the object's parent, returning a null if there's no parent. This will break real applications, so CipDevice implementations must override this method to supply a real executor.
- Returns:
- An executor for general immediate task processing.
-
scheduler
public java.util.concurrent.ScheduledExecutorService scheduler()
CIP connections that produce data at intervals need a way to schedule the transmissions, and may need significant time to assemble the data needed. As with executor(), this may be a resource problem for devices, so the host device must make an appropriate scheduler service available. Objects with repetitive housekeeping tasks should also use this scheduler instead of creating their own threads.The base CIP object implementation simply retrieves the scheduler from the object's parent, returning a null if there's no parent. This will break real applications, so CipDevice implementations must override this method to supply a real scheduler.
- Returns:
- An executor for repeating task processing.
-
logger
public org.slf4j.Logger logger()
To the extent possible, CIP objects should not fail other than in predefined ways with CIPExceptions. Other exceptions should be caught and reported to the instance logger, then continue operating where possible.- Returns:
-
-