Search in sources :

Example 1 with Device

use of net.sourceforge.usbdm.deviceDatabase.Device in project usbdm-eclipse-plugins by podonoghue.

the class UsbdmDeviceSelectionPage_2 method createPageData.

private synchronized void createPageData() {
    fPageData = new HashMap<String, String>();
    fPageData.put(UsbdmConstants.PATH_SEPARATOR_KEY, String.valueOf(File.separator));
    String buildToolsId = getBuildToolsId();
    ToolInformationData toolInfo = ToolInformationData.getToolInformationTable().get(buildToolsId);
    if (toolInfo == null) {
        fPageData.put(UsbdmConstants.BUILD_TOOLS_BIN_PATH_KEY, "");
        fPageData.put(UsbdmConstants.GDB_COMMAND_KEY, "gdb");
    } else {
        fPageData.put(UsbdmConstants.BUILD_TOOLS_BIN_PATH_KEY, "${" + toolInfo.getPathVariableName() + "}");
        fPageData.put(UsbdmConstants.GDB_COMMAND_KEY, "${" + toolInfo.getPrefixVariableName() + "}gdb");
    }
    fPageData.put(UsbdmConstants.BUILD_TOOLS_ID_KEY, buildToolsId);
    fPageData.put(UsbdmConstants.INTERFACE_TYPE_KEY, fInterfaceType.name());
    Device device = getDevice();
    if (device == null) {
        return;
    }
    addDeviceAttributes(fPageData, device);
    // Add launch parameters from device information
    LaunchParameterUtilities.addLaunchParameters(fPageData, device, null);
// System.err.println("UsbdmProjectParametersPage_2.updatePageData() - exit");
}
Also used : ToolInformationData(net.sourceforge.usbdm.constants.ToolInformationData) Device(net.sourceforge.usbdm.deviceDatabase.Device)

Example 2 with Device

use of net.sourceforge.usbdm.deviceDatabase.Device in project usbdm-eclipse-plugins by podonoghue.

the class DeviceSelectorPanel method buildTreeModel.

/**
 * Build the model representing the device choices
 * @param pm
 *
 * @return
 * @throws InterruptedException
 */
void buildTreeModel(IProgressMonitor pm, BaseModel root) throws InterruptedException {
    fDeviceName = null;
    if ((fDeviceDatabase == null) || (fDeviceDatabase.getTargetType() != fTargetType)) {
        fDeviceDatabase = new DeviceDatabase(fTargetType);
    }
    if (!fDeviceDatabase.isValid()) {
        fDeviceText.setText("<Device database invalid>");
        return;
    }
    String currentFamily = null;
    BaseModel familyTree = null;
    String currentSubFamily = null;
    BaseModel subFamilyTree = null;
    for (Device device : fDeviceDatabase.getDeviceList()) {
        IProgressMonitor sub = new SubProgressMonitor(pm, 1);
        try {
            if (device.isHidden()) {
                continue;
            }
            String family = getFamilyName(device.getName());
            if ((familyTree == null) || (currentFamily == null) || !currentFamily.equalsIgnoreCase(family)) {
                familyTree = findCategoryNode(root, family);
            }
            if (familyTree == null) {
                currentFamily = family;
                familyTree = new CategoryModel(root, family);
                currentSubFamily = null;
                subFamilyTree = null;
            }
            String subFamily = getSubFamilyNamePrefix(device.getName());
            if ((subFamilyTree == null) || (currentSubFamily == null) || (!currentSubFamily.equalsIgnoreCase(subFamily))) {
                subFamilyTree = findCategoryNode(familyTree, subFamily);
            }
            if (subFamilyTree == null) {
                currentSubFamily = subFamily;
                subFamilyTree = new CategoryModel(familyTree, currentSubFamily);
            }
            if (device.getName().equalsIgnoreCase(currentSubFamily)) {
                continue;
            }
            new DeviceModel(subFamilyTree, device.getName());
            if (pm.isCanceled()) {
                throw new InterruptedException();
            }
        } finally {
            sub.done();
        }
    }
}
Also used : IProgressMonitor(org.eclipse.core.runtime.IProgressMonitor) DeviceDatabase(net.sourceforge.usbdm.deviceDatabase.DeviceDatabase) Device(net.sourceforge.usbdm.deviceDatabase.Device) SubProgressMonitor(org.eclipse.core.runtime.SubProgressMonitor)

Example 3 with Device

use of net.sourceforge.usbdm.deviceDatabase.Device in project usbdm-eclipse-plugins by podonoghue.

the class KSDKLibraryImportWizard method run.

@Override
public void run(IProgressMonitor progressMonitor) throws InvocationTargetException, InterruptedException {
    System.err.println("KSDKLibraryImportWizard.run()");
    SubMonitor monitor = SubMonitor.convert(progressMonitor);
    monitor.beginTask("Importing KDS Library", 100);
    Map<String, String> paramMap = new HashMap<String, String>();
    try {
        kdsLibraryImportWizardPage.getPageData(paramMap);
        Device device = getDevice(paramMap.get(UsbdmConstants.TARGET_DEVICE_KEY));
        if (device == null) {
            throw new Exception("Failed to obtain device description for " + paramMap.get(UsbdmConstants.TARGET_DEVICE_KEY));
        }
        // Add device options
        ProjectActionList deviceActionList = device.getProjectActionList(paramMap);
        // UsbdmOptionsPanel.getPageData(paramMap, deviceActionLists);
        listParamMap("KSDKLibraryImportWizard.run() - paramMap =================================", paramMap);
        // Create project
        System.err.println("KSDKLibraryImportWizard.run() - Creating project");
        IProject project = new CDTProjectManager().createUSBDMProject(paramMap, monitor.newChild(30));
        // Apply default device project options
        System.err.println("KSDKLibraryImportWizard.run() - Applying deviceActionLists");
        ProcessProjectActions.process(this, project, device, deviceActionList, paramMap, monitor.newChild(30));
        // Apply Library options
        System.err.println("KSDKLibraryImportWizard.run() - Getting libraryActionList");
        ProjectActionList libraryActionList = kdsLibraryImportWizardPage.getProjectActionList();
        System.err.println("KSDKLibraryImportWizard.run() - Applying libraryActionList");
        ProcessProjectActions.process(this, project, device, libraryActionList, paramMap, monitor.newChild(30));
        updateConfigurations(project, monitor.newChild(10));
    } catch (Exception e) {
        e.printStackTrace();
        throw new InvocationTargetException(e);
    } finally {
        monitor.done();
    }
}
Also used : HashMap(java.util.HashMap) Device(net.sourceforge.usbdm.deviceDatabase.Device) SubMonitor(org.eclipse.core.runtime.SubMonitor) CDTProjectManager(net.sourceforge.usbdm.cdt.ui.newProjectWizard.CDTProjectManager) ProjectActionList(net.sourceforge.usbdm.packageParser.ProjectActionList) InvocationTargetException(java.lang.reflect.InvocationTargetException) IProject(org.eclipse.core.resources.IProject) InvocationTargetException(java.lang.reflect.InvocationTargetException)

Example 4 with Device

use of net.sourceforge.usbdm.deviceDatabase.Device in project usbdm-eclipse-plugins by podonoghue.

the class LaunchParameterUtilities method createLaunchConfig.

/**
 * Creates a launch configuration as a physical file<br>
 * It attempts to deduce the device name from project files and asks the user to select/confirm the device choice.
 *
 * @param shell   Shell for dialogues
 * @param project Project to create launch configuration within
 * @param bin Path to binary
 * @param build   String describing build e.g. debug or release. Used in naming launch configuration
 *
 * @return A launch configuration
 * @throws Exception
 */
public static ILaunchConfiguration createLaunchConfig(final Shell shell, final IProject project, IBinary bin) throws Exception {
    IPath binPath = bin.getResource().getProjectRelativePath();
    String buildName = "Default";
    if (binPath.segmentCount() >= 2) {
        // Use containing folder as build name
        buildName = binPath.segment(binPath.segmentCount() - 2);
    }
    // Directories to create launch configuration in (order of preference)
    String[] folders = { "Project_Settings/Debugger", "Project_Settings" };
    IContainer folder = null;
    for (String trialFolder : folders) {
        IFolder t = project.getFolder(trialFolder);
        if (t.exists()) {
            folder = t;
            break;
        }
    }
    if (folder == null) {
        // System.err.println("'Project_Settings folder' doesn't exist, creating launch config in root directory");
        folder = project;
    }
    // Create launch file name e.g. project_debug_USBDM.launch
    IFile launchFile = folder.getFile(new Path(project.getName() + "_" + buildName + "_USBDM.launch"));
    if (launchFile.exists()) {
        // System.err.println("File " + launchFile + " already exists");
        throw new Exception("Launch configuration \n\"" + launchFile.getName() + "\"\nalready exists");
    }
    // Try to get device name from existing project files
    String deviceName = scrapeDeviceName(project);
    // Ask user to select/confirm device
    DeviceSelector deviceSelector = new DeviceSelector(shell, TargetType.T_ARM, deviceName);
    int rc = deviceSelector.open();
    if (rc != Window.OK) {
        return null;
    }
    Device device = deviceSelector.getDevice();
    // Map used to hold variable for launch file creation
    Map<String, String> variableMap = new HashMap<String, String>();
    // Add device name to project creation map
    variableMap.put(UsbdmConstants.PROJECT_NAME_KEY, project.getName());
    // Add launch parameters from device information
    LaunchParameterUtilities.addLaunchParameters(variableMap, device, binPath);
    // Create launch file and let the system know about it
    InputStream contents = getLaunchFile(variableMap);
    launchFile.create(contents, true, null);
    launchFile.refreshLocal(IResource.DEPTH_ONE, null);
    project.refreshLocal(IResource.DEPTH_INFINITE, null);
    // Return the launch configuration
    return DebugPlugin.getDefault().getLaunchManager().getLaunchConfiguration(launchFile);
}
Also used : IPath(org.eclipse.core.runtime.IPath) Path(org.eclipse.core.runtime.Path) IFile(org.eclipse.core.resources.IFile) IPath(org.eclipse.core.runtime.IPath) DeviceSelector(net.sourceforge.usbdm.deviceDatabase.ui.DeviceSelector) HashMap(java.util.HashMap) Device(net.sourceforge.usbdm.deviceDatabase.Device) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) IOException(java.io.IOException) CModelException(org.eclipse.cdt.core.model.CModelException) IContainer(org.eclipse.core.resources.IContainer) IFolder(org.eclipse.core.resources.IFolder)

Example 5 with Device

use of net.sourceforge.usbdm.deviceDatabase.Device in project usbdm-eclipse-plugins by podonoghue.

the class UsbdmDynamicOptionPage_N method main.

// @Override
// public boolean canFlipToNextPage() {
// return isPageComplete();
// }
/**
 * Test main
 *
 * @param args
 * @throws Exception
 */
public static void main(String[] args) throws Exception {
    Display display = new Display();
    Shell shell = new Shell(display);
    shell.setText("Packages Available");
    shell.setLayout(new FillLayout());
    Composite composite = new Composite(shell, SWT.NONE);
    composite.setLayout(new FillLayout());
    String deviceName = "FRDM_K22F";
    // String deviceName = "FRDM_KL27Z";
    // String deviceName = "MKL27Z64M4";
    Map<String, String> paramMap = new HashMap<String, String>();
    paramMap.put("linkerFlashSize", "0x100");
    paramMap.put("linkerRamSize", "0x100");
    paramMap.put("outputType", "xxxxxProjectType.exe");
    paramMap.put("targetDevice", deviceName);
    // UsbdmDynamicOptionPage_N page = new UsbdmDynamicOptionPage_N(deviceName, paramMap, "usbdm-project-options-page");
    // UsbdmDynamicOptionPage_N page = new UsbdmDynamicOptionPage_N(deviceName, paramMap, "kinetis-CPP-abstraction-options-page");
    WizardPageInformation wizardPageInfo = new WizardPageInformation("kinetis-sdk-options-page", "Kinetis", "Kinetis description");
    DeviceDatabase deviceDatabase = new DeviceDatabase(TargetType.T_ARM);
    Device device = deviceDatabase.getDevice(deviceName);
    ProjectActionList projectActionList = device.getProjectActionList(paramMap);
    UsbdmDynamicOptionPage_N page = new UsbdmDynamicOptionPage_N(device, projectActionList, wizardPageInfo);
    page.createControl(composite);
    shell.open();
    while (!shell.isDisposed()) {
        if (!display.readAndDispatch())
            display.sleep();
    }
    page.getPageData(paramMap);
    display.dispose();
}
Also used : Shell(org.eclipse.swt.widgets.Shell) Composite(org.eclipse.swt.widgets.Composite) HashMap(java.util.HashMap) DeviceDatabase(net.sourceforge.usbdm.deviceDatabase.DeviceDatabase) Device(net.sourceforge.usbdm.deviceDatabase.Device) ProjectActionList(net.sourceforge.usbdm.packageParser.ProjectActionList) FillLayout(org.eclipse.swt.layout.FillLayout) Display(org.eclipse.swt.widgets.Display) WizardPageInformation(net.sourceforge.usbdm.packageParser.WizardPageInformation)

Aggregations

Device (net.sourceforge.usbdm.deviceDatabase.Device)6 HashMap (java.util.HashMap)3 DeviceDatabase (net.sourceforge.usbdm.deviceDatabase.DeviceDatabase)2 DeviceSelector (net.sourceforge.usbdm.deviceDatabase.ui.DeviceSelector)2 ProjectActionList (net.sourceforge.usbdm.packageParser.ProjectActionList)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 InvocationTargetException (java.lang.reflect.InvocationTargetException)1 CDTProjectManager (net.sourceforge.usbdm.cdt.ui.newProjectWizard.CDTProjectManager)1 ToolInformationData (net.sourceforge.usbdm.constants.ToolInformationData)1 InterfaceType (net.sourceforge.usbdm.constants.UsbdmSharedConstants.InterfaceType)1 WizardPageInformation (net.sourceforge.usbdm.packageParser.WizardPageInformation)1 CModelException (org.eclipse.cdt.core.model.CModelException)1 IContainer (org.eclipse.core.resources.IContainer)1 IFile (org.eclipse.core.resources.IFile)1 IFolder (org.eclipse.core.resources.IFolder)1 IProject (org.eclipse.core.resources.IProject)1 IPath (org.eclipse.core.runtime.IPath)1 IProgressMonitor (org.eclipse.core.runtime.IProgressMonitor)1