OpenASIP 2.2
Loading...
Searching...
No Matches
MachineTestReporter.cc
Go to the documentation of this file.
1/*
2 Copyright (c) 2002-2009 Tampere University.
3
4 This file is part of TTA-Based Codesign Environment (TCE).
5
6 Permission is hereby granted, free of charge, to any person obtaining a
7 copy of this software and associated documentation files (the "Software"),
8 to deal in the Software without restriction, including without limitation
9 the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 and/or sell copies of the Software, and to permit persons to whom the
11 Software is furnished to do so, subject to the following conditions:
12
13 The above copyright notice and this permission notice shall be included in
14 all copies or substantial portions of the Software.
15
16 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
20 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
21 FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
22 DEALINGS IN THE SOFTWARE.
23 */
24/**
25 * @file MachineTestReporter.cc
26 *
27 * Implementation of MachineTestReporter class.
28 *
29 * @author Lasse Laasonen 2004 (lasse.laasonen-no.spam-tut.fi)
30 */
31
34#include "MachineTester.hh"
35#include "Bus.hh"
36#include "Segment.hh"
37#include "Port.hh"
38#include "Application.hh"
39
40using std::string;
41using boost::format;
42using namespace TTAMachine;
43
44/**
45 * Generates a general error message of the error that occurred when tried
46 * to attach a socket to a segment.
47 *
48 * @param socket The socket that was tried to be connected.
49 * @param segment The segment to which the socket was tried to be connected.
50 * @param tester MachineTester that was used to check if the connection can
51 * be made.
52 * @return An error message.
53 */
54string
56 const Socket& socket,
57 const Segment& segment,
58 const MachineTester& tester) {
59
61
62// Bus* sameChainConnection = tester.sameChainConnection();
63// if (sameChainConnection != NULL) {
64// format text = textGenerator.text(MachineTestReportTextGenerator::
65// TXT_SOCKET_SEGMENT_CONN_SAME_CHAIN);
66// text % socket.name() % segment.name() % segment.parentBus()->name() %
67// sameChainConnection->name();
68// return text.str();
69// }
70
71 if (tester.connectionExists()) {
72 format text = textGenerator.text(MachineTestReportTextGenerator::
73 TXT_SOCKET_SEGMENT_CONN_EXISTS);
74 text % socket.name() % segment.name() % segment.parentBus()->name();
75 return text.str();
76 }
77
78 if (tester.illegalRegistration()) {
79 format text = textGenerator.text(MachineTestReportTextGenerator::
80 TXT_SOCKET_SEGMENT_CONN_ILLEGAL_REG);
81 text % socket.name() % segment.parentBus()->name();
82 return text.str();
83 }
84
85// Bus* straddlingBus = tester.straddlingBus();
86// if (straddlingBus != NULL) {
87// format text = textGenerator.text(
88// MachineTestReportTextGenerator::
89// TXT_SOCKET_SEGMENT_CONN_STRADDLING_BUS);
90// text % socket.name() % segment.name() % segment.parentBus()->name() %
91// straddlingBus->name();
92// return text.str();
93// }
94
95// Socket* crossingSocket = tester.crossingSocket(socket);
96// if (crossingSocket != NULL) {
97// format text = textGenerator.text(MachineTestReportTextGenerator::
98// TXT_SOCKET_SEGMENT_CONN_CROSSING);
99// text % socket.name() % segment.name() % segment.parentBus()->name() %
100// crossingSocket->name();
101// return text.str();
102// }
103
104// Unit* straddlingUnit = tester.straddlingUnit();
105// if (straddlingUnit != NULL) {
106// format text = textGenerator.text(
107// MachineTestReportTextGenerator::
108// TXT_SOCKET_SEGMENT_CONN_STRADDLING_UNIT);
109// text % socket.name() % segment.name() % segment.parentBus()->name() %
110// straddlingUnit->name();
111// return text.str();
112// }
113
114 Port* doubleInputConn = tester.sameDirSocketConnection(Socket::INPUT);
115 Port* doubleOutputConn = tester.sameDirSocketConnection(Socket::OUTPUT);
116 Port* forbiddenInputConn =
118 Port* forbiddenOutputConn =
120 if (doubleInputConn != NULL || forbiddenInputConn != NULL) {
121 assert(doubleOutputConn != NULL || forbiddenOutputConn != NULL);
122 format text = textGenerator.text(
124 TXT_SOCKET_SEGMENT_CONN_BOTH_DIRS_ARE_ILLEGAL);
125 Port* errInputPort = doubleInputConn != NULL ? doubleInputConn :
126 forbiddenInputConn;
127 Port* errOutputPort = doubleOutputConn != NULL ? doubleOutputConn :
128 forbiddenOutputConn;
129 text % socket.name() % errInputPort->name() %
130 errInputPort->parentUnit()->name() % errOutputPort->name() %
131 errOutputPort->parentUnit()->name();
132 return text.str();
133 }
134
135 return "";
136}
137
138
139/**
140 * Generates a general error message of the error that occurred when tried
141 * to attach a socket to a port.
142 *
143 * @param socket The socket that was tried to be connected.
144 * @param port The port to which the socket was tried to be connected.
145 * @param tester MachineTester that was used to check if the connection can
146 * be made.
147 * @return An error message.
148 */
149string
151 const Socket& socket,
152 const Port& port,
153 const MachineTester& tester) {
154
155 MachineTestReportTextGenerator textGenerator;
156
157 if (tester.illegalRegistration()) {
158 format text = textGenerator.text(MachineTestReportTextGenerator::
159 TXT_SOCKET_PORT_CONN_ILLEGAL_REG);
160 text % socket.name() % port.parentUnit()->name();
161 return text.str();
162 }
163
164 if (tester.connectionExists()) {
165 format text = textGenerator.text(MachineTestReportTextGenerator::
166 TXT_SOCKET_PORT_CONN_EXISTS);
167 text % socket.name() % port.name() % port.parentUnit()->name();
168 return text.str();
169 }
170
171 if (tester.wrongSocketDirection()) {
172 format text = textGenerator.text(
174 TXT_SOCKET_PORT_CONN_WRONG_SOCKET_DIR);
175 text % socket.name() % port.name() % port.parentUnit()->name();
176 return text.str();
177 }
178
179 if (tester.maxConnections()) {
180 format text = textGenerator.text(MachineTestReportTextGenerator::
181 TXT_SOCKET_PORT_CONN_MAX_CONN);
182 text % socket.name() % port.name() % port.parentUnit()->name();
183 return text.str();
184 }
185
186// Socket* straddlingUnitConn = tester.straddlingUnitConnection();
187// if (straddlingUnitConn != NULL) {
188// format text = textGenerator.text(
189// MachineTestReportTextGenerator::
190// TXT_SOCKET_PORT_CONN_STRADDLING_UNIT);
191// text % socket.name() % port.name() % port.parentUnit()->name() %
192// straddlingUnitConn->name();
193// return text.str();
194// }
195
197 format text = textGenerator.text(
199 TXT_SOCKET_PORT_CONN_RF_PORT_CONN_EXISTS);
200 text % socket.name() % port.name() % port.parentUnit()->name();
201 return text.str();
202 }
203
204 return "";
205}
206
207
208/**
209 * Generates a general error message of the error that occurred when tried
210 * to bridge the given buses.
211 *
212 * @param sourceBus The source bus.
213 * @param destinationBus The destination bus.
214 * @param tester MachineTester that was used to check if the buses can be
215 * joined by a bridge.
216 * @return An error message.
217 */
218string
220 const Bus& sourceBus,
221 const Bus& destinationBus,
222 const MachineTester& tester) {
223
224 MachineTestReportTextGenerator textGenerator;
225 if (tester.illegalRegistration()) {
226 format text = textGenerator.text(MachineTestReportTextGenerator::
227 TXT_BRIDGE_ILLEGAL_REG);
228 text % sourceBus.name() % destinationBus.name();
229 return text.str();
230 }
231 if (tester.loop()) {
232 format text = textGenerator.text(MachineTestReportTextGenerator::
233 TXT_BRIDGE_LOOP);
234 text % sourceBus.name() % destinationBus.name();
235 return text.str();
236 }
237 if (tester.connectionExists()) {
238 format text = textGenerator.text(MachineTestReportTextGenerator::
239 TXT_BRIDGE_EXISTS);
240 text % sourceBus.name() % destinationBus.name();
241 return text.str();
242 }
243// Bus* straddlingBus = tester.straddlingBus();
244// if (straddlingBus != NULL) {
245// format text = textGenerator.text(MachineTestReportTextGenerator::
246// TXT_BRIDGE_STRADDLING_BUS);
247// text % sourceBus.name() % destinationBus.name() %
248// straddlingBus->name();
249// return text.str();
250// }
251// Socket* crossing = tester.crossingSocket(0);
252// if (crossing != NULL) {
253// Socket* crossing2 = tester.crossingSocket(1);
254// format text = textGenerator.text(MachineTestReportTextGenerator::
255// TXT_BRIDGE_CROSSING_SOCKET);
256// text % sourceBus.name() % destinationBus.name() % crossing->name() %
257// crossing2->name();
258// return text.str();
259// }
260 Bus* branchedBus = tester.branchedBus();
261 if (branchedBus != NULL) {
262 format text = textGenerator.text(MachineTestReportTextGenerator::
263 TXT_BRIDGE_BRANCHED_BUS);
264 text % sourceBus.name() % destinationBus.name() %
265 branchedBus->name();
266 return text.str();
267 }
268// Socket* bindingSocket = tester.bindingSocket();
269// if (bindingSocket != NULL) {
270// format text = textGenerator.text(MachineTestReportTextGenerator::
271// TXT_BRIDGE_BINDING_SOCKET);
272// text % sourceBus.name() % destinationBus.name() %
273// bindingSocket->name();
274// return text.str();
275// }
276// Unit* straddlingUnit = tester.straddlingUnit();
277// if (straddlingUnit != NULL) {
278// format text = textGenerator.text(MachineTestReportTextGenerator::
279// TXT_BRIDGE_STRADDLING_UNIT);
280// text % sourceBus.name() % destinationBus.name() %
281// straddlingUnit->name();
282// return text.str();
283// }
284
285 return "";
286}
287
288
289/**
290 * Generates a general error message of the reason why the direction of the
291 * given socket can not be set.
292 *
293 * @param socket The socket.
294 * @param direction The direction that was tried to set.
295 * @param tester The MachineTester used to check if the direction can be set.
296 * @return An error message.
297 */
298string
300 const Socket& socket,
301 Socket::Direction direction,
302 const MachineTester& tester) {
303
304 MachineTestReportTextGenerator textGenerator;
305 if (tester.unknownSocketDirection()) {
306 format text = textGenerator.text(MachineTestReportTextGenerator::
307 TXT_SOCKET_DIR_UNKNOWN);
308 text % socket.name();
309 return text.str();
310 }
311 if (tester.noConnections()) {
312 format text = textGenerator.text(MachineTestReportTextGenerator::
313 TXT_SOCKET_NO_CONN);
314 text % socket.name();
315 return text.str();
316 }
317 Port* sameDirConnection = tester.sameDirSocketConnection(direction);
318 if (sameDirConnection != NULL) {
319 format text = textGenerator.text(MachineTestReportTextGenerator::
320 TXT_SOCKET_SAME_DIR_CONN);
321 if (direction == Socket::OUTPUT) {
322 text % socket.name() % "output" % sameDirConnection->name() %
323 sameDirConnection->parentUnit()->name();
324 } else if (direction == Socket::INPUT) {
325 text % socket.name() % "input" % sameDirConnection->name() %
326 sameDirConnection->parentUnit()->name();
327 } else {
328 assert(false);
329 }
330 return text.str();
331 }
332 Port* forbiddenSocketDir = tester.forbiddenSocketDirection(direction);
333 if (forbiddenSocketDir != NULL) {
334 format text = textGenerator.text(MachineTestReportTextGenerator::
335 TXT_SOCKET_FORBIDDEN_DIR);
336 if (direction == Socket::OUTPUT) {
337 text % socket.name() % "output" % forbiddenSocketDir->name() %
338 forbiddenSocketDir->parentUnit()->name();
339 } else if (direction == Socket::INPUT) {
340 text % socket.name() % "input" % forbiddenSocketDir->name() %
341 forbiddenSocketDir->parentUnit()->name();
342 } else {
343 assert(false);
344 }
345 return text.str();
346 }
347 return "";
348}
#define assert(condition)
static std::string socketPortConnectionError(const TTAMachine::Socket &socket, const TTAMachine::Port &port, const MachineTester &tester)
static std::string socketDirectionSettingError(const TTAMachine::Socket &socket, TTAMachine::Socket::Direction, const MachineTester &tester)
static std::string bridgingError(const TTAMachine::Bus &sourceBus, const TTAMachine::Bus &destinationBus, const MachineTester &tester)
static std::string socketSegmentConnectionError(const TTAMachine::Socket &socket, const TTAMachine::Segment &segment, const MachineTester &tester)
TTAMachine::Port * sameDirSocketConnection(TTAMachine::Socket::Direction direction) const
bool illegalRegistration() const
bool wrongSocketDirection() const
bool maxConnections() const
TTAMachine::Bus * branchedBus() const
bool noConnections() const
TTAMachine::Port * forbiddenSocketDirection(TTAMachine::Socket::Direction direction) const
bool registerFilePortAlreadyConnected() const
bool connectionExists() const
bool unknownSocketDirection() const
bool loop() const
virtual TCEString name() const
Unit * parentUnit() const
virtual std::string name() const
Definition Port.cc:141
std::string name() const
Bus * parentBus() const
@ OUTPUT
Data goes from port to bus.
Definition Socket.hh:60
@ INPUT
Data goes from bus to port.
Definition Socket.hh:59
virtual boost::format text(int textId)