How to log on to multiple controllers in RS from PC SDK ?
Best Answer
-
vikram6892 said:Hello Scott,Thank you very much for your answer.From your above code, I can understand that the LogOn (to controller) operation takes places as it loops through each (controller) item in the for loop.
for(int i = 0; i < _storedController.Count(); i++)
Let's say if we have 3 controllers, after the execution of the for loop, the pc application will be logged on to the 3rd controller. So I can only control or take access over the task from 3rd controller alone. Is it right ? Correct me if I am wrong.I would like to do some actions viz., start a rapid task, set program pointer to a routine, etc. in all the 3 controllers simultaneously. Will that be possible ?Controller.LogOff()
method the controllers will remain logged on. You just need to index through your list to get the controller object. Example below to do an action on all controllers;class Class1 { NetworkScanner _networkScan = new NetworkScanner(); List<Controller> _storedController = new List<Controller>(); Controller _controller; ControllerInfo[] _controllerCollection; private void ControllerLogon() { // Network scan for running robots (online and virtual) _networkScan.Scan(); // add running robots to a collection _controllerCollection = _networkScan.GetControllers(); // index through found robots for (int i = 0; i < _controllerCollection.Count(); i++) { if (_controllerCollection[i].IsVirtual) { // if controller is virtual create new Virtual Controller _controller = new Controller(_controllerCollection[i]); // add _controller to list for future use. _storedController.Add(_controller); } } for (int i = 0; i < _storedController.Count(); i++) { // Logs into each controller as default user. _storedController[i].Logon(UserInfo.DefaultUser); } } private void ControllerActions() { // Index through controllers that has default user logged on for (int i = 0; i < _storedController.Count(); i++) { // Check controller is virtual that the user is logged in if (_storedController[i].IsVirtual && _storedController[i].CurrentUser == UserInfo.DefaultUser) { // Execute your code here } } } }
It's probably better to do it asynchronously so you can access all controllers at the same time and not slow down the main thread but the above will do the job for you if you are not familiar with threading and/or not worried about losing microseconds.
1
Answers
-
I'm assuming by the IP address they're virtual robots? If so you create a new controller object for each of them then logon.
private void ControllerLogon() { NetworkScanner _networkScan = new NetworkScanner(); List<Controller> _storedController = new List<Controller>(); Controller _controller; // Network scan for running robots (online and virtual) _networkScan.Scan(); // add running robots to a collection ControllerInfo[] _controllerCollection = _networkScan.GetControllers(); // index through found robots for (int i = 0; i < aCollection.Count(); i++) { if (aCollection[i].IsVirtual) { // if controller is virtual create new Virtual Controller _controller = new Controller(aCollection[i]); // add _controller to list for future use. _storedController.Add(_controller); } } for(int i = 0; i < _storedController.Count(); i++) { // Logs into each controller as default user. _storedController[i].Logon(UserInfo.DefaultUser); } }
Alternatively you could use a new thread to logon to each of them concurrently and do whatever you want to do but you may experience cross threading issues if you then try and use the active station.0 -
Hello Scott,Thank you very much for your answer.From your above code, I can understand that the LogOn (to controller) operation takes places as it loops through each (controller) item in the for loop.
for(int i = 0; i < _storedController.Count(); i++)
Let's say if we have 3 controllers, after the execution of the for loop, the pc application will be logged on to the 3rd controller. So I can only control or take access over the task from 3rd controller alone. Is it right ? Correct me if I am wrong.I would like to do some actions viz., start a rapid task, set program pointer to a routine, etc. in all the 3 controllers simultaneously. Will that be possible ?
0 -
Hello @scottMHA,Finally I got the answer. Thank you very much.0
-
vikram6892 said:Hello Scott,Thank you very much for your answer.From your above code, I can understand that the LogOn (to controller) operation takes places as it loops through each (controller) item in the for loop.
for(int i = 0; i < _storedController.Count(); i++)
Let's say if we have 3 controllers, after the execution of the for loop, the pc application will be logged on to the 3rd controller. So I can only control or take access over the task from 3rd controller alone. Is it right ? Correct me if I am wrong.I would like to do some actions viz., start a rapid task, set program pointer to a routine, etc. in all the 3 controllers simultaneously. Will that be possible ?
The below should set the program pointer to whatever module and routine you wish.private void ControllerActions() { // Index through controllers that has default user logged on for (int i = 0; i < _storedController.Count(); i++) { // Check controller is virtual that the user is logged in if (_storedController[i].IsVirtual && _storedController[i].CurrentUser == UserInfo.DefaultUser) { // If controller execution has stopped set program pointer. if (_storedController[i].Rapid.ExecutionStatus == ExecutionStatus.Stopped) { Task[] _rapidTasks = _storedController[i].Rapid.GetTasks(); for (int j = 0; j < _rapidTasks.Count(); j++) { if (_rapidTasks[i].Name == "T_ROB1") { _rapidTasks[i].SetProgramPointer("YourModule", "YourRoutine"); } } } } } }
0
Categories
- All Categories
- 5.5K RobotStudio
- 396 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 250 ScreenMaker
- 2.8K Robot Controller
- 316 IRC5
- 61 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 798 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 5 Job listings