According to the device, the digital I/O information will be displayed. In detail this will be:
Apart from this output of the current state and description of the different input and output signal lines and related properties the user can also interactively change the state of the digital output line and some other properties during the sample execution. How this can be achieved can be seen in the source code of the sample.
using mv.impact.acquire.examples.helper;
using System;
using System.Collections.ObjectModel;
namespace mv.impact.acquire.examples
{
class DigitalIOs
{
{
FeatureAccess.modifyPropertyValue(p.
lowPart_pc,
"",
"");
}
{
Console.WriteLine("This device has");
Console.WriteLine(" {0} digital input(s)", inputCount);
for (int i = 0; i < inputCount; i++)
{
}
Console.WriteLine();
if (inputCount > 0)
{
Console.WriteLine("All input registers can be queried with a single function call: Calling 'readInputRegister' returned ");
Console.WriteLine();
Console.WriteLine("From the LSB to the MSB a '1' in this result indicates, that this input is currently connected to a signal");
Console.WriteLine("that is interpreted as a logical '1'. E.g. 0x13 indicates that inputs 0, 1 and 4 are currently in 'high' state.");
}
Console.WriteLine(" {0} digital input(s)", outputCount);
if (outputCount > 0)
{
int readOnlyAccessMask = 0;
bool boRun = true;
while (boRun)
{
for (int j = 0; j < outputCount; j++)
{
Console.WriteLine(
" [{0}]: {1}(current state: {2}, {3}manually switchable)", j, pOutput.
description, pOutput.
get(), (pOutput.
isWriteable ?
"" :
"NOT "));
{
readOnlyAccessMask |= 1 << j;
}
}
Console.WriteLine();
Console.WriteLine("Enter the number of a digital output followed by [ENTER] to modify its state or 'c' followed by [ENTER] to continue.");
string cmd = Console.ReadLine();
if (cmd == "c")
{
boRun = false;
continue;
}
int index = 0;
try
{
index = Convert.ToInt32(cmd);
}
catch
{
Console.WriteLine("Invalid input:");
continue;
}
if (index >= outputCount)
{
Console.WriteLine("Invalid selection");
continue;
}
{
Console.WriteLine(
"{0} is not manually switchable.", Output.
description);
continue;
}
Console.WriteLine("Please enter the number in front of the function that shall be called followed by [ENTER]:");
Console.WriteLine(" [0]: set");
Console.WriteLine(" [1]: reset");
Console.WriteLine(" [2]: flip");
int newMode = Convert.ToInt32(Console.ReadLine());
switch (newMode)
{
case 0:
break;
case 1:
break;
case 2:
break;
default:
Console.WriteLine("Invalid selection.");
break;
}
}
Console.WriteLine("All output registers can be queried with a single function call.");
Console.WriteLine("From the LSB to the MSB a '1' in this result indicates, that this output is currently switched to 'high' or 'active' state");
Console.WriteLine("E.g. 0x22 indicates that outputs 1 and 5 (zero-based) are currently in 'high' state.");
uint fullOutputMask = 0;
if (outputCount > 0)
{
fullOutputMask = (uint)Math.Pow(2, outputCount) - 1;
}
boRun = true;
while (boRun)
{
Console.WriteLine("Calling 'readOutputRegister' returned ");
Console.WriteLine();
Console.WriteLine("Please enter 'y' followed by [ENTER] to modify all digital outputs with a single function");
Console.WriteLine("call or anything else followed by [ENTER] to continue.");
if (Console.ReadLine() != "y")
{
boRun = false;
continue;
}
Console.WriteLine("Please enter the bitmask in hex that contains the new values for the digital outputs followed by [ENTER]: ");
uint value = UInt32.Parse(Console.ReadLine(), System.Globalization.NumberStyles.HexNumber);
if ((value & ~fullOutputMask) != 0)
{
value &= fullOutputMask;
Console.WriteLine("WARNING: More bits than outputs specified. Bitmask truncated to ");
Console.WriteLine("0x{0}", value.ToString("X4"));
Console.WriteLine();
}
Console.WriteLine("Please enter the bitmask in hex that contains '1's for outputs that shall be affected by this operation followed by [ENTER]: ");
uint mask = UInt32.Parse(Console.ReadLine(), System.Globalization.NumberStyles.HexNumber);
if ((readOnlyAccessMask & mask) != 0)
{
Console.WriteLine("WARNING: At least one selected output is not manually switchable: Mask: ");
Console.WriteLine("0x{0}", mask.ToString("X4"));
Console.WriteLine(", read-only access mask: ");
Console.WriteLine("0x{0}", readOnlyAccessMask.ToString("X4"));
Console.WriteLine();
Console.WriteLine("No digital outputs have been modified.");
continue;
}
}
}
Console.WriteLine("This device also has");
{
Console.WriteLine("How to program the HRTC (Hardware RealTime Controller) is not part of this sample, but the manual will contain a separate chapter on this topic.");
}
}
static void mvGenICamIOAccess(
Device pDev)
{
try
{
bool boRun = true;
while (boRun)
{
Console.WriteLine();
Console.WriteLine(" This device has {0} DigitalIOs", IOCount);
Console.WriteLine(" ------------------------------------------");
foreach (long value in validLineSelectorValues)
{
Console.WriteLine(
" IO {0}: \t Type: {1} \t Current state: {2}", value, dioc.
lineMode.readS(), Convert.ToBoolean(dioc.
lineStatus.
read()) ?
"ON" :
"OFF");
}
Console.WriteLine(" ------------------------------------------");
Console.WriteLine();
Console.WriteLine("Please enter a valid line number:");
Console.WriteLine("- if it is an output its value will be inverted");
Console.WriteLine("- if it is an input its value will be polled continuously for 10 seconds");
Console.Write("- or press 'c' to continue:");
ConsoleKeyInfo userInput = Console.ReadKey();
Console.WriteLine();
if (userInput.Key == ConsoleKey.C)
{
boRun = false;
continue;
}
else if (Char.IsDigit(userInput.KeyChar))
{
int userInputDigit = Convert.ToInt32((userInput.KeyChar.ToString()));
if (userInputDigit < IOCount)
{
{
{
}
else
{
}
}
else if (dioc.
lineMode.readS() ==
"Input")
{
Console.WriteLine();
Console.WriteLine();
Console.WriteLine(" ------------------------------------------");
Console.WriteLine(
" Polling Input '{0}'", dioc.
lineSelector.readS());
Console.WriteLine(" ------------------------------------------");
Console.WriteLine();
for (int i = 0; i < 100; i++)
{
Console.Write(
"\r Value:{0} \t Remaining Time:{1:F1}", Convert.ToBoolean(dioc.
lineStatus.
read()) ?
"ON" :
"OFF", 10.0 - ((float)i / 10));
System.Threading.Thread.Sleep(100);
}
Console.WriteLine();
Console.WriteLine();
}
else
{
Console.WriteLine(
"IO {0} is a '{1}'!", userInputDigit, dioc.
lineMode.readS());
}
}
else
{
Console.WriteLine();
Console.WriteLine(" Invalid IO Number! ");
Console.WriteLine();
}
}
else
{
Console.WriteLine();
Console.WriteLine(" Invalid Keyboard Input! ");
Console.WriteLine();
}
}
}
{
Console.WriteLine();
Console.WriteLine(
"An error occurred while playing around with the digital I/Os of device " + pDev.
serial +
"(error code: " + e.Message + ").");
Console.WriteLine();
}
}
static void mvBlueFOXIOAccess(
Device pDev)
{
displayCommonIOFeatures(ioss);
{
}
Console.WriteLine(
"To use a digital output in 'expose active' mode, the property '{0}' can be used.", cs.
flashMode.name);
Console.WriteLine("If a delay between switching the output and starting the frame exposure is needed, this can be achieved by ");
}
static void Main(string[] args)
{
Device pDev = DeviceAccess.getDeviceFromUserInput();
if (pDev == null)
{
Console.WriteLine("Unable to continue! Press any key to end the program.");
Console.Read();
Environment.Exit(1);
}
{
mvGenICamIOAccess(pDev);
}
{
mvBlueFOXIOAccess(pDev);
}
else
{
Console.WriteLine(
"Device {0} ({1}) is not supported by this sample", pDev.
serial, pDev.
product);
Console.WriteLine("Press [ENTER] to end the application");
Console.Read();
Environment.Exit(1);
}
Console.WriteLine();
Console.WriteLine("Press [ENTER] to end the application");
Console.Read();
}
}
}
mvBlueFOX related camera settings (Device specific interface layout only).
Definition CameraSettingsBlueFOX.cs:15
readonly EnumPropertyI< TCameraFlashMode > flashMode
An enumerated integer property defining the behaviour of the flash output of the camera (if available...
Definition CameraSettingsBlueFOX.cs:174
readonly PropertyI flashToExposeDelay_us
An integer property defining the delay in us between the start of the flash signal output and the beg...
Definition CameraSettingsBlueFOX.cs:160
This class and its functions represent an actual device detected by this interface in the current sys...
Definition Device.cs:91
readonly EnumPropertyI< TDeviceInterfaceLayout > interfaceLayout
An enumerated integer property which can be used to define which interface layout shall be used when ...
Definition Device.cs:604
readonly PropertyS product
A string property (read-only) containing the product name of this device.
Definition Device.cs:502
readonly PropertyS family
A string property (read-only) containing the family name of this device.
Definition Device.cs:491
readonly PropertyS serial
A string property (read-only) containing the serial number of this device.
Definition Device.cs:516
String description
Returns a description for this digital output.
Definition DigitalIO.cs:74
A class to represent a digital output pin(Device specific interface layout only).
Definition DigitalIO.cs:91
override bool get()
Returns the current state of this output pin.
Definition DigitalIO.cs:120
bool isWriteable
Checks if the caller has write/modify access to this digital output.
Definition DigitalIO.cs:144
void set()
Sets the output pin to 'logic 1'.
Definition DigitalIO.cs:122
void reset()
Sets the output pin to 'logic 0'.
Definition DigitalIO.cs:124
bool flip()
Inverts the current state of the digital output and returns the previous state.
Definition DigitalIO.cs:107
ReadOnlyCollection< T > listOfValidValues
Returns a list of valid values for this property.
Definition EnumPropertyI64.cs:602
EnumPropertyI64< T > write(T value)
Writes one value to the property.
Definition EnumPropertyI64.cs:432
EnumPropertyI< T > write(T value)
Writes one value to the property.
Definition EnumPropertyI.cs:449
T read()
Reads a value from a property.
Definition EnumPropertyI.cs:342
Category that contains the digital input and output control features.
Definition mvIMPACT_acquire_GenICam.autogen.cs:3634
readonly mv.impact.acquire.PropertyI64 lineMode
An enumerated integer property. Controls if the physical Line is used to Input or Output a signal.
Definition mvIMPACT_acquire_GenICam.autogen.cs:3736
readonly mv.impact.acquire.PropertyI64 lineSelector
An enumerated integer property. Selects the physical line (or pin) of the external device connector o...
Definition mvIMPACT_acquire_GenICam.autogen.cs:3724
readonly mv.impact.acquire.PropertyIBoolean lineInverter
A boolean property. Controls the inversion of the signal of the selected input or output Line.
Definition mvIMPACT_acquire_GenICam.autogen.cs:3741
readonly mv.impact.acquire.PropertyIBoolean lineStatus
A boolean property. Returns the current status of the selected input or output Line.
Definition mvIMPACT_acquire_GenICam.autogen.cs:3746
A class to handle the digital inputs and outputs for mvBlueFOX USB cameras (Device specific interface...
Definition IOSubSystemBlueFOX.cs:51
readonly EnumPropertyI< TBlueFOXDigitalInputThreshold > digitalInputThreshold
An enumerated integer property defining the threshold for the digital inputs in Volt.
Definition IOSubSystemBlueFOX.cs:211
A base class to handle digital inputs and outputs (Device specific interface layout only).
Definition IOSubSystem.cs:19
DigitalInput input(int nr)
Returns a const pointer to a mv.impact.acquire.DigitalInput object.
Definition IOSubSystem.cs:131
void writeOutputRegister(uint value, uint mask)
Alters the state of the digital output register.
uint readOutputRegister()
Returns the current state of the digital output register.
DigitalOutput output(int nr)
Returns a pointer to a mv.impact.acquire.DigitalOutput object.
Definition IOSubSystem.cs:144
uint readInputRegister()
Returns the current state of the digital input register.
int inputCount
Returns the number of mv.impact.acquire.DigitalInput s available for the mv.impact....
Definition IOSubSystem.cs:233
int outputCount
Returns the number of digital outputs available for the mv.impact.acquire.Device associated with this...
Definition IOSubSystem.cs:235
int pulseStartConfigurationCount
Returns the number of mv.impact.acquire.PulseStartConfiguration objects available for the mv....
Definition IOSubSystem.cs:239
int RTCtrProgramCount
Returns the number of mv.impact.acquire.RTCtrProgram s available for the mv.impact....
Definition IOSubSystem.cs:237
An base class for exceptions generated by Impact Acquire.
Definition Exceptions.cs:9
A small helper class to administer various library search path related variables and paths.
Definition LibraryPath.cs:14
static void init()
Calling this method will add the folders containing unmanaged libraries to the systems library search...
Definition LibraryPath.cs:251
String readS()
Reads data from this property as a string.
Definition Property.cs:303
A class to represent a sync. output pin(Device specific interface layout only).
Definition SyncOutput.cs:18
readonly PropertyF lowPart_pc
A float property defining the width in percent the sync. signal stays low during one period....
Definition SyncOutput.cs:54
readonly PropertyF frequency_Hz
A float property defining the frequency(in Hertz) for the sync. signal generated by this pin.
Definition SyncOutput.cs:52
TBoolean
Defines a Boolean value type.
Definition mvDriverBaseEnums.cs:481
TDeviceInterfaceLayout
Defines valid interface layouts for the device.
Definition mvDriverBaseEnums.cs:1921
This namespace contains classes and functions belonging to the GenICam specific part of the image acq...
Definition GenTLDriverConfigurator.cs:6
This namespace contains classes and functions belonging to the image acquisition module of this SDK.
Definition Enumerations.cs:2
Definition Enumerations.cs:2
Definition Enumerations.cs:2