# FP SDK 5.14. Rapid Data Value Changed Event.

**URL:** <https://tech-community.robotics.abb.com/t/fp-sdk-5-14-rapid-data-value-changed-event/5063>\
**Category:** Developer Tools\
**Created:** [August 31, 2012, 5:42am UTC](https://tech-community.robotics.abb.com/t/fp-sdk-5-14-rapid-data-value-changed-event/5063 "2012-08-31T05:42:05Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![SAV](https://avatars.discourse-cdn.com/v4/letter/s/65b543/32.png) [@SAV](https://tech-community.robotics.abb.com/u/SAV)\
**Post date:** [August 31, 2012, 5:42am UTC](https://tech-community.robotics.abb.com/t/fp-sdk-5-14-rapid-data-value-changed-event/5063/1 "2012-08-31T05:42:05Z")

</div>

Dear sirs,

Could someone shed some light to the the logic of the rapid data changing event triggering.  
I have a PERS variable and have a subscribtion on the data changing.  
Here it is:

public void SubscribeMethodOnRapidData(string rdName, Action method)  
{  
\_rapidsMap.Add(rdName, method);  
\_controller.Rapid.GetRapidData(“T\_ROB1”, “ProgressModule”, rdName).ValueChanged += rd\_changed;

}

private void rd\_changed(object sender, DataValueChangedEventArgs e)  
{  
if (sender is RapidData)  
{  
MessageBox.Show(“RapidData has changed!”);  
string rdName = ((RapidData)sender).Name;  
Action method = \_rapidsMap[rdName];  
ControllerDataToComponent sgnToComponent = new ControllerDataToComponent();  
sgnToComponent.dataValue = GetRapidData(rdName).ToString();  
method.Invoke(sgnToComponent);  
}  
else  
MessageBox.Show(“sender is not RapidData!”);  
}

During the execution the value of the rapid variable changes many times, but I have no event triggering. Why? What I had missed? It works perfect with the signals…

Thank you in advance…

P.S. I’m using the virtual controller

---

<div class="post-metadata">

**Author:** ![John\_Wiberg](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/john_wiberg/32/1485_2.png) [@John\_Wiberg](https://tech-community.robotics.abb.com/u/John_Wiberg)\
**Post date:** [September 6, 2012, 3:00pm UTC](https://tech-community.robotics.abb.com/t/fp-sdk-5-14-rapid-data-value-changed-event/5063/2 "2012-09-06T15:00:12Z")

</div>

Hi SAV,

Got your message so here I am 👍  
First here is an example which I ran just now which works, you need three buttons and a TpsLabel, and then the declaration of the ctrl and myRD needs to be at the top of the class declaration.

```auto
private void btnSub_Click(object sender, EventArgs e)
{
myRD = ctrl.Rapid.GetRapidData("T_ROB1", "Module1", "myNum");
this.myRD.ValueChanged += myRD_ValueChanged;
}
private void myRD_ValueChanged(object sender, DataValueChangedEventArgs e)
{
this.Invoke(new EventHandler(ToTheLabel), sender, e);
}
private void ToTheLabel(object sender, System.EventArgs e)
{
if (this.tpsLabel1.Text == "")
{
this.tpsLabel1.Text = DateTime.Now.ToString() + " : " + myRD.Value.ToString();
}
else
{
this.tpsLabel1.Text = this.tpsLabel1.Text + " " + DateTime.Now.ToString() + " : " + myRD.Value.ToString();
}
}
private void btnClear_Click(object sender, EventArgs e)
{
tpsLabel1.Text = "";
}
```

Regarding your code, first your use of the windows messagebox is a no-no, you should be using the GTPUMessageBox instead.

I’ll go through the rest later.

---

<div class="post-metadata">

**Author:** ![John\_Wiberg](https://dub1.discourse-cdn.com/flex005/user_avatar/tech-community.robotics.abb.com/john_wiberg/32/1485_2.png) [@John\_Wiberg](https://tech-community.robotics.abb.com/u/John_Wiberg)\
**Post date:** [September 7, 2012, 4:00pm UTC](https://tech-community.robotics.abb.com/t/fp-sdk-5-14-rapid-data-value-changed-event/5063/3 "2012-09-07T16:00:40Z")

</div>

Sorry, had to do some other stuff in between. OK lets look at your code.

1. Can’t see your other stuff, so I really can’t say regarding your calls like \_rapidsMap
2. In the event [rd\_changed] you have code that make UI changes (MessageBox.Show) before the invoke. Wouldn’t it be better to just send along the sender and e and then do the strings and sgnToComponent execution in the invoked method. See [Working with RAPID data](http://developercenter.robotstudio.com:80/Index.aspx?DevCenter=FPSDK&OpenDocument&Url=../FPSDKAppManual/doc49.html) and [Controller events and threads](http://developercenter.robotstudio.com:80/Index.aspx?DevCenter=FPSDK&OpenDocument&Url=../FPSDKAppManual/doc23.html)  
In my example above you see that I use that in the [myRD\_ValueChanged], which invokes [ToTheLabel].
3. what do you use the delegate for?  
Action  
Can’t make sense of that.

---

<div class="post-metadata">

**Author:** ![SAV](https://avatars.discourse-cdn.com/v4/letter/s/65b543/32.png) [@SAV](https://tech-community.robotics.abb.com/u/SAV)\
**Post date:** [September 13, 2012, 4:38am UTC](https://tech-community.robotics.abb.com/t/fp-sdk-5-14-rapid-data-value-changed-event/5063/4 "2012-09-13T04:38:42Z")

</div>

You was right, it works. The key point was the following: the variable myRd must be not local.  
Thank you, John.

---

<div class="post-metadata">

**Author:** ![lubosko105](https://avatars.discourse-cdn.com/v4/letter/l/ecccb3/32.png) [@lubosko105](https://tech-community.robotics.abb.com/u/lubosko105)\
**Post date:** [March 17, 2021, 2:28pm UTC](https://tech-community.robotics.abb.com/t/fp-sdk-5-14-rapid-data-value-changed-event/5063/5 "2021-03-17T14:28:59Z")

</div>

Hi guys.  
is it possible to fire event also for ‘Signal’ (I/O system), but not only PERS Rapid variable?
