(07-20-2023, 10:05 AM)Albert Wrote:You should be able to do both:
- Use one instance of RoboDK with multiple API connections (multiple instances of robolink). When you use the same instance of RoboDK, item pointers are exactly the same.
- Multiple instances of RoboDK running with one or more API connections each. Make sure you start RoboDK using the -NEWINSTANCE command line option so you open a new instance of RoboDK.
I chose the second method above.
However, although 3 RDKs corresponding to ports (20501, 20502, 20503) should have been started, 3 projects are added to the RDK corresponding to port (20500) which should not be used. I want to fix this bug.
In the code below three RDKs were created.
Code:
NUM_WORKERS = 3
robodk_executable_path = "/home/***/RoboDK/RoboDK-Start.sh"
for env_no in range(1, NUM_WORKERS+1):
api_port = 20500 + env_no
subprocess.Popen(["bash", robodk_executable_path, "-NEWINSTANCE", "-PORT", str(api_port)], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
Code:
class RoboController:
def __init__(self, env_no, api_port) -> None:
self.env_no = env_no
self.api_port = api_port
self.RDK = Robolink(args=["-PORT=" + str(self.api_port),])
self.project_directory = os.path.abspath(os.path.dirname(__file__))
self.RDK.AddFile(os.path.join(self.project_directory, "./rdk/Conveying.rdk"))
print(f"RDK.AddFile - RDK: {self.RDK}, API port: {self.api_port}" )
Code:
(RoboController pid=1548973) RDK.AddFile - RDK: , API port: 20502
(RoboController pid=1548972) RDK.AddFile - RDK: , API port: 20501
(RoboController pid=1548974) RDK.AddFile - RDK: , API port: 20503