Skip to content

Commit

Permalink
Move base clocks info from SHARED.EVENT_INFO record to SHARED record
Browse files Browse the repository at this point in the history
  • Loading branch information
gossen authored and OpenModelica-Hudson committed Jul 3, 2015
1 parent 2362cf3 commit 1f4d2f2
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 35 deletions.
8 changes: 7 additions & 1 deletion Compiler/BackEnd/BackendDAE.mo
Expand Up @@ -126,9 +126,16 @@ uniontype Shared "Data shared for all equation-systems"
BackendDAEType backendDAEType "indicate for what the BackendDAE is used";
SymbolicJacobians symjacs "Symbolic Jacobians";
ExtraInfo info "contains extra info that we send around like the model name";
PartitionsInfo partitionsInfo;
end SHARED;
end Shared;

uniontype PartitionsInfo
record PARTITIONS_INFO
array<.DAE.ClockKind> clocks;
end PARTITIONS_INFO;
end PartitionsInfo;

uniontype ExtraInfo "extra information that we should send around with the DAE"
record EXTRA_INFO "extra information that we should send around with the DAE"
String description "the model description string";
Expand Down Expand Up @@ -536,7 +543,6 @@ uniontype EventInfo
list<ZeroCrossing> sampleLst "[deprecated] list of sample as before, only used by cpp runtime (TODO: REMOVE ME)";
list<ZeroCrossing> relationsLst "list of zero crossing function as before";
Integer numberMathEvents "stores the number of math function that trigger events e.g. floor, ceil, integer, ...";
array<.DAE.ClockKind> clocks;
end EVENT_INFO;
end EventInfo;

Expand Down
5 changes: 3 additions & 2 deletions Compiler/BackEnd/BackendDAECreate.mo
Expand Up @@ -133,7 +133,7 @@ algorithm
eqnarr := BackendEquation.listEquation(eqns);
reqnarr := BackendEquation.listEquation(reqns);
ieqnarr := BackendEquation.listEquation(ieqns);
einfo := BackendDAE.EVENT_INFO(timeEvents, whenclauses_1, {}, {}, {}, 0, arrayCreate(0, DAE.INFERRED_CLOCK()));
einfo := BackendDAE.EVENT_INFO(timeEvents, whenclauses_1, {}, {}, {}, 0);
symjacs := {(NONE(), ({}, {}, ({}, {})), {}), (NONE(), ({}, {}, ({}, {})), {}), (NONE(), ({}, {}, ({}, {})), {}), (NONE(), ({}, {}, ({}, {})), {})};
outBackendDAE := BackendDAE.DAE(BackendDAEUtil.createEqSystem(vars_1, eqnarr)::{},
BackendDAE.SHARED(knvars,
Expand All @@ -149,7 +149,8 @@ algorithm
einfo,
extObjCls,
BackendDAE.SIMULATION(),
symjacs,inExtraInfo));
symjacs,inExtraInfo,
BackendDAE.PARTITIONS_INFO(arrayCreate(0, DAE.INFERRED_CLOCK()))));
BackendDAEUtil.checkBackendDAEWithErrorMsg(outBackendDAE);
neqStr := intString(BackendDAEUtil.equationSize(eqnarr));
nvarStr := intString(BackendVariable.varsSize(vars_1));
Expand Down
5 changes: 2 additions & 3 deletions Compiler/BackEnd/BackendDAEOptimize.mo
Expand Up @@ -259,14 +259,13 @@ protected
list<BackendDAE.WhenClause> whenClauseLst;
list<BackendDAE.ZeroCrossing> zeroCrossingLst, sampleLst, relationsLst;
Integer numberMathEvents;
array<DAE.ClockKind> clocks;
algorithm
BackendDAE.EVENT_INFO(timeEvents, whenClauseLst, zeroCrossingLst, sampleLst, relationsLst, numberMathEvents, clocks) := iEventInfo;
BackendDAE.EVENT_INFO(timeEvents, whenClauseLst, zeroCrossingLst, sampleLst, relationsLst, numberMathEvents) := iEventInfo;
(whenClauseLst, outTypeA) := traverseWhenClauseExps(whenClauseLst, func, inTypeA, {});
(zeroCrossingLst, outTypeA) := traverseZeroCrossingExps(zeroCrossingLst, func, outTypeA, {});
(sampleLst, outTypeA) := traverseZeroCrossingExps(sampleLst, func, outTypeA, {});
(relationsLst, outTypeA) := traverseZeroCrossingExps(relationsLst, func, outTypeA, {});
oEventInfo := BackendDAE.EVENT_INFO(timeEvents, whenClauseLst, zeroCrossingLst, sampleLst, relationsLst, numberMathEvents, clocks);
oEventInfo := BackendDAE.EVENT_INFO(timeEvents, whenClauseLst, zeroCrossingLst, sampleLst, relationsLst, numberMathEvents);
end traverseEventInfoExps;

protected function traverseWhenClauseExps<T>
Expand Down
5 changes: 3 additions & 2 deletions Compiler/BackEnd/BackendDAEUtil.mo
Expand Up @@ -8000,7 +8000,8 @@ protected
DAE.FunctionTree functions = DAEUtil.avlTreeNew();
algorithm
shared := BackendDAE.SHARED( emptyVars, emptyVars, emptyVars, emptyEqs, emptyEqs, {}, {}, cache, graph,
DAEUtil.avlTreeNew(), BackendDAEUtil.emptyEventInfo(), {}, backendDAEType, {}, ei);
DAEUtil.avlTreeNew(), BackendDAEUtil.emptyEventInfo(), {}, backendDAEType, {}, ei,
BackendDAE.PARTITIONS_INFO(arrayCreate(0, DAE.INFERRED_CLOCK())) );
end createEmptyShared;

public function makeSingleEquationComp
Expand Down Expand Up @@ -8282,7 +8283,7 @@ end setSharedOptimica;
public function emptyEventInfo
output BackendDAE.EventInfo info;
algorithm
info := BackendDAE.EVENT_INFO({}, {}, {}, {}, {}, 0, emptyClocks());
info := BackendDAE.EVENT_INFO({}, {}, {}, {}, {}, 0);
end emptyEventInfo;

public function emptyClocks
Expand Down
3 changes: 1 addition & 2 deletions Compiler/BackEnd/BackendDump.mo
Expand Up @@ -267,7 +267,6 @@ protected
BackendDAE.ExternalObjectClasses extObjClasses;
BackendDAE.BackendDAEType backendDAEType;
BackendDAE.SymbolicJacobians symjacs;
array<DAE.ClockKind> clocks;
algorithm
BackendDAE.SHARED(knownVars=knownVars,
externalObjects=externalObjects,
Expand All @@ -276,7 +275,7 @@ algorithm
removedEqs=removedEqs,
constraints=constraints,
eventInfo=BackendDAE.EVENT_INFO( timeEvents=timeEvents, relationsLst=relationsLst, zeroCrossingLst=zeroCrossingLst,
sampleLst=sampleLst, whenClauseLst=whenClauseLst, clocks = clocks ),
sampleLst=sampleLst, whenClauseLst=whenClauseLst ),
extObjClasses=extObjClasses,
backendDAEType=backendDAEType,
symjacs=symjacs) := inShared;
Expand Down
5 changes: 2 additions & 3 deletions Compiler/BackEnd/BackendInline.mo
Expand Up @@ -515,13 +515,12 @@ algorithm
BackendDAE.EventInfo ev;
Boolean b1, b2, b3;
list<BackendDAE.TimeEvent> timeEvents;
array<DAE.ClockKind> clocks;

case(BackendDAE.EVENT_INFO(timeEvents, wclst, zclst, samples, relations, numberOfMathEvents, clocks), fns) equation
case(BackendDAE.EVENT_INFO(timeEvents, wclst, zclst, samples, relations, numberOfMathEvents), fns) equation
(wclst_1, b1) = inlineWhenClauses(wclst, fns, {}, false);
(zclst_1, b2) = inlineZeroCrossings(zclst, fns, {}, false);
(relations, b3) = inlineZeroCrossings(relations, fns, {}, false);
ev = if b1 or b2 or b3 then BackendDAE.EVENT_INFO(timeEvents, wclst_1, zclst_1, samples, relations, numberOfMathEvents, clocks)
ev = if b1 or b2 or b3 then BackendDAE.EVENT_INFO(timeEvents, wclst_1, zclst_1, samples, relations, numberOfMathEvents)
else inEventInfo;
then ev;

Expand Down
22 changes: 9 additions & 13 deletions Compiler/BackEnd/FindZeroCrossings.mo
Expand Up @@ -115,19 +115,17 @@ protected
BackendDAE.Variables vars_;
BackendDAE.EquationArray eqns_;
BackendDAE.ExtraInfo info;
array<DAE.ClockKind> clocks;
BackendDAE.EventInfo eventInfo;

algorithm
BackendDAE.DAE(systs, shared) := inDAE;
BackendDAE.SHARED(removedEqs=removedEqs, eventInfo=eventInfo) := shared;
BackendDAE.EVENT_INFO(timeEvents=timeEvents,
whenClauseLst=whenClauseLst,
zeroCrossingLst=zeroCrossingLst,
sampleLst=sampleLst,
relationsLst=relationsLst,
numberMathEvents=numberMathEvents,
clocks=clocks) := eventInfo;
BackendDAE.EVENT_INFO( timeEvents=timeEvents,
whenClauseLst=whenClauseLst,
zeroCrossingLst=zeroCrossingLst,
sampleLst=sampleLst,
relationsLst=relationsLst,
numberMathEvents=numberMathEvents ) := eventInfo;

ht := HashTableExpToIndex.emptyHashTable();

Expand All @@ -150,8 +148,7 @@ algorithm
zeroCrossingLst,
sampleLst,
relationsLst,
numberMathEvents,
clocks);
numberMathEvents);

shared := BackendDAEUtil.setSharedEventInfo(shared, eventInfo);
shared := BackendDAEUtil.setSharedRemovedEqns(shared, removedEqs);
Expand Down Expand Up @@ -670,14 +667,13 @@ algorithm
list<BackendDAE.ZeroCrossing> zero_crossings;
list<BackendDAE.ZeroCrossing> relations, sampleLst;
Integer countMathFunctions;
array<DAE.ClockKind> clocks;
//No zero crossing for clocked discrete partitions;
case BackendDAE.CLOCKED_PARTITION(subClock=BackendDAE.SUBCLOCK(solver=NONE()))
then (inSyst, inShared);
else
algorithm
BackendDAE.SHARED( knownVars=knvars, eventInfo=einfo) := inShared;
BackendDAE.EVENT_INFO( timeEvents=timeEvents, zeroCrossingLst=zero_crossings, clocks=clocks,
BackendDAE.EVENT_INFO( timeEvents=timeEvents, zeroCrossingLst=zero_crossings,
sampleLst=sampleLst, whenClauseLst=whenclauses, relationsLst=relations,
numberMathEvents=countMathFunctions ) := einfo;
eqs_lst := BackendEquation.equationList(eqns);
Expand All @@ -691,7 +687,7 @@ algorithm
end if;
eqns1 := BackendEquation.listEquation(eqs_lst1);
einfo := BackendDAE.EVENT_INFO( timeEvents, whenclauses, zero_crossings, sampleLst, relations,
countMathFunctions, clocks );
countMathFunctions );
then (BackendDAEUtil.setEqSystEqs(inSyst, eqns1), BackendDAEUtil.setSharedEventInfo(inShared, einfo));
end match;
end findZeroCrossings1;
Expand Down
15 changes: 7 additions & 8 deletions Compiler/BackEnd/SynchronousFeatures.mo
Expand Up @@ -131,14 +131,13 @@ protected
list<BackendDAE.ZeroCrossing> relationsLst;
Integer numberMathEvents;
algorithm
BackendDAE.SHARED(eventInfo=eventInfo) := inShared;
BackendDAE.EVENT_INFO( timeEvents=timeEvents, whenClauseLst=whenClauseLst, sampleLst=sampleLst,
zeroCrossingLst=zeroCrossingLst, relationsLst=relationsLst,
numberMathEvents=numberMathEvents) := eventInfo;
eventInfo := BackendDAE.EVENT_INFO( timeEvents=timeEvents, whenClauseLst=whenClauseLst,
zeroCrossingLst=zeroCrossingLst, relationsLst=relationsLst,
numberMathEvents=numberMathEvents, sampleLst=sampleLst, clocks = inClocks );
outShared := BackendDAEUtil.setSharedEventInfo(inShared, eventInfo);
outShared := match inShared
local
BackendDAE.Shared shared;
case shared as BackendDAE.SHARED()
algorithm shared.partitionsInfo := BackendDAE.PARTITIONS_INFO(inClocks);
then shared;
end match;
end setClocks;

protected type UnresolvedPartitionData = tuple<BackendDAE.Variables, BackendDAE.EquationArray, BackendDAE.SubClock>;
Expand Down
2 changes: 1 addition & 1 deletion Compiler/SimCode/SimCodeUtil.mo
Expand Up @@ -267,6 +267,7 @@ algorithm
constraints=constraints,
classAttrs=classAttributes,
symjacs=symJacs,
partitionsInfo=BackendDAE.PARTITIONS_INFO(baseClocks),
eventInfo=BackendDAE.EVENT_INFO(timeEvents=timeEvents))) = dlow;


Expand All @@ -289,7 +290,6 @@ algorithm
// Assertions and crap
// create parameter equations
partitionsKind = BackendDAEUtil.foldEqSystem(dlow, collectPartitions, {});
BackendDAE.DAE(shared=BackendDAE.SHARED(eventInfo=BackendDAE.EVENT_INFO(clocks=baseClocks))) = dlow;
((uniqueEqIndex, startValueEquations)) = BackendDAEUtil.foldEqSystem(dlow, createStartValueEquations, (uniqueEqIndex, {}));
((uniqueEqIndex, nominalValueEquations)) = BackendDAEUtil.foldEqSystem(dlow, createNominalValueEquations, (uniqueEqIndex, {}));
((uniqueEqIndex, minValueEquations)) = BackendDAEUtil.foldEqSystem(dlow, createMinValueEquations, (uniqueEqIndex, {}));
Expand Down

0 comments on commit 1f4d2f2

Please sign in to comment.