CogPrio ClassCognex VisionPro 9.7
CogPrio is used to configure and interact with the precision I/O event system.
Inheritance Hierarchy

System Object
  System MarshalByRefObject
    Cognex.VisionPro.Implementation CogObjectBase
      Cognex.VisionPro.Implementation CogSerializableObjectBase
        Cognex.VisionPro.Implementation CogSerializableChangedEventBase
          Cognex.VisionPro.Comm.Implementation.Internal CogPrioEventConfigObjectBase
            Cognex.VisionPro.Comm CogPrio

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

public sealed class CogPrio : CogPrioEventConfigObjectBase, 
	ICogPrioEventScheduler, IDisposable

The CogPrio type exposes the following members.

Methods

  NameDescription
Public methodCreateDefaultEvents
Create and return set of default precision i/o events for this hardware.

Adds an "InputChanged_" event for each input line. The event for input line 0 is named "InputChanged_0" and so on... The input events are _CAUSED_ by any signal transition on the dedicated input line. The input events are not configured with a _RESPONSE_.

Adds an "PulseOutput_" event for each output line. The event for output line 0 is named "PulseOutput_0" and so on... The output events _RESPOND_ by pulsing the the dedicated output line high for 10.0ms. The output events are not configured with a _CAUSE_ and only occcur as a result direct user scheduling.

This method creates and returns a collection of events. Note that you need to assign the returned collection of default events to the Comm Card Prio object (i.e. mPrio.Events = mPrio.CreateDefaultEvents()) if you wish to actually configure and use these events on the hardware.

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 methodDisableEvents
Disables all configured events from firing.
Public methodDispose
Public methodEnableEvents
Enables the configured events.
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Public methodGetBanks
Returns an array of the supported I/O banks of the current hardware.
Public methodGetBankType
Returns the type (input, output, etc...) of a given I/O bank
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 methodGetNumLines
Returns the number of I/O lines the hardware supports in the given bank.
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 methodIsBankSupported
Returns true if the hardware supports the given I/O bank.
Public methodIsInputBank
Returns true if the bank is an input bank.
Public methodIsLineSupported
Returns true if the hardware supports the given I/O bank.
Public methodIsOutputBank
Returns true if the bank is an output bank.
Public methodReadState
Get the current state of the I/O interface.
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 methodSetEncoderCount
Set the encoder count.

Note that current hardware platforms only report 32-bits of encoder data. This means that, depending on the hardware, the encoder may rollover (go back to 0) when the encoder count reaches 4294967295, (0xFFFFFFFF).

On platforms like this only the lower 32 bits of the encoderCount argument are used when calling SetEncoderCount()... So don't try to set the encoder count to a negative number or a number greater than 4294967295.

Public methodSetOutput
Set an output line.
Public methodSetOutputs(CogPrioBankConstants, Int64)
Set multiple output lines at the same time.
Public methodSetOutputs(CogPrioBankConstants, Int64, Int64)
Set multiple output lines at the same time.
Public methodSetValid 
Cognex Internal Use Only
(Inherited from CogPrioEventConfigObjectBase.)
Public methodSetValid(Boolean,  String )
Cognex Internal Use Only
(Inherited from CogPrioEventConfigObjectBase.)
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 methodToString
Returns a String that represents the current Object.
(Inherited from Object.)
Top
Fields

  NameDescription
Public fieldStatic memberSfDebounceDuration
This bit will be set in the EventArgs of a Changed event every time the value returned by DebounceDuration may have changed.
Public fieldStatic memberSfEvents
This bit will be set in the EventArgs of a Changed event every time the value returned by Events may have changed.
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 propertyClockFrequency
Get the frequency of the clock. Use this value to convert clock ticks to wall clock time.
Public propertyDebounceDuration
Gets or sets the debounce duration in milliseconds for all input lines.
Public propertyEvents
A collection of CogPrioEvent. Add and configure events within this collection to interact with the precision I/O event system.
Public propertyHasChanged (Inherited from CogSerializableChangedEventBase.)
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 propertyValid
Indicates whether the configuration of this object is valid/invalid for the current hardware.

The valid/invalid state is automatically updated when this object is part of a CogPrio.Events collection.

Objects marked Invalid should be reconfigured to be valid. Otherwise the CogPrio event system will not function.

Use the validationErrorMsg to understand how to reconfigure the object to be valid.

(Inherited from CogPrioEventConfigObjectBase.)
Public propertyValidationErrorMsg
Returns a collection of validation error messages that describe issues with the CogPrio.Events configuration.

The valid/invalid state is automatically updated when this object is part of a CogPrio.Events collection.

Objects marked Invalid should be reconfigured to be valid. Otherwise the CogPrio event system will not function.

Use the validation error msg to understand how to reconfigure the object to be valid.

(Inherited from CogPrioEventConfigObjectBase.)
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.)
Top
Remarks

Precision I/O supports getting and setting the state of the Comm Card's Discrete I/O lines.

Precision I/O also supports configuration of an event system that runs on the Comm Card's real-time processor.

The precision I/O event system allows the Comm Card to receive inputs and automatically react to them without involving the host PC.

This enables accurate configuration and reporting of I/O events and avoids typical host PC latency issues.

Hardware platforms and supported I/O lines:

Cognex Communication Card 24C
InputBank0, Line0-Line78 general purpose inputs numbered 0-7
OutputBank0, Line0-Line1516 general purpose outputs numbered 0-15

Cognex Communication Card 24A (Cognex Vision Controller)
InputBank0, Line0-Line78 general purpose inputs numbered 0-7
OutputBank0, Line0-Line1516 general purpose outputs numbered 0-15
DS1000OutputBank0, Line0Camera 0 Enable (Not For Application Use)
DS1000OutputBank0, Line1Camera 1 Enable (Not For Application Use)
DS1000OutputBank0, Line2Camera 0 Trigger
DS1000OutputBank0, Line3Camera 1 Trigger
DS1000OutputBank0, Line4Camera 0 Control (Not For Application Use)
DS1000OutputBank0, Line5Camera 1 Control (Not For Application Use)
DS1000OutputBank0, Line6Camera 0 Power (Not For Application Use)
DS1000OutputBank0, Line7Camera 1 Power (Not For Application Use)

Examples

// This code shows simple use of 
// Comm Card API. This sample: 
//  
// 1. Initializes comm card's i/o interface. 
// 2. Reads input line 0. 
// 3. Signs up for host notification when input line 0 toggles. 
// 4. Sets an output line 0 high.
[Test]
public void Example2()
{
CogCommCards commCardCollection = new CogCommCards();

Console.WriteLine("Found: {0} comm cards", commCardCollection.Count);

if (commCardCollection.Count == 0)
return;

CogCommCard card = commCardCollection[0];

Console.WriteLine("Name: {0}", card.Name);
Console.WriteLine("Serial: {0}", card.SerialNumber);

CogDiscreteIOAccess discreteIOAccess = card.DiscreteIOAccess;
if (discreteIOAccess == null)
throw new Exception("discrete IO is not supported.");

// Create the prio interface
CogPrio prio = discreteIOAccess.CreatePrecisionIO();

// Read input 0 
bool isInputLine0High = mPrio.ReadState()[CogPrioBankConstants.InputBank0, 0];
Console.WriteLine("Input line 0 is " + (isInputLine0High ? "high" : "low"));

// Create an event that occurs when Input 0 changes
prio.Events.Add(
new CogPrioEvent() {
Name = "InputChanged_0",
CausesLine = new CogPrioEventCauseLineCollection() {
new CogPrioEventCauseLine() {
LineBank = CogPrioBankConstants.InputBank0,
LineNumber = 0,
LineTransition = CogPrioLineTransitionConstants.Any }}});

// Sign up for host notification when on the event
prio.Events["InputChanged_0"].HostNotification +=
new CogPrioEventHandler(InputChanged_0_HostNotification);

// Always ensure the events collection is valid. 
if(!prio.Valid)
{ 
  Console.WrtieLine(prio.ValidationErrorMsg[0]);
}

// Set output 0 high
prio.SetOutput(CogPrioBankConstants.OutputBank0,         // i/o bank 
0,                                        // line number
CogPrioOutputLineValueConstants.SetHigh); // line value to set
}

void InputChanged_0_HostNotification(object sender, CogPrioEventArgs e)
{
Console.WriteLine("rcvd host notification for InputChanged_0 event");
}
See Also