Skip to content
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

Feature/proxy-fmu #633

Merged
merged 47 commits into from
Aug 18, 2021
Merged

Feature/proxy-fmu #633

merged 47 commits into from
Aug 18, 2021

Conversation

markaren
Copy link
Contributor

@markaren markaren commented Apr 6, 2021

Adds proxy-fmu support to libcosim. proxy-fmu is implemented in C++ and supports automatic spawning of new processes. Thus it replaces the current usage of the JVM based fmu-proxy solution.

Closes #628

@markaren
Copy link
Contributor Author

markaren commented Apr 6, 2021

Integration works locally at this point.

@markaren markaren changed the title Feature/proxy server Feature/proxy-fmu Apr 7, 2021
@markaren markaren force-pushed the feature/proxy-server branch 2 times, most recently from 1297921 to c3e6e57 Compare April 9, 2021 12:45
@markaren
Copy link
Contributor Author

markaren commented Apr 9, 2021

Not finding FMILibrary on linux when building proxyfmu is such a weird error.
conan create works when triggered from proxyfmu repository. Why does it fail here?
I tried running plain conan install without going through conan create for libcosim first. Still the same error.

Note that the same error is reproduceable on a plain ubuntu installation.

@kyllingstad any ideas?

@markaren
Copy link
Contributor Author

Doubt it. I ran with that update susessfully yesterday and here non proxy builds fails also.

@markaren
Copy link
Contributor Author

cheduled maintenance is currently in progress. We will provide updates as necessary.
Apr 22, 14:00 UTC - 18:00 UTC
Scheduled - Detail: The DNS record http://conan.bintray.com will be routed to the new ConanCenter repository.
Impact: Temporary instability, none lasting.

If you receive this error, it is related to this maintenance:

@ljamt
Copy link
Member

ljamt commented May 6, 2021

Just build cosim-cli locally with the conan package from this branch:
libcosim/0.8.0@osp/testing-feature_proxy-server

Then reconfigured the House demo configuration to the following:

	<Simulators>
        <Simulator name="Clock" source="proxyfmu://localhost?file=Clock.fmu"/>
        <Simulator name="InnerWall" source="proxyfmu://localhost?file=InnerWall.fmu"/>
        <Simulator name="OuterWall1" source="proxyfmu://localhost?file=OuterWall1.fmu">
            <InitialValues>
                <InitialValue variable="T_outside">
                    <Real value="5.3"/>
                </InitialValue>
            </InitialValues>
        </Simulator>
        <Simulator name="OuterWall2" source="proxyfmu://localhost?file=OuterWall2.fmu">
            <InitialValues>
                <InitialValue variable="T_outside">
                    <Real value="4.9"/>
                </InitialValue>
            </InitialValues>
        </Simulator>
        <Simulator name="Room1" source="proxyfmu://localhost?file=Room1.fmu"/>
        <Simulator name="Room2" source="proxyfmu://localhost?file=Room2.fmu"/>
        <Simulator name="TempController" source="proxyfmu://localhost?file=TempController.fmu"/>
    </Simulators>

Testing with
cosim run c:\dev\cse-demos\house\OspSystemStructure_.xml -d 10

At first successful result:

@progress 1 1.000000 1.000000
@progress 2 2.000000 2.000000
@progress 3 3.000000 3.000000
@progress 4 4.000000 4.000000
@progress 5 5.000000 5.000000
@progress 6 6.000000 6.000000
@progress 7 7.000000 7.000000
@progress 8 8.000000 8.000000
@progress 9 9.000000 9.000000
@progress 10 10.000000 10.000000
[proxyfmu] Shutting down proxy for Clock::Clock done..
[proxyfmu] External proxy process for instance 'Clock' returned with status 0
[proxyfmu] Shutting down proxy for TempController::TempController done..
[proxyfmu] External proxy process for instance 'TempController' returned with status 0
[proxyfmu] Shutting down proxy for OuterWall1::OuterWall1 done..
[proxyfmu] External proxy process for instance 'OuterWall1' returned with status 0
[proxyfmu] Shutting down proxy for InnerWall::InnerWall done..
[proxyfmu] External proxy process for instance 'InnerWall' returned with status 0
[proxyfmu] Shutting down proxy for OuterWall2::OuterWall2 done..
[proxyfmu] External proxy process for instance 'OuterWall2' returned with status 0
[proxyfmu] Shutting down proxy for Room1::Room1 done..
[proxyfmu] External proxy process for instance 'Room1' returned with status 0
[proxyfmu] Shutting down proxy for Room2::Room2 done..
[proxyfmu] External proxy process for instance 'Room2' returned with status 0

But subsequent simulations gave:

Attempt 2:
Thrift: Thu May  6 16:42:20 2021 TServerSocket::listen() BIND 64466
Unhandled Exception reached the top of main: Could not bind: errno = 10013, application will now exit
[proxyfmu] External proxy process for instance 'Room1' returned with status 2
Thrift: Thu May  6 16:42:23 2021 TSocket::open() connect() <Host: localhost Port: 64466>: errno = 10061
Thrift: Thu May  6 16:42:25 2021 TSocket::open() connect() <Host: localhost Port: 64466>: errno = 10061

Attempt 3:
Thrift: Thu May  6 16:42:29 2021 TServerSocket::listen() BIND 53205
Unhandled Exception reached the top of main: Could not bind: errno = 10013, application will now exit
[proxyfmu] External proxy process for instance 'OuterWall1' returned with status 2
Thrift: Thu May  6 16:42:32 2021 TSocket::open() connect() <Host: localhost Port: 53205>: errno = 10061
Thrift: Thu May  6 16:42:34 2021 TSocket::open() connect() <Host: localhost Port: 53205>: errno = 10061

Attempt 4:
Thrift: Thu May  6 16:42:49 2021 TServerSocket::listen() BIND 53308
Unhandled Exception reached the top of main: Could not bind: errno = 10013, application will now exit
[proxyfmu] External proxy process for instance 'InnerWall' returned with status 2
Thrift: Thu May  6 16:42:52 2021 TSocket::open() connect() <Host: localhost Port: 53308>: errno = 10061
Thrift: Thu May  6 16:42:54 2021 TSocket::open() connect() <Host: localhost Port: 53308>: errno = 10061

Curious to hear if you see the same.

@markaren
Copy link
Contributor Author

markaren commented May 6, 2021

Hmm, runs fine here (same case). You might have been unlucky with the port selection?

@ljamt
Copy link
Member

ljamt commented May 7, 2021

Hmm, runs fine here (same case). You might have been unlucky with the port selection?

You are probably right. For me, this specific case works ~3 out of 10 attempts.

Copy link
Member

@kyllingstad kyllingstad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks really good, great work! I have some comments about error handling and formatting that I'd like you to address, but otherwise, I think this is good to go.

(Sorry for taking so long before doing the review, btw.)

src/cosim/proxy/proxy_uri_sub_resolver.cpp Outdated Show resolved Hide resolved
src/cosim/proxy/remote_fmu.hpp Show resolved Hide resolved
src/cosim/proxy/remote_slave.cpp Outdated Show resolved Hide resolved

cosim::proxy::remote_slave::~remote_slave()
{
remote_slave::end_simulation();
Copy link
Member

@kyllingstad kyllingstad May 10, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I haven't looked into the functions you're calling here, but I just want to note that one cannot throw exceptions from destructors(*). So if there is a non-neglectible chance that these functions may throw, you may want to wrap the calls in a try-catch-statement and log a message on error.

(*) Or, you can, but it causes the program to immediately crash via std::terminate().

tools/housekeeping Show resolved Hide resolved
tools/tmp_cleanup Show resolved Hide resolved
Copy link
Member

@kyllingstad kyllingstad left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job!

@markaren
Copy link
Contributor Author

markaren commented Jun 1, 2021

Can merge this once a new release has been made from master and @ljamt has vetted it. I'd also like to have #637 merged first, so I can make use of it in this PR.

markaren added 2 commits June 3, 2021 15:31
# Conflicts:
#	src/cosim/fmuproxy/fmuproxy_client.cpp
#	tests/ssp_loader_fmuproxy_test.cpp
@ljamt
Copy link
Member

ljamt commented Aug 6, 2021

Can merge this once a new release has been made from master and @ljamt has vetted it. I'd also like to have #637 merged first, so I can make use of it in this PR.

Done testing and approving the PR now. Great work!!
Apologies for the delay.

@markaren
Copy link
Contributor Author

markaren commented Aug 7, 2021

There is still the issue that this feature is not part of the unit testing though...

@ljamt
Copy link
Member

ljamt commented Aug 9, 2021

There is still the issue that this feature is not part of the unit testing though...

This PR includes two unit test files. What feature is not part of the unit testing?

@markaren
Copy link
Contributor Author

markaren commented Aug 9, 2021

Conan builds are not tested through the CI.

Lars Ivar Hatledal added 3 commits August 14, 2021 09:42
@markaren
Copy link
Contributor Author

markaren commented Aug 14, 2021

Enabled testing for this feature. Tests passes, but some other issues appeared for gcc8.

# Conflicts:
#	.github/workflows/ci-conan.yml
#	conanfile.py
@markaren markaren merged commit d23a7b4 into master Aug 18, 2021
@markaren markaren deleted the feature/proxy-server branch August 18, 2021 08:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Integrate with proxy-fmu
3 participants