After selecting a device the user can choose what he wants to do. The program waits for the input:
bool boRun = true;
while (boRun)
{
Console.WriteLine();
Console.WriteLine("-------------------------------------------------------------------------------");
Console.WriteLine(" enter 'quit', 'snap', 'list', 'help' or the name of ");
Console.WriteLine(" the property you want to modify followed by [ENTER]: ");
Console.WriteLine("-------------------------------------------------------------------------------");
Console.Write("Command:>");
String command = Console.ReadLine();
Console.WriteLine();
if (command == "snap")
{
singleCapture(boMustStartAcquisition, fi, pDev, timeout_ms);
}
else if (command == "list")
{
foreach (KeyValuePair<string, Property> KVP in propertyMap)
{
Console.WriteLine(KVP.Key);
}
}
else if (command == "help")
{
Console.WriteLine("quit: terminates this sample application");
#if USE_DISPLAY
Console.WriteLine("snap: takes and displays one image with the current settings");
#else
Console.WriteLine("snap: takes one image with the current settings");
#endif
Console.WriteLine("list: displays all properties available for this device");
Console.WriteLine("help: displays this help text");
Console.WriteLine("timeout: set a new timeout(in ms) used as a max. timeout to wait for an image");
Console.WriteLine("the full name of a property must be specified");
}
else if (command == "quit")
{
boRun = false;
continue;
}
else if (command == "timeout")
{
Console.WriteLine("Enter the new timeout to be passed to the imageRequestWaitFor function: ");
timeout_ms = Convert.ToInt32(Console.ReadLine());
}
else
{
if (!propertyMap.ContainsKey(command))
{
Console.WriteLine("Unknown command or property");
}
else
{
Property prop = propertyMap[command];
ExampleHelper.displayPropertyData(prop);
if (prop.hasDict)
{
Console.WriteLine("This function expects the string representation as input!");
}
}
}
}
'timeout' will define a new timeout used as a max. wait timeout for a snapped image to become ready
string name = prop.name;
Console.WriteLine("Property '{0}' currently specifies the following flags: {1}", name, prop.flagsAsString());
if (prop.hasMinValue)
{
Console.WriteLine("The minimum value of '{0}' is {1}", name, prop.readS(TPropertyLimits.plMinValue));
}
if (prop.hasMaxValue)
{
Console.WriteLine("The maximum value of '{0}' is {1}", name, prop.readS(TPropertyLimits.plMaxValue));
}
if (prop.hasStepWidth)
{
Console.WriteLine(
"The increment of '{0}' is {1}", name, prop.readS(
TPropertyLimits.plStepWidth));
}
if (prop.hasDict)
{
Console.WriteLine("'{0}' defines a dictionary. Valid values are: ", name);
{
PropertyI p = new PropertyI(prop.hObj);
List<KeyValuePair<String, int>> sequence = new List<KeyValuePair<String, int>>();
p.getTranslationDict(sequence);
foreach (KeyValuePair<String, int> entry in sequence)
{
Console.WriteLine("[{0}]: {1}", entry.Value, entry.Key);
}
}
{
PropertyI64 p = new PropertyI64(prop.hObj);
List<KeyValuePair<String, long>> sequence = new List<KeyValuePair<String, long>>();
p.getTranslationDict(sequence);
foreach (KeyValuePair<String, long> entry in sequence)
{
Console.WriteLine("[{0}]: {1}", entry.Value, entry.Key);
}
}
{
PropertyF p = new PropertyF(prop.hObj);
List<KeyValuePair<String, double>> sequence = new List<KeyValuePair<String, double>>();
p.getTranslationDict(sequence);
foreach (KeyValuePair<String, double> entry in sequence)
{
Console.WriteLine("[{0}]: {1}", entry.Value, entry.Key);
}
}
else
{
Console.WriteLine("Error! Unhandled enum prop type: {0}", prop.typeAsString);
}
}
Console.WriteLine("The current value of '{0}' is: {1}", name, prop.readS());
TPropertyLimits
Defines valid limits which can be queried for a mv.impact.acquire.Property object.
Definition Property.cs:18
TComponentType
Allowed components handled by this module.
Definition mvPropHandlingDatatypes.cs:197
using System;
using System.Collections.Generic;
#if USE_DISPLAY
#endif
using mv.impact.acquire.examples.helper;
namespace mv.impact.acquire.examples
{
class Properties
{
#region private members -----------------------------------------------
#if USE_DISPLAY
#endif
#endregion
static void populatePropertyMap(Dictionary<string, Property> m,
Component it,
string currentPath)
{
{
string fullName = currentPath;
if (fullName != "")
{
fullName += "/";
}
{
}
{
}
++it;
}
}
{
{
}
DeviceAccess.manuallyStartAcquisitionIfNeeded(pDev, fi);
if (pRequest != null)
{
{
#if USE_DISPLAY
if (window_ == null)
{
}
# if CLR_AT_LEAST_3_DOT_5
# else
# endif
#endif
}
else
{
}
Console.WriteLine();
Console.WriteLine();
}
DeviceAccess.manuallyStopAcquisitionIfNeeded(pDev, fi);
}
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);
}
Console.WriteLine("Initialising the device. This might take some time...");
try
{
}
{
Console.WriteLine(
"An error occurred while opening the device " + pDev.
serial +
"(error code: " + e.Message + "). Press any key to end the application...");
Console.ReadLine();
Environment.Exit(1);
}
Dictionary<string, Property> propertyMap = new Dictionary<string, Property>();
populatePropertyMap(propertyMap, comp.
firstChild,
"");
try
{
populatePropertyMap(propertyMap, comp.
firstChild,
"");
}
populatePropertyMap(propertyMap, comp.
firstChild,
"");
populatePropertyMap(propertyMap, comp.
firstChild,
"SystemSettings");
populatePropertyMap(propertyMap, comp.
firstChild,
"Info");
populatePropertyMap(propertyMap, comp.
firstChild,
"Device");
int timeout_ms = 500;
bool boRun = true;
while (boRun)
{
Console.WriteLine();
Console.WriteLine("-------------------------------------------------------------------------------");
Console.WriteLine(" enter 'quit', 'snap', 'list', 'help' or the name of ");
Console.WriteLine(" the property you want to modify followed by [ENTER]: ");
Console.WriteLine("-------------------------------------------------------------------------------");
Console.Write("Command:>");
String command = Console.ReadLine();
Console.WriteLine();
if (command == "snap")
{
singleCapture(pDev, fi, timeout_ms);
}
else if (command == "list")
{
foreach (KeyValuePair<string, Property> KVP in propertyMap)
{
Console.WriteLine(KVP.Key);
}
}
else if (command == "help")
{
Console.WriteLine("quit: terminates this sample application");
#if USE_DISPLAY
Console.WriteLine("snap: takes and displays one image with the current settings");
#else
Console.WriteLine("snap: takes one image with the current settings");
#endif
Console.WriteLine("list: displays all properties available for this device");
Console.WriteLine("help: displays this help text");
Console.WriteLine("timeout: set a new timeout(in ms) used as a max. timeout to wait for an image");
Console.WriteLine("the full name of a property must be specified");
}
else if (command == "quit")
{
boRun = false;
continue;
}
else if (command == "timeout")
{
Console.WriteLine("Enter the new timeout to be passed to the imageRequestWaitFor function: ");
timeout_ms = Convert.ToInt32(Console.ReadLine());
}
else
{
if (!propertyMap.ContainsKey(command))
{
Console.WriteLine("Unknown command or property");
}
else
{
FeatureAccess.displayPropertyData(prop);
{
Console.WriteLine("This function expects the string representation as input!");
}
{
Console.Write("Enter new Value:> ");
String NewVal = Console.ReadLine();
int index = 0;
{
Console.WriteLine(
"'{0} defines {1} values. Enter the (zero-based) index of the value to modify: ", prop.
name, prop.
valCount);
index = System.Convert.ToInt32(Console.ReadLine());
}
try
{
}
{
Console.WriteLine("");
}
}
else
{
Console.WriteLine(
"'{0}' is read-only, thus can't be modified.", prop.
name);
}
}
}
}
}
}
}
String name
Returns the name of the component referenced by this object.
Definition ComponentAccess.cs:167
int hObj
Returns a unique identifier for the component referenced by this object.
Definition ComponentAccess.cs:155
int searchbase_id
Returns the unique identifier of the base list from where to start searching for a component.
Definition ComponentLocatorBase.cs:159
A base class to implement access to internal driver components.
Definition Component.cs:133
bool isWriteable
Checks if the caller has write/modify access to the component.
Definition Component.cs:769
bool isList
Checks if this component is of type mv.impact.acquire.ComponentList.
Definition Component.cs:680
Component firstChild
Moves to the first child of this component(moves down one level).
Definition Component.cs:597
bool isProp
Checks if this component is of type mv.impact.acquire.Property or a derived type.
Definition Component.cs:708
bool isValid
Checks if the internal component referenced by this object is still valid.
Definition Component.cs:727
A class to locate components within the driver.
Definition DeviceComponentLocator.cs:74
This class and its functions represent an actual device detected by this interface in the current sys...
Definition Device.cs:91
void open()
Opens a device.
Definition Device.cs:209
int hDev
A unique identifier for this device.
Definition Device.cs:350
readonly PropertyS serial
A string property (read-only) containing the serial number of this device.
Definition Device.cs:516
T read()
Reads a value from a property.
Definition EnumPropertyI.cs:342
The function interface to devices supported by this interface.
Definition FunctionInterface.cs:21
int imageRequestSingle()
Sends an image request to the mv.impact.acquire.Device driver.
Definition FunctionInterface.cs:656
Request getRequest(int nr)
Returns a const pointer to the desired mv.impact.acquire.Request.
Definition FunctionInterface.cs:452
int imageRequestWaitFor(int timeout_ms)
Waits for a request object to become ready.
Definition FunctionInterface.cs:1021
bool isRequestNrValid(int nr)
Check if nr specifies a valid mv.impact.acquire.Request.
Definition FunctionInterface.cs:1098
An base class for exceptions generated by Impact Acquire.
Definition Exceptions.cs:9
static String getErrorCodeAsString(int errorCode)
Returns a string representation of a error.
Definition Exceptions.cs:48
String errorCodeAsString
Returns a string representation of the error associated with the exception.
Definition Exceptions.cs:118
String errorString
Returns an error string containing information about the reason for the error.
Definition Exceptions.cs:92
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
IntPtr read()
Reads a value from a property.
Definition PropertyPtr.cs:49
String read()
Reads a value from a property.
Definition PropertyS.cs:144
A base class for properties.
Definition Property.cs:109
Property writeS(String value)
Assigns a new value to this property.
Definition Property.cs:667
bool hasDict
Returns whether this property defines a translation dictionary or not.
Definition Property.cs:842
uint valCount
Returns the current number of values managed by this property.
Definition Property.cs:919
Contains information about a captured buffer.
Definition Request.cs:77
readonly PropertyPtr imageData
A pointer property (read-only) containing the start address of the image data.
Definition Request.cs:1579
readonly PropertyI imageLinePitch
An integer property (read-only) containing the offset (in bytes) to the next line of each channel bel...
Definition Request.cs:1655
readonly EnumPropertyI< TRequestResult > requestResult
An enumerated integer property (read-only) defining the result of this request.
Definition Request.cs:1211
readonly PropertyI imageWidth
An integer property (read-only) containing the width of the image in pixels.
Definition Request.cs:1693
readonly PropertyI imageBytesPerPixel
An integer property (read-only) containing the number of bytes per pixel in this image.
Definition Request.cs:1679
bool isOK
Convenience function to check if a request has been processed successfully.
Definition Request.cs:1173
readonly PropertyI imageHeight
An integer property (read-only) containing the height of the image in pixels.
Definition Request.cs:1704
int unlock()
Unlocks the request for the driver again.
Definition Request.cs:619
readonly EnumPropertyI< TImageBufferPixelFormat > imagePixelFormat
An enumerated integer property (read-only) containing the pixel format of this image.
Definition Request.cs:1540
A class that can be used to display images in a window.
Definition ImageDisplayWindow.cs:15
readonly ImageDisplay imageDisplay
Returns a reference to the actual display object associated with this window.
Definition ImageDisplayWindow.cs:108
void SetImage(IntPtr pData, int width, int height, int bipp, int pitch)
Sets the next image to display.
Definition ImageDisplay.cs:282
void Update()
Immediately redraws the current image.
Definition ImageDisplay.cs:333
TDMR_ERROR
Errors reported by the device manager.
Definition mvDriverBaseEnums.cs:2375
TDeviceListType
Defines valid interface list types, which can be located using an instance of mv.impact....
Definition TDeviceListType.cs:6
This namespace contains classes and functions that can be used to display images.
Definition Enumerations.cs:2
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