int main(int argc, char **argv) { int ADCvalue01 = 0; int StepSpeed = 100; //Stepping speed (smaler value = faster) int i = 0; int KeyHit = 0; int KeyCode[5]; int SingleKey=0; char TextLine[300]; char FileName[100] = ""; char FileNameOld[100] = ""; char FullFileName[300]; char a; char IsDigit[]="-1234567890"; int ReadState = 0; int MenueLevel = 0; int FileSelected = 0; int FileStartRow = 0; int stopPlot = 0; long xMin = 1000000, xMax = -1000000; long yMin = 1000000, yMax = -1000000; long coordinateCount = 0; long coordinatePlot = 0; long currentPlotX = 0, currentPlotY = 0, currentPlotDown = 1; long xNow = 0, yNow = 0, zNow = 0; char *pEnd; FILE *PlotFile; double Scale = 1.0; double OldScale = 1.0; double PicWidth = 0.0; double PicHeight = 0.0; long MoveLength = 100; long OldMoveLength = 200; long PlotStartTime = 0; int MoveFinished = 0; long stepPause = 5000; long stepPauseNormal = 5000; long stepPauseMaterial = 20000; long zHub = 200; int plotterMode = 1; char FileInfo[3]; long FileSize; long LongTemp; long DataOffset; long HeaderSize; long PictureWidth; long PictureHeight; int IntTemp; int ColorDepth; long CompressionType; long PictureSize; long XPixelPerMeter; long YPixelPerMeter; long ColorNumber; long ColorUsed; int PixelRed, PixelGreen, PixelBlue; int PixOK = 0; long StepsPerPixelX = 50, StepsPerPixelY = 50; long JetOffset1 = 40, JetOffset2 = 40; //Mapping between wiringPi and pin order of my I/O board. //This was necessary, because I used a wrong description of the GPIOs //You have to change the order according to your board! //@@@THESE ARE ALL OUTPUS!! strcpy(FileName, "noFiLE"); if (wiringPiSetup () == -1){ printf("Could not run wiringPiSetup!"); exit(1); } getmaxyx(stdscr, MaxRows, MaxCols); MessageY = MaxRows-3; clrscr(1, MaxRows); PrintRow('-', MessageY - 1); initscr(); noecho(); cbreak(); start_color(); while(!quit) { clearScreen(); char * choices[] = {"Plot File","Manual Control","Servo Control","Opto Sensor Control","X&Y Control","initalize","Exit"}; char *description[] = { "You select a file to plot and will plot the file on the plotter", "Will give you full control over the plotter for debuging or demenstration", "Lets you enter and test different duration of pulses sent to the servo for fine tuning and debugging", "Will read in the togleing of the opto sensor for debuging", "Will let you have control how much to move in x and y by ticks more precisly", "Test initalization procedure", "Will exit the prgram"}; int result = menus("Hello and Welcome to my creation please sleect a mode", choices,description,7,20); switch (result) { case 1: ; /* FILE * fp; char * line = NULL; size_t len = 0; ssize_t read; fp = fopen ("sampleGcode.txt","r");*/ //Plot file char dir[1024]; getcwd(dir,sizeof(dir)); MessageText("3 seconds until plotting starts !!!!!!!!!!!!!!!!!", 1, 2, 0); delay(3000); if((PlotFile=chooseFile(dir))==NULL){ sprintf(TextLine, "Can't open file '%s'!\n", FullFileName); strcpy(FileName, "NoFiLE"); ErrorText(TextLine); } else{ currentPlotX = 0; currentPlotY = 0; PlotStartTime = time(0); PrintMenue_03(FullFileName, coordinateCount, 0, 0, 0, PlotStartTime,Scale); coordinatePlot = 0; stopPlot = 0; if(currentPlotDown == 1){ penMove(1); currentPlotDown = 0; } while(!(feof(PlotFile)) && stopPlot == 0){ fread(&a, 1, 1, PlotFile); if(a == '>'){ ReadState = 0; } if(ReadState == 0 || ReadState == 1){ TextLine[i] = a; TextLine[i+1] = '\0'; i++; } if(ReadState == 2 || ReadState == 3){ if(strchr(IsDigit, a) != NULL){ TextLine[i] = a; TextLine[i+1] = '\0'; i++; } } if(ReadState == 2){ if(strchr(IsDigit, a) == NULL){ if(strlen(TextLine) > 0){ xNow = (strtol(TextLine, &pEnd, 10) - xMin) * 0.33333 * Scale; ReadState = 3; i=0; TextLine[0]='\0'; } } } if(ReadState == 3){ if(strchr(IsDigit, a) == NULL){ if(strlen(TextLine) > 0){ yNow = ((yMax - strtol(TextLine, &pEnd, 10)) - yMin) * 0.33333 * Scale;//Flip around y-axis coordinatePlot++; PrintMenue_03(FullFileName, coordinateCount, coordinatePlot, xNow, yNow, PlotStartTime, Scale); if(stopPlot == 0){ stopPlot =0; moveXY(xNow - currentPlotX, yNow - currentPlotY); currentPlotX = xNow; currentPlotY = yNow; // sprintf(TextLine, "xNow=%ld, yNow=%ld", xNow, yNow); // MessageText(TextLine, MessageX+1, MessageY+1, 0); // getch(); } else{ if(currentPlotDown == 1){ if(plotterMode == 1){ penMove(1); } currentPlotDown = 0; } } if(currentPlotDown == 0){ if(stopPlot == 0){ penMove(0); currentPlotDown = 1; } } ReadState = 2; i=0; TextLine[0]='\0'; } } } if(strcmp(TextLine, "<path") == 0){ if(currentPlotDown == 1){ penMove(1); currentPlotDown = 0; } ReadState = 2; i = 0; TextLine[0]='\0'; } if(a == '<'){ i = 1; TextLine[0] = a; TextLine[1] = '\0'; ReadState = 1; } } fclose(PlotFile); if(currentPlotDown == 1){ penMove(1); currentPlotDown = 0; } PrintMenue_03(FullFileName, coordinateCount, coordinatePlot, 0, 0, PlotStartTime,Scale); moveXY(-currentPlotX, -currentPlotY); currentPlotX = 0; currentPlotY = 0; while(kbhit()){ getch(); } MessageText("Finished! Press any key to return to main menu.", MessageX, MessageY, 0); getch(); break; } break; case 2: manualControl(); break; case 3: servoControl(); break; case 4: optoControl(); break; case 5: xyControl(); break; case 6: initalize(); break; case -1: default: system("reset"); quit=true; break; } } allSTOP(); endwin(); return 0; }
void ArraysAdv1Lab::GamePaint(RECT rect) { PrintRow(m_EvenArr,MAX_EVEN,25,25); PrintRow(m_RandArr,MAX_RAND,25,60); }
void Counter::FilterCommands(vector<LfcCommand *> * commands) { int numberOfBadLfcLs = 0; int nubmerOfGoodLfcLs = 0; int nubmerOfGoodLfcCr = 0; int nubmerOfBadLfcCr = 0; int numberOfGoodReplicate = 0; int numberOfBadReplicate = 0; int numberOfGoodMkDir = 0; int numberOfBadMkDir = 0; int numberOfCP = 0; int numberOfGoodDelReplica = 0; int numberOfBadDelReplica = 0; int numberOfServErrors = 0; int numberPingDB = 0; int numberOfUTimes = 0; int numberOfSymlinks = 0; int numberOfRmDir = 0; int numberOfLr = 0; std::vector<LfcCommand *>::const_iterator iterator; for (iterator = commands->begin(); iterator != commands->end(); ++iterator) { LfcCommand * command = *iterator; if (command != NULL) { LFCCommandName function = command->GetName(); if (function == LFC_LS) { if (command->IsFailed()) { numberOfBadLfcLs++; } else { nubmerOfGoodLfcLs++; } } if (function == LCG_CR) { if (command->IsFailed()) { nubmerOfBadLfcCr++; } else { nubmerOfGoodLfcCr++; } } else if (function == LCG_REP) { if (command->IsFailed()) { numberOfBadReplicate++; } else { numberOfGoodReplicate++; } } else if (function == LFC_MKDIR) { if (command->IsFailed()) { numberOfBadMkDir++; } else { numberOfGoodMkDir++; } } else if (function == LCG_CP) { numberOfCP++; } else if (function == LCG_DEL) { if (command->IsFailed()) { numberOfBadDelReplica++; } else { numberOfGoodDelReplica++; } } else if (function == LCG_SERV) { numberOfServErrors++; } else if (function == LCG_PINGDB) { numberPingDB++; } else if (function == LCG_UTIME) { numberOfUTimes++; } else if (function == LCG_AA) { numberOfSymlinks++; } else if (function == LCG_RM) { numberOfRmDir++; } else if (function == LCG_LR) { numberOfLr++; } } } printf("|%-12s |%10s |%10s |\n", "command", "failed", "good"); PrintRow("lfc-ls", numberOfBadLfcLs, nubmerOfGoodLfcLs); PrintRow("lcg-cr", nubmerOfBadLfcCr, nubmerOfGoodLfcCr); PrintRow("lcg-rep", numberOfBadReplicate, numberOfGoodReplicate); PrintRow("lfc-mkdir", numberOfBadMkDir, numberOfGoodMkDir); PrintRow("lcg-cp", -1, numberOfCP); PrintRow("lcg-pingdb", numberPingDB, 0); PrintRow("lcg-del", -1, numberOfGoodDelReplica); PrintRow("srv-err", numberOfServErrors, 0); PrintRow("utimes", 0, numberOfUTimes); PrintRow("lcg-aa", -1, numberOfSymlinks); PrintRow("lcg-rm", -1, numberOfRmDir); PrintRow("lcg-lr", -1, numberOfLr); cout << "lcg-rep failed contains lcg-cp failed and lcg-del failed because they are written the same to log." << endl; }