OpenASIP  2.0
Static Public Member Functions | List of all members
MachineTestReporter Class Reference

#include <MachineTestReporter.hh>

Collaboration diagram for MachineTestReporter:
Collaboration graph

Static Public Member Functions

static std::string socketSegmentConnectionError (const TTAMachine::Socket &socket, const TTAMachine::Segment &segment, const MachineTester &tester)
 
static std::string socketPortConnectionError (const TTAMachine::Socket &socket, const TTAMachine::Port &port, const MachineTester &tester)
 
static std::string bridgingError (const TTAMachine::Bus &sourceBus, const TTAMachine::Bus &destinationBus, const MachineTester &tester)
 
static std::string socketDirectionSettingError (const TTAMachine::Socket &socket, TTAMachine::Socket::Direction, const MachineTester &tester)
 

Detailed Description

Creates string error messages according to the error stated by MachineTester.

Definition at line 45 of file MachineTestReporter.hh.

Member Function Documentation

◆ bridgingError()

string MachineTestReporter::bridgingError ( const TTAMachine::Bus sourceBus,
const TTAMachine::Bus destinationBus,
const MachineTester tester 
)
static

Generates a general error message of the error that occurred when tried to bridge the given buses.

Parameters
sourceBusThe source bus.
destinationBusThe destination bus.
testerMachineTester that was used to check if the buses can be joined by a bridge.
Returns
An error message.

Definition at line 219 of file MachineTestReporter.cc.

222  {
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 }

References MachineTester::branchedBus(), MachineTester::connectionExists(), MachineTester::illegalRegistration(), MachineTester::loop(), TTAMachine::Component::name(), and Texts::TextGenerator::text().

Referenced by TTAMachine::Bridge::Bridge(), and TTAMachine::Bridge::loadState().

Here is the call graph for this function:

◆ socketDirectionSettingError()

string MachineTestReporter::socketDirectionSettingError ( const TTAMachine::Socket socket,
TTAMachine::Socket::Direction  direction,
const MachineTester tester 
)
static

Generates a general error message of the reason why the direction of the given socket can not be set.

Parameters
socketThe socket.
directionThe direction that was tried to set.
testerThe MachineTester used to check if the direction can be set.
Returns
An error message.

Definition at line 299 of file MachineTestReporter.cc.

302  {
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 }

References assert, MachineTester::forbiddenSocketDirection(), TTAMachine::Socket::INPUT, TTAMachine::Port::name(), TTAMachine::Component::name(), MachineTester::noConnections(), TTAMachine::Socket::OUTPUT, TTAMachine::Port::parentUnit(), MachineTester::sameDirSocketConnection(), Texts::TextGenerator::text(), and MachineTester::unknownSocketDirection().

Referenced by SocketDialog::onDirection(), and TTAMachine::Socket::setDirection().

Here is the call graph for this function:

◆ socketPortConnectionError()

string MachineTestReporter::socketPortConnectionError ( const TTAMachine::Socket socket,
const TTAMachine::Port port,
const MachineTester tester 
)
static

Generates a general error message of the error that occurred when tried to attach a socket to a port.

Parameters
socketThe socket that was tried to be connected.
portThe port to which the socket was tried to be connected.
testerMachineTester that was used to check if the connection can be made.
Returns
An error message.

Definition at line 150 of file MachineTestReporter.cc.

153  {
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 
196  if (tester.registerFilePortAlreadyConnected()) {
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 }

References MachineTester::connectionExists(), MachineTester::illegalRegistration(), MachineTester::maxConnections(), TTAMachine::Port::name(), TTAMachine::Component::name(), TTAMachine::Port::parentUnit(), MachineTester::registerFilePortAlreadyConnected(), Texts::TextGenerator::text(), and MachineTester::wrongSocketDirection().

Referenced by TTAMachine::Port::attachSocket().

Here is the call graph for this function:

◆ socketSegmentConnectionError()

string MachineTestReporter::socketSegmentConnectionError ( const TTAMachine::Socket socket,
const TTAMachine::Segment segment,
const MachineTester tester 
)
static

Generates a general error message of the error that occurred when tried to attach a socket to a segment.

Parameters
socketThe socket that was tried to be connected.
segmentThe segment to which the socket was tried to be connected.
testerMachineTester that was used to check if the connection can be made.
Returns
An error message.

Definition at line 55 of file MachineTestReporter.cc.

58  {
59 
60  MachineTestReportTextGenerator textGenerator;
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 =
117  tester.forbiddenSocketDirection(Socket::INPUT);
118  Port* forbiddenOutputConn =
119  tester.forbiddenSocketDirection(Socket::OUTPUT);
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 }

References assert, MachineTester::connectionExists(), MachineTester::forbiddenSocketDirection(), MachineTester::illegalRegistration(), TTAMachine::Socket::INPUT, TTAMachine::Port::name(), TTAMachine::Segment::name(), TTAMachine::Component::name(), TTAMachine::Socket::OUTPUT, TTAMachine::Segment::parentBus(), TTAMachine::Port::parentUnit(), MachineTester::sameDirSocketConnection(), and Texts::TextGenerator::text().

Referenced by TTAMachine::Socket::attachBus(), TTAMachine::Segment::attachSocket(), and SocketDialog::onAttach().

Here is the call graph for this function:

The documentation for this class was generated from the following files:
TTAMachine::Component::name
virtual TCEString name() const
Definition: MachinePart.cc:125
MachineTester::unknownSocketDirection
bool unknownSocketDirection() const
Definition: MachineTester.cc:424
TTAMachine::Bus
Definition: Bus.hh:53
MachineTester::illegalRegistration
bool illegalRegistration() const
Definition: MachineTester.cc:355
Texts::TextGenerator::text
virtual boost::format text(int textId)
Definition: TextGenerator.cc:94
MachineTester::noConnections
bool noConnections() const
Definition: MachineTester.cc:437
MachineTester::wrongSocketDirection
bool wrongSocketDirection() const
Definition: MachineTester.cc:397
MachineTester::branchedBus
TTAMachine::Bus * branchedBus() const
Definition: MachineTester.cc:380
MachineTester::loop
bool loop() const
Definition: MachineTester.cc:367
assert
#define assert(condition)
Definition: Application.hh:86
TTAMachine::Segment::parentBus
Bus * parentBus() const
TTAMachine::Port
Definition: Port.hh:54
MachineTester::registerFilePortAlreadyConnected
bool registerFilePortAlreadyConnected() const
Definition: MachineTester.cc:488
MachineTester::sameDirSocketConnection
TTAMachine::Port * sameDirSocketConnection(TTAMachine::Socket::Direction direction) const
Definition: MachineTester.cc:451
MachineTester::connectionExists
bool connectionExists() const
Definition: MachineTester.cc:342
MachineTester::forbiddenSocketDirection
TTAMachine::Port * forbiddenSocketDirection(TTAMachine::Socket::Direction direction) const
Definition: MachineTester.cc:471
TTAMachine::Port::name
virtual std::string name() const
Definition: Port.cc:141
MachineTester::maxConnections
bool maxConnections() const
Definition: MachineTester.cc:410
TTAMachine::Segment::name
std::string name() const
MachineTestReportTextGenerator
Definition: MachineTestReportTextGenerator.hh:40
TTAMachine::Port::parentUnit
Unit * parentUnit() const