# start python callback server with a dynamic port gateway = JavaGateway( gateway_parameters=GatewayParameters(port=port), callback_server_parameters=CallbackServerParameters(port=0)) # Retrieve the port to which the python callback server was bound python_port = gateway.get_callback_server().get_listening_port() # Tell the Java side to connect to the python callback server with the new # python port, using the java_gateway_server attribute that retrieves the # GatewayServer instance addr = gateway.java_gateway_server.getCallbackClient().getAddress() gateway.java_gateway_server.resetCallbackClient(addr, python_port) # Fetch proxy objects that allow interaction with display map = gateway.getMap() for var in map: f.write("Received from Java: %s\n" % var) # Map should contain at least these: widget = map["widget"] pvs = map["pvs"] PVUtil = map["PVUtil"] ScriptUtil = map["ScriptUtil"] f.write("widget = %s\n" % str(widget)) f.write("pvs = %s\n" % str(pvs)) # From now on it looks just like the jython example: # -------------------------------------------------- trigger = PVUtil.getInt(pvs[0]) if trigger:
# Connect python side to Java, # start python callback server with a dynamic port gateway = JavaGateway(gateway_parameters=GatewayParameters(port=port), callback_server_parameters=CallbackServerParameters(port=0)) # Retrieve the port to which the python callback server was bound python_port = gateway.get_callback_server().get_listening_port() # Tell the Java side to connect to the python callback server with the new # python port, using the java_gateway_server attribute that retrieves the # GatewayServer instance addr = gateway.java_gateway_server.getCallbackClient().getAddress() gateway.java_gateway_server.resetCallbackClient(addr, python_port) # Fetch proxy objects that allow interaction with display map = gateway.getMap() for var in map: f.write("Received from Java: %s\n" % var) # Map should contain at least these: widget = map["widget"] pvs = map["pvs"] PVUtil = map["PVUtil"] ScriptUtil = map["ScriptUtil"] f.write("widget = %s\n" % str(widget)) f.write("pvs = %s\n" % str(pvs)) # From now on it looks just like the jython example: # -------------------------------------------------- trigger = PVUtil.getInt(pvs[0]) if trigger: