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
Delphi wrapper #892
Comments
Bruce, a) For the Delphi code, best would be if you could figure out how to do a b) I don't think there is anything wrong with R22 - On Wed, Dec 9, 2015 at 11:04 AM, Bruce Wernick notifications@github.com
|
OK, I will try the pull request. It could be a bug in my code but it is strange that it works correctly over the entire range except for this little region of high pressure liquid. Here, you can see the actual line that crashes: procedure TMainForm.PaintBox1MouseMove(Sender: TObject; Shift: TShiftState; X, |
Sorry, I clicked the wrong button! |
OK, I have created a pull request and copied a single Delphi project with all associated source code. I have commented all places in the code where it crashes. Strange thing is that if I wrap the error in a try/except, it actually does what it is expected. |
Are you passing the correct arguments to the functions? For instance, in EXPORT_CODE long CONVENTION get_global_param_string(const char *param, char and I don't see where in your code you pass the length of the output buffer. On Wed, Dec 9, 2015 at 11:34 PM, Bruce Wernick notifications@github.com
|
Ja, I wondered about that. Initially I had an integer but then I saw your Lazarus example didn't have it so I took it out.
You are right, I should go back to the C source to make sure the interface is correct. |
OK, the integer resolved the problem with these calls
But, it doesn't explain the inconsistency here:
It works without problem everywhere except for that one little region! |
Here is a single point demo that illustrates the crash in the dll. I've kept it as simple as possible to avoid any confusion.
Now, the same point with Python.
The Python code runs without problems. The DLL crash is a runtime error 207. |
Thanks for the example. I plan to dig into this in the near future and see On Fri, Dec 11, 2015 at 11:51 AM, Bruce Wernick notifications@github.com
|
Here is a good clue. If I disable the fpu exceptions, the DLL works.
So, the fault is very likely to be something like the 8087 stack overflow from recursive calls |
Very interesting. I think we are close to figuring out what is going on. On Fri, Dec 11, 2015 at 12:08 PM, Bruce Wernick notifications@github.com
|
Calling DLL from C++ (VS2013 64-bit for both DLL and executable, with default flags from cmake) works just fine
|
I tried calling the DLL from python with the exact inputs that cause you failure. Also, no failure. Where do you get your DLL from? Did you built it yourself? If so,how did you build it? |
I can't debug what I can't cause to fail. |
This becomes very interesting for me too. The problems described in #891 are also related to calling a DLL from Delphi and I thought I handled all the fpu-related issues, but obviously, I did not succeed. |
I understand that you can't find a solution when you can't actually repeat the same problem. I have had the same thing with my own software. Just to make things a little more confusing, here I use Python to read the same DLL and it works!
So, this means that there is a problem when called by Delphi. |
I will persist with the Delphi problem, maybe I can help to identify the cause. We know that the Delphi code works when the fpu exception is disabled. Could it be my Delphi settings? |
I have found some links suggests that this is common problem with Delphi. Apparently, most compilers disable the fpu while the Delphi compiler specifically enables it. |
Should we add a note to the Delphi/Lazarus wrapper page? Could you write a brief paragraph in #893 ? |
Yes, I am very happy to hear this problem is only in Delphi !!! I tried On Sat, Dec 12, 2015 at 10:04 AM, Jorrit Wronski notifications@github.com
|
I have updated my project4 demo. It uses the win32 shared dll with Delphi and is working well with all refrigerants. For fun, I added some features like a screenshot and a copy selected point to clipboard. |
The Delphi wrapper seems to have some errors (probably just out of date). I had to do a bit of trial and error and managed to get most parts working.
[I tried to attach all the code but it wouldn't accept then - how do I submit some code?].
{
Delphi Interface for CoolProp
Bruce Wernick, 9 December 2015
}
unit cpIntf;
interface
const
cpdll = 'CoolProp.dll';
type
CoolChar = AnsiChar;
PCoolChar = PAnsiChar;
CoolStr = AnsiString;
CoolVec = array[0..1023] of CoolChar;
function get_global_param_string(
param: PCoolChar;
var res: CoolVec): LongInt; stdcall;
external cpdll name '_get_global_param_string@12';
function get_fluid_param_string(
fluid: PCoolChar; param: PCoolChar;
var Output: CoolVec): Longint; stdcall;
external cpdll name '_get_fluid_param_string@12';
function PropsSI(spec: PCoolChar;
prop1: PCoolChar; val1: Double;
prop2: PCoolChar; val2: Double;
ref: CoolStr): Double; stdcall;
external cpdll name '_PropsSI@32';
function Props1SI(spec: PCoolChar;
ref: CoolStr): Double; stdcall;
external cpdll name '_Props1SI@8';
function HAPropsSI(spec: PCoolChar;
prop1: PCoolChar; val1: Double;
prop2: PCoolChar; val2: Double;
prop3: PCoolChar; val3: Double): Double; stdcall;
external cpdll name '_HAPropsSI@40';
implementation
begin
end.
When I started using it, I kept getting the odd error. So, I plotted a ph-chart and on every error, I draw a yellow blob.
The attached picture shows R22 but a similar pattern happens with all the other fluids.
The text was updated successfully, but these errors were encountered: