FlexPendant Start View Problem
Thank You,
RickSlickRick2009-04-06 20:48:43
Comments
-
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.
Russell Drown0 -
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.Thanks,Rick
Rick Lemberg0 -
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.
Thanks,Rick Lemberg0 -
Can you attach a backup of your robot as well?Russell Drown0
-
Hello Russ,Here is the backup from the robot, not all the code that i'm working with is the Cognex_Ethernet.sysThanks
Rick Lemberg0 -
OK, I see several problems with your application.
1. 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:
private void dsVisionPartPresentUpdate_Changed(object sender, SignalChangedEventArgs e)
{
if (e.NewSignalState.Value == 1)
{
tpsVisionPPIndicator.BackColor = Color.Lime;
}
else
{
tpsVisionPPIndicator.BackColor = Color.Red;
}
}
but you MUST do this:
private void dsRobotClearVisionUpdate_Changed(object sender, SignalChangedEventArgs e)
{
this.Invoke(new ABB.Robotics.Controllers.IOSystemDomain.SignalChangedEventHandler(this.UpdateUI), new Object[] { sender, e });
}
private void UpdateUI(object sender, SignalChangedEventArgs e)
{
if (e.NewSignalState.Value == 1)
{
tpsClearIndicator.BackColor = Color.Lime;
}
else
{
tpsClearIndicator.BackColor = Color.Red;
}
}
This is well-documented in the user guide, and the same applies for all of the RAPID data you are subscribing to.
2. 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.
3. 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.
4. 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.
5. 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.Russell Drown0 -
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.Thanks,Rick
Rick Lemberg0 -
Hello Russ,I found the problem to my errors, copy paste....oops!! Please let me know about the databinding and if I'm disposing properly.Thanks,RickRick Lemberg0
-
Here is a few recommendations:1. 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;}2. You should not need to remove the handlers that you are invoking to, i.e.
UpdateUI_PassedImage does not need to be manually removed3. 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)
{
RapidData rd = null;
try
{
// read the data type from rapid
// increment the counter
// write the new value
rd = myRapid.GetRapidData("T_ROB1", "Cognex_Ethernet", "pnFailedImages");
Num myVar = (Num)rd.Value;
myVar.FillFromNum(0);
rd.Value = myVar;
}
catch (Exception ex)
{
ABB.Robotics.Diagnostics.Trace.WriteLine("Exception: " + ex.ToString());
}
finally
{
if(rd != null)
{
rd.Dispose();
rd = null;
}
}
}
}4.It is recommended that you remove and reactivate event handlers whenRussD2009-04-14 19:35:01
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.
5. 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.Russell Drown0 -
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.Thank You,RickRick Lemberg0
-
No problem, maybe we'll see you at the Technology Days next week.Russell Drown0
Categories
- All Categories
- 5.5K RobotStudio
- 394 UpFeed
- 18 Tutorials
- 13 RobotApps
- 297 PowerPacs
- 405 RobotStudio S4
- 1.8K Developer Tools
- 249 ScreenMaker
- 2.7K Robot Controller
- 309 IRC5
- 59 OmniCore
- 7 RCS (Realistic Controller Simulation)
- 785 RAPID Programming
- AppStudio
- 3 RobotStudio AR Viewer
- 18 Wizard Easy Programming
- 105 Collaborative Robots
- 4 Job listings