Browse Source

Changed Interpreter from Float to Double

Andreas Mülder 11 years ago
parent
commit
f13da7e808

+ 4 - 9
plugins/org.yakindu.sct.model.sexec/src/org/yakindu/sct/model/sexec/transformation/SequenceBuilder.xtend

@@ -457,7 +457,7 @@ class SequenceBuilder {
 		flow.initSequence = initSequence
 		return initSequence
 	}
-
+	//TODO: Move to type system
 	def effectiveInitialValue(VariableDefinition vd) {
 		if (vd.initialValue != null) {
 			return vd.initialValue
@@ -465,7 +465,7 @@ class SequenceBuilder {
 			switch (vd) {
 				case isBooleanType(vd.type): false.buildValue
 				case isIntegerType(vd.type): 0.buildValue
-				case isRealType(vd.type): buildValue(0.0 as float)
+				case isRealType(vd.type): buildValue(0.0d as double)
 				case isStringType(vd.type): "".buildValue
 				default: null
 			}
@@ -487,11 +487,6 @@ class SequenceBuilder {
 	}
 
 	def Expression buildValueExpression(TimeEventSpec tes) {
-
-		//		val PrimitiveValueExpression pve = stext.factory.createPrimitiveValueExpression 
-		//		val IntLiteral intLit = stext.factory.createIntLiteral
-		//		intLit.value = tes.value
-		//		pve.value = intLit
 		val pve = tes.value.copy
 
 		switch (tes.unit) {
@@ -549,10 +544,10 @@ class SequenceBuilder {
 		pve
 	}
 
-	def Expression buildValue(float r) {
+	def Expression buildValue(double d) {
 		val PrimitiveValueExpression pve = factory.createPrimitiveValueExpression
 		val RealLiteral lit = factory.createRealLiteral
-		lit.value = r
+		lit.value = d
 		pve.value = lit
 
 		pve

+ 5 - 7
plugins/org.yakindu.sct.simulation.ui/src/org/yakindu/sct/simulation/ui/view/editing/RealEditingSupport.java

@@ -30,13 +30,12 @@ public class RealEditingSupport extends ScopeSlotEditingSupport {
 
 	@Override
 	public CellEditor getCellEditor(Object element) {
-		TextCellEditor textCellEditor = new TextCellEditor(
-				(Composite) getViewer().getControl());
+		TextCellEditor textCellEditor = new TextCellEditor((Composite) getViewer().getControl());
 		textCellEditor.setValidator(new ICellEditorValidator() {
 			public String isValid(Object value) {
 				String stringValue = (String) value;
 				try {
-					Float.parseFloat(stringValue);
+					Double.parseDouble(stringValue);
 				} catch (NumberFormatException e) {
 					return "No valid real value!";
 				}
@@ -48,14 +47,13 @@ public class RealEditingSupport extends ScopeSlotEditingSupport {
 
 	@Override
 	public Class<?> getSupportedType() {
-		return Float.class;
+		return Double.class;
 	}
 
 	@Override
 	protected Object convertValue(Object element, Object value) {
-		if (value != null && value instanceof String
-				&& ((String) value).trim().length() > 0) {
-			return Float.parseFloat((String) value);
+		if (value != null && value instanceof String && ((String) value).trim().length() > 0) {
+			return Double.parseDouble((String) value);
 		}
 		return null;
 	}

+ 1 - 1
test-plugins/org.yakindu.sct.model.sexec.test/src/org/yakindu/sct/model/sexec/transformation/test/Assert.java

@@ -91,7 +91,7 @@ public class Assert {
 						.getValue());
 			}
 			else if (literal instanceof RealLiteral) {
-				currentValue = Float.toString(((RealLiteral) literal)
+				currentValue = Double.toString(((RealLiteral) literal)
 						.getValue());
 			}
 			else if (literal instanceof StringLiteral) {