Your post and all the replies indicate that your supervisor wants to “eavesdrop” on all the computers that are running this window. If that is the case, there is no need to read further.
If your supervisor, however, just wants to see what the users of a particular window are seeing, then the supervisor could simply open up a vision client that displays that window. If there are multiple windows the client could alternate between them using a timer.
Your assessment is correct. That being said, ignition is on an OT network so he would need to RD into a jump box then open the client…… Additionally we have several buildings with different ignition gateways so to see all of them he would need to RD into two different jump boxes. I don’t know about your supervisor but this is not something my boss wants or maybe even can do. He specifically requested a sharepoint site with images of three cells currently with semi-live KPI screen images with more to be added later. I have IT grabbing images from a shared folder on the jump boxes, I just need to get the client to write a screenshot into the shared folder on the gateway (s) and the job is complete.
Mind boggling. Your IT thinks shared folders on a jump box that has access to the OT network is secure?!?. Are you trolling us?
If not trolling:
Consider placing a front-end gateway in your IT network that accepts and incoming GAN connection from the OT network. And then putting suitable Perspective dashboards in the front end gateway. In this architecture, live data is pushed through a secure protocol (*cough* non-Microsoft *cough*) to the IT world.
NOT TROLLING. The idea of an OT network to our IT department is almost a foreign concept, its been both a struggle to get them on board but at the same time a blessing that they don’t have OT “rules” that limit my ability to do work. At another facility they hired a third party to build a true OT network so fun times in the wild west are going to come to an end soon. You are 100% correct that it isn’t secure. We do not have perspective licenses, that is the next challenge. I have tried several times to move us off Vision but…. Otherwise your suggestion would be a great solution. Thanks for all the help.
Understood. You will find that Perspective cannot do everything Vision can do, and vice versa. I strongly recommend my clients use both. (Vision in OT, Perspective in IT, typically.)
You may find this function useful for your scripting to see what windows are actually opened instead of just always trying to snapshot the MainWindow. system.gui.getOpenedWindows | Ignition User Manual
import os.path, sys
from java.io import File
from javax.imageio import ImageIO
This example prints out the path of each currently opened window to the console.
Component = system.gui.getWindow('Main Windows/Main Window')
bufferedImage = system.print.createImage(Component)
rawPath = system.util.getProperty("user.home") + system.util.getProperty("file.separator") +"Cletus_KPI.jpg"
formattedPath = File(r'C:\Users\Public\Pictures\KPI IMAGES ROBOT 2')
ImageIO.write(bufferedImage , "jpg", formattedPath)
print ("Snapshot success")
THis is the error I am getting, it looks like it cannot access the system folder I identified:
java.io.FileNotFoundException: C:\Users\Public\Pictures\KPI IMAGES ROBOT 2 (Access is denied) at java.base/java.io.RandomAccessFile.open0(Native Method) at java.base/java.io.RandomAccessFile.open(Unknown Source) at java.base/java.io.RandomAccessFile.(Unknown Source) at java.base/java.io.RandomAccessFile.(Unknown Source) at java.desktop/javax.imageio.stream.FileImageOutputStream.(Unknown Source) at java.desktop/com.sun.imageio.spi.FileImageOutputStreamSpi.createOutputStreamInstance(Unknown Source) at java.desktop/javax.imageio.ImageIO.createImageOutputStream(Unknown Source) at java.desktop/javax.imageio.ImageIO.write(Unknown Source) at java.base/jdk.internal.reflect.GeneratedMethodAccessor115.invoke(Unknown Source) at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) at java.base/java.lang.reflect.Method.invoke(Unknown Source) at org.python.core.PyReflectedFunction.call(PyReflectedFunction.java:188) at org.python.core.PyReflectedFunction.call(PyReflectedFunction.java:206) at org.python.core.PyObject.call(PyObject.java:515) at org.python.core.PyObject.call(PyObject.java:519) at org.python.pycode._pyx20.f$0(<TimerScript:LMI_CHAMF_KPI/Snapshot @5,000ms >:17) at org.python.pycode._pyx20.call_function(<TimerScript:LMI_CHAMF_KPI/Snapshot @5,000ms >) at org.python.core.PyTableCode.call(PyTableCode.java:171) at org.python.core.PyCode.call(PyCode.java:18) at org.python.core.Py.runCode(Py.java:1614) at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:782) at com.inductiveautomation.ignition.common.script.ScriptManager.runCode(ScriptManager.java:730) at com.inductiveautomation.ignition.common.script.TimerScriptTask.run(TimerScriptTask.java:92) at java.base/java.util.TimerThread.mainLoop(Unknown Source) at java.base/java.util.TimerThread.run(Unknown Source)
import os.path, sys
from java.io import File
from javax.imageio import ImageIO
This example prints out the path of each currently opened window to the console.
Component = system.gui.getWindow('Main Windows/Main Window')
bufferedImage = system.print.createImage(Component)
rawPath = system.util.getProperty(r'C:\Users\Public\Pictures') + system.util.getProperty("file.separator") +"Cletus_KPI.jpg"
formattedPath = File(rawPath)
ImageIO.write(bufferedImage , "jpg", formattedPath)
print ("Snapshot success")
FUNCTIONAL WORKING SCRIPT, SOLVED! THANK YOU EVERYONE!!!:
import os # Import os for path handling
from java.io import File
from javax.imageio import ImageIO
Get the reference to the component you want to print
Component = system.gui.getWindow('Main Windows/Main Window')
Create an image of the component
bufferedImage = system.print.createImage(Component)
Define the path to save the image
basePath = r'C:\Users\Public\Pictures'
fileName = "Cletus_KPI.jpg"
Construct the full path
rawPath = os.path.join(basePath, fileName)
formattedPath = File(rawPath)
Use try-except to handle potential issues
ImageIO.write(bufferedImage, "jpg", formattedPath)
print("Snapshot success")
import os # Import os for path handling
from java.io import File
from javax.imageio import ImageIO
# Get the reference to the component you want to print
Component = system.gui.getWindow('Main Windows/Main Window')
# Create an image of the component
bufferedImage = system.print.createImage(Component)
# Define the path to save the image
formattedPath = File(File(r'C:\Users\Public\Pictures'), "Cletus_KPI.jpg")
ImageIO.write(bufferedImage, "jpg", formattedPath)
print("Snapshot success")
Very minor but now that you have a working script probably better to log this so its longer living in the vision client instead of printing. Do a try/except and log errors too in case something unexepected occurs. Otherwise congrats!