blob: 931449b5586dbe4086787cfefe6ff393821eeb69 (
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
|
/*******************************************************************************
* 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 "ActorClassBase.h"
#include "common/modelbase/InterfaceItemBase.h"
#include "common/modelbase/RTSystemServicesProtocol.h"
#include "common/modelbase/SystemPortOwner.h"
#include "etDatatypes.h"
#include <iterator>
#include <string>
#include <vector>
namespace etRuntime {
ActorClassBase::ActorClassBase(IRTObject* parent, const std::string& name) :
SystemPortOwner(parent, name),
m_state(0),
m_RTSystemPort(this, IFITEM_RTSystemPort),
m_className("noname") {
}
ActorClassBase::~ActorClassBase() {
m_state = 0;
}
//SubSystemClassBase* ActorClassBase::getSubSystem() const {
// return 0; // TODO JH
//}
//--------------------- life cycle functions
void ActorClassBase::init() {
ActorClassBase* child = 0;
for (std::vector<IRTObject*>::iterator it = getChildren().begin(); it != getChildren().end(); ++it) {
if ((child = dynamic_cast<ActorClassBase*>(*it)) != 0)
child->init();
}
initUser();
}
void ActorClassBase::start() {
ActorClassBase* child = 0;
for (std::vector<IRTObject*>::iterator it = getChildren().begin(); it != getChildren().end(); ++it) {
if ((child = dynamic_cast<ActorClassBase*>(*it)) != 0)
child->start();
}
startUser();
}
void ActorClassBase::stop() {
stopUser();
ActorClassBase* child = 0;
for (std::vector<IRTObject*>::iterator it = getChildren().begin(); it != getChildren().end(); ++it) {
if ((child = dynamic_cast<ActorClassBase*>(*it)) != 0)
child->stop();
}
}
void ActorClassBase::destroy() {
SystemPortOwner::destroy();
}
etBool ActorClassBase::handleSystemEvent(InterfaceItemBase* ifitem, int evt, void* generic_data) {
if ((ifitem != 0) && (ifitem->getLocalId() != 0)) {
return false;
}
switch (evt) {
case RTSystemServicesProtocol::IN_executeInitialTransition:
executeInitTransition();
break;
case RTSystemServicesProtocol::IN_startDebugging:
break;
case RTSystemServicesProtocol::IN_stopDebugging:
break;
default:
return false;
}
return true;
}
std::string ActorClassBase::toString() const {
ActorClassBase* thisPtr = const_cast<ActorClassBase*>(this);
char buffer[10];
sprintf(buffer, "%i", thisPtr->getThread());
return getName() + " : " + getClassName() + " thread:" + buffer;
}
} /* namespace etRuntime */
|