diff --git a/simulators/c++2/src_simulator/arch/CPU.cpp b/simulators/c++2/src_simulator/arch/CPU.cpp index 6415fa913ae2d74357b909c4ed822209f7c96cfb..9a9daae7db99ce741b53c9c7e5e7ce1dc42eafa2 100644 --- a/simulators/c++2/src_simulator/arch/CPU.cpp +++ b/simulators/c++2/src_simulator/arch/CPU.cpp @@ -168,7 +168,7 @@ void CPU::schedule2XML(std::ostringstream& glob,std::ofstream& myfile) const{ } } -std::map<TMLTask*, std::string> CPU::HWTIMELINE2HTML(std::ofstream& myfile,std::map<TMLTask*, std::string> taskCellClasses,unsigned int nextCellClassIndex, std::string& iTracetaskList) const { +std::map<TMLTask*, std::string> CPU::HWTIMELINE2HTML(std::ostringstream& myfile,std::map<TMLTask*, std::string> taskCellClasses,unsigned int nextCellClassIndex, std::string& iTracetaskList) const { TransactionList _transactListClone; std::string taskList = iTracetaskList.c_str(); for (int z = 0; z < _transactList.size(); z++) { @@ -223,9 +223,11 @@ std::map<TMLTask*, std::string> CPU::HWTIMELINE2HTML(std::ofstream& myfile,std:: listScaleTime.push_back(aCurrTrans->getStartTime()+1); } if (isBlankTooBig){ - writeHTMLColumn( myfile, aBlanks+1, "not", "idle time", "<- idle " + tempString.str() + " ->", false ); + myfile << "<td colspan=\""<< aBlanks+1 <<"\" title=\"idle time\" class=\"not\">" << "<- idle " + tempString.str() + " ->" << "</td>\n"; +// writeHTMLColumn( myfile, aBlanks+1, "not", "idle time", "<- idle " + tempString.str() + " ->", false ); } else { - writeHTMLColumn( myfile, aBlanks+1, "not", "idle time" ); + myfile << "<td colspan=\""<< aBlanks+1 <<"\" title=\"idle time\" class=\"not\"></td>\n"; +// writeHTMLColumn( myfile, aBlanks+1, "not", "idle time" ); } } else if ( aBlanks > 0 ){ @@ -235,9 +237,11 @@ std::map<TMLTask*, std::string> CPU::HWTIMELINE2HTML(std::ofstream& myfile,std:: listScaleTime.push_back(aCurrTrans->getStartTime()); } if (isBlankTooBig){ - writeHTMLColumn( myfile, aBlanks, "not", "idle time", "<- idle " + tempString.str() + " ->", false ); + myfile << "<td colspan=\""<< aBlanks <<"\" title=\"idle time\" class=\"not\">" << "<- idle " + tempString.str() + " ->" << "</td>\n"; +// writeHTMLColumn( myfile, aBlanks, "not", "idle time", "<- idle " + tempString.str() + " ->", false ); } else { - writeHTMLColumn( myfile, aBlanks, "not", "idle time" ); + myfile << "<td colspan=\""<< aBlanks <<"\" title=\"idle time\" class=\"not\"></td>\n"; +// writeHTMLColumn( myfile, aBlanks, "not", "idle time" ); } } @@ -251,7 +255,8 @@ std::map<TMLTask*, std::string> CPU::HWTIMELINE2HTML(std::ofstream& myfile,std:: listScale.push_back(aLength); std::ostringstream title; title << "idle:" << aCurrTrans->getIdlePenalty() << " switching penalty:" << aCurrTrans->getTaskSwitchingPenalty(); - writeHTMLColumn( myfile, aLength, "not", title.str() ); + myfile << "<td colspan=\"" << aLength << "\" title=\"" << title.str() << "\" class=\"not\"></td>\n"; +// writeHTMLColumn( myfile, aLength, "not", title.str() ); } aLength = aCurrTrans->getOperationLength(); @@ -266,7 +271,8 @@ std::map<TMLTask*, std::string> CPU::HWTIMELINE2HTML(std::ofstream& myfile,std:: tempReduce += aLength - 10; aLength = 10; } - writeHTMLColumn( myfile, aLength, cellClass, aCurrTrans->toShortString(), aCurrContent ); + myfile << "<td colspan=\"" << aLength << "\" title=\"" << aCurrTrans->toShortString() << "\" class=\""<< cellClass <<"\">"<< aCurrContent <<"</td>\n"; +// writeHTMLColumn( myfile, aLength, cellClass, aCurrTrans->toShortString(), aCurrContent ); listScale.push_back(aLength); if(aCurrTrans->getStartTime() > listScaleTime.back()){ listScaleTime.push_back(aCurrTrans->getStartTime()); @@ -300,14 +306,18 @@ std::map<TMLTask*, std::string> CPU::HWTIMELINE2HTML(std::ofstream& myfile,std:: spanVal << ""; if(aLength+1 >= listScale.size()){ if(changeCssClass){ - writeHTMLColumn( myfile, 5, "sc1", spanVal.str(), spanVal.str(), false ); + myfile << "<td colspan=\"5\" class=\"sc1\">" << spanVal.str() << "</td>"; +// writeHTMLColumn( myfile, 5, "sc1", spanVal.str(), spanVal.str(), false ); } else - writeHTMLColumn( myfile, 5, "sc", spanVal.str(), spanVal.str(), false ); + myfile << "<td colspan=\"5\" class=\"sc\">" << spanVal.str() << "</td>"; +// writeHTMLColumn( myfile, 5, "sc", spanVal.str(), spanVal.str(), false ); }else { if(changeCssClass){ - writeHTMLColumn( myfile, listScale[aLength+1], "sc1", spanVal.str(), spanVal.str(), false ); + myfile << "<td colspan=\"" << listScale[aLength+1] << "\" class=\"sc1\">" << spanVal.str() << "</td>"; +// writeHTMLColumn( myfile, listScale[aLength+1], "sc1", spanVal.str(), spanVal.str(), false ); } else - writeHTMLColumn( myfile, listScale[aLength+1], "sc", spanVal.str(), spanVal.str(), false ); + myfile << "<td colspan=\"" << listScale[aLength+1] << "\" class=\"sc\">" << spanVal.str() << "</td>"; +// writeHTMLColumn( myfile, listScale[aLength+1], "sc", spanVal.str(), spanVal.str(), false ); } //myfile << "<td colspan=\"5\" class=\"sc\">" << aLength << "</td>"; } diff --git a/simulators/c++2/src_simulator/arch/CPU.h b/simulators/c++2/src_simulator/arch/CPU.h index 71c9de992436648116193b4803794b7a1c694b9b..3ce2797cf8bf0162ed5cda1424cb276c83940353 100755 --- a/simulators/c++2/src_simulator/arch/CPU.h +++ b/simulators/c++2/src_simulator/arch/CPU.h @@ -121,7 +121,7 @@ public: void buttonPieChart(std::ofstream& myfile) const; void showPieChart(std::ofstream& myfile) const; void HW2HTML(std::ofstream& myfile) const; - std::map<TMLTask*, std::string> HWTIMELINE2HTML(std::ofstream& myfile,std::map<TMLTask*, std::string> taskCellClasses,unsigned int nextCellClassIndex, std::string& iTracetaskList) const; + std::map<TMLTask*, std::string> HWTIMELINE2HTML(std::ostringstream& myfile,std::map<TMLTask*, std::string> taskCellClasses,unsigned int nextCellClassIndex, std::string& iTracetaskList) const; void schedule2HTML(std::ofstream& myfile) const; void schedule2XML(std::ostringstream& glob,std::ofstream& myfile) const; inline void setCoreNumberGraph(unsigned int n){ _coreNumberGraph=n;} diff --git a/simulators/c++2/src_simulator/arch/FPGA.cpp b/simulators/c++2/src_simulator/arch/FPGA.cpp index 260db510d35cb4e602459601abbf9f252ea0dc70..7420e309290c79cc2f56045dd9c5e994e8d3c70d 100644 --- a/simulators/c++2/src_simulator/arch/FPGA.cpp +++ b/simulators/c++2/src_simulator/arch/FPGA.cpp @@ -593,7 +593,7 @@ std::string FPGA::determineHTMLCellClass(std::map<TMLTask*, std::string> &taskCo return taskColors[ task ]; } -std::map<TMLTask*, std::string> FPGA::HWTIMELINE2HTML(std::ofstream& myfile,std::map<TMLTask*, std::string> taskCellClasses1,unsigned int nextCellClassIndex1, std::string& iTracetaskList) { +std::map<TMLTask*, std::string> FPGA::HWTIMELINE2HTML(std::ostringstream& myfile,std::map<TMLTask*, std::string> taskCellClasses1,unsigned int nextCellClassIndex1, std::string& iTracetaskList) { TransactionList _transactListClone; std::string taskList = iTracetaskList.c_str(); for (int z = 0; z < _transactList.size(); z++) { @@ -651,9 +651,9 @@ std::map<TMLTask*, std::string> FPGA::HWTIMELINE2HTML(std::ofstream& myfile,std: listScaleTime.push_back(aCurrTrans->getStartTime()+1); } if (isBlankTooBig){ - writeHTMLColumn( myfile, aBlanks+1, "not", "idle time", "<- idle " + tempString.str() + " ->", false ); + myfile << "<td colspan=\""<< aBlanks+1 <<"\" title=\"idle time\" class=\"not\">" << "<- idle " + tempString.str() + " ->" << "</td>\n"; } else { - writeHTMLColumn( myfile, aBlanks+1, "not", "idle time" ); + myfile << "<td colspan=\""<< aBlanks+1 <<"\" title=\"idle time\" class=\"not\"></td>\n"; } } else if ( aBlanks > 0 ){ @@ -663,9 +663,9 @@ std::map<TMLTask*, std::string> FPGA::HWTIMELINE2HTML(std::ofstream& myfile,std: listScaleTime.push_back(aCurrTrans->getStartTime()); } if (isBlankTooBig){ - writeHTMLColumn( myfile, aBlanks, "not", "idle time", "<- idle " + tempString.str() + " ->", false ); + myfile << "<td colspan=\""<< aBlanks <<"\" title=\"idle time\" class=\"not\">" << "<- idle " + tempString.str() + " ->" << "</td>\n"; } else { - writeHTMLColumn( myfile, aBlanks, "not", "idle time" ); + myfile << "<td colspan=\""<< aBlanks <<"\" title=\"idle time\" class=\"not\"></td>\n"; } } @@ -679,7 +679,8 @@ std::map<TMLTask*, std::string> FPGA::HWTIMELINE2HTML(std::ofstream& myfile,std: tempReduce += aLength - 10; aLength = 10; } - writeHTMLColumn( myfile, aLength, cellClass, aCurrTrans->toShortString(), aCurrContent ); + myfile << "<td colspan=\"" << aLength << "\" title=\"" << aCurrTrans->toShortString() << "\" class=\""<< cellClass <<"\">"<< aCurrContent <<"</td>\n"; +// writeHTMLColumn( myfile, aLength, cellClass, aCurrTrans->toShortString(), aCurrContent ); listScale.push_back(aLength); if(aCurrTrans->getStartTime() > listScaleTime.back()){ listScaleTime.push_back(aCurrTrans->getStartTime()); @@ -716,14 +717,18 @@ std::map<TMLTask*, std::string> FPGA::HWTIMELINE2HTML(std::ofstream& myfile,std: if(aLength+1 >= listScale.size()){ if(changeCssClass){ - writeHTMLColumn( myfile, 5, "sc1", spanVal.str(), spanVal.str(), false ); + myfile << "<td colspan=\"5\" class=\"sc1\">" << spanVal.str() << "</td>"; +// writeHTMLColumn( myfile, 5, "sc1", spanVal.str(), spanVal.str(), false ); } else - writeHTMLColumn( myfile, 5, "sc", spanVal.str(), spanVal.str(), false ); + myfile << "<td colspan=\"5\" class=\"sc\">" << spanVal.str() << "</td>"; +// writeHTMLColumn( myfile, 5, "sc", spanVal.str(), spanVal.str(), false ); } else { if(changeCssClass){ - writeHTMLColumn( myfile, listScale[aLength+1], "sc1", spanVal.str(), spanVal.str(), false ); + myfile << "<td colspan=\"" << listScale[aLength+1] << "\" class=\"sc1\">" << spanVal.str() << "</td>"; +// writeHTMLColumn( myfile, listScale[aLength+1], "sc1", spanVal.str(), spanVal.str(), false ); } else - writeHTMLColumn( myfile, listScale[aLength+1], "sc", spanVal.str(), spanVal.str(), false ); + myfile << "<td colspan=\"" << listScale[aLength+1] << "\" class=\"sc\">" << spanVal.str() << "</td>"; +// writeHTMLColumn( myfile, listScale[aLength+1], "sc", spanVal.str(), spanVal.str(), false ); } } myfile << "</tr>" << std::endl << std::endl; diff --git a/simulators/c++2/src_simulator/arch/FPGA.h b/simulators/c++2/src_simulator/arch/FPGA.h index acd819bc3d6b75148dcdad963273cba811e763b9..a060e20830b4b615da7821217ba1077a64116dfa 100644 --- a/simulators/c++2/src_simulator/arch/FPGA.h +++ b/simulators/c++2/src_simulator/arch/FPGA.h @@ -133,7 +133,7 @@ public: ///inline unsigned int getTransNumber() { return _transNumber;} inline unsigned int getID () { return _ID;} void HW2HTML(std::ofstream& myfile) ; - std::map<TMLTask*, std::string> HWTIMELINE2HTML(std::ofstream& myfile,std::map<TMLTask*, std::string> taskCellClasses,unsigned int nextCellClassIndex, std::string& iTracetaskList); + std::map<TMLTask*, std::string> HWTIMELINE2HTML(std::ostringstream& myfile,std::map<TMLTask*, std::string> taskCellClasses1,unsigned int nextCellClassIndex1, std::string& iTracetaskList); void removeTrans(int numberOfTrans); void schedule2HTML(std::ofstream& myfile) ; inline const TaskList& getTaskList() const{return _taskList;} diff --git a/simulators/c++2/src_simulator/arch/SchedulableDevice.cpp b/simulators/c++2/src_simulator/arch/SchedulableDevice.cpp index a5e62d81f6c60da3e7f68f26b9af9f7d9bf37033..212733c60e37fa37fde82d8214f4b9edd432dfa5 100644 --- a/simulators/c++2/src_simulator/arch/SchedulableDevice.cpp +++ b/simulators/c++2/src_simulator/arch/SchedulableDevice.cpp @@ -298,7 +298,7 @@ void SchedulableDevice::buttonPieChart(std::ofstream& myfile) const{ myfile << " chart" << _ID << ".update();" << std::endl; } -std::map<TMLTask*, std::string> SchedulableDevice::HWTIMELINE2HTML(std::ofstream& myfile,std::map<TMLTask*, std::string> taskCellClasses,unsigned int nextCellClassIndex, std::string& iTracetaskList) const { +std::map<TMLTask*, std::string> SchedulableDevice::HWTIMELINE2HTML(std::ostringstream& myfile,std::map<TMLTask*, std::string> taskCellClasses,unsigned int nextCellClassIndex, std::string& iTracetaskList) const { TransactionList _transactListClone; std::string taskList = iTracetaskList.c_str(); for (int z = 0; z < _transactList.size(); z++) { @@ -347,9 +347,11 @@ std::map<TMLTask*, std::string> SchedulableDevice::HWTIMELINE2HTML(std::ofstream listScaleTime.push_back(aCurrTrans->getStartTime()+1); } if (isBlankTooBig){ - writeHTMLColumn( myfile, aBlanks+1, "not", "idle time", "<- idle " + tempString.str() + " ->", false ); + myfile << "<td colspan=\""<< aBlanks+1 <<"\" title=\"idle time\" class=\"not\">" << "<- idle " + tempString.str() + " ->" << "</td>\n"; +// writeHTMLColumn( myfile, aBlanks+1, "not", "idle time", "<- idle " + tempString.str() + " ->", false ); } else { - writeHTMLColumn( myfile, aBlanks+1, "not", "idle time" ); + myfile << "<td colspan=\""<< aBlanks+1 <<"\" title=\"idle time\" class=\"not\"></td>\n"; +// writeHTMLColumn( myfile, aBlanks+1, "not", "idle time" ); } } else if ( aBlanks > 0 ){ @@ -359,25 +361,28 @@ std::map<TMLTask*, std::string> SchedulableDevice::HWTIMELINE2HTML(std::ofstream listScaleTime.push_back(aCurrTrans->getStartTime()); } if (isBlankTooBig){ - writeHTMLColumn( myfile, aBlanks, "not", "idle time", "<- idle " + tempString.str() + " ->", false ); + myfile << "<td colspan=\""<< aBlanks <<"\" title=\"idle time\" class=\"not\">" << "<- idle " + tempString.str() + " ->" << "</td>\n"; +// writeHTMLColumn( myfile, aBlanks, "not", "idle time", "<- idle " + tempString.str() + " ->", false ); } else { - writeHTMLColumn( myfile, aBlanks, "not", "idle time" ); + myfile << "<td colspan=\""<< aBlanks <<"\" title=\"idle time\" class=\"not\"></td>\n"; +// writeHTMLColumn( myfile, aBlanks, "not", "idle time" ); } } - unsigned int aLength = aCurrTrans->getPenalties(); + unsigned int aLength = aCurrTrans->getPenalties(); - if ( aLength != 0 ) { - std::ostringstream title; - listScaleTime.push_back(listScaleTime.back()+aLength); - if(checkLastTime->getEndTime() >= 250 && aLength >10){ - tempReduce += aLength - 10; - aLength = 10; + if ( aLength != 0 ) { + std::ostringstream title; + listScaleTime.push_back(listScaleTime.back()+aLength); + if(checkLastTime->getEndTime() >= 250 && aLength >10){ + tempReduce += aLength - 10; + aLength = 10; + } + listScale.push_back(aLength); + title << "idle:" << aCurrTrans->getIdlePenalty() << " switching penalty:" << aCurrTrans->getTaskSwitchingPenalty(); + myfile << "<td colspan=\"" << aLength << "\" title=\"" << title.str() << "\" class=\"not\"></td>\n"; +// writeHTMLColumn( myfile, aLength, "not", title.str() ); } - listScale.push_back(aLength); - title << "idle:" << aCurrTrans->getIdlePenalty() << " switching penalty:" << aCurrTrans->getTaskSwitchingPenalty(); - writeHTMLColumn( myfile, aLength, "not", title.str() ); - } aLength = aCurrTrans->getOperationLength(); @@ -392,7 +397,8 @@ std::map<TMLTask*, std::string> SchedulableDevice::HWTIMELINE2HTML(std::ofstream tempReduce += aLength - 10; aLength = 10; } - writeHTMLColumn( myfile, aLength, cellClass, aCurrTrans->toShortString(), aCurrContent); + myfile << "<td colspan=\"" << aLength << "\" title=\"" << aCurrTrans->toShortString() << "\" class=\""<< cellClass <<"\">"<< aCurrContent <<"</td>\n"; +// writeHTMLColumn( myfile, aLength, cellClass, aCurrTrans->toShortString(), aCurrContent); listScale.push_back(aLength); if(aCurrTrans->getStartTime() > listScaleTime.back()){ listScaleTime.push_back(aCurrTrans->getStartTime()); @@ -427,14 +433,18 @@ std::map<TMLTask*, std::string> SchedulableDevice::HWTIMELINE2HTML(std::ofstream if(aLength+1 >= listScale.size()){ if(changeCssClass){ - writeHTMLColumn( myfile, 5, "sc1", spanVal.str(), spanVal.str(), false ); + myfile << "<td colspan=\"5\" class=\"sc1\">" << spanVal.str() << "</td>"; +// writeHTMLColumn( myfile, 5, "sc1", spanVal.str(), spanVal.str(), false ); } else - writeHTMLColumn( myfile, 5, "sc", spanVal.str(), spanVal.str(), false ); + myfile << "<td colspan=\"5\" class=\"sc\">" << spanVal.str() << "</td>"; +// writeHTMLColumn( myfile, 5, "sc", spanVal.str(), spanVal.str(), false ); }else { if(changeCssClass){ - writeHTMLColumn( myfile, listScale[aLength+1], "sc1", spanVal.str(), spanVal.str(), false ); + myfile << "<td colspan=\"" << listScale[aLength+1] << "\" class=\"sc1\">" << spanVal.str() << "</td>"; +// writeHTMLColumn( myfile, listScale[aLength+1], "sc1", spanVal.str(), spanVal.str(), false ); } else - writeHTMLColumn( myfile, listScale[aLength+1], "sc", spanVal.str(), spanVal.str(), false ); + myfile << "<td colspan=\"" << listScale[aLength+1] << "\" class=\"sc\">" << spanVal.str() << "</td>"; +// writeHTMLColumn( myfile, listScale[aLength+1], "sc", spanVal.str(), spanVal.str(), false ); } } diff --git a/simulators/c++2/src_simulator/arch/SchedulableDevice.h b/simulators/c++2/src_simulator/arch/SchedulableDevice.h index 58b3f76ec3711963d426b49bc4fbd184fe3f36dc..0f8979b0c022764d7ad91762f02afa97e3da1ccf 100644 --- a/simulators/c++2/src_simulator/arch/SchedulableDevice.h +++ b/simulators/c++2/src_simulator/arch/SchedulableDevice.h @@ -79,7 +79,7 @@ public: void drawPieChart(std::ofstream& myfile) const; void showPieChart(std::ofstream& myfile) const; void HW2HTML(std::ofstream& myfile) const; - std::map<TMLTask*, std::string> HWTIMELINE2HTML(std::ofstream& myfile,std::map<TMLTask*, std::string> taskCellClasses,unsigned int nextCellClassIndex, std::string& iTracetaskList) const; + std::map<TMLTask*, std::string> HWTIMELINE2HTML(std::ostringstream& myfile,std::map<TMLTask*, std::string> taskCellClasses,unsigned int nextCellClassIndex, std::string& iTracetaskList) const; ///Writes a HTML representation of the schedule to an output file /** \param myfile Reference to the ofstream object representing the output file diff --git a/simulators/c++2/src_simulator/definitions.h b/simulators/c++2/src_simulator/definitions.h index 399337e8ecbb22f0aa17b2198abf35525801ab0e..27e3d43760adc454e4dddb8a463d7c6fe0bcf049 100644 --- a/simulators/c++2/src_simulator/definitions.h +++ b/simulators/c++2/src_simulator/definitions.h @@ -396,7 +396,7 @@ h2 span {\n \ .t11{background-color: gray;}\n \ .t12{background-color: fuchsia;}\n \ .t13{background-color: blue;}\n \ -.t14{background-color: LightGoldenRodYellow;}\n \ +.t14{background-color: darkred;}\n \ .wrapper {\n \ width: 256px;\n \ height: 256px;\n \ diff --git a/simulators/c++2/src_simulator/sim/Simulator.cpp b/simulators/c++2/src_simulator/sim/Simulator.cpp index 286fe798fc2fea43d61b9b6848018a80694c4524..e30c4526642d36d58fe5b29a89429965a5f9ee83 100644 --- a/simulators/c++2/src_simulator/sim/Simulator.cpp +++ b/simulators/c++2/src_simulator/sim/Simulator.cpp @@ -461,66 +461,58 @@ void Simulator::latencies2XML(std::ostringstream& glob, int id1, int id2) { (*j)->latencies2XML(glob, id1,id2); } } -void Simulator::timeline2HTML(std::string& iTraceFileName,std::string& iTracetaskList) const { - if ( !ends_with( iTraceFileName, EXT_HTML ) ) { - iTraceFileName.append( EXT_HTML ); - } - std::ofstream myfile(iTraceFileName.c_str()); - //myfile<<"model name: "<<iTraceFileName.c_str(); +void Simulator::timeline2HTML(std::string& iTracetaskList, std::ostringstream& myfile) const { + std::map<TMLTask*, std::string> taskCellClasses; - if (myfile.is_open()) { - myfile << SCHED_HTML_DOC; // <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n - myfile << SCHED_HTML_BEG_HTML; // <html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n - myfile << SCHED_HTML_BEG_HEAD; // <head>\n - myfile << SCHED_HTML_BEG_STYLE; // <style>\n"; - myfile << SCHED_HTML_CSS_CONTENT_TIMELINE; - myfile << SCHED_HTML_END_STYLE; // <style>\n"; - myfile << SCHED_HTML_META; // <meta http-equiv=\"content-type\" content=\"text/html; charset=ISO-8859-1\" />\n - myfile << SCHED_HTML_BEG_TITLE; // <title> - myfile << "Scheduling"; - myfile << SCHED_HTML_END_TITLE; // </title>\n - myfile << SCHED_HTML_END_HEAD; // </head>\n - myfile << SCHED_HTML_BEG_BODY; // <body>\n + myfile << "<!DOCTYPE html>\n"; // <!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Strict//EN\"\n\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd\">\n + myfile << "<html>\n"; // <html xmlns=\"http://www.w3.org/1999/xhtml\" xml:lang=\"en\" lang=\"en\">\n + myfile << SCHED_HTML_BEG_HEAD; // <head>\n + myfile << SCHED_HTML_BEG_STYLE; // <style>\n"; + myfile << SCHED_HTML_CSS_CONTENT_TIMELINE << std::endl; + myfile << SCHED_HTML_END_STYLE; // <style>\n"; + myfile << SCHED_HTML_BEG_TITLE; // <title> + myfile << "Timeline Diagram"; + myfile << SCHED_HTML_END_TITLE; // </title>\n + myfile << SCHED_HTML_END_HEAD; // </head>\n + myfile << SCHED_HTML_BEG_BODY; // <body>\n // myfile << "<h1>Task to show: " << iTracetaskList.c_str() <<"</h1>\n"; - myfile << "<table style=\"float: left;position: relative;\"><tr><td width=\"170px\" style=\"max-width: unset;min-width: 170px;border-style: none none none none;\"></td>\n" - << "<td class=\"notfirst\"></td>\n" - << "<td style=\"border-style: solid none none none; border-width: 2px;border-color: red;text-align: right\"colspan=\"1000\"><b>Time</b></td>\n</tr>\n" - << "<tr><th></th><th class=\"notfirst\"></th></tr>\n" - << "<div class = \"clear\"></div>" << std::endl; - for(CPUList::const_iterator i=_simComp->getCPUList().begin(); i != _simComp->getCPUList().end(); ++i){ - for(unsigned int j = 0; j < (*i)->getAmoutOfCore(); j++) { - taskCellClasses = (*i)->HWTIMELINE2HTML(myfile, taskCellClasses, taskCellClasses.size(), iTracetaskList); - (*i)->setCycleTime((*i)->getCycleTime()+1); - } - if((*i)->getAmoutOfCore() == 1) - (*i)->setCycleTime(0); - } - - for(FPGAList::const_iterator j=_simComp->getFPGAList().begin(); j != _simComp->getFPGAList().end(); ++j){ - (*j)->setStartFlagHTML(true); - for(TaskList::const_iterator i = (*j)->getTaskList().begin(); i != (*j)->getTaskList().end(); ++i){ - (*j)->setHtmlCurrTask(*i); - taskCellClasses = (*j)->HWTIMELINE2HTML(myfile, taskCellClasses, taskCellClasses.size(), iTracetaskList); - (*j)->setStartFlagHTML(false); - } + myfile << "<table style=\"float: left;position: relative;\"><tr><td width=\"170px\" style=\"max-width: unset;min-width: 170px;border-style: none none none none;\"></td>\n" + << "<td class=\"notfirst\"></td>\n" + << "<td style=\"border-style: solid none none none; border-width: 2px;border-color: red;text-align: right\"colspan=\"1000\"><b>Time</b></td>\n</tr>\n" + << "<tr><th></th><th class=\"notfirst\"></th></tr>\n" + << "<div class = \"clear\"></div>" << std::endl; + for(CPUList::const_iterator i=_simComp->getCPUList().begin(); i != _simComp->getCPUList().end(); ++i){ + for(unsigned int j = 0; j < (*i)->getAmoutOfCore(); j++) { + taskCellClasses = (*i)->HWTIMELINE2HTML(myfile, taskCellClasses, taskCellClasses.size(), iTracetaskList); + (*i)->setCycleTime((*i)->getCycleTime()+1); + } + if((*i)->getAmoutOfCore() == 1) + (*i)->setCycleTime(0); } - for(BusList::const_iterator j=_simComp->getBusList().begin(); j != _simComp->getBusList().end(); ++j){ + for(FPGAList::const_iterator j=_simComp->getFPGAList().begin(); j != _simComp->getFPGAList().end(); ++j){ + (*j)->setStartFlagHTML(true); + for(TaskList::const_iterator i = (*j)->getTaskList().begin(); i != (*j)->getTaskList().end(); ++i){ + (*j)->setHtmlCurrTask(*i); taskCellClasses = (*j)->HWTIMELINE2HTML(myfile, taskCellClasses, taskCellClasses.size(), iTracetaskList); + (*j)->setStartFlagHTML(false); } - myfile << "</tr>\n<tr><th>HW</th><th class=\"notfirst\"></th></tr>\n<div class = \"clear\"></div>\n"; - myfile << "</table>\n<table>\n<tr><td width=\"170px\" style=\"max-width: unset;min-width: 170px;border-style: none none none none;\"></td>\n<td class=\"notlast\"></td>\n<td class=\"notlast\"></td>\n"; - for( std::map<TMLTask*, std::string>::iterator taskColIt = taskCellClasses.begin(); taskColIt != taskCellClasses.end(); ++taskColIt ) { - TMLTask* task = (*taskColIt).first; - // Unset the default td max-width of 5px. For some reason setting the max-with on a specific t style does not work - myfile << "<td class=\"" << taskCellClasses[ task ] << "\"></td><td style=\"max-width: unset;min-width: 170px;\">" << task->toString() << "</td><td class=\"space\"></td>"; - } - myfile << "</tr>\n</table>\n"; - myfile << SCHED_HTML_END_BODY; // </body>\n - myfile << SCHED_HTML_END_HTML; // </html>\n - myfile.close(); } + + for(BusList::const_iterator j=_simComp->getBusList().begin(); j != _simComp->getBusList().end(); ++j){ + taskCellClasses = (*j)->HWTIMELINE2HTML(myfile, taskCellClasses, taskCellClasses.size(), iTracetaskList); + } + myfile << "</tr>\n<tr><th>HW</th><th class=\"notfirst\"></th></tr>\n<div class = \"clear\"></div>\n"; + myfile << "</table>\n<table>\n<tr><td width=\"170px\" style=\"max-width: unset;min-width: 170px;border-style: none none none none;\"></td>\n<td class=\"notlast\"></td>\n<td class=\"notlast\"></td>\n"; + for( std::map<TMLTask*, std::string>::iterator taskColIt = taskCellClasses.begin(); taskColIt != taskCellClasses.end(); ++taskColIt ) { + TMLTask* task = (*taskColIt).first; + // Unset the default td max-width of 5px. For some reason setting the max-with on a specific t style does not work + myfile << "<td class=\"" << taskCellClasses[ task ] << "\"></td><td style=\"max-width: unset;min-width: 170px;\">" << task->toString() << "</td><td class=\"space\"></td>"; + } + myfile << "</tr>\n</table>\n"; + myfile << SCHED_HTML_END_BODY; // </body>\n + myfile << SCHED_HTML_END_HTML; // </html>\n } void Simulator::schedule2HTML(std::string& iTraceFileName) const { #ifdef DEBUG_HTML @@ -1944,8 +1936,8 @@ void Simulator::decodeCommand(std::string iCmd, std::ostream& iXmlOutStream){ std::cout << "Save trace in file x." << std::endl; aInpStream >> aParam1; aInpStream >>aStrParam; - std::string aStrParamTask; - aInpStream >> aStrParamTask; +// std::string aStrParamTask; +// aInpStream >> aStrParamTask; switch (aParam1){ case 0: //VCD aGlobMsg << TAG_MSGo << "Schedule output in VCD format" << TAG_MSGc << std::endl; @@ -1962,10 +1954,15 @@ void Simulator::decodeCommand(std::string iCmd, std::ostream& iXmlOutStream){ case 3: //XML aGlobMsg << TAG_MSGo << "Schedule output in XML format" << TAG_MSGc << std::endl; schedule2XML(anEntityMsg,aStrParam); - case 4: //timeline diagram + case 4: {//timeline diagram aGlobMsg << TAG_MSGo << "Schedule output in HTML format" << TAG_MSGc << std::endl; - timeline2HTML(aStrParam, aStrParamTask); + std::ostringstream timelineContent; + timelineContent << "<![CDATA["; + timeline2HTML(aStrParam, timelineContent); + timelineContent << "]]>"; + aGlobMsg << TAG_MSGo << timelineContent.str() << TAG_MSGc << std::endl; break; + } default: aGlobMsg << TAG_MSGo << MSG_CMDNFOUND<< TAG_MSGc << std::endl; anErrorCode=3; diff --git a/simulators/c++2/src_simulator/sim/Simulator.h b/simulators/c++2/src_simulator/sim/Simulator.h index ee75500b245d765302a90e9e81bf7e9d96a7dceb..ad74c1c55c41b60184a5bbee4714f189ed784cbe 100644 --- a/simulators/c++2/src_simulator/sim/Simulator.h +++ b/simulators/c++2/src_simulator/sim/Simulator.h @@ -247,7 +247,7 @@ public: ///Writes a HTML representation of the schedule of CPUs and buses to an output file void schedule2HTML(std::string& iTraceFileName) const; - void timeline2HTML(std::string& iTraceFileName, std::string& iTracetaskList) const; + void timeline2HTML(std::string& iTracetaskList, std::ostringstream& myfile) const; ///Writes simulation traces in VCD format to an output file /** diff --git a/src/main/java/remotesimulation/CommandParser.java b/src/main/java/remotesimulation/CommandParser.java index de2ac9c92b1401b79198f115bcc590ad9b17241f..85fc7395e2c92d18c831d789d9c8e67d9d76ad0d 100755 --- a/src/main/java/remotesimulation/CommandParser.java +++ b/src/main/java/remotesimulation/CommandParser.java @@ -495,13 +495,11 @@ public class CommandParser { commandList.add(sc); // save-timeline-trace-in-file - params = new int[2]; - paramNames = new String[2]; + params = new int[1]; + paramNames = new String[1]; params[0] = 2; - paramNames[0] = "File name"; - params[1] = 2; - paramNames[1] = "Task List"; - sc = new SimulationCommand("save-timeline-trace-in-file", "stltif", "7 4", params, paramNames, "Saves the current timeline trace of the simulation in a HTML file"); + paramNames[0] = "Task List"; + sc = new SimulationCommand("show-timeline-trace", "stlt", "7 4", params, paramNames, "Show the current timeline diagram tracein HTML format"); commandList.add(sc); // set-variable diff --git a/src/main/java/ui/interactivesimulation/JFrameInteractiveSimulation.java b/src/main/java/ui/interactivesimulation/JFrameInteractiveSimulation.java index b2ce7781948b2d63d825ab22031a3aae34b09153..19fd00cd0088137c02718a7c345682df4eb3a9bc 100644 --- a/src/main/java/ui/interactivesimulation/JFrameInteractiveSimulation.java +++ b/src/main/java/ui/interactivesimulation/JFrameInteractiveSimulation.java @@ -261,7 +261,8 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene private BufferedWriter bw; private int simIndex=0; private String listOfTaskToShowInTimeLine = ""; - private String timelineTempFile = ""; + private String timelineParam = ""; + private boolean isServerReply = false; public JFrameInteractiveSimulation(Frame _f, MainGUI _mgui, String _title, String _hostSystemC, String _pathExecute, TMLMapping<TGComponent> _tmap, List<Point> _points) { super(_title); @@ -1373,6 +1374,18 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene // ssxml = ssxml + s + "\n"; } + index0 = ssxml.indexOf("<![CDATA["); + int index1 = ssxml.indexOf("]]>"); + if ((index0 > -1) && (index1 > -1)) { + timelineParam = ssxml.substring(index0+9, index1).trim(); + if(tmlSimPanelTimeline != null) { + tmlSimPanelTimeline.setServerReply(timelineParam); + } + ssxml = ssxml.replace( timelineParam,""); + ssxml = ssxml.replace( "<![CDATA[",""); + ssxml = ssxml.replace( "]]>",""); + isServerReply = true; + } index0 = ssxml.indexOf("</siminfo>"); @@ -1537,15 +1550,48 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene private void updateTimelineTrace() { if (tmlSimPanelTimeline != null && tmlSimPanelTimeline.isShowing() && !listOfTaskToShowInTimeLine.equals("")) { - tmlSimPanelTimeline.setParam(paramMainCommand.getText().trim()); - mctb.setEnabled(false); - tmlSimPanelTimeline.setContentPaneEnable(false); -// System.out.println(timelineTempFile); -// System.out.println(listOfTaskToShowInTimeLine); - sendCommand( "save-timeline-trace-in-file" + " " + timelineTempFile + " " + listOfTaskToShowInTimeLine ); - tmlSimPanelTimeline.setPaneContent(timelineTempFile); - tmlSimPanelTimeline.setContentPaneEnable(true); - mctb.setEnabled(true); + Thread t = new Thread(new Runnable() { + @Override + public void run() { + commandTab.setEnabled(false); + tmlSimPanelTimeline.setParam(paramMainCommand.getText().trim()); + tmlSimPanelTimeline.setContentPaneEnable(false); + mctb.setActive(false); + isServerReply = false; + timelineParam = ""; + sendCommand( "show-timeline-trace " + listOfTaskToShowInTimeLine ); + Frame f = new JFrame("Updating Data"); + JPanel p = new JPanel(); + JProgressBar b = new JProgressBar(); + // set initial value + b.setValue(0); + int temp = 0; + b.setStringPainted(true); + p.add(b); + f.add(p); + f.setSize(200, 200); + f.setLocationRelativeTo(tmlSimPanelTimeline); + f.setVisible(true); + while (!isServerReply) { + temp++; + b.setValue(temp); + try { + Thread.sleep(50); + } catch (InterruptedException e) { + e.printStackTrace(); + } + } + f.dispose(); + f.setVisible(false); + tmlSimPanelTimeline.setStatusBar(time.getText().trim()); + tmlSimPanelTimeline.setContentPaneEnable(true); + mctb.setActive(true); + commandTab.setEnabled(true); + setAll(); + } + }); + t.start(); + } } @@ -1561,22 +1607,15 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene GraphicLib.centerOnParent(jdstmlc); jdstmlc.setVisible(true); listOfTaskToShowInTimeLine = ""; - timelineTempFile = "timetimetrace.html"; for (String taskname : tmlComponentsToValidate) { listOfTaskToShowInTimeLine += taskname + ","; } - final String directory = saveDirName.getText().trim(); - if ( !directory.isEmpty() ) { - if (!directory.endsWith(File.separator)) - timelineTempFile = directory + File.separator + timelineTempFile; - else - timelineTempFile = directory + timelineTempFile; - } + if (!listOfTaskToShowInTimeLine.equals("")) { - sendCommand( "save-timeline-trace-in-file" + " " + timelineTempFile + " " + listOfTaskToShowInTimeLine ); - tmlSimPanelTimeline = new JFrameTMLSimulationPanelTimeline(new Frame(), mgui, this, "Show Trace - Timeline", timelineTempFile); + tmlSimPanelTimeline = new JFrameTMLSimulationPanelTimeline(new Frame(), mgui, this, "Show Trace - Timeline", timelineParam); tmlSimPanelTimeline.setParam(paramMainCommand.getText().trim()); tmlSimPanelTimeline.setVisible(true); + updateTimelineTrace(); } buttonShowTraceTimeline.setEnabled(true); } @@ -3479,6 +3518,10 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene //TraceManager.addDev("Command:" + command); if (command.equals(actions[InteractiveSimulationActions.ACT_STOP_ALL].getActionCommand())) { + if (tmlSimPanelTimeline != null) { + tmlSimPanelTimeline.dispose(); + tmlSimPanelTimeline.setVisible(false); + } close(); } else if (command.equals(actions[InteractiveSimulationActions.ACT_START_ALL].getActionCommand())) { setComponents(); @@ -3502,6 +3545,9 @@ public class JFrameInteractiveSimulation extends JFrame implements ActionListene break; } } + if (tmlSimPanelTimeline != null) { + tmlSimPanelTimeline.setContentPaneEnable(false); + } killSimulator(); close(); return; diff --git a/src/main/java/ui/interactivesimulation/JFrameTMLSimulationPanelTimeline.java b/src/main/java/ui/interactivesimulation/JFrameTMLSimulationPanelTimeline.java index e7d3b9116daf023de1002f49b07f59f27f5cc220..e30c544a7716e9cba7bd78a3a4c02b9d3673c72b 100644 --- a/src/main/java/ui/interactivesimulation/JFrameTMLSimulationPanelTimeline.java +++ b/src/main/java/ui/interactivesimulation/JFrameTMLSimulationPanelTimeline.java @@ -9,23 +9,15 @@ import ui.MainGUI; import ui.TGComponent; import javax.swing.*; -import javax.swing.text.Document; import java.awt.*; import java.awt.event.*; import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.nio.file.DirectoryNotEmptyException; -import java.nio.file.Files; -import java.nio.file.NoSuchFileException; -import java.nio.file.Paths; -import java.util.*; +import java.io.FileWriter; public class JFrameTMLSimulationPanelTimeline extends JFrame implements ActionListener { public InteractiveSimulationActions[] actions; - private static String htmlPaneContent; - private JTextPane sdpanel; + private JEditorPane sdpanel; protected JLabel status; private Container framePanel; private ProgressMonitor pm; @@ -37,6 +29,7 @@ public class JFrameTMLSimulationPanelTimeline extends JFrame implements ActionLi protected JComboBox<String> cpus, busses, mems, tasks, chans; private TMLMapping<TGComponent> tmap; private JTextField paramMainCommand; + private MainCommandsToolBar mctb; public JFrameTMLSimulationPanelTimeline(Frame _f, MainGUI _mgui,JFrameInteractiveSimulation _jfis, String _title, String _path) { super(_title); @@ -74,7 +67,7 @@ public class JFrameTMLSimulationPanelTimeline extends JFrame implements ActionLi commandTab = GraphicLib.createTabbedPaneRegular();//new JTabbedPane(); commandTab.addTab("Control", null, jp01, "Main control commands"); - MainCommandsToolBar mctb = new MainCommandsToolBar(jfis); + mctb = new MainCommandsToolBar(jfis); jp01.add(mctb, BorderLayout.NORTH); jp02 = new JPanel(); @@ -154,15 +147,10 @@ public class JFrameTMLSimulationPanelTimeline extends JFrame implements ActionLi timelinePane.add(commandTab, BorderLayout.SOUTH); framePanel.add(timelinePane, BorderLayout.NORTH); // Simulation panel - sdpanel = new JTextPane(); + sdpanel = new JEditorPane(); sdpanel.setEditable(false); sdpanel.setContentType("text/html"); - File file = new File(filePath); - try { - sdpanel.setPage(file.toURI().toURL()); - } catch (IOException e) { - e.printStackTrace(); - } +// sdpanel.setText(filePath); JScrollPane jsp = new JScrollPane(sdpanel, JScrollPane.VERTICAL_SCROLLBAR_ALWAYS, JScrollPane.HORIZONTAL_SCROLLBAR_ALWAYS); jsp.setWheelScrollingEnabled(true); @@ -189,6 +177,7 @@ public class JFrameTMLSimulationPanelTimeline extends JFrame implements ActionLi taskIDs = makeTasksIDs(); chanIDs = makeChanIDs(); } + public String[] makeCPUIDs() { if (tmap == null) { return null; @@ -231,24 +220,6 @@ public class JFrameTMLSimulationPanelTimeline extends JFrame implements ActionLi public void close() { - try - { - Files.deleteIfExists(Paths.get(filePath)); - } - catch(NoSuchFileException e) - { - System.out.println("No such file/directory exists"); - } - catch(DirectoryNotEmptyException e) - { - System.out.println("Directory is not empty."); - } - catch(IOException e) - { - System.out.println("Invalid permissions."); - } - - System.out.println("Deletion successful."); dispose(); setVisible(false); } @@ -257,7 +228,6 @@ public class JFrameTMLSimulationPanelTimeline extends JFrame implements ActionLi TraceManager.addDev("Saving in html format"); File file = null; JFileChooser jfcimg = new JFileChooser(); -// jfcimg.setCurrentDirectory(new File("")); int returnVal = jfcimg.showSaveDialog(getContentPane()); if (returnVal == JFileChooser.APPROVE_OPTION) { file = jfcimg.getSelectedFile(); @@ -278,10 +248,10 @@ public class JFrameTMLSimulationPanelTimeline extends JFrame implements ActionLi return; } try { - FileOutputStream fos = new FileOutputStream(file); - htmlPaneContent = sdpanel.getText(); - fos.write(htmlPaneContent.getBytes()); - fos.close(); + FileWriter myWriter = new FileWriter(file); + myWriter.write(filePath); + myWriter.close(); + System.out.println("Successfully wrote to the file."); JOptionPane.showMessageDialog(getContentPane(), "The capture was correctly performed and saved in " + file.getAbsolutePath(), "Screen capture ok", JOptionPane.INFORMATION_MESSAGE); } catch (Exception e) { TraceManager.addDev("Error during save trace: " + e.getMessage()); @@ -289,22 +259,15 @@ public class JFrameTMLSimulationPanelTimeline extends JFrame implements ActionLi return; } } + public void setParam(String param) { paramMainCommand.setText(param); } + public void setContentPaneEnable(boolean x) { - commandTab.setEnabled(x); - } - public void setPaneContent(String filePath) { - try { - File file = new File(filePath); - Document doc = sdpanel.getDocument(); - doc.putProperty(Document.StreamDescriptionProperty, null); - sdpanel.setPage(file.toURI().toURL()); - } catch (IOException e) { - e.printStackTrace(); - } + mctb.setActive(x); } + public void actionPerformed(ActionEvent evt) { String command = evt.getActionCommand(); if (command.equals(actions[InteractiveSimulationActions.ACT_QUIT_SD_WINDOW].getActionCommand())) { @@ -314,4 +277,17 @@ public class JFrameTMLSimulationPanelTimeline extends JFrame implements ActionLi saveHTML(); } } + + public void setServerReply(String content) { + try { + filePath = content; + sdpanel.setText(content); + } catch (Exception e) { + System.out.println(e.toString()); + } + } + + public void setStatusBar (String s) { + status.setText("Ready ... Time: " + s); + } } diff --git a/ttool/src/test/java/tmltranslator/TimelineDiagramTest.java b/ttool/src/test/java/tmltranslator/TimelineDiagramTest.java index eca1a7602ced50541ae3eca57e351a7ef8ebf386..5f7e1ee9cdc232e8fb0e57aa721579186decf622 100644 --- a/ttool/src/test/java/tmltranslator/TimelineDiagramTest.java +++ b/ttool/src/test/java/tmltranslator/TimelineDiagramTest.java @@ -42,6 +42,7 @@ public class TimelineDiagramTest extends AbstractUITest { private boolean isReady = false; private boolean running = true; private Vector<SimulationTransaction> trans; + private String ssxml; final static String EXPECTED_FILE_GENERATED_TIMELINE = getBaseResourcesDir() + "tmltranslator/expected/expected_get_generated_timeline.txt"; @BeforeClass public static void setUpBeforeClass() throws Exception { @@ -66,8 +67,8 @@ public class TimelineDiagramTest extends AbstractUITest { System.out.println("executing: checking syntax " + s); // select architecture tab mainGUI.openProjectFromFile(new File(RESOURCES_DIR + s + ".xml")); - for(TURTLEPanel _tab : mainGUI.getTabs()) { - if(_tab instanceof TMLArchiPanel) { + for (TURTLEPanel _tab : mainGUI.getTabs()) { + if (_tab instanceof TMLArchiPanel) { for (TDiagramPanel tdp : _tab.getPanels()) { if (tdp instanceof TMLArchiDiagramPanel) { mainGUI.selectTab(tdp); @@ -114,7 +115,7 @@ public class TimelineDiagramTest extends AbstractUITest { BufferedReader proc_in; String str; boolean mustRecompileAll; - Penalties penalty = new Penalties(SIM_DIR + "src_simulator"); + Penalties penalty = new Penalties(SIM_DIR + "src_simulator"); int changed = penalty.handlePenalties(false); if (changed == 1) { @@ -157,36 +158,76 @@ public class TimelineDiagramTest extends AbstractUITest { return; } System.out.println("SUCCESS: executing: " + "make -C " + SIM_DIR); - // Run the simulator - String graphPath = SIM_DIR + "testgraph_" + s + ".html"; + // Starts simulation + Runtime.getRuntime().exec("./" + SIM_DIR + "run.x" + " -server"); + Thread.sleep(1000); + // Connects to the simulator, incase of using terminal: "./run.x -server" to start server and "nc localhost 3490" to connect to server + rc = new RemoteConnection("localhost"); + try { + rc.connect(); + isReady = true; + } catch (RemoteConnectionException rce) { + System.out.println("Could not connect to server."); + } try { - String[] params = new String[3]; - - params[0] = "./" + SIM_DIR + "run.x"; - params[1] = "-cmd"; - params[2] = "1 6 100; 7 4 " + graphPath + " ApplicationSimple__Src,ApplicationSimple__T1,ApplicationSimple__T2"; - proc = Runtime.getRuntime().exec(params); - //proc = Runtime.getRuntime().exec("./" + SIM_DIR + "run.x -explo -gname testgraph_" + s); - proc_in = new BufferedReader(new InputStreamReader(proc.getInputStream())); + toServer(" 1 6 100", rc); + Thread.sleep(5); + toServer("7 4 ApplicationSimple__Src,ApplicationSimple__T1,ApplicationSimple__T2", rc); + Thread.sleep(5); + while (running) { + String demo = null; + try { + demo = rc.readOneLine(); + } catch (RemoteConnectionException e) { + e.printStackTrace(); + } + running = analyzeServerAnswer(demo); + } - monitorError(proc); + File file = new File(EXPECTED_FILE_GENERATED_TIMELINE); + String content = FileUtils.readFileToString(file, StandardCharsets.UTF_8); + assertTrue(content.equals(ssxml)); + System.out.println("Test done"); - while ((str = proc_in.readLine()) != null) { - // TraceManager.addDev( "Sending " + str + " from " + port + " to client..." ); - System.out.println("executing: " + str); - } - } catch (Exception e) { - // Probably make is not installed - System.out.println("FAILED: executing simulation"); - return; + }catch (Exception e) { + e.printStackTrace(); + } + } + } + private synchronized void toServer (String s, RemoteConnection rc) throws RemoteConnectionException { + while (!isReady) { + TraceManager.addDev("Server not ready"); + try { + rc.send("13"); + wait(250); + } catch (InterruptedException ie) { + ie.printStackTrace(); } - File file = new File(EXPECTED_FILE_GENERATED_TIMELINE); - String content = FileUtils.readFileToString(file, StandardCharsets.UTF_8); - File file1 = new File(graphPath); - String content1 = FileUtils.readFileToString(file1, StandardCharsets.UTF_8); - assertTrue(content.equals(content1)); + } + rc.send(s); + System.out.println("send " + s); + } + + private boolean analyzeServerAnswer(String s) { + boolean isRunning = true; + int index0 = s.indexOf("<?xml"); + if (index0 != -1) { + // + ssxml = s.substring(index0, s.length()) + "\n"; + } else { + // + ssxml = ssxml + s + "\n"; } + index0 = ssxml.indexOf("<![CDATA["); + int index1 = ssxml.indexOf("]]>"); + if ((index0 > -1) && (index1 > -1)) { + ssxml = ssxml.substring(index0 + 9, index1).trim(); + isRunning = false; + } + return isRunning; } + } + diff --git a/ttool/src/test/resources/tmltranslator/expected/expected_get_generated_timeline.txt b/ttool/src/test/resources/tmltranslator/expected/expected_get_generated_timeline.txt index e86804c16769ab855bc43369acc326706f72f81c..c19c032eda442d7c716d493e5dbd086ca34c341a 100644 --- a/ttool/src/test/resources/tmltranslator/expected/expected_get_generated_timeline.txt +++ b/ttool/src/test/resources/tmltranslator/expected/expected_get_generated_timeline.txt @@ -1,6 +1,5 @@ -<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" -"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> -<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en"> +<!DOCTYPE html> +<html> <head> <style> table{ @@ -76,16 +75,16 @@ table{ .t11{background-color: gray;} .t12{background-color: fuchsia;} .t13{background-color: blue;} - .t14{background-color: LightGoldenRodYellow;} + .t14{background-color: darkred;} .wrapper { width: 256px; height: 256px; } .clear { clear:both - }</style> -<meta http-equiv="content-type" content="text/html; charset=ISO-8859-1" /> -<title>Scheduling</title> + } +</style> +<title>Timeline Diagram</title> </head> <body> <table style="float: left;position: relative;"><tr><td width="170px" style="max-width: unset;min-width: 170px;border-style: none none none none;"></td> @@ -97,42 +96,42 @@ table{ <tr><td width="170px" style="max-width: unset;min-width: 170px;background-color: aqua;">FPGA1_1_core_0</td> <td class="notfirst"></td> <td class="notlast"></td> -<td title="idle time" class="not"></td> -<td title="ApplicationSimple__T1: Wait ApplicationSimple__evtToT1__ApplicationSimple__evtToT1 params: t:1 l:1 (vl:1) params:(100(size)) Ch: ApplicationSimple__evtToT1__ApplicationSimple__evtToT1" class="t0"></td> -<td title="idle time" class="not" colspan="4"></td> -<td title="ApplicationSimple__T1: Read 400,ApplicationSimple__chToT1 t:6 l:400 (vl:400) params: Ch: ApplicationSimple__chToT1" class="t0" colspan="10"> R</td> +<td colspan="1" title="idle time" class="not"></td> +<td colspan="1" title="ApplicationSimple__T1: Wait ApplicationSimple__evtToT1__ApplicationSimple__evtToT1 params: t:1 l:1 (vl:1) params:(100(size)) Ch: ApplicationSimple__evtToT1__ApplicationSimple__evtToT1" class="t0"> W</td> +<td colspan="4" title="idle time" class="not"></td> +<td colspan="10" title="ApplicationSimple__T1: Read 400,ApplicationSimple__chToT1 t:6 l:400 (vl:400) params: Ch: ApplicationSimple__chToT1" class="t0"> R</td> </tr> <tr><th></th><th class="notfirst"><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th><th></th></tr> <tr><td width="170px" style="max-width: unset;min-width: 170px;border-style: none none none none;"></td> <td class="notfirst"></td> <td class="notlast"></td> -<td title="0" class="sc"></td><td title="1" class="sc"></td><td title="2" class="sc" colspan="4">2</td><td title="6" class="sc" colspan="10">6</td><td title="406" class="sc" colspan="5">406</td></tr> +<td colspan="1" class="sc">0</td><td colspan="1" class="sc">1</td><td colspan="4" class="sc">2</td><td colspan="10" class="sc">6</td><td colspan="5" class="sc">406</td></tr> <div class = "clear"></div> <tr><td width="170px" style="max-width: unset;min-width: 170px;background-color: aqua;">Src_1_core_0</td> <td class="notfirst"></td> <td class="notlast"></td> -<td title="ApplicationSimple__Src: Send ApplicationSimple__evtToT1__ApplicationSimple__evtToT1(evtFB) len:2 content:0 params: t:0 l:1 (vl:1) params:(100(size)) Ch: ApplicationSimple__evtToT1__ApplicationSimple__evtToT1" class="t1"></td> -<td title="ApplicationSimple__Src: Write 400,ApplicationSimple__chToT1 t:1 l:5 (vl:400) params: Ch: ApplicationSimple__chToT1" class="t1" colspan="5"> W</td> +<td colspan="1" title="ApplicationSimple__Src: Send ApplicationSimple__evtToT1__ApplicationSimple__evtToT1(evtFB) len:2 content:0 params: t:0 l:1 (vl:1) params:(100(size)) Ch: ApplicationSimple__evtToT1__ApplicationSimple__evtToT1" class="t1"> S</td> +<td colspan="5" title="ApplicationSimple__Src: Write 400,ApplicationSimple__chToT1 t:1 l:5 (vl:400) params: Ch: ApplicationSimple__chToT1" class="t1"> W</td> </tr> <tr><th></th><th class="notfirst"><th></th><th></th><th></th><th></th><th></th><th></th></tr> <tr><td width="170px" style="max-width: unset;min-width: 170px;border-style: none none none none;"></td> <td class="notfirst"></td> <td class="notlast"></td> -<td title="0" class="sc"></td><td title="1" class="sc" colspan="5">1</td><td title="6" class="sc" colspan="5">6</td></tr> +<td colspan="1" class="sc">0</td><td colspan="5" class="sc">1</td><td colspan="5" class="sc">6</td></tr> <div class = "clear"></div> <tr><td width="170px" style="max-width: unset;min-width: 170px;background-color: aqua;">Bus0_0</td> <td class="notfirst"></td> <td class="notlast"></td> -<td title="idle time" class="not"></td> -<td title="ApplicationSimple__Src: Write 400,ApplicationSimple__chToT1 t:1 l:5 (vl:400) params: Ch: ApplicationSimple__chToT1" class="t1" colspan="5"> W</td> +<td colspan="1" title="idle time" class="not"></td> +<td colspan="5" title="ApplicationSimple__Src: Write 400,ApplicationSimple__chToT1 t:1 l:5 (vl:400) params: Ch: ApplicationSimple__chToT1" class="t1"> W</td> </tr> <tr><th></th><th class="notfirst"><th></th><th></th><th></th><th></th><th></th><th></th></tr> <tr><td width="170px" style="max-width: unset;min-width: 170px;border-style: none none none none;"></td> <td class="notfirst"></td> <td class="notlast"></td> -<td title="0" class="sc"></td><td title="1" class="sc" colspan="5">1</td><td title="6" class="sc" colspan="5">6</td></tr> +<td colspan="1" class="sc">0</td><td colspan="5" class="sc">1</td><td colspan="5" class="sc">6</td></tr> <div class = "clear"></div> </tr> <tr><th>HW</th><th class="notfirst"></th></tr> @@ -145,4 +144,4 @@ table{ <td class="t0"></td><td style="max-width: unset;min-width: 170px;">ApplicationSimple__T1</td><td class="space"></td><td class="t1"></td><td style="max-width: unset;min-width: 170px;">ApplicationSimple__Src</td><td class="space"></td></tr> </table> </body> -</html> +</html> \ No newline at end of file