Search in sources :

Example 1 with ProcessProjectActions

use of net.sourceforge.usbdm.deviceEditor.peripherals.ProcessProjectActions in project usbdm-eclipse-plugins by podonoghue.

the class DeviceInfo method generateCppFiles.

/**
 * Generate CPP files (pin_mapping.h, gpio.h)<br>
 * Used for testing (files created relative to executable)
 *
 * @throws Exception
 */
public void generateCppFiles() throws Exception {
    // Output directory for test files
    Path folder = Paths.get("Testing");
    // Generate device header file
    Path headerfilePath = folder.resolve(UsbdmConstants.PROJECT_INCLUDE_FOLDER).resolve(getDeviceSubFamily() + ".h");
    DevicePeripherals devicePeripherals = getDevicePeripherals();
    devicePeripherals.writeHeaderFile(headerfilePath, new NullProgressMonitor());
    // Generate pinmapping.h etc
    WriteFamilyCpp writer = new WriteFamilyCpp();
    writer.writeCppFiles(folder, "", this);
    // Regenerate vectors.cpp
    Map<String, String> variableMap = getSimpleSymbolMap();
    generateVectorTable(variableMap, devicePeripherals, new NullProgressMonitor());
    FileUtility.refreshFile(folder.resolve(UsbdmConstants.PROJECT_VECTOR_CPP_PATH), variableMap);
    ProcessProjectActions processProjectActions = new ProcessProjectActions();
    regenerateProjectFiles(processProjectActions, null, new NullProgressMonitor());
    for (String key : fPeripheralsMap.keySet()) {
        Peripheral p = fPeripheralsMap.get(key);
        if (p instanceof PeripheralWithState) {
            ((PeripheralWithState) p).regenerateProjectFiles(processProjectActions, null, new NullProgressMonitor());
        }
    }
}
Also used : Path(java.nio.file.Path) NullProgressMonitor(org.eclipse.core.runtime.NullProgressMonitor) PeripheralWithState(net.sourceforge.usbdm.deviceEditor.peripherals.PeripheralWithState) ProcessProjectActions(net.sourceforge.usbdm.deviceEditor.peripherals.ProcessProjectActions) DevicePeripherals(net.sourceforge.usbdm.peripheralDatabase.DevicePeripherals) WriteFamilyCpp(net.sourceforge.usbdm.deviceEditor.peripherals.WriteFamilyCpp)

Example 2 with ProcessProjectActions

use of net.sourceforge.usbdm.deviceEditor.peripherals.ProcessProjectActions in project usbdm-eclipse-plugins by podonoghue.

the class DeviceInfo method generateCppFiles.

/**
 * Generate CPP files (pin_mapping.h, gpio.h etc) within an Eclipse C++ project
 *
 * @param project       Destination Eclipse C++ project
 * @param monitor
 * @throws Exception
 */
public void generateCppFiles(IProject project, IProgressMonitor monitor) throws Exception {
    SubMonitor subMonitor = SubMonitor.convert(monitor, (fPeripheralsMap.size() + 5) * 100);
    // Generate device header file
    Path projectDirectory = Paths.get(project.getLocation().toPortableString());
    Path headerfilePath = projectDirectory.resolve(UsbdmConstants.PROJECT_INCLUDE_FOLDER).resolve(getDeviceSubFamily() + ".h");
    subMonitor.subTask("Parse SVD file");
    DevicePeripherals devicePeripherals = getDevicePeripherals();
    subMonitor.worked(10);
    devicePeripherals.writeHeaderFile(headerfilePath, subMonitor.newChild(10));
    // Generate pinmapping.h etc
    WriteFamilyCpp writer = new WriteFamilyCpp();
    writer.writeCppFiles(project, this, subMonitor.newChild(10));
    // Regenerate vectors.cpp
    Map<String, String> variableMap = new HashMap<String, String>();
    generateVectorTable(variableMap, devicePeripherals, subMonitor.newChild(10));
    FileUtility.refreshFile(project, UsbdmConstants.PROJECT_VECTOR_CPP_PATH, variableMap, subMonitor.newChild(10));
    ProcessProjectActions processProjectActions = new ProcessProjectActions();
    regenerateProjectFiles(processProjectActions, project, subMonitor.newChild(10));
    for (String key : fPeripheralsMap.keySet()) {
        Peripheral p = fPeripheralsMap.get(key);
        if (p instanceof PeripheralWithState) {
            ((PeripheralWithState) p).regenerateProjectFiles(processProjectActions, project, subMonitor.newChild(10));
        }
    }
}
Also used : Path(java.nio.file.Path) PeripheralWithState(net.sourceforge.usbdm.deviceEditor.peripherals.PeripheralWithState) ProcessProjectActions(net.sourceforge.usbdm.deviceEditor.peripherals.ProcessProjectActions) DevicePeripherals(net.sourceforge.usbdm.peripheralDatabase.DevicePeripherals) HashMap(java.util.HashMap) WriteFamilyCpp(net.sourceforge.usbdm.deviceEditor.peripherals.WriteFamilyCpp) SubMonitor(org.eclipse.core.runtime.SubMonitor)

Aggregations

Path (java.nio.file.Path)2 PeripheralWithState (net.sourceforge.usbdm.deviceEditor.peripherals.PeripheralWithState)2 ProcessProjectActions (net.sourceforge.usbdm.deviceEditor.peripherals.ProcessProjectActions)2 WriteFamilyCpp (net.sourceforge.usbdm.deviceEditor.peripherals.WriteFamilyCpp)2 DevicePeripherals (net.sourceforge.usbdm.peripheralDatabase.DevicePeripherals)2 HashMap (java.util.HashMap)1 NullProgressMonitor (org.eclipse.core.runtime.NullProgressMonitor)1 SubMonitor (org.eclipse.core.runtime.SubMonitor)1