@@ -9810,17 +9810,20 @@ case SIMCODE(modelInfo = MODELINFO(__), modelStructure = fmims) then
98109810 'ModelicaMessage("Using default Clock(1.0)!");'
98119811 let subClocks = (subPartitions |> subPartition =>
98129812 match subPartition
9813- case SUBPARTITION(subClock=SUBCLOCK(factor=RATIONAL(nom=fnom, denom=fres), shift=RATIONAL(nom=snom, denom=sres))) then
9813+ case SUBPARTITION(idx=idx, subClock=SUBCLOCK(factor=RATIONAL(nom=fnom, denom=fres), shift=RATIONAL(nom=snom, denom=sres))) then
9814+ let startTime =if isBooleanClock(baseClock) then <<-1>> else <<_simTime + _clockShift[<%idx%>-1] * _clockInterval[<%idx%>-1]>>
9815+ let startCondition = if isBooleanClock(baseClock) then <<false>> else <<true>>
9816+
98149817 <<
98159818 <%preExp%>
9816- _clockInterval[<%i%> ] = <%interval%> * <%fnom%>.0 / <%fres%>.0;
9817- _clockShift[<%i%> ] = <%snom%>.0 / <%sres%>.0;
9818- _clockTime[<%i%> ] = _simTime + _clockShift[<%i%>] * _clockInterval[<%i%>] ;
9819- if( _clockShift[<%i%> ]>0)
9820- _clockCondition[<%i%> ] = false;
9819+ _clockInterval[<%idx%>-1 ] = <%interval%> * <%fnom%>.0 / <%fres%>.0;
9820+ _clockShift[<%idx%>-1 ] = <%snom%>.0 / <%sres%>.0;
9821+ _clockTime[<%idx%>-1 ] = <%startTime%> ;
9822+ if( _clockShift[<%idx%>-1 ]>0)
9823+ _clockCondition[<%idx%>-1 ] = false;
98219824 else
9822- _clockCondition[<%i%> ] =true ;
9823- _clockStart[<%i%> ] = true;
9825+ _clockCondition[<%idx%>-1 ] = <%startCondition%> ;
9826+ _clockStart[<%idx%>-1 ] = true;
98249827
98259828 <%i%> ++;
98269829 >>
@@ -12473,7 +12476,8 @@ template handleSystemEvents(list<ZeroCrossing> zeroCrossings, SimCode simCode ,T
1247312476 //if there is a single clock event, update all clock conditions
1247412477 if (clock_event_detected){
1247512478 for(int i =0;i< _dimClock;i++){
12476- if(_simTime +1e-9 > _clockTime[i]){
12479+ //check if a deterministic clockTime is reached, boolean clocks have clockTime -1
12480+ if(_simTime +1e-9 > _clockTime[i] and _clockTime[i]!= -1){
1247712481 _clockCondition[i]=true;
1247812482 }
1247912483 }
@@ -12806,9 +12810,11 @@ template clockedPartFunctions(Integer i, list<SimEqSystem> previousAssignments,
1280612810 case SUBCLOCK(factor=RATIONAL(nom=fnom, denom=fres), shift=RATIONAL(nom=snom, denom=sres))
1280712811 then
1280812812 <<
12813+ //compute new clock tick
1280912814 _clockInterval[<%idx%>] = <%intvl%> * <%fnom%>.0 / <%fres%>.0;
1281012815 _clockTime[<%idx%>] = _simTime +_clockInterval[<%idx%>] ;
1281112816 >>
12817+ let newClockTime = if isBooleanClock(baseClock) then <<_clockTime[<%idx%>] = -1;>> else clockvals
1281212818
1281312819 let funcs = listAppend(previousAssignments,equations) |> eq =>
1281412820 equation_function_create_single_func(eq, context/*BUFC*/, simCode, &extraFuncs, &extraFuncsDecl, extraFuncsNamespace, "evaluate", "", stateDerVectorName, useFlatArrayNotation, enableMeasureTime, false, false, 'const int clockIndex = <%i%>;<%\n%>')
@@ -12824,22 +12830,26 @@ template clockedPartFunctions(Integer i, list<SimEqSystem> previousAssignments,
1282412830 createEvaluateWithSplit(i0, context, eqs, funcName, className, simCode, &extraFuncs, &extraFuncsDecl, extraFuncsNamespace)
1282512831 ; separator="\n")
1282612832 let idx = intAdd(i, -1)
12833+
12834+
1282712835 <<
1282812836 <%funcs%>
1282912837
1283012838 void <%className%>::<%funcName%>(const UPDATETYPE command)
1283112839 {
1283212840
12833- <%varDecls%>
12841+ <%varDecls%>
1283412842 <%preExp%>
12843+
12844+ // do we still need _clockStart?
1283512845 if (_simTime > _clockTime[<%idx%>]) {
1283612846 _clockStart[<%idx%>] = false;
1283712847 }
12848+
1283812849 //evaluate clock partition equations
1283912850 <%funcCalls%>
1284012851
12841- //compute new clock tick
12842- <%clockvals%>
12852+ <%newClockTime%>
1284312853
1284412854 //assign the previous-vars since the step is completed
1284512855 <%funcCallsPrev%>
0 commit comments