Search in sources :

Example 1 with DeviceVariantInformation

use of net.sourceforge.usbdm.deviceEditor.information.DeviceVariantInformation in project usbdm-eclipse-plugins by podonoghue.

the class FamilyXmlWriter method writeXmlFile.

/**
 * Writes XML file
 *
 * @param xmlFilePath      Path to write XML to
 * @param deviceInfomation Data to write
 * @throws Exception
 */
public void writeXmlFile(Path xmlFilePath) throws Exception {
    String xmlFilename = xmlFilePath.getFileName().toString();
    BufferedWriter writer = Files.newBufferedWriter(xmlFilePath, StandardCharsets.UTF_8);
    XmlDocumentUtilities documentUtilities = new XmlDocumentUtilities(writer);
    documentUtilities.writeXmlFilePreamble(xmlFilename, DeviceInfo.DTD_FILE, "Generated from " + fDeviceInfo.getSourceFilename());
    documentUtilities.openTag("root");
    documentUtilities.writeAttribute("version", DeviceInfo.VERSION);
    documentUtilities.openTag("family");
    documentUtilities.writeAttribute("name", fDeviceInfo.getDeviceSubFamily());
    for (String key : fDeviceInfo.getDeviceVariants().keySet()) {
        DeviceVariantInformation deviceInformation = fDeviceInfo.findVariant(key);
        documentUtilities.openTag("device");
        documentUtilities.writeAttribute("name", deviceInformation.getName());
        documentUtilities.writeAttribute("manual", deviceInformation.getManual());
        documentUtilities.writeAttribute("package", deviceInformation.getPackage().getName());
        documentUtilities.closeTag();
    }
    documentUtilities.closeTag();
    writePeripherals(documentUtilities);
    // writeSignals(documentUtilities);
    writePins(documentUtilities);
    writePackages(documentUtilities);
    documentUtilities.closeTag();
    writer.close();
}
Also used : XmlDocumentUtilities(net.sourceforge.usbdm.deviceEditor.xmlParser.XmlDocumentUtilities) BufferedWriter(java.io.BufferedWriter) DeviceVariantInformation(net.sourceforge.usbdm.deviceEditor.information.DeviceVariantInformation)

Example 2 with DeviceVariantInformation

use of net.sourceforge.usbdm.deviceEditor.information.DeviceVariantInformation in project usbdm-eclipse-plugins by podonoghue.

the class TestParseXML method report.

static void report(DeviceInfo deviceInfo) {
    for (String key : deviceInfo.getDeviceVariants().keySet()) {
        DeviceVariantInformation deviceInformation = deviceInfo.findVariant(key);
        System.err.println("deviceInformation = " + deviceInformation);
    }
    for (String packageName : deviceInfo.getDevicePackages().keySet()) {
        DevicePackage devicePackage = deviceInfo.findDevicePackage(packageName);
        System.err.println("Package = " + devicePackage);
        for (String pinName : devicePackage.getPins().keySet()) {
            String location = devicePackage.getLocation(pinName);
            System.err.print(pinName + " => " + location + ", ");
        }
        System.err.println();
    }
    for (String pinName : deviceInfo.getPins().keySet()) {
        Pin pin = deviceInfo.findPin(pinName);
        System.err.print("Pin = " + pin.getName() + ", ");
    }
    ;
    System.err.println();
    for (String peripheralName : deviceInfo.getPeripheralNames()) {
        System.err.print("Peripheral = " + peripheralName + ", ");
    }
    ;
    System.err.println();
    for (String signals : deviceInfo.getSignals().keySet()) {
        System.err.print("Signal = " + signals + ", ");
    }
    ;
    System.err.println();
}
Also used : Pin(net.sourceforge.usbdm.deviceEditor.information.Pin) DevicePackage(net.sourceforge.usbdm.deviceEditor.information.DevicePackage) DeviceVariantInformation(net.sourceforge.usbdm.deviceEditor.information.DeviceVariantInformation)

Example 3 with DeviceVariantInformation

use of net.sourceforge.usbdm.deviceEditor.information.DeviceVariantInformation in project usbdm-eclipse-plugins by podonoghue.

the class PackageImageModel method createImage.

/**
 * Creates the image representing the package
 *
 * @return Image created (transfers ownership!)
 */
private Image createImage() {
    try {
        DeviceVariantInformation deviceVariant = fModelFactory.getDeviceInfo().getVariant();
        IPath path = Usbdm.getResourcePath().append("Stationery/Packages/Images/" + deviceVariant.getPackage().getName() + ".png");
        return new Image(Display.getCurrent(), path.toString());
    } catch (Exception e) {
        System.err.println("Failed to load device image, reason: )" + e.getMessage());
        return null;
    }
}
Also used : IPath(org.eclipse.core.runtime.IPath) Image(org.eclipse.swt.graphics.Image) DeviceVariantInformation(net.sourceforge.usbdm.deviceEditor.information.DeviceVariantInformation)

Aggregations

DeviceVariantInformation (net.sourceforge.usbdm.deviceEditor.information.DeviceVariantInformation)3 BufferedWriter (java.io.BufferedWriter)1 DevicePackage (net.sourceforge.usbdm.deviceEditor.information.DevicePackage)1 Pin (net.sourceforge.usbdm.deviceEditor.information.Pin)1 XmlDocumentUtilities (net.sourceforge.usbdm.deviceEditor.xmlParser.XmlDocumentUtilities)1 IPath (org.eclipse.core.runtime.IPath)1 Image (org.eclipse.swt.graphics.Image)1