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