Thanks for any responses.
ZPL Macro will be the fastest to implement for sure. Pick up the supplied sample, modify it as required, and BLAM! it's ready to go.
A ZOS-API operand will require some external compiler, like Visual Studio, but it's still pretty easy assuming you also know C#, Python, MatLab etc as the coding language is not supplied with OpticStudio. This kind of extension is a separate program that connects to OS.
Don't use DDE for a new project. ZOS-API replaces DDE, and we only support it for backwards compatibility. Don't start a new project using DDE.
The speed differences are really down to the calculation you need to perform. ZPL is quite fast, and has a low overhead as it's built into ZOS. ZOS-API gives you the speed of a fully compiled application, with a little more overhead as you have to set up the interprocess communication. However ZPL does not have a libray of FFT or statistical functions etc for you to call, so if it isn't already supported as a ZPL keyword you'll have to roll your own.
I would suggest starting with a ZPLM operand. 90% of the issue is getting the program flow (your algorithm) correct, and the macro will likely to be 'fast enough'. However, if you are writing this operand for other people to use, or if you need more speed, then convert it to ZOS-API using C# (or anything else, but I use C# and find it fairly easy to write simple things, whilst having the ability for the more talented/knowledgeable to produce truly well-optimized code).
In general, people are much more forgiving of their own code's foibles, so if you are going to be the only user, a ZPLM macro will be fine unless you're doing something with a heavy computational load. If you're expecting other people to use it, use ZOS-API as it's faster, and you also get access to whatever the compiler offers in error handling, user feedback, etc.
HTH,
- Mark
Also, to avoid the overhead as much as possible, combine as many calculations as possible into one macro call. For relatively simple calculations, the execution time is dominated by the overhead.
Thanks so much for you reply. This was the exact information I was looking for!
Best,
Ramzi
I do think that sometimes ZPL gets a bum rap because it's so easy to use. Despite being interpreted and not compiled, it has low calling overhead and is often perfectly 'fast enough'. You do need to be doing something pretty intensive to really need a compiled alternative.
All the other advice Paul gives is spot-on too. Just pay the overhead once, and get your macro/extension/API to do everything you need, and then send the data back via multiple calls. Don't write separate code for each piece of data, as you'll pay the overhead every time.
Reply
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.