changeset 1430:f578c190a661 draft

add files
author Daichi TOMA <toma@cr.ie.u-ryukyu.ac.jp>
date Wed, 28 Mar 2012 17:50:03 +0900
parents ae5fb867cf84
children 9b0908cb7553
files TaskManager/kernel/ppe/ExportTaskLog.cc TaskManager/kernel/ppe/ExportTaskLog.h TaskManager/kernel/ppe/TaskLog.cc
diffstat 3 files changed, 86 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TaskManager/kernel/ppe/ExportTaskLog.cc	Wed Mar 28 17:50:03 2012 +0900
@@ -0,0 +1,54 @@
+#include "ExportTaskLog.h"
+const char* const ExportTaskLog::FILENAME="logfile.xml";
+
+ExportTaskLog::ExportTaskLog(QueueInfo<TaskLog> *_tasklog)
+{
+    tasklog = _tasklog;
+
+    open();
+}
+
+ExportTaskLog::~ExportTaskLog()
+{
+    close();
+}
+
+void
+ExportTaskLog::open()
+{
+    if ((fp = fopen(FILENAME, "w")) == NULL) {
+        printf("file open error!\n");
+        exit(EXIT_FAILURE);
+    };
+}
+
+void
+ExportTaskLog::printOut()
+{
+    fprintf(fp, "<root>\n");
+    while(!tasklog->empty()){
+        TaskLog *log = tasklog->poll();
+        fprintf(fp, "<task>\n");
+        fprintf(fp, "\t<task_id>%d</task_id>\n", log->mtask_id);
+        fprintf(fp, "\t<cmd>%d</cmd>\n", log->cmd);
+        fprintf(fp, "\t<create_time>%llu</create_time>\n", log->create_time);
+        fprintf(fp, "\t<execute_time>%llu</execute_time>\n", log->execute_time);
+        fprintf(fp, "\t<finish_time>%llu</finish_time>\n", log->finish_time);
+        while(!log->wait_for_list.empty()){
+            waitTask *task = log->wait_for_list.poll();
+            fprintf(fp, "\t<wait_for>\n");
+            fprintf(fp, "\t\t<task_id>%d</task_id>\n", task->task_id);
+            fprintf(fp, "\t\t<cmd>%d</cmd>\n", task->cmd);
+            fprintf(fp, "\t</wait_for>\n");
+        }
+        fprintf(fp, "</task>\n");
+    }
+    fprintf(fp, "</root>\n");
+}
+
+void
+ExportTaskLog::close()
+{
+    fclose(fp);
+}
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TaskManager/kernel/ppe/ExportTaskLog.h	Wed Mar 28 17:50:03 2012 +0900
@@ -0,0 +1,28 @@
+#ifndef included_exporttasklog
+#define included_exporttasklog
+
+#include <stdio.h>
+#include "TaskLog.h"
+#include "QueueInfo.h"
+
+class ExportTaskLog {
+public:
+    ExportTaskLog(QueueInfo<TaskLog> *_tasklog);
+    virtual ~ExportTaskLog();
+
+public:
+    void open();
+    void printOut();
+    void close();
+
+private:
+    QueueInfo<TaskLog> *tasklog;
+    FILE *fp;
+
+    static const char* const FILENAME;
+
+};
+
+
+
+#endif
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/TaskManager/kernel/ppe/TaskLog.cc	Wed Mar 28 17:50:03 2012 +0900
@@ -0,0 +1,4 @@
+#include "TaskLog.h"
+
+// initialize
+int TaskLog::task_id = 0;