Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 4d51fbaa24bef48ef528586c444873571cefa34f (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
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
/**
 * @author generated by eTrice
 *
 * Source File of SubSystemClass SubSys
 * 
 */

#include "Node1.h"

/* include instances for all classes */
#include "node1_sys1_Inst.h"
#include "node1_sys1_Disp.h"

#include "debugging/etLogger.h"
#include "debugging/etMSCLogger.h"

#include "platform/etTimer.h"
#include "etRuntimeConfig.h"
#include "messaging/etMessageService.h"

/* data for Node1 */
typedef struct Node1 {
	char *name;
	volatile int shutdownRequest;
} Node1;

static Node1 Node1Inst = {"Node1",0};

void node1_sys1_initActorInstances(void);
void node1_sys1_constructActorInstances(void);


void node1_sys1_initMessageServices(void){
	ET_MSC_LOGGER_SYNC_ENTRY("Node1", "initMessageServices")

	/* filling all message service threads with data */
	/*PhysicalThread1*/
	// TODO: gen
	msgService_PhysicalThread1.thread.stacksize = 1024;
	msgService_PhysicalThread1.thread.priority = 0;
	msgService_PhysicalThread1.thread.threadName = "PhysicalThread1";
	msgService_PhysicalThread1.thread.threadFunction = (etThreadFunction) etMessageService_execute;
	msgService_PhysicalThread1.thread.threadFunctionData = &msgService_PhysicalThread1;


	/*PhysicalThread2*/
	// TODO: gen
	msgService_PhysicalThread2.thread.stacksize = 1024;
	msgService_PhysicalThread2.thread.priority = 0;
	msgService_PhysicalThread2.thread.threadName = "PhysicalThread2";
	msgService_PhysicalThread2.thread.threadFunction = (etThreadFunction) etMessageService_execute;
	msgService_PhysicalThread2.thread.threadFunctionData = &msgService_PhysicalThread2;
	
	/* initialization of all message services */
	etMessageService_init(&msgService_PhysicalThread1, msgBuffer_PhysicalThread1, MESSAGE_POOL_MAX, MESSAGE_BLOCK_SIZE, MsgDispatcher_PhysicalThread1_receiveMessage);
	etMessageService_init(&msgService_PhysicalThread2, msgBuffer_PhysicalThread2, MESSAGE_POOL_MAX, MESSAGE_BLOCK_SIZE, MsgDispatcher_PhysicalThread2_receiveMessage);

	ET_MSC_LOGGER_SYNC_EXIT
}

void node1_sys1_startMessageServices(void){
	ET_MSC_LOGGER_SYNC_ENTRY("Node1", "startMessageServices")

	etMessageService_start(&msgService_PhysicalThread1);
	etMessageService_start(&msgService_PhysicalThread2);

	ET_MSC_LOGGER_SYNC_EXIT
}

void node1_sys1_stopMessageServices(void){
	ET_MSC_LOGGER_SYNC_ENTRY("Node1", "stopMessageServices")

	etMessageService_stop(&msgService_PhysicalThread1);
	etMessageService_stop(&msgService_PhysicalThread2);

	ET_MSC_LOGGER_SYNC_EXIT
}

void node1_sys1_destroyMessageServices(void){
	ET_MSC_LOGGER_SYNC_ENTRY("Node1", "destroyMessageServices")

	etMessageService_destroy(&msgService_PhysicalThread1);
	etMessageService_destroy(&msgService_PhysicalThread2);

	ET_MSC_LOGGER_SYNC_EXIT
}

void node1_sys1_init(void){
	ET_MSC_LOGGER_SYNC_ENTRY("Node1", "init")
	etLogger_logInfoF("%s_init", Node1Inst.name);

	/* construct all actors */
	node1_sys1_constructActorInstances();

	node1_sys1_initMessageServices();

	/* init all actors */
	node1_sys1_initActorInstances();
	
	ET_MSC_LOGGER_SYNC_EXIT
}

void node1_sys1_start(void){
	ET_MSC_LOGGER_SYNC_ENTRY("Node1", "start")
	etLogger_logInfoF("%s_start", Node1Inst.name);
	node1_sys1_startMessageServices();
	ET_MSC_LOGGER_SYNC_EXIT
}

void node1_sys1_run(void){
	ET_MSC_LOGGER_SYNC_ENTRY("Node1", "run")
	
	etThread_sleep(1000);

//	#ifdef ET_RUNTIME_ENDLESS
//		while(!(Node1Inst.shutdownRequest)){
//			if (etTimer_executeNeeded()){
//				etMessageService_execute(&msgService_PhysicalThread1);
//			}
//		}
//	#else
//		uint32 loopCounter = 0;
//		while(!(Node1Inst.shutdownRequest)){
//			if (etTimer_executeNeeded()){
//				etMessageService_execute(&msgService_PhysicalThread1);
//				etLogger_logInfo("Execute");
//				if (loopCounter++ > ET_RUNTIME_MAXLOOP){
//					break;
//				}
//			}
//		}
//	#endif
	
	ET_MSC_LOGGER_SYNC_EXIT
}

void node1_sys1_stop(void){
	ET_MSC_LOGGER_SYNC_ENTRY("Node1", "stop")
	etLogger_logInfoF("%s_stop", Node1Inst.name);
	node1_sys1_stopMessageServices();
	ET_MSC_LOGGER_SYNC_EXIT
}

void node1_sys1_destroy(void){
	ET_MSC_LOGGER_SYNC_ENTRY("Node1", "destroy")
	etLogger_logInfoF("%s_destroy", Node1Inst.name);
	node1_sys1_destroyMessageServices();
	ET_MSC_LOGGER_SYNC_EXIT
}

void node1_sys1_shutdown(void){
	ET_MSC_LOGGER_SYNC_ENTRY("Node1", "shutdown")
	etLogger_logInfoF("%s_shutdown", Node1Inst.name);
	Node1Inst.shutdownRequest = 1;
	ET_MSC_LOGGER_SYNC_EXIT
}


void node1_sys1_constructActorInstances(void){
	ET_MSC_LOGGER_SYNC_ENTRY("Node1", "constructActorInstances")
	ET_MSC_LOGGER_SYNC_EXIT
}

void node1_sys1_initActorInstances(void){
	ET_MSC_LOGGER_SYNC_ENTRY("Node1", "initActorInstances")
	Sender_init(&_SubSys_Sender);
	Receiver_init(&_SubSys_Receiver);
	ET_MSC_LOGGER_SYNC_EXIT
}

Back to the top