Skip to content

Commit

Permalink
support for non-periodic events & property-based jdeeco setup in the sim
Browse files Browse the repository at this point in the history
  • Loading branch information
keznikl authored and andranikm committed Feb 7, 2014
1 parent cddfa1a commit e6cb997
Show file tree
Hide file tree
Showing 13 changed files with 370 additions and 59 deletions.
13 changes: 13 additions & 0 deletions jdeeco-core/src/cz/cuni/mff/d3s/deeco/DeecoProperties.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
package cz.cuni.mff.d3s.deeco;

public final class DeecoProperties {
public static final String PACKET_SIZE = "deeco.publish.packetsize";
public static final String PUBLISHING_PERIOD = "deeco.publish.period";
public static final String USE_INDIVIDUAL_KNOWLEDGE_PUBLISHING = "deeco.publish.individual";
public static final String DISABLE_BOUNDARY_CONDITIONS = "deeco.boundary.disable";
public static final String DISABLE_GOSSIP_CONDITION = "deeco.gossipcnd.disable";
public static final String GOSSIP_CONDITION_RSSI = "deeco.gossipcnd.rssi";
public static final String MESSAGE_CACHE_DEADLINE = "deeco.receive.cache.deadline";
public static final String MESSAGE_CACHE_WIPE_PERIOD = "deeco.receive.cache.period";

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/**
*/
package cz.cuni.mff.d3s.deeco.model.runtime.api;


/**
* <!-- begin-user-doc -->
* A representation of the model object '<em><b>Time Trigger</b></em>'.
* <!-- end-user-doc -->
*
* <p>
* The following features are supported:
* <ul>
* <li>{@link cz.cuni.mff.d3s.deeco.model.runtime.api.TimeTrigger#getPeriod <em>Period</em>}</li>
* <li>{@link cz.cuni.mff.d3s.deeco.model.runtime.api.TimeTrigger#getOffset <em>Offset</em>}</li>
* </ul>
* </p>
*
* @see cz.cuni.mff.d3s.deeco.model.runtime.meta.RuntimeMetadataPackage#getTimeTrigger()
* @model
* @generated
*/
public interface TimeTrigger extends Trigger {
/**
* Returns the value of the '<em><b>Period</b></em>' attribute.
* The default value is <code>"0"</code>.
* <!-- begin-user-doc -->
* <p>
* If the meaning of the '<em>Period</em>' attribute isn't clear,
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
* @return the value of the '<em>Period</em>' attribute.
* @see #setPeriod(long)
* @see cz.cuni.mff.d3s.deeco.model.runtime.meta.RuntimeMetadataPackage#getTimeTrigger_Period()
* @model default="0" required="true"
* @generated
*/
long getPeriod();

/**
* Sets the value of the '{@link cz.cuni.mff.d3s.deeco.model.runtime.api.TimeTrigger#getPeriod <em>Period</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Period</em>' attribute.
* @see #getPeriod()
* @generated
*/
void setPeriod(long value);

/**
* Returns the value of the '<em><b>Offset</b></em>' attribute.
* The default value is <code>"0"</code>.
* <!-- begin-user-doc -->
* <p>
* If the meaning of the '<em>Offset</em>' attribute isn't clear,
* there really should be more of a description here...
* </p>
* <!-- end-user-doc -->
* @return the value of the '<em>Offset</em>' attribute.
* @see #setOffset(long)
* @see cz.cuni.mff.d3s.deeco.model.runtime.meta.RuntimeMetadataPackage#getTimeTrigger_Offset()
* @model default="0" required="true"
* @generated
*/
long getOffset();

/**
* Sets the value of the '{@link cz.cuni.mff.d3s.deeco.model.runtime.api.TimeTrigger#getOffset <em>Offset</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @param value the new value of the '<em>Offset</em>' attribute.
* @see #getOffset()
* @generated
*/
void setOffset(long value);

} // TimeTrigger
Original file line number Diff line number Diff line change
@@ -0,0 +1,217 @@
/**
*/
package cz.cuni.mff.d3s.deeco.model.runtime.impl;

import cz.cuni.mff.d3s.deeco.model.runtime.api.TimeTrigger;

import cz.cuni.mff.d3s.deeco.model.runtime.meta.RuntimeMetadataPackage;

import org.eclipse.emf.common.notify.Notification;

import org.eclipse.emf.ecore.EClass;

import org.eclipse.emf.ecore.impl.ENotificationImpl;

/**
* <!-- begin-user-doc -->
* An implementation of the model object '<em><b>Time Trigger</b></em>'.
* <!-- end-user-doc -->
* <p>
* The following features are implemented:
* <ul>
* <li>{@link cz.cuni.mff.d3s.deeco.model.runtime.impl.TimeTriggerImpl#getPeriod <em>Period</em>}</li>
* <li>{@link cz.cuni.mff.d3s.deeco.model.runtime.impl.TimeTriggerImpl#getOffset <em>Offset</em>}</li>
* </ul>
* </p>
*
* @generated
*/
public class TimeTriggerImpl extends TriggerImpl implements TimeTrigger {
/**
* The default value of the '{@link #getPeriod() <em>Period</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getPeriod()
* @generated
* @ordered
*/
protected static final long PERIOD_EDEFAULT = 0L;

/**
* The cached value of the '{@link #getPeriod() <em>Period</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getPeriod()
* @generated
* @ordered
*/
protected long period = PERIOD_EDEFAULT;

/**
* The default value of the '{@link #getOffset() <em>Offset</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getOffset()
* @generated
* @ordered
*/
protected static final long OFFSET_EDEFAULT = 0L;

/**
* The cached value of the '{@link #getOffset() <em>Offset</em>}' attribute.
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @see #getOffset()
* @generated
* @ordered
*/
protected long offset = OFFSET_EDEFAULT;

/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
protected TimeTriggerImpl() {
super();
}

/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
protected EClass eStaticClass() {
return RuntimeMetadataPackage.Literals.TIME_TRIGGER;
}

/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public long getPeriod() {
return period;
}

/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setPeriod(long newPeriod) {
long oldPeriod = period;
period = newPeriod;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, RuntimeMetadataPackage.TIME_TRIGGER__PERIOD, oldPeriod, period));
}

/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public long getOffset() {
return offset;
}

/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
public void setOffset(long newOffset) {
long oldOffset = offset;
offset = newOffset;
if (eNotificationRequired())
eNotify(new ENotificationImpl(this, Notification.SET, RuntimeMetadataPackage.TIME_TRIGGER__OFFSET, oldOffset, offset));
}

/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public Object eGet(int featureID, boolean resolve, boolean coreType) {
switch (featureID) {
case RuntimeMetadataPackage.TIME_TRIGGER__PERIOD:
return getPeriod();
case RuntimeMetadataPackage.TIME_TRIGGER__OFFSET:
return getOffset();
}
return super.eGet(featureID, resolve, coreType);
}

/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eSet(int featureID, Object newValue) {
switch (featureID) {
case RuntimeMetadataPackage.TIME_TRIGGER__PERIOD:
setPeriod((Long)newValue);
return;
case RuntimeMetadataPackage.TIME_TRIGGER__OFFSET:
setOffset((Long)newValue);
return;
}
super.eSet(featureID, newValue);
}

/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public void eUnset(int featureID) {
switch (featureID) {
case RuntimeMetadataPackage.TIME_TRIGGER__PERIOD:
setPeriod(PERIOD_EDEFAULT);
return;
case RuntimeMetadataPackage.TIME_TRIGGER__OFFSET:
setOffset(OFFSET_EDEFAULT);
return;
}
super.eUnset(featureID);
}

/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public boolean eIsSet(int featureID) {
switch (featureID) {
case RuntimeMetadataPackage.TIME_TRIGGER__PERIOD:
return period != PERIOD_EDEFAULT;
case RuntimeMetadataPackage.TIME_TRIGGER__OFFSET:
return offset != OFFSET_EDEFAULT;
}
return super.eIsSet(featureID);
}

/**
* <!-- begin-user-doc -->
* <!-- end-user-doc -->
* @generated
*/
@Override
public String toString() {
if (eIsProxy()) return super.toString();

StringBuffer result = new StringBuffer(super.toString());
result.append(" (period: ");
result.append(period);
result.append(", offset: ");
result.append(offset);
result.append(')');
return result.toString();
}

} //TimeTriggerImpl
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,10 @@ private static class PublisherTrigger extends TimeTriggerExt {
public PublisherTrigger(long period, long seed) {
super();
setPeriod(period);
setOffset(0);
random = new Random(seed);
// for experiments, publisher task has a random start offset up to its period
setOffset(random.nextInt((int) period));

}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,20 +233,6 @@ void scheduleAfter(SchedulerEvent event, long delay) {
queue.notify();
}

//
// /**
// * Note that this method has to be explicitly protected by queue's monitor!
// */
// void scheduleNow(SchedulerEvent event, long period) {
// event.nextExecutionTime = System.currentTimeMillis(); // start immediately
// event.period = period;
// event.state = SchedulerEvent.SCHEDULED;
//
// queue.add(event);
// if (queue.getMin() == event)
// queue.notify();
// }


@Override
public void removeTask(Task task) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@

import cz.cuni.mff.d3s.deeco.annotations.In;
import cz.cuni.mff.d3s.deeco.annotations.InOut;
import cz.cuni.mff.d3s.deeco.annotations.Out;
import cz.cuni.mff.d3s.deeco.annotations.PeriodicScheduling;
import cz.cuni.mff.d3s.deeco.annotations.Process;
import cz.cuni.mff.d3s.deeco.annotations.TriggerOnChange;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,6 @@
*/
public class Main {

static double POSITION_FACTOR = 1;
static int PACKET_SIZE = 2000;
static int PUBLISHING_PERIOD = 1000;

static String OMNET_CONFIG_TEMPLATE = "omnetpp.ini.templ";
static String OMNET_CONFIG_PATH = "omnetpp.ini";

Expand Down Expand Up @@ -80,22 +76,22 @@ public static void main(String[] args) throws AnnotationProcessorException, IOEx

omnetConfig.append(String.format(
"**.node[%s].mobility.initialX = %dm\n",
i, (int) (component.position.x * POSITION_FACTOR)));
i, (int) (component.position.x)));
omnetConfig.append(String.format(
"**.node[%s].mobility.initialY = %dm\n",
i, (int) (component.position.y * POSITION_FACTOR)));
i, (int) (component.position.y)));
omnetConfig.append(String.format(
"**.node[%s].mobility.initialZ = 0m\n", i));
omnetConfig.append(String.format(
"**.node[%s].appl.id = \"%s\"\n\n", i, component.id));

Host host = sim.getHost(component.id, PACKET_SIZE);
Host host = sim.getHost(component.id);
hosts.add(host);

// there is only one component instance
model.getComponentInstances().get(0).getInternalData().put(PositionAwareComponent.HOST_REFERENCE, host);

RuntimeFramework runtime = builder.build(host, model, PUBLISHING_PERIOD);
RuntimeFramework runtime = builder.build(host, model);
runtimes.add(runtime);
runtime.start();
i++;
Expand Down
Loading

0 comments on commit e6cb997

Please sign in to comment.