Download Simplon programmer`s guide
Transcript
Simplon programmer's guide Programming with Simplon sizeof(szOldUserID)); pDevice->SetString(LvDevice_DeviceUserID, szNewUserID); In case you need to know in advance how big string buffer you need for the string, use the LvModule::GetStringSize(). For example: size_t Size; pDevice->GetStringSize(LvDevice_EventLvLogMessage, &Size); char* pLogMessage = new char[Size]; pDevice->GetString(LvDevice_EventLvLogMessage, pLogMessage, Size); //... delete[] pLogMessage; The C++ API adds a possibility to use the std::string for convenience — see the Section 2.2.2, “The C++ Class Library” [p. 31] for more details. In this case you do not need to take care about the string size. Example: std::string sOldUserID; std::string sNewUserID = "Tomatito"; pDevice->GetString(LvDevice_DeviceUserID, sOldUserID); pDevice->SetString(LvDevice_DeviceUserID, sNewUserID.c_str()); 2.4.9. The Enumeration feature The enumeration feature can have one value from a list of available values (enumeration entries). In GenICam the enumeration values are strings. Simplon for convenience offers also using predefined constants for enumeration entries (included are constants for all enumerations supported by Leutron Vision hardware). Use the LvModule::SetEnumStr() and LvModule::GetEnumStr() for a generic manipulation (enum values as strings) or LvModule::SetEnum() and LvModule::GetEnum() when you use the predefined constants. The following examples show the difference. Fully generic access: LvFeature FeatureID; pDevice->GetFeatureByName(LvFtrGroup_DeviceRemote, "PixelFormat", &FeatureID); pDevice->SetEnumStr(FeatureID, "Mono8"); Half generic - enum entry as a string: pDevice->SetEnumStr(LvDevice_PixelFormat, "Mono8"); Using predefined constants also for enum entries: pDevice->SetEnum(LvDevice_PixelFormat, LvPixelFormat_Mono8); Note that the actual value of the predefined constant does not have any numerical meaning. An exception is the LvPixelFormat — there the constants are compound from several parts, from which is possible to determine additional info, like bits per pixel, mono/color etc. More info in the Reference Guide. Sometimes you may need to convert the enum string value to a numeric constant or vice versa. The LvModule::GetEnumValByStr() and LvModule::GetEnumStrByVal() are available for this purpose. Similarly as features themselves, some of the enumeration entries may become unavailable upon the current status. Use the LvModule::IsAvailableEnumEntry() for determining, if the enum entry is currently available. Typically, the device supports only a subset of all possible pixel formats: if (pDevice->IsAvailableEnumEntry(LvDevice_PixelFormat, LvPixelFormat_BGR8Packed)) Copyright © Leutron Vision 54 Leutron Vision