Skip to content

Commit

Permalink
v0.4.0 - docu fix (#59)
Browse files Browse the repository at this point in the history
* fixing windows handle issue

* naming fixes (#61)

* FMPy CI - second try (#62)

* debug version of FMPy tests

#TODO should be removed before PR

* removed debug statements

example and tests-latest actions where successfully tested on 17 Dec 2024 18:56 GMT

* added julia caching

* fix for PkgEval Xvfb issue

* version bump fix

---------

Co-authored-by: Simon Exner <[email protected]>

* fixes for bouncing-test and disabled FMU export for test and example (#64)

* fixes for bouncing-test and disabled FMU export for test and example

* reformatted

* scope fixes

* disabled defective tests

* fixes for fmpy-testing

* fixes for fmpy test

* formatted

* fixes for fmpytests

---------

Co-authored-by: Simon Exner <[email protected]>
Co-authored-by: Simon Exner <[email protected]>
  • Loading branch information
3 people authored Jan 15, 2025
1 parent 8c1f976 commit 0c3bdd2
Show file tree
Hide file tree
Showing 15 changed files with 376 additions and 93 deletions.
4 changes: 4 additions & 0 deletions .github/workflows/Eval.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,10 @@ jobs:
julia-arch: [x64]

steps:
# Required by PkgEval.jl as xvfb runs into issues with ubuntu 24. See ci.yml workflow of PkgEval.jl repo
- name: "Allow unprivileged user namespaces"
run: sudo sysctl -w kernel.apparmor_restrict_unprivileged_userns=0

# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it
- name: Check out repository
uses: actions/checkout@v4
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/Example.yml
Original file line number Diff line number Diff line change
Expand Up @@ -142,11 +142,17 @@ jobs:
needs: [jupyter, pluto]
if: github.event_name != 'pull_request' && github.ref_name == 'main'
runs-on: ubuntu-latest
env:
HAS_TRIGGER_TOKEN: ${{ secrets.FMI_DOC_TRIGGER_PAT != '' }}
steps:
# Trigger an repoisitory dispath event
- name: Repository Dispatch
if: ${{ env.HAS_TRIGGER_TOKEN == 'true' }}
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.FMI_DOC_TRIGGER_PAT }}
repository: 'ThummeTo/FMI.jl'
event-type: trigger-docu
- name: no-token-warning
if: ${{ env.HAS_TRIGGER_TOKEN != 'true' }}
run: echo "::warning title=no_token_for_FMI-Repo::Please trigger FMI-Docs manually!!! automatic building of documentation requires an accesstoken for FMI.jl github repository; it has to be added as secrets.FMI_DOC_TRIGGER_PAT to the FMIExport.jl repo "
10 changes: 7 additions & 3 deletions .github/workflows/TestLTS.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Test v1.10 (LTS)
name: Test (LTS)

on:
workflow_dispatch:
Expand All @@ -16,11 +16,11 @@ jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
fail-fast: false # keep other os running if one fails
matrix:
julia-version: ['lts']
julia-arch: [x64]
os: [windows-latest] # ubuntu-latest,
os: [windows-latest, ubuntu-latest]
experimental: [false]

steps:
Expand All @@ -35,6 +35,10 @@ jobs:
version: ${{ matrix.julia-version }}
arch: ${{ matrix.julia-arch }}

# Set up julia-cache
- name: Set up julia-cache
uses: julia-actions/cache@v2

# Set up cache
- name: "Set up cache"
uses: actions/cache@v4
Expand Down
10 changes: 7 additions & 3 deletions .github/workflows/TestLatest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,11 +16,11 @@ jobs:
test:
runs-on: ${{ matrix.os }}
strategy:
fail-fast: true
fail-fast: false # keep other os running if one fails
matrix:
julia-version: ['1']
julia-arch: [x64]
os: [windows-latest] # ubuntu-latest,
os: [windows-latest, ubuntu-latest]
experimental: [false]

steps:
Expand All @@ -35,6 +35,10 @@ jobs:
version: ${{ matrix.julia-version }}
arch: ${{ matrix.julia-arch }}

# Set up julia-cache
- name: Set up julia-cache
uses: julia-actions/cache@v2

# Set up cache
- name: "Set up cache"
uses: actions/cache@v4
Expand Down Expand Up @@ -66,4 +70,4 @@ jobs:
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
with:
file: lcov.info
files: lcov.info
11 changes: 5 additions & 6 deletions examples/FMI2/BouncingBall/src/BouncingBall.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ FMU_FCT_EVALUATE = function(t, x_c, ẋ_c, x_d, u, p, eventMode)
v = 0.0
end
end

end

a = (m * -g) / m # the system's physical equation (a little longer than necessary)
Expand Down Expand Up @@ -156,11 +155,11 @@ using FMIBuild: saveFMU # <= this must be excluded during exp
saveFMU(fmu, fmu_save_path; debug=true, compress=false) # <= this must be excluded during export, because saveFMU would start an infinite build loop with itself (debug=true allows debug messages, but is slow during execution!)

### some tests ###
using FMI, DifferentialEquations
fmu.executionConfig.loggingOn = true
solution = simulate(fmu, (0.0, 3.0); recordValues=["sticking"])
using Plots
plot(solution)
# using FMI, DifferentialEquations
# fmu.executionConfig.loggingOn = true
# solution = simulate(fmu, (0.0, 3.0); recordValues=["sticking"])
# using Plots
# plot(solution)

# The following line is a end-marker for excluded code for the FMU compilation process!
### FMIBUILD_NO_EXPORT_END ###
2 changes: 1 addition & 1 deletion examples/FMI2/Manipulation/src/Manipulation.jl
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ fmu = FMIBUILD_CONSTRUCTOR(dirname(sourceFMU))
import FMIBuild:saveFMU # <= this must be excluded during export, because FMIBuild cannot execute itself (but it is able to build)
saveFMU(fmu, fmu_save_path; resources=Dict(sourceFMU=>"SpringDamperPendulum1D.fmu")) # <= this must be excluded during export, because fmi2Save would start an infinte build loop with itself

# some tests
### some tests ###
# using FMI
# fmu.executionConfig.loggingOn = true
# solution = fmiSimulateME(fmu, (0.0, 5.0); dtmax=0.1, recordValues=[fmi2ValueReference(335544320)])
Expand Down
8 changes: 5 additions & 3 deletions examples/jupyter-src/Export.ipynb
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,8 @@
"metadata": {},
"outputs": [],
"source": [
"saveFMU(fmu, fmu_save_path, fmu_source_path; debug=false, compress=false) # feel free to set debug true, disabled for documentation building\n",
"# currently export is broken, therefor we will not do it\n",
"#saveFMU(fmu, fmu_save_path, fmu_source_path; debug=false, compress=false) # feel free to set debug true, disabled for documentation building\n",
"#saveFMU(fmu_save_path, fmu_source_path; debug=false, compress=false) this meight be the format after the next release"
]
},
Expand All @@ -310,8 +311,9 @@
"metadata": {},
"outputs": [],
"source": [
"mkpath(\"Export-BouncingBall_files\")\n",
"cp(fmu_save_path, joinpath(\"Export-BouncingBall_files\", \"BouncingBall.fmu\"))"
"mkpath(\"Export_files\")\n",
"# currently export is broken, therefor we will not find anything there\n",
"#cp(fmu_save_path, joinpath(\"Export_files\", \"BouncingBall.fmu\"))"
]
},
{
Expand Down
12 changes: 10 additions & 2 deletions src/FMI2_simple.jl
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ function evaluate(_component::fmi2Component, eventMode=false)
tmp_xc, ẋc, tmp_xd, p = FMU_FCT_EVALUATE(component.t, xc, ẋc, xd, u, p, eventMode)

if eventMode # overwrite state vector allowed
component.eventInfo.valuesOfContinuousStatesChanged = (xc != tmp_xc ? fmi2True : fmi2False)
component.eventInfo.valuesOfContinuousStatesChanged = (xc != tmp_xc ? fmi2True : component.eventInfo.valuesOfContinuousStatesChanged)
#component.eventInfo.newDiscreteStatesNeeded = (xd != tmp_xd ? fmi2True : fmi2False)

xc = tmp_xc
Expand Down Expand Up @@ -406,6 +406,7 @@ function simple_fmi2SetContinuousStates(_component::fmi2Component, _x::Ptr{fmi2R

if nx != length(component.fmu.modelDescription.stateValueReferences)
logWarning(component, "fmi2SetContinuousStates: Model has $(length(component.fmu.modelDescription.stateValueReferences)) states, but `nx`=$(nx).")
return fmi2StatusWarning
end

x = unsafe_wrap(Array{fmi2Real}, _x, nx)
Expand All @@ -432,7 +433,7 @@ function simple_fmi2NewDiscreteStates(_component::fmi2Component, _fmi2eventInfo:
component = dereferenceInstance(_component)

if component.state != fmi2ComponentStateEventMode
logError(component, "fmi2NewDiscreteStates must be called in event mode, mode is `$(component.state )`!")
logError(component, "fmi2NewDiscreteStates must be called in event mode, mode is `$(component.state)`!")
return fmi2StatusError
end

Expand All @@ -447,6 +448,9 @@ function simple_fmi2NewDiscreteStates(_component::fmi2Component, _fmi2eventInfo:
eventInfo.nextEventTimeDefined = fmi2False # [ToDo]
eventInfo.nextEventTime = 0.0 # [ToDo]
unsafe_store!(_fmi2eventInfo, eventInfo);

# reset
eventInfo.valuesOfContinuousStatesChanged = fmi2False

return fmi2StatusOK
end
Expand Down Expand Up @@ -476,6 +480,7 @@ function simple_fmi2GetDerivatives(_component::fmi2Component, _derivatives::Ptr{

if nx != length(component.fmu.modelDescription.derivativeValueReferences)
logWarning(component, "fmi2GetDerivatives: Model has $(length(component.fmu.modelDescription.derivativeValueReferences)) states, but `nx`=$(nx).")
return fmi2StatusWarning
end

derivatives = unsafe_wrap(Array{fmi2Real}, _derivatives, nx)
Expand All @@ -493,6 +498,7 @@ function simple_fmi2GetEventIndicators(_component::fmi2Component, _eventIndicato

if ni != length(component.fmu.modelDescription.numberOfEventIndicators)
logWarning(component, "fmi2GetEventIndicators: Model has $(length(component.eventIndicators)) states, but `ni`=$(ni).")
return fmi2StatusWarning
end

eventIndicators = unsafe_wrap(Array{fmi2Real}, _eventIndicators, ni)
Expand All @@ -513,6 +519,7 @@ function simple_fmi2GetContinuousStates(_component::fmi2Component, _x::Ptr{fmi2R

if nx != length(component.fmu.modelDescription.stateValueReferences)
logWarning(component, "fmi2GetContinuousStates: Model has $(length(component.fmu.modelDescription.stateValueReferences)) states, but `nx`=$(nx).")
return fmi2StatusWarning
end

x = unsafe_wrap(Array{fmi2Real}, _x, nx)
Expand All @@ -530,6 +537,7 @@ function simple_fmi2GetNominalsOfContinuousStates(_component::fmi2Component, _x_

if nx != length(component.fmu.modelDescription.stateValueReferences)
logWarning(component, "fmi2GetNominalsOfContinuousStates: Model has $(length(component.fmu.modelDescription.stateValueReferences)) states, but `nx`=$(nx).")
return fmi2StatusWarning
end

x_nominal = unsafe_wrap(Array{fmi2Real}, _x_nominal, nx)
Expand Down
1 change: 1 addition & 0 deletions test/Project.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
[deps]
Conda = "8f4d0f93-b110-5947-807f-2305c1781a2d"
Dates = "ade2ca70-3891-5945-98fb-dc099432e06a"
FMIBuild = "226f0e26-6dd6-4589-ada7-1d32f6e1d800"
FMIImport = "9fcbc62e-52a0-44e9-a616-1359a0008194"
FMIZoo = "724179cf-c260-40a9-bd27-cccc6fe2f195"
Expand Down
55 changes: 0 additions & 55 deletions test/bouncing_ball.jl

This file was deleted.

Loading

0 comments on commit 0c3bdd2

Please sign in to comment.