EnEff-BIM / EnEffBIM-Framework

translating from BIM to BEPS
MIT License
8 stars 0 forks source link

SWIG API Implementation #84

Closed PRemmen closed 8 years ago

PRemmen commented 9 years ago

The newest version is implemented with SWIG.

Right now, there are probably some Python Versions issue. Jun and me will look into that.

@math-boy could you shortly comment on the strength/limitations and occuring problems with SWIG

PRemmen commented 9 years ago

@math-boy What is the current status of the Python version issues and the binding with SWIG in general?

math-boy commented 9 years ago

@PRemmen The work was delayed as I got a serious cold last Thur. I just resume my work today. Here is a brief summary of the advantage we using SWIG: 1) Robust: the 1st SWIG was developed in 1995. 2) Active: the latest SWIG was released August 3, 2015 3) Flexible: SWIG uses its own developed C++ code parser, which support all the ANSI C/C++ syntax, can generate the Python wrapper automatically if our interface file is correct. Not like the Boost.Python parser Pyster, they do not need to generate the Python wrapper, however, they need to call external parser gccxml for the C++ directive generation, which will fail on parsing the external libs we are using. Not like SIP, SIP does not include a full C++ parser, so we need manually compose a set of different C++2Python specification files.

math-boy commented 9 years ago

@PRemmen A limitation of SWIG: as SWIG generate the Python wrapper automatically based on its C++ code parser instead of using manually developed C++2Python specification files, like SIP, the code efficiency might be lower than SIP.

PRemmen commented 9 years ago

@math-boy

Thanks a lot for the new code! :) However, I got still some trouble with dll import (as in the version before). Here is what I get:

neue bitmap

Do you have any idea/solution to this problem? I would like to test the API before TelCo an Wednesday to give you feedback.

@PRemmen Can you bring your laptop to my office tmr? Then we can sit together to see what kind of libraries we need to install on pc.

math-boy commented 9 years ago

@PRemmen Hi Peter, I just upload a new demo of the SimModel API here: https://github.com/EnEff-BIM/EnEffBIM-Framework/tree/LibSimmodel_API/LibSimModelAPI The new demo has following updates: 1) It is running under the Python 3.5.0 32-bit environment. 2) The SimXML loading function SimModel() is working for Python now. So you can specify the SimXML file you wanna load by giving the file directory and name, like: SimModel("Boiler_Gas_VDI6020Test.xml"). The 1st use case data is loaded correctly in Python side. 3) The SimXML file syntax validation is integrated into the SimModel() function, and also working in Python side. If the use case data has some errors, the SimModel_() will output the error info from the C++ to your Python console. 4) A part of the hierarchy is automatically wrapped for the Python side testing. You can see the following class inheritance and their internal property functions are automatically wrapped by SWIG via the file 'test_dll.py': SimBuilding_Building_Default->SimBuilding_Building->SimBuilding->SimSpatialStructureElement->SimObject->SimObjectDefinition->SimRoot. Here SimRoot is the base class of SimModel, defining the general info of a SimModel elment, e.g. the RefId() The SimBuilding_Building_Default is a child class using in the SimXML file for defining the basic data of a building element, e.g., the BuildingHeight() 4) Further development: as you can see in the runme.py file, when we call the function SimBuilding_Building_Default (), a list of SimBuilding_Building_Default elements will be returned. However, the list structure SimBuilding_Building_Default_sequence now is not iterable as the internal API converting C++ vector into Python list is under testing. I hope we can finish the developing in 1 or 2 days. Then you can retrieve each single element of the list. 5) When I finished the step 4), I will extend my SWIG interface file to finish the other SimModel classes binding. For this step, I think we can finish it in 1 or 2 days if no new technical problems found.

PRemmen commented 9 years ago

@math-boy yes no porblem, if really additional packages are needed we can add them to the requirement in coteto. What kind of extra packages did you install?

Off topic: i think it would be better to not edit my comment and instead create a new comment, then we will get notifications :)

math-boy commented 9 years ago

@PRemmen I'm using Codesythesis XSD lib to compile my SimModel C++ functions, using SWIG to wrap the C++ API and generate the Python wrapper. It might be due to some dll library are not packed into the pyd file. I'm checking it, and will upload a new version if I find something is missing. Because I think you do not need to install above two tools as they are too large for only using the API.

math-boy commented 9 years ago

@PRemmen Hi Peter, I found the reason: the github ignored some file of my uploading. I'll try to upload them again after changing the .gitignore file. Otherwise, pls just bring your laptop to my office tmr, and we copy all the data into your pc.

math-boy commented 9 years ago

@PRemmen Hi Peter, pls download a tool from this link: http://www.dependencywalker.com/ Our program is 32bit, so you need this: http://www.dependencywalker.com/depends22_x86.zip Then use this tool to open the pyd file to check which dll library is missed on your system. We can copy them from my pc to your system.

PRemmen commented 9 years ago

Okay, but I guess we need to find general solution for that, e.g. include them into coteto install.

math-boy commented 9 years ago

No worry about this issue. When we find the dependency on ur pc, next time I can compile a static lib including all of these dependent libs.

Peter Remmen notifications@github.com<mailto:notifications@github.com> ? 02.11.2015 20:40 ???

Okay, but I guess we need to find general solution for that, e.g. include them into coteto install.

Reply to this email directly or view it on GitHubhttps://github.com/EnEff-BIM/EnEffBIM-Framework/issues/84#issuecomment-153135401.

thorade commented 9 years ago

I had that DependencyWalker software installed already and just checked the file EnEffBIM-Framework\LibSimModelAPI\LibSimModelAPI\_test_dll.pyd. Two dlls are missing:

thorade commented 9 years ago

@math-boy would it be difficult to use Python 3.4 instead of 3.5? Then we can use WinPython, they offer a portable installation that comes with lots of packages preinstalled and Jörg, Peter and me use that distribution. https://winpython.github.io/ I guess they will offer Python 3.5 in a couple of weeks. https://github.com/winpython/winpython/issues/67

thorade commented 9 years ago

I just used

git clean -xdn
git clean -xdf

to remove all the ignored files and directories. This is is useful especially after mass-renaming stuff.

PRemmen commented 9 years ago

Just talked to @math-boy

The mentioned missing DLL have been the problem. Jun will compile them with the next upload.

Also agreed to use Python 3.4 / WinPython.

math-boy commented 9 years ago

@thorade Thank you very much for the useful feedback. As @PRemmen said, we agree with your suggestion. And I just upload these two dependent dll libs into our repository.

thorade commented 9 years ago

I am currently downloading WinPython 3.4 with 32bit so I can run the runme.py, but the download server seems to be slow.

Dependency Walker did now find all first level dependencies, but there are some unresolved implicit dependencies:

Warning: At least one delay-load dependency module was not found. Warning: At least one module has an unresolved import due to a missing export function in a delay-load dependent module.

Not sure, maybe these are just warnings, not errors.

thorade commented 9 years ago

http://stackoverflow.com/questions/7378959/how-to-check-for-dll-dependency One can also use Visual Studio or Sysinternals Process Explorer to analyze dependencies: https://technet.microsoft.com/de-de/sysinternals/bb842062

math-boy commented 9 years ago

@thorade Thank you for your solution. I'll publish an entire package next time including all dependencies required by a clean pc.

math-boy commented 8 years ago

Hi @PRemmen and @thorade , I just upload a new version of our demo: 1) We can access the internal property of SimModel now 2) Some additional functions are under developing. See the runme.py comments. 3) The SWIG based automated framework is proved that we can generate the Python API automatically. I'll begin to finish all the remaining work in 7 to 10 days. 4) The demo is compiled with Python 3.5. I'll install the version 3.4 next time.

thorade commented 8 years ago

We had problems running the runme.py on two computers , the error message was about some dll missing (unfortunately, it did not say which one). Installing CodeSynthesis XSD (and a reboot) seems to fix that problem, I will use DependencyWalker to find out which DLL exactly was missing.

Should we include all required dlls or is it preferred to install CodeSynthesis XSD on all computers? That is also OK, but then we should mention it somewhere.

codesynthesis_xsd

math-boy commented 8 years ago

@thorade XERCES-C_3_1_VC100.DLL copy this dll into the local folder if the CodeSynthesis XSD is not installed on your PC. I will add this dll into the release package next time.