Your project settings don’t match what is in the asembly attributes, you must have changed the project name after it was initially created. Right-click project properties in VS and look at the Application tab, you need to update the values in the assembly attribute in view.cs to match the values for Assembly Name and Default Namespace.
Hello RussD,Thank You for the info, I went through and changed the names in the View but it still had issues. I created a new project and just copied over the code I needed, now it is 80% working. The view comes up in the TP and VTP, however on the real TP my data fields are not populating. In the virtual controller all is working, I don’t understand but still working. I’ve attached the project, if you could take a look I’d appreciate it.
Any update to my issue, the buttons to change the data type states and values work. The button state does not change as its coded to and text does not show up in the labels.
I think that the first issue is that your event handlers are failing because you are not invoking them to the main applicaiton thread. These event handlers execute on a background thread, while the user interface objects you are trying to modify exist on the main windows thread and cannot be affected by the background thread, therefore their arguments must be invoked tothe main thread.
For example, every place that you have added an event handler (DataChanged or SignalChanged), you are doing something like this:
This is well-documented in the user guide, and the same applies for all of the RAPID data you are subscribing to.
You have lots of memory leaks in your application. Everywhere you are declaring a local RapidData instance, you must dispose of it after you are done with it. When you declare these objects at the module level, you must clean them up before you close the application or they will become memory leaks, this includes disposing of the controller object as well. Disposing is also well-covered in the user’s guide.
Similarly, you must remove all of your event handlers that you add when your application is done with them, or you will have resource leaks.
You can address some of these resource issues and increase application reliability by adding try-catch-finally structures, you can dispose of resources in the finally portion. Error handling is well-covered in the user guide. You must catch all exceptions in your user code, the only alternative is for Taf.exe to handle the error, it handles them by forcing the FP to reboot.
I would urge you to consider using the DataBinding and Signalbinding classes, they will address most of this resource management for you, although you must dispose of these objects when your application is closed.
Hello Russ,
Thanks for the reply, I’m sure you can tell I’m new to this. I have been working on the memory dispose and now I have four errors that I cannot get rid of, nor do I understand them 100%. My error is Error 1 No overload for ‘UpdateUI_VisionX’ matches delegate ‘System.EventHandler’ . I don’t fully understand how this is not working when several just like it are working.
On the databinding, I was working on that and couldn’t get the data binding to work and I had a forum discussion with Carlos. That discussion ended with thats a bug that needs fixed. But that was for the virtual enviroment and I have not tried it on the real TP. Does databinding work on the real Tp’s?
I’ve attached my updated application, hopefully the solution to my error’s come easy.
In your dispose routine you should remove the event handlers associated with an object before disposing of the object, otherwise you may get a null reference exception. Here is a sample from the user’s guide:
if (_controller != null)
{
_controller.OperatingModeChanged -= new ABB.Robotics.Controllers.OperatingModeChangedEvent
_controller.Dispose();
_controller = null;
}
You should not need to remove the handlers that you are invoking to, i.e.
UpdateUI_PassedImage does not need to be manually removed
You still need to dispose of the local declarations of RapidData that you are making:
Here is one way you can do this, it also demonstrates exception handling
public void ResetFailedCount(object sender, ABB.Robotics.Tps.Windows.Forms.MessageBoxEventArgs e)
{
if (e.DialogResult == System.Windows.Forms.DialogResult.Yes)
4.It is recommended that you remove and reactivate event handlers when
ITpsViewActivation.Deactivate and
ITpsViewActivation.Activate are called. You can use this fact to your advantage by having the same method remove handlers in the dispose and deactivate methods.
There is a sample application at www.robotstudio.com/community in the content sharing section that demonstrates data binding as well as other best practices. I would use this as a good reference for best practices.
Thank You very much Russ for you time and help. I am starting to make these changes. Look for the improvements on the post we have going about displaying live images.