CogDiscreteIOAccess is used to factory/initialize instances of the precision I/O event system running on the comm card by calling CreatePrecisionIO .
Cognex.VisionPro.Comm CogDiscreteIOAccess
Namespace: Cognex.VisionPro.Comm
Assembly: Cognex.VisionPro.Comm (in Cognex.VisionPro.Comm.dll) Version: 79.0.0.0
The CogDiscreteIOAccess type exposes the following members.
| Name | Description | |
|---|---|---|
| CreatePrecisionIO |
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.
| |
| CreatePrecisionIOImpl |
Cognex Internal Use Only
| |
| Dispose |
Disposes any outstanding discrete i/o hardware resources.
| |
| Dispose(Boolean) | ||
| Equals | Determines whether the specified Object is equal to the current Object. (Inherited from Object.) | |
| Finalize | (Overrides Object Finalize .) | |
| GetActivePrecisionIO |
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. | |
| GetHashCode | Serves as a hash function for a particular type. (Inherited from Object.) | |
| GetType | Gets the Type of the current instance. (Inherited from Object.) | |
| MemberwiseClone | Creates a shallow copy of the current Object. (Inherited from Object.) | |
| Reset |
Resets the state of the i/o subsystem by
disposing any outstanding hardware resources.
| |
| ToString | Returns a String that represents the current Object. (Inherited from Object.) |
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.
- Use SetOutput(CogPrioBankConstants, Int32, CogPrioOutputLineValueConstants) to manually set an I/O line high or low.
- Use ReadState to get the current state the I/O lines.
- Construct instances of CogPrioEvent and add them to the Events collection to configure a set of named events that correspond to different actions of interest that occur on the I/O card.
- Use CausesLine to configure which I/O line transitions cause a precision I/O event to occur.
- Use CausesNdm to configure which NDM signals of the factory floor protocol cause a precision I/O event to occur.
- Use ResponsesLine to configure an automatic I/O line response to a precision I/O event.
- Use Schedule(CogPrioEventScheduleTypeConstants, Double, CogPrioState) to manually schedule a configured precision I/O event to occur at an precise instant.
- Use HostNotification to receive notifications whenever a configured event occurs.
Hardware platforms and supported I/O lines:
| Cognex Communication Card 24C | |
|---|---|
| InputBank0, Line0-Line7 | 8 general purpose inputs numbered 0-7 |
| OutputBank0, Line0-Line15 | 16 general purpose outputs numbered 0-15 |
| Cognex Communication Card 24A (Cognex Vision Controller) | |
|---|---|
| InputBank0, Line0-Line7 | 8 general purpose inputs numbered 0-7 |
| OutputBank0, Line0-Line15 | 16 general purpose outputs numbered 0-15 |
| DS1000OutputBank0, Line0 | Camera 0 Enable (Not For Application Use) |
| DS1000OutputBank0, Line1 | Camera 1 Enable (Not For Application Use) |
| DS1000OutputBank0, Line2 | Camera 0 Trigger |
| DS1000OutputBank0, Line3 | Camera 1 Trigger |
| DS1000OutputBank0, Line4 | Camera 0 Control (Not For Application Use) |
| DS1000OutputBank0, Line5 | Camera 1 Control (Not For Application Use) |
| DS1000OutputBank0, Line6 | Camera 0 Power (Not For Application Use) |
| DS1000OutputBank0, Line7 | Camera 1 Power (Not For Application Use) |
// 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"); }