Commit 824d3b82 authored by Anders Nilsson's avatar Anders Nilsson

Updated with changes from the version of siaras ontologycompiler in the skillserver.

parent 4fc6b400
/* -*-Java-*- */
/*
* Copyright (C) 2007 Anders Nilsson <anders.nilsson@cs.lth.se>
*
* This file is part of SkillServer.
*/
import java.util.*;
aspect ConfigGen {
/********************************
* String genConfig()
********************************/
syn String Device.genConfig() = "No configuration for type: "+
getClass().getName()+"\n";
eq Controller.genConfig() {
if (id().contains("ABB")) {
StringBuffer s = new StringBuffer();
s.append("EIO:CFG_1.0:4:0::\n");
s.append("#\n");
s.append("EIO_BUS_USER:\n");
s.append(" -Name \"SIM\" -Driver \"/sim1:\"\n");
s.append(" -Name \"SW\" -Driver \"/sw1:\"\n");
s.append(" -Name \"BASE\" -Driver \"/BASE1:\"\n");
s.append("#\n");
s.append("EIO_UNIT:\n");
s.append(" -Name \"BOARD1\" -Type \"eip000\" -Bus \"SIM\" -Address \"6\" -Digin 16 -Digout 16\n");
s.append(" -Name \"BOARDSIM\" -Type \"eip000\" -Bus \"SIM\" -Address \"1\" -Digin 16 -Digout 16\n");
// System.out.println("devices: "+getNumDevice());
for (int i=0; i<getNumDevice(); i++) {
Device d = (Device) getDevice(i);
// System.out.println("Subdevice: "+d.id());
if (d instanceof IO_Board) {
s.append(" -Name ");
s.append("\""+d.id()+"\" ");
s.append("-Type ");
s.append("\""+d.id()+"\" ");
s.append("-Bus \"BASE\" ");
System.out.println(d.getNumProperty());
d.dumpTree("",System.out);
for (int j=0; j<d.getNumProperty(); j++) {
System.out.println(d.getProperty(j).decl().name());
if (d.getProperty(j).decl() instanceof Signal) {
Signal sig = (Signal) d.getProperty(j).decl();
if (sig instanceof DigIn) {
s.append(" -Digin ");
} else if (sig instanceof DigOut) {
s.append(" -DigOut ");
} else {
s.append(" Unknown_Signal ");
}
s.append(sig.getValue());
}
}
s.append("\n");
// s.append("-Digin 16 -Digout 16\n");
}
}
s.append("#\n");
s.append("EIO_SAFETY_SIGNAL = EIO_SIGNAL:\n");
s.append(" -Name \"BatAlarm\" -Type \"DO\" -Unit \"BOARD1\" -Phsig 3 -Store\n");
s.append(" -Name \"Charge\" -Type \"DO\" -Unit \"BOARD1\" -Phsig 1 -Store\n");
s.append(" -Name \"Discharge\" -Type \"DO\" -Unit \"BOARD1\" -Phsig 2 -Store\n");
s.append("#\n");
s.append("EIO_USER_SIGNAL = EIO_SIGNAL:\n");
s.append(" -Name \"Batlow\" -Type \"DI\" -Unit \"BOARD1\" -Phsig 5\n");
s.append(" -Name \"Batmeasure\" -Type \"DO\" -Unit \"BOARD1\" -Phsig 4 -Store\n");
s.append(" -Name \"Batreset\" -Type \"DO\" -Unit \"BOARDSIM\" -Phsig 9\n");
s.append(" -Name \"toollock\" -Type \"DO\" -Unit \"dig328\" -Phsig 1\n");
s.append(" -Name \"drillfeed\" -Type \"DO\" -Unit \"dig328\" -Phsig 2\n");
s.append(" -Name \"drillstop\" -Type \"DO\" -Unit \"dig328\" -Phsig 3\n");
s.append(" -Name \"drillstart\" -Type \"DO\" -Unit \"dig328\" -Phsig 6\n");
s.append("#\n");
s.append("EIO_GROUP_PHS = EIO_SIGNAL:\n");
s.append(" -Name \"Batresult\" -Type \"GO\" -Unit \"BOARDSIM\" -Phsig 1 -Length 8 -Store\n");
return s.toString();
} else {
return "No configuration support for controller: "+id();
}
}
}
......@@ -29,6 +29,7 @@ public class Ontology extends Parser {
SiarasParser parser = new SiarasParser(r);
ast = parser.Start();
ast.traverseAST();
} catch (ParseException e) {
System.out.println(e.getMessage());
}
......@@ -60,6 +61,6 @@ public class Ontology extends Parser {
public static void main(String[] args) {
Start ast = getAST(args[0]);
ast.getIndividual("CLOOS_R350").dumpTree("",System.out);
ast.getIndividual("ABB_IRB-140").dumpTree("",System.out);
}
}
......@@ -64,3 +64,30 @@ aspect Qualification {
}
}
}
aspect Property {
syn boolean Device.hasElement(String name) {
for (int i=0; i<getNumElement(); i++) {
if (((ComplexElement) getElement(i)).name().equals(name)) {
return true;
}
}
return false;
}
rewrite Device {
when (hasElement("hasProperty")) to Device {
List remainList = new List();
for (int i=0; i<getNumElement(); i++) {
ComplexElement e = (ComplexElement) getElement(i);
if (e.name().equals("hasProperty")) {
addProperty((Thing) e);
} else {
remainList.add(e);
}
}
setElementList(remainList);
return this;
}
}
}
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