use of net.sourceforge.usbdm.deviceEditor.xmlParser.ParseFamilyXML in project usbdm-eclipse-plugins by podonoghue.
the class DeviceInfo method parse.
/**
* Load hardware description from file
*
* @param hardwarePath Path to load from
*
* @throws Exception
*/
private void parse(Path hardwarePath) throws Exception {
System.err.println("DeviceInfo.parse(" + hardwarePath.toAbsolutePath() + ")");
fHardwarePath = hardwarePath;
String filename = fHardwarePath.getFileName().toString();
if (filename.endsWith(HARDWARE_CSV_FILE_EXTENSION)) {
ParseFamilyCSV parser = new ParseFamilyCSV(this);
parser.parseFile(fHardwarePath);
} else if ((filename.endsWith("xml")) || (filename.endsWith(HARDWARE_FILE_EXTENSION))) {
ParseFamilyXML parser = new ParseFamilyXML();
parser.parseFile(this, fHardwarePath);
fVariableProvider = new VariableProvider("Common Settings", this) {
// Add change lister to mark editor dirty
@Override
public void addVariable(Variable variable) {
super.addVariable(variable);
variable.addListener(DeviceInfo.this);
}
};
fMenuData = ParseMenuXML.parseMenuFile("_common_settings", fVariableProvider);
ArrayList<PeripheralWithState> peripheralWithStateList = new ArrayList<PeripheralWithState>();
// Construct list of all PeripheralWithState
for (String name : fPeripheralsMap.keySet()) {
Peripheral p = fPeripheralsMap.get(name);
if (p instanceof PeripheralWithState) {
peripheralWithStateList.add((PeripheralWithState) fPeripheralsMap.get(name));
}
}
// Sort in priority order
Collections.sort(peripheralWithStateList, new Comparator<PeripheralWithState>() {
@Override
public int compare(PeripheralWithState o1, PeripheralWithState o2) {
return o2.getPriority() - o1.getPriority();
}
});
// Construct peripherals
for (PeripheralWithState p : peripheralWithStateList) {
if (p instanceof PeripheralWithState) {
// System.err.println("Constructing " + p);
((PeripheralWithState) p).loadModels();
}
}
for (PeripheralWithState p : peripheralWithStateList) {
if (p instanceof PeripheralWithState) {
p.instantiateAliases();
}
}
} else {
throw new Exception("Unexpected file type for " + hardwarePath);
}
}
Aggregations