Commit 3d742256 authored by EYRAUD-DUBOIS Lionel's avatar EYRAUD-DUBOIS Lionel
Browse files

Support for saving multiple schedules in one file

parent be8f47ac
...@@ -21,12 +21,25 @@ int ActionSequence::chooseType(int t, int nr) { ...@@ -21,12 +21,25 @@ int ActionSequence::chooseType(int t, int nr) {
return -1; return -1;
} }
ExportToFile::ExportToFile(string filename, Instance* ins, bool header) ExportToFile::ExportToFile(string filename, Instance* ins, bool header, string name)
: output(filename), instance(ins) { : output(filename), instance(ins), name(name) {
if(name != "")
output << "sched ";
if(header) if(header)
output << "Tid worker taskType start duration end" << endl; output << "Tid worker taskType start duration end" << endl;
} }
void ExportToFile::changeName(string newName) {
if((name == "" && newName != "")) {
cerr << "EtF: Warning, adding a name after the start breaks the header" << endl;
}
if(name != "" && newName == "") newName = "NA";
name = newName;
}
void ExportToFile::onSchedule(int i, int w, double s, double f) { void ExportToFile::onSchedule(int i, int w, double s, double f) {
if(name != "")
this->output << name << " ";
this->output << i << " " << w << " " << instance->taskTypes[i] << " " this->output << i << " " << w << " " << instance->taskTypes[i] << " "
<< s << " " << (f - s) << " " << f << endl; << s << " " << (f - s) << " " << f << endl;
} }
......
...@@ -24,11 +24,13 @@ class ActionSequence : public SchedAction { ...@@ -24,11 +24,13 @@ class ActionSequence : public SchedAction {
}; };
class ExportToFile : public SchedAction { class ExportToFile : public SchedAction {
ofstream output; std::ofstream output;
Instance* instance; Instance* instance;
std::string name;
public: public:
ExportToFile(string filename, Instance* ins, bool header = false); ExportToFile(std::string filename, Instance* ins, bool header = false, std::string name ="");
void onSchedule(int i, int w, double s, double f); void onSchedule(int i, int w, double s, double f);
void changeName(std::string newName);
~ExportToFile(); ~ExportToFile();
}; };
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment