Beispiel #1
0
// display info on a given attribute of the camera
void QueryAttribute(const char* aLabel)
{
    tPvAttributeInfo lInfo;

    if(!PvAttrInfo(GCamera.Handle,aLabel,&lInfo))
    {
        char lFlags[5];

        memset(lFlags,' ',sizeof(char) * 4);

        if(lInfo.Flags & ePvFlagRead)
            lFlags[0] = 'r';
        if(lInfo.Flags & ePvFlagWrite)
            lFlags[1] = 'w';
        if(lInfo.Flags & ePvFlagVolatile)
            lFlags[2] = 'v';
        if(lInfo.Flags & ePvFlagConst)
            lFlags[3] = 'c';
        lFlags[4] = '\0';

        printf("%30s (%30s) [%7s][%s]",aLabel,lInfo.Category,DatatypeToString(lInfo.Datatype),lFlags); 
        
        switch(lInfo.Datatype)
        {           
            case ePvDatatypeString:
            {
                char lValue[128];

                // we assume here that any string value will be less than 128 characters
                // long, wich we may not be the case
                
                if(!PvAttrStringGet(GCamera.Handle,aLabel,lValue,128,NULL))
                    printf(" = %s\n",lValue);
                else
                    printf(" = ERROR!\n");

                break;                
            }
            case ePvDatatypeEnum:
            {
                char lValue[128];

                // we assume here that any string value will be less than 128 characters
                // long, wich we may not be the case
                
                if(!PvAttrEnumGet(GCamera.Handle,aLabel,lValue,128,NULL))
                    printf(" = %s\n",lValue);
                else
                    printf(" = ERROR!\n");
                break;
            }
            case ePvDatatypeUint32:
            {
                tPvUint32 lValue;
                
                if(!PvAttrUint32Get(GCamera.Handle,aLabel,&lValue))
                    printf(" = %lu\n",lValue);
                else
                    printf(" = ERROR!\n");
                break;
            }
            case ePvDatatypeFloat32:
            {
                tPvFloat32 lValue;
                
                if(!PvAttrFloat32Get(GCamera.Handle,aLabel,&lValue))
                    printf(" = %f\n",lValue);
                else
                    printf(" = ERROR!\n");
                break;
            }
            default:
                printf("\n");
        }
    }
}
// display info on a given attribute of the camera
void QueryAttribute(const char* aLabel)
{
    tPvAttributeInfo lInfo;

    if(PvAttrInfo(GCamera.Handle,aLabel,&lInfo) == ePvErrSuccess)
    {
        char lFlags[5];

        memset(lFlags,' ',sizeof(char) * 4);

        if(lInfo.Flags & ePvFlagRead)
            lFlags[0] = 'r';
        if(lInfo.Flags & ePvFlagWrite)
            lFlags[1] = 'w';
        if(lInfo.Flags & ePvFlagVolatile)
            lFlags[2] = 'v';
        if(lInfo.Flags & ePvFlagConst)
            lFlags[3] = 'c';
        lFlags[4] = '\0';

	//	printf("%30s (%30s) [%7s]{%s}",aLabel,lInfo.Category,DatatypeToString(lInfo.Datatype),lFlags); 
    //    printf("%s/%s = %s [%s]{%s}\n",lInfo.Category,aLabel,lValue,DatatypeToString(lInfo.Datatype),lFlags); 

        switch(lInfo.Datatype)
        {           
            case ePvDatatypeString:
            {
                char lValue[128];

                // we assume here that any string value will be less than 128 characters
                // long, which we may not be the case
                
                if(PvAttrStringGet(GCamera.Handle,aLabel,lValue,128,NULL) == ePvErrSuccess)
                    printf("%s/%s = %s [%s,%s]\n",lInfo.Category,aLabel,lValue,DatatypeToString(lInfo.Datatype),lFlags); 
                else
                    printf("ERROR!\n");

                break;                
            }
            case ePvDatatypeEnum:
            {
                char lValue[128];

                // we assume here that any string value will be less than 128 characters
                // long, which we may not be the case
                
                if(PvAttrEnumGet(GCamera.Handle,aLabel,lValue,128,NULL) == ePvErrSuccess)
                    printf("%s/%s = %s [%s,%s]\n",lInfo.Category,aLabel,lValue,DatatypeToString(lInfo.Datatype),lFlags); 
                else
                    printf("ERROR!\n");
                break;
            }
            case ePvDatatypeUint32:
            {
                tPvUint32 lValue;
                
                if(PvAttrUint32Get(GCamera.Handle,aLabel,&lValue) == ePvErrSuccess)
                    printf("%s/%s = %lu [%s,%s]\n",lInfo.Category,aLabel,lValue,DatatypeToString(lInfo.Datatype),lFlags); 
                else
                    printf("ERROR!\n");
                break;
            }
            case ePvDatatypeInt64:
            {
                tPvInt64 lValue;
                
                if(PvAttrInt64Get(GCamera.Handle,aLabel,&lValue) == ePvErrSuccess)
                    printf("%s/%s = %lld [%s,%s]\n",lInfo.Category,aLabel,lValue,DatatypeToString(lInfo.Datatype),lFlags); 
                else
                    printf("ERROR!\n");
                break;
            }            
            case ePvDatatypeFloat32:
            {
                tPvFloat32 lValue;
                
                if(PvAttrFloat32Get(GCamera.Handle,aLabel,&lValue) == ePvErrSuccess)
                    printf("%s/%s = %f [%s,%s]\n",lInfo.Category,aLabel,lValue,DatatypeToString(lInfo.Datatype),lFlags); 
                else
                    printf("ERROR!\n");
                break;
            }
            case ePvDatatypeBoolean:
            {
                tPvBoolean lValue;
                
                if(PvAttrBooleanGet(GCamera.Handle,aLabel,&lValue) == ePvErrSuccess)
                    printf("%s/%s = %s [%s,%s]\n",lInfo.Category,aLabel,lValue ? "true" : "false",DatatypeToString(lInfo.Datatype),lFlags); 
                else
                    printf("ERROR!\n");                   
                break;
            }
            default:
                //command
				printf("%s/%s [%s,%s]\n",lInfo.Category,aLabel,DatatypeToString(lInfo.Datatype),lFlags);
        }
    }
}