CogDiscreteIOAccess ClassCognex VisionPro 9.8 SR1
Instances of CogDiscreteIOAccess class are held by the CogCommCard class.

CogDiscreteIOAccess is used to factory/initialize instances of the precision I/O event system running on the comm card by calling CreatePrecisionIO .

Inheritance Hierarchy

System Object
  Cognex.VisionPro.Comm CogDiscreteIOAccess

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

public class CogDiscreteIOAccess : IDisposable

The CogDiscreteIOAccess type exposes the following members.

Methods

  NameDescription
Public methodCreatePrecisionIO
Creates and returns a precision I/O object. The user interacts with the precision I/O capabilities of the comm card though the returned object.
Public methodCreatePrecisionIOImpl
Cognex Internal Use Only
Public methodDispose 
Disposes any outstanding discrete i/o hardware resources.
Protected methodDispose(Boolean)
Public methodEquals
Determines whether the specified Object is equal to the current Object.
(Inherited from Object.)
Protected methodFinalize (Overrides Object Finalize .)
Public methodGetActivePrecisionIO
Returns a reference to the currently active precision I/O object held by the Comm Card or null if no currently active precision I/O object exists.

An active precision I/O object will only exist if one of the CreatePrecisionIO  methods has been called previously.

Public methodGetHashCode
Serves as a hash function for a particular type.
(Inherited from Object.)
Public methodGetType
Gets the Type of the current instance.
(Inherited from Object.)
Protected methodMemberwiseClone
Creates a shallow copy of the current Object.
(Inherited from Object.)
Public methodReset
Resets the state of the i/o subsystem by disposing any outstanding hardware resources.
Public methodToString
Returns a String that represents the current Object.
(Inherited from Object.)
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