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);
}
}
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);
}
}
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);
}
}
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;
}
Aggregations