Search in sources :

Example 1 with DsfSession

use of org.eclipse.cdt.dsf.service.DsfSession 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 DsfSession

use of org.eclipse.cdt.dsf.service.DsfSession 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 DsfSession

use of org.eclipse.cdt.dsf.service.DsfSession in project usbdm-eclipse-plugins by podonoghue.

the class GdbDsfSessionListener method removeListener.

/**
 * Remove a listener for GDB events
 *
 * @param listener Listener to remove
 */
public void removeListener(GdbSessionListener listener) {
    // System.err.println("removeListener(GdbSessionListener) : " + listener);
    gdbSessionListeners.remove(listener);
    if (gdbSessionListeners.size() == 0) {
        // Last listener removed - remove session hooks
        for (DsfSession dsfSession : DsfSession.getActiveSessions()) {
            dsfSession.removeServiceEventListener(this);
        }
        dsfSessions = null;
        DsfSession.removeSessionStartedListener(this);
        DsfSession.removeSessionEndedListener(this);
    }
}
Also used : DsfSession(org.eclipse.cdt.dsf.service.DsfSession)

Example 4 with DsfSession

use of org.eclipse.cdt.dsf.service.DsfSession 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

DsfSession (org.eclipse.cdt.dsf.service.DsfSession)4 UsbdmDevicePeripheralsModel (net.sourceforge.usbdm.peripherals.model.UsbdmDevicePeripheralsModel)3 SVDIdentifier (net.sourceforge.usbdm.peripheralDatabase.SVDIdentifier)1