Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 4109a1a28914caaa86c005b0c2352bddd39b3ed6 (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
/**
 * @author generated by eTrice
 *
 * Source File of ProtocolClass PInterrupt
 * 
 */

#include "PInterrupt.h"
#include "debugging/etMSCLogger.h"
#include "PInterrupt_Utils.h"


/*--------------------- port methods */
etInt32 PInterruptReplPort_getReplication(const PInterruptReplPort* self) {
	return ((etReplPort*)self)->size;
}



void PInterruptConjPort_event(const PInterruptConjPort* self) {
	// the message should be sent via the fire operation !!
}

void PInterruptConjReplPort_event_broadcast(const PInterruptConjReplPort* self) {
	int i;
	for (i=0; i<((etReplPort*)self)->size; ++i) {
		PInterruptConjPort_event(&((etReplPort*)self)->ports[i].port);
	}					
}

void PInterruptConjReplPort_event(const PInterruptConjReplPort* self, int idx__et) {
	PInterruptConjPort_event(&((etReplPort*)self)->ports[idx__et].port);
}

/* begin PInterruptConjPort specific (including base classes) */
/*--------------------- begin user code ---------------------*/
#include "messaging/etMessageService.h"
/*--------------------- end user code ---------------------*/

/*--------------------- operations ---------------------*/
 PInterruptConjPort* PInterruptConjPort_export(PInterruptConjPort* self) {
	msg.address = self->peerAddress;
	msg.evtID = PInterrupt_IN_event;
	callback.func=(void (*)(void*))PInterruptConjPort_dispatch;
	callback.param=(void *)self;
	etMessageService_registerHighPrioFunc(self->msgService,&callback);
	return self;
}
 void PInterruptConjPort_dispatch(PInterruptConjPort* self) {
	// this operation will be executed from the message service
	if (enable){
		enable=0;
		self->msgService->msgDispatcher(&msg);
	}
}
 void PInterruptConjPort_fire(PInterruptConjPort* self) {
	// this method runs on interrupt level
	enable=1;
	etSema_wakeupFromISR(&self->msgService->executionSemaphore);
}
/* end PInterruptConjPort specific (including base classes) */

etInt32 PInterruptConjReplPort_getReplication(const PInterruptConjReplPort* self) {
	return ((etReplPort*)self)->size;
}



/*--------------------- debug helpers */

/* message names as strings for debugging (generate MSC) */
static const char* const PInterrupt_messageStrings[] = {"MIN", "event", "MAX"};

const char* PInterrupt_getMessageString(int msg_id) {
	if (msg_id<PInterrupt_MSG_MIN || msg_id>PInterrupt_MSG_MAX+1){
		/* id out of range */
		return "Message ID out of range";
	}
	else{
		return PInterrupt_messageStrings[msg_id];
	}
}

Back to the top