printing from ZEN Macro to TCP-IP Client

Everything OAD-related that won't fit in the other categories: share general aspects of macro programming and discuss the OAD environment
Post Reply
Anthony Fouad
Posts: 5
Joined: Mon Aug 30, 2021 11:24 pm

printing from ZEN Macro to TCP-IP Client

Post by Anthony Fouad »

I created a ZEN Macro named "Macro-01" that simply runs print 'running Macro-01!!'. I've configured Zen and PuTTY as described in the PDF "Developer's Guide to the TCP-IP Concept.pdf". When load Putty I correctly see "Welcome to ZEN PythonScript". But when I call Run Macro-01, instead of seeing my print, I get the response "ok". I get precisely the same behavior using a Python socket.socket() as the client. How can I receive custom feedback from the ZEN Macro?

Aside question - would it be advisable to send an image back to the client through the TCP-IP connection, or would another strategy be suggested?
CarlZeissMicroscopy3
Posts: 180
Joined: Wed May 20, 2020 10:10 am

Re: printing from ZEN Macro to TCP-IP Client

Post by CarlZeissMicroscopy3 »

Hello Anthony Fouad,
How can I receive custom feedback from the ZEN Macro?
my macro called 'MyPrintTest' looks like this:

Code: Select all

print "Hello"

When I run it with with e.g. PuTTY via
run MyPrintTest

the response is
Hello
Ok

see attachment ...

(What came to my mind: the macro has to be saved before calling it via PuTTY)
would it be advisable to send an image back to the client through the TCP-IP connection, or would another strategy be suggested?
My recommendation would be to save the image as a file on a shared drive/directory and then access the file directly.
There might be situations where sending an image back is preferred or necessary but whenever possible I use a shared drive.
Attachments
MyPrintText.png
MyPrintText.png (10.33 KiB) Viewed 5257 times
Anthony Fouad
Posts: 5
Joined: Mon Aug 30, 2021 11:24 pm

Re: printing from ZEN Macro to TCP-IP Client

Post by Anthony Fouad »

Thanks for the quick reply! I've confirmed that my Macro-01 is saved before running clients. Results below. When I run from the Macro editor I see the printouts in the "Message" window, but I'm still not getting anything sent back to clients.

Macro-01:

Code: Select all

print "Running Macro-01!!"
Response in Python (Identical responses in PuTTY using raw mode)

Code: Select all

>>> import socket
>>> s = socket.socket()
>>> s.connect(("127.0.0.1",52757))
>>> s.send("run Macro-01".encode())
12
>>> s.recv(1000).decode()
'Welcome to ZEN PythonScript\r\nOk\r\n'
CarlZeissMicroscopy3
Posts: 180
Joined: Wed May 20, 2020 10:10 am

Re: printing from ZEN Macro to TCP-IP Client

Post by CarlZeissMicroscopy3 »

Hello Anthony Fouad,

the TCP-interface of OAD is daily tested as a lot of internal Zen testing is done via this approach and most of our integration of Zen in automated systems also use it.

Therefore, we should try to clarify some points that are more additional concerns of the TCP-interface.

In a first step I would try is to rename the macro with a name not automatically given by the Zen Editor. The idea is that there might be another empty “Macro-01“ in one of the OAD Macro folders which is executed instead of your “Macro-01“. This would cause exactly the same result that you reported.

A second aspect worth inspecting is to check your installed Hotfixes of your Zen Version. The lower the number of your Zen Version, the more likely it is that it might have an influence on your TCP-Interface. Your installed Hotfixes can be found at Menu-bar Help / About Zen … / Show Zen Information / Service Packs

To check the Hotfixes available for your system please try
https://portal.zeiss.com/download-center/softwares/mic
After registration the ‘Download Center’ opens, and you can see a search field. Enter your Zen Version e.g. ‘3.1’ and click the search button. You will get a list where you search for ‘3.1’ and click ‘show all files’. Scrolling a bit down shows the last Hotfix.

I hope this helps to clarify your case.
Anthony Fouad
Posts: 5
Joined: Mon Aug 30, 2021 11:24 pm

Re: printing from ZEN Macro to TCP-IP Client

Post by Anthony Fouad »

I did apply the hotfix and try changing file names, to no avail. The problem turned out to be that Zen must be restarted completely after saving any changes to a macro before any changes will be reflected on the TCP client. Apparently Zen was caching the old version of Macro-01 which was empty and only reloads the edited files upon restarting. Thanks again for the suggestions!
CarlZeissMicroscopy3
Posts: 180
Joined: Wed May 20, 2020 10:10 am

Re: printing from ZEN Macro to TCP-IP Client

Post by CarlZeissMicroscopy3 »

Hello Anthony Fouad,
Zen must be restarted completely after saving any changes to a macro before any changes will be reflected on the TCP client
please be aware that you do not have to restart Zen!
just use
load Macro-01
e.g. in PuTTY after 'Macro-01' has been changed.

I hope this makes it easier for you to work with the TCP interface.
Anthony Fouad
Posts: 5
Joined: Mon Aug 30, 2021 11:24 pm

Re: printing from ZEN Macro to TCP-IP Client

Post by Anthony Fouad »

Thank you, that was actually a huge help!
Sebastian Bech-Terkilsen
Posts: 3
Joined: Sun Nov 22, 2020 12:51 pm

Re: printing from ZEN Macro to TCP-IP Client

Post by Sebastian Bech-Terkilsen »

Where can i find this "Developer's Guide to the TCP-IP Concept.pdf" that is referenced in this post? I have no experience with TCP-IP so it sounds like I need it, I am unsure how to get started.

Cheers, Sebastian
Post Reply