Commit 05f6b8af authored by Le Van Truong's avatar Le Van Truong

update wait delay transaction

parent 2d7d2f67
......@@ -91,6 +91,11 @@ public:
/**
\return Pointer to the current transaction
*/
virtual bool getActiveDelay(){return false;}
virtual bool isDelayTransaction(){return false;}
inline TMLTransaction* getCurrTransaction() const {return _currTransaction;}
///Returns a pointer to the task which could be unblocked by the command
/**
......
......@@ -43,9 +43,13 @@ Ludovic Apvrille, Renaud Pacalet
#include <TMLTransaction.h>
#include <SimComponents.h>
//#include <CommandListener.h>
TMLDelayCommand::TMLDelayCommand(ID iID, TMLTask* iTask,TMLLength iStatLength, ActionFuncPointer iActionFunc, const char* iLiveVarList, bool iCheckpoint):TMLCommand(iID, iTask, 1, 1, iLiveVarList, iCheckpoint),_actionFunc(iActionFunc){
_length = iStatLength;
TMLDelayCommand::TMLDelayCommand(ID iID, TMLTask* iTask,TMLLength iStatLength, ActionFuncPointer iActionFunc, const char* iLiveVarList, bool iCheckpoint, bool isActiveDelay):TMLCommand(iID, iTask, 1, 1, iLiveVarList, iCheckpoint),_actionFunc(iActionFunc){
if (!isActiveDelay){
_isActiveDelay = false;
}else {
_length = iStatLength;
_isActiveDelay = true;
}
_type=ACT;
}
void TMLDelayCommand::execute(){
......
......@@ -56,7 +56,10 @@ public:
\param iLiveVarList Bitmap of live variables
\param iCheckpoint Checkpoint Flag
*/
TMLDelayCommand(ID iID, TMLTask* iTask, TMLLength iStatLength, ActionFuncPointer iActionFunc, const char* iLiveVarList, bool iCheckpoint);
bool _isActiveDelay;
virtual bool getActiveDelay() {return _isActiveDelay;}
virtual bool isDelayTransaction(){return true;}
TMLDelayCommand(ID iID, TMLTask* iTask, TMLLength iStatLength, ActionFuncPointer iActionFunc, const char* iLiveVarList, bool iCheckpoint, bool isActiveDelay);
void execute();
//TMLTask* getDependentTask() const;
std::string toString() const;
......
......@@ -550,15 +550,16 @@ void TMLTask::schedule2HTML(std::ofstream& myfile) const {
TMLTransaction* aCurrTrans = *i;
unsigned int aBlanks = aCurrTrans->getStartTime() - aCurrTime;
if ( aBlanks > 0 ) {
writeHTMLColumn( myfile, aBlanks, "not", "idle time" );
}
if ( aBlanks >= 0 && (!(aCurrTrans->getCommand()->getActiveDelay()) && aCurrTrans->getCommand()->isDelayTransaction()) )
writeHTMLColumn( myfile, aBlanks+1, "not", "idle time" );
else if ( aBlanks > 0 )
writeHTMLColumn( myfile, aBlanks, "not", "idle time" );
unsigned int aLength = aCurrTrans->getPenalties();
if ( aLength != 0 ) {
std::ostringstream title;
title << "idle:" << aCurrTrans->getIdlePenalty() << " switch:" << aCurrTrans->getTaskSwitchingPenalty();
title << "idle:" << aCurrTrans->getIdlePenalty() << " switching penalty:" << aCurrTrans->getTaskSwitchingPenalty();
writeHTMLColumn( myfile, aLength, "not", title.str() );
}
......@@ -570,7 +571,9 @@ void TMLTask::schedule2HTML(std::ofstream& myfile) const {
std::string aCurrTransName=aCurrTrans->toShortString();
unsigned int indexTrans=aCurrTransName.find_first_of(":");
std::string aCurrContent=aCurrTransName.substr(indexTrans+1,2);
writeHTMLColumn( myfile, aLength, cellClass, aCurrTrans->toShortString(), aCurrContent );
if(!(!(aCurrTrans->getCommand()->getActiveDelay()) && aCurrTrans->getCommand()->isDelayTransaction())){
writeHTMLColumn( myfile, aLength, cellClass, aCurrTrans->toShortString(), aCurrContent );
}
aCurrTime = aCurrTrans->getEndTime();
// }
......
......@@ -194,15 +194,16 @@ void CPU::HW2HTML(std::ofstream& myfile) const {
TMLTransaction* aCurrTrans = *i;
unsigned int aBlanks = aCurrTrans->getStartTime() - aCurrTime;
if ( aBlanks > 0 ) {
writeHTMLColumn( myfile, aBlanks, "not", "idle time" );
}
if ( aBlanks >= 0 && (!(aCurrTrans->getCommand()->getActiveDelay()) && aCurrTrans->getCommand()->isDelayTransaction()) )
writeHTMLColumn( myfile, aBlanks+1, "not", "idle time" );
else if ( aBlanks > 0 )
writeHTMLColumn( myfile, aBlanks, "not", "idle time" );
unsigned int aLength = aCurrTrans->getPenalties();
if ( aLength != 0 ) {
std::ostringstream title;
title << "idle:" << aCurrTrans->getIdlePenalty() << " switch:" << aCurrTrans->getTaskSwitchingPenalty();
title << "idle:" << aCurrTrans->getIdlePenalty() << " switching penalty:" << aCurrTrans->getTaskSwitchingPenalty();
writeHTMLColumn( myfile, aLength, "not", title.str() );
}
......@@ -214,7 +215,9 @@ void CPU::HW2HTML(std::ofstream& myfile) const {
std::string aCurrTransName=aCurrTrans->toShortString();
unsigned int indexTrans=aCurrTransName.find_first_of(":");
std::string aCurrContent=aCurrTransName.substr(indexTrans+1,2);
writeHTMLColumn( myfile, aLength, cellClass, aCurrTrans->toShortString(), aCurrContent );
if(!(!(aCurrTrans->getCommand()->getActiveDelay()) && aCurrTrans->getCommand()->isDelayTransaction())){
writeHTMLColumn( myfile, aLength, cellClass, aCurrTrans->toShortString(), aCurrContent );
}
if(aCurrTrans->getCommand()->getTask()->getIsDaemon() == true && aCurrTrans->getEndTime() > _simulatedTime)
aCurrTime = _simulatedTime;
else
......@@ -264,15 +267,16 @@ void CPU::schedule2HTML(std::ofstream& myfile) const {
TMLTransaction* aCurrTrans = *i;
unsigned int aBlanks = aCurrTrans->getStartTime() - aCurrTime;
if ( aBlanks > 0 ) {
writeHTMLColumn( myfile, aBlanks, "not", "idle time" );
}
if ( aBlanks >= 0 && (!(aCurrTrans->getCommand()->getActiveDelay()) && aCurrTrans->getCommand()->isDelayTransaction()) )
writeHTMLColumn( myfile, aBlanks+1, "not", "idle time" );
else if ( aBlanks > 0 )
writeHTMLColumn( myfile, aBlanks, "not", "idle time" );
unsigned int aLength = aCurrTrans->getPenalties();
if ( aLength != 0 ) {
std::ostringstream title;
title << "idle:" << aCurrTrans->getIdlePenalty() << " switch:" << aCurrTrans->getTaskSwitchingPenalty();
title << "idle:" << aCurrTrans->getIdlePenalty() << " switching penalty:" << aCurrTrans->getTaskSwitchingPenalty();
writeHTMLColumn( myfile, aLength, "not", title.str() );
}
......@@ -281,9 +285,9 @@ void CPU::schedule2HTML(std::ofstream& myfile) const {
// Issue #4
TMLTask* task = aCurrTrans->getCommand()->getTask();
const std::string cellClass = determineHTMLCellClass( taskCellClasses, task, nextCellClassIndex );
writeHTMLColumn( myfile, aLength, cellClass, aCurrTrans->toShortString() );
if(!(!(aCurrTrans->getCommand()->getActiveDelay()) && aCurrTrans->getCommand()->isDelayTransaction())){
writeHTMLColumn( myfile, aLength, cellClass, aCurrTrans->toShortString() );
}
if(aCurrTrans->getCommand()->getTask()->getIsDaemon() == true && aCurrTrans->getEndTime() > _simulatedTime)
aCurrTime = _simulatedTime;
else
......
......@@ -596,9 +596,10 @@ void FPGA::HW2HTML(std::ofstream& myfile) {
TMLTransaction* aCurrTrans = *i;
unsigned int aBlanks = aCurrTrans->getStartTime() - aCurrTime;
//std::cout<<"blank is "<<aBlanks<<std::endl;
if ( aBlanks > 0 ) {
writeHTMLColumn( myfile, aBlanks, "not", "idle time" );
}
if ( aBlanks >= 0 && (!(aCurrTrans->getCommand()->getActiveDelay()) && aCurrTrans->getCommand()->isDelayTransaction()) )
writeHTMLColumn( myfile, aBlanks+1, "not", "idle time" );
else if ( aBlanks > 0 )
writeHTMLColumn( myfile, aBlanks, "not", "idle time" );
unsigned int aLength = aCurrTrans->getOperationLength();
......@@ -609,8 +610,9 @@ void FPGA::HW2HTML(std::ofstream& myfile) {
std::string aCurrTransName=aCurrTrans->toShortString();
unsigned int indexTrans=aCurrTransName.find_first_of(":");
std::string aCurrContent=aCurrTransName.substr(indexTrans+1,2);
writeHTMLColumn( myfile, aLength, cellClass, aCurrTrans->toShortString(), aCurrContent );
if(!(!(aCurrTrans->getCommand()->getActiveDelay()) && aCurrTrans->getCommand()->isDelayTransaction())){
writeHTMLColumn( myfile, aLength, cellClass, aCurrTrans->toShortString(), aCurrContent );
}
if(aCurrTrans->getCommand()->getTask()->getIsDaemon() == true && aCurrTrans->getEndTime() > _simulatedTime)
aCurrTime = _simulatedTime;
else
......@@ -664,9 +666,10 @@ void FPGA::schedule2HTML(std::ofstream& myfile) {
TMLTransaction* aCurrTrans = *i;
unsigned int aBlanks = aCurrTrans->getStartTime() - aCurrTime;
//std::cout<<"blank is "<<aBlanks<<std::endl;
if ( aBlanks > 0 ) {
writeHTMLColumn( myfile, aBlanks, "not", "idle time" );
}
if ( aBlanks >= 0 && (!(aCurrTrans->getCommand()->getActiveDelay()) && aCurrTrans->getCommand()->isDelayTransaction()) )
writeHTMLColumn( myfile, aBlanks+1, "not", "idle time" );
else if ( aBlanks > 0 )
writeHTMLColumn( myfile, aBlanks, "not", "idle time" );
unsigned int aLength = aCurrTrans->getOperationLength();
......@@ -675,8 +678,9 @@ void FPGA::schedule2HTML(std::ofstream& myfile) {
TMLTask* task = aCurrTrans->getCommand()->getTask();
// std::cout<<"what is this task?"<<task->toString()<<std::endl;
const std::string cellClass = determineHTMLCellClass( nextCellClassIndex );
writeHTMLColumn( myfile, aLength, cellClass, aCurrTrans->toShortString() );
if(!(!(aCurrTrans->getCommand()->getActiveDelay()) && aCurrTrans->getCommand()->isDelayTransaction())){
writeHTMLColumn( myfile, aLength, cellClass, aCurrTrans->toShortString() );
}
if(aCurrTrans->getCommand()->getTask()->getIsDaemon() == true && aCurrTrans->getEndTime() > _simulatedTime)
aCurrTime = _simulatedTime;
......
......@@ -430,8 +430,9 @@ void MultiCoreCPU::schedule2HTML(std::ofstream& myfile) const{
aCurrTrans=*i;
//if (aCurrTrans->getVirtualLength()==0) continue;
aBlanks=aCurrTrans->getStartTime()-aCurrTime;
if (aBlanks>0){
if ( aBlanks >= 0 && (!(aCurrTrans->getCommand()->getActiveDelay()) && aCurrTrans->getCommand()->isDelayTransaction()) )
myfile << "<td colspan=\""<< aBlanks+1 <<"\" title=\"idle time\" class=\"not\"></td>\n";
else if (aBlanks>0){
if (aBlanks==1)
myfile << "<td title=\"idle time\" class=\"not\"></td>\n";
else
......@@ -444,18 +445,20 @@ void MultiCoreCPU::schedule2HTML(std::ofstream& myfile) const{
if (aLength==1){
//myfile << "<td title=\""<< aCurrTrans->toShortString() << "\" class=\"t15\"></td>\n";
//myfile << "<td title=\" idle:" << aCurrTrans->getIdlePenalty() << " switch:" << aCurrTrans->getTaskSwitchingPenalty() << " bran:" << aCurrTrans->getBranchingPenalty() << "\" class=\"t15\"></td>\n";
myfile << "<td title=\" idle:" << aCurrTrans->getIdlePenalty() << " switch:" << aCurrTrans->getTaskSwitchingPenalty() << "\" class=\"t15\"></td>\n";
myfile << "<td title=\" idle:" << aCurrTrans->getIdlePenalty() << " switching penalty:" << aCurrTrans->getTaskSwitchingPenalty() << "\" class=\"t15\"></td>\n";
}else{
//myfile << "<td colspan=\"" << aLength << "\" title=\" idle:" << aCurrTrans->getIdlePenalty() << " switch:" << aCurrTrans->getTaskSwitchingPenalty() << " bran:" << aCurrTrans->getBranchingPenalty() << "\" class=\"t15\"></td>\n";
myfile << "<td colspan=\"" << aLength << "\" title=\" idle:" << aCurrTrans->getIdlePenalty() << " switch:" << aCurrTrans->getTaskSwitchingPenalty() << "\" class=\"t15\"></td>\n";
myfile << "<td colspan=\"" << aLength << "\" title=\" idle:" << aCurrTrans->getIdlePenalty() << " switching penalty:" << aCurrTrans->getTaskSwitchingPenalty() << "\" class=\"t15\"></td>\n";
}
}
aLength=aCurrTrans->getOperationLength();
aColor=aCurrTrans->getCommand()->getTask()->getInstanceNo() & 15;
if (aLength==1)
myfile << "<td title=\""<< aCurrTrans->toShortString() << "\" class=\"t"<< aColor <<"\"></td>\n";
else
myfile << "<td colspan=\"" << aLength << "\" title=\"" << aCurrTrans->toShortString() << "\" class=\"t"<< aColor <<"\"></td>\n";
if(!(!(aCurrTrans->getCommand()->getActiveDelay()) && aCurrTrans->getCommand()->isDelayTransaction())){
if (aLength==1)
myfile << "<td title=\""<< aCurrTrans->toShortString() << "\" class=\"t"<< aColor <<"\"></td>\n";
else
myfile << "<td colspan=\"" << aLength << "\" title=\"" << aCurrTrans->toShortString() << "\" class=\"t"<< aColor <<"\"></td>\n";
}
aCurrTime=aCurrTrans->getEndTime();
......
......@@ -51,7 +51,7 @@ RRPrioScheduler::RRPrioScheduler(const std::string& iName, Priority iPrio, TMLTi
TMLTime RRPrioScheduler::schedule(TMLTime iEndSchedule){
TaskList::iterator i;
//std::cout << _name << ": Schedule called \n";
TMLTransaction *anOldTransaction=_nextTransaction, *aTempTrans;
TMLTransaction *anOldTransaction=_nextTransaction, *aTempTrans, *isDelayTrans;
TMLTime aLowestRunnableTimeFuture=-1,aRunnableTime, aLowestRunnableTimePast=-1;
WorkloadSource *aSourcePast=0, *aSourceFuture=0;
//, *aScheduledSource=0;
......@@ -61,7 +61,10 @@ TMLTime RRPrioScheduler::schedule(TMLTime iEndSchedule){
_lastSource->schedule(iEndSchedule);
if (_lastSource->getNextTransaction(iEndSchedule)!=0 && _lastSource->getNextTransaction(iEndSchedule)->getVirtualLength()!=0){
//if (anOldTransaction==0 || _lastSource->getNextTransaction(iEndSchedule)==anOldTransaction || _timeSlice >=_elapsedTime + anOldTransaction->getBranchingPenalty() + anOldTransaction->getOperationLength() + _minSliceSize){
if (anOldTransaction==0 || _lastSource->getNextTransaction(iEndSchedule)==anOldTransaction || _timeSlice >=_elapsedTime + anOldTransaction->getOperationLength() + _minSliceSize){
isDelayTrans = _lastSource->getNextTransaction(iEndSchedule);
if((!(isDelayTrans->getCommand()->getActiveDelay()) && isDelayTrans->getCommand()->isDelayTransaction())){
aSameTaskFound=false;
}else if (anOldTransaction==0 || _lastSource->getNextTransaction(iEndSchedule)==anOldTransaction || _timeSlice >=_elapsedTime + anOldTransaction->getOperationLength() + _minSliceSize){
std::cout << "Select same task, remaining: " << _timeSlice - anOldTransaction->getOperationLength() << "\n";
aSourcePast=_lastSource;
aSameTaskFound=true;
......
......@@ -52,7 +52,7 @@ RRScheduler::RRScheduler(const std::string& iName, Priority iPrio, TMLTime iTime
TMLTime RRScheduler::schedule(TMLTime iEndSchedule){
TaskList::iterator i;
//std::cout << _name << ": Schedule called \n";
TMLTransaction *anOldTransaction=_nextTransaction, *aTempTrans;
TMLTransaction *anOldTransaction=_nextTransaction, *aTempTrans, *isDelayTrans;
TMLTime aLowestRunnableTimeFuture=-1,aRunnableTime, aLowestRunnableTimePast=-1;
WorkloadSource *aSourcePast=0, *aSourceFuture=0;
//, *aScheduledSource=0;
......@@ -61,7 +61,10 @@ TMLTime RRScheduler::schedule(TMLTime iEndSchedule){
//aScheduledSource=_lastSource;
_lastSource->schedule(iEndSchedule);
if (_lastSource->getNextTransaction(iEndSchedule)!=0 && _lastSource->getNextTransaction(iEndSchedule)->getVirtualLength()!=0){
if (anOldTransaction==0 || _lastSource->getNextTransaction(iEndSchedule)==anOldTransaction || _timeSlice >=_elapsedTime + anOldTransaction->getOperationLength() + _minSliceSize){
isDelayTrans = _lastSource->getNextTransaction(iEndSchedule);
if((!(isDelayTrans->getCommand()->getActiveDelay()) && isDelayTrans->getCommand()->isDelayTransaction())){
aSameTaskFound=false;
}else if (anOldTransaction==0 || _lastSource->getNextTransaction(iEndSchedule)==anOldTransaction || _timeSlice >=_elapsedTime + anOldTransaction->getOperationLength() + _minSliceSize){
//std::cout << "Select same task, remaining: " << _timeSlice - anOldTransaction->getOperationLength() << "\n";
aSourcePast=_lastSource;
aSameTaskFound=true;
......
......@@ -324,15 +324,16 @@ void SchedulableDevice::HW2HTML(std::ofstream& myfile) const {
TMLTransaction* aCurrTrans = *i;
unsigned int aBlanks = aCurrTrans->getStartTime() - aCurrTime;
if ( aBlanks > 0 ) {
writeHTMLColumn( myfile, aBlanks, "not", "idle time" );
}
if ( aBlanks >= 0 && (!(aCurrTrans->getCommand()->getActiveDelay()) && aCurrTrans->getCommand()->isDelayTransaction()) )
writeHTMLColumn( myfile, aBlanks+1, "not", "idle time" );
else if ( aBlanks > 0 )
writeHTMLColumn( myfile, aBlanks, "not", "idle time" );
unsigned int aLength = aCurrTrans->getPenalties();
if ( aLength != 0 ) {
std::ostringstream title;
title << "idle:" << aCurrTrans->getIdlePenalty() << " switch:" << aCurrTrans->getTaskSwitchingPenalty();
title << "idle:" << aCurrTrans->getIdlePenalty() << " switching penalty:" << aCurrTrans->getTaskSwitchingPenalty();
writeHTMLColumn( myfile, aLength, "not", title.str() );
}
......@@ -402,15 +403,16 @@ void SchedulableDevice::schedule2HTML(std::ofstream& myfile) const {
TMLTransaction* aCurrTrans = *i;
unsigned int aBlanks = aCurrTrans->getStartTime() - aCurrTime;
if ( aBlanks > 0 ) {
writeHTMLColumn( myfile, aBlanks, "not", "idle time" );
}
if ( aBlanks >= 0 && (!(aCurrTrans->getCommand()->getActiveDelay()) && aCurrTrans->getCommand()->isDelayTransaction()) )
writeHTMLColumn( myfile, aBlanks+1, "not", "idle time" );
else if ( aBlanks > 0 )
writeHTMLColumn( myfile, aBlanks, "not", "idle time" );
unsigned int aLength = aCurrTrans->getPenalties();
if ( aLength != 0 ) {
std::ostringstream title;
title << "idle:" << aCurrTrans->getIdlePenalty() << " switch:" << aCurrTrans->getTaskSwitchingPenalty();
title << "idle:" << aCurrTrans->getIdlePenalty() << " switching penalty:" << aCurrTrans->getTaskSwitchingPenalty();
writeHTMLColumn( myfile, aLength, "not", title.str() );
}
......@@ -419,8 +421,9 @@ void SchedulableDevice::schedule2HTML(std::ofstream& myfile) const {
// Issue #4
TMLTask* task = aCurrTrans->getCommand()->getTask();
const std::string cellClass = determineHTMLCellClass( taskCellClasses, task, nextCellClassIndex );
writeHTMLColumn( myfile, aLength, cellClass, aCurrTrans->toShortString() );
if(!(!(aCurrTrans->getCommand()->getActiveDelay()) && aCurrTrans->getCommand()->isDelayTransaction())){
writeHTMLColumn( myfile, aLength, cellClass, aCurrTrans->toShortString() );
}
aCurrTime = aCurrTrans->getEndTime();
// }
......
......@@ -52,6 +52,7 @@ import java.util.Objects;
*/
public class TMLActivityElementWithIntervalAction extends TMLActivityElement {
protected String minDelay, maxDelay;
protected boolean isActiveDelay = false;
public TMLActivityElementWithIntervalAction(String _name, Object _referenceObject) {
super(_name, _referenceObject);
......@@ -74,16 +75,20 @@ public class TMLActivityElementWithIntervalAction extends TMLActivityElement {
}
public String customExtraToXML() {
return " min=\"" + minDelay + "\" max=\"" + maxDelay + "\" ";
return " min=\"" + minDelay + "\" max=\"" + maxDelay + "\" " + "isActiveDelay=\"" + isActiveDelay + "\" ";
}
public void setActiveDelay(boolean _b){
isActiveDelay = _b;}
public boolean getActiveDelay(){return isActiveDelay;}
public boolean equalSpec(Object o) {
if (!(o instanceof TMLActivityElementWithIntervalAction)) return false;
if (!super.equalSpec(o)) return false;
TMLActivityElementWithIntervalAction tmlAEIAction = (TMLActivityElementWithIntervalAction) o;
return Objects.equals(minDelay, tmlAEIAction.getMinDelay()) &&
Objects.equals(maxDelay, tmlAEIAction.getMaxDelay());
Objects.equals(maxDelay, tmlAEIAction.getMaxDelay()) &&
Objects.equals(isActiveDelay, tmlAEIAction.getActiveDelay());
}
......
......@@ -2138,7 +2138,7 @@ public class TMLModeling<E> {
del1 = (TMLDelay)elt1;
del0 = (TMLDelay)elt0;
if (del1.getUnit().equals(del0.getUnit())) {
if (del1.getUnit().equals(del0.getUnit()) && (del1.getActiveDelay() == del0.getActiveDelay())) {
// We delete the second i.e. elt1
activity.removeElement(elt1);
......
......@@ -432,9 +432,9 @@ public class TMLTextSpecification<E> {
tmp1 = ((TMLDelay) elt).getMinDelay();
tmp2 = ((TMLDelay) elt).getMaxDelay();
if (tmp1.compareTo(tmp2) == 0) {
code = "DELAY" + SP + modifyString(((TMLDelay) elt).getMinDelay()) + SP + modifyString(((TMLDelay) elt).getUnit()) + CR;
code = "DELAY" + SP + modifyString(((TMLDelay) elt).getMinDelay()) + SP + modifyString(((TMLDelay) elt).getUnit()) + SP + "isActiveDelay" + SP + ((TMLDelay) elt).getActiveDelay() + CR;
} else {
code = "DELAY" + SP + modifyString(((TMLDelay) elt).getMinDelay()) + SP + modifyString(((TMLDelay) elt).getMaxDelay()) + SP + modifyString(((TMLDelay) elt).getUnit()) + CR;
code = "DELAY" + SP + modifyString(((TMLDelay) elt).getMinDelay()) + SP + modifyString(((TMLDelay) elt).getMaxDelay()) + SP + modifyString(((TMLDelay) elt).getUnit()) + SP + "isActiveDelay" + SP + ((TMLDelay) elt).getActiveDelay() + CR;
}
return code + makeBehavior(task, elt.getNextElement(0));
......@@ -2643,13 +2643,13 @@ public class TMLTextSpecification<E> {
inTaskDec = false;
// inTaskBehavior = true;
if ((_split.length < 3) || (_split.length > 5)) {
error = "A DELAY operation must be declared with 2 or 3 parameters, and not " + (_split.length - 1);
if ((_split.length < 3) || (_split.length > 6)) {
error = "A DELAY operation must be declared with 2, 3, 4 or 5 parameters, and not " + (_split.length - 1);
addError(0, _lineNb, 0, error);
return -1;
}
if (_split.length == 3) {
if (_split.length == 3 || _split.length == 5) {
if (!checkParameter("DELAY", _split, 2, 0, _lineNb)) {
error = "A DELAY operation must be specified with a valid time unit (ns, us, ms, s))";
addError(0, _lineNb, 0, error);
......@@ -2657,7 +2657,7 @@ public class TMLTextSpecification<E> {
}
}
if (_split.length == 4) {
if (_split.length == 4 || _split.length == 6) {
if (!checkParameter("DELAY", _split, 3, 0, _lineNb)) {
error = "A DELAY operation must be specified with a valid time unit (ns, us, ms, s))";
addError(0, _lineNb, 0, error);
......@@ -2668,11 +2668,19 @@ public class TMLTextSpecification<E> {
TMLDelay delay = new TMLDelay("delay", null);
delay.setMinDelay(_split[1]);
if (_split.length == 3) {
delay.setMaxDelay(_split[1]);
delay.setUnit(_split[2]); // DELAY min unit - this is for old format
} else if (_split.length == 4) {
delay.setMaxDelay(_split[2]);
delay.setUnit(_split[3]); // DELAY min max unit - this is for old format
} else if (_split.length == 5) {
delay.setMaxDelay(_split[1]);
delay.setUnit(_split[2]);
delay.setActiveDelay(Boolean.valueOf(_split[4])); // DELAY min unit isActivedelay boolean
} else {
delay.setMaxDelay(_split[2]);
delay.setUnit(_split[3]);
delay.setActiveDelay(Boolean.valueOf(_split[5])); // DELAY min max unit isActivedelay boolean
}
......
......@@ -557,12 +557,22 @@ public class MappedSystemCTask {
comment = action;
action += "\nif (tmpDelayxy==0) tmpDelayxy=1;\n";
if (delay.getMinDelay().equals(delay.getMaxDelay())) {
action += "_endLastTransaction+=0";
if (!delay.getActiveDelay()){
action += "_endLastTransaction+=tmpDelayxy"; // Take all delay totally idle for x units of time
} else {
action += "_endLastTransaction+=0"; //consumes cycles
}
delayLen = delay.getMaxDelay() + "*" + masterClockFreq + delay.getMasterClockFactor();
} else {
action += "TMLTime tmpDelayxx = " + delay.getMinDelay() + "*" + masterClockFreq + delay.getMasterClockFactor() + ";\nif (tmpDelayxx==0) tmpDelayxx=1;\n";
action += "_endLastTransaction+= 0";
delayLen = delay.getMinDelay() + "*" + masterClockFreq + delay.getMasterClockFactor();
if (!delay.getActiveDelay()){
action += "_endLastTransaction+= myrand(tmpDelayxx,tmpDelayxy)"; // Take all delay totally idle for x units of time
} else {
action += "_endLastTransaction+=0"; //consumes cycles
}
java.util.Random r = new java.util.Random();
delayLen = String.valueOf(r.nextInt(Integer.valueOf(delay.getMaxDelay())-Integer.valueOf(delay.getMinDelay())) + Integer.valueOf(delay.getMinDelay())) + "*" + masterClockFreq + delay.getMasterClockFactor();
}
String elemName = currElem.getName(), idString;
if (elemName.charAt(0) == '#') {
......@@ -575,7 +585,7 @@ public class MappedSystemCTask {
idString = String.valueOf(currElem.getID());
}
hcode += "TMLDelayCommand " + cmdName + SCCR;
initCommand += "," + cmdName + "(" + idString + ",this,"+ delayLen +",(ActionFuncPointer)&" + reference + "::" + cmdName + "_func, " + getFormattedLiveVarStr(currElem) + ")" + CR;
initCommand += "," + cmdName + "(" + idString + ",this,"+ delayLen +",(ActionFuncPointer)&" + reference + "::" + cmdName + "_func, " + getFormattedLiveVarStr(currElem) + ", " + delay.getActiveDelay() + ")" + CR;
nextCommand = cmdName + ".setNextCommand(array(1,(TMLCommand*)" + makeCommands(currElem.getNextElement(0), false, retElement, null) + "));\n";
functions += "void " + reference + "::" + cmdName + "_func(){\n#ifdef ADD_COMMENTS\naddComment(new Comment(_endLastTransaction,0," + commentNum + "));\n#endif\n" + modifyString(addSemicolonIfNecessary(action)) + CR;
//functions+="return 0"+ SCCR;
......
......@@ -291,6 +291,7 @@ public class ActivityDiagram2TMLTranslator {
tmldelay.setMinDelay(modifyString(((TMLADDelay)tgc).getDelayValue()));
tmldelay.setMaxDelay(modifyString(((TMLADDelay)tgc).getDelayValue()));
tmldelay.setUnit(((TMLADDelay)tgc).getUnit());
tmldelay.setActiveDelay(((TMLADDelay)tgc).getActiveDelayEnable());
activity.addElement(tmldelay);
((BasicErrorHighlight)tgc).setStateAction(ErrorHighlight.OK);
corrTgElement.addCor(tmldelay, tgc);
......@@ -300,6 +301,7 @@ public class ActivityDiagram2TMLTranslator {
tmldelay.setMinDelay(modifyString(((TMLADDelayInterval)tgc).getMinDelayValue()));
tmldelay.setMaxDelay(modifyString(((TMLADDelayInterval)tgc).getMaxDelayValue()));
tmldelay.setUnit(((TMLADDelayInterval)tgc).getUnit());
tmldelay.setActiveDelay(((TMLADDelayInterval)tgc).getActiveDelayEnableValue());
activity.addElement(tmldelay);
((BasicErrorHighlight)tgc).setStateAction(ErrorHighlight.OK);
corrTgElement.addCor(tmldelay, tgc);
......
......@@ -66,6 +66,7 @@ public class TGCTimeDelay extends TGCWithoutInternalComponent{
private String maxDelay = "";
private String unit = "ns"; // can be "ns" or "us" or "ms" or "s";
private boolean hasMaxDelay;
private boolean isActiveDelay;
public TGCTimeDelay(int _x, int _y, int _minX, int _maxX, int _minY, int _maxY, boolean _pos, TGComponent _father, TDiagramPanel _tdp) {
super(_x, _y, _minX, _maxX, _minY, _maxY, _pos, _father, _tdp);
......@@ -144,11 +145,13 @@ public class TGCTimeDelay extends TGCWithoutInternalComponent{
}
array[0] = getMinDelay(); array[1] = getMaxDelay(); array[2] = getUnit();
JDialogTimeIntervalUnit jdti = new JDialogTimeIntervalUnit(frame, array, hasMaxDelay, "Setting time parameters", ind, "max");
JDialogTimeIntervalUnit jdti = new JDialogTimeIntervalUnit(getTDiagramPanel().getMainGUI(), frame, array, hasMaxDelay, isActiveDelay,
"Setting time parameters", ind,
"max");
//jdti.setSize(350, 250);
GraphicLib.centerOnParent(jdti, 350, 250);
jdti.setVisible( true ); // blocked until dialog has been closed
isActiveDelay = jdti.isActiveDelay();
minDelay = array[0]; maxDelay = array[1]; unit = array[2];
if (hasMaxDelay) {
......@@ -180,6 +183,12 @@ public class TGCTimeDelay extends TGCWithoutInternalComponent{
public void setHasMaxValue(boolean b) {
hasMaxDelay = b;
}
public void setActiveDelay(boolean b) {
isActiveDelay = b;
}
public boolean getActiveDelay() {
return isActiveDelay;
}
public void setMinDelay(String del) {
minDelay = del;
......@@ -207,6 +216,8 @@ public class TGCTimeDelay extends TGCWithoutInternalComponent{
sb.append(getMaxDelay());
sb.append("\" hasMaxDelay=\"");
sb.append(hasMaxDelay);
sb.append("\" isActiveDelay=\"");
sb.append(isActiveDelay);
sb.append("\" unit=\"");
sb.append(getUnit());
sb.append("\" />\n");
......@@ -236,6 +247,9 @@ public class TGCTimeDelay extends TGCWithoutInternalComponent{
if (elt.getAttribute("hasMaxDelay") != null) {
hasMaxDelay = elt.getAttribute("hasMaxDelay").compareTo("true") == 0;
}
if (elt.getAttribute("isActiveDelay") != null) {
isActiveDelay = elt.getAttribute("isActiveDelay").compareTo("true") == 0;
}
unit = elt.getAttribute("unit");
}
}
......
......@@ -81,6 +81,7 @@ public class TMLADDelay extends TADComponentWithSubcomponents /* Issue #69 TGCWi
tgc.setMinDelay("10");
tgc.setMaxDelay("nope");
tgc.setHasMaxValue(false);
tgc.setActiveDelay(false);
tgc.setUnit("ms");
tgc.setName("value of the delay");
tgc.makeValue();
......@@ -139,7 +140,8 @@ public class TMLADDelay extends TADComponentWithSubcomponents /* Issue #69 TGCWi
public String getUnit() {
return ((TGCTimeDelay)tgcomponent[0]).getUnit();
}
public boolean getActiveDelayEnable(){return ((TGCTimeDelay)tgcomponent[0]).getActiveDelay(); }
@Override
public int getType() {
return TGComponentManager.TMLAD_DELAY;
......
......@@ -156,7 +156,9 @@ public class TMLADDelayInterval extends TADComponentWithSubcomponents /* Issue #
public void setMaxValue(String val) {
((TGCTimeDelay)(tgcomponent[0])).setMaxDelay(val);
}
public boolean getActiveDelayEnableValue(){return ((TGCTimeDelay)tgcomponent[0]).getActiveDelay(); }
@Override
public int getType() {
return TGComponentManager.TMLAD_INTERVAL_DELAY;
......
......@@ -41,6 +41,9 @@
package ui.window;
import help.HelpManager;
import ui.MainGUI;
import ui.TGHelpButton;
import ui.util.IconManager;
import javax.swing.*;
......@@ -59,15 +62,17 @@ public class JDialogTimeIntervalUnit extends JDialogBase implements ActionListen
private String[] arrayDelay;
private boolean hasMaxDelay;
private boolean isActiveDelay;
private JPanel panel1;
// Panel1
private JTextField text1, text2;
private JComboBox<String> unit;
private JCheckBox wait_delay;
private String id1, id2;
private MainGUI mgui;
public TGHelpButton myButton;
/* Creates new form */
// arrayDelay: [0] -> minDelay ; [1] -> maxDelay
public JDialogTimeIntervalUnit(Frame f, String[] _arrayDelay, boolean _hasMaxDelay, String title) {
......@@ -80,17 +85,26 @@ public class JDialogTimeIntervalUnit extends JDialogBase implements ActionListen
pack();
}
public JDialogTimeIntervalUnit(Frame f, String[] _arrayDelay, boolean _hasMaxDelay, String title, String _id1, String _id2) {
public JDialogTimeIntervalUnit(MainGUI _mgui, Frame f, String[] _arrayDelay, boolean _hasMaxDelay, boolean _isActiveDelay, String title,
String _id1,
String _id2) {
super(f, title, true);
mgui =_mgui;
arrayDelay = _arrayDelay;
hasMaxDelay = _hasMaxDelay;
isActiveDelay = _isActiveDelay;
id1 = _id1;
id2 = _id2;
initComponents();
myInitComponents();
pack();
}
private void makeEndHelpButton(String helpWord, MainGUI mgui, HelpManager hm, JPanel panel, GridBagConstraints c) {
Icon myIcon = IconManager.imgic32;
myButton = new TGHelpButton(myIcon, helpWord, mgui, hm);
myButton.addToPanel(panel, c);
}
private void myInitComponents() {
}
......@@ -115,7 +129,7 @@ public class JDialogTimeIntervalUnit extends JDialogBase implements ActionListen
panel1.setBorder(new javax.swing.border.TitledBorder("setting min and max delays"));
}
panel1.setPreferredSize(new Dimension(300, 150));
// first line panel1
c1.weighty = 1.0;
c1.weightx = 1.0;
......@@ -123,7 +137,7 @@ public class JDialogTimeIntervalUnit extends JDialogBase implements ActionListen
c1.fill = GridBagConstraints.BOTH;
c1.gridheight = 1;
panel1.add(new JLabel(" "), c1);
// second line panel1
c1.gridwidth = 1;
c1.gridheight = 1;
......@@ -166,7 +180,14 @@ public class JDialogTimeIntervalUnit extends JDialogBase implements ActionListen
unit.addItem("s");
unit.setSelectedItem(arrayDelay[2]);
panel1.add(unit, c1);
c1.gridwidth = 1;
if ((id1 != null) && (id2 != null)){
wait_delay = new JCheckBox("Active Delay");
wait_delay.setSelected(isActiveDelay);
panel1.add(wait_delay,c1);
c1.gridwidth = GridBagConstraints.REMAINDER; //end row
makeEndHelpButton("activedelay.html", mgui, mgui.getHelpManager(), panel1, c1);
}
// main panel;
c0.gridwidth = 1;
c0.gridheight = 10;
......@@ -182,7 +203,9 @@ public class JDialogTimeIntervalUnit extends JDialogBase implements ActionListen