Hi all,
I am trying to read a num data from MainModule.mod, modify it in C# and send it back to MainModule.mod.
So far I have succeeded in reading the num data, modifying it in C#, but not sending it back. How do I send the modified value back to MainModule.mod.
Any thoughts deeply appreciated.
See the following examples (make sure you defined your Rapid variable as PERS):
MODULE MainModule
PERS num Value := 4;
ENDMODULE
using System;
using ABB.Robotics.Controllers;
using ABB.Robotics.Controllers.Discovery;
using ABB.Robotics.Controllers.RapidDomain;
namespace PCSDKTest2
{
class Program
{
static void Main(string[] args)
{
// variables
NetworkScanner ns;
Controller c;
Task t;
Module m;
RapidData r;
Num v;
// scan network
ns = new NetworkScanner();
ns.Scan();
// get first found controller
if (ns.Controllers.Count > 0)
{
try
{
// create the controller
c = new Controller(ns.Controllers[0]);
if (c != null)
{
// log on
c.Logon(UserInfo.DefaultUser);
// request mastership
using (Mastership ms = Mastership.Request(c.Rapid))
{
try
{
// get task
t = c.Rapid.GetTask("T_ROB1");
if (t != null)
{
// get module
m = t.GetModule("MainModule");
if (m != null)
{
// get variable
r = m.GetRapidData("Value");
if (r != null)
{
// read value
v = (Num)r.Value;
// increase value
v = new Num(v.Value + 1);
// save value
r.Value = v;
}
// dispose module
m.Dispose();
}
// dispose task
t.Dispose();
}
}
catch (Exception) { }
}
// log off
c.Logoff();
// dispose controller
c.Dispose();
}
}
catch(Exception) { }
}
}
}
}
Hi John_Verheij,
Spot on! Thanks that works..