Ver Mensaje Individual
  #9 (permalink)  
Antiguo 06/06/2010, 16:18
fj87
 
Fecha de Ingreso: junio-2010
Mensajes: 17
Antigüedad: 14 años, 5 meses
Puntos: 0
Respuesta: Tarjeta de adquisicion

Código C:
Ver original
  1. int WINAPI
  2. WinMain( HINSTANCE hInstance,
  3.          HINSTANCE hPrevInstance,
  4.          LPSTR lpCmdLine,
  5.          int nCmdShow )
  6. /*++
  7. This is our apps entry point.  It calls the open layers functions
  8. to execute the required operation.
  9. --*/
  10. {
  11.    DBL  freq;
  12.    UINT size,dma,gainsup,samplesize;
  13.    int i;
  14.  
  15.    UINT channel = 0;
  16.    UINT numberADs = 0;
  17.    UINT currentAD = 0;
  18.    DBL gain = 1.0;
  19.    HBUF  hBuffer = NULL;
  20.    ECODE ec=OLNOERROR;
  21.  
  22.  
  23.    board.hdrvr = NULL;
  24.  
  25.     // Get cmdline board
  26.     if (lpCmdLine[0]!=0)
  27.     {
  28.      CHECKERROR( olDaInitialize(lpCmdLine,&board.hdrvr) );
  29.      strcpy(board.name,lpCmdLine);
  30.     }
  31.     else
  32.     {
  33.    /* Get first available Open Layers board */
  34.    CHECKERROR (olDaEnumBoards(GetDriver,(LPARAM)(LPBOARD)&board));
  35.     }
  36.    /* check for error within callback function */
  37.  
  38.    CHECKERROR (board.status);
  39.  
  40.    /* check for NULL driver handle - means no boards */
  41.  
  42.    if (board.hdrvr == NULL){
  43.       MessageBox(HWND_DESKTOP, " No Open Layer boards!!!", "Error",
  44.             MB_ICONEXCLAMATION | MB_OK);
  45.       return ((UINT)NULL);
  46.    }
  47.  
  48.    /* get handle to first available ADC sub system */
  49.    CHECKERROR(olDaGetDevCaps(board.hdrvr,OLDC_ADELEMENTS,&numberADs));
  50.  
  51.     while(1)    // Enumerate through all the A/D subsystems and try and select the first available one...
  52.    {
  53.         ec=olDaGetDASS(board.hdrvr,OLSS_AD,currentAD,&board.hdass);
  54.         if (ec!=OLNOERROR)
  55.         {
  56.         // busy subsys etc...
  57.         currentAD++;
  58.         if (currentAD>numberADs)
  59.         {
  60.             MessageBox(HWND_DESKTOP,"No Available A/D Subsystems!","Error",MB_ICONEXCLAMATION|MB_OK);
  61.               return ((UINT)NULL);
  62.         }
  63.  
  64.         }
  65.         else
  66.         break;
  67.  
  68.    }
  69.  
  70.    /*
  71.       Set up the ADC - multiple wrap so we can get buffer reused
  72.       window messages.
  73.    */
  74.  
  75.    CHECKERROR (olDaGetSSCapsEx(board.hdass,OLSSCE_MAXTHROUGHPUT,&freq));
  76.    CHECKERROR (olDaGetSSCaps(board.hdass,OLSSC_NUMDMACHANS,&dma));
  77.    CHECKERROR (olDaGetSSCaps(board.hdass,OLSSC_SUP_PROGRAMGAIN,&gainsup));
  78.    
  79.    dma  = min (1, dma);            /* try for one dma channel   */
  80.    freq = min (1000.0, freq);      /* try for 1000hz throughput */
  81.  
  82.    CHECKERROR (olDaSetDataFlow(board.hdass,OL_DF_CONTINUOUS));
  83.    CHECKERROR (olDaSetWrapMode(board.hdass,OL_WRP_MULTIPLE));
  84.    CHECKERROR (olDaSetClockFrequency(board.hdass,freq));
  85.    CHECKERROR (olDaSetDmaUsage(board.hdass,dma));
  86.    CHECKERROR (olDaSetChannelListEntry(board.hdass,0,channel));
  87.  
  88.    /* only set the gain if the board supports it!!! */
  89.  
  90.    if (gainsup)
  91.       CHECKERROR (olDaSetGainListEntry(board.hdass,0,gain));
  92.  
  93.    CHECKERROR (olDaSetChannelListSize(board.hdass,1));
  94.    CHECKERROR (olDaConfig(board.hdass));
  95.  
  96.    size = (UINT)freq/1;     /* 1 second buffer */
  97.    
  98.    /* allocate the input buffers */
  99.    /* Put the buffer to the ADC  */
  100.    
  101.     CHECKERROR(olDaGetResolution(board.hdass,&samplesize));
  102.     if (samplesize > 16)
  103.         samplesize=4; //4 bytes...// e.g. 24 bits = 4 btyes
  104.     else
  105.         samplesize=2;             // e.g. 16 or 12 bits = 2 bytes
  106.  
  107.    for (i=0;i<NUM_BUFFERS;i++)
  108.    {
  109.       CHECKERROR (olDmCallocBuffer(0,0,(ULNG) size,samplesize,&hBuffer));
  110.       CHECKERROR (olDaPutBuffer(board.hdass, hBuffer));
  111.    }
  112.  
  113.    /*
  114.       use a dialog box to collect information and error
  115.       messages from the subsystem
  116.    */
  117.  
  118.    DialogBox(hInstance, (LPCSTR)INPUTBOX, HWND_DESKTOP, InputBox);
  119.  
  120.    /*
  121.       get the input buffers from the ADC subsystem and
  122.       free the input buffers
  123.    */
  124.  
  125.    CHECKERROR (olDaFlushBuffers(board.hdass));
  126.    
  127.    for (i=0;i<NUM_BUFFERS;i++)
  128.    {
  129.       CHECKERROR (olDaGetBuffer(board.hdass, &hBuffer));
  130.       CHECKERROR (olDmFreeBuffer(hBuffer));
  131.    }
  132.    
  133.    /* release the subsystem and the board */
  134.  
  135.    CHECKERROR (olDaReleaseDASS(board.hdass));
  136.    CHECKERROR (olDaTerminate(board.hdrvr));
  137.  
  138.    /* all done - return */
  139.  
  140.    return ((UINT)NULL);
  141. }

segunda parte.
Os agradecería enormemente algun consejo para afrontar una programación similar en python.

muchas gracias