Bug 514634 General Improvement

Change-Id: I245be33b26bbc937b08a611068a957d8ae97e0f1
diff --git a/codegen/org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph/src/org/eclipse/efm/modeling/codegen/xlia/sdf/polygraph/mocc/ast/MoccActor.java b/codegen/org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph/src/org/eclipse/efm/modeling/codegen/xlia/sdf/polygraph/mocc/ast/MoccActor.java
index b39c001..fc84663 100644
--- a/codegen/org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph/src/org/eclipse/efm/modeling/codegen/xlia/sdf/polygraph/mocc/ast/MoccActor.java
+++ b/codegen/org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph/src/org/eclipse/efm/modeling/codegen/xlia/sdf/polygraph/mocc/ast/MoccActor.java
@@ -12,11 +12,16 @@
  *******************************************************************************/
 package org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph.mocc.ast;
 
+import java.io.StringWriter;
 import java.util.ArrayList;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
 
 import org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph.mocc.ast.MoccPort.Direction;
 import org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph.mocc.ast.feature.MoccActorFeature;
+import org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph.util.PrettyPrintWriter;
 
 public class MoccActor {
 
@@ -51,6 +56,16 @@
 	protected final List< MoccActor > predecessorActor;
 	protected final List< MoccActor > successorActor;
 
+

+	// Composite purpose

+	protected MoccSystem subSystem;

+

+	// system.channel  ---> subsystem.actor

+	protected Map<MoccChannel, MoccActor> inputGateway;

+	// subsystem.actor ---> system.channel

+	protected Map<MoccActor, MoccChannel> outputGateway;

+

+	// Analysis Purpose

 	public MoccActorFeature FEATURE;
 
 	// Timed & Phase - Selector & Processor Mode - Actor
@@ -82,6 +97,10 @@
 		this.predecessorActor = new ArrayList<MoccActor>();
 		this.successorActor = new ArrayList<MoccActor>();
 
+		this.subSystem = null;

+		this.inputGateway  = null;

+		this.outputGateway = null;

+

 		this.FEATURE = null;
 
 		system.addActor( this );
@@ -115,6 +134,10 @@
 		this.predecessorActor = new ArrayList<MoccActor>();
 		this.successorActor = new ArrayList<MoccActor>();
 
+		this.subSystem     = null;

+		this.inputGateway  = null;

+		this.outputGateway = null;

+

 		this.FEATURE = null;
 
 		system.addActor( this );
@@ -385,6 +408,74 @@
 		successorActor.add( channel.getInputPort().getActor() );
 	}
 
+

+	// COMPOSITE ACTOR INPUT GATEWAY

+	public Map<MoccChannel, MoccActor> getInputGateway() {

+		return this.inputGateway;

+	}

+

+	public boolean hasInputGateway() {

+		return( this.inputGateway != null );

+	}

+

+	public void addInputGateway(final MoccChannel channel, final MoccActor actor) {

+		if( this.inputGateway == null ) {

+			this.inputGateway = new HashMap<MoccChannel, MoccActor>();

+		}

+		this.inputGateway.put(channel, actor);

+	}

+

+	public void addInputGateway(final MoccChannel channel) {

+		if( this.inputGateway == null ) {

+			this.inputGateway = new HashMap<MoccChannel, MoccActor>();

+		}

+		this.inputGateway.put(channel, this);

+

+//		addProxyPort(channel, Direction.INPUT);

+	}

+

+

+	// COMPOSITE ACTOR OUTPUT GATEWAY

+	public Map<MoccActor, MoccChannel> getOutputGateway() {

+		return this.outputGateway;

+	}

+

+	public boolean hasOutputGateway() {

+		return( this.outputGateway != null );

+	}

+

+	public void addOutputGateway(final MoccActor actor, final MoccChannel channel) {

+		if( this.outputGateway == null ) {

+			this.outputGateway = new HashMap<MoccActor, MoccChannel>();

+		}

+		this.outputGateway.put(actor, channel);

+	}

+

+	public void addOutputGateway(final MoccChannel channel) {

+		if( this.outputGateway == null ) {

+			this.outputGateway = new HashMap<MoccActor, MoccChannel>();

+		}

+		this.outputGateway.put(this, channel);

+

+//		addProxyPort(channel, Direction.OUTPUT);

+	}

+

+

+	// COMPOSITE ACTOR SUB-SYSTEM

+	public MoccSystem getSubSystem() {

+		return this.subSystem;

+	}

+

+	public boolean isComposite() {

+		return( (this.subSystem != null)

+				&& (! this.subSystem.getActor().isEmpty()) );

+	}

+

+	public void setSubSystem(final MoccSystem moccSystem) {

+		this.subSystem = moccSystem;

+	}

+

+

 	// MoccActorFeature
 	public void computeFeature() {
 		FEATURE = new MoccActorFeature(this);
@@ -399,76 +490,140 @@
 
 	@Override
 	public String toString() {
-		final StringBuilder sout = new StringBuilder();
+		final StringWriter buffer = new StringWriter();
+		final PrettyPrintWriter writer = new PrettyPrintWriter(buffer);
 
-		sout.append("actor ").append(name).append(" {").append('\n');
+		toWriter( writer );
 
-		sout.append('\t').append("frequency = " ).append(frequency)
-			.append('\n')
-			.append('\t').append("phase = "     ).append(phase)
-			.append('\n')
-			.append('\t').append("moe {")
-			.append('\n')
-			.append("\t\t").append("schedule = ")
-			.append(schedule).append('\n');
+		return buffer.toString();
+	}
+
+	public PrettyPrintWriter toWriter(final PrettyPrintWriter writer) {
+		writer.appendTab("actor ").append(name).appendEol(" {");
+
+		writer.appendTab2("frequency = ").appendEol(frequency)
+			.appendTab2("phase = "      ).appendEol(phase)
+			.appendTab2Eol("moe {")
+			.appendTab3("schedule = "  ).appendEol(schedule);
 
 		if( FEATURE != null ) {
-			sout.append("\t\t").append("executable = ")
-					.append(FEATURE.isExecutable).append('\n')
-				.append("\t\t").append("repetition = ")
-					.append(FEATURE.repetition).append('\n')
-				.append("\t\t").append("activation = ")
-					.append(FEATURE.strActivation()).append('\n');
+			writer.appendTab3("omega_freq = ")

+					.appendEol(FEATURE.omegaFrequency)

+				.appendTab3("executable = ")
+					.appendEol(FEATURE.isExecutable)
+				.appendTab3("repetition = ")
+					.appendEol(FEATURE.repetition)
+				.appendTab3("activation = ")
+					.appendEol(FEATURE.strActivation());
 		}
-		sout.append('\t').append('}')
-			.append('\n');
+		writer.appendTab2Eol('}');
 
 		if( selector != null ) {
-			sout.append('\t').append("selector = " )
-				.append(selector.getName()).append('\n');
+			writer.appendTab2("selector = ").appendEol(selector.getName());
 		}
 		if( selectionSet.length > 0 ) {
-			sout.append('\t').append("selectionSet = [ " );
+			writer.appendTab2("selectionSet = [");
 			for( final MoccMode mode : selectionSet ) {
-				sout.append(mode.getLiteral()).append(' ');
+				writer.append(mode.getLiteral()).append(' ');
 			}
-			sout.append(']').append('\n');
+			writer.appendEol(']');
 		}
 		if( processingSet.length > 0 ) {
-			sout.append('\t').append("processingSet = [ " );
+			writer.appendTab2("processingSet = [");
 			for( final MoccMode mode : processingSet ) {
-				sout.append(mode.getLiteral()).append(' ');
+				writer.append(mode.getLiteral()).append(' ');
 			}
-			sout.append(']').append('\n');
+			writer.appendEol(']');
 		}
 
 
 		if( ! predecessorActor.isEmpty() ) {
-			sout.append('\t').append("predecessor = [ " );
+			writer.appendTab2("predecessor = [");
 			for( final MoccActor actor : predecessorActor ) {
-				sout.append(actor.getName()).append(' ');
+				writer.append(actor.getName()).append(' ');
 			}
-			sout.append(']').append('\n');
+			writer.appendEol(']');
 		}
 		if( ! successorActor.isEmpty() ) {
-			sout.append('\t').append("successor = [ " );
+			writer.appendTab2("successor = [");
 			for( final MoccActor actor : successorActor ) {
-				sout.append(actor.getName()).append(' ');
+				writer.append(actor.getName()).append(' ');
 			}
-			sout.append(']').append('\n');
+			writer.appendEol(']');
 		}
 
+
+		final PrettyPrintWriter writer2 = writer.itab2();
+
 		for( final MoccPort port : getInputPort() ) {
-			sout.append('\t').append(port.toString()).append('\n');
+			port.toWriter(writer2);
 		}
 
 		for( final MoccPort port : getOutputPort() ) {
-			sout.append('\t').append(port.toString()).append('\n');
+			port.toWriter(writer2);
 		}
 
-		sout.append('}');
+

+		if( this.inputGateway != null ) {

+			writer.appendEol();

+

+			writer.appendTab2Eol("input gateway {");

+

+			for( final  Entry<MoccChannel, MoccActor> bridge

+					: this.inputGateway.entrySet() )

+			{

+				final MoccChannel channel = bridge.getKey();

+				final MoccActor proxyActor = bridge.getValue();

+

+				writer.appendTab3(channel.getOutputActor().getName())

+					.append("->")

+					.append(channel.getName())

+					.append( " ==> this" );

+				if( this != proxyActor ) {

+					writer.append('.').appendEol(proxyActor.name);

+				}

+				else {

+					writer.appendEol();

+				}

+			}

+

+			writer.appendTab2Eol('}');

+		}

+

+		if( this.outputGateway != null ) {

+			writer.appendEol();

+

+			writer.appendTab2Eol("output gateway {");

+

+			for( final  Entry<MoccActor, MoccChannel> bridge

+					: this.outputGateway.entrySet() )

+			{

+				final MoccChannel channel = bridge.getValue();

+				final MoccActor proxyActor = bridge.getKey();

+

+				writer.appendTab3("this");

+				if( this != proxyActor ) {

+					writer.append('.').append(proxyActor.name);

+				}

+				writer.append( " ==> " )

+					.append(channel.getName())

+					.append("->")

+					.appendEol(channel.getInputActor().getName());

+			}

+

+			writer.appendTab2Eol('}');

+		}

+

+		if( this.subSystem != null ) {
+			writer2.appendEol();
+			this.subSystem.toWriter(writer2);
+		}
 
-		return sout.toString();
+		writer.appendTabEol('}');
+
+		writer.flush();
+
+		return writer;
 	}
 
 	public boolean hasEnoughInitialRate(final MoccActor sourceActor) {
diff --git a/codegen/org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph/src/org/eclipse/efm/modeling/codegen/xlia/sdf/polygraph/mocc/ast/MoccChannel.java b/codegen/org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph/src/org/eclipse/efm/modeling/codegen/xlia/sdf/polygraph/mocc/ast/MoccChannel.java
index edce725..cac8472 100644
--- a/codegen/org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph/src/org/eclipse/efm/modeling/codegen/xlia/sdf/polygraph/mocc/ast/MoccChannel.java
+++ b/codegen/org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph/src/org/eclipse/efm/modeling/codegen/xlia/sdf/polygraph/mocc/ast/MoccChannel.java
@@ -12,6 +12,10 @@
  *******************************************************************************/
 package org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph.mocc.ast;
 
+import java.io.StringWriter;
+
+import org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph.util.PrettyPrintWriter;
+
 public class MoccChannel {
 
 	protected final MoccSystem system;
@@ -178,48 +182,53 @@
 
 	@Override
 	public String toString() {
-		final StringBuilder sout = new StringBuilder();
+		final StringWriter buffer = new StringWriter();
+		final PrettyPrintWriter writer = new PrettyPrintWriter(buffer);
 
-		sout.append("channel");
+		toWriter( writer );
 
-		sout.append(' ').append(name).append(" {")
-			.append('\n')
-			.append('\t').append("deciding = ").append(isDeciding).append('\n')
+		return buffer.toString();
+	}
 
-			.append('\t').append("output<").append(outputPort.strRate());
+	public PrettyPrintWriter toWriter(final PrettyPrintWriter writer) {
+		writer.appendTab("channel").append(' ').append(name).appendEol(" {");
+
+		writer.appendTab2("deciding = ").appendEol(isDeciding);
+
+		writer.appendTab2("output<").append(outputPort.strRate());
 		if( outputPort.cycloStaticRate != null ) {
-			sout.append(" , ");
-			outputPort.strCycloStaticRate(sout);
+			writer.append(" , ");
+			outputPort.strCycloStaticRate(writer);
 		}
-		sout.append("> ")
+		writer.append("> ")
 			.append(outputPort.getActor().getName())
-			.append("->").append(outputPort.getName())
-			.append('\n');
+			.append("->").appendEol(outputPort.getName());
 
 		if( hasInitialRate() ) {
-			sout.append('\t').append("initial{ rate = ")
+			writer.appendTab2("initial{ rate = ")
 				.append(strInitialRate());
 
 			if( hasInitialMode() ) {
-				sout.append(" , mode = ").append(initialMode.getLiteral());
+				writer.append(" , mode = ").append(initialMode.getLiteral());
 			}
 
-			sout.append(" }")
-				.append('\n');
+			writer.appendEol(" }");
 		}
 
-		sout.append('\t').append("input<").append(inputPort.strRate());
+		writer.appendTab2("input<").append(inputPort.strRate());
 		if( inputPort.cycloStaticRate != null ) {
-			sout.append(" , ");
-			inputPort.strCycloStaticRate(sout);
+			writer.append(" , ");
+			inputPort.strCycloStaticRate(writer);
 		}
-		sout.append("> ")
+		writer.append("> ")
 			.append(inputPort.getActor().getName())
-			.append("->").append(inputPort.getName())
-			.append('\n')
-			.append('}');
+			.append("->").appendEol(inputPort.getName());
 
-		return sout.toString();
+		writer.appendTabEol('}');
+
+		writer.flush();
+
+		return writer;
 	}
 
 
diff --git a/codegen/org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph/src/org/eclipse/efm/modeling/codegen/xlia/sdf/polygraph/mocc/ast/MoccPort.java b/codegen/org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph/src/org/eclipse/efm/modeling/codegen/xlia/sdf/polygraph/mocc/ast/MoccPort.java
index 67780b5..b5e0060 100644
--- a/codegen/org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph/src/org/eclipse/efm/modeling/codegen/xlia/sdf/polygraph/mocc/ast/MoccPort.java
+++ b/codegen/org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph/src/org/eclipse/efm/modeling/codegen/xlia/sdf/polygraph/mocc/ast/MoccPort.java
@@ -12,6 +12,9 @@
  *******************************************************************************/
 package org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph.mocc.ast;
 
+import java.io.StringWriter;
+
+import org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph.util.PrettyPrintWriter;
 import org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph.util.Rational;
 
 public class MoccPort {
@@ -326,39 +329,48 @@
 		}
 	}
 
-	public void strCycloStaticRate(final StringBuilder sout) {
-		sout.append('[');
+	public void strCycloStaticRate(final PrettyPrintWriter writer) {
+		writer.append('[');
 		for (final int rate : cycloStaticRate) {
-			sout.append(' ').append(rate);
+			writer.append(' ').append(rate);
 		}
-		sout.append(" ]");
+		writer.append(" ]");
 	}
 
 
 	@Override
 	public String toString() {
-		final StringBuilder sout = new StringBuilder();
+		final StringWriter buffer = new StringWriter();
+		final PrettyPrintWriter writer = new PrettyPrintWriter(buffer);
 
-		sout.append(direction.toString().toLowerCase())
+		toWriter( writer );
+
+		return buffer.toString();
+	}
+
+	public PrettyPrintWriter toWriter(final PrettyPrintWriter writer) {
+		writer.appendTab(direction.toString().toLowerCase())
 			.append(isDeciding ? " deciding" : "")
 			.append(" port< rate = ").append(strRate());
 
 		if( cycloStaticRate != null ) {
-			sout.append(" , cyclo = ");
-			strCycloStaticRate(sout);
+			writer.append(" , cyclo = ");
+			strCycloStaticRate(writer);
 		}
 
 		if( channel.hasInitialRate() ) {
-			sout.append(" , initial = ").append(channel.strInitialRate());
+			writer.append(" , initial = ").append(channel.strInitialRate());
 		}
 		if( channel.hasInitialMode() ) {
-			sout.append(" , mode = ")
+			writer.append(" , mode = ")
 				.append(channel.getInitialMode().getLiteral());
 		}
 
-		sout.append(" > ").append(name);
+		writer.append(" > ").appendEol(name);
 
-		return sout.toString();
+		writer.flush();
+
+		return writer;
 	}
 
 }
diff --git a/codegen/org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph/src/org/eclipse/efm/modeling/codegen/xlia/sdf/polygraph/mocc/ast/MoccSystem.java b/codegen/org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph/src/org/eclipse/efm/modeling/codegen/xlia/sdf/polygraph/mocc/ast/MoccSystem.java
index 9ac3325..b114a41 100644
--- a/codegen/org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph/src/org/eclipse/efm/modeling/codegen/xlia/sdf/polygraph/mocc/ast/MoccSystem.java
+++ b/codegen/org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph/src/org/eclipse/efm/modeling/codegen/xlia/sdf/polygraph/mocc/ast/MoccSystem.java
@@ -12,10 +12,12 @@
  *******************************************************************************/
 package org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph.mocc.ast;
 
+import java.io.StringWriter;
 import java.util.Arrays;
 import java.util.Vector;
 
 import org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph.mocc.ast.feature.MoccSystemFeature;
+import org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph.util.PrettyPrintWriter;
 
 public class MoccSystem {
 
@@ -47,7 +49,7 @@
 		this.channels = new Vector<MoccChannel>();
 		this.channelWellFormedness = true;
 
-		MODE_SET = new Vector<MoccMode>();
+		this.MODE_SET = new Vector<MoccMode>();

 
 		this.UNDEFINED = newMode(nameModeUndefined, literalModeUndefined);
 		this.NOMINAL   = newMode(nameModeNominal  , literalModeNominal  );
@@ -78,7 +80,7 @@
 
 		final MoccMode mode = new MoccMode(uniqModeValue++, name, literal);
 
-		MODE_SET.add( mode );
+		this.MODE_SET.add( mode );

 
 		return mode;
 	}
@@ -414,161 +416,174 @@
 
 
 	public String toAbstract() {
-		final StringBuilder sout = new StringBuilder();
+		final StringWriter buffer = new StringWriter();
+		final PrettyPrintWriter writer = new PrettyPrintWriter(buffer);
 
-		sout.append("// The Polygraph System Graph Abstract\n")
-			.append("system ").append(name).append(" {")
-			.append("\n")
-			.append('\t').append("well-formed = ").append(isWellFormed())
-			.append("\n")
-			.append('\t').append("actor       = ").append(getActor().size())
-			.append('\n')
-			.append('\t').append("channel     = ").append(getChannel().size())
-			.append('\t').append("channel OK? = ").append(isChannelConsistent())
-			.append('\n');
+		toAbstract( writer );
+
+		return buffer.toString();
+	}
+
+	public PrettyPrintWriter toAbstract(final PrettyPrintWriter writer) {
+		writer.appendTabEol("// The Polygraph System Graph Abstract");
+
+		writer.appendTab("system ").append(name).appendEol(" {");
+
+		writer
+			.appendTab2("well-formed = ").appendEol(isWellFormed())
+			.appendTab2("actor       = ").appendEol(getActor().size())
+			.appendTab2("channel     = ").append(getChannel().size())
+			.appendTab2("channel OK? = ").appendEol(isChannelConsistent());
 
 		if( FEATURE != null ) {
-			sout.append('\t').append("timed       = ")
-					.append(FEATURE.timedActorCount).append('\n')
-				.append('\t').append("phase       = ")
-					.append(FEATURE.phaseActorCount).append('\n')
-				.append('\t').append("consistency = ")
-					.append(FEATURE.consistency).append('\n');
+			writer
+				.appendTab2("timed       = ").appendEol(FEATURE.timedActorCount)
+				.appendTab2("phase       = ").appendEol(FEATURE.phaseActorCount)
+				.appendTab2("consistency = ").appendEol(FEATURE.consistency);
 
 			if( FEATURE.consistency ) {
-				sout.append('\t')
-					.append("frequencies = " )
-						.append(Arrays.toString(FEATURE.exeFrequencies)).append('\n')
-					.append('\t').append("time        = +" )
-						.append(FEATURE.time_interval).append('\n')
-					.append('\t').append("time_period = " )
-						.append(FEATURE.time_period).append('\n')
-					.append('\t').append("tick_period = " )
-						.append(FEATURE.tick_period).append('\n')
-					.append('\t').append("repetition  = " )
-						.append(Arrays.toString(FEATURE.repetitions))
-						.append('\n')
-					.append('\t').append("firings     = " )
-						.append(FEATURE.firings).append('\n')
-					.append('\n');
+				writer
+					.appendTab2("repetition  = " )
+						.appendEol(Arrays.toString(FEATURE.repetitions))
+					.appendTab2("firings     = " ).appendEol(FEATURE.firings)

+
+					.appendTab2("frequencies = " ).appendEol(FEATURE.strFrequencies())

+

+					.appendTab2("tick_frequency = ").appendEol(FEATURE.tick_frequency)

+					.appendTab2("tick_step      = +").appendEol(FEATURE.tick_step)

+

+					.appendTab2("period         = " ).appendEol(FEATURE.period)       // time resolution

+					.appendTab2("hyperperiod    = " ).appendEol(FEATURE.hyperperiod); // live resolution

+

+
+				writer.appendEol();
 
 				for( final MoccActor actor : getActor() ) {
-					sout.append('\t').append(actor.FEATURE.strActivation())
+					writer.appendTab2(actor.FEATURE.strActivation())
 						.append(' ').append(actor.getName())
-						.append( actor.isTimed() ? "*" : "" )
-						.append('\n');
+						.appendEol( actor.isTimed() ? "*" : "" );
 				}
 			}
 		}
 
-		sout.append('}');
+		writer.appendTabEol('}');
 
-		return sout.toString();
+		return writer;
 	}
 
 
 	@Override
 	public String toString() {
-		final StringBuilder sout = new StringBuilder();
+		final StringWriter buffer = new StringWriter();
+		final PrettyPrintWriter writer = new PrettyPrintWriter(buffer);
 
-		sout.append("// The MOCC system graph\n\n");
+		toWriter( writer );
 
-		sout.append("system ").append(name).append(" {").append("\n\n");
+		return buffer.toString();
+	}
+
+	public PrettyPrintWriter toWriter(final PrettyPrintWriter writer) {
+		writer.appendTabEol("// The MOCC system graph");
+
+		writer.appendTab("system ").append(name).appendEol2(" {");
+
+		final PrettyPrintWriter writer2 = writer.itab2();
 
 		for( final MoccActor actor : getActor() ) {
-			sout.append(actor.toString()).append('\n');
+			actor.toWriter(writer2);
 		}
 
-		sout.append('\n');
+		writer.appendEol();
 
 		for( final MoccChannel channel : getChannel() ) {
-			sout.append(channel.toString()).append('\n');
+			channel.toWriter(writer2);
 		}
 
-		sout.append('\n').append("moe {").append('\n');
+		writer.appendEol();
+
+		writer.appendTab2Eol("moe {");
 
 		if( FEATURE != null ) {
-			sout.append('\t').append("consistency = ")

-				.append(FEATURE.consistency).append('\n');

-

-			sout.append('\t').append("// Causality partial order").append('\n');
-			sout.append('\t').append("root = [ " );
+			writer.appendTab3("consistency = ").appendEol(FEATURE.consistency);
+
+			writer.appendTab3Eol("// Causality partial order");
+			writer.appendTab3("root = [ " );
 			for( final MoccActor actor : this.FEATURE.rootActor ) {
-				sout.append(actor.getName()).append(' ');
+				writer.append(actor.getName()).append(' ');
 			}
-			sout.append(']').append('\n');
+			writer.appendEol(']');
 
-			sout.append('\t').append("leaf = [ " );
+			writer.appendTab3("leaf = [ " );
 			for( final MoccActor actor : this.FEATURE.leafActor ) {
-				sout.append(actor.getName()).append(' ');
+				writer.append(actor.getName()).append(' ');
 			}
-			sout.append(']').append('\n');
+			writer.appendEol(']');
 
-			sout.append('\t').append("order = [ " );
+			writer.appendTab3("order = [ " );
 			for( final MoccActor actor : this.actors ) {
-				sout.append(actor.schedule).append(':')
+				writer.append(actor.schedule).append(':')
 					.append(actor.getName()).append(' ');
 			}
-			sout.append(']').append('\n');
+			writer.appendEol(']');
 
 			int schedule = 0;
-			sout.append('\t').append("stage = 0:[ " );
+			writer.appendTab3("stage = 0:[ " );
 			for( final MoccActor actor : this.actors ) {
 				if( actor.schedule == schedule ) {
-					sout.append(actor.getName()).append(' ');
+					writer.append(actor.getName()).append(' ');
 				}
 				else {
 					schedule = actor.schedule;
 
-					sout.append(']').append('\n')
-						.append('\t').append("stage = ").append(schedule)
+					writer.appendEol(']')
+						.appendTab3("stage = ").append(schedule)
 						.append(":[ " ).append(actor.getName()).append(' ');
 				}
 			}
-			sout.append(']').append('\n');
+			writer.appendEol(']');
 
-			sout.append('\n')
-				.append('\t').append("timed_actor = " )
+			writer.appendEol();
+
+			writer.appendTab3("timed_actor = " )
 					.append(FEATURE.timedActorCount).append(" / ")
-					.append(actors.size()).append('\n')
-				.append('\t').append("frequencies = " )
-					.append(FEATURE.strFrequencies()).append('\n')
+					.appendEol(actors.size())
 
-				.append('\t').append("phase       = ")
+				.appendTab3("phase       = ")
 					.append(FEATURE.phaseActorCount).append(" / ")
-					.append(actors.size()).append('\n')
+					.appendEol(actors.size())
 
-				.append('\t').append("time        = +" )

-					.append(FEATURE.time_interval).append('\n')

-				.append('\t').append("time_period = " )
-					.append(FEATURE.time_period).append('\n')

-				.append('\t').append("tick_period = " )
-					.append(FEATURE.tick_period).append('\n')
-				.append('\t').append("repetition  = " )
-					.append(Arrays.toString(FEATURE.repetitions))
-					.append('\n')
-				.append('\t').append("firings     = " )
-					.append(FEATURE.firings).append('\n')
-				.append('\n');
+				.appendTab3("frequencies    = " )

+					.appendEol(FEATURE.strFrequencies())

+

+				.appendTab3("tick_frequency = ").appendEol(FEATURE.tick_frequency)

+				.appendTab3("tick_step      = +").appendEol(FEATURE.tick_step)

+				.appendTab3("period         = " ).appendEol(FEATURE.period)      // time resolution

+				.appendTab3("hyperperiod    = " ).appendEol(FEATURE.hyperperiod) // live resolution

+

+				.appendTab3("repetition     = " )

+					.appendEol(Arrays.toString(FEATURE.repetitions))

+				.appendTab3("firings     = "  ).appendEol(FEATURE.firings);
+
+			writer.appendEol();
 
 			for( final MoccActor actor : getActor() ) {
-				sout.append('\t').append(actor.FEATURE.strActivation())
+				writer.appendTab3(actor.FEATURE.strActivation())
 					.append(' ').append(actor.getName())
-					.append( actor.isTimed() ? "*" : "" )
-					.append('\n');
+					.appendEol( actor.isTimed() ? "*" : "" );
 			}
-			sout.append('\n');
 		}
 
-//		sout.append('\t').append("schedule {").append('\n');
-//
-//		sout.append('\t').append('}').append('\n');
-//
-//		sout.append('}').append('\n');
+		writer.appendTab2Eol('}');
 
-		sout.append('\n').append('}');
+//		sout.appendTab2Eol("schedule {");
+//
+//		sout.appendTab2Eol('}');
 
-		return sout.toString();
+		writer.appendTabEol('}');
+
+		writer.flush();
+
+		return writer;
 	}
 
 }
diff --git a/codegen/org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph/src/org/eclipse/efm/modeling/codegen/xlia/sdf/polygraph/mocc/ast/feature/MoccActorFeature.java b/codegen/org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph/src/org/eclipse/efm/modeling/codegen/xlia/sdf/polygraph/mocc/ast/feature/MoccActorFeature.java
index ad93e6c..e679c52 100644
--- a/codegen/org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph/src/org/eclipse/efm/modeling/codegen/xlia/sdf/polygraph/mocc/ast/feature/MoccActorFeature.java
+++ b/codegen/org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph/src/org/eclipse/efm/modeling/codegen/xlia/sdf/polygraph/mocc/ast/feature/MoccActorFeature.java
@@ -27,6 +27,9 @@
 
 	public final boolean isTimed;
 
+	// Normalized Frequency s.t. gcd( all frequencies ) == 1

+	public int omegaFrequency;

+

 	public final boolean isRegular;
 
 	public double inferredFrequency;
@@ -86,6 +89,9 @@
 
 		this.isTimed = actor.getFrequency() > 0;
 
+		// Could be minimized by System.FEATURE constructor

+		this.omegaFrequency = actor.getFrequency();

+

 		this.inferredFrequency = actor.getFrequency();
 
 		this.isRegular = ! (this.isModeSelector || this.isModeProcessor);
@@ -192,7 +198,7 @@
 	public void computeActivation(final MoccSystemFeature moccSystemFeature) {
 		this.isExecutable = (this.repetition > 0) && hasInteraction;
 
-		this.activation = new boolean[ moccSystemFeature.tick_period ];

+		this.activation = new boolean[ moccSystemFeature.hyperperiod ];

 
 		if( isTimed && consistency ) {
 			final int period = this.activation.length / Math.abs(this.repetition);
diff --git a/codegen/org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph/src/org/eclipse/efm/modeling/codegen/xlia/sdf/polygraph/mocc/ast/feature/MoccSystemFeature.java b/codegen/org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph/src/org/eclipse/efm/modeling/codegen/xlia/sdf/polygraph/mocc/ast/feature/MoccSystemFeature.java
index d3683da..93932d2 100644
--- a/codegen/org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph/src/org/eclipse/efm/modeling/codegen/xlia/sdf/polygraph/mocc/ast/feature/MoccSystemFeature.java
+++ b/codegen/org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph/src/org/eclipse/efm/modeling/codegen/xlia/sdf/polygraph/mocc/ast/feature/MoccSystemFeature.java
@@ -62,9 +62,19 @@
 	public final int[] allFrequencies;
 	public final int[] exeFrequencies;
 
-	public final int time_interval;

-	public final int time_period;

-	public final int tick_period;
+	// Normalized Frequencies s.t. gcd( all frequencies ) == 1

+	public final int[] exeOmagaFrequencies;
+

+

+	public final int tick_frequency; // gcd( Executable Actor Frequencies )

+

+//	public final int time_period;    // lcm( Executable Actor Frequencies )

+

+	public final int period;         // lcm( Executable Actor Omega_Frequencies )

+	public final int hyperperiod;    // minimal multiple of period for liveness

+

+	public final int tick_step;

+//	public final int tick_period;

 
 	private int scheduledStageCount;
 
@@ -98,6 +108,8 @@
 		final Set< Integer > allFrequencies = new HashSet<Integer>();
 		final Set< Integer > exeFrequencies = new HashSet<Integer>();
 
+		boolean hasIsolatedTimedActor = false;
+

 		assert (! system.getActor().isEmpty()) :

 			"Unexpected a MoccSystem without actor";

 

@@ -133,6 +145,9 @@
 				if( actor.FEATURE.hasInteraction ) {
 					exeFrequencies.add(actor.getFrequency());
 				}
+				else {

+					hasIsolatedTimedActor = true;

+				}

 			}
 
 			hasRegular = hasRegular || actor.FEATURE.isRegular;
@@ -216,7 +231,7 @@
 			this.allFrequencies[offset++] = frequency;
 		}
 
-		if( (phaseActorCount == 0) && (this.allFrequencies.length > 0) ) {
+		if( hasIsolatedTimedActor ) {
 			this.exeFrequencies = new int[exeFrequencies.size()];
 			offset = 0;
 			for( final Integer frequency : exeFrequencies ) {
@@ -227,21 +242,54 @@
 			this.exeFrequencies = this.allFrequencies;
 		}
 
-		if( this.exeFrequencies.length > 1 ) {
-			this.time_interval = gcd( this.exeFrequencies );

-			this.time_period   = lcm( this.exeFrequencies );

-			this.tick_period   = time_period / time_interval;

-		}
-		else if( this.exeFrequencies.length == 1 ) {
-			this.time_interval = this.exeFrequencies[0];

-			this.time_period   = this.exeFrequencies[0];

-			this.tick_period   = 1;

+		// Minimize ime unit for all executable frequencies
+		final int gcdExecFrequencies = gcd( this.exeFrequencies );
+		if( gcdExecFrequencies > 1 ) {
+			this.exeOmagaFrequencies = new int[ this.exeFrequencies.length ];
+
+			offset = 0;
+			for( final int frequency : this.exeFrequencies ) {
+				this.exeOmagaFrequencies[offset++] =
+						(frequency / gcdExecFrequencies);
+			}
+
+			for( final MoccActor actor : system.getActor() ) {
+				if( actor.FEATURE.isTimed && actor.FEATURE.hasInteraction )
+				{
+					actor.FEATURE.omegaFrequency =
+							actor.frequency / gcdExecFrequencies;
+				}
+				else {
+					actor.FEATURE.omegaFrequency = -1;
+				}
+			}
 		}
 		else {
-			this.time_interval = 1;

-			this.time_period   = 1;

-			this.tick_period   = this.scheduledStageCount + 1;

-//		IntStream.of( this.repetitions ).sum() + 1 - system.getActor().size();

+			this.exeOmagaFrequencies = this.exeFrequencies;
+		}
+
+		this.tick_step   = 1;
+
+		if( this.exeFrequencies.length > 1 ) {
+			this.tick_frequency = gcdExecFrequencies;
+
+			this.period      = lcm( this.exeOmagaFrequencies );
+			this.hyperperiod = computeHyperperiod();  // i.e. ratio * period
+		}
+		else if( this.exeFrequencies.length == 1 ) {
+			this.tick_frequency = this.exeFrequencies[0];
+
+			this.period      = 1;
+			this.hyperperiod = 1;
+		}
+		else {
+			this.tick_frequency = 1;
+
+			this.period = this.scheduledStageCount + 1;
+
+			this.hyperperiod = this.period;
+
+//			IntStream.of( this.repetitions ).sum() + 1 - system.getActor().size();
 		}
 
 		// For non-conex graph
@@ -264,19 +312,24 @@
 		final StringBuilder sout = new StringBuilder(
 				Arrays.toString(exeFrequencies));
 
+		if( this.exeFrequencies != this.exeOmagaFrequencies ) {

+			sout.append( " - MINIMIZED - " )

+				.append( Arrays.toString(exeOmagaFrequencies) );

+		}

+

 		if( this.exeFrequencies != this.allFrequencies ) {
 			final HashSet<Integer> execFreq = new HashSet<Integer>();
 			for (final Integer freq : this.exeFrequencies) {
 				execFreq.add(freq);
 			}
 
-			sout.append(" -- [");
+			sout.append(" -- OTHER -- {");

 			for (final Integer freq : this.allFrequencies) {
 				if( ! execFreq.contains(freq) ) {
 					sout.append(" ").append(freq);
 				}
 			}
-			sout.append(" ]");
+			sout.append(" }");

 		}
 
 		return sout.toString();
@@ -466,14 +519,69 @@
 		}
 	}
 
+

+	private int computeHyperperiod() {

+		for( final MoccActor actor : rationals.keySet() ) {

+			if( actor.FEATURE.isTimed && actor.FEATURE.hasInteraction

+				&& (actor.FEATURE.repetition != actor.FEATURE.omegaFrequency) )

+//						(actor.getFrequency() / this.tick_frequency)) )

+			{

+				return( (this.period * actor.FEATURE.repetition)

+						/ actor.FEATURE.omegaFrequency );

+			}

+		}

+

+		return this.period;

+	}

+

+

+//	public boolean checkTimeConsistency(final MoccActor actor) {
+//
+//		return (! actor.FEATURE.isTimed)
+//				|| ((actor.FEATURE.repetition * this.period) !=
+//					(actor.FEATURE.omegaFrequency * this.hyperperiod));
+//	}
+//
+//	public boolean checkPhaseConsistency(final MoccActor actor) {
+//
+//		return (! actor.FEATURE.isTimed)
+//				|| (actor.getPhase() < (this.period / actor.FEATURE.omegaFrequency));
+//	}
+
+	public String inconsistencyReason(final MoccActor actor) {
+		if( actor.FEATURE.isTimed ) {
+			final int ratio = (this.hyperperiod / this.period);
+
+			if( actor.FEATURE.repetition != (actor.FEATURE.omegaFrequency * ratio) )
+			{
+				return "inconsistent< repetition:" + actor.FEATURE.repetition
+						+ " != (frequency:" + actor.getFrequency()
+						+ " / tick_freq:" + this.tick_frequency + "): "
+						+ actor.FEATURE.omegaFrequency + " >";
+			}
+			else if( actor.getPhase() >= (this.hyperperiod / actor.getFrequency()) )
+			{
+				return "inconsistent< phase:" + actor.getPhase()
+						+ " >= (hyperperiod:" + (this.hyperperiod * this.tick_frequency)
+						+ " / frequency:" + actor.getFrequency() + "): "
+						+ this.period / actor.FEATURE.omegaFrequency + " >";
+			}
+		}
+
+		return "inconsistent< ? >";
+	}
+
 	private boolean checkConsistency() {
 		boolean consistency = true;
+
+		final int ratio = (this.hyperperiod / this.period);
 		for( final MoccActor actor : rationals.keySet() ) {
-			actor.FEATURE.consistency = (! actor.FEATURE.isTimed) 
+			actor.FEATURE.consistency = (! actor.FEATURE.isTimed)
 				|| (! actor.FEATURE.hasInteraction)
-				|| ((actor.FEATURE.repetition ==
-						(actor.getFrequency() / this.time_interval))

-					&& (actor.getPhase() < (this.time_period / actor.getFrequency())));

+				|| ( ( actor.FEATURE.repetition ==
+							(actor.FEATURE.omegaFrequency * ratio) )
+					&& (actor.getPhase() <
+						(this.period / actor.FEATURE.omegaFrequency)));
 
 			consistency &= actor.FEATURE.consistency;
 		}
diff --git a/codegen/org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph/src/org/eclipse/efm/modeling/codegen/xlia/sdf/polygraph/mocc/helper/MoccActorHelper.java b/codegen/org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph/src/org/eclipse/efm/modeling/codegen/xlia/sdf/polygraph/mocc/helper/MoccActorHelper.java
index f41294d..2894a6c 100644
--- a/codegen/org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph/src/org/eclipse/efm/modeling/codegen/xlia/sdf/polygraph/mocc/helper/MoccActorHelper.java
+++ b/codegen/org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph/src/org/eclipse/efm/modeling/codegen/xlia/sdf/polygraph/mocc/helper/MoccActorHelper.java
@@ -14,9 +14,9 @@
 
 import org.eclipse.efm.ecore.formalml.datatype.EnumerationLiteral;
 import org.eclipse.efm.ecore.formalml.datatype.EnumerationType;
+import org.eclipse.efm.ecore.formalml.infrastructure.Machine;
 import org.eclipse.efm.ecore.formalml.infrastructure.Routine;
 import org.eclipse.efm.ecore.formalml.infrastructure.Variable;
-import org.eclipse.efm.ecore.formalml.statemachine.Statemachine;
 import org.eclipse.efm.formalml.ecore.factory.XLIA_DATATYPE;
 import org.eclipse.efm.formalml.ecore.factory.XLIA_EXPRESSION;
 import org.eclipse.efm.formalml.ecore.factory.XLIA_INFRA;
@@ -26,7 +26,7 @@
 
 	public final MoccActor actor;
 
-	public final Statemachine statemachine;
+	public final Machine machine;

 
 	public Variable constFREQUENCY;
 	public Variable constREPETITION;
@@ -69,12 +69,10 @@
 //	public Routine macroActivationPassTest;
 
 
-
-	public MoccActorHelper(
-			final MoccActor actor, final Statemachine statemachine) {
+	public MoccActorHelper(final MoccActor actor, final Machine machine) {

 		super();
 		this.actor = actor;
-		this.statemachine = statemachine;
+		this.machine = machine;

 
 		this.constFREQUENCY  = null;
 		this.constREPETITION = null;
@@ -130,7 +128,7 @@
 
 
 	public void declareConstantsVariables(
-			final Statemachine xliaActor,
+			final Machine xliaActor,
 			final EnumerationType MODE_SET_TYPE,
 			final EnumerationLiteral MODE_NOMINAL,
 			final boolean ALWAYS_USING_MODE)
@@ -213,7 +211,7 @@
 	////////////////////////////////////////////////////////////////////////////
 	// Variable Declaration for Mode Selector / Processor Actor
 	protected void modeActorDeclaration(
-			final Statemachine xliaActor,
+			final Machine xliaActor,
 			final EnumerationType MODE_SET_TYPE,
 			final EnumerationLiteral MODE_NOMINAL,
 			final boolean ALWAYS_USING_MODE)
@@ -266,7 +264,7 @@
 
 
 	protected void selectorActorDeclaration(
-			final Statemachine xliaActor, final EnumerationType MODE_SET_TYPE)
+			final Machine xliaActor, final EnumerationType MODE_SET_TYPE)
 	{
 		// CONSTANT - TYPE : SELECTION SET
 		this.modeSelectionSet = modeLiterals(

@@ -278,7 +276,7 @@
 	}
 
 	protected void processorActorDeclaration(
-			final Statemachine xliaActor, final EnumerationType MODE_SET_TYPE)
+			final Machine xliaActor, final EnumerationType MODE_SET_TYPE)
 	{
 		// CONSTANT - TYPE : PROCESSING SET
 		this.modeProcessingSet = modeLiterals(MODE_SET_TYPE,
diff --git a/codegen/org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph/src/org/eclipse/efm/modeling/codegen/xlia/sdf/polygraph/mocc/helper/MoccPortHelper.java b/codegen/org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph/src/org/eclipse/efm/modeling/codegen/xlia/sdf/polygraph/mocc/helper/MoccPortHelper.java
index b41899f..7e2afe3 100644
--- a/codegen/org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph/src/org/eclipse/efm/modeling/codegen/xlia/sdf/polygraph/mocc/helper/MoccPortHelper.java
+++ b/codegen/org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph/src/org/eclipse/efm/modeling/codegen/xlia/sdf/polygraph/mocc/helper/MoccPortHelper.java
@@ -18,9 +18,9 @@
 import org.eclipse.efm.ecore.formalml.datatype.EnumerationType;
 import org.eclipse.efm.ecore.formalml.expression.Expression;
 import org.eclipse.efm.ecore.formalml.infrastructure.ChannelDirection;
+import org.eclipse.efm.ecore.formalml.infrastructure.Machine;
 import org.eclipse.efm.ecore.formalml.infrastructure.Port;
 import org.eclipse.efm.ecore.formalml.infrastructure.Variable;
-import org.eclipse.efm.ecore.formalml.statemachine.Statemachine;
 import org.eclipse.efm.ecore.formalml.statement.BlockStatement;
 import org.eclipse.efm.ecore.formalml.statement.IfStatement;
 import org.eclipse.efm.formalml.ecore.factory.XLIA_DATATYPE;
@@ -181,7 +181,7 @@
 	 */
 	public Port createPortToken(final String name,
 			final MoccPort moccPort, final ChannelDirection direction,
-			final Statemachine xliaActor, final DataType tokenType)
+			final Machine xliaActor, final DataType tokenType)
 	{
 		final String prefix =
 				(direction == ChannelDirection.INPUT) ? "received": "sent";
@@ -200,7 +200,7 @@
 
 	public Port createPortToken(
 			final MoccPort moccPort, final ChannelDirection direction,
-			final Statemachine xliaActor, final DataType tokenType)
+			final Machine xliaActor, final DataType tokenType)
 	{
 		return createPortToken(moccPort.getName(),
 				moccPort, direction, xliaActor, tokenType);
@@ -216,7 +216,7 @@
 	 * @return
 	 */
 	public Port createPortTokenMode(final String name, final MoccPort moccPort,
-			final ChannelDirection direction, final Statemachine xliaActor,
+			final ChannelDirection direction, final Machine xliaActor,
 			final DataType tokenType, final DataType modeType)
 	{
 		final String prefix =
@@ -235,7 +235,7 @@
 	}
 
 	public Port createPortTokenMode(final MoccPort moccPort,
-			final ChannelDirection direction, final Statemachine xliaActor,
+			final ChannelDirection direction, final Machine xliaActor,
 			final DataType tokenType, final DataType modeType)
 	{
 		return createPortTokenMode(moccPort.getName(),
@@ -251,7 +251,7 @@
 	 * @param xliaActor
 	 * @param aLWAYS_USING_MODE
 	 */
-	public void createOutputPort(final Statemachine xliaActor,
+	public void createOutputPort(final Machine xliaActor,
 			final EnumerationType MODE_SET_TYPE, final boolean ALWAYS_USING_MODE)
 	{
 		// CONSTANT: TOKEN PRODUCTION
@@ -289,12 +289,12 @@
 			final DataType modeType =
 					XLIA_DATATYPE.createReference(MODE_SET_TYPE);
 
-			this.xliaPort = createPortTokenMode("out#" + 

+			this.xliaPort = createPortTokenMode("out#" +

 					moccPort.getChannel().getName(), moccPort,
 					ChannelDirection.OUTPUT, xliaActor, tokenType, modeType);
 		}
 		else {
-			this.xliaPort = createPortToken("out#" + 

+			this.xliaPort = createPortToken("out#" +

 					moccPort.getChannel().getName(),
 					moccPort, ChannelDirection.OUTPUT, xliaActor, tokenType);
 		}
@@ -307,7 +307,7 @@
 	 * @param xliaActor
 	 * @param aLWAYS_USING_MODE
 	 */
-	public void createInputPort(final Statemachine xliaActor,
+	public void createInputPort(final Machine xliaActor,
 			final EnumerationType MODE_SET_TYPE, final boolean ALWAYS_USING_MODE,
 			final boolean generatedChannelPort)
 	{
@@ -410,7 +410,7 @@
 					ChannelDirection.INPUT, xliaActor, portTokenType);
 
 			if( generatedChannelPort ) {
-				this.xliaChannelPort = createPortToken("in#" + 

+				this.xliaChannelPort = createPortToken("in#" +

 						moccPort.getChannel().getName(), moccPort,
 //						ChannelDirection.INPUT, xliaActor, channelTokenType);
 						ChannelDirection.OUTPUT, xliaActor, channelTokenType);
diff --git a/codegen/org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph/src/org/eclipse/efm/modeling/codegen/xlia/sdf/polygraph/mocc/xlia/Generator.java b/codegen/org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph/src/org/eclipse/efm/modeling/codegen/xlia/sdf/polygraph/mocc/xlia/Generator.java
index 6e614ab..61493fc 100644
--- a/codegen/org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph/src/org/eclipse/efm/modeling/codegen/xlia/sdf/polygraph/mocc/xlia/Generator.java
+++ b/codegen/org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph/src/org/eclipse/efm/modeling/codegen/xlia/sdf/polygraph/mocc/xlia/Generator.java
@@ -14,8 +14,6 @@
 

 import java.io.FileWriter;

 import java.io.IOException;

-import java.io.PrintWriter;

-import java.util.Arrays;

 

 import org.eclipse.core.resources.IResource;

 import org.eclipse.core.resources.ResourcesPlugin;

@@ -26,6 +24,7 @@
 import org.eclipse.efm.formalml.ecore.factory.XLIAGenerator;

 import org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph.mocc.ast.MoccActor;

 import org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph.mocc.ast.MoccSystem;

+import org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph.util.PrettyPrintWriter;

 

 public class Generator {

 

@@ -40,10 +39,9 @@
 		if ( moccSystem != null ) {

 			// Transform MoCC AST to xLIA Model

 			final MoCC2XLIA mocc2xlia =

-					new MoCC2XLIA(moccSystem, conformance, traceGeneration);

-			mocc2xlia.transform();

+					new MoCC2XLIA(conformance, traceGeneration);

 

-			return mocc2xlia.xliaModel;

+			return mocc2xlia.transformSystem(moccSystem);

 		}

 

 		return null;

@@ -53,11 +51,9 @@
 	public static void transformModel(

 			final IPath path, final MoccSystem moccSystem)

 	{

-		final MoCC2XLIA moccGenerator = new MoCC2XLIA(moccSystem, false, false);

+		final MoCC2XLIA mocc2xlia = new MoCC2XLIA(false, false);

 

-		moccGenerator.transform();

-

-		final XliaModel xliaModel = moccGenerator.xliaModel;

+		final XliaModel xliaModel = mocc2xlia.transformSystem(moccSystem);

 

 		final IPath filePath =

 				path.append(moccSystem.getName()).addFileExtension("xlia");

@@ -74,26 +70,27 @@
 			final MoccSystem moccSystem, final XliaModel xliaModel)

 	{

 		try {

-			final FileWriter buffer = new FileWriter( path.toOSString() );

-			final PrintWriter writer = new PrintWriter(buffer);

+			final FileWriter fileWriter = new FileWriter( path.toOSString() );

+

+			final PrettyPrintWriter ppwr = new PrettyPrintWriter(fileWriter);

 

 			final CharSequence strXLIA =

 					XLIAGenerator.generateModel(xliaModel);

 

-			writer.write("\n/*\n");

+			// MoCC ABSTRACT

+			ppwr.appendEol_Eol("/*");

+			moccSystem.toAbstract(ppwr);

+			ppwr.appendEol_Eol2("*/");

 

-			writer.write(moccSystem.toAbstract());

+			// XLIA

+			ppwr.append(strXLIA.toString());

 

-			writer.write("\n*/\n\n");

+			// MoCC

+			ppwr.appendEol_Eol("/*");

+			moccSystem.toWriter(ppwr);

+			ppwr.appendEol_Eol("*/");

 

-			writer.write(strXLIA.toString());

-

-			writer.write("\n/*\n");

-

-			writer.write(moccSystem.toString());

-			writer.write("\n*/\n");

-

-			writer.close();

+			ppwr.close();

 

 		} catch (final IOException e) {

 			e.printStackTrace();

@@ -103,52 +100,36 @@
 	public static void write(final IPath path, final MoccSystem moccSystem)

 	{

 		try {

-			final FileWriter buffer = new FileWriter( path.toOSString() );

-			final PrintWriter writer = new PrintWriter(buffer);

+			final FileWriter fileWriter = new FileWriter( path.toOSString() );

 

-			final StringBuilder sout = new StringBuilder();

-			sout.append("\n/*\n")

-				.append("==> INCONSISTENT MoccSystem <==\n");

+			final PrettyPrintWriter ppwr = new PrettyPrintWriter(fileWriter);

 

-			sout.append("system ").append(moccSystem.getName())

-				.append(" {").append('\n');

-			

+			ppwr.appendEol_Eol("/*")

+				.appendEol("==> INCONSISTENT MoccSystem <==");

+

+			moccSystem.toAbstract(ppwr).appendEol();

+

 			if( moccSystem.FEATURE != null ) {

-				sout.append('\t').append("frequencies = " )

-					.append(Arrays.toString(

-							moccSystem.FEATURE.exeFrequencies)).append('\n')

-					.append('\t').append("time = +")

-						.append(moccSystem.FEATURE.time_interval)

-						.append('\n')

-					.append('\t').append("period = ")

-						.append(moccSystem.FEATURE.time_period)

-						.append('\n')

-					.append('\t').append("repetition = ")

-						.append(Arrays.toString(moccSystem.FEATURE.repetitions))

-						.append('\n')

-					.append('}').append('\n');

-			}

-			for( final MoccActor actor : moccSystem.getActor() ) {

-				if( (actor.FEATURE != null) && (! actor.FEATURE.consistency) ) {

-					sout.append("Inconsistent actor ")

-						.append(actor.getName()).append(" {").append('\n')

-						.append('\t').append("frequency = ")

-							.append(actor.getFrequency()).append('\n')

-						.append('\t').append("phase = ")

-							.append(actor.getPhase()).append('\n')

-						.append('\t').append("repetition = ")

-							.append(actor.FEATURE.repetition).append('\n')

-						.append('}').append('\n');

+				for( final MoccActor actor : moccSystem.getActor() ) {

+					if( (actor.FEATURE != null) && (! actor.FEATURE.consistency) ) {

+						ppwr.append(moccSystem.FEATURE.inconsistencyReason(actor))

+							.appendTab(" actor ")

+							.append(actor.getName()).appendEol(" {")

+							.appendTab2("frequency = ")

+								.appendEol(actor.getFrequency())

+							.appendTab2("phase = ")

+								.appendEol(actor.getPhase())

+							.appendTab2("repetition = ")

+								.appendEol(actor.FEATURE.repetition)

+							.appendEol('}');

+					}

 				}

 			}

-			sout.append('\n');

+			ppwr.appendEol();

 

-			writer.write(sout.toString());

+			moccSystem.toWriter(ppwr).appendEol_Eol("*/");

 

-			writer.write(moccSystem.toString());

-			writer.write("\n*/\n");

-

-			writer.close();

+			ppwr.close();

 

 		} catch (final IOException e) {

 			e.printStackTrace();

diff --git a/codegen/org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph/src/org/eclipse/efm/modeling/codegen/xlia/sdf/polygraph/mocc/xlia/MoCC2XLIA.java b/codegen/org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph/src/org/eclipse/efm/modeling/codegen/xlia/sdf/polygraph/mocc/xlia/MoCC2XLIA.java
index b823125..e375e04 100644
--- a/codegen/org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph/src/org/eclipse/efm/modeling/codegen/xlia/sdf/polygraph/mocc/xlia/MoCC2XLIA.java
+++ b/codegen/org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph/src/org/eclipse/efm/modeling/codegen/xlia/sdf/polygraph/mocc/xlia/MoCC2XLIA.java
@@ -19,11 +19,9 @@
 import org.eclipse.efm.ecore.formalml.datatype.EnumerationLiteral;
 import org.eclipse.efm.ecore.formalml.datatype.EnumerationType;
 import org.eclipse.efm.ecore.formalml.expression.Expression;
-import org.eclipse.efm.ecore.formalml.expression.RelationalBinaryExpression;
 import org.eclipse.efm.ecore.formalml.infrastructure.Behavior;
 import org.eclipse.efm.ecore.formalml.infrastructure.Connector;
 import org.eclipse.efm.ecore.formalml.infrastructure.Machine;
-import org.eclipse.efm.ecore.formalml.infrastructure.ModelOfExecution;
 import org.eclipse.efm.ecore.formalml.infrastructure.ModelOfInteraction;
 import org.eclipse.efm.ecore.formalml.infrastructure.Parameter;
 import org.eclipse.efm.ecore.formalml.infrastructure.ParameterSet;
@@ -55,6 +53,8 @@
 
 public class MoCC2XLIA {
 
+	protected boolean IS_ROOT_SYSTEM;

+

 	protected boolean CONFORMANCE_PURPOSE;
 
 	protected boolean TRACE_GENERATION_PURPOSE;
@@ -68,17 +68,15 @@
 
 	public Map< MoccPort , MoccPortHelper > portHelper;
 
-	public MoccSystem moccSystem;
+	public Machine xliaMainMachine;

 
-	public XliaModel xliaModel;
-
-	public XliaSystem xliaSystem;
-	public Behavior mainBehavior;
-
+	public Variable constPeriod; // defined if period =/= hyperperiod

+	public Variable constHyperPeriod;

+

+	public Variable constTickFrequency;

+	public Variable constTickStep;

+

 	public Variable varTick;
-	public Variable varTickPeriod;

-	public Variable varTimeDelta;

-
 	public Variable varTimestamp;
 
 	public Variable varCanBeActivate;
@@ -92,29 +90,31 @@
 	public Routine macroReceiveTokenMode;
 	public Routine macroReceiveTokenDecidingMode;
 
-	public Routine macroJsonTraceHeader;
+//	public Routine macroJsonTraceHeader;

 	public Routine macroJsonTraceBegin;
-	

+

 	public Routine macroJsonTraceTokenBodyHead;

 	public Routine macroJsonTraceTokenBodyTail;

-	

+

 	public Routine macroJsonTraceTokenModeBodyHead;

 	public Routine macroJsonTraceTokenModeBodyTail;

-	

+

 	public Routine macroJsonTraceEnd;
-	public Routine macroJsonTraceFooter;
+//	public Routine macroJsonTraceFooter;

 
 
 	protected MoCC2XLIASchedule schedulerGenerator;
 
 
-	public MoCC2XLIA(final MoccSystem moccSystem,
-			final boolean conformance, final boolean traceGeneration) {
+	public MoCC2XLIA(final boolean conformance, final boolean traceGeneration)

+	{

+		this.IS_ROOT_SYSTEM = true;

+

 		this.CONFORMANCE_PURPOSE = conformance;
 
 		this.TRACE_GENERATION_PURPOSE = traceGeneration;

 

-		PRODUCE_SYMBOLIC_MODE = (! this.CONFORMANCE_PURPOSE);

+		MoCC2XLIA.PRODUCE_SYMBOLIC_MODE = (! this.CONFORMANCE_PURPOSE);

 

 		this.ALWAYS_USING_MODE = true;

 
@@ -122,18 +122,15 @@
 
 		this.portHelper  = new HashMap<MoccPort , MoccPortHelper >();
 
-		this.moccSystem = moccSystem;
+		this.xliaMainMachine = null;

 
-		this.xliaModel = null;
-
-		this.xliaSystem = null;
-
-		this.mainBehavior = null;
-
+		this.constPeriod = null;

+		this.constHyperPeriod = null;

+

+		this.constTickFrequency = null;

+		this.constTickStep = null;

+

 		this.varTick         = null;
-		this.varTickPeriod   = null;
-		this.varTimeDelta = null;

-
 		this.varTimestamp    = null;
 
 		this.varCanBeActivate = null;
@@ -146,22 +143,70 @@
 		this.macroReceiveTokenMode = null;
 		this.macroReceiveTokenDecidingMode = null;
 
-		this.macroJsonTraceHeader  = null;
+//		this.macroJsonTraceHeader  = null;

 		this.macroJsonTraceBegin   = null;
-		

+

 		this.macroJsonTraceTokenBodyHead     = null;

 		this.macroJsonTraceTokenBodyTail     = null;

 		this.macroJsonTraceTokenModeBodyHead = null;

 		this.macroJsonTraceTokenModeBodyTail = null;

-		

+

 		this.macroJsonTraceEnd     = null;
-		this.macroJsonTraceFooter  = null;
+//		this.macroJsonTraceFooter = null;

 
-		schedulerGenerator = new MoCC2XLIASchedule(this);
+		schedulerGenerator = null;

 	}
 
-	public MoCC2XLIA(final MoccSystem moccSystem) {
-		this(moccSystem, true, false);
+	public MoCC2XLIA(final MoCC2XLIA mocc2xlia)
+	{
+		this.IS_ROOT_SYSTEM = false;
+
+		this.CONFORMANCE_PURPOSE = mocc2xlia.CONFORMANCE_PURPOSE;
+
+		this.TRACE_GENERATION_PURPOSE = mocc2xlia.TRACE_GENERATION_PURPOSE;
+
+//		PRODUCE_SYMBOLIC_MODE = mocc2xlia.PRODUCE_SYMBOLIC_MODE; // static property
+
+		this.ALWAYS_USING_MODE = true;
+
+		this.actorHelper = new HashMap<MoccActor, MoccActorHelper>();
+
+		this.portHelper  = new HashMap<MoccPort , MoccPortHelper >();
+
+		this.xliaMainMachine = null;
+
+		this.constPeriod = null;

+		this.constHyperPeriod = null;

+

+		this.constTickFrequency = null;

+		this.constTickStep = null;

+

+		this.varTick       = null;
+		this.varTimestamp  = null;

+
+
+		this.varCanBeActivate = null;
+
+		this.MODE_SET_TYPE  = mocc2xlia.MODE_SET_TYPE;
+		this.MODE_NOMINAL   = mocc2xlia.MODE_NOMINAL;
+		this.MODE_UNDEFINED = mocc2xlia.MODE_UNDEFINED;
+
+		this.macroReceiveToken     = mocc2xlia.macroReceiveToken;
+		this.macroReceiveTokenMode = mocc2xlia.macroReceiveTokenMode;
+		this.macroReceiveTokenDecidingMode = mocc2xlia.macroReceiveTokenDecidingMode;
+
+//		this.macroJsonTraceHeader  = mocc2xlia.macroJsonTraceHeader;
+		this.macroJsonTraceBegin   = mocc2xlia.macroJsonTraceBegin;
+
+		this.macroJsonTraceTokenBodyHead     = mocc2xlia.macroJsonTraceTokenBodyHead;
+		this.macroJsonTraceTokenBodyTail     = mocc2xlia.macroJsonTraceTokenBodyTail;
+		this.macroJsonTraceTokenModeBodyHead = mocc2xlia.macroJsonTraceTokenModeBodyHead;
+		this.macroJsonTraceTokenModeBodyTail = mocc2xlia.macroJsonTraceTokenModeBodyTail;
+
+		this.macroJsonTraceEnd    = mocc2xlia.macroJsonTraceEnd;
+//		this.macroJsonTraceFooter = mocc2xlia.macroJsonTraceFooter;
+
+		schedulerGenerator = null;
 	}
 
 
@@ -174,109 +219,167 @@
 	}
 
 
-	public void transform()
+	public XliaModel transformSystem(final MoccSystem moccSystem)
 	{
 		// Basic static analysis feature
 		final MoccSystemFeature moccSystemFeature =
-				this.moccSystem.computeFeatureStrict();

+				moccSystem.computeFeatureStrict();
 
 		assert (moccSystemFeature.consistency) :
 				"Unexpected a non-consistency MoCC System : " +
-				this.moccSystem.getName();
+				moccSystem.getName();
 
-		if( ! moccSystemFeature.consistency ) {
-			this.xliaModel = null;
-			this.xliaSystem = null;
+		if( moccSystemFeature.consistency ) {
+			// For Moka Trace compatibility
+			ALWAYS_USING_MODE = true;//moccSystem.FEATURE.hasModeSelector;
 
-			return;
+			// Transformation to XLIA
+			final XliaModel xliaModel = XLIA_INFRA.createModel();
+
+			final XliaSystem xliaSystem =
+					XLIA_INFRA.createSystem(moccSystem.getName());
+
+			xliaModel.setSystem( xliaSystem );
+
+			this.xliaMainMachine = xliaSystem;
+
+			transform(moccSystem, moccSystemFeature);
+
+			return xliaModel;
 		}
+		else {
+			return null;
+		}
+	}
 
-

-		// For Moka Trace compatibility

-		ALWAYS_USING_MODE = false; //moccSystem.FEATURE.hasModeSelector;

-

-

-		// Transformation to XLIA
-		this.xliaModel = XLIA_INFRA.createModel();
-		this.xliaSystem = XLIA_INFRA.createSystem(this.moccSystem.getName());
-		this.xliaModel.setSystem( this.xliaSystem );
+	public void transformSubSystem(
+			final MoccActor moccActor, final Machine xliaActor)
+	{
+		final MoccSystem subSystem = moccActor.getSubSystem();
+		if( subSystem != null ) {
+			// Basic static analysis feature
+			final MoccSystemFeature moccSystemFeature =
+					subSystem.computeFeatureStrict();
 
-		if( ALWAYS_USING_MODE || moccSystemFeature.hasModeProcessor ) {
+			assert (moccSystemFeature.consistency) :
+					"Unexpected a non-consistency MoCC System : " +
+					subSystem.getName();
+
+			if( moccSystemFeature.consistency ) {
+				// For Moka Trace compatibility
+				ALWAYS_USING_MODE = true;//moccSystem.FEATURE.hasModeSelector;
+
+				// Transformation to XLIA
+				this.xliaMainMachine = xliaActor;
+
+				transform(subSystem, moccSystemFeature);
+			}
+		}
+	}
+
+	protected void transform(final MoccSystem moccSystem,
+			final MoccSystemFeature moccSystemFeature)
+	{
+		// For Moka Trace compatibility
+		ALWAYS_USING_MODE = true;//moccSystem.FEATURE.hasModeSelector;
+
+		if( (ALWAYS_USING_MODE || moccSystemFeature.hasModeProcessor)
+			&& (this.MODE_SET_TYPE == null) )
+		{
 			// MODE SET TYPE
-			this.MODE_SET_TYPE = XLIA_DATATYPE.addEnum(xliaSystem,
-					"MODE_SET", this.moccSystem.getModeLiterals());
+			this.MODE_SET_TYPE = XLIA_DATATYPE.addEnum(this.xliaMainMachine,
+					"MODE_SET", moccSystem.getModeLiterals());
 
 			// VALUE: NOMINAL - UNDEFINED - MODE
 			this.MODE_NOMINAL = XLIA_DATATYPE.getEnumLiteral(
-					this.MODE_SET_TYPE, this.moccSystem.NOMINAL.getLiteral());
+					this.MODE_SET_TYPE, moccSystem.NOMINAL.getLiteral());
 
 			this.MODE_UNDEFINED =  XLIA_DATATYPE.getEnumLiteral(
-					this.MODE_SET_TYPE, this.moccSystem.UNDEFINED.getLiteral());
+					this.MODE_SET_TYPE, moccSystem.UNDEFINED.getLiteral());
 
 			// MACRO ROUTINES
 			this.macroReceiveTokenMode =
-					createReceiveTokenModeRoutine(this.xliaSystem);
+					createReceiveTokenModeRoutine(this.xliaMainMachine);
 
 			this.macroReceiveTokenDecidingMode =
-					createReceiveTokenDecidingModeRoutine(this.xliaSystem);
+					createReceiveTokenDecidingModeRoutine(this.xliaMainMachine);
 		}
 
 		// MACRO ROUTINES
-		this.macroReceiveToken = createReceiveTokenRoutine(this.xliaSystem);
+		if( this.IS_ROOT_SYSTEM ) {
+			this.macroReceiveToken = createReceiveTokenRoutine(this.xliaMainMachine);
+		}
 
 
 		// TIME CONFIGURATION
-		this.varTimeDelta = XLIA_INFRA.createConstant(

-				XLIA_DATATYPE.createInteger(), "TIME_DELTA",

-				XLIA_EXPRESSION.createInteger(

-						moccSystemFeature.time_interval));

-		this.xliaSystem.getVariable().add(this.varTimeDelta);

-
-		this.varTickPeriod = XLIA_INFRA.createConstant(
-				XLIA_DATATYPE.createInteger(), "TICK_PERIOD",
+		this.constTickFrequency = XLIA_INFRA.createConstant(
+				XLIA_DATATYPE.createInteger(), "TICK_FREQUENCY",
 				XLIA_EXPRESSION.createInteger(
-						moccSystemFeature.tick_period));
-		this.xliaSystem.getVariable().add(this.varTickPeriod);
+						moccSystemFeature.tick_frequency));
+		this.xliaMainMachine.getVariable().add(this.constTickFrequency);
+
+		this.constTickStep = XLIA_INFRA.createConstant(
+				XLIA_DATATYPE.createInteger(), "TICK_STEP",
+				XLIA_EXPRESSION.createInteger(
+						moccSystemFeature.tick_step));
+		this.xliaMainMachine.getVariable().add(this.constTickStep);
+
+		if( moccSystemFeature.period != moccSystemFeature.hyperperiod ) {
+			this.constPeriod = XLIA_INFRA.createConstant(
+					XLIA_DATATYPE.createInteger(), "PERIOD",
+					XLIA_EXPRESSION.createInteger(
+							moccSystemFeature.period));
+			this.xliaMainMachine.getVariable().add(this.constPeriod);
+		}
+
+		this.constHyperPeriod = XLIA_INFRA.createConstant(
+				XLIA_DATATYPE.createInteger(), "HYPERPERIOD",
+				XLIA_EXPRESSION.createInteger(
+						moccSystemFeature.hyperperiod));
+		this.xliaMainMachine.getVariable().add(this.constHyperPeriod);
 
 		this.varTick = XLIA_INFRA.createLocaleVariable(
 				XLIA_DATATYPE.createInteger(),
 				"tick", XLIA_EXPRESSION.zero());
-		this.xliaSystem.getVariable().add(this.varTick);
+		this.xliaMainMachine.getVariable().add(this.varTick);
 
 		this.varTimestamp = XLIA_INFRA.createLocaleVariable(
 				XLIA_DATATYPE.createInteger(),
 				"timestamp", XLIA_EXPRESSION.zero());
-		this.xliaSystem.getVariable().add(this.varTimestamp);
+		this.xliaMainMachine.getVariable().add(this.varTimestamp);
 
 
 		// GENERAL ENABLED ACTIVATION
 		this.varCanBeActivate = XLIA_INFRA.createLocaleVariable(
 				XLIA_DATATYPE.createBoolean(),
 				"canBeActivate", XLIA_EXPRESSION.trueValue());
-		this.xliaSystem.getVariable().add(this.varCanBeActivate);
+		this.xliaMainMachine.getVariable().add(this.varCanBeActivate);
 
 		// MACRO TRACE ROUTINES
-		if( this.TRACE_GENERATION_PURPOSE ) {
-			createJsonTraceRoutine(this.xliaSystem, moccSystemFeature);

+		if( this.TRACE_GENERATION_PURPOSE && this.IS_ROOT_SYSTEM) {
+			createJsonTraceRoutine(this.xliaMainMachine, moccSystemFeature);
 		}
 
 		// ACTOR TRANSFORMATIONS
-		for (final MoccActor actor : this.moccSystem.getActor()) {
-			this.xliaSystem.getMachine().add(

-					transformActor(actor, moccSystemFeature) );

+		for (final MoccActor actor : moccSystem.getActor()) {
+			this.xliaMainMachine.getMachine().add(
+					transformActor(actor, moccSystemFeature) );
 		}
 
 
 		// MAIN BEHAVIOR
-		this.mainBehavior = XLIA_INFRA.createBehavior();
-		this.xliaSystem.setMain(this.mainBehavior);
+		final Behavior mainBehavior = XLIA_INFRA.createBehavior();
+		this.xliaMainMachine.setMain(mainBehavior);
 
 		// MODEL OF INTERACTION
-		transformChannel();
+		transformChannel(moccSystem, mainBehavior);
 
 		// MODEL OF EXECUTION
+
+		schedulerGenerator =
+				new MoCC2XLIASchedule(this, moccSystem, this.xliaMainMachine);
+
 		schedulerGenerator.compute(moccSystemFeature);
-//		computeScheduler(moccSystemFeature);
 	}
 
 
@@ -310,7 +413,7 @@
 				XLIA_EXPRESSION.createExpression("\n\t\t\t\"tick\": "),
 //						XLIA_EXPRESSION.createExpression(

 //								XLIA_EXPRESSION.OP_MULT,

-//								this.varTick, this.varTimeDelta),

+//								this.varTick, this.constTickStep),

 						XLIA_EXPRESSION.createExpression(this.varTick),
 						XLIA_EXPRESSION.createExpression(","),
 				XLIA_EXPRESSION.createExpression("\n\t\t\t\"timestamp\": "),
@@ -332,7 +435,7 @@
 			this.macroJsonTraceTokenModeBodyHead =

 					createJsonTraceBodyRoutine(

 							machine, "jsonTraceTokenModeBodyHead", "", true);

-	

+

 			this.macroJsonTraceTokenModeBodyTail =

 					createJsonTraceBodyRoutine(

 							machine, "jsonTraceTokenModeBodyTail", ",", true);

@@ -340,7 +443,7 @@
 		else {

 			this.macroJsonTraceTokenBodyHead = createJsonTraceBodyRoutine(

 					machine, "jsonTraceTokenBodyHead", "", false);

-	

+

 			this.macroJsonTraceTokenBodyTail = createJsonTraceBodyRoutine(

 					machine, "jsonTraceTokenBodyTail", ",", false);

 
@@ -382,10 +485,13 @@
 		final BlockStatement block =
 				XLIA_STATEMENT.createBlockStatement();
 
-		final BlockStatement thenBlock = XLIA_STATEMENT.addIfThen(block,
+		final IfStatement ifStatement = XLIA_STATEMENT.addIf(block,

 				XLIA_EXPRESSION.createRelational(XLIA_EXPRESSION.OP_GT,
 						tokenCount, XLIA_EXPRESSION.zero()));
 
+		final BlockStatement thenBlock =

+				XLIA_STATEMENT.createBlockStatement(ifStatement);

+

 		final MetaStatement traceStatement = XLIA_STATEMENT.addTrace(thenBlock,
 				XLIA_EXPRESSION.createExpression(traceSeparator + "\n\t\t\t\t{"),
 				XLIA_EXPRESSION.createExpression("\n\t\t\t\t\t\"channel\": \""),
@@ -420,6 +526,13 @@
 		traceStatement.getOperand().add(
 				XLIA_EXPRESSION.createExpression("\n\t\t\t\t}"));
 
+

+		final BlockStatement elseBlock =

+				XLIA_STATEMENT.createElseBlockStatement(ifStatement);

+

+		XLIA_STATEMENT.addTrace(elseBlock,

+				XLIA_EXPRESSION.createExpression(traceSeparator + "\n\t\t\t\t{}") );

+

 		return XLIA_INFRA.createMacroRoutine(
 				machine, routineName, parameterSet, block);
 	}
@@ -644,109 +757,138 @@
 
 
 
-	public Statemachine transformActor(

+	public Machine transformActor(

 			final MoccActor actor, final MoccSystemFeature moccSystemFeature)

 	{
-		// Basic static analysis feature
-		final Statemachine xliaActor =
-				XLIA_STATEMACHINE.createStatemachine(actor.getName());
-
-		actorHelper.put(actor, new MoccActorHelper(actor, xliaActor));
-
-		final MoccActorHelper actorHELPER = helper(actor);
-
-		// CONSTANTS & VARIABLES
-		actorHELPER.declareConstantsVariables(xliaActor,
-				MODE_SET_TYPE, this.MODE_NOMINAL, ALWAYS_USING_MODE);
-
-		for( final MoccPort moccPort : actor.getInputPort() ) {
-			transformInputPort(moccPort, xliaActor);
-		}
-
-		for( final MoccPort moccPort : actor.getOutputPort() ) {
-			transformOutputPort(moccPort, xliaActor);
-		}
-
-		// MACRO ROUTINES
-		if( actor.hasInputPort() ) {
-			computeInitializationBehavior(actor);
-
-			computeReceptionBehavior(actor);
-
-			computeActivationTestBehavior(actor, moccSystemFeature);

-
-			computeConsumptionBehavior(actor);
-
-			if( this.CONFORMANCE_PURPOSE || this.TRACE_GENERATION_PURPOSE ) {
-				computeConsumptionTraceBehavior(actor);
-			}
-		}
-		else {
-			computeActivationTestBehavior(actor, moccSystemFeature);

-		}

+		if( actor.isComposite() ) {

+			final Machine xliaActor =

+					XLIA_INFRA.createMachine(actor.getName());

 

-		if( actor.hasOutputPort() ) {

-			computeProductionBehavior(actor);
-		}
+			actorHelper.put(actor, new MoccActorHelper(actor, xliaActor));

+

+			final MoccActorHelper actorHELPER = helper(actor);

+

+			// CONSTANTS & VARIABLES

+			actorHELPER.declareConstantsVariables(xliaActor,

+					MODE_SET_TYPE, this.MODE_NOMINAL, ALWAYS_USING_MODE);

+

+			for( final MoccPort moccPort : actor.getInputPort() ) {

+				transformInputPort(moccPort, xliaActor);

+			}

+

+			for( final MoccPort moccPort : actor.getOutputPort() ) {

+				transformOutputPort(moccPort, xliaActor);

+			}

+

+			// Transform MoCC AST to xLIA Model

+			final MoCC2XLIA mocc2xlia = new MoCC2XLIA(this);

+

+			mocc2xlia.transformSubSystem(actor, xliaActor);

+

+			return xliaActor;

+		}

+		else {

+			// Basic static analysis feature
+			final Statemachine xliaActor =
+					XLIA_STATEMACHINE.createStatemachine(actor.getName());
 
-		if( actor.FEATURE.isModeSelector )
-		{
-			if( actor.FEATURE.isModeProcessor )
-			{
-				// Mode Selector & Processor
-				transformInputOutoutActor(actor, xliaActor);

+			actorHelper.put(actor, new MoccActorHelper(actor, xliaActor));
+
+			final MoccActorHelper actorHELPER = helper(actor);
+
+			// CONSTANTS & VARIABLES
+			actorHELPER.declareConstantsVariables(xliaActor,
+					MODE_SET_TYPE, this.MODE_NOMINAL, ALWAYS_USING_MODE);
+
+			for( final MoccPort moccPort : actor.getInputPort() ) {
+				transformInputPort(moccPort, xliaActor);
 			}
-			else if( actor.FEATURE.hasInput )

-			{
-				// Mode Selector with Input

-				transformInputOutoutActor(actor, xliaActor);

+
+			for( final MoccPort moccPort : actor.getOutputPort() ) {
+				transformOutputPort(moccPort, xliaActor);
 			}
-			else {
-				// Mode Selector without input
-				transformOutputActor(actor, xliaActor);
-			}
-		}
-		else if( actor.FEATURE.isModeProcessor )
-		{
-			if( actor.FEATURE.hasInput )
-			{
-				if( actor.FEATURE.hasOutput )
-				{
-					// Mode Processor
-					transformProcessorActor(actor, xliaActor);
-				}
-				else {
-					// Mode Processor without output
-					transformInputActor(actor, xliaActor);
+
+			// MACRO ROUTINES
+			if( actor.hasInputPort() ) {
+				computeInitializationBehavior(actor);
+
+				computeReceptionBehavior(actor);
+
+				computeActivationTestBehavior(actor, moccSystemFeature);

+
+				computeConsumptionBehavior(actor);
+
+				if( this.CONFORMANCE_PURPOSE || this.TRACE_GENERATION_PURPOSE ) {
+					computeConsumptionTraceBehavior(actor);
 				}
 			}
 			else {
-				// Mode Processor without input
-				transformOutputActor(actor, xliaActor);
+				computeActivationTestBehavior(actor, moccSystemFeature);

+			}

+

+			if( actor.hasOutputPort() ) {

+				computeProductionBehavior(actor);
 			}
-		}
-		else
-		{
-			if( actor.FEATURE.hasInput )
+
+			if( actor.FEATURE.isModeSelector )
 			{
-				if( actor.FEATURE.hasOutput )
+				if( actor.FEATURE.isModeProcessor )
 				{
-					// Regular i.e. with Input & Ouput
+					// Mode Selector & Processor
+					transformInputOutoutActor(actor, xliaActor);

+				}
+				else if( actor.FEATURE.hasInput )

+				{
+					// Mode Selector with Input

 					transformInputOutoutActor(actor, xliaActor);

 				}
 				else {
-					// Regular without output
-					transformInputActor(actor, xliaActor);
+					// Mode Selector without input
+					transformOutputActor(actor, xliaActor);
 				}
 			}
-			else {
-				// Regular without input
-				transformOutputActor(actor, xliaActor);
+			else if( actor.FEATURE.isModeProcessor )
+			{
+				if( actor.FEATURE.hasInput )
+				{
+					if( actor.FEATURE.hasOutput )
+					{
+						// Mode Processor
+						transformProcessorActor(actor, xliaActor);
+					}
+					else {
+						// Mode Processor without output
+						transformInputActor(actor, xliaActor);
+					}
+				}
+				else {
+					// Mode Processor without input
+					transformOutputActor(actor, xliaActor);
+				}
 			}
-		}
+			else
+			{
+				if( actor.FEATURE.hasInput )
+				{
+					if( actor.FEATURE.hasOutput )
+					{
+						// Regular i.e. with Input & Ouput
+						transformInputOutoutActor(actor, xliaActor);

+					}
+					else {
+						// Regular without output
+						transformInputActor(actor, xliaActor);
+					}
+				}
+				else {
+					// Regular without input
+					transformOutputActor(actor, xliaActor);
+				}
+			}
 
-		return xliaActor;
-	}
+			return xliaActor;
+		}
+	}

 
 
 	public static EnumerationLiteral[] modeLiterals(
@@ -770,7 +912,7 @@
 	 * @param xliaActor
 	 */
 	public void transformOutputPort(
-			final MoccPort moccPort, final Statemachine xliaActor)
+			final MoccPort moccPort, final Machine xliaActor)

 	{
 		final MoccPortHelper helperPort =
 				new MoccPortHelper(helper(moccPort.actor), moccPort);
@@ -788,7 +930,7 @@
 	 * @param xliaActor
 	 */
 	public void transformInputPort(
-			final MoccPort moccPort, final Statemachine xliaActor)
+			final MoccPort moccPort, final Machine xliaActor)

 	{
 		final MoccPortHelper helperPort =
 				new MoccPortHelper(helper(moccPort.actor), moccPort);
@@ -805,20 +947,21 @@
 	/**
 	 * CHANNEL -> XLIA
 	 */
-	public void transformChannel()
+	public void transformChannel(

+			final MoccSystem moccSystem, final Behavior xliaBehavior)

 	{
 		final ModelOfInteraction moInteraction =
-				XLIA_INFRA.createMOI(this.mainBehavior);
+				XLIA_INFRA.createMOI(xliaBehavior);

 
 		if( CONFORMANCE_PURPOSE ) {
 			final Connector connectorEnv =
 					XLIA_INFRA.createConnectorEnv("channel_env");
 
-			for( final MoccActor actor : this.moccSystem.getActor() ) {
+			for( final MoccActor actor : moccSystem.getActor() ) {

 				for( final MoccPort moccPort : actor.getInputPort() ) {
 //					XLIA_INFRA.addConnectorEndInputPoint(connectorEnv,
 					XLIA_INFRA.addConnectorEndOutputPoint(connectorEnv,
-							helper(moccPort.actor).statemachine,
+							helper(moccPort.actor).machine,

 							helper(moccPort).xliaChannelPort );
 				}
 			}
@@ -828,7 +971,7 @@
 			}
 		}
 
-		for( final MoccChannel channel : this.moccSystem.getChannel() ) {
+		for( final MoccChannel channel : moccSystem.getChannel() ) {

 			final MoccActor outputActor = channel.getOutputActor();
 
 			final Connector connector =
@@ -836,11 +979,11 @@
 							outputActor.FEATURE.repetition);
 
 			XLIA_INFRA.addConnectorEndOutputPoint(connector,
-					helper(outputActor).statemachine,
+					helper(outputActor).machine,

 					helper(channel.getOutputPort()).xliaPort );
 
 			XLIA_INFRA.addConnectorEndInputPoint(connector,
-					helper(channel.getInputActor()).statemachine,
+					helper(channel.getInputActor()).machine,

 						helper(channel.getInputPort()).xliaPort);
 
 			moInteraction.getConnectors().add( connector );
@@ -848,251 +991,251 @@
 	}
 
 
-	/**
-	 * XLIA SYSTEM SCHEDULER
-	 * @param moccSystemFeature
-	 */
-	public void computeScheduler(final MoccSystemFeature moccSystemFeature)
-	{
-		final ModelOfExecution moExcecution = XLIA_INFRA.createMOE(this.mainBehavior);
-
-		// MOE: RUN
-		final Routine runRoutine =
-				XLIA_INFRA.createRoutine(XLIA_STATEMENT.OP_RUN);
-		moExcecution.setRunRoutine(runRoutine);
-
-		final BlockStatement blockRun =
-				XLIA_STATEMENT.createBlockStatement(runRoutine);
-
-		// Authorized global activation
-		XLIA_STATEMENT.addAssignment(blockRun,
-				this.varCanBeActivate,
-				XLIA_EXPRESSION.trueValue());
-
-		XLIA_STATEMENT.addActivitySchedule(blockRun);
-
-		// Test if a timed actor disable global activation because of
-		// timed constraint failure
-		if( moccSystemFeature.hasTimed ) {
-			XLIA_STATEMENT.addGuard(blockRun,
-					XLIA_EXPRESSION.createExpression(this.varCanBeActivate));
-		}
-
-		// MOE: SCHEDULE
-		final Routine scheduleRoutine =
-				XLIA_INFRA.createRoutine(XLIA_STATEMENT.OP_SCHEDULE);
-		moExcecution.setScheduleRoutine(scheduleRoutine);
-
-		final BlockStatement blockSchedule =
-				XLIA_STATEMENT.createBlockStatement(scheduleRoutine);
-
-		final int activationCount = moccSystemFeature.tick_period - 1;

-
-		if( moccSystemFeature.hasTimed ) {
-			final IfStatement ifStatement = XLIA_STATEMENT.addIf(blockSchedule);
-
-			computeSchedulingActor(moccSystemFeature, ifStatement, 0);
-
-			for( int index = 1 ; index < activationCount; index++) {
-				computeSchedulingActor(moccSystemFeature,
-						XLIA_STATEMENT.addElseIf(ifStatement), index);
-			}
-
-			final BlockStatement elseBlock =
-					XLIA_STATEMENT.createElseBlockStatement(ifStatement);
-			computeSchedulingActor(moccSystemFeature, elseBlock, activationCount);
-		}
-		else if( moccSystemFeature.tick_period > 1 ) {
-			final IfStatement ifStatement = XLIA_STATEMENT.addIf(blockSchedule);
-
-			computeStagingActor(moccSystemFeature, ifStatement, 0);
-
-			for( int stage = 1 ; stage < activationCount; stage++) {
-				computeStagingActor(moccSystemFeature,
-						XLIA_STATEMENT.addElseIf(ifStatement), stage);
-			}
-
-			final BlockStatement elseBlock =
-					XLIA_STATEMENT.createElseBlockStatement(ifStatement);
-			computeStagingActor(moccSystemFeature, elseBlock, activationCount);
-		}
-		else {
-			computeSchedulingActor(moccSystemFeature, blockSchedule, 0);
-		}
-
-		// MOE: RUN
-		XLIA_STATEMENT.addAssignment(blockRun, this.varTimestamp,
-				XLIA_EXPRESSION.createExpression(
-						XLIA_EXPRESSION.OP_PLUS,
-							this.varTimestamp, this.varTimeDelta));

-
-		XLIA_STATEMENT.addAssignment(blockRun, this.varTick,
-					XLIA_EXPRESSION.createExpression(

-							XLIA_EXPRESSION.OP_PLUS, this.varTick,

-							XLIA_EXPRESSION.createInteger(1)));

-
-
-		// PERIOD & RE-INITIALISATION
-		final IfStatement ifPeriod = XLIA_STATEMENT.addIf(blockRun,
-				XLIA_EXPRESSION.createRelational(
-						XLIA_EXPRESSION.OP_EQ,
-						this.varTick, this.varTickPeriod));
-
-		final BlockStatement blockPeriod =
-				XLIA_STATEMENT.createBlockStatement(ifPeriod);
-
-		// NEW PERIOD: INTIALISATION
-		XLIA_STATEMENT.addAssignment(blockPeriod,
-				this.varTick, XLIA_EXPRESSION.zero());
-
-		BlockStatement blockReinit = blockPeriod;
-
-		IfStatement ifReinit = null;
-		if( ! moccSystemFeature.hasTimed ) {
-			ifReinit = XLIA_STATEMENT.addIf(blockPeriod);
-			blockReinit = XLIA_STATEMENT.createBlockStatement(ifReinit);
-		}
-
-		Expression untimedConditionalReinitialisation = null;
-
-		// NEW PERIOD: CHECKING
-		for( final MoccActor actor : this.moccSystem.getActor() ) {
-			final MoccActorHelper actorHELPER = helper(actor);
-
-//			if( ! actor.FEATURE.isTimed )
-			{
-				final RelationalBinaryExpression actorRepetitionCond =
-						XLIA_EXPRESSION.createRelational(
-								XLIA_EXPRESSION.OP_EQ,
-								actorHELPER.statemachine,
-								actorHELPER.varActivationCount,
-									actorHELPER.constREPETITION);

-
-				if( moccSystemFeature.hasTimed ) {
-					XLIA_STATEMENT.addGuard(blockReinit, actorRepetitionCond);
-				}
-				else if( untimedConditionalReinitialisation == null ) {
-					untimedConditionalReinitialisation = actorRepetitionCond;
-				}
-				else {
-					untimedConditionalReinitialisation =
-							XLIA_EXPRESSION.createFlatAND(
-									untimedConditionalReinitialisation,
-									actorRepetitionCond);
-				}
-			}
-
-//!@! CSDF
-			XLIA_STATEMENT.addAssignment(blockReinit,
-					actorHELPER.statemachine,
-					actorHELPER.varActivationCount,
-					XLIA_EXPRESSION.zero());
-		}
-
-		// UNTIMED SYSTEM RE-INITIALISATION
-		if( untimedConditionalReinitialisation != null ) {
-			ifReinit.setCondition(untimedConditionalReinitialisation);
-		}
-
-		// ENABLED ONLY RECEPTION BEFORE RE-INITIALISATION

-		final BlockStatement blockReception =

-				XLIA_STATEMENT.createBlockStatement(

-						blockReinit, XLIA_STATEMENT.OP_SEQUENCE_WEAK);

-
-		XLIA_STATEMENT.addAssignment(blockReception,

-				this.varCanBeActivate,

-				XLIA_EXPRESSION.falseValue());

-

-
-		for( final MoccActor actor : this.moccSystem.getActor() ) {
-			if( actor.FEATURE.hasInput ) {
-				XLIA_STATEMENT.addActivityRun(blockReception,
-						helper(actor).statemachine);
-			}
-		}
-	}
-
-
-	protected void computeSchedulingActor(
-			final MoccSystemFeature moccSystemFeature,
-			final ConditionalBlockStatement ifBlock, final int activationIndex) {
-		final BlockStatement thenBlock =
-				XLIA_STATEMENT.createBlockStatement(ifBlock);
-
-		ifBlock.setCondition(XLIA_EXPRESSION.createRelational(
-				XLIA_EXPRESSION.OP_EQ, this.varTick,
-				XLIA_EXPRESSION.createInteger(activationIndex)));
-
-		computeSchedulingActor(moccSystemFeature, thenBlock, activationIndex);
-	}
-
-	protected void computeSchedulingActor(
-			final MoccSystemFeature moccSystemFeature,
-			final BlockStatement thenBlock, final int activationIndex) {
-//		int statementCount = 0;
-		for( final MoccActor actor : this.moccSystem.getActor() ) {
-			if( actor.FEATURE.activation[activationIndex] ) {
-				final MoccActorHelper actorHELPER = helper(actor);
-
-				if( actor.FEATURE.isTimed ) {
-					XLIA_STATEMENT.addActivityRun(thenBlock,
-							actorHELPER.statemachine);
-				}
-				else {
-					XLIA_STATEMENT.addActivityRtc(thenBlock,
-							actorHELPER.statemachine);
-				}
-
-				// Increment statementCount
-//				++statementCount;
-			}
-		}
-
-//		if( (statementCount > 1) /*&& (! moccSystemFeature.hasTimed)*/ ) {
-//			thenBlock.setOp( XLIA_STATEMENT.OP_SEQUENCE_WEAK );
+//	/**
+//	 * XLIA SYSTEM SCHEDULER
+//	 * @param moccSystemFeature
+//	 */
+//	public void computeScheduler(final MoccSystemFeature moccSystemFeature)
+//	{
+//		final ModelOfExecution moExcecution = XLIA_INFRA.createMOE(this.mainBehavior);
+//
+//		// MOE: RUN
+//		final Routine runRoutine =
+//				XLIA_INFRA.createRoutine(XLIA_STATEMENT.OP_RUN);
+//		moExcecution.setRunRoutine(runRoutine);
+//
+//		final BlockStatement blockRun =
+//				XLIA_STATEMENT.createBlockStatement(runRoutine);
+//
+//		// Authorized global activation
+//		XLIA_STATEMENT.addAssignment(blockRun,
+//				this.varCanBeActivate,
+//				XLIA_EXPRESSION.trueValue());
+//
+//		XLIA_STATEMENT.addActivitySchedule(blockRun);
+//
+//		// Test if a timed actor disable global activation because of
+//		// timed constraint failure
+//		if( moccSystemFeature.hasTimed ) {
+//			XLIA_STATEMENT.addGuard(blockRun,
+//					XLIA_EXPRESSION.createExpression(this.varCanBeActivate));
 //		}
-	}
-
-
-	protected void computeStagingActor(
-			final MoccSystemFeature moccSystemFeature,
-			final ConditionalBlockStatement ifBlock, final int stageIndex) {
-		final BlockStatement thenBlock =
-				XLIA_STATEMENT.createBlockStatement(ifBlock);
-
-		ifBlock.setCondition(XLIA_EXPRESSION.createRelational(
-				XLIA_EXPRESSION.OP_EQ, this.varTick,
-				XLIA_EXPRESSION.createInteger(stageIndex)));
-
-		computeStagingActor(moccSystemFeature, thenBlock, stageIndex);
-	}
-
-	protected void computeStagingActor(
-			final MoccSystemFeature moccSystemFeature,
-			final BlockStatement thenBlock, final int stageIndex) {
-//		int statementCount = 0;
-		for( final MoccActor actor : this.moccSystem.getActor() ) {
-			if( actor.schedule == stageIndex ) {
-				final MoccActorHelper actorHELPER = helper(actor);
-
-				XLIA_STATEMENT.addActivityRtc(thenBlock, actorHELPER.statemachine);
-
-				// Increment statementCount
-//				++statementCount;
-			}
-		}
-
-//		if( (statementCount > 1) /*&& (! moccSystemFeature.hasTimed)*/ ) {
-//			thenBlock.setOp( XLIA_STATEMENT.OP_SEQUENCE_WEAK );
+//
+//		// MOE: SCHEDULE
+//		final Routine scheduleRoutine =
+//				XLIA_INFRA.createRoutine(XLIA_STATEMENT.OP_SCHEDULE);
+//		moExcecution.setScheduleRoutine(scheduleRoutine);
+//
+//		final BlockStatement blockSchedule =
+//				XLIA_STATEMENT.createBlockStatement(scheduleRoutine);
+//
+//		final int activationCount = moccSystemFeature.tick_period - 1;

+//
+//		if( moccSystemFeature.hasTimed ) {
+//			final IfStatement ifStatement = XLIA_STATEMENT.addIf(blockSchedule);
+//
+//			computeSchedulingActor(moccSystemFeature, ifStatement, 0);
+//
+//			for( int index = 1 ; index < activationCount; index++) {
+//				computeSchedulingActor(moccSystemFeature,
+//						XLIA_STATEMENT.addElseIf(ifStatement), index);
+//			}
+//
+//			final BlockStatement elseBlock =
+//					XLIA_STATEMENT.createElseBlockStatement(ifStatement);
+//			computeSchedulingActor(moccSystemFeature, elseBlock, activationCount);
 //		}
-	}
+//		else if( moccSystemFeature.tick_period > 1 ) {
+//			final IfStatement ifStatement = XLIA_STATEMENT.addIf(blockSchedule);
+//
+//			computeStagingActor(moccSystemFeature, ifStatement, 0);
+//
+//			for( int stage = 1 ; stage < activationCount; stage++) {
+//				computeStagingActor(moccSystemFeature,
+//						XLIA_STATEMENT.addElseIf(ifStatement), stage);
+//			}
+//
+//			final BlockStatement elseBlock =
+//					XLIA_STATEMENT.createElseBlockStatement(ifStatement);
+//			computeStagingActor(moccSystemFeature, elseBlock, activationCount);
+//		}
+//		else {
+//			computeSchedulingActor(moccSystemFeature, blockSchedule, 0);
+//		}
+//
+//		// MOE: RUN
+//		XLIA_STATEMENT.addAssignment(blockRun, this.varTimestamp,
+//				XLIA_EXPRESSION.createExpression(
+//						XLIA_EXPRESSION.OP_PLUS,
+//							this.varTimestamp, this.varTimeDelta));

+//
+//		XLIA_STATEMENT.addAssignment(blockRun, this.varTick,
+//					XLIA_EXPRESSION.createExpression(

+//							XLIA_EXPRESSION.OP_PLUS, this.varTick,

+//							XLIA_EXPRESSION.createInteger(1)));

+//
+//
+//		// PERIOD & RE-INITIALISATION
+//		final IfStatement ifPeriod = XLIA_STATEMENT.addIf(blockRun,
+//				XLIA_EXPRESSION.createRelational(
+//						XLIA_EXPRESSION.OP_EQ,
+//						this.varTick, this.varTickPeriod));
+//
+//		final BlockStatement blockPeriod =
+//				XLIA_STATEMENT.createBlockStatement(ifPeriod);
+//
+//		// NEW PERIOD: INTIALISATION
+//		XLIA_STATEMENT.addAssignment(blockPeriod,
+//				this.varTick, XLIA_EXPRESSION.zero());
+//
+//		BlockStatement blockReinit = blockPeriod;
+//
+//		IfStatement ifReinit = null;
+//		if( ! moccSystemFeature.hasTimed ) {
+//			ifReinit = XLIA_STATEMENT.addIf(blockPeriod);
+//			blockReinit = XLIA_STATEMENT.createBlockStatement(ifReinit);
+//		}
+//
+//		Expression untimedConditionalReinitialisation = null;
+//
+//		// NEW PERIOD: CHECKING
+//		for( final MoccActor actor : this.moccSystem.getActor() ) {
+//			final MoccActorHelper actorHELPER = helper(actor);
+//
+////			if( ! actor.FEATURE.isTimed )
+//			{
+//				final RelationalBinaryExpression actorRepetitionCond =
+//						XLIA_EXPRESSION.createRelational(
+//								XLIA_EXPRESSION.OP_EQ,
+//								actorHELPER.machine,
+//								actorHELPER.varActivationCount,
+//									actorHELPER.constREPETITION);

+//
+//				if( moccSystemFeature.hasTimed ) {
+//					XLIA_STATEMENT.addGuard(blockReinit, actorRepetitionCond);
+//				}
+//				else if( untimedConditionalReinitialisation == null ) {
+//					untimedConditionalReinitialisation = actorRepetitionCond;
+//				}
+//				else {
+//					untimedConditionalReinitialisation =
+//							XLIA_EXPRESSION.createFlatAND(
+//									untimedConditionalReinitialisation,
+//									actorRepetitionCond);
+//				}
+//			}
+//
+////!@! CSDF
+//			XLIA_STATEMENT.addAssignment(blockReinit,
+//					actorHELPER.machine,
+//					actorHELPER.varActivationCount,
+//					XLIA_EXPRESSION.zero());
+//		}
+//
+//		// UNTIMED SYSTEM RE-INITIALISATION
+//		if( untimedConditionalReinitialisation != null ) {
+//			ifReinit.setCondition(untimedConditionalReinitialisation);
+//		}
+//
+//		// ENABLED ONLY RECEPTION BEFORE RE-INITIALISATION

+//		final BlockStatement blockReception =

+//				XLIA_STATEMENT.createBlockStatement(

+//						blockReinit, XLIA_STATEMENT.OP_SEQUENCE_WEAK);

+//
+//		XLIA_STATEMENT.addAssignment(blockReception,

+//				this.varCanBeActivate,

+//				XLIA_EXPRESSION.falseValue());

+//

+//
+//		for( final MoccActor actor : this.moccSystem.getActor() ) {
+//			if( actor.FEATURE.hasInput ) {
+//				XLIA_STATEMENT.addActivityRun(blockReception,
+//						helper(actor).machine);
+//			}
+//		}
+//	}
+//
+//
+//	protected void computeSchedulingActor(
+//			final MoccSystemFeature moccSystemFeature,
+//			final ConditionalBlockStatement ifBlock, final int activationIndex) {
+//		final BlockStatement thenBlock =
+//				XLIA_STATEMENT.createBlockStatement(ifBlock);
+//
+//		ifBlock.setCondition(XLIA_EXPRESSION.createRelational(
+//				XLIA_EXPRESSION.OP_EQ, this.varTick,
+//				XLIA_EXPRESSION.createInteger(activationIndex)));
+//
+//		computeSchedulingActor(moccSystemFeature, thenBlock, activationIndex);
+//	}
+//
+//	protected void computeSchedulingActor(
+//			final MoccSystemFeature moccSystemFeature,
+//			final BlockStatement thenBlock, final int activationIndex) {
+////		int statementCount = 0;
+//		for( final MoccActor actor : this.moccSystem.getActor() ) {
+//			if( actor.FEATURE.activation[activationIndex] ) {
+//				final MoccActorHelper actorHELPER = helper(actor);
+//
+//				if( actor.FEATURE.isTimed ) {
+//					XLIA_STATEMENT.addActivityRun(thenBlock,
+//							actorHELPER.machine);
+//				}
+//				else {
+//					XLIA_STATEMENT.addActivityRtc(thenBlock,
+//							actorHELPER.machine);
+//				}
+//
+//				// Increment statementCount
+////				++statementCount;
+//			}
+//		}
+//
+////		if( (statementCount > 1) /*&& (! moccSystemFeature.hasTimed)*/ ) {
+////			thenBlock.setOp( XLIA_STATEMENT.OP_SEQUENCE_WEAK );
+////		}
+//	}
+//
+//
+//	protected void computeStagingActor(
+//			final MoccSystemFeature moccSystemFeature,
+//			final ConditionalBlockStatement ifBlock, final int stageIndex) {
+//		final BlockStatement thenBlock =
+//				XLIA_STATEMENT.createBlockStatement(ifBlock);
+//
+//		ifBlock.setCondition(XLIA_EXPRESSION.createRelational(
+//				XLIA_EXPRESSION.OP_EQ, this.varTick,
+//				XLIA_EXPRESSION.createInteger(stageIndex)));
+//
+//		computeStagingActor(moccSystemFeature, thenBlock, stageIndex);
+//	}
+//
+//	protected void computeStagingActor(
+//			final MoccSystemFeature moccSystemFeature,
+//			final BlockStatement thenBlock, final int stageIndex) {
+////		int statementCount = 0;
+//		for( final MoccActor actor : this.moccSystem.getActor() ) {
+//			if( actor.schedule == stageIndex ) {
+//				final MoccActorHelper actorHELPER = helper(actor);
+//
+//				XLIA_STATEMENT.addActivityRtc(thenBlock, actorHELPER.machine);
+//
+//				// Increment statementCount
+////				++statementCount;
+//			}
+//		}
+//
+////		if( (statementCount > 1) /*&& (! moccSystemFeature.hasTimed)*/ ) {
+////			thenBlock.setOp( XLIA_STATEMENT.OP_SEQUENCE_WEAK );
+////		}
+//	}
 
 
 
 	////////////////////////////////////////////////////////////////////////////
 	// Variable Declaration for Mode Selector / Processor Actor
 	public void modeActorDeclaration(final MoccActor actor,
-			final Statemachine xliaActor)
+			final Machine xliaActor)

 	{
 		final MoccActorHelper actorHELPER = helper(actor);
 
@@ -1391,7 +1534,7 @@
 
 		actorHELPER.macroInitialization =
 				XLIA_INFRA.createMacroRoutine(
-						actorHELPER.statemachine, "initialization", block);
+						actorHELPER.machine, "initialization", block);

 	}
 
 	/**
@@ -1455,7 +1598,7 @@
 
 		actorHELPER.macroReception =
 				XLIA_INFRA.createMacroRoutine(
-						actorHELPER.statemachine, "reception", block);
+						actorHELPER.machine, "reception", block);

 	}
 
 
@@ -1536,7 +1679,7 @@
 
 		actorHELPER.macroActivationTest =
 				XLIA_INFRA.createMacroRoutine(
-						actorHELPER.statemachine, "activationTest", block);
+						actorHELPER.machine, "activationTest", block);

 
 		// Case where actor has some input port
 		computeActivationMode(actor);

@@ -1584,7 +1727,7 @@
 
 		actorHELPER.macroComputeProcessingMode =
 				XLIA_INFRA.createMacroRoutine(
-						actorHELPER.statemachine,
+						actorHELPER.machine,

 						"computeProcessingMode", blockEnable);
 	}
 
@@ -1649,7 +1792,7 @@
 				"Actor< " + actor.getName() + " >::MODE<UNDEFINED>");

 
 		actorHELPER.macroComputeProcessingMode = XLIA_INFRA.createMacroRoutine(
-				actorHELPER.statemachine, "computeProcessingMode", blockEnable);
+				actorHELPER.machine, "computeProcessingMode", blockEnable);

 	}
 
 
@@ -1715,7 +1858,7 @@
 
 		actorHELPER.macroConsumption =
 				XLIA_INFRA.createMacroRoutine(
-						actorHELPER.statemachine, "consumption", block);
+						actorHELPER.machine, "consumption", block);

 	}
 
 	/**
@@ -1771,7 +1914,7 @@
 
 		actorHELPER.macroConsumptionTrace =
 				XLIA_INFRA.createMacroRoutine(
-						actorHELPER.statemachine, "consumptionTrace", block);
+						actorHELPER.machine, "consumptionTrace", block);

 	}
 
 	/**
@@ -1873,7 +2016,7 @@
 //		}
 
 			actorHELPER.macroProduction = XLIA_INFRA.createMacroRoutine(
-				actorHELPER.statemachine, "production", block);
+				actorHELPER.machine, "production", block);

 	}
 
 
diff --git a/codegen/org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph/src/org/eclipse/efm/modeling/codegen/xlia/sdf/polygraph/mocc/xlia/MoCC2XLIASchedule.java b/codegen/org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph/src/org/eclipse/efm/modeling/codegen/xlia/sdf/polygraph/mocc/xlia/MoCC2XLIASchedule.java
index 1f8abb0..0fefeb4 100644
--- a/codegen/org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph/src/org/eclipse/efm/modeling/codegen/xlia/sdf/polygraph/mocc/xlia/MoCC2XLIASchedule.java
+++ b/codegen/org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph/src/org/eclipse/efm/modeling/codegen/xlia/sdf/polygraph/mocc/xlia/MoCC2XLIASchedule.java
@@ -15,6 +15,7 @@
 import org.eclipse.efm.ecore.formalml.expression.Expression;

 import org.eclipse.efm.ecore.formalml.expression.RelationalBinaryExpression;

 import org.eclipse.efm.ecore.formalml.infrastructure.Behavior;

+import org.eclipse.efm.ecore.formalml.infrastructure.Machine;

 import org.eclipse.efm.ecore.formalml.infrastructure.ModelOfExecution;

 import org.eclipse.efm.ecore.formalml.infrastructure.Routine;

 import org.eclipse.efm.ecore.formalml.statemachine.Pseudostate;

@@ -30,16 +31,24 @@
 import org.eclipse.efm.formalml.ecore.factory.XLIA_STATEMACHINE;

 import org.eclipse.efm.formalml.ecore.factory.XLIA_STATEMENT;

 import org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph.mocc.ast.MoccActor;

+import org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph.mocc.ast.MoccSystem;

 import org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph.mocc.ast.feature.MoccSystemFeature;

 import org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph.mocc.helper.MoccActorHelper;

 

 public class MoCC2XLIASchedule {

 

-	protected MoCC2XLIA mainGenerator;

+	protected final MoCC2XLIA mainGenerator;

 

-	public MoCC2XLIASchedule(final MoCC2XLIA mainGenerator) {

+	protected final MoccSystem moccSystem;

+

+	protected final Machine xliaMainMachine;

+

+	public MoCC2XLIASchedule(final MoCC2XLIA mainGenerator,

+			final MoccSystem moccSystem, final Machine xliaMainMachine) {

 		super();

 		this.mainGenerator = mainGenerator;

+		this.moccSystem      = moccSystem;

+		this.xliaMainMachine = xliaMainMachine;

 	}

 

 

@@ -60,7 +69,8 @@
 	 */

 	public void computeScheduler(final MoccSystemFeature moccSystemFeature)

 	{

-		final ModelOfExecution moExcecution = XLIA_INFRA.createMOE(mainGenerator.mainBehavior);

+		final ModelOfExecution moExcecution =

+				XLIA_INFRA.createMOE(this.xliaMainMachine.getMain());

 

 		// MOE: RUN

 		final Routine runRoutine =

@@ -72,7 +82,7 @@
 

 		// Authorized global activation

 		XLIA_STATEMENT.addAssignment(blockRun,

-				mainGenerator.varCanBeActivate,

+				this.mainGenerator.varCanBeActivate,

 				XLIA_EXPRESSION.trueValue());

 

 		XLIA_STATEMENT.addActivitySchedule(blockRun);

@@ -81,7 +91,8 @@
 		// timed constraint failure

 		if( moccSystemFeature.hasTimed ) {

 			XLIA_STATEMENT.addGuard(blockRun,

-					XLIA_EXPRESSION.createExpression(mainGenerator.varCanBeActivate));

+					XLIA_EXPRESSION.createExpression(

+							this.mainGenerator.varCanBeActivate));

 		}

 

 		// MOE: SCHEDULE

@@ -92,7 +103,7 @@
 		final BlockStatement blockSchedule =

 				XLIA_STATEMENT.createBlockStatement(scheduleRoutine);

 

-		final int activationCount = moccSystemFeature.tick_period - 1;

+		final int activationCount = moccSystemFeature.hyperperiod - 1;

 

 		if( moccSystemFeature.hasTimed ) {

 			final IfStatement ifStatement = XLIA_STATEMENT.addIf(blockSchedule);

@@ -108,7 +119,7 @@
 					XLIA_STATEMENT.createElseBlockStatement(ifStatement);

 			computeSchedulingActor(moccSystemFeature, elseBlock, activationCount);

 		}

-		else if( moccSystemFeature.tick_period > 1 ) {

+		else if( moccSystemFeature.hyperperiod > 1 ) {

 			final IfStatement ifStatement = XLIA_STATEMENT.addIf(blockSchedule);

 

 			computeStagingActor(moccSystemFeature, ifStatement, 0);

@@ -127,29 +138,33 @@
 		}

 

 		// MOE: RUN

-		XLIA_STATEMENT.addAssignment(blockRun, mainGenerator.varTimestamp,

+		XLIA_STATEMENT.addAssignment(blockRun, this.mainGenerator.varTimestamp,

 				XLIA_EXPRESSION.createExpression(

 						XLIA_EXPRESSION.OP_PLUS,

-							mainGenerator.varTimestamp, mainGenerator.varTimeDelta));

+							this.mainGenerator.varTimestamp,

+							this.mainGenerator.constTickFrequency));

 

-		XLIA_STATEMENT.addAssignment(blockRun, mainGenerator.varTick,

-					XLIA_EXPRESSION.createExpression(

-							XLIA_EXPRESSION.OP_PLUS, mainGenerator.varTick,

-							XLIA_EXPRESSION.createInteger(1)));

+		XLIA_STATEMENT.addAssignment(blockRun,

+				this.mainGenerator.varTick,

+				XLIA_EXPRESSION.createExpression(

+						XLIA_EXPRESSION.OP_PLUS,

+						this.mainGenerator.varTick,

+						XLIA_EXPRESSION.createInteger(1)));

 

 

 		// PERIOD & RE-INITIALISATION

 		final IfStatement ifPeriod = XLIA_STATEMENT.addIf(blockRun,

 				XLIA_EXPRESSION.createRelational(

 						XLIA_EXPRESSION.OP_EQ,

-						mainGenerator.varTick, mainGenerator.varTickPeriod));

+						this.mainGenerator.varTick,

+						this.mainGenerator.constHyperPeriod));

 

 		final BlockStatement blockPeriod =

 				XLIA_STATEMENT.createBlockStatement(ifPeriod);

 

 		// NEW PERIOD: INTIALISATION

 		XLIA_STATEMENT.addAssignment(blockPeriod,

-				mainGenerator.varTick, XLIA_EXPRESSION.zero());

+				this.mainGenerator.varTick, XLIA_EXPRESSION.zero());

 

 

 		computeScheduleReinitialisation(moccSystemFeature, blockPeriod);

@@ -163,7 +178,7 @@
 				XLIA_STATEMENT.createBlockStatement(ifBlock);

 

 		ifBlock.setCondition(XLIA_EXPRESSION.createRelational(

-				XLIA_EXPRESSION.OP_EQ, mainGenerator.varTick,

+				XLIA_EXPRESSION.OP_EQ, this.mainGenerator.varTick,

 				XLIA_EXPRESSION.createInteger(activationIndex)));

 

 		computeSchedulingActor(moccSystemFeature, thenBlock, activationIndex);

@@ -173,17 +188,15 @@
 			final MoccSystemFeature moccSystemFeature,

 			final BlockStatement thenBlock, final int activationIndex) {

 //		int statementCount = 0;

-		for( final MoccActor actor : mainGenerator.moccSystem.getActor() ) {

+		for( final MoccActor actor : this.moccSystem.getActor() ) {

 			if( actor.FEATURE.activation[activationIndex] ) {

-				final MoccActorHelper actorHELPER = mainGenerator.helper(actor);

+				final MoccActorHelper actorHELPER = this.mainGenerator.helper(actor);

 

 				if( actor.FEATURE.isTimed ) {

-					XLIA_STATEMENT.addActivityRun(thenBlock,

-							actorHELPER.statemachine);

+					XLIA_STATEMENT.addActivityRun(thenBlock, actorHELPER.machine);

 				}

 				else {

-					XLIA_STATEMENT.addActivityRtc(thenBlock,

-							actorHELPER.statemachine);

+					XLIA_STATEMENT.addActivityRtc(thenBlock, actorHELPER.machine);

 				}

 

 				// Increment statementCount

@@ -204,7 +217,7 @@
 				XLIA_STATEMENT.createBlockStatement(ifBlock);

 

 		ifBlock.setCondition(XLIA_EXPRESSION.createRelational(

-				XLIA_EXPRESSION.OP_EQ, mainGenerator.varTick,

+				XLIA_EXPRESSION.OP_EQ, this.mainGenerator.varTick,

 				XLIA_EXPRESSION.createInteger(stageIndex)));

 

 		computeStagingActor(moccSystemFeature, thenBlock, stageIndex);

@@ -214,11 +227,11 @@
 			final MoccSystemFeature moccSystemFeature,

 			final BlockStatement thenBlock, final int stageIndex) {

 //		int statementCount = 0;

-		for( final MoccActor actor : mainGenerator.moccSystem.getActor() ) {

+		for( final MoccActor actor : this.moccSystem.getActor() ) {

 			if( (actor.schedule == stageIndex) && actor.FEATURE.isExecutable ) {

-				final MoccActorHelper actorHELPER = mainGenerator.helper(actor);

+				final MoccActorHelper actorHELPER = this.mainGenerator.helper(actor);

 

-				XLIA_STATEMENT.addActivityRtc(thenBlock, actorHELPER.statemachine);

+				XLIA_STATEMENT.addActivityRtc(thenBlock, actorHELPER.machine);

 

 				// Increment statementCount

 //				++statementCount;

@@ -239,7 +252,7 @@
 		BlockStatement blockReinit = blockPeriod;

 

 //		XLIA_STATEMENT.addAssignment(blockReinit,

-//				mainGenerator.varTick, XLIA_EXPRESSION.zero());

+//				this.mainGenerator.varTick, XLIA_EXPRESSION.zero());

 

 		IfStatement ifReinit = null;

 		if( ! moccSystemFeature.hasTimed ) {

@@ -250,15 +263,15 @@
 		Expression untimedConditionalReinitialisation = null;

 

 		// NEW PERIOD: CHECKING

-		for( final MoccActor actor : mainGenerator.moccSystem.getActor() ) {

-			final MoccActorHelper actorHELPER = mainGenerator.helper(actor);

+		for( final MoccActor actor : this.moccSystem.getActor() ) {

+			final MoccActorHelper actorHELPER = this.mainGenerator.helper(actor);

 

 			if( actor.FEATURE.isExecutable ) // && (! actor.FEATURE.isTimed) )

 			{

 				final RelationalBinaryExpression actorRepetitionCond =

 						XLIA_EXPRESSION.createRelational(

 								XLIA_EXPRESSION.OP_EQ,

-								actorHELPER.statemachine,

+								actorHELPER.machine,

 								actorHELPER.varActivationCount,

 									actorHELPER.constREPETITION);

 

@@ -277,7 +290,7 @@
 

 //!@! CSDF

 				XLIA_STATEMENT.addAssignment(blockReinit,

-						actorHELPER.statemachine,

+						actorHELPER.machine,

 						actorHELPER.varActivationCount,

 						XLIA_EXPRESSION.zero());

 			}

@@ -294,18 +307,18 @@
 						blockReinit, XLIA_STATEMENT.OP_SEQUENCE_WEAK);

 

 		XLIA_STATEMENT.addAssignment(blockReception,

-				mainGenerator.varCanBeActivate,

+				this.mainGenerator.varCanBeActivate,

 				XLIA_EXPRESSION.falseValue());

 

-		for( final MoccActor actor : mainGenerator.moccSystem.getActor() ) {

+		for( final MoccActor actor : this.moccSystem.getActor() ) {

 			if( actor.FEATURE.hasInput &&  actor.FEATURE.isExecutable ) {

 				XLIA_STATEMENT.addActivityRun(blockReception,

-						mainGenerator.helper(actor).statemachine);

+						this.mainGenerator.helper(actor).machine);

 			}

 		}

 

 		XLIA_STATEMENT.addAssignment(blockReception,

-				mainGenerator.varCanBeActivate,

+				this.mainGenerator.varCanBeActivate,

 				XLIA_EXPRESSION.trueValue());

 	}

 

@@ -315,11 +328,12 @@
 	 * XLIA SYSTEM SCHEDULER

 	 * @param moccSystemFeature

 	 */

-	public void computeBehavior(final MoccSystemFeature moccSystemFeature) {

+	public void computeBehavior(final MoccSystemFeature moccSystemFeature)

+	{

 		final Statemachine xliaScheduler =

 				XLIA_STATEMACHINE.createStatemachine("scheduler");

 

-		mainGenerator.xliaSystem.getBehavior().add(xliaScheduler);

+		this.xliaMainMachine.getBehavior().add(xliaScheduler);

 

 		final Region region = XLIA_STATEMACHINE.createRegion(xliaScheduler);

 

@@ -337,13 +351,13 @@
 		final Transition t_period = XLIA_STATEMACHINE.createTransition(

 				"t_period", s_tick_period, s_tick);

 

-		Vertex next_tick = (moccSystemFeature.tick_period > 1) ?

+		Vertex next_tick = (moccSystemFeature.hyperperiod > 1) ?

 				XLIA_STATEMACHINE.createState(region, "tick_1") : s_tick_period;

 

 		Transition t_tick = XLIA_STATEMACHINE.createTransition(

 				"t_tick_0", s_tick, next_tick);

 

-		final int activationCount = moccSystemFeature.tick_period - 1;

+		final int activationCount = moccSystemFeature.hyperperiod - 1;

 

 		if( moccSystemFeature.hasTimed ) {

 			computeRunninActorTickAcivity(moccSystemFeature, t_tick, 0);

@@ -369,7 +383,7 @@
 						moccSystemFeature, t_tick, activationCount);

 			}

 		}

-		else if( moccSystemFeature.tick_period > 1 ) {

+		else if( moccSystemFeature.hyperperiod > 1 ) {

 			computeStaginActorTickAcivity(moccSystemFeature, t_tick, 0);

 

 			for( int index = 1 ; index < activationCount; index++) {

@@ -390,7 +404,7 @@
 			computeStaginActorTickAcivity(

 					moccSystemFeature, t_tick, activationCount);

 		}

-		else if( moccSystemFeature.tick_period == 0 ) {

+		else if( moccSystemFeature.hyperperiod == 0 ) {

 

 		}

 

@@ -409,15 +423,15 @@
 				XLIA_STATEMENT.createBlockStatement(transition);

 

 //		ifBlock.setCondition(XLIA_EXPRESSION.createRelational(

-//				XLIA_EXPRESSION.OP_EQ, mainGenerator.varTick,

+//				XLIA_EXPRESSION.OP_EQ, this.mainGenerator.varTick,

 //				XLIA_EXPRESSION.createInteger(activationIndex)));

 

-		XLIA_STATEMENT.addAssignment(block, mainGenerator.varTick,

+		XLIA_STATEMENT.addAssignment(block, this.mainGenerator.varTick,

 				XLIA_EXPRESSION.createInteger(activationIndex));

 

 		computeSchedulingActor(moccSystemFeature, block, activationIndex);

 

-//		XLIA_STATEMENT.addAssignment(block, mainGenerator.varTick,

+//		XLIA_STATEMENT.addAssignment(block, this.mainGenerator.varTick,

 //				XLIA_EXPRESSION.createInteger(activationIndex + 1));

 	}

 

@@ -430,12 +444,12 @@
 				XLIA_STATEMENT.createBlockStatement(transition);

 

 //		ifBlock.setCondition(XLIA_EXPRESSION.createRelational(

-//				XLIA_EXPRESSION.OP_EQ, mainGenerator.varTick,

+//				XLIA_EXPRESSION.OP_EQ, this.mainGenerator.varTick,

 //				XLIA_EXPRESSION.createInteger(activationIndex)));

 

 		computeStagingActor(moccSystemFeature, block, stageIndex);

 

-		XLIA_STATEMENT.addAssignment(block, mainGenerator.varTick,

+		XLIA_STATEMENT.addAssignment(block, this.mainGenerator.varTick,

 				XLIA_EXPRESSION.createInteger(stageIndex + 1));

 	}

 

@@ -448,13 +462,13 @@
 				XLIA_STATEMENT.createBlockStatement(transition);

 

 //		XLIA_STATEMENT.addAssignment(blockPeriod,

-//				mainGenerator.varTick, XLIA_EXPRESSION.zero());

+//				this.mainGenerator.varTick, XLIA_EXPRESSION.zero());

 

 		// Test if a timed actor disable global activation because of

 		// timed constraint failure

 		if( moccSystemFeature.hasTimed ) {

 			XLIA_STATEMENT.addGuard(blockPeriod,

-					XLIA_EXPRESSION.createExpression(mainGenerator.varCanBeActivate));

+					XLIA_EXPRESSION.createExpression(this.mainGenerator.varCanBeActivate));

 		}

 

 		computeScheduleReinitialisation(moccSystemFeature, blockPeriod);

@@ -462,7 +476,7 @@
 

 

 	private void computeBehaviorMoe(

-			final MoccSystemFeature moccSystemFeature, final Statemachine xliaScheduler) {

+			final MoccSystemFeature moccSystemFeature, final Machine xliaScheduler) {

 

 		final Behavior moeBehavior = XLIA_INFRA.createBehavior();

 		xliaScheduler.setMain(moeBehavior);

@@ -479,7 +493,7 @@
 

 		// Authorized global activation

 		XLIA_STATEMENT.addAssignment(blockRun,

-				mainGenerator.varCanBeActivate,

+				this.mainGenerator.varCanBeActivate,

 				XLIA_EXPRESSION.trueValue());

 

 		XLIA_STATEMENT.addActivitySchedule(blockRun);

@@ -488,13 +502,14 @@
 		// timed constraint failure

 		if( moccSystemFeature.hasTimed ) {

 			XLIA_STATEMENT.addGuard(blockRun,

-					XLIA_EXPRESSION.createExpression(mainGenerator.varCanBeActivate));

+					XLIA_EXPRESSION.createExpression(this.mainGenerator.varCanBeActivate));

 		}

 

-		XLIA_STATEMENT.addAssignment(blockRun, mainGenerator.varTimestamp,

+		XLIA_STATEMENT.addAssignment(blockRun, this.mainGenerator.varTimestamp,

 				XLIA_EXPRESSION.createExpression(

 						XLIA_EXPRESSION.OP_PLUS,

-							mainGenerator.varTimestamp, mainGenerator.varTimeDelta));

+							this.mainGenerator.varTimestamp,

+							this.mainGenerator.constTickFrequency));

 	}

 

 

diff --git a/codegen/org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph/src/org/eclipse/efm/modeling/codegen/xlia/sdf/polygraph/test/Mocc2XliaTest.java b/codegen/org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph/src/org/eclipse/efm/modeling/codegen/xlia/sdf/polygraph/test/Mocc2XliaTest.java
index 3141c97..94c6fa1 100644
--- a/codegen/org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph/src/org/eclipse/efm/modeling/codegen/xlia/sdf/polygraph/test/Mocc2XliaTest.java
+++ b/codegen/org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph/src/org/eclipse/efm/modeling/codegen/xlia/sdf/polygraph/test/Mocc2XliaTest.java
@@ -282,11 +282,9 @@
 		final String message = "MoCC --> xLIA : " + moccSystem.getName();

 		System.out.println(message + "...");

 

-		final MoCC2XLIA moccGenerator = new MoCC2XLIA(moccSystem, true, false);

+		final MoCC2XLIA moccGenerator = new MoCC2XLIA(true, false);

 

-		moccGenerator.transform();

-

-		final XliaModel xliaModel = moccGenerator.xliaModel;

+		final XliaModel xliaModel = moccGenerator.transformSystem(moccSystem);

 

 		System.out.println(message + " OK transformation");

 

@@ -362,11 +360,9 @@
 				moccSystem = mutationChannel(random);

 			}

 

-			final MoCC2XLIA moccGenerator = new MoCC2XLIA(moccSystem, true, false);

+			final MoCC2XLIA moccGenerator = new MoCC2XLIA(true, false);

 

-			moccGenerator.transform();

-

-			final XliaModel xliaModel = moccGenerator.xliaModel;

+			final XliaModel xliaModel = moccGenerator.transformSystem(moccSystem);

 

 			if( xliaModel != null ) {

 				++mutationConsistentCount;

diff --git a/codegen/org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph/src/org/eclipse/efm/modeling/codegen/xlia/sdf/polygraph/test/MoccCodeGeneratorTest.java b/codegen/org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph/src/org/eclipse/efm/modeling/codegen/xlia/sdf/polygraph/test/MoccCodeGeneratorTest.java
index 6ebcfe1..921c4b7 100644
--- a/codegen/org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph/src/org/eclipse/efm/modeling/codegen/xlia/sdf/polygraph/test/MoccCodeGeneratorTest.java
+++ b/codegen/org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph/src/org/eclipse/efm/modeling/codegen/xlia/sdf/polygraph/test/MoccCodeGeneratorTest.java
@@ -283,11 +283,9 @@
 		final String message = "MoCC --> xLIA : " + moccSystem.getName();

 		System.out.println(message + "...");

 

-		final MoCC2XLIA moccGenerator = new MoCC2XLIA(moccSystem, false, false);

+		final MoCC2XLIA moccGenerator = new MoCC2XLIA(false, false);

 

-		moccGenerator.transform();

-

-		final XliaModel xliaModel = moccGenerator.xliaModel;

+		final XliaModel xliaModel = moccGenerator.transformSystem(moccSystem);

 

 		System.out.println(message + " OK transformation");

 

diff --git a/codegen/org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph/src/org/eclipse/efm/modeling/codegen/xlia/sdf/polygraph/util/PrettyPrintWriter.java b/codegen/org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph/src/org/eclipse/efm/modeling/codegen/xlia/sdf/polygraph/util/PrettyPrintWriter.java
new file mode 100644
index 0000000..29eda32
--- /dev/null
+++ b/codegen/org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph/src/org/eclipse/efm/modeling/codegen/xlia/sdf/polygraph/util/PrettyPrintWriter.java
@@ -0,0 +1,413 @@
+/*******************************************************************************
+ * Copyright (c) 2019 CEA LIST.
+ *
+ * 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
+ *
+ * Contributors:
+ *  Arnault Lapitre (CEA LIST) arnault.lapitre@cea.fr
+ *  - Initial API and Implementation
+ *******************************************************************************/
+package org.eclipse.efm.modeling.codegen.xlia.sdf.polygraph.util;
+
+import java.io.FileNotFoundException;
+import java.io.IOException;
+import java.io.PrintWriter;
+import java.io.Writer;
+
+public class PrettyPrintWriter extends PrintWriter {
+
+	public static String DEFAULT_TAB  = "";
+	public static String DEFAULT_ITAB = "\t";
+	public static String DEFAULT_EOL  = "\n";
+
+	protected Writer writer;
+
+	public String EOL;
+	public String EOL2;
+
+	public String iTAB;
+
+	public String TAB1;
+	public String TAB2;
+	public String TAB3;
+	public String TAB4;
+	public String TAB5;
+
+
+	////////////////////////////////////////////////////////////////////////////
+	// CONSTRUCTOR
+	////////////////////////////////////////////////////////////////////////////
+
+	public PrettyPrintWriter(final Writer writer, final String tab, final String itab, final String eol) {
+		super( writer );
+
+		this.writer = writer;
+
+		this.TAB1 = tab;
+		this.iTAB = itab;
+
+		this.EOL  = eol;
+		this.EOL2 = this.EOL + eol;
+
+		this.TAB2 =  this.TAB1 + this.iTAB;
+		this.TAB3 =  this.TAB2 + this.iTAB;
+		this.TAB4 =  this.TAB3 + this.iTAB;
+		this.TAB5 =  this.TAB4 + this.iTAB;
+	}
+
+	public PrettyPrintWriter(final String fileName, final String tab, final String itab, final String eol)
+			throws FileNotFoundException{
+		super( fileName );
+
+		this.TAB1 = tab;
+		this.iTAB = itab;
+
+		this.EOL  = eol;
+		this.EOL2 = this.EOL + eol;
+
+		this.TAB2 =  this.TAB1 + this.iTAB;
+		this.TAB3 =  this.TAB2 + this.iTAB;
+		this.TAB4 =  this.TAB3 + this.iTAB;
+		this.TAB5 =  this.TAB4 + this.iTAB;
+	}
+
+
+	public PrettyPrintWriter(final Writer writer, final String tab, final String itab) {
+		this(writer, tab, itab, DEFAULT_EOL);
+	}
+
+	public PrettyPrintWriter(final Writer writer, final String tab) {
+		this(writer, tab, DEFAULT_ITAB, DEFAULT_EOL);
+	}
+
+	public PrettyPrintWriter(final Writer writer) {
+		this(writer, DEFAULT_TAB, DEFAULT_ITAB, DEFAULT_EOL);
+	}
+
+	@Override
+	public void close() {
+		if( this.writer != null ) {
+			try {
+				this.writer.close();
+			} catch (final IOException e) {
+				e.printStackTrace();
+			}
+		}
+	}
+
+	public String tab(int count) {
+		String ntab = TAB1;
+		for( ; count > 0 ; --count ) {
+			ntab += iTAB;
+		}
+
+		return( ntab );
+	}
+
+	public void pushTab(int count) {
+		if( count > 0 ) {
+			super.append( TAB1 );
+
+			for( ; count > 0 ; --count ) {
+				super.append( iTAB );
+			}
+		}
+	}
+
+
+	////////////////////////////////////////////////////////////////////////////
+	// INDENTATION
+	////////////////////////////////////////////////////////////////////////////
+
+	public PrettyPrintWriter itab(final String tab, final String itab, final String eol) {
+		return( new PrettyPrintWriter(this, tab, itab, eol) );
+	}
+
+	public PrettyPrintWriter notab() {
+		return( new PrettyPrintWriter(this, "", "", "") );
+	}
+
+	public PrettyPrintWriter itab2() {
+		return( new PrettyPrintWriter(this, TAB2, iTAB, EOL) );
+	}
+
+	public PrettyPrintWriter itab2(final String eol) {
+		return( new PrettyPrintWriter(this, TAB2, iTAB, eol) );
+	}
+
+
+	public PrettyPrintWriter itab3() {
+		return( new PrettyPrintWriter(this, TAB3, iTAB, EOL) );
+	}
+
+	public PrettyPrintWriter itab4() {
+		return( new PrettyPrintWriter(this, TAB4, iTAB, EOL) );
+	}
+
+	public PrettyPrintWriter itab5() {
+		return( new PrettyPrintWriter(this, TAB5, iTAB, EOL) );
+	}
+
+	public PrettyPrintWriter itab(final int count) {
+		return( new PrettyPrintWriter(this, tab(count), iTAB, EOL) );
+	}
+
+
+	////////////////////////////////////////////////////////////////////////////
+	// append STRING
+	////////////////////////////////////////////////////////////////////////////
+
+	@Override
+	public PrettyPrintWriter append(final char c) {
+		super.append( c );
+
+		return this;
+	}
+
+	public PrettyPrintWriter append(final String str) {
+		super.append( str );
+
+		return this;
+	}
+
+	public PrettyPrintWriter append(final boolean value) {
+		super.print(value);
+
+		return this;
+	}
+
+	public PrettyPrintWriter append(final int value) {
+		super.print(value);
+
+		return this;
+	}
+
+	public PrettyPrintWriter append(final float value) {
+		super.print(value);
+
+		return this;
+	}
+
+	public PrettyPrintWriter append(final double value) {
+		super.print(value);
+
+		return this;
+	}
+
+
+	////////////////////////////////////////////////////////////////////////////
+	// append TAB & STRING
+	////////////////////////////////////////////////////////////////////////////
+
+	public PrettyPrintWriter appendTab() {
+		super.append( TAB1 );
+
+		return this;
+	}
+
+	public PrettyPrintWriter appendTab(final String str) {
+		super.append( TAB1 ).append( str );
+
+		return this;
+	}
+
+	public PrettyPrintWriter appendTabEol(final String str) {
+		super.append( TAB1 ).append( str ).append( EOL );
+
+		return this;
+	}
+
+	public PrettyPrintWriter appendTabEol(final char c) {
+		super.append( TAB1 ).append( c ).append( EOL );
+
+		return this;
+	}
+
+	public PrettyPrintWriter appendTabEol2(final String str) {
+		super.append( TAB1 ).append( str ).append( EOL2 );
+
+		return this;
+	}
+
+
+	public PrettyPrintWriter appendEol_Eol(final String str) {
+		super.append( EOL ).append( str ).append( EOL );
+
+		return this;
+	}
+
+	public PrettyPrintWriter appendEol_Eol2(final String str) {
+		super.append( EOL ).append( str ).append( EOL2 );
+
+		return this;
+	}
+
+	public PrettyPrintWriter appendEolTab(final String str) {
+		super.append( EOL ).append( TAB1 ).append( str );
+
+		return this;
+	}
+
+	public PrettyPrintWriter appendEolTab2(final String str) {
+		super.append( EOL ).append( TAB2 ).append( str );
+
+		return this;
+	}
+
+	public PrettyPrintWriter appendEolTab_Eol(final String str) {
+		super.append( EOL ).append( TAB1 ).append( str ).append( EOL );
+
+		return this;
+	}
+
+
+	////////////////////////////////////////////////////////////////////////////
+	// append TAB & COMMENT LINE
+	////////////////////////////////////////////////////////////////////////////
+
+	public PrettyPrintWriter commentLine(final String str) {
+		if( str != null ) {
+			for( final String line : str.split("\\R") ) {
+				this.appendTab( "// " ).appendEol( line );
+			}
+		}
+
+		return this;
+	}
+
+	public PrettyPrintWriter commentLine(final Object object) {
+		if( object != null ) {
+			for( final String line : object.toString().split("\\R") ) {
+				this.appendTab( "// " ).appendEol( line );
+			}
+		}
+
+		return this;
+	}
+
+
+	////////////////////////////////////////////////////////////////////////////
+	// append TAB2 & STRING
+	////////////////////////////////////////////////////////////////////////////
+
+	public PrettyPrintWriter appendTab2() {
+		super.append( TAB2 );
+
+		return this;
+	}
+
+	public PrettyPrintWriter appendTab2(final String str) {
+		super.append( TAB2 ).append( str );
+
+		return this;
+	}
+
+	public PrettyPrintWriter appendTab2Eol(final String str) {
+		super.append( TAB2 ).append( str ).append( EOL );
+
+		return this;
+	}
+
+	public PrettyPrintWriter appendTab2Eol(final char c) {
+		super.append( TAB2 ).append( c ).append( EOL );
+
+		return this;
+	}
+
+	public PrettyPrintWriter appendTab2Eol2(final String str) {
+		super.append( TAB2 ).append( str ).append( EOL2 );
+
+		return this;
+	}
+
+
+	////////////////////////////////////////////////////////////////////////////
+	// append TAB3 & STRING
+	////////////////////////////////////////////////////////////////////////////
+
+	public PrettyPrintWriter appendTab3() {
+		super.append( TAB3 );
+
+		return this;
+	}
+
+	public PrettyPrintWriter appendTab3(final String str) {
+		super.append( TAB3 ).append( str );
+
+		return this;
+	}
+
+	public PrettyPrintWriter appendTab3Eol(final String str) {
+		super.append( TAB3 ).append( str ).append( EOL );
+
+		return this;
+	}
+
+	public PrettyPrintWriter appendTab3Eol2(final String str) {
+		super.append( TAB3 ).append( str ).append( EOL2 );
+
+		return this;
+	}
+
+
+	////////////////////////////////////////////////////////////////////////////
+	// append STRING & EOL
+	////////////////////////////////////////////////////////////////////////////
+
+	public PrettyPrintWriter appendEol() {
+		super.append( EOL );
+
+		return this;
+	}
+
+	public PrettyPrintWriter appendEol(final String str) {
+		super.append( str ).append( EOL );
+
+		return this;
+	}
+
+	public PrettyPrintWriter appendEol(final char c) {
+		super.print( c );
+		super.append( EOL );
+
+		return this;
+	}
+
+	public PrettyPrintWriter appendEol(final long value) {
+		super.print( value );
+		super.append( EOL );
+
+		return this;
+	}
+
+	public PrettyPrintWriter appendEol(final boolean value) {
+		super.print( value );
+		super.append( EOL );
+
+		return this;
+	}
+
+
+	public PrettyPrintWriter appendEol2() {
+		super.append( EOL2 );
+
+		return this;
+	}
+
+	public PrettyPrintWriter appendEol2(final String str) {
+		super.append( str ).append( EOL2 );
+
+		return this;
+	}
+
+	public PrettyPrintWriter appendEol2(final char c) {
+		super.append( c ).append( EOL2 );
+
+		return this;
+	}
+
+
+}