diff options
Diffstat (limited to 'plugins/org.eclipse.etrice.core.etphys')
11 files changed, 88 insertions, 48 deletions
diff --git a/plugins/org.eclipse.etrice.core.etphys/META-INF/MANIFEST.MF b/plugins/org.eclipse.etrice.core.etphys/META-INF/MANIFEST.MF index 749427f7e..faddaf3d0 100644 --- a/plugins/org.eclipse.etrice.core.etphys/META-INF/MANIFEST.MF +++ b/plugins/org.eclipse.etrice.core.etphys/META-INF/MANIFEST.MF @@ -21,15 +21,16 @@ Import-Package: org.apache.log4j, org.eclipse.xtext.xbase.lib Bundle-RequiredExecutionEnvironment: JavaSE-1.6 Export-Package: org.eclipse.etrice.core.etphys, - org.eclipse.etrice.core.etphys.services, + org.eclipse.etrice.core.etphys.converters, org.eclipse.etrice.core.etphys.eTPhys, org.eclipse.etrice.core.etphys.eTPhys.impl, org.eclipse.etrice.core.etphys.eTPhys.util, - org.eclipse.etrice.core.etphys.serializer, + org.eclipse.etrice.core.etphys.formatting, + org.eclipse.etrice.core.etphys.generator, org.eclipse.etrice.core.etphys.parser.antlr, org.eclipse.etrice.core.etphys.parser.antlr.internal, - org.eclipse.etrice.core.etphys.validation, org.eclipse.etrice.core.etphys.scoping, - org.eclipse.etrice.core.etphys.generator, - org.eclipse.etrice.core.etphys.formatting + org.eclipse.etrice.core.etphys.serializer, + org.eclipse.etrice.core.etphys.services, + org.eclipse.etrice.core.etphys.validation diff --git a/plugins/org.eclipse.etrice.core.etphys/src-gen/org/eclipse/etrice/core/etphys/ETPhys.ecore b/plugins/org.eclipse.etrice.core.etphys/src-gen/org/eclipse/etrice/core/etphys/ETPhys.ecore index 0e74f0f21..d1004c94f 100644 --- a/plugins/org.eclipse.etrice.core.etphys/src-gen/org/eclipse/etrice/core/etphys/ETPhys.ecore +++ b/plugins/org.eclipse.etrice.core.etphys/src-gen/org/eclipse/etrice/core/etphys/ETPhys.ecore @@ -135,7 +135,7 @@ <details key="documentation" value="<br>This is the execution mode of the thread.
"/> </eAnnotations> </eStructuralFeatures> - <eStructuralFeatures xsi:type="ecore:EAttribute" name="time" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"/> + <eStructuralFeatures xsi:type="ecore:EAttribute" name="time" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//ELong"/> <eStructuralFeatures xsi:type="ecore:EAttribute" name="prio" eType="ecore:EDataType http://www.eclipse.org/emf/2002/Ecore#//EInt"> <eAnnotations source="http://www.eclipse.org/emf/2002/GenModel"> <details key="documentation" value="<br>This is the priority of the thread.
"/> diff --git a/plugins/org.eclipse.etrice.core.etphys/src-gen/org/eclipse/etrice/core/etphys/ETPhys.xtextbin b/plugins/org.eclipse.etrice.core.etphys/src-gen/org/eclipse/etrice/core/etphys/ETPhys.xtextbin Binary files differindex 5f3974108..10b1c33e2 100644 --- a/plugins/org.eclipse.etrice.core.etphys/src-gen/org/eclipse/etrice/core/etphys/ETPhys.xtextbin +++ b/plugins/org.eclipse.etrice.core.etphys/src-gen/org/eclipse/etrice/core/etphys/ETPhys.xtextbin diff --git a/plugins/org.eclipse.etrice.core.etphys/src-gen/org/eclipse/etrice/core/etphys/eTPhys/PhysicalThread.java b/plugins/org.eclipse.etrice.core.etphys/src-gen/org/eclipse/etrice/core/etphys/eTPhys/PhysicalThread.java index fe58975ab..a39a3ffd9 100644 --- a/plugins/org.eclipse.etrice.core.etphys/src-gen/org/eclipse/etrice/core/etphys/eTPhys/PhysicalThread.java +++ b/plugins/org.eclipse.etrice.core.etphys/src-gen/org/eclipse/etrice/core/etphys/eTPhys/PhysicalThread.java @@ -124,12 +124,12 @@ public interface PhysicalThread extends EObject * </p> * <!-- end-user-doc --> * @return the value of the '<em>Time</em>' attribute. - * @see #setTime(int) + * @see #setTime(long) * @see org.eclipse.etrice.core.etphys.eTPhys.ETPhysPackage#getPhysicalThread_Time() * @model * @generated */ - int getTime(); + long getTime(); /** * Sets the value of the '{@link org.eclipse.etrice.core.etphys.eTPhys.PhysicalThread#getTime <em>Time</em>}' attribute. @@ -139,7 +139,7 @@ public interface PhysicalThread extends EObject * @see #getTime() * @generated */ - void setTime(int value); + void setTime(long value); /** * Returns the value of the '<em><b>Prio</b></em>' attribute. diff --git a/plugins/org.eclipse.etrice.core.etphys/src-gen/org/eclipse/etrice/core/etphys/eTPhys/impl/ETPhysPackageImpl.java b/plugins/org.eclipse.etrice.core.etphys/src-gen/org/eclipse/etrice/core/etphys/eTPhys/impl/ETPhysPackageImpl.java index 5d29246d0..7b272bf64 100644 --- a/plugins/org.eclipse.etrice.core.etphys/src-gen/org/eclipse/etrice/core/etphys/eTPhys/impl/ETPhysPackageImpl.java +++ b/plugins/org.eclipse.etrice.core.etphys/src-gen/org/eclipse/etrice/core/etphys/eTPhys/impl/ETPhysPackageImpl.java @@ -716,7 +716,7 @@ public class ETPhysPackageImpl extends EPackageImpl implements ETPhysPackage initEAttribute(getPhysicalThread_Default(), ecorePackage.getEBoolean(), "default", null, 0, 1, PhysicalThread.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEAttribute(getPhysicalThread_Name(), ecorePackage.getEString(), "name", null, 0, 1, PhysicalThread.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEAttribute(getPhysicalThread_Execmode(), this.getExecMode(), "execmode", null, 0, 1, PhysicalThread.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); - initEAttribute(getPhysicalThread_Time(), ecorePackage.getEInt(), "time", null, 0, 1, PhysicalThread.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); + initEAttribute(getPhysicalThread_Time(), ecorePackage.getELong(), "time", null, 0, 1, PhysicalThread.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEAttribute(getPhysicalThread_Prio(), ecorePackage.getEInt(), "prio", null, 0, 1, PhysicalThread.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEAttribute(getPhysicalThread_Stacksize(), ecorePackage.getEInt(), "stacksize", null, 0, 1, PhysicalThread.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); initEAttribute(getPhysicalThread_Msgblocksize(), ecorePackage.getEInt(), "msgblocksize", null, 0, 1, PhysicalThread.class, !IS_TRANSIENT, !IS_VOLATILE, IS_CHANGEABLE, !IS_UNSETTABLE, !IS_ID, IS_UNIQUE, !IS_DERIVED, IS_ORDERED); diff --git a/plugins/org.eclipse.etrice.core.etphys/src-gen/org/eclipse/etrice/core/etphys/eTPhys/impl/PhysicalThreadImpl.java b/plugins/org.eclipse.etrice.core.etphys/src-gen/org/eclipse/etrice/core/etphys/eTPhys/impl/PhysicalThreadImpl.java index f80fc9c8a..410dd10a5 100644 --- a/plugins/org.eclipse.etrice.core.etphys/src-gen/org/eclipse/etrice/core/etphys/eTPhys/impl/PhysicalThreadImpl.java +++ b/plugins/org.eclipse.etrice.core.etphys/src-gen/org/eclipse/etrice/core/etphys/eTPhys/impl/PhysicalThreadImpl.java @@ -103,7 +103,7 @@ public class PhysicalThreadImpl extends MinimalEObjectImpl.Container implements * @generated * @ordered */ - protected static final int TIME_EDEFAULT = 0; + protected static final long TIME_EDEFAULT = 0L; /** * The cached value of the '{@link #getTime() <em>Time</em>}' attribute. @@ -113,7 +113,7 @@ public class PhysicalThreadImpl extends MinimalEObjectImpl.Container implements * @generated * @ordered */ - protected int time = TIME_EDEFAULT; + protected long time = TIME_EDEFAULT; /** * The default value of the '{@link #getPrio() <em>Prio</em>}' attribute. @@ -290,7 +290,7 @@ public class PhysicalThreadImpl extends MinimalEObjectImpl.Container implements * <!-- end-user-doc --> * @generated */ - public int getTime() + public long getTime() { return time; } @@ -300,9 +300,9 @@ public class PhysicalThreadImpl extends MinimalEObjectImpl.Container implements * <!-- end-user-doc --> * @generated */ - public void setTime(int newTime) + public void setTime(long newTime) { - int oldTime = time; + long oldTime = time; time = newTime; if (eNotificationRequired()) eNotify(new ENotificationImpl(this, Notification.SET, ETPhysPackage.PHYSICAL_THREAD__TIME, oldTime, time)); @@ -450,7 +450,7 @@ public class PhysicalThreadImpl extends MinimalEObjectImpl.Container implements setExecmode((ExecMode)newValue); return; case ETPhysPackage.PHYSICAL_THREAD__TIME: - setTime((Integer)newValue); + setTime((Long)newValue); return; case ETPhysPackage.PHYSICAL_THREAD__PRIO: setPrio((Integer)newValue); diff --git a/plugins/org.eclipse.etrice.core.etphys/src-gen/org/eclipse/etrice/core/etphys/parser/antlr/internal/InternalETPhys.tokens b/plugins/org.eclipse.etrice.core.etphys/src-gen/org/eclipse/etrice/core/etphys/parser/antlr/internal/InternalETPhys.tokens index 581d49d5a..bf4ca61b0 100644 --- a/plugins/org.eclipse.etrice.core.etphys/src-gen/org/eclipse/etrice/core/etphys/parser/antlr/internal/InternalETPhys.tokens +++ b/plugins/org.eclipse.etrice.core.etphys/src-gen/org/eclipse/etrice/core/etphys/parser/antlr/internal/InternalETPhys.tokens @@ -77,7 +77,7 @@ RULE_WS=9 's'=40 'RuntimeClass'=30 ':'=16 -'['=32 '-'=35 +'['=32 ']'=33 'from'=37 diff --git a/plugins/org.eclipse.etrice.core.etphys/src-gen/org/eclipse/etrice/core/etphys/services/ETPhysGrammarAccess.java b/plugins/org.eclipse.etrice.core.etphys/src-gen/org/eclipse/etrice/core/etphys/services/ETPhysGrammarAccess.java index e7e8a3779..0303b0e9f 100644 --- a/plugins/org.eclipse.etrice.core.etphys/src-gen/org/eclipse/etrice/core/etphys/services/ETPhysGrammarAccess.java +++ b/plugins/org.eclipse.etrice.core.etphys/src-gen/org/eclipse/etrice/core/etphys/services/ETPhysGrammarAccess.java @@ -699,7 +699,7 @@ public class ETPhysGrammarAccess extends AbstractGrammarElementFinder { private final RuleCall cINTTerminalRuleCall_3_0 = (RuleCall)cGroup_3.eContents().get(0); private final Keyword cNsKeyword_3_1 = (Keyword)cGroup_3.eContents().get(1); - //TIME returns ecore::EInt: + //TIME returns ecore::ELong: // INT "s" | INT "ms" | INT "us" | INT "ns"; public ParserRule getRule() { return rule; } @@ -995,7 +995,7 @@ public class ETPhysGrammarAccess extends AbstractGrammarElementFinder { return getFQNAccess().getRule(); } - //TIME returns ecore::EInt: + //TIME returns ecore::ELong: // INT "s" | INT "ms" | INT "us" | INT "ns"; public TIMEElements getTIMEAccess() { return (pTIME != null) ? pTIME : (pTIME = new TIMEElements()); diff --git a/plugins/org.eclipse.etrice.core.etphys/src/org/eclipse/etrice/core/etphys/ETPhys.xtext b/plugins/org.eclipse.etrice.core.etphys/src/org/eclipse/etrice/core/etphys/ETPhys.xtext index 379c294ad..fdba13686 100644 --- a/plugins/org.eclipse.etrice.core.etphys/src/org/eclipse/etrice/core/etphys/ETPhys.xtext +++ b/plugins/org.eclipse.etrice.core.etphys/src/org/eclipse/etrice/core/etphys/ETPhys.xtext @@ -89,4 +89,4 @@ ImportedFQN: FQN: ID ('.' ID)*; -TIME returns ecore::EInt: (INT 's') | (INT 'ms') | (INT 'us') | (INT 'ns'); +TIME returns ecore::ELong: (INT 's') | (INT 'ms') | (INT 'us') | (INT 'ns'); diff --git a/plugins/org.eclipse.etrice.core.etphys/src/org/eclipse/etrice/core/etphys/converters/ETPhysConverter.java b/plugins/org.eclipse.etrice.core.etphys/src/org/eclipse/etrice/core/etphys/converters/ETPhysConverter.java index 33148692c..4f5df9ec9 100644 --- a/plugins/org.eclipse.etrice.core.etphys/src/org/eclipse/etrice/core/etphys/converters/ETPhysConverter.java +++ b/plugins/org.eclipse.etrice.core.etphys/src/org/eclipse/etrice/core/etphys/converters/ETPhysConverter.java @@ -25,7 +25,7 @@ public class ETPhysConverter extends DefaultTerminalConverters { private TimeConverter timeConverter = new TimeConverter(); @ValueConverter(rule="TIME") - public IValueConverter<Integer> getTimeConverter() { + public IValueConverter<Long> getTimeConverter() { return timeConverter; } } diff --git a/plugins/org.eclipse.etrice.core.etphys/src/org/eclipse/etrice/core/etphys/converters/TimeConverter.java b/plugins/org.eclipse.etrice.core.etphys/src/org/eclipse/etrice/core/etphys/converters/TimeConverter.java index 3774eb60c..082b8fe67 100644 --- a/plugins/org.eclipse.etrice.core.etphys/src/org/eclipse/etrice/core/etphys/converters/TimeConverter.java +++ b/plugins/org.eclipse.etrice.core.etphys/src/org/eclipse/etrice/core/etphys/converters/TimeConverter.java @@ -18,44 +18,53 @@ import org.eclipse.xtext.nodemodel.INode; /** * @author Henrik Rentz-Reichert - * + * */ -public class TimeConverter extends AbstractLexerBasedConverter<Integer> { +public class TimeConverter extends AbstractLexerBasedConverter<Long> { + + public static final String SEC = "s"; + public static final String MILLI_SEC = "ms"; + public static final String MICRO_SEC = "us"; + public static final String NANO_SEC = "ns"; - /* (non-Javadoc) - * @see org.eclipse.xtext.conversion.IValueConverter#toValue(java.lang.String, org.eclipse.xtext.nodemodel.INode) + /* + * (non-Javadoc) + * + * @see + * org.eclipse.xtext.conversion.IValueConverter#toValue(java.lang.String, + * org.eclipse.xtext.nodemodel.INode) */ @Override - public Integer toValue(String string, INode node) throws ValueConverterException { - if (string==null || string.isEmpty()) + public Long toValue(String string, INode node) throws ValueConverterException { + if (string == null || string.isEmpty()) throw new ValueConverterException("Couldn't convert empty string to time.", node, null); else { // determine power and extract number int power; int pos; String value; - if ((pos=string.indexOf("ns"))>0) { - value = string.substring(0,pos); + if ((pos = string.indexOf(NANO_SEC)) > 0) { + value = string.substring(0, pos); power = 1; } - else if ((pos=string.indexOf("us"))>0) { - value = string.substring(0,pos); + else if ((pos = string.indexOf(MICRO_SEC)) > 0) { + value = string.substring(0, pos); power = 1000; } - else if ((pos=string.indexOf("ms"))>0) { - value = string.substring(0,pos); + else if ((pos = string.indexOf(MILLI_SEC)) > 0) { + value = string.substring(0, pos); power = 1000000; } - else if ((pos=string.indexOf("s"))>0) { - value = string.substring(0,pos); + else if ((pos = string.indexOf(SEC)) > 0) { + value = string.substring(0, pos); power = 1000000000; } else throw new ValueConverterException("No unit specified with time (s, ms, us or ns).", node, null); - + try { - int val = Integer.parseInt(value.trim()); - return Integer.valueOf(val)*power; + long val = Long.parseLong(value.trim()); + return val * power; } catch (NumberFormatException e) { throw new ValueConverterException("Could not parse time value.", node, e); @@ -63,27 +72,57 @@ public class TimeConverter extends AbstractLexerBasedConverter<Integer> { } } - /* (non-Javadoc) - * @see org.eclipse.xtext.conversion.impl.AbstractLexerBasedConverter#toEscapedString(java.lang.Object) + /* + * (non-Javadoc) + * + * @see + * org.eclipse.xtext.conversion.impl.AbstractLexerBasedConverter#toEscapedString + * (java.lang.Object) */ @Override - protected String toEscapedString(Integer value) { - if (value%1000==0) { - if (value%1000000==0) { - if (value%1000000000==0) { - return (value/1000000000)+"s"; + protected String toEscapedString(Long value) { + if (value % 1000 == 0) { + if (value % 1000000 == 0) { + if (value % 1000000000 == 0) { + return (value / 1000000000) + SEC; } else { - return (value/1000000)+"ms"; + return (value / 1000000) + MILLI_SEC; } } else { - return (value/1000)+"us"; + return (value / 1000) + MICRO_SEC; } } else { - return value+"ns"; + return value + NANO_SEC; } } + /** + * Returns the part of <b>nanoSeconds</b>, that is descriped by <b>unit</b> + * and <b>isNewUnit</b>.<br> + * If <b>isNewUnit</b> = true then anything that can not be represented by + * <b>unit</b> is cut away.<br> + * If <b>isNewUnit</b> = false then the unit remains nano seconds but + * contains nothing higher than <b>unit</b>. + * + * @param unit + * - split along inclusive + * @param isNewUnit + * - upper/lower part + */ + public static long split(long nanoSeconds, String unit, boolean isNewUnit) { + if (unit.equals(SEC)) + return (isNewUnit) ? (nanoSeconds / 1000000000) : nanoSeconds; + if (unit.equals(MILLI_SEC)) + return (isNewUnit) ? (nanoSeconds / 1000000) : nanoSeconds - split(nanoSeconds, SEC, true) * 1000000000; + if (unit.equals(MICRO_SEC)) + return (isNewUnit) ? (nanoSeconds / 1000) : nanoSeconds - split(nanoSeconds, MILLI_SEC, true) * 1000000; + if (unit.equals(NANO_SEC)) + return (isNewUnit) ? nanoSeconds : nanoSeconds - split(nanoSeconds, MICRO_SEC, true) * 1000; + + throw new UnsupportedOperationException("Invalid time unit"); + } + } |