How to set EnumerationNode using integer (Cvb++ 13.02.002)

Hi guys,

Is there a way to set EnumerationNode using integer? I would like to set PixelFormat using PFNC standard values.

E.g using node Std::PixelFormat:

...
//Getting pixelFormat node
auto node = deviceNodeMap->Node("Std::PixelFormat"); 
auto enumNode = std::dynamic_pointer_cast<Cvb::EnumerationNode>(node);      

//Getting the Entries is possible to print the values following PFNC standard and as string.
for (auto value : enumNode->Entries()) {
  cout << value->NumericValue() << endl;
  cout << value->SymbolicValue() << endl;
}

//To set the STRING value is possible to use SetValue()
enumNode->SetValue("Mono8");

I would like to use a similar SetValue() function but using PFNC standard value like 0x01080002 (Mono8).
Does someone know a way or the proper way to set this node using integer?

Thank you in advance.

Bests,
Diogo Justen

Hi @djusten

You can do;

void SetNumericValue(CvbEnumerationNode& enumerationNode, std::int64_t value)
{
  auto entries = enumerationNode.Entries()
  auto symbolicValue = std::find_if(entries.begin(), entries.end(), 
  [value](const Cvb::EnumEntryNodePtr& node)
  {
    return value == node->NumericValue();
  })->SymbolicValue();
 enumerationNode.SetValue(symbolicValue);
}

Please note, that I did not run the code so it might need some adjustments.

Hi @Andreas,

Thank you for your help, what you suggested worked.
The final code running look like this:

try
{
    auto enumNode = std::dynamic_pointer_cast<Cvb::EnumerationNode>(node);      
    auto entries = enumNode->Entries();                                         
    if (entries.empty())                                                        
    {                                                                           
      WARNING("Entries node empty");                                            
      return false;                                                             
    }                                                                           
                                                                                
    auto symbolicValue = std::find_if(entries.begin(), entries.end(),           
                           [value](const Cvb::EnumEntryNodePtr & node)          
    {                                                                           
      return value == node->NumericValue();                                     
    })->get()->SymbolicValue();                                                 
                                                                                
    if (symbolicValue.empty())                                                  
    {                                                                           
      WARNING("Invalid symbolic value");                                        
      return false;                                                             
    }                                                                           
                                                                                
    enumNode->SetValue(symbolicValue);                                          
}

Thanks!!
Diogo Justen

Just keep in mind: the integer value is not standardized in the GenICam Standard Features Naming Convention, only the string values are. This is why only the string version of SetValue is provided.

PixelFormat has the Pixel Format Naming Convention, though, which also defines integer constants. Thus in this case it should be fine.