Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 7216a1640cb3b01b5d0a60de4b35ee8123d9eb40 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
/*******************************************************************************
 * Copyright (c) 2012 Draeger Medical GmbH (http://www.draeger.com).
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution, and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 *
 * CONTRIBUTORS:
 * 		Peter Karlitschek (initial contribution)
 *
 *******************************************************************************/

#include "DebuggingService.h"

#include "common/modelbase/ActorClassBase.h"
#include "common/modelbase/SubSystemClassBase.h"
#include "common/modelbase/InterfaceItemBase.h"

namespace etRuntime {

DebuggingService& DebuggingService::getInstance() {
	static DebuggingService instance;

	return instance;
}

DebuggingService::DebuggingService() :
		m_asyncLogger(),
		m_syncLogger(),
		m_portInstances() {
}

const InterfaceItemBase* DebuggingService::getPort(const Address& address) const {
	Map<Address, const InterfaceItemBase*>::const_iterator it = m_portInstances.find(address);
	if (it != m_portInstances.end())
		return it->second;

	return 0;
}

void DebuggingService::addMessageAsyncOut(const Address& source, const Address& target, const String& msg) {
	const InterfaceItemBase* srcPort = getPort(source);
	const InterfaceItemBase* tgtPort = getPort(target);
	if (srcPort != 0 && tgtPort != 0) {
		etRuntime::String srcPath = srcPort->getActor()->getInstancePath();
		etRuntime::String tgtPath = tgtPort->getActor()->getInstancePath();
		m_asyncLogger.addMessageAsyncOut(srcPath, tgtPath, msg);
	}

}

void DebuggingService::addMessageAsyncIn(const Address& source, const Address& target, const String& msg) {
	const InterfaceItemBase* srcPort = getPort(source);
	const InterfaceItemBase* tgtPort = getPort(target);
	if (srcPort != 0 && tgtPort != 0) {
		etRuntime::String srcPath = srcPort->getActor()->getInstancePath();
		etRuntime::String tgtPath = tgtPort->getActor()->getInstancePath();
		m_asyncLogger.addMessageAsyncIn(srcPath, tgtPath, msg);
	}
}

void DebuggingService::addMessageSyncCall(const Address& source, const Address& target, const String& msg) {
	const InterfaceItemBase* srcPort = getPort(source);
	const InterfaceItemBase* tgtPort = getPort(target);
	if (srcPort != 0 && tgtPort != 0) {
		etRuntime::String srcPath = srcPort->getActor()->getInstancePath();
		etRuntime::String tgtPath = tgtPort->getActor()->getInstancePath();
		m_asyncLogger.addMessageSyncCall(srcPath, tgtPath, msg);
	}
}

void DebuggingService::addMessageSyncReturn(const Address& source, const Address& target, const String& msg) {
	const InterfaceItemBase* srcPort = getPort(source);
	const InterfaceItemBase* tgtPort = getPort(target);
	if (srcPort != 0 && tgtPort != 0) {
		m_asyncLogger.addMessageSyncReturn(srcPort->getActor()->getInstancePath(),
				tgtPort->getActor()->getInstancePath(), msg);
	}
}

void DebuggingService::addActorState(const ActorClassBase& actor, const String& state) {
	etRuntime::String instancePath = actor.getInstancePath();
	m_asyncLogger.addActorState(instancePath, state);
}

void DebuggingService::addMessageActorCreate(const SubSystemClassBase& parent, const String& refName) {
	etRuntime::String parentPath = parent.getInstancePath();
	m_asyncLogger.addMessageActorCreate(parentPath, String(parentPath) + IRTObject::PATH_DELIM + refName);
}

void DebuggingService::addMessageActorCreate(const ActorClassBase& parent, const String& refName) {
	etRuntime::String parentPath = parent.getInstancePath();
	m_asyncLogger.addMessageActorCreate(parentPath, String(parentPath) + IRTObject::PATH_DELIM + refName);
}

void DebuggingService::addMessageActorDestroy(const ActorClassBase& inst) {
	etRuntime::String parentPath = inst.getParent()->getInstancePath();
	etRuntime::String instancePath = inst.getInstancePath();
	//if (!(inst.getParent() instanceof OptionalActorInterfaceBase))
	m_asyncLogger.addMessageActorDestroy(parentPath, instancePath);
}

void DebuggingService::addVisibleComment(const String& comment) {
	m_asyncLogger.addVisibleComment(comment);
}

void DebuggingService::addPortInstance(const InterfaceItemBase& port) {
	m_portInstances[port.getAddress()] = &port;
}

void DebuggingService::removePortInstance(const InterfaceItemBase& port) {
	m_portInstances.erase(port.getAddress());
}

} /* namespace etRuntime */

Back to the top