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 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: 93.1.0.0 (93.1.0.0)
Syntax
The CogJobManager type exposes the following members.
Constructors
| Name | Description | |
|---|---|---|
| CogJobManager |
Default CogJobManager constructor. The newly constructed CogJobManager has a default name in the form "CogJobManager#"
| |
| CogJobManager(String) |
CogJobManager constructor that takes a name.
|
Methods
| Name | Description | |
|---|---|---|
| CloneParameters |
CloneParamters. Internal use only.
| |
| CopyParameters |
CopyParameters. Internal use only.
| |
| CreateObjRef | Creates an object that contains all the relevant information required to generate a proxy used to communicate with a remote object. (Inherited from MarshalByRefObject.) | |
| Equals | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) | |
| FailureItem |
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.
| |
| FailureItem(Int32, Boolean) |
FailureItem(int,bool) allows any failure packet to be looked at and/or removed from the failure queue.
| |
| FailureQueueFlush |
Flush/clear the failure queue of all packets. This method cannot be called while the CogJobManager or any contained CogJobs are running.
| |
| GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) | |
| GetLifetimeService | Retrieves the current lifetime service object that controls the lifetime policy for this instance. (Inherited from MarshalByRefObject.) | |
| GetType | Gets the Type of the current instance. (Inherited from Object.) | |
| InitializeLifetimeService | Obtains a lifetime service object to control the lifetime policy for this instance. (Inherited from MarshalByRefObject.) | |
| IOPostLoadSetup |
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.
| |
| Job(Int32) |
Retrieve a references to the CogJob from the JobManager by name index.
| |
| Job(String) |
Retrieve a references to the CogJob from the JobManager by name.
| |
| JobAdd |
JobAdd is used to add CogJobs to the CogJobManager.
| |
| JobRemove(String) |
JobRemove is used to remove CogJobs by name from the CogJobManager.
| |
| JobRemove(CogJob) |
JobRemove is used to remove CogJobs from the CogJobManager.
| |
| OnDeserialization |
Serialization Callback. Internal use only.
| |
| RequestHeartbeat |
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.
| |
| Reset |
Reset puts the CogJobManager into its initial state. If there are any contained CogJobs, they are shutdown and removed.
| |
| ResumeAndRaiseChangedEvent |
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.) | |
| Run |
Run the CogJobManager and any contained CogJobs just once. See CogJob.Run() for additional information regarding the running of CogJobs.
| |
| RunContinuous |
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.
| |
| Shutdown |
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.
| |
| Stop |
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.
| |
| StopHeartbeat | ||
| StreamInput |
Call this function to retrieve an interface, ICogIOTCPIP, of a QB TCP/IP device used to receive an input message.
| |
| SuspendChangedEvent |
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.) | |
| timeBeginPeriod | ||
| timeEndPeriod | ||
| ToString | Returns a String that represents the current Object. (Inherited from Object.) | |
| UserQueueFlush |
Flush/clear the user queue of all packets. This method cannot be called while the CogJobManager or any contained CogJobs are running.
| |
| UserResult |
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.
| |
| UserResult(Int32, Boolean) |
UserResult(int,bool) allows any result packet to be looked at and/or removed from the user queue.
|
Fields
| Name | Description | |
|---|---|---|
| SfDiscreteQueueCapacity | IOQueueCapacity State Flag | |
| SfFailureLogModes | Failure Log Modes State Flag | |
| SfFailureQueueCapacity | FailureQueueCapacity State Flag | |
| SfGarbageCollection | Garbage Collection State Flag | |
| SfGarbageCollectionInterval | Garbage Collection Interval State Flag | |
| SfImageQueueOverflowAction | Handle Image Queue Overflow State Flag | |
| SfIOClearQueueOnStop | Clear I/O Queue When Stop State Flag | |
| SfIOClientAutoReconnect | Client auto-reconnect State Flag | |
| SfIOEnable | IOEnable State Flag | |
| SfIOErrorAction | Handle I/O Error State Flag | |
| SfIOHeartbeat | IOHeartbeat State Flag | |
| SfJobsRunningState | Jobs Running State State Flag | |
| SfName | Name State Flag | |
| SfOperatingMode | Operating Mode State Flag | |
| SfProcessingModel | Processing Model State Flag | |
| SfProcessorCount | Processor Count State Flag | |
| SfRealTimeQueueCapacity | RealTimeQueueCapacity State Flag | |
| SfState | State State Flag | |
| SfTotalDependentIterations | Total Dependent Iterations State Flag | |
| SfTotalVisionToolAccepts | Total Vision Tool Accepts State Flag | |
| SfTotalVisionToolErrors | Total Vision Tool Errors State Flag | |
| SfTotalVisionToolRejects | Total Vision Tool Rejects State Flag | |
| SfTotalVisionToolWarnings | Total Vision Tool Warnings State Flag | |
| SfUserQueueCapacity | UserQueueCapacity State Flag | |
| SfUserQueueResultCreation | UserQueueResultCreation State Flag | |
| SfVisionTool | Vision Tool State Flag | |
| SfVisionToolRunStatus | Vision Tool Run Status State Flag |
Properties
| Name | Description | |
|---|---|---|
| ChangedEventSuspended |
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.) | |
| FailureLogModes |
Get or set the vision tool run status result code which will cause an image to be placed into the failure queue.
| |
| FailureQueueCapacity |
Get or set the failure queue capacity.
| |
| FailureQueueCount |
Read-only property which returns the number of failure packets in the failure queue.
| |
| GarbageCollection |
Get or set if the CogJobManager should do garbage collection.
| |
| GarbageCollectionInterval |
Get or set the garbage collection interval.
| |
| HasChanged | (Inherited from CogSerializableChangedEventBase.) | |
| ImageQueueOverflowAction |
Get or set the running state of the CogJob or CogJobManager when the image queue overflowed event is fired by a job.
| |
| IOClearQueueOnStop |
Determines whether or not the I/O queue contents must be cleared when the job stops.
| |
| IOClientAutoReconnect |
Internal use only.
| |
| IODeviceList |
Returns CogIODeviceList. The user can use this class to retrieve
a reference to a CogIODevice derived object, which is created by CogJobManager initially.
| |
| IOEnable |
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.
| |
| IOErrorAction |
Get or set the running state of the CogJob or CogJobManager when an I/O error occurs.
| |
| IOErrorLog |
This property returns a collection of I/O runtime errors.
Cognex Internal Use Only.
| |
| IOHeartbeat |
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.
| |
| IOInfoList |
Returns the CogIOInfoList, which is used to map I/O signals to physical
devices in the system. Cognex internal use only
| |
| IOQueueCapacity |
Get or set the discrete queue capacity.
| |
| JobCount |
Get the number of CogJobs contained within the CogJobManager.
| |
| JobsRunningState |
Read-only property to get the state of all CogJobs in the CogJobManager.
| |
| Name |
Get or set the name of the CogJobManager.
| |
| OperatingMode |
Get or set the operating mode of the CogJobManager.
| |
| OwnedDependent |
Read-only property to retrieve the CogJobManagerDependent object.
| |
| OwnedIndependent |
Read-only property to retrieve the CogJobManagerIndependent object.
| |
| PersistedApplicationState |
Get the application state that was in effect when this job manager was last serialized to a file.
| |
| StateFlags |
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.) | |
| UserData |
UserData. Internal use only.
| |
| UserQueueCapacity |
Get or set the user queue capacity.
| |
| UserQueueCount |
Read-only property which returns the number of result packets in the user queue.
| |
| UserQueueResultCreation |
Get or set the user queue result creation behavior.
| |
| VisionToolMTEnable |
Get or set the vision tools multi-threading enable.
| |
| VisionToolMTThreadCount |
Get or set the number of threads that all multi-threaded vision tools will use if the ThreadCountMode is set to UserSpecified.
| |
| VisionToolMTThreadCountMode |
Get or set the thread count mode of the vision tool multi-threading mechanism.
|
Events
| Name | Description | |
|---|---|---|
| Changed |
This event is raised when one or more parts of the object's state may
have changed.
(Inherited from CogSerializableChangedEventBase.) | |
| FailureItemAvailable |
Raised when a new item is available in the Failure Queue.
| |
| FailureItemRemoved |
Raised when an item is removed from the Failure Queue.
| |
| FailureQueueFlushed |
Raised when the failure queue is flushed
| |
| FailureQueueOverflowed |
Raised when the failure queue overflows.
| |
| IOError |
Raised when any I/O error occurs.
| |
| JobAdded |
Raised when a job is added to the JobManager
| |
| JobRemoved |
Raised when a job is removed from the JobManager
| |
| ResetComplete |
Raised when a job is reset.
| |
| Stopped |
Raised when all jobs are completely stopped.
| |
| UserQueueFlushed |
Raised when the user queue is flushed.
| |
| UserQueueOverflowed |
Raised when the user queue overflows.
| |
| UserResultAvailable |
Raised when a new result is available in the User Queue.
| |
| UserResultRemoved |
Raised when a result is removed from the User Queue.
|
Remarks
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 ModuleSee Also