CogJobManager ClassCognex VisionPro 9.7
The CogJobManager class is the toplevel class of QuickBuild. It is responsible for managing and providing global information to CogJobs. Shutdown  must be called when you are done using the CogJobManager object.
Inheritance Hierarchy

System Object
  System MarshalByRefObject
    Cognex.VisionPro.Implementation CogObjectBase
      Cognex.VisionPro.Implementation CogSerializableObjectBase
        Cognex.VisionPro.Implementation CogSerializableChangedEventBase
          Cognex.VisionPro.QuickBuild CogJobManager

Namespace: Cognex.VisionPro.QuickBuild
Assembly: Cognex.VisionPro.QuickBuild.Core (in Cognex.VisionPro.QuickBuild.Core.dll) Version: 73.0.0.0 (73.0.0.0)
Syntax

[SerializableAttribute]
public sealed class CogJobManager : CogSerializableChangedEventBase, 
	IDeserializationCallback

The CogJobManager type exposes the following members.

Constructors

  NameDescription
Public methodCogJobManager 
Default CogJobManager constructor. The newly constructed CogJobManager has a default name in the form "CogJobManager#"
Public methodCogJobManager(String)
CogJobManager constructor that takes a name.
Top
Methods

  NameDescription
Public methodCloneParameters
CloneParamters. Internal use only.
Public methodCopyParameters
CopyParameters. Internal use only.
Public methodCreateObjRef
Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object.
(Inherited from MarshalByRefObject.)
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Public methodFailureItem 
FailureItem() removes and returns the oldest failure packet from the failure queue. FailureItem() will return null if the failure queue is empty. This method may be called while the CogJobManager or CogJobs are running.
Public methodFailureItem(Int32, Boolean)
FailureItem(int,bool) allows any failure packet to be looked at and/or removed from the failure queue.
Public methodFailureQueueFlush
Flush/clear the failure queue of all packets. This method cannot be called while the CogJobManager or any contained CogJobs are running.
Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetLifetimeService
Retrieves the current lifetime service object that controls the lifetime policy for this instance.
(Inherited from MarshalByRefObject.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Public methodInitializeLifetimeService
Obtains a lifetime service object to control the lifetime policy for this instance.
(Inherited from MarshalByRefObject.)
Public methodIOPostLoadSetup
QuickBuild is unable to monitor Online input command after it starts up because the default IOEnable mode is always set to false (offline mode). However, Online and Emergency Stop input signals should be still monitored even if in offline mode. The user must call this routine to ask CogJobManager to monitor those input signals that must be monitored in offline mode. This function should also be called after the user successfully loads a QuickBuild application.
Public methodJob(Int32)
Retrieve a references to the CogJob from the JobManager by name index.
Public methodJob(String)
Retrieve a references to the CogJob from the JobManager by name.
Public methodJobAdd
JobAdd is used to add CogJobs to the CogJobManager.
Public methodJobRemove(String)
JobRemove is used to remove CogJobs by name from the CogJobManager.
Public methodJobRemove(CogJob)
JobRemove is used to remove CogJobs from the CogJobManager.
Public methodOnDeserialization
Serialization Callback. Internal use only.
Public methodRequestHeartbeat
The user only needs to call this routine once. Once it is called, Heartbeat is generated whenever the following two conditions are met--IOEnable is true and IOHeartbeat is valid.
Public methodReset
Reset puts the CogJobManager into its initial state. If there are any contained CogJobs, they are shutdown and removed.
Public methodResumeAndRaiseChangedEvent
Re-enables raising of the Changed event after SuspendChangedEvent has been called, and raises the Changed event if the ChangedEventSuspended count is reduced to zero and any changes were made while events were suspended. Must be called once for each call to SuspendChangedEvent.
(Inherited from CogSerializableChangedEventBase.)
Public methodRun
Run the CogJobManager and any contained CogJobs just once. See CogJob.Run() for additional information regarding the running of CogJobs.
Public methodRunContinuous
Run the CogJobManager and all contained CogJobs in a continuous loop. This CogJobManager will not stop running until Stop() is called. See CogJob.RunContinuous() for additional information regarding the running of CogJobs.
Public methodShutdown
Shutdown terminates all internal threads inside the CogJobManager and calls shutdown on all contained CogJobs. Shutdown must be called to allow the CogJobManager to cleanly terminate. After the CogJobManager and all contained CogJobs have shutdown, it cannot be run again. Do not persist (save) a shutdown CogJobManager, since it cannot be run again, even after de-persisting it.
Public methodStop
Stop forces the CogJobManager and any contained CogJobs to stop running. Only when the CogJobManager is running continuously can it be stopped. This method returns immediately and does not wait. Once the CogJobManager and any contained jobs have completely stopped, the Stopped event will be fired. If the CogJobManager is not running, this method has no effect.
Public methodStopHeartbeat
Public methodStreamInput
Call this function to retrieve an interface, ICogIOTCPIP, of a QB TCP/IP device used to receive an input message.
Public methodSuspendChangedEvent
Temporarily suspends the raising of the Changed event. May be called more than once, and a corresponding call to ResumeAndRaiseChangedEvent must be made for each call to SuspendChangedEvent.
(Inherited from CogSerializableChangedEventBase.)
Public methodStatic membertimeBeginPeriod
Public methodStatic membertimeEndPeriod
Public methodToString
Returns a String that represents the current Object.
(Inherited from Object.)
Public methodUserQueueFlush
Flush/clear the user queue of all packets. This method cannot be called while the CogJobManager or any contained CogJobs are running.
Public methodUserResult 
UserResult() removes and returns the oldest result packet from the user queue. UserResult() will return null if the user queue is empty. This method may be called while the CogJobManager or CogJobs are running.
Public methodUserResult(Int32, Boolean)
UserResult(int,bool) allows any result packet to be looked at and/or removed from the user queue.
Top
Fields

  NameDescription
Public fieldStatic memberSfDiscreteQueueCapacity
IOQueueCapacity State Flag
Public fieldStatic memberSfFailureLogModes
Failure Log Modes State Flag
Public fieldStatic memberSfFailureQueueCapacity
FailureQueueCapacity State Flag
Public fieldStatic memberSfGarbageCollection
Garbage Collection State Flag
Public fieldStatic memberSfGarbageCollectionInterval
Garbage Collection Interval State Flag
Public fieldStatic memberSfImageQueueOverflowAction
Handle Image Queue Overflow State Flag
Public fieldStatic memberSfIOClearQueueOnStop
Clear I/O Queue When Stop State Flag
Public fieldStatic memberSfIOClientAutoReconnect
Client auto-reconnect State Flag
Public fieldStatic memberSfIOEnable
IOEnable State Flag
Public fieldStatic memberSfIOErrorAction
Handle I/O Error State Flag
Public fieldStatic memberSfIOHeartbeat
IOHeartbeat State Flag
Public fieldStatic memberSfJobsRunningState
Jobs Running State State Flag
Public fieldStatic memberSfName
Name State Flag
Public fieldStatic memberSfOperatingMode
Operating Mode State Flag
Public fieldStatic memberSfProcessingModel
Processing Model State Flag
Public fieldStatic memberSfProcessorCount
Processor Count State Flag
Public fieldStatic memberSfRealTimeQueueCapacity
RealTimeQueueCapacity State Flag
Public fieldStatic memberSfState
State State Flag
Public fieldStatic memberSfTotalDependentIterations
Total Dependent Iterations State Flag
Public fieldStatic memberSfTotalVisionToolAccepts
Total Vision Tool Accepts State Flag
Public fieldStatic memberSfTotalVisionToolErrors
Total Vision Tool Errors State Flag
Public fieldStatic memberSfTotalVisionToolRejects
Total Vision Tool Rejects State Flag
Public fieldStatic memberSfTotalVisionToolWarnings
Total Vision Tool Warnings State Flag
Public fieldStatic memberSfUserQueueCapacity
UserQueueCapacity State Flag
Public fieldStatic memberSfUserQueueResultCreation
UserQueueResultCreation State Flag
Public fieldStatic memberSfVisionTool
Vision Tool State Flag
Public fieldStatic memberSfVisionToolRunStatus
Vision Tool Run Status State Flag
Top
Properties

  NameDescription
Public propertyChangedEventSuspended
If nonzero, indicates that the raising of the Changed event has been suspended. This value is incremented when SuspendChangedEvent is called and decremented when ResumeAndRaiseChangedEvent is called.
(Inherited from CogSerializableChangedEventBase.)
Public propertyFailureLogModes
Get or set the vision tool run status result code which will cause an image to be placed into the failure queue.
Public propertyFailureQueueCapacity
Get or set the failure queue capacity.
Public propertyFailureQueueCount
Read-only property which returns the number of failure packets in the failure queue.
Public propertyGarbageCollection
Get or set if the CogJobManager should do garbage collection.
Public propertyGarbageCollectionInterval
Get or set the garbage collection interval.
Public propertyHasChanged (Inherited from CogSerializableChangedEventBase.)
Public propertyImageQueueOverflowAction
Get or set the running state of the CogJob or CogJobManager when the image queue overflowed event is fired by a job.
Public propertyIOClearQueueOnStop
Determines whether or not the I/O queue contents must be cleared when the job stops.
Public propertyIOClientAutoReconnect
Internal use only.
Public propertyIODeviceList
Returns CogIODeviceList. The user can use this class to retrieve a reference to a CogIODevice derived object, which is created by CogJobManager initially.
Public propertyIOEnable
When this property is set to true, Cognex handles all I/O operations. Otherwise, the user is responsible for fetching results from the real-time queue and processing I/O operations. Note: The user must not modify input line commands when IOEnable is true.
Public propertyIOErrorAction
Get or set the running state of the CogJob or CogJobManager when an I/O error occurs.
Public propertyIOErrorLog
This property returns a collection of I/O runtime errors. Cognex Internal Use Only.
Public propertyIOHeartbeat
The CogJobManager generates the heartbeat signal while it is running using the data provided by IOHeartbeat. The caller must enable the output line before running any of the jobs.
Public propertyIOInfoList
Returns the CogIOInfoList, which is used to map I/O signals to physical devices in the system. Cognex internal use only
Public propertyIOQueueCapacity
Get or set the discrete queue capacity.
Public propertyJobCount
Get the number of CogJobs contained within the CogJobManager.
Public propertyJobsRunningState
Read-only property to get the state of all CogJobs in the CogJobManager.
Public propertyName
Get or set the name of the CogJobManager.
Public propertyOperatingMode
Get or set the operating mode of the CogJobManager.
Public propertyOwnedDependent
Read-only property to retrieve the CogJobManagerDependent object.
Public propertyOwnedIndependent
Read-only property to retrieve the CogJobManagerIndependent object.
Public propertyPersistedApplicationState
Get the application state that was in effect when this job manager was last serialized to a file.
Public propertyStateFlags
Returns the complete set of state flags supported on this object. The flags may be indexed by name as shown in the following C# code snippet: if (changedObject.StateFlags["Color"] & eventArgs.StateFlags) { ... }
(Inherited from CogSerializableChangedEventBase.)
Public propertyUserData
UserData. Internal use only.
Public propertyUserQueueCapacity
Get or set the user queue capacity.
Public propertyUserQueueCount
Read-only property which returns the number of result packets in the user queue.
Public propertyUserQueueResultCreation
Get or set the user queue result creation behavior.
Public propertyStatic memberVisionToolMTEnable
Get or set the vision tools multi-threading enable.
Public propertyStatic memberVisionToolMTThreadCount
Get or set the number of threads that all multi-threaded vision tools will use if the ThreadCountMode is set to UserSpecified.
Public propertyStatic memberVisionToolMTThreadCountMode
Get or set the thread count mode of the vision tool multi-threading mechanism.
Top
Events

  NameDescription
Public eventChanged
This event is raised when one or more parts of the object's state may have changed.
(Inherited from CogSerializableChangedEventBase.)
Public eventFailureItemAvailable
Raised when a new item is available in the Failure Queue.
Public eventFailureItemRemoved
Raised when an item is removed from the Failure Queue.
Public eventFailureQueueFlushed
Raised when the failure queue is flushed
Public eventFailureQueueOverflowed
Raised when the failure queue overflows.
Public eventIOError
Raised when any I/O error occurs.
Public eventJobAdded
Raised when a job is added to the JobManager
Public eventJobRemoved
Raised when a job is removed from the JobManager
Public eventResetComplete
Raised when a job is reset.
Public eventStopped
Raised when all jobs are completely stopped.
Public eventUserQueueFlushed
Raised when the user queue is flushed.
Public eventUserQueueOverflowed
Raised when the user queue overflows.
Public eventUserResultAvailable
Raised when a new result is available in the User Queue.
Public eventUserResultRemoved
Raised when a result is removed from the User Queue.
Top
Remarks

Shutdown  must be called when you are done using the CogJobManager object. Failure to call Shutdown  will cause the CogJobManager to hang.
Examples

using System;
using System.Threading;

using Cognex.VisionPro;
using Cognex.VisionPro.QuickBuild;

public class ImplementCJM
{
  private CogJobManager myJobManager;
  private static Semaphore semaphore;

  private void myJobManager_Stopped(object sender, EventArgs e)
  {
    // Signal the main thread that the CogJobManager has now stopped
    semaphore.Release();
  }

  private void myJobManager_UserResultAvailable(object sender, EventArgs e)
  {
     // Add code here to handle UserResultAvailable Event.
  }

  // Add Stop and UserResultAvailable Event Handlers. 
  private void addEventHandler()
  {
    myJobManager.Stopped += new CogJobManager.CogJobManagerStoppedEventHandler(myJobManager_Stopped);
    myJobManager.UserResultAvailable += new CogJobManager.CogUserResultAvailableEventHandler(myJobManager_UserResultAvailable);
  }

  // Remove Stop and UserResultAvailable Event Handlers. 
  private void removeEventHandler()
  {
    myJobManager.Stopped -= new CogJobManager.CogJobManagerStoppedEventHandler(myJobManager_Stopped);
    myJobManager.UserResultAvailable -= new CogJobManager.CogUserResultAvailableEventHandler(myJobManager_UserResultAvailable);
  }

  public static void Main()
  {
    // Create a semaphore that can satisfy one concurrent request. 
    // Use an initial count of zero, so that the entire semaphore count is initially 
    // owned by the main program thread.
    semaphore = new Semaphore(0, 1);
    ImplementCJM implementCJM = new ImplementCJM();

    // Create a CogJobManager object from a saved application vpp file.
    implementCJM.myJobManager = (CogJobManager)CogSerializer.LoadObjectFromFile(@"C:\Program Files\Cognex\VisionPro\Samples\Programming\QuickBuild\advancedAppOne.vpp");

    // Flush queues.
    implementCJM.myJobManager.UserQueueFlush();
    implementCJM.myJobManager.FailureQueueFlush();

    implementCJM.addEventHandler();

    // Run CogJobManager once.
    implementCJM.myJobManager.Run();

    // Wait for the CogJobManager to stop
    semaphore.WaitOne();

    System.Console.WriteLine("The CogJobManager has stopped");

    // Remove handlers, and shut down the CogJobManager.
    implementCJM.removeEventHandler();
    implementCJM.myJobManager.Shutdown();
    }
  }
}
Imports System.Threading

Imports Cognex.VisionPro
Imports Cognex.VisionPro.QuickBuild

Module ImplementCJM

  Dim myJobManager As CogJobManager
  Dim semaphore As Semaphore

  Private Sub myCogJobManager_Stopped(ByVal sender As System.Object, ByVal e As CogJobManagerActionEventArgs)
    ' Signal the main thread that the CogJobManager has now stopped
    semaphore.Release()
  End Sub

  Private Sub myCogJobManager_UserResultAvailable(ByVal sender As System.Object, ByVal e As CogJobManagerActionEventArgs)
    ' Add code here to handle UserResultAvailable Event.
  End Sub

  Private Sub addEventHandler()
    AddHandler myJobManager.Stopped, AddressOf myCogJobManager_Stopped
    AddHandler myJobManager.UserResultAvailable, AddressOf myCogJobManager_UserResultAvailable
  End Sub

  Private Sub removeEventHandler()
    RemoveHandler myJobManager.Stopped, AddressOf myCogJobManager_Stopped
    RemoveHandler myJobManager.UserResultAvailable, AddressOf myCogJobManager_UserResultAvailable
  End Sub

  Sub Main()
    semaphore = New Semaphore(0, 1)

    ' Create a CogJobManager object from a saved application vpp file.
    myJobManager = CType(CogSerializer.LoadObjectFromFile("C:\Program Files\Cognex\VisionPro\Samples\Programming\QuickBuild\advancedAppOne.vpp"), CogJobManager)

    ' Flush queues.
    myJobManager.UserQueueFlush()
    myJobManager.FailureQueueFlush()

    addEventHandler()

    ' Run CogJobManager once.
    myJobManager.Run()

    ' Wait for the CogJobManager to stop
    semaphore.WaitOne()

    System.Console.WriteLine("The CogJobManager has stopped")

    ' Remove handlers, and shut down the CogJobManager.
    removeEventHandler()
    myJobManager.Shutdown()

    ' Shutdown the CogJobManager.
    myJobManager.Shutdown()
  End Sub

End Module
See Also