Commit 8598e4c4 authored by Anders Nilsson's avatar Anders Nilsson

Added new ontology, revised code.

parent 0bb74d2d
......@@ -43,8 +43,9 @@ OwlMaxCardinality : ComplexElement;
OwlObjectProperty : OwlProperty;
OwlOneOf : ComplexElement;
OwlOnProperty : OwlProperty;
OwlSomeValuesFrom : OwlValuesFrom;
OwlRestriction : ComplexElement;
OwlSomeValuesFrom : OwlValuesFrom;
OwlTransitiveProperty : ComplexElement;
OwlUnionOf : ComplexElement;
abstract SimpleElement : Element;
......
......@@ -87,6 +87,7 @@ SPECIAL_TOKEN : /* COMMENTS */
| < OWL_ONTOLOGY : "owl:Ontology" >
| < OWL_RESTRICTION : "owl:Restriction" >
| < OWL_SOMEVALUESFROM : "owl:someValuesFrom" >
| < OWL_TRANSITIVEPROPERTY : "owl:TransitiveProperty" >
| < OWL_UNIONOF : "owl:unionOf" >
| < RDF_RDF : "rdf:RDF" >
| < RDF_ABOUT : "rdf:about" >
......@@ -424,8 +425,9 @@ void OwlElement() : {}
| OwlObjectProperty()
| OwlOneOf()
| OwlOnProperty()
| OwlSomeValuesFrom()
| OwlRestriction()
| OwlSomeValuesFrom()
| OwlTransitiveProperty()
| OwlUnionOf()
}
......@@ -543,16 +545,22 @@ void OwlOnProperty () #OwlOnProperty : {}
(">" ElementList() "</" <OWL_ONPROPERTY> ">" | ElementList() "/>")
}
void OwlRestriction () #OwlRestriction : {}
{
<OWL_RESTRICTION> AttributeList()
(">" ElementList() "</" <OWL_RESTRICTION> ">" | ElementList() "/>")
}
void OwlSomeValuesFrom () #OwlSomeValuesFrom : {}
{
<OWL_SOMEVALUESFROM> AttributeList()
(">" ElementList() "</" <OWL_SOMEVALUESFROM> ">" | ElementList() "/>")
}
void OwlRestriction () #OwlRestriction : {}
void OwlTransitiveProperty () #OwlTransitiveProperty : {}
{
<OWL_RESTRICTION> AttributeList()
(">" ElementList() "</" <OWL_RESTRICTION> ">" | ElementList() "/>")
<OWL_TRANSITIVEPROPERTY> AttributeList()
(">" ElementList() "</" <OWL_TRANSITIVEPROPERTY> ">" | ElementList() "/>")
}
void OwlUnionOf () #OwlUnionOf : {}
......
......@@ -7,31 +7,31 @@
*/
aspect Geometry {
syn lazy String Thing.getGeometryRef() = "NotApplicable";
// syn lazy String Thing.getGeometryRef() = "NotApplicable";
eq Product.getGeometryRef(){
// eq Product.getGeometryRef(){
// // if (getNumAttribute() > 0) {
// // return getAttribute(0).name();
// // } else {
// // return "unknown_id";
// // }
for (int i=0; i<getNumElement(); i++) {
// System.out.println(" Checking "+getElement(i));
if (getElement(i).isGeometryRef()) {
System.out.println("Found Geometry ref");
// System.out.println(" Found identifier: "+((ComplexElement) getElement(i)).getAttribute(0).name());
Geometry g = (Geometry) ((ClassUse) getElement(i)).decl();
// System.out.println(" "+((ComplexElement) ident.getElement(0)).name());
// return ident.value();
return g.getValue();
}
}
return "_No_GeometryRef_";
}
// // // if (getNumAttribute() > 0) {
// // // return getAttribute(0).name();
// // // } else {
// // // return "unknown_id";
// // // }
// for (int i=0; i<getNumElement(); i++) {
// // System.out.println(" Checking "+getElement(i));
// if (getElement(i).isGeometryRef()) {
// System.out.println("Found Geometry ref");
// // System.out.println(" Found identifier: "+((ComplexElement) getElement(i)).getAttribute(0).name());
// Geometry g = (Geometry) ((ClassUse) getElement(i)).decl();
// // System.out.println(" "+((ComplexElement) ident.getElement(0)).name());
// // return ident.value();
// return g.getValue();
// }
// }
// return "_No_GeometryRef_";
// }
syn boolean Element.isGeometryRef() = false;
eq ComplexElement.isGeometryRef() = name().equals("hasGeometry"); // Ugly hack!
eq Geometry.isGeometryRef() = true;
// syn boolean Element.isGeometryRef() = false;
// eq ComplexElement.isGeometryRef() = name().equals("hasGeometry"); // Ugly hack!
// eq Geometry.isGeometryRef() = true;
}
\ No newline at end of file
......@@ -52,13 +52,13 @@ public class GeometryDemo extends Parser {
con.readLine("\n\nFind the Teapot instance");
Product p = (Product) ast.getIndividual("Teapot_1");
p.dumpTree("",System.out);
// p.prettyPrint("",System.out);
// Product p = (Product) ast.getIndividual("Teapot_1");
// p.dumpTree("",System.out);
// // p.prettyPrint("",System.out);
con.readLine("\n\nFind the geometry reference");
// con.readLine("\n\nFind the geometry reference");
String s = p.getGeometryRef();
System.out.println("Geometry model: "+s);
// String s = p.getGeometryRef();
// System.out.println("Geometry model: "+s);
}
}
......@@ -354,12 +354,12 @@ void StringElement() #StringElement : { Token t;String s; }
{
t = <IDENTIFIER>
{
s = t.image;
s = t.image+" ";
if (getToken(1).kind != START_TAG ) {
s += getData();
}
}
{jjtThis.setLITERAL(s);}
{jjtThis.setLITERAL(s.trim());}
}
JAVACODE
......
......@@ -51,7 +51,7 @@ aspect SkillserverInterface {
public Thing Thing.getIndividual(String id) {
// System.out.println(" "+name());
// System.out.println("Looking for: "+id+" in: "+id()+" ("+name()+")");
// System.out.println("Looking in: "+id()+" "+" ("+name()+")");
// System.out.println("Looking in: "+id());
// if (id().contains(id) &&
// (this instanceof Device)) {
if (id.equals(id())) {
......@@ -96,7 +96,6 @@ aspect SkillserverInterface {
* getPropertyValues(String name)
********************************/
public Collection Thing.getPropertyValues(String name) {
// System.out.println("Looking for property: "+name+" in "+id());
LinkedList l = new LinkedList();
for (int i=0; i<getNumElement(); i++) {
if (getElement(i) instanceof ClassUse) {
......@@ -114,6 +113,17 @@ aspect SkillserverInterface {
return l;
}
public Collection Device.getPropertyValues(String name) {
LinkedList l = new LinkedList();
for (int i=0; i<getNumProperty(); i++) {
ClassUse c = (ClassUse) getProperty(i);
if (c.name().equals(name)) {
l.add(c.decl());
}
}
return l;
}
/********************************
* Thing Thing.getDirectType()
********************************/
......@@ -227,32 +237,32 @@ aspect Misc {
// } else {
// return "unknown_id";
// }
for (int i=0; i<getNumElement(); i++) {
// for (int i=0; i<getNumElement(); i++) {
// System.out.println(" Checking "+getElement(i));
if (getElement(i).isIdentifier()) {
// if (getElement(i).isIdentifier()) {
// System.out.println(" Found identifier: "+((ComplexElement) getElement(i)).getAttribute(0).name());
Identifier ident = (Identifier) ((ClassUse) getElement(i)).decl();
// Identifier ident = (Identifier) ((ClassUse) getElement(i)).decl();
// System.out.println(" "+((ComplexElement) ident.getElement(0)).name());
// return ident.value();
return ident.getValue();
}
}
// return ident.getValue();
// }
// }
return "unknown_id";
}
syn boolean Element.isIdentifier() = false;
eq ComplexElement.isIdentifier() = name().equals("hasIdentifier"); // Ugly hack!
eq Identifier.isIdentifier() = true;
// eq Identifier.isIdentifier() = true;
// eq ClassUse.isIdentifier() = decl().isIdentifier();
syn lazy String Identifier.value() {
for (int i=0; i<getNumElement(); i++) {
if (getElement(i) instanceof StringElement) {
return ((StringElement) getElement(i)).getLITERAL();
}
}
return "#valueNotFound";
}
// syn lazy String Identifier.value() {
// for (int i=0; i<getNumElement(); i++) {
// if (getElement(i) instanceof StringElement) {
// return ((StringElement) getElement(i)).getLITERAL();
// }
// }
// return "#valueNotFound";
// }
}
......
......@@ -21,6 +21,10 @@ public class Statistics extends Parser {
ast.getSensors(System.out);
System.out.println();
// System.out.println("Test");
// System.out.println(ast.getIndividual("Asentics_CR723-A073").id());
// System.out.println();
}
}
......@@ -55,7 +55,8 @@ aspect Statistics {
}
public void Sensor.getSensors(PrintStream pStream) {
pStream.println(" "+getOwlIdentifier().getIDENTIFIER()+
" : "+getAttribute(0).getValue().getSTRING_LITERAL());
" : "+getAttribute(0).getValue().getSTRING_LITERAL()+
" ("+id()+")");
super.getSensors(pStream);
}
......
This diff is collapsed.
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment