If i would like to trigger label printing from TCP printer by pressing a button on ignition Vision client what would like have to consider to get it set up? Any gateway settings, anything other thoughts please? Sorry its a bit broad question.
Tag your question as Vision or Perspective. It will matter.
i edited my question as Vision related
That’s fine but some of the experts will be watching by tag and may miss your question. That’s why I suggested the tag.
good point - i just added Vision tag
Depends on how you generate your label. ZPL, perhaps?
A Vision client can open a socket, send the bytes of ZPL, and close the socket in one go. Since it is likely to execute in less than a tenth of a second, I would just call the function that does it in the button’s actionPerformed event.
Thanks for your reply Phil.
yes it is ZPL indeed and in the project the existing code does have socket transmission code which i can simulate on chrome ZPL simulator (using local address) to see what label will look like.
I am wondering what might go wrong or what i need to consider when this label print command go to the TCP printer ?
When driven by a button, I just tolerate any error dialogs that result from comms problems.
If there is any chance of non-ASCII content, I would use the
java.net classes, not python’s
Good point regarding java classes. Thank you
Sidebar, I wonder if a
system.net.socket() context manager would be used often enough to be worth inclusion. Might just cause more confusion in Perspective…
Nah, already maxed out.
Opening and closing a socket isn’t the hard part about what most people are trying to do with sockets.
The hard part is it’s not easy to set up a long running / background task or anything that needs a more complicated lifecycle than when projects restart.
You need a PhD in Ignition’s obscure scripting implementation details to maybe not screw it up and have a memory leak.
java.net and friends are not that difficult to use, and anyone trying to use advice from StackOverflow and such will want them as-is. I wouldn’t bother.
I probably should encapsulate some of my techniques in my LifeCycle module to make this easier.