Skip to main content
aboutsummaryrefslogtreecommitdiffstats
blob: 57a8eb84a806925099700e4a87f79318e1d6fd9a (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
/*******************************************************************************
 * Copyright (c) 2010 protos software gmbh (http://www.protos.de).
 * 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
 *******************************************************************************/

package org.eclipse.etrice.runtime.java.modelbase;

import org.eclipse.etrice.runtime.java.messaging.Address;
import org.eclipse.etrice.runtime.java.messaging.IMessageReceiver;
import org.eclipse.etrice.runtime.java.messaging.IRTObject;
import org.eclipse.etrice.runtime.java.messaging.Message;
import org.eclipse.etrice.runtime.java.messaging.MessageService;
import org.eclipse.etrice.runtime.java.messaging.RTServices;

/**
 * The base class for model actor classes.
 * 
 * @author Thomas Schuetz
 *
 */
public abstract class ActorClassBase extends EventReceiver implements IMessageReceiver {

	protected static final int EVT_SHIFT = 1000;	// TODOHRR: use 256 or shift operation later

	protected static final int NO_STATE = 0;
	protected static final int STATE_TOP = 1;

	protected static final int NOT_CAUGHT = 0;
	
	private String className = "noname";

	/**
	 * the current state
	 */
	protected int state;

	private MessageService ownMsgsvc = null;
	private Address ownAddr = null;
	
	public ActorClassBase(IRTObject parent, String name, Address ownAddr) {
		super(parent, name);
		
		this.ownAddr = ownAddr;
		ownMsgsvc = RTServices.getInstance().getMsgSvcCtrl().getMsgSvc(this.ownAddr.threadID);
	}

	public String toString(){
		return "ActorClass(className="+className+", instancePath="+getInstancePath()+")";
	}
	
	public String getClassName() {
		return className;
	}
	public void setClassName(String className) {
		this.className = className;
	}

	@Override
	public Address getAddress() {
		// TODO: Actor should have its own address for services and debugging
		return null;
	}
	
	//--------------------- lifecycle functions
	public abstract void init();
	public abstract void start();
	public abstract void stop();
	public abstract void destroy();

	@Override
	public void receive(Message msg) {
	}
	
	public int getState() {
		return state;
	}

	public MessageService getMsgsvc() {
		return ownMsgsvc;
	}
}

Back to the top