Gets a discrete I/O access object.
Namespace: Cognex.VisionPro.CommUse the discrete I/O access object to access the discrete I/O and precision I/O features of the comm card.
This property returns null if the hardware does not support discrete I/O.
Assembly: Cognex.VisionPro.Comm (in Cognex.VisionPro.Comm.dll) Version: 73.0.0.0
Syntax
Property Value
Type: CogDiscreteIOAccessRemarks
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.
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