Connecting C# and Rapid Mastership problem.
Gabel
✭
Hello, im working on getting some basic communicion between C# and Rapid. But im having some truble whit the Mastership class. Note in the code "This is where my problem is", im getting "An unhandled exception of type 'ABB.Robotics.GenericControllerException' occurred in ABB.Robotics.Adapters.IRC5.dll".
Im working in microsoft visual studio professional 2012.
Here is my code:
using System;
using ABB.Robotics;
using ABB.Robotics.Controllers;
using ABB.Robotics.Controllers.Discovery;
using ABB.Robotics.Controllers.RapidDomain;
class Program{
static void Main(string[] args){
NetworkScanner scanner = new NetworkScanner();
scanner.Scan();
ControllerInfoCollection controllers = scanner.Controllers;
foreach (ControllerInfo controllerInfo in controllers){
Console.WriteLine("IPAddress: " + controllerInfo.IPAddress.ToString()+"\n");
Console.WriteLine("System Name : " + controllerInfo.SystemName + "\n");
Console.WriteLine("Controller Name: " + controllerInfo.ControllerName + "\n");
}
Console.WriteLine("Connected to ip: " + scanner.Controllers[0].IPAddress.ToString());
Controller _controller = new Controller(scanner.Controllers[0].SystemId);
_controller.Logon(UserInfo.DefaultUser);
//int i;
//for (i = 0; i < 10; i++)
//{
// Console.WriteLine(_controller.MotionSystem.ActiveMechanicalUnit.GetPosition().ToString() + "\n" + "i= " + i);
// // System.Threading.Thread.Sleep(500);
//}
Bool boolRunning;
RapidData rd = _controller.Rapid.GetRapidData("T_ROB1", "Module1", "running");
if (rd.Value is ABB.Robotics.Controllers.RapidDomain.Bool)
{
boolRunning = (ABB.Robotics.Controllers.RapidDomain.Bool)rd.Value;
//assign the value of the RAPID data to a local variable
bool boolValue = boolRunning.Value;
Console.WriteLine("The RAPID bool is: " + boolValue);
//Assign new value to .Net variable
boolRunning.Value = false;
//Request mastership of Rapid before writing to the controller
//Mastership master = Mastership.Request(_controller.Rapid);
Mastership m = Mastership.Request(_controller.Rapid); //This is where my problem is
Console.WriteLine(m.IsMaster.ToString());
//Change: controller is repaced by aController
rd.Value = boolRunning;
//Release mastership as soon as possible
m.Dispose();
}
Console.ReadLine();
}
}
0
Comments
-
Could you catch the exception and see if there is any more information to be seen from it?0
-
The problem was that mastership was given to someone else, rebooted the VC and it was fine.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)
- 799 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 5 Job listings