Control the ZEN Macro

Discuss macros to control the hardware functions of your ZEISS microscope
Post Reply
user-6850
Posts: 18
Joined: Thu Jan 01, 1970 1:00 am

Control the ZEN Macro

Post by user-6850 »

Dears,

I purchased Axio Imager.Z2 Vario. The laser microscope will be delivered in July.
I have an installation CD for Zen 2.6 (blue edition).
The software license is ZEN system, but the license key is before delivery.

I want to know how to create an application in Visual C++ and control ZEN now.
Because I'm working for software design of the microscope system.

I found information from the past log that can be controlled by TCP or COM, but I do not know specifically.

Could you tell me about the questions below?

Q1. I want to execute a macro created in ZEN from a Visual C ++ application, what should I do?
Q2. COM is pointing to 'MTBApi.tlb' in MTB SDK?('MTBApi.tlb' is not enough)
Q3. How do you specifically use the 'TCP Script Service' of the ZEN Macro Environment (IDE)? Is there a list of TCP commands?
Q4. Can I design without obtaining a license key?

Thanking you in advance.

Sincerely,
user-4
Posts: 398
Joined: Thu Jan 01, 1970 1:00 am

Post by user-4 »

how to create an application in Visual C++ and control ZEN
Hello Yosuke,

yes, Zen blue can be controlled by TCP or COM. If you intend to write a C++ application both alternatives are possible.

In both cases, you will need a license of Open Application Development (OAD), which includes the Python IDE plus access to TCP and COM.

For all the automation-projects I have done so far the TCP interface has been used.

There are several advantages like:
With TCP the ‘client software’ does not have to be on the same computer, whereas COM needs both software packages to be ‘close together’
TCP offers you the possibility to go cross platform, which means that the client could be on a Linux or Mac computer and Zen as a server runs on a windows platform.

The technology needed for TCP is standard with opening a connection, sending data and waiting to receive data etc. In the menu Tools, Options, Macro you can configure the TCP-Setting if necessary. You can start your first tests with a console application like PuTTY (a nice program that you can download for free in the internet). Simply type ‘help’ in e.g. PuTTY to get a list of commands available. In most cases, you can easily switch the client from your C++ application to e.g. PuTTY to check your development.

In comparison, COM has to be registered and can be very tricky if things do not work (any more). After installing new releases or hotfixes etc. it might be necessary to unregister the old interface and register the new one.

With TCP the main idea is to develop the program or step of your workflow in the Python Macro Environment and then call ‘run MyMacro’ via TCP. When using COM it is also recommended to do the first steps in the Python Macro Environment to get things running. In the next step you have to transfer the macro to COM. Although the Python macro and COM use the same Object Library translating the macro to COM is not strait forward for some technical reasons. One reason is, that COM does not know overloading of functions, so your call in Python MyFunction(...) might be MyFunction_3(...) in COM etc.

I do not want to state that COM is just second best. Quite a lot of people use the COM-Interface to connect ‚normal‘ Python, which produces native code like C++, or other software packages like MatLab to Zen.

There are several contribution on the ‘TCP interface’ and the ‘COM interface’ in this forum!
user-6850
Posts: 18
Joined: Thu Jan 01, 1970 1:00 am

Post by user-6850 »

Dears,

Thank you for your reply.

We will try to use TCP.

Is there a way to get a command list other than typing 'help'?
Currently, I can only use ZEN lite.

Is there a manual for the command?

Sincerely,
user-4
Posts: 398
Joined: Thu Jan 01, 1970 1:00 am

Post by user-4 »

Is there a way to get a command list?
I think there is still a basic misunderstanding concerning the TCP-Interface.

The primary advantage of the TCP-Interface is how it is used. The main part of programming is done directly in the Python Macro Environment of Zen. So all the ‘commands’ you will use are written in Python, which means that this forum will give you a good impression what and how it can be done. When you have written your macro (starting an experiment, doing some analysis, saving the results in a file etc.) this ‘functional entity’ gets a name and is executed via TCP by using the command ‘run macroname’.

In addition to a simple ‘run macroname’ you can also run the macro plus transferring parameters, if needed.

If you want to send feedback to the client, e.g. at the end of a macro, you will write something like print ‘well done’. However, this print command is not part of the TCP-Interface but a line of code in the Python macro.

Therefore, you need a Zen blue system with an Open Application Development license to gather some experience with the integrated Python environment.
In a second step you can run your already existing macros via TCP.
user-6850
Posts: 18
Joined: Thu Jan 01, 1970 1:00 am

Post by user-6850 »

Dears,

Thank you for your reply.

I almost understood it.

・ I need to write code in ZEN
・ I can transfer ‘run macroname’ and parameters
・ The client (creation software) can synchronize with the server (ZEN)
・ I need to get ZEN early and gain experience

Thank you for giving me good advice.

Sincerely,
user-4
Posts: 398
Joined: Thu Jan 01, 1970 1:00 am

Post by user-4 »

Yes, very good summary!

I just would like to add a bit to the last point

I need to get ZEN plus OAD early and gain experience

as OAD does not come automatically with Zen.

Getting Zen early:
Even if the microscope is not already installed, you can use Zen, OAD and thus TCP (all with license) when you click “Zen image processing” at the start of Zen. With “Zen image processing” you will get a full blown Zen and OAD where just the interface to the acquisition methods (like experiment, live and continuous) are missing (not working).
I am not sure if the Zeiss Sales Process in your country/case allows to give out the license ahead, so please carefully ask your local sales people ;-)
Post Reply