Newer
Older
AlgebraicDataflowArchitectureModel / AlgebraicDataflowArchitectureModel / src / simulator / interfaces / NativeSender.java
package simulator.interfaces;

import java.util.HashSet;
import java.util.Set;

import models.algebra.Expression;
import models.algebra.InvalidMessage;
import models.algebra.ParameterizedIdentifierIsFutureWork;
import models.algebra.UnificationFailed;
import models.algebra.ValueUndefined;
import models.dataConstraintModel.Channel;
import models.dataConstraintModel.ResourcePath;
import models.dataFlowModel.DataTransferChannel;
import models.dataFlowModel.ResolvingMultipleDefinitionIsFutureWork;
import simulator.Event;
import simulator.Resource;
import simulator.Simulator;

abstract public class NativeSender {
	protected Simulator simulator;
	protected DataTransferChannel channel;
	protected ResourcePath resourcePath;
	protected Resource resource;
	
	public NativeSender(Simulator simulator, DataTransferChannel channel, ResourcePath resourcePath, Resource resource) {
		this.simulator = simulator;
		this.channel = channel;
		this.resourcePath = resourcePath;
		this.resource = resource;
	}
	
	public void sendToModel(Expression message) {
		try {
			Event event = new Event(channel, message, resourcePath, resource);
			simulator.transition(event);
		} catch (ParameterizedIdentifierIsFutureWork | ResolvingMultipleDefinitionIsFutureWork | InvalidMessage | UnificationFailed | ValueUndefined e) {
			e.printStackTrace();
		}
	}
}