⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 dodmabm.c

📁 16 relay output channels and 16 isolated digital input channels LED indicators to show activated
💻 C
📖 第 1 页 / 共 3 页
字号:
        switch (LOWORD(wParam))
        {
        case IDOK :
			{
				// save the data width
				for ( i = IDC_32DO; i <= IDC_8DIO; i++)
				{
					if( SendDlgItemMessage(hDlg, i, BM_GETCHECK, 0, 0) == 1)
					{
						gdwDataWidth = (i - IDC_32DO) + 1;
					}
				}
				
				// save the start type
				for ( i = IDC_SOFT_START; i <= IDC_EXTERNAL_START; i++ )
				{
					if ( SendDlgItemMessage( hDlg, i, BM_GETCHECK, 0, 0 ) == 1 )
					{
						gdwDOStartMode = i - IDC_SOFT_START + 1;
					}
				}
				
				// save the operation mode
				for ( i = IDC_NORMAL; i <= IDC_BURST; i++ )
				{
					if ( SendDlgItemMessage( hDlg, i, BM_GETCHECK, 0, 0 ) == 1 )
					{
						gdwOperationMode = i - IDC_NORMAL ;
					}
				}
				
				// save the stop type
				for ( i = IDC_SOFT_STOP; i <= IDC_EXTERNAL_STOP; i++ )
				{
					if ( SendDlgItemMessage( hDlg, i, BM_GETCHECK, 0, 0 ) == 1 )
					{
						gdwDOStopMode = i - IDC_SOFT_STOP + 1;
					}
				}
				
				// save the trigger source
				// 30MHz(1), 15Mhz(2), 10Mhz(3), Counter 0(4), External (5), 12MHz(6), 20MHz(7)
				gdwDOTriggerSource = SendDlgItemMessage(hDlg, IDC_LIST_TRIGGER_SOURCE, LB_GETCURSEL, 0, 0) + 1;
				
				// save the counter0 value 
				SendDlgItemMessage(hDlg, IDC_EDIT_COUNTER1_VALUE, WM_GETTEXT, 10, (LPARAM)(LPSTR)szBuffer) ;
				gdwCounterValue[1] = (DWORD)atoi(szBuffer);
				
				// save the Digital output value 
				sprintf(szBuffer,"%s","0x");
                GetDlgItemText(hDlg,IDC_DIGITALOUT,&(szBuffer[2]),10);
				gdwDigitalOut=strtoul(szBuffer, (char**)(&szTemp),16);
				
				// save user buffer size
				// 1M(0), 2M(1), 4M(2), 8M(3), 16M(4)
				gdwUserBufferSize = SendDlgItemMessage(hDlg, IDC_LIST_USER_BUFFER, LB_GETCURSEL, 0, 0);
				
				// DRV_DeviceClose((LONG far *)&DriverHandle);
			}
			
		case IDCANCEL :
            EndDialog(hDlg, 0);
            return TRUE;
			
		case  IDC_LIST_TRIGGER_SOURCE:
			{
				if( HIWORD(wParam) == LBN_SELCHANGE )
				{
					
					if( SendDlgItemMessage(hDlg, IDC_LIST_TRIGGER_SOURCE, LB_GETCURSEL ,0,0) == 3 )
						bEnable = TRUE;
					else 
						bEnable = FALSE;
					
					EnableWindow( GetDlgItem(hDlg, IDC_EDIT_COUNTER0_VALUE), bEnable);
				}
				
			}
			break;
			
        case IDC_DeviceSelect:
			/*
            // Step 1: Select Device
            ErrCde = DRV_SelectDevice(hDlg, FALSE, &dwDeviceNum, szDeviceName);
            if (ErrCde != SUCCESS)
            {
                DRV_GetErrorMessage(ErrCde,(LPSTR)szErrMsg);
                MessageBox(hWnd,(LPCSTR)szErrMsg,"Driver Message",MB_OK);
                return 0;
            }
		    SetDlgItemText(hDlg,IDC_DEVICE_NAME,szDeviceName);
			
            // -------------------------------------------------
            // Initialize Input Range List Combobox, it needs to
            // get device features for gain list
            // -------------------------------------------------
			
            // Step 2: Open Device
            ErrCde = DRV_DeviceOpen(dwDeviceNum, (LONG far *)&DriverHandle);
            if (ErrCde != SUCCESS)
            {
                DRV_GetErrorMessage(ErrCde,(LPSTR)szErrMsg);
                MessageBox(hWnd, (LPCSTR)szErrMsg,
                    "Driver Message", MB_OK);
                return 0;
            }
			
            // Step 3: Get device features
            ptDevFeatures.buffer = (LPDEVFEATURES)&DevFeatures;
            ptDevFeatures.size = sizeof(DEVFEATURES);
            if ((ErrCde = DRV_DeviceGetFeatures(DriverHandle,
                (LPT_DeviceGetFeatures)&ptDevFeatures)) != SUCCESS)
            {
                DRV_GetErrorMessage(ErrCde,(LPSTR)szErrMsg);
                MessageBox(hWnd, (LPCSTR)szErrMsg, "Driver Message",
                    MB_OK);
                DRV_DeviceClose((LONG far *)&DriverHandle);
                return 0;
            }
			
			
			
            // Step 5: Close device
            DRV_DeviceClose((LONG far *)&DriverHandle);
			
            return TRUE;
			*/
           gbConfigured = FALSE;
           SendMessage(hDlg, WM_INITDIALOG, 0, 0);
           break;

        case IDC_CYCLIC :
            gdwCyclicMode = 1;
            break;
        case IDC_NONCYCLIC :
            gdwCyclicMode = 0;
            break;
        case IDC_DMA_SLAVE :
           gdwDmaMode = 0;
           break;
        case IDC_DMA_MASTER :
           gdwDmaMode = 1;
           break;
        case IDC_NORMAL :
        case IDC_8255 :
           if( BD_MIC3755 == gdwBoardId )
           {
              EnableWindow(GetDlgItem(hDlg, IDC_DMA_SLAVE), FALSE);
              EnableWindow(GetDlgItem(hDlg, IDC_DMA_MASTER), FALSE);
           }        
           break;
           
        case IDC_BURST :
           if( BD_MIC3755 == gdwBoardId )
           {
              EnableWindow(GetDlgItem(hDlg, IDC_DMA_SLAVE), TRUE);
              EnableWindow(GetDlgItem(hDlg, IDC_DMA_MASTER), TRUE);
           } 
           break;
			
        }
        break;
    }
    return FALSE ;
}

/******************************************************************************
FUNCTION: ShowDataDlgProc(HWND, unsigned, WPARAM, LPARAM)

  PURPOSE:  Processes dialog box messages for acquired data
  ******************************************************************************/
  
  BOOL FTYPE ShowDataDlgProc(hDlg, message, wParam, lParam)
	  HWND hDlg;                                  /* window handle                 */
  unsigned message;                           /* type of message               */
  WPARAM wParam;                              /* additional information        */
  LPARAM lParam;                              /* additional information        */
  {
	  ULONG  lEndDisplay, lStartDisplay;
	  ULONG  i;
	  DWORD  dwUserBufferSize, dwCount;
	  
	  switch (message)
	  {
	  case WM_INITDIALOG :
		  {         
			  dwUserBufferSize = (DWORD)(Mega * pow((double)2, (double)gdwUserBufferSize));
			  // 32DI(0)/32DO(1)/ 16 DIO(2) / 8DIO(3)
			  switch( gdwDataWidth )
			  {
			  case 3:
				  dwCount = dwUserBufferSize;
				  break;
				  
			  case 2:
				  dwCount = dwUserBufferSize / 2;
				  break;
				  
			  default:
				  dwCount = dwUserBufferSize / 4;
				  break;
			  }
			  
			  lStartDisplay = gdwStartPt;
			  ultoa(lStartDisplay, szBuffer, 10);
			  SetWindowText(GetDlgItem(hDlg,IDC_FROM),(LPCTSTR)szBuffer);
			  
			  lEndDisplay = gdwStopPt;
			  ultoa(lEndDisplay, szBuffer, 10);
			  SetWindowText(GetDlgItem(hDlg,IDC_TO),(LPCTSTR)szBuffer);
			  
			  ultoa(dwCount, szBuffer, 10);
			  SetWindowText(GetDlgItem(hDlg,IDC_TOTAL),(LPCTSTR)szBuffer);
			  
			  for(i = lStartDisplay; (i <= lEndDisplay) && (i < dwCount); ++i)
			  {
				  if ( gdwDataWidth == 3 )     // 8-bit
				  {
					  sprintf(szBuffer, "Buf[%ld] = %2x", i, ((BYTE far *)hUserBuf)[i]);
				  }
				  else if ( gdwDataWidth == 2 )  // 16-bit
				  {
					  sprintf(szBuffer, "Buf[%ld] = %4x",i, ((USHORT far *)hUserBuf)[i]);
				  }
				  else                           // 32-bit
				  {
					  sprintf(szBuffer, "Buf[%ld] = %8x",i, ((ULONG far *)hUserBuf)[i]);
				  }
				  
				  
				  if(SendDlgItemMessage(hDlg, IDC_DATALIST, LB_ADDSTRING, 0,
					  (LPARAM)(LPSTR)szBuffer) == LB_ERRSPACE)
				  {
					  MessageBox(hWnd,(LPCSTR)"Not Enough Memory",
						  "Display Data",MB_OK);
					  return TRUE;
				  }
			  }
			  
			  return TRUE;
		  }
		  
	  case WM_COMMAND :
		  switch (LOWORD(wParam))
		  {
		  case IDC_BACKBUTTON :
			  break;			
		  case IDC_BACKWARD :
			  break;
		  case IDC_FORWARD :
			  break;			
		  case IDC_FORWARDBUTTON :
			  break;
		  case IDC_UPDATE :
			  break;
		  case IDOK :
		  case IDCANCEL :
			  EndDialog(hDlg, 0);
			  return TRUE;
		  }
		  break;
	  }
	  return FALSE ;
  }
  
  /******************************************************************************
  FUNCTION: DisplayDlgProc(HWND, unsigned, WPARAM, LPARAM)
  
    PURPOSE:  Processes dialog box messages for display range
  ******************************************************************************/
  
  BOOL FTYPE DisplayDlgProc(hDlg, message, wParam, lParam)
	  HWND hDlg;                               /* window handle                   */
  unsigned message;                        /* type of message                 */
  WPARAM wParam;                           /* additional information          */
  LPARAM lParam;                           /* additional information          */
  {
	  
	  switch (message)
	  {
	  case WM_INITDIALOG :
		  
		  // Initialize Start Point
		  ultoa(gdwStartPt, szBuffer, 10);
		  
		  SendDlgItemMessage(hDlg, IDC_ESTAPT, EM_REPLACESEL, 0,
			  (LPARAM)((LPSTR)szBuffer));
		  
		  // Initialize Stop Point
		  ultoa(gdwStopPt, szBuffer, 10);
		  
		  SendDlgItemMessage(hDlg, IDC_ESTOPT, EM_REPLACESEL, 0,
			  (LPARAM)((LPSTR)szBuffer));
		  
		  return TRUE;
		  
	  case WM_COMMAND :
		  switch (LOWORD(wParam))
		  {
		  case IDOK :
		  case IDCANCEL :
			  EndDialog(hDlg, 0);
			  return TRUE;
			  
		  case IDC_ESTAPT :
			  
			  if (HIWORD(wParam) == EN_KILLFOCUS)
			  {
				  if(SendDlgItemMessage(hDlg, IDC_ESTAPT,
					  EM_GETMODIFY, 0, 0))
				  {
					  SendDlgItemMessage(hDlg, IDC_ESTAPT,
						  WM_GETTEXT, 10, (LPARAM)(LPSTR)szBuffer) ;
					  gdwStartPt = (USHORT)atoi(szBuffer);
					  SendDlgItemMessage(hDlg, IDC_ESTAPT,
						  EM_SETMODIFY, FALSE, 0) ;
				  }
			  }
			  return TRUE;
			  
		  case IDC_ESTOPT :
			  if (HIWORD(wParam) == EN_KILLFOCUS)
			  {
				  if(SendDlgItemMessage(hDlg, IDC_ESTOPT,
					  EM_GETMODIFY, 0, 0))
				  {
					  SendDlgItemMessage(hDlg, IDC_ESTOPT,
						  WM_GETTEXT, 10, (LPARAM)(LPSTR)szBuffer) ;
					  gdwStopPt = atol(szBuffer);
					  SendDlgItemMessage(hDlg, IDC_ESTOPT,
						  EM_SETMODIFY, FALSE, 0) ;
				  }
			  }
			  return TRUE;
		  }
		  break;
	  }
	  return FALSE ;
  }
  
  /******************************************************************************
  FUNCTION: MainWndProc(HWND, unsigned, WPARAM, LPARAM)
  
    PURPOSE:  Processes messages
	
	  MESSAGES:
	  
        WM_CREATE     - create window
        WM_COMMAND    - application menu (About dialog box)
        WM_DESTROY    - destroy window
  ******************************************************************************/
  
  long FTYPE MainWndProc(hWnd, message, wParam, lParam)
	  HWND     hWnd;                            /* window handle                   */
  unsigned message;                         /* type of message                 */
  WPARAM   wParam;                          /* additional information          */
  LPARAM   lParam;                          /* additional information          */
  {
	  
	  TEXTMETRIC tm;
	  HDC     hdc;
	  static  int cxChar, cyChar;
	  DWORD  dwUserBufferSize;
	  DWORD  dwCount;
	  ULONG  dwFdoStatus, dwRetrieved;
	  char    *szStr, szDest[100], szTemp[50];
	  double  ratio;
	  int     dec, sign;
	  DWORD  i;
	  //    USHORT  temp;
	  
	  
	  switch (message)
	  {
	  case WM_CREATE:
		  
		  hMenu = GetMenu(hWnd);
		  
		  hInstance = ((LPCREATESTRUCT) lParam)->hInstance ;
		  
		  lpfnConfigDlgProc = MakeProcInstance (ConfigDlgProc, hInstance) ;
		  
		  lpfnShowDataDlgProc = MakeProcInstance (ShowDataDlgProc, hInstance) ;
		  
		  lpfnDisplayDlgProc = MakeProcInstance (DisplayDlgProc, hInstance) ;
		  
		  hdc = GetDC(hWnd);
		  SelectObject(hdc, GetStockObject(SYSTEM_FIXED_FONT));
		  GetTextMetrics(hdc, &tm);
		  cxChar = tm.tmAveCharWidth;
		  cyChar = tm.tmHeight + tm.tmExternalLeading;
		  ReleaseDC(hWnd, hdc);
		  
		  //Create stop button and status button
		  hwndStopButton = CreateWindow("button", "Stop",
			  (DWORD)(WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON),
			  0, 0, 8*cxChar, 3*cyChar/2, hWnd,
			  (HMENU)IDC_STOPBUTTON,
			  (HANDLE)hInstance, (LPVOID)NULL);
		  
		  hwndStatusButton = CreateWindow("button", "Status",
			  (DWORD)(WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON),
			  8*cxChar, 0, 8*cxChar, 3*cyChar/2, hWnd,
			  (HMENU)IDC_STATUSBUTTON,
			  (HANDLE)hInstance, (LPVOID)NULL);
		  
		  EnableWindow(hwndStopButton, FALSE);
		  EnableWindow(hwndStatusButton, FALSE);
		  
		  return 0 ;
		  
	  case WM_COMMAND:     /* message: from application menu */
		  
		  hMenu = GetMenu(hWnd);
		  
		  switch(LOWORD(wParam))
		  {
			  // Show the dialog box of the input parameter
		  case IDM_SETTING :
			  
			  DialogBox (hInstance, MAKEINTRESOURCE(IDD_SETTING),
				  hWnd, lpfnConfigDlgProc) ;
			  return 0;
			  
			  // Show the dialog box for the range of data to display
		  case IDM_DISPLAY:
			  
			  DialogBox (hInstance, MAKEINTRESOURCE(IDD_DISPLAY),
				  hWnd, lpfnDisplayDlgProc) ;
			  
			  return 0;
			  

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -