Search in sources :

Example 1 with UsbdmDevicePeripheralsModel

use of net.sourceforge.usbdm.peripherals.model.UsbdmDevicePeripheralsModel in project usbdm-eclipse-plugins by podonoghue.

the class GdbDsfSessionListener method addExistingSessions.

/**
 * Adds existing sessions
 */
void addExistingSessions() {
    // Add any existing sessions
    dsfSessions = new HashMap<String, UsbdmDevicePeripheralsModel>();
    for (DsfSession dsfSession : DsfSession.getActiveSessions()) {
        addSession(dsfSession.getId());
        sessionStarted(dsfSession);
    }
}
Also used : UsbdmDevicePeripheralsModel(net.sourceforge.usbdm.peripherals.model.UsbdmDevicePeripheralsModel) DsfSession(org.eclipse.cdt.dsf.service.DsfSession)

Example 2 with UsbdmDevicePeripheralsModel

use of net.sourceforge.usbdm.peripherals.model.UsbdmDevicePeripheralsModel in project usbdm-eclipse-plugins by podonoghue.

the class GdbDsfSessionListener method addListener.

/**
 * Add a listener for GDB events
 *
 * @param listener
 */
public void addListener(final GdbSessionListener listener) {
    gdbSessionListeners.add(listener);
    if (gdbSessionListeners.size() == 1) {
        // First listener - add session hooks
        // System.err.println("addListener(GdbSessionListener) : adding session listeners");
        addExistingSessions();
        DsfSession.addSessionStartedListener(GdbDsfSessionListener.this);
        DsfSession.addSessionEndedListener(GdbDsfSessionListener.this);
    }
    // Notify of any existing sessions
    for (DsfSession dsfSession : DsfSession.getActiveSessions()) {
        UsbdmDevicePeripheralsModel model = dsfSessions.get(dsfSession.getId());
        listener.sessionStarted(model);
    }
}
Also used : UsbdmDevicePeripheralsModel(net.sourceforge.usbdm.peripherals.model.UsbdmDevicePeripheralsModel) DsfSession(org.eclipse.cdt.dsf.service.DsfSession)

Example 3 with UsbdmDevicePeripheralsModel

use of net.sourceforge.usbdm.peripherals.model.UsbdmDevicePeripheralsModel in project usbdm-eclipse-plugins by podonoghue.

the class GdbDsfSessionListener method sessionEnded.

/*
    * (non-Javadoc)
    * @see org.eclipse.cdt.dsf.service.DsfSession.SessionEndedListener#sessionEnded(org.eclipse.cdt.dsf.service.DsfSession)
    */
@Override
public void sessionEnded(DsfSession dsfSession) {
    // System.err.println("sessionEnded(DsfSession) : ID = " + dsfSession.getId());
    dsfSession.removeServiceEventListener(this);
    // Should have been done by handleDsfEvent(ISuspendedDMEvent event)
    UsbdmDevicePeripheralsModel deviceModel = dsfSessions.get(dsfSession.getId());
    if (deviceModel != null) {
        for (GdbSessionListener sessionListener : gdbSessionListeners) {
            sessionListener.sessionTerminated(deviceModel);
        }
    }
    dsfSessions.remove(dsfSession.getId());
}
Also used : UsbdmDevicePeripheralsModel(net.sourceforge.usbdm.peripherals.model.UsbdmDevicePeripheralsModel)

Example 4 with UsbdmDevicePeripheralsModel

use of net.sourceforge.usbdm.peripherals.model.UsbdmDevicePeripheralsModel in project usbdm-eclipse-plugins by podonoghue.

the class GdbDsfSessionListener method handleDsfEvent.

/**
 */
@DsfServiceEventHandler
public void handleDsfEvent(IExitedDMEvent event) {
    String sessionId = event.getDMContext().getSessionId();
    // System.err.println(String.format("handleDsfEvent(IExitedDMEvent, s=%s, r=%s)", sessionId, event.toString()));
    UsbdmDevicePeripheralsModel deviceModel = dsfSessions.get(sessionId);
    if (deviceModel != null) {
        for (GdbSessionListener sessionListener : gdbSessionListeners) {
            sessionListener.sessionTerminated(deviceModel);
        }
    }
}
Also used : UsbdmDevicePeripheralsModel(net.sourceforge.usbdm.peripherals.model.UsbdmDevicePeripheralsModel) DsfServiceEventHandler(org.eclipse.cdt.dsf.service.DsfServiceEventHandler)

Example 5 with UsbdmDevicePeripheralsModel

use of net.sourceforge.usbdm.peripherals.model.UsbdmDevicePeripheralsModel in project usbdm-eclipse-plugins by podonoghue.

the class GdbDsfSessionListener method addSession.

/*
    * ========================================================
    *  DSF Session handling
    * ========================================================
    */
/**
 * Adds a session and associated model to dsfSessions
 *
 * @param sessionId DSF Session id used to track session
 *
 * @return true => new session was added,
 *     <br>false => session already exists
 *
 * @note This can be time consuming as model is loaded from disk
 */
private boolean addSession(String sessionId) {
    if (!dsfSessions.containsKey(sessionId)) {
        // New session
        DsfSession dsfSession = DsfSession.getSession(sessionId);
        String deviceName = getDeviceName(dsfSession);
        // System.err.println("GdbDsfSessionListener.addSession(), deviceName="+deviceName);
        SVDIdentifier svdId = new SVDIdentifier(UsbdmPeripheralDescriptionProvider.ID, deviceName);
        // System.err.println("GdbDsfSessionListener.addSession(), svdId="+svdId);
        UsbdmDevicePeripheralsModel peripheralModel = UsbdmDevicePeripheralsModel.createModel(new GdbDsfInterface(dsfSession), svdId);
        dsfSessions.put(sessionId, peripheralModel);
        return true;
    }
    return false;
}
Also used : UsbdmDevicePeripheralsModel(net.sourceforge.usbdm.peripherals.model.UsbdmDevicePeripheralsModel) SVDIdentifier(net.sourceforge.usbdm.peripheralDatabase.SVDIdentifier) DsfSession(org.eclipse.cdt.dsf.service.DsfSession)

Aggregations

UsbdmDevicePeripheralsModel (net.sourceforge.usbdm.peripherals.model.UsbdmDevicePeripheralsModel)8 SVDIdentifier (net.sourceforge.usbdm.peripheralDatabase.SVDIdentifier)3 DsfSession (org.eclipse.cdt.dsf.service.DsfSession)3 DsfServiceEventHandler (org.eclipse.cdt.dsf.service.DsfServiceEventHandler)2 FillLayout (org.eclipse.swt.layout.FillLayout)2 Display (org.eclipse.swt.widgets.Display)2 Shell (org.eclipse.swt.widgets.Shell)2 Path (java.nio.file.Path)1 DevicePeripherals (net.sourceforge.usbdm.peripheralDatabase.DevicePeripherals)1 DeviceModel (net.sourceforge.usbdm.peripherals.model.DeviceModel)1 DevicePeripheralSelectionDialogue (net.sourceforge.usbdm.peripherals.view.DevicePeripheralSelectionDialogue)1 UsbdmDevicePeripheralsView (net.sourceforge.usbdm.peripherals.view.UsbdmDevicePeripheralsView)1 Color (org.eclipse.swt.graphics.Color)1 Composite (org.eclipse.swt.widgets.Composite)1