Search in sources :

Example 1 with WriteFamilyCpp

use of net.sourceforge.usbdm.deviceEditor.peripherals.WriteFamilyCpp 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 WriteFamilyCpp

use of net.sourceforge.usbdm.deviceEditor.peripherals.WriteFamilyCpp 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)

Example 3 with WriteFamilyCpp

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

the class TestCreateCpp method main.

public static void main(String[] args) throws Exception {
    Path directory = Paths.get("BulkTesting");
    Path dataDirectory = Paths.get("data");
    // Locate header output directory
    Path headerDirectory = directory.resolve("Project_Headers");
    // Locate source output directory
    Path sourcesDirectory = directory.resolve("Sources");
    // Create output directories if needed
    if (!directory.toFile().exists()) {
        Files.createDirectory(directory);
    }
    if (!headerDirectory.toFile().exists()) {
        Files.createDirectory(headerDirectory);
    }
    if (!sourcesDirectory.toFile().exists()) {
        Files.createDirectory(sourcesDirectory);
    }
    DirectoryStream<Path> folderStream = Files.newDirectoryStream(dataDirectory.toAbsolutePath(), csvFilter);
    for (Path filePath : folderStream) {
        if (!Files.isRegularFile(filePath)) {
            continue;
        }
        /*
          * Process each input file
          */
        System.err.println("Processing " + filePath.getFileName() + " ======================== ");
        DeviceInfo deviceInfo = DeviceInfo.create(filePath);
        WriteFamilyCpp writer = new WriteFamilyCpp();
        writer.writeCppFiles(directory, deviceInfo);
    }
}
Also used : Path(java.nio.file.Path) WriteFamilyCpp(net.sourceforge.usbdm.deviceEditor.peripherals.WriteFamilyCpp) DeviceInfo(net.sourceforge.usbdm.deviceEditor.information.DeviceInfo)

Aggregations

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