src/SituationsLog.cpp

Go to the documentation of this file.
00001 #include "SituationsLog.h"
00002 #include <stdio.h>
00003 #include <math.h>
00004 
00005 SituationsLog::SituationsLog(int iPlayerNr, char* strTeamName)
00006 {
00007   // try to open file
00008   char filename[255];
00009   sprintf(filename, "%s-#%.2i", strTeamName, iPlayerNr); 
00010   log = fopen(filename, "w+");
00011   
00012   if (log == 0)
00013         printf("\nError opening file'%s'", filename);
00014   else
00015     printf("\nLog file succesfully opened\n");
00016 
00017   // printf XML header    
00018   fprintf(log, "<?xml version=\"1.0\" standalone=\"yes\"?>\n");
00019   fprintf(log, "<Situations xmlns=\"http://www2.dcs.elf.stuba.sk/TeamProject/2006/team03/SituationsSchema.xsd\">\n");      
00020 }
00021  
00022 SituationsLog::~SituationsLog()
00023 {
00024   fprintf(log, "</Situations>\n"); 
00025   fclose(log);  
00026 }
00027 
00028 void SituationsLog::situationBegin(char* strType, int iTime)
00029 {
00030   fprintf(log, "  <Situation type=\"%s\" time=\"%i\">\n", strType, iTime);
00031 }
00032 
00033 void SituationsLog::situationEnd()
00034 {
00035   fprintf(log, "  </Situation>");
00036 }
00037   
00038 void SituationsLog::addObject(char strType[], double iX, double iY, char color[])
00039 {
00040   fprintf(log, "    <Object x=\"%i\" y=\"%i\" type=\"%s\" color=\"%s\" />\n", (int)round(iX), (int)round(iY), strType, color);
00041 }
00042 
00043 void SituationsLog::addObject(char strType[], double iX, double iY, char color[], double value)
00044 {
00045   fprintf(log, "    <Object x=\"%i\" y=\"%i\" type=\"%s\" color=\"%s\" value=\"%.2f\" />\n", (int)round(iX), (int)round(iY), strType, color, value);
00046 }
00047 
00048 void SituationsLog::addObject(char strType[], double dX, double dY)
00049 {
00050   fprintf(log, "    <Object x=\"%i\" y=\"%i\" type=\"%s\" />\n", (int)round(dX), (int)round(dY), strType);
00051 }
00052 
00053 void SituationsLog::addObject(char strType[], double dX, double dY, double dX2, double dY2)
00054 {
00055   fprintf(log, "    <Object x=\"%i\" y=\"%i\" type=\"%s\" x2=\"%i\" y2=\"%i\" />\n", (int)round(dX), (int)round(dY), strType, (int)round(dX2), (int)round(dY2));
00056 }
00057 
00058 void SituationsLog::addObject(char strType[], double dX, double dY, double dX2, double dY2, char color[])
00059 {
00060   fprintf(log, "    <Object x=\"%i\" y=\"%i\" type=\"%s\" x2=\"%i\" y2=\"%i\" color=\"%s\" />\n", (int)round(dX), (int)round(dY), strType, (int)round(dX2), (int)round(dY2), color);
00061 }
00062 
00063 void SituationsLog::addObject(char strType[], double dX, double dY, double dX2, double dY2, char color[], double value)
00064 {
00065   fprintf(log, "    <Object x=\"%i\" y=\"%i\" type=\"%s\" x2=\"%i\" y2=\"%i\" color=\"%s\" value=\"%.2f\" />\n", (int)round(dX), (int)round(dY), strType, (int)round(dX2), (int)round(dY2), color, value);
00066 }
00067 
00068 void SituationsLog::addObject(char strType[], double dX, double dY, double radius)
00069 {
00070   fprintf(log, "    <Object x=\"%i\" y=\"%i\" type=\"%s\" radius=\"%i\" />\n", (int)round(dX), (int)round(dY), strType, (int)round(radius));
00071 }

Generated on Thu Apr 26 22:45:28 2007 for GangOfSix(GOS)-RoboCupTeamProject by  doxygen 1.5.1-p1