示例#1
0
/**
 * Write a name/value pair to the EW microRecorder.
 */
static bool
WritePair(Port &port, const char *name, const TCHAR *value)
{
    return WriteLabel(port, name) &&
           WriteCleanString(port, value, 1000) &&
           port.FullWrite("\r\n", 2, 500);
}
示例#2
0
/**
 * Write a name/value pair to the EW microRecorder.
 */
static bool
WritePair(Port &port, const char *name, const TCHAR *value,
          OperationEnvironment &env)
{
  return WriteLabel(port, name, env) &&
    WriteCleanString(port, value, env, 1000) &&
    port.FullWrite("\r\n", 2, env, 500);
}
示例#3
0
void CSoma::WriteIDYZ(CImage& anImage, unsigned char color)
{
	int VFrom = m_Center.m_iZ - DigitWidth / 2;
	int VTo = m_Center.m_iZ + DigitWidth / 2;
	int HFrom = m_Center.m_iY - DigitWidth / 2;
	int HTo = m_Center.m_iY + DigitWidth / 2;

	WriteLabel(anImage, VFrom, VTo, HFrom, HTo, color);
}
示例#4
0
static bool
EWMicroRecorderWriteWaypoint(Port &port, const char *type,
                             const Waypoint &way_point)
{
    return WriteLabel(port, type) &&
           WriteGeoPoint(port, way_point.location) &&
           port.Write(' ') &&
           WriteCleanString(port, way_point.name.c_str(), 1000) &&
           port.FullWrite("\r\n", 2, 500);
}
示例#5
0
//+++-S-cf-------------------------------------------------------------------
//  NAME:       Draw()
//  DESC:       Draw legend
//  PARAMETERS: CHART_HPAINT hp, 
//              CHART_HRECT hr
//  RETURN:     None
//----------------------------------------------------------------------E-+++
void wxLegend::Draw(
    CHART_HPAINT hp, 
    CHART_HRECT hr
)
{    
    int iPages = NumPages();
    int iLines = iPages > 0 ? ROWS_PAGE : GetCount();
    wxCoord h;
    //h = (ROWS_PAGE * ROW_SIZE < hr->h) ? ROWS_PAGE * ROW_SIZE : hr->h;
    h = (iLines * ROW_SIZE < hr->h) ? iLines * ROW_SIZE : hr->h;

    wxCoord x, y;
    x = (wxCoord)( 5 + hr->x );
    y = (wxCoord)( 5 + hr->y );

    //-----------------------------------------------------------------------
    // draw arrows
    //-----------------------------------------------------------------------
    if ( iPages > 0 )
    {
        hp->SetBrush( *wxGREY_BRUSH );
        hp->SetPen( *wxBLACK_PEN );
        
        DrawArrow( hp, x+hr->w/2, y, 8, ARROW_UP, false );
        hp->DrawLine( x+15, y+10, x+hr->w-15, y+10);
        DrawArrow( hp, x+hr->w/2, y + 20, 8, ARROW_DOWN, false );
    }

    //-----------------------------------------------------------------------
    // draw shadow
    //-----------------------------------------------------------------------
    y += 30;
    hp->SetBrush( *wxGREY_BRUSH );
    hp->SetPen( *wxTRANSPARENT_PEN );
    hp->DrawRectangle( x +5, y +5, hr->w - 10, h );

    //-----------------------------------------------------------------------
    // draw legend window
    //-----------------------------------------------------------------------
    hp->SetBrush( *wxWHITE_BRUSH );
    hp->SetPen( *wxBLACK_PEN );
    hp->DrawRectangle( x, y, hr->w - 10, h );

    //-----------------------------------------------------------------------
    // write labels
    //-----------------------------------------------------------------------
    WriteLabel( hp, x+3, y+3, m_Page );

}
示例#6
0
文件: main.c 项目: Nabeko/nand2tetris
int main(int argc, char* argv[])
{
  struct dirent *pDirent;
  DIR *pDir;
  char *dirName;
  char inputFilename[128];

  FILE *inP, *outP; // input and output file
  Command *vmCommands; // all VM Commands
  int count=0; // count of instructions
  int i; // loop index
  Command *currentCommand = NULL;
  
  if(argc != 2) {
    printf("Usage : VMTranslator <directory>");
    return -1;
  }
  
  dirName = argv[1];

  // open directory  
  pDir = opendir (dirName);
  if(pDir == NULL) {
    printf("Can not open directory '%s'\n", dirName);
  }

  vmCommands = (Command*)malloc(sizeof(Command) * MAX_COMMAND_NUM);

  // create the output file
  outP = Open(dirName, basename(dirName));
  if(!outP) {
    printf("File open failed!\n");
    goto failed;
  }
  WriteInit(outP);

  
  while ((pDirent = readdir(pDir)) != NULL) {
    // only open the *.vm files in directory
    if( CheckFileExtension(pDirent->d_name) ) {
        sprintf(inputFilename, "%s/%s", dirName, pDirent->d_name);
        // open the input file
        inP = fopen(inputFilename, "r");
        if(!inP) {
          printf("File '%s' open failed!\n", inputFilename);
          continue;
        }

        SetFileName(basename(inputFilename));

        memset(vmCommands, 0, MAX_COMMAND_NUM);

		count = Parse(inP, &vmCommands);
        for( i = 0; i < count; i++) {
           currentCommand = vmCommands + i;
           switch(currentCommand->commandType){
              case C_ARITHMETIC:
	               WriteArithmetic(outP, currentCommand->arg1);
                   break;
              case C_LABEL:
                   WriteLabel(outP, currentCommand->arg1);
                   break;
              case C_GOTO:
                   WriteGoTo(outP, currentCommand->arg1);
                   break;
              case C_IF:
                   WriteIf(outP, currentCommand->arg1);
                   break;
              case C_PUSH:
              case C_POP:
                   WritePushPop(outP, currentCommand->commandType, currentCommand->arg1, currentCommand->arg2);
                   break;
              case C_FUNCTION:
                   WriteFunction(outP, currentCommand->arg1, currentCommand->arg2);
                   break;
              case C_CALL:
                   WriteCall(outP, currentCommand->arg1, currentCommand->arg2);
                   break;
              case C_RETURN:
                   WriteReturn(outP);
                   break;
              default:
                   break;
	        }
        }
        fclose(inP);
    }
  }
  closedir (pDir);
  Close(outP);

failed:
  free(vmCommands);

  return 0;
}