Subversion Repositories shark

Compare Revisions

Ignore whitespace Rev 1269 → Rev 1270

/demos/trunk/loader/generators/fsf-schema.xsd
File deleted
/demos/trunk/loader/generators/java/task_class.java
1,4 → 1,4
package first_filter;
//package first_filter;
 
/**
* <p>Title: First XML filter</p>
23,4 → 23,4
public task_class() {
}
 
}
}
/demos/trunk/loader/generators/java/timespec.java
1,4 → 1,4
package first_filter;
//package first_filter;
 
/**
* <p>Title: First XML filter</p>
34,4 → 34,4
 
}
 
}
}
/demos/trunk/loader/generators/java/fsf-schema.xsd
0,0 → 1,77
<?xml version="1.0" encoding="UTF-8"?>
<xs:schema xmlns:xs='http://www.w3.org/2001/XMLSchema'>
 
<xs:element name="fsf_framework">
<xs:complexType>
<xs:sequence>
<xs:element ref="simulation"/>
<xs:element ref="contract" minOccurs='1' maxOccurs='unbounded'/>
</xs:sequence>
</xs:complexType>
</xs:element>
 
<xs:element name="simulation">
<xs:complexType>
<xs:sequence>
<xs:element name="time" type="xs:string"/>
</xs:sequence>
</xs:complexType>
</xs:element>
 
<xs:element name="contract">
<xs:complexType>
<xs:sequence>
<xs:element name="cmin" type="xs:string"/>
<xs:element name="tmax" type="xs:string" />
<xs:element name="cmax" type="xs:string" />
<xs:element name="tmin" type="xs:string" />
<xs:element name="workload" type="xs:string" />
<xs:element ref="localscheduler"/>
</xs:sequence>
</xs:complexType>
</xs:element>
 
<xs:element name="localscheduler">
<xs:complexType>
<xs:sequence>
<xs:element ref="task_section" minOccurs='1' maxOccurs='unbounded'/>
</xs:sequence>
<xs:attribute name="type" type="xs:string" use='required'/>
</xs:complexType>
</xs:element>
 
<xs:element name="task_section">
<xs:complexType>
<xs:sequence>
<xs:element name="number" type="xs:integer"/>
<xs:element name="dline" type="xs:string" minOccurs="0" />
<xs:element name="wcet" type="xs:string"/>
<xs:element ref="act_section"/>
<xs:element ref="exec_section"/>
</xs:sequence>
<xs:attribute name="type" type="xs:string" use='required'/>
</xs:complexType>
</xs:element>
 
<xs:element name="act_section">
<xs:complexType>
<xs:sequence>
<xs:element name="start_time" type="xs:string"/>
<xs:element name="period_time" type="xs:string" minOccurs="0" />
<xs:element name="delta_time" type="xs:string" minOccurs="0" />
</xs:sequence>
<xs:attribute name="type" type="xs:string" use='required'/>
</xs:complexType>
</xs:element>
 
<xs:element name="exec_section">
<xs:complexType>
<xs:sequence>
<xs:element name="exec_time" type="xs:string"/>
<xs:element name="delta_time" type="xs:string" minOccurs="0" />
</xs:sequence>
<xs:attribute name="type" type="xs:string" use='required'/>
</xs:complexType>
</xs:element>
 
</xs:schema>
/demos/trunk/loader/generators/java/makefile
0,0 → 1,12
CLASSPATH=/danger/java/j2sdk1.4.2/jre/lib
 
all:
javac Applicazione.java timespec.java task_class.java -classpath "$(CLASSPATH)/jdom.jar"
 
exec:
 
java -classpath ".:$(CLASSPATH)/jdom.jar:$(CLASSPATH)/xercesImpl.jar:$(CLASSPATH)/xml-apis.jar" Applicazione ./loadxml.fsf
 
clean:
rm -f *.class
 
/demos/trunk/loader/generators/java/Applicazione.java
1,4 → 1,4
package first_filter;
//package first_filter;
 
import java.io.*;
import java.net.*;
9,6 → 9,8
import org.jdom.input.SAXBuilder;
import org.jdom.output.XMLOutputter;
import java.util.regex.*;
import java.util.random;
 
/**
* <p>Title: First XML filter</p>
* <p>Description: </p>
205,7 → 207,7
} else if (t.getValue().equals("OneShot")) {
process_oneshot_task(e, out);
task_type=21;
} else if (t.getValue().equals("PeriodicTask")) {
} else if (t.getValue().equals("CyclicalTask")) {
String[] dline=pattern.split(e.getChild("dline").getText());
task_type=22;
time.tv_sec = Long.valueOf(dline[0]).longValue();
245,11 → 247,15
void process_back_task(Element e, OutputStreamWriter out) {
 
Pattern pattern = Pattern.compile("[us\\s]+");
String[] start_time=pattern.split(e.getChild("start_time").getText());
String[] wcet=pattern.split(e.getChild("wcet").getText());
 
Element act_section=e.getChild("act_section");
String[] start_time=pattern.split(act_section.getChild("start_time").getText());
Element exec_section=e.getChild("exec_section");
 
String[] exec_const=pattern.split(exec_section.getChild("exec_const").getText());
try {
out.write("struct timespec act_task"+task_group+"[]={{"+start_time[0]+","+start_time[1]+"},};\n\n");
out.write("struct timespec exec_task"+task_group+"[]={{"+wcet[0]+","+wcet[1]+"},};\n\n");
out.write("struct timespec exec_task"+task_group+"[]={{"+exec_const[0]+","+exec_const[1]+"},};\n\n");
 
}
catch (java.io.IOException ex) {
258,13 → 264,17
}
}
void process_oneshot_task(Element e, OutputStreamWriter out) {
int number=Integer.parseInt(e.getChild("number").getText());
Pattern pattern = Pattern.compile("[us\\s]+");
String[] start_time=pattern.split(e.getChild("start_time").getText());
String[] wcet=pattern.split(e.getChild("wcet").getText());
Element act_section=e.getChild("act_section");
String[] start_time=pattern.split(act_section.getChild("start_time").getText());
 
Element exec_section=e.getChild("exec_section");
String[] exec_const=pattern.split(exec_section.getChild("exec_const").getText());
 
try {
out.write("struct timespec act_task"+task_group+"[]={{"+start_time[0]+","+start_time[1]+"},};\n\n");
out.write("struct timespec exec_task"+task_group+"[]={{"+wcet[0]+","+wcet[1]+"},};\n\n");
out.write("struct timespec exec_task"+task_group+"[]={{"+exec_const[0]+","+exec_const[1]+"},};\n\n");
}
catch (java.io.IOException ex) {
System.out.println("File Exception: " + ex.getMessage());
271,13 → 281,41
}
}
 
int process_periodic_task(Element e, OutputStreamWriter out) {
int number=Integer.parseInt(e.getChild("number").getText());
int process_cyclical_task(Element e, OutputStreamWriter out) {
int activated=1;
Pattern pattern = Pattern.compile("[us\\s]+");
String[] start_time=pattern.split(e.getChild("start_time").getText());
String[] wcet=pattern.split(e.getChild("wcet").getText());
String[] period=pattern.split(e.getChild("mit").getText());
Element act_section=e.getChild("act_section");
String[] start_time=pattern.split(act_section.getChild("start_time").getText());
String[] period=pattern.split(act_section.getChild("period_time").getText());
Element deltatime=act_section.getChild("delta_time");
String[] delta_time;
 
long act_delta=0;
timespec delta_act_ts = new timespec();
 
if (deltatime.exists()) {
delta_time = pattern.split(deltatime.getText());
delta_act_ts.tv_sec = Long.valueOf(delta_time[0]).longValue();
delta_act_ts.tv_nsec = Long.valueOf(delta_time[1]).longValue() / 1000;
act_delta = delta_act_ts.TIMESPEC2USEC();
}
 
Element exec_section=e.getChild("exec_section");
String[] exec_const=pattern.split(exec_section.getChild("exec_const").getText());
Element execdelta=exec_section.getChild("exec_delta");
String[] exec_delta;
 
long exec_delta_long = 0;
timespec delta_act_ts = new timespec();
 
if (execdelta.exists()) {
exec_delta=pattern.split(execdelta.getText());
exec_act_ts.tv_sec = Long.valueOf(exec_delta[0]).longValue();
exec_act_ts.tv_nsec = Long.valueOf(exec_delta[1]).longValue() / 1000;
exec_delta_long = exec_act_ts.TIMESPEC2USEC();
}
 
try {
out.write("struct timespec act_task"+task_group+"[]={{"+
start_time[0]+","+start_time[1]+"},\n");
286,25 → 324,40
time.tv_sec = Long.valueOf(period[0]).longValue();
time.tv_nsec = Long.valueOf(period[1]).longValue() / 1000;
 
long mit = time.TIMESPEC2USEC();
long usecperiod = time.TIMESPEC2USEC();
timespec nextact = new timespec();
 
time.tv_sec = Long.valueOf(start_time[0]).longValue();
time.tv_nsec = Long.valueOf(start_time[1]).longValue() / 1000;
Random rd = new Random();
 
while (simulation_time.TIMESPEC_A_GT_B(time)) {
time.ADDUSEC2TIMESPEC(mit);
out.write(" {"+period[0]+","+period[1]+"},\n");
 
nextact.tv_sec = Long.valueOf(period[0]).longValue();
nextact.tv_nsec = Long.valueOf(period[1]).longValue() / 1000;
 
nextact.ADDUSEC2TIMESPEC((rd.nextInt() & Integer.MAX_INT) % act_delta - act_delta/2);
 
time.ADDUSEC2TIMESPEC(usecperiod);
out.write(" {"+nextact.tv_sec+","+nextact.tv_nsec/1000+"},\n");
activated++;
// fprintf(file_act_header, " {%d,%d},\n",
// (int) c - > act_par_2.tv_sec, (int) c - > act_par_2.tv_nsec);
}
out.write("};\n");
 
out.write("struct timespec exec_task"+task_group+"[]={{"+
wcet[0]+","+wcet[1]+"},\n");
out.write("struct timespec exec_task"+task_group+"[]={\n");
 
for (int i=1; i<activated; i++) {
out.write(" {"+wcet[0]+","+wcet[1]+"},\n");
timespec nextexec = new timespec();
 
for (int i=0; i<activated; i++) {
 
nextexec.tv_sec = Long.valueOf(exec_const[0]).longValue();
nextexec.tv_nsec = Long.valueOf(exec_const[1]).longValue() / 1000;
 
nextexec.ADDUSEC2TIMESPEC((rd.nextInt() & Integer.MAX_INT) % exec_delta_long - exec_delta_long/2);
out.write(" {"+nextexec.tv_sec+","+nextexec.tv_nsec/1000+"},\n");
 
}
out.write("};\n");
}