Class CipObject

    • Field Detail

      • name

        protected java.lang.String name
      • iLogger

        protected org.slf4j.Logger iLogger
    • 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.
        Overrides:
        setParent in class CipTree
        Parameters:
        parent - The new parent of this object.
        Returns:
        The object replaced by this object in the parent, if any.
      • 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)
      • 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.
        Overrides:
        setChild in class CipTree
        Parameters:
        child - The CipTree to register.
        seg - The Path Segment that identifies this child.
        Returns:
        The replaced CipTree, if any.
      • 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 a Mirrored 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:
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class CipTree