-
Notifications
You must be signed in to change notification settings - Fork 7
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Documentation fixes and moved to FMI.jl #49
Merged
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,35 +20,44 @@ const fmi2Real = Creal # defined in FMICore.jl, dependent on the Julia arch | |
const fmi2Integer = Cint | ||
const fmi2Byte = Char | ||
const fmi2ValueReference = Cuint | ||
|
||
""" | ||
fmi2FMUstate is a pointer to a data structure in the FMU that saves the internal FMU state of the actual or | ||
a previous time instant. This allows to restart a simulation from a previous FMU state. | ||
|
||
Source: FMI2.0.3 Spec [p.17]; See also section 2.1.8 | ||
""" | ||
const fmi2FMUstate = Ptr{Cvoid} | ||
const fmi2Component = Ptr{Cvoid} | ||
const fmi2ComponentEnvironment = Ptr{Cvoid} | ||
const fmi2Enum = Array{Array{String}} # TODO: remove, this is not part of the spec! | ||
export fmi2Char, fmi2String, fmi2Boolean, fmi2Real, fmi2Integer, fmi2Byte, fmi2ValueReference, fmi2FMUstate, fmi2Component, fmi2ComponentEnvironment, fmi2Enum | ||
|
||
const fmi2Status = Cuint | ||
const fmi2StatusOK = Cuint(0) | ||
const fmi2StatusWarning = Cuint(1) | ||
const fmi2StatusDiscard = Cuint(2) | ||
const fmi2StatusError = Cuint(3) | ||
const fmi2StatusFatal = Cuint(4) | ||
const fmi2StatusPending = Cuint(5) | ||
|
||
""" | ||
Source: FMISpec2.0.2[p.18]: 2.1.3 Status Returned by Functions | ||
|
||
Status returned by functions. The status has the following meaning: | ||
fmi2OK – all well | ||
fmi2Warning – things are not quite right, but the computation can continue. Function “logger” was called in the model (see below), and it is expected that this function has shown the prepared information message to the user. | ||
fmi2Discard – this return status is only possible if explicitly defined for the corresponding function | ||
- fmi2OK – all well | ||
- fmi2Warning – things are not quite right, but the computation can continue. Function “logger” was called in the model (see below), and it is expected that this function has shown the prepared information message to the user. | ||
- fmi2Discard – this return status is only possible if explicitly defined for the corresponding function | ||
(ModelExchange: fmi2SetReal, fmi2SetInteger, fmi2SetBoolean, fmi2SetString, fmi2SetContinuousStates, fmi2GetReal, fmi2GetDerivatives, fmi2GetContinuousStates, fmi2GetEventIndicators; | ||
CoSimulation: fmi2SetReal, fmi2SetInteger, fmi2SetBoolean, fmi2SetString, fmi2DoStep, fmiGetXXXStatus): | ||
For “model exchange”: It is recommended to perform a smaller step size and evaluate the model equations again, for example because an iterative solver in the model did not converge or because a function is outside of its domain (for example sqrt(<negative number>)). If this is not possible, the simulation has to be terminated. | ||
For “co-simulation”: fmi2Discard is returned also if the slave is not able to return the required status information. The master has to decide if the simulation run can be continued. In both cases, function “logger” was called in the FMU (see below) and it is expected that this function has shown the prepared information message to the user if the FMU was called in debug mode (loggingOn = fmi2True). Otherwise, “logger” should not show a message. | ||
fmi2Error – the FMU encountered an error. The simulation cannot be continued with this FMU instance. If one of the functions returns fmi2Error, it can be tried to restart the simulation from a formerly stored FMU state by calling fmi2SetFMUstate. | ||
- fmi2Error – the FMU encountered an error. The simulation cannot be continued with this FMU instance. If one of the functions returns fmi2Error, it can be tried to restart the simulation from a formerly stored FMU state by calling fmi2SetFMUstate. | ||
This can be done if the capability flag canGetAndSetFMUstate is true and fmi2GetFMUstate was called before in non-erroneous state. If not, the simulation cannot be continued and fmi2FreeInstance or fmi2Reset must be called afterwards.4 Further processing is possible after this call; especially other FMU instances are not affected. Function “logger” was called in the FMU (see below), and it is expected that this function has shown the prepared information message to the user. | ||
fmi2Fatal – the model computations are irreparably corrupted for all FMU instances. [For example, due to a run-time exception such as access violation or integer division by zero during the execution of an fmi function]. Function “logger” was called in the FMU (see below), and it is expected that this function has shown the prepared information message to the user. It is not possible to call any other function for any of the FMU instances. | ||
fmi2Pending – this status is returned only from the co-simulation interface, if the slave executes the function in an asynchronous way. That means the slave starts to compute but returns immediately. The master has to call fmi2GetStatus(..., fmi2DoStepStatus) to determine if the slave has finished the computation. Can be returned only by fmi2DoStep and by fmi2GetStatus (see section 4.2.3). | ||
- fmi2Fatal – the model computations are irreparably corrupted for all FMU instances. [For example, due to a run-time exception such as access violation or integer division by zero during the execution of an fmi function]. Function “logger” was called in the FMU (see below), and it is expected that this function has shown the prepared information message to the user. It is not possible to call any other function for any of the FMU instances. | ||
- fmi2Pending – this status is returned only from the co-simulation interface, if the slave executes the function in an asynchronous way. That means the slave starts to compute but returns immediately. The master has to call fmi2GetStatus(..., fmi2DoStepStatus) to determine if the slave has finished the computation. Can be returned only by fmi2DoStep and by fmi2GetStatus (see section 4.2.3). | ||
""" | ||
const fmi2Status = Cuint | ||
const fmi2StatusOK = Cuint(0) | ||
const fmi2StatusWarning = Cuint(1) | ||
const fmi2StatusDiscard = Cuint(2) | ||
const fmi2StatusError = Cuint(3) | ||
const fmi2StatusFatal = Cuint(4) | ||
const fmi2StatusPending = Cuint(5) | ||
fmi2Status, fmi2StatusOK, fmi2StatusWarning, fmi2StatusDiscard, fmi2StatusError, fmi2StatusFatal, fmi2StatusPending | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what's this? (list of status codes) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same here: one docstring for all codes (take note of the line numbers, github's formatting here is unhelpful) |
||
export fmi2Status, fmi2StatusOK, fmi2StatusWarning, fmi2StatusDiscard, fmi2StatusError, fmi2StatusFatal, fmi2StatusPending | ||
|
||
""" | ||
|
@@ -114,14 +123,15 @@ const fmi2InitialApprox = Cuint(1) | |
const fmi2InitialCalculated = Cuint(2) | ||
export fmi2Initial, fmi2InitialExact, fmi2InitialApprox, fmi2InitialCalculated | ||
|
||
const fmi2True = fmi2Boolean(true) | ||
const fmi2False = fmi2Boolean(false) | ||
""" | ||
Source: FMISpec2.0.2[p.16]: 2.1.2 Platform Dependent Definitions | ||
|
||
To simplify porting, no C types are used in the function interfaces, but the alias types are defined in this section. | ||
All definitions in this section are provided in the header file “fmi2TypesPlatform.h”. | ||
""" | ||
const fmi2True = fmi2Boolean(true) | ||
const fmi2False = fmi2Boolean(false) | ||
fmi2True, fmi2False | ||
export fmi2True, fmi2False | ||
|
||
""" | ||
|
@@ -150,7 +160,14 @@ export fmi2StatusKind, fmi2StatusKindDoStepStatus, fmi2StatusKindPendingStatus, | |
|
||
# Custom helper, not part of the FMI-Spec. | ||
""" | ||
ToDo. | ||
Types of dependency: | ||
|
||
- `fmi2DependencyKindDependent`: no particular structure, f(v) | ||
- `fmi2DependencyKindConstant`: constant factor, c*v (for Real valued variables only) | ||
- `fmi2DependencyKindFixed`: tunable factor, p*v (for Real valued variables only) | ||
- `fmi2DependencyKindDependent`: discrete factor, d*v (for Real valued variables only) | ||
|
||
Source: FMI2.0.3 Spec for fmi2VariableDependency [p.60] | ||
""" | ||
const fmi2DependencyKind = Cuint | ||
const fmi2DependencyKindDependent = Cuint(0) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is the declaration seperated from the doc string now?
(doc string starts in L44, declaration is in L36)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
because otherwise each status would need its own docstring. Even if that option is preferred, I recommend to implement it in the future and go with this solution for now