Skip to content

Commit 900bb22

Browse files
committed
Add default clock period to fix ticket:3752
1 parent 5d18848 commit 900bb22

File tree

2 files changed

+17
-12
lines changed

2 files changed

+17
-12
lines changed

Compiler/Template/CodegenCpp.tpl

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9744,19 +9744,23 @@ case SIMCODE(modelInfo = MODELINFO(__)) then
97449744
case CLOCKED_PARTITION(__) then
97459745
let &preExp = buffer "" /*BUFD*/
97469746
let intvl = daeExp(getClockInterval(baseClock), contextOther, &preExp, &varDecls, simCode, &extraFuncs, &extraFuncsDecl, extraFuncsNamespace, stateDerVectorName, useFlatArrayNotation)
9747+
let interval = match intvl case "0.0" then '1.0' else intvl
9748+
let warning = match intvl case "0.0" then
9749+
'ModelicaMessage("Using default Clock(1.0)!");'
97479750
let subClocks = (subPartitions |> subPartition =>
97489751
match subPartition
97499752
case SUBPARTITION(subClock=SUBCLOCK(factor=RATIONAL(nom=fnom, denom=fres), shift=RATIONAL(nom=snom, denom=sres))) then
97509753
<<
97519754
<%preExp%>
9752-
_clockInterval[<%i%>] = <%intvl%> * <%fnom%>.0 / <%fres%>.0;
9755+
_clockInterval[<%i%>] = <%interval%> * <%fnom%>.0 / <%fres%>.0;
97539756
_clockShift[<%i%>] = <%snom%>.0 / <%sres%>.0;
97549757
_clockTime[<%i%>] = _simTime + _clockShift[<%i%>] * _clockInterval[<%i%>];
97559758
<%i%> ++;
97569759
>>
97579760
; separator="\n")
97589761
<<
97599762
<%subClocks%>
9763+
<%warning%>
97609764
>>
97619765
; separator="\n")%>
97629766
>>

SimulationRuntime/cpp/Core/Utils/Modelica/ModelicaUtilities.cpp

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,17 @@ extern "C" {
1717

1818
void ModelicaMessage(const char* string)
1919
{
20-
throw ModelicaSimulationError(UTILITY,"ModelicaMessage not implemented yet");
20+
fprintf(stdout, string);
21+
fflush(stdout);
2122
}
2223

23-
void ModelicaVFormatMessage(const char*string, va_list args)
24+
void ModelicaVFormatMessage(const char* string, va_list args)
2425
{
2526
vfprintf(stdout, string, args);
2627
fflush(stdout);
2728
}
2829

29-
void ModelicaFormatMessage(const char* string,...)
30+
void ModelicaFormatMessage(const char* string, ...)
3031
{
3132
va_list args;
3233
va_start(args, string);
@@ -36,22 +37,22 @@ void ModelicaFormatMessage(const char* string,...)
3637

3738
void ModelicaError(const char* string)
3839
{
39-
throw ModelicaSimulationError(UTILITY,string);
40+
throw ModelicaSimulationError(UTILITY, string);
4041
}
4142

42-
void ModelicaVFormatError(const char*string, va_list args)
43+
void ModelicaVFormatError(const char* string, va_list args)
4344
{
44-
throw ModelicaSimulationError(UTILITY,"ModelicaVFormatError not implemented yet");
45+
char buffer[256];
46+
vsnprintf(buffer, 256, string, args);
47+
ModelicaError(buffer);
4548
}
4649

47-
void ModelicaFormatError(const char* text, ...)
50+
void ModelicaFormatError(const char* string, ...)
4851
{
49-
char buffer[256];
5052
va_list args;
51-
va_start(args, text);
52-
vsnprintf(buffer, 256, text, args);
53+
va_start(args, string);
54+
ModelicaVFormatError(string, args);
5355
va_end(args);
54-
ModelicaError(buffer);
5556
}
5657

5758
static std::map<const char*, char*> _allocatedStrings;

0 commit comments

Comments
 (0)