Skip to content

Commit

Permalink
fix(plc4go/codegen): work on time support
Browse files Browse the repository at this point in the history
  • Loading branch information
sruehl committed Mar 7, 2022
1 parent 2f587a7 commit e91f634
Showing 1 changed file with 22 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,13 @@ public String getLanguageTypeNameForTypeReference(TypeReference typeReference) {
case VSTRING:
return "string";
case TIME:
return "Time";
case DATE:
return "Date";
case DATETIME:
return "Date";
emitRequiredImport("time");
return "time.Time";
default:
throw new RuntimeException("Unsupported simple type");
}
throw new RuntimeException("Unsupported simple type");
}

public String getPlcValueTypeForTypeReference(TypeReference typeReference) {
Expand Down Expand Up @@ -229,8 +229,9 @@ public String getPlcValueTypeForTypeReference(TypeReference typeReference) {
return "values.NewPlcDATE";
case DATETIME:
return "values.NewPlcDATE_AND_TIME";
default:
throw new FreemarkerException("Unsupported simple type" + simpleTypeReference.getBaseType());
}
throw new FreemarkerException("Unsupported simple type" + simpleTypeReference.getBaseType());
}

@Override
Expand Down Expand Up @@ -358,8 +359,15 @@ public String getReadBufferReadMethodCall(String logicalName, SimpleTypeReferenc
String lengthExpression = toExpression(field, field.getType(), vstringTypeReference.getLengthExpression(), null, null, false, false);
return "readBuffer.ReadString(\"" + logicalName + "\", uint32(" + lengthExpression + "))";
}
case TIME:
return "readBuffer.ReadTime(\"" + logicalName + "\")";
case DATE:
return "readBuffer.ReadDate(\"" + logicalName + "\")";
case DATETIME:
return "readBuffer.ReadDateTime(\"" + logicalName + "\")";
default:
throw new FreemarkerException("Unsupported base type" + simpleTypeReference.getBaseType());
}
throw new FreemarkerException("Unsupported base type" + simpleTypeReference.getBaseType());
}

@Override
Expand Down Expand Up @@ -458,8 +466,15 @@ public String getWriteBufferWriteMethodCall(String logicalName, SimpleTypeRefere
return "writeBuffer.WriteString(\"" + logicalName + "\", uint32(" + lengthExpression + "), \"" +
encoding + "\", " + fieldName + writerArgsString + ")";
}
case DATE:
return "writeBuffer.WriteDate(\"" + logicalName + "\"" + fieldName + writerArgsString + ")";
case TIME:
return "writeBuffer.WriteTime(\"" + logicalName + "\"" + fieldName + writerArgsString + ")";
case DATETIME:
return "writeBuffer.WriteDateTime(\"" + logicalName + "\"" + fieldName + writerArgsString + ")";
default:
throw new FreemarkerException("Unsupported base type" + simpleTypeReference.getBaseType());
}
throw new FreemarkerException("Unsupported base type" + simpleTypeReference.getBaseType());
}

public String getReservedValue(ReservedField reservedField) {
Expand Down

0 comments on commit e91f634

Please sign in to comment.