コード例 #1
0
ファイル: MainWindow.cpp プロジェクト: ZeitgeberH/eyetracker
/*
 * Method:    OnOpen()
 * Purpose:   called when the window is open
 * Comments:  none
 */
void CMainWindow::OnOpen(wxCommandEvent& aEvent)
{
    // set the initial status text
    SetStatusText(L"Ready ...");
    // then list all the cameras already plugged
    ListCameras();
}
コード例 #2
0
int main(int argc, char* argv[])
{
    // initialize PvAPI
    if(PvInitialize() == ePvErrSuccess)
    { 
        // set the handler for CTRL-C
        //SetConsoleCtrlHandler(CtrlCHandler, TRUE);
	
        // the following call will only return upon CTRL-C
        ListCameras();
        
        // uninit the API
        PvUnInitialize();
    }
    else
        printf("failed to initialize the API\n");
    

	return 0;
}
コード例 #3
0
ファイル: CLIpConfig.cpp プロジェクト: AIRLab-POLIMI/iDrive
int main(int argc, char* argv[])
{
    int err = 0;

    // initialise PvAPI
    if(!PvInitialize())
    {
        int c;
        unsigned long uid = 0;
        bool bList = false;
        bool bGet  = false;
        bool bSet  = false;
        bool bMode = false;
        bool bAddr = false;
        bool bMask = false;
        bool bWay  = false;
        char* vMode = NULL;
        char* vAddr = NULL;
        char* vMask = NULL;
        char* vWay  = NULL;
    
        while ((c = getopt (argc, argv, "lu:gsm:i:n:pw:h?")) != -1)
        {
            switch(c)
            {
                case 'l':
                {
                    bList = true;
                    break;
                }
                case 'u':
                {
                    if(optarg)
                        uid = atol(optarg);
                    
                    break;    
                }
                case 'g':
                {
                    bGet = true;
                    break;
                }
                case 's':
                {
                    bSet = true;
                    break;
                }
                case 'm':
                {
                    bMode = true;
                    if(optarg)
                        vMode = optarg;
                    break;
                }
                case 'i':
                {
                    bAddr = true;
                    if(optarg)
                        vAddr = optarg;
                    break;
                }
                case 'n':
                {
                    bMask = true;
                    if(optarg)
                        vMask = optarg;
                    break;
                }
                case 'w':
                {
                    bWay = true;
                    if(optarg)
                        vWay = optarg;
                    break;
                }
                case '?':
                case 'h':
                {
                    ShowUsage();
                    break;    
                }
                default:
                    break;
            }
        }

        if(uid || bList)
        {

        
            if(bList)
            {
                printf("Searching for cameras ...\n");
                Sleep(2000);
            
                ListCameras();
            }
            else
            {
                printf("Looking for the camera ...\n");
                Sleep(1000);
            
                if(bGet)
                {
                    tPvCameraInfo  camInfo;
                    tPvIpSettings  camConf;
                    struct in_addr addr;

                    if(!PvCameraInfo(uid,&camInfo) &&
                        !PvCameraIpSettingsGet(uid,&camConf))
                    {
                        printf("\t\t\t%s - %s\n",camInfo.SerialString,camInfo.DisplayName);
                        printf("Mode supported:\t\t");
                        if(camConf.ConfigModeSupport & ePvIpConfigPersistent)
                            printf("FIXED ");
                        if(camConf.ConfigModeSupport & ePvIpConfigDhcp)
                            printf("DHCP ");
                        if(camConf.ConfigModeSupport & ePvIpConfigAutoIp)
                            printf("AutoIP");
                        printf("\n");
                        printf("Current mode:\t\t");
                        if(camConf.ConfigMode & ePvIpConfigPersistent)
                            printf("FIXED\n");
                        else
                        if(camConf.ConfigMode & ePvIpConfigDhcp)
                            printf("DHCP&AutoIP\n");
                        else
                        if(camConf.ConfigMode & ePvIpConfigAutoIp)
                            printf("AutoIP\n");

                        addr.s_addr = camConf.CurrentIpAddress;
                        printf("Current address:\t%s\n",inet_ntoa(addr));
                        addr.s_addr = camConf.CurrentIpSubnet;
                        printf("Current subnet:\t\t%s\n",inet_ntoa(addr));
                        addr.s_addr = camConf.CurrentIpGateway;
                        printf("Current gateway:\t%s\n",inet_ntoa(addr));
                    }
                    else
                        fprintf(stderr,"failed to talk to the camera!\n");
                }
                else
                if(bSet)
                {
                    tPvCameraInfo  camInfo;
                    tPvIpSettings  camConf;
                    bool           bApply = false;

                    if(!PvCameraInfo(uid,&camInfo) &&
                        !PvCameraIpSettingsGet(uid,&camConf))
                    {
                        if(bMode && vMode)
                        {
                            unsigned long Mode = 0;                          
                                                 
                            if(!strcasecmp(vMode,"fixed"))
                                Mode = ePvIpConfigPersistent;
                            else
                            if(!strcasecmp(vMode,"dhcp"))
                                Mode = ePvIpConfigDhcp;
                            else
                            if(!strcasecmp(vMode,"autoip"))
                                Mode = ePvIpConfigAutoIp;
                            else
                            {
                                fprintf(stderr,"%s isn't a valid mode\n",vMode);
                                err = 1;
                            }

                            if(Mode)
                            {
                                if(camConf.ConfigModeSupport & Mode)
                                {
                                    camConf.ConfigMode = (tPvIpConfig)Mode;
                                    bApply = true; 
                                }
                                else
                                {
                                    fprintf(stderr,"%s isn't supported by the camera\n",vMode);
                                    err = 1;
                                }
                            }
                        }
                    
                        if(bAddr && vAddr)
                        {
                            camConf.PersistentIpAddr = inet_addr(vAddr); 
                            bApply = true;     
                        }
                      
                        if(bMask && vMask)
                        {
                            camConf.PersistentIpSubnet = inet_addr(vMask);
                            bApply = true;     
                        }
                        
                        if(bWay && vWay)
                        {
                            camConf.PersistentIpGateway = inet_addr(vWay);
                            bApply = true;     
                        }                                                 

                        if(bApply)
                        {
                            if(PvCameraIpSettingsChange(uid,&camConf))
                            {
                                fprintf(stderr,"failed to set the configuration!\n");
                                err = 1;
                            }
                            else
                                printf("Settings changed for %s - %s\n",camInfo.SerialString,camInfo.DisplayName);
                        }
                    }
                    else
                        fprintf(stderr,"failed to talk to the camera!\n");
                }
                else
                {
                    ShowUsage();
                    err = 1;  
                }
            }
        }
        else
        {
            ShowUsage();
            err = 1;  
        }

        // uninitialise the API
        PvUnInitialize();
    }
    else
    {
        err = 1;
        fprintf(stderr,"failed to initialise the API\n");
    }
    
	return err;
}