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

📄 tstcfg.c

📁 美国GE公司MIL-1553B测试程序
💻 C
📖 第 1 页 / 共 2 页
字号:
/**************************************************************************
*
*  PROCEDURE NAME - GfxTextcolor
*
*  FUNCTION
*     This routine is called to adjust the screen colors.  If your
*     programming environment does not support this function insure that
*     the function evaluates to NULL.
*
*   Parameters
*     int color   -> New screen color to set.
*
**************************************************************************/
#if defined(__BORLANDC__) && 1 && (defined(_DOS) || defined(__WIN32__))
// Borland compiler
struct text_info texti;                // Screen information.
void GfxTextcolor(int color)
{
   static int  FirstPass = 1;    // Time to do first pass initialization?
   static int  ColorSupported;

   if ( FirstPass ) {
      FirstPass = 0;
      gettextinfo(&texti);
      if ( (texti.currmode == C80)   || (texti.currmode == C4350) ||
           (texti.currmode == 0x00E) || (texti.currmode == 0x007) ||
           (texti.currmode == 0x00C) || (texti.currmode == 0x003) ||
           (texti.currmode == 0x00A)                                 )
         ColorSupported = 1;
      else
         ColorSupported = 0;
   }
   if ( ColorSupported )
      textcolor(color);
}
#define printf   cprintf    /* Borland needs to use cprintf, not printf! */
#elif defined(__WIN32__)
// Must be Microsoft for Windows
#define LIGHTGREEN 1
#define LIGHTRED 2
#define LIGHTMAGENTA 3
#define YELLOW 4
#define WHITE 5

HANDLE                     hStdout;
HANDLE                     hStdin;
CONSOLE_SCREEN_BUFFER_INFO csbiInfo; 
WORD                       wOldColorAttrs;
COORD                      dwSize;

void GfxTextcolor(int color)
{
   static int  FirstPass = 1;    // Time to do first pass initialization?

   if ( FirstPass ) {
      FirstPass = 0;
      hStdin = GetStdHandle(STD_INPUT_HANDLE);
      hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
      if (hStdin == INVALID_HANDLE_VALUE ||
         hStdout == INVALID_HANDLE_VALUE)
      {
         printf("Console Bad Handle\n");
         exit(0);
      }
      wOldColorAttrs = csbiInfo.wAttributes;
      SetConsoleTitle("Test Configuration");
      dwSize.X= 80;
      dwSize.Y = 25;
      SetConsoleScreenBufferSize(hStdout, dwSize);
   }
   switch (color)
   {
   case LIGHTGREEN:
      SetConsoleTextAttribute(hStdout, FOREGROUND_GREEN | FOREGROUND_INTENSITY);
      break;
   case LIGHTRED:
      SetConsoleTextAttribute(hStdout, FOREGROUND_RED | FOREGROUND_INTENSITY);
      break;
   case LIGHTMAGENTA:
      SetConsoleTextAttribute(hStdout, FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY);
      break;
   case YELLOW:
      SetConsoleTextAttribute(hStdout, FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_INTENSITY);
      break;
   case WHITE:
      SetConsoleTextAttribute(hStdout, FOREGROUND_GREEN | FOREGROUND_RED | FOREGROUND_BLUE | FOREGROUND_INTENSITY);
      break;
   }
}
#else
// Must be ANSI control sequences or generic
#define GfxTextcolor(p1)
#endif

/**************************************************************************
*
*  PROCEDURE NAME - GfxClear
*
*  FUNCTION
*     This routine is called to clear the screen.
*
**************************************************************************/

static void GfxClear(void) // Clear the screen to blanks
{
#ifdef _CVI_
   Cls();
#elif defined(__TURBOC__)
   clrscr();               // DOS-Win 16 and Win 32 compatible Borland functions
#elif defined (__WIN32__)
   printf("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n");
#else
   printf("\033[2J");      // ANSI-compatible terminal control codes
#endif
}

/**************************************************************************
*
*  PROCEDURE NAME - GfxMove
*
*  FUNCTION
*     This routine is called to position the cursor on the screen.
*
**************************************************************************/

static void GfxMove(int x,int y) // Position the cursor for output at col, line
{
#ifdef _CVI_
   //  horizontal, vertical positions
   SetCaretPos(y,x);
#elif defined(__TURBOC__)
    // col  line
   gotoxy(y,x);            // DOS-Win 16 and Win 32 compatible Borland functions
#elif defined (__WIN32__)
   csbiInfo.dwCursorPosition.Y = x-1;
   csbiInfo.dwCursorPosition.X = y-1;
   SetConsoleCursorPosition(hStdout, csbiInfo.dwCursorPosition);
#else
   printf("\033[%d;%dH", x, y);  // ANSI-compatible terminal control codes
#endif
}

/****************************************************************************
*  Function AskForBoardDefs
*
*  Ask the user for the board definitions.
****************************************************************************/
static void AskForBoardDefs(void)
{
   char szMsg[200];      // GP text string.
   int  status,indx;
   
 //  GfxClear();  // Clear the screen
   printf("Device Number      Device Name\n\r");
   
   for(indx=0; indx<dlist.num_devices; indx++)
   {
       printf("      %d            %s \n\r",dlist.device_num[indx],dlist.name[indx]);
   } 
   printf("\n\r");
   printf("Test Config can run two 1553 channels on one or two boards\n\n\r");
   printf("Please select the Device Number for the first channel \n\rfrom the list Above(default 0):");
   fgets(szMsg, sizeof(szMsg), stdin);
   status = sscanf(szMsg, "%lx", &dwMemAddr[0]);

   if ( status != 1 )
      dwMemAddr[0] = 0;

Board0NotOK:
   printf("Please enter the Channel Number (1 - 4) for the first channel (default 1): ");

   fgets(szMsg, sizeof(szMsg), stdin);
   status = sscanf(szMsg, "%lx", &wIoAddr[0]);
   if ( status != 1 )
      wIoAddr[0] = 1;

   if(wIoAddr[0] < 1 || wIoAddr[0] > 4)
      goto Board0NotOK;

   wIoAddr[0]--;

   printf("\n\nPlease enter the Device Number for the second channel \n\rfrom the list Above(default 0):");
   fgets(szMsg, sizeof(szMsg), stdin);
   status = sscanf(szMsg, "%lx", &dwMemAddr[1]);
   if ( status != 1 )
      dwMemAddr[1] = 0;

Board1NotOK:
   printf("Please enter the Channel Number (1 - 4) for the second channel (default 2): ");
   fgets(szMsg, sizeof(szMsg), stdin);
   status = sscanf(szMsg, "%lx", &wIoAddr[1]);
   if ( status != 1 )
       wIoAddr[1] = 2;

   if(wIoAddr[1] < 1 || wIoAddr[1] > 4)
      goto Board1NotOK;

   wIoAddr[1]--;

   if((wIoAddr[0] == wIoAddr[1]) && (dwMemAddr[0] == dwMemAddr[1]))
      goto Board1NotOK;
   printf("\n\r");
}

/****************************************************************
*
*  display_command_args - Display a usage message to the user.
*
****************************************************************/
static void display_command_args(void)
{
   BT_UINT wUcode, wAPI;

   GfxTextcolor(LIGHTGREEN);
   BusTools_GetRevision(0, &wUcode, &wAPI);
   printf("\r\n\r\n\r\n\r\n");
   printf("   赏屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯屯籠r\n");
   printf("   

⌨️ 快捷键说明

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