Skip to content
Snippets Groups Projects
Commit 67df8f0d authored by Le Van Truong's avatar Le Van Truong
Browse files

write fake channel

parent 1754bc9f
No related branches found
No related tags found
1 merge request!284Add signals to channel
......@@ -342,6 +342,13 @@ TMLChannel* SimComponents::getChannelByID(ID iID) const{
return NULL;
}
void SimComponents::getChannelList(){
for(ChannelList::const_iterator i=_channelList.begin(); i != _channelList.end(); ++i){
std::cout << "hellboy channel ID " << (*i)->getID() << std::endl;
std::cout << "hellboy channel name " << (*i)->toShortString() << std::endl;
}
}
/*TMLChoiceCommand* SimComponents::getCurrentChoiceCmd(){
TMLChoiceCommand* aResult;
for(TaskList::const_iterator i=_taskList.begin(); i != _taskList.end(); ++i){
......
......@@ -316,6 +316,7 @@ public:
ListenerSubject<GeneralListener>* getListenerByID(ID iID);
virtual void generateTEPEs()=0;
void showTaskStates();
void getChannelList();
bool couldCPUBeIdle(CPU* iCPU);
bool couldFPGABeIdle(FPGA* iFPGA);
protected:
......
......@@ -1080,6 +1080,7 @@ void Simulator::printHelp(){
"-explo generate the reachability graph \n"
"-cmd \'c1 p1 p2;c2\' execute commands c1 with parameters p1 and p2 and c2\n"
"-oxml ofile xml reply is written to ofile, in case the -cmd option is used\n"
"-signals ofile generates signals from declared file \n"
"***************************************************************************\n\n";
}
......@@ -1101,6 +1102,34 @@ void Simulator::run(){
std::cout << "Simulator loop terminated." << std::endl;
}
std::vector<std::string> readFromFile(std::string& filename){
std::string x;
std::vector<std::string> parameters;
std::ifstream inFile(filename.c_str());
// inFile.open(filename);
if (!inFile) {
std::cout << "Unable to open file";
exit(1); // terminate with error
}
while (inFile >> x) {
std::cout<< "hellboy read: " << x << std::endl;
parameters.push_back(x);
}
inFile.close();
return parameters;
}
void Simulator::addSignalToTask(){
_simComp->getChannelList();
}
template < typename T > std::string to_string( const T& n )
{
std::ostringstream stm ;
stm << n ;
return stm.str() ;
}
ServerIF* Simulator::run(int iLen, char ** iArgs){
std::string aArgString;
std::string graphName = "";
......@@ -1127,6 +1156,48 @@ ServerIF* Simulator::run(int iLen, char ** iArgs){
//if (!aArgString.empty()) return new ServerExplore();
std::cout << "Running in command line mode.\n";
_replyToServer = false;
aArgString=getArgs("-signals", "signals.txt", iLen, iArgs);
if (!aArgString.empty()) {
addSignalToTask();
std::ifstream inFile1(aArgString.c_str());
int lineNumber = std::count(std::istreambuf_iterator<char>(inFile1), std::istreambuf_iterator<char>(), '\n');
std::cout << "hellboy lineNumber " << lineNumber << std::endl;
std::vector<std::string> parameters = readFromFile(aArgString);
std::string aNewCmd;
int previousTransTime = 0;
for (int i = 0; i < lineNumber; i++){
std::string channelName = "Application__" + parameters[i*4+1] + "__Application__" + parameters[i*4+1];
TMLChannel* t = _simComp->getChannelByName(channelName);
std::cout<< "hellboy TTTTTTT: " << t->toShortString() << "ID = " << t->getID() <<std::endl;
int timeToRun;
std::istringstream (parameters[i*4]) >> timeToRun;
timeToRun = timeToRun - previousTransTime;
std::istringstream (parameters[i*4]) >> previousTransTime;
if(t != 0){
aNewCmd += "1 6 " + to_string(timeToRun) + "; 6 " + to_string(t->getID()) + " 1";
}
if(i + 1 != lineNumber) aNewCmd += ";";
}
aNewCmd += ";1 0; 7 1 test.html";
std::cout<<"hellboy decodeCommand "<< aNewCmd << std::endl;
std::ofstream aXmlOutFile1;
std::string aXmlFileName1 = getArgs("-oxml", "reply.xml", iLen, iArgs);
if (aXmlFileName1.empty()) aXmlOutFile1.open("/dev/null"); else aXmlOutFile1.open(aXmlFileName1.c_str());
if (aXmlOutFile1.is_open()){
std::string aNextCmd1;
std::istringstream iss1(aNewCmd+";");
getline(iss1, aNextCmd1, ';');
while (!(iss1.eof() || aNextCmd1.empty())){
std::cout << "next cmd to execute: \"" << aNextCmd1 << "\"\n";
decodeCommand(aNextCmd1, aXmlOutFile1);
getline(iss1, aNextCmd1, ';');
}
aXmlOutFile1.close();
}else
std::cout << "XML output file could not be opened, aborting.\n";
}
aArgString =getArgs("-help", "help", iLen, iArgs);
if (aArgString.empty()){
//aArgString =getArgs("-explo", "explo", iLen, iArgs);
......@@ -1645,7 +1716,11 @@ void Simulator::decodeCommand(std::string iCmd, std::ostream& iXmlOutStream){
TMLEventChannel* anEventChannel = dynamic_cast<TMLEventChannel*>(aChannel);
if (anEventChannel==0){
//aChannel->insertSamples(aParam1, anInsertParam);
aChannel->insertSamples(aParam1, 0);
int x = 1;
Parameter* anInsertParam = new SizedParameter<ParamType,1>(x);
aInpStream >> anInsertParam;
aChannel->insertSamples(aParam1, anInsertParam);
} else {
//Parameter<ParamType> anInsertParam((dynamic_cast<TMLEventChannel*>(aChannel))->getParamNo());
Parameter* anInsertParam = anEventChannel->buildParameter();
......
......@@ -265,6 +265,7 @@ public:
/**
\param iTraceFileName Name of the output trace file
*/
void addSignalToTask();
void schedule2TXT(std::string& iTraceFileName) const;
void schedule2XML(std::ostringstream& glob,std::string& iTraceFileName) const;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment