Author Topic: Swapping toolbox components  (Read 1349 times)

Smcuser

  • Newbie
  • *
  • Posts: 14
    • View Profile
Swapping toolbox components
« on: November 29, 2016, 09:27:57 AM »
Does anyone know if it is possible to exchange between different versions of the same component residing in the toolbox e.g. I modified the VB code for an AHMI controls component and saved it with a new name. In my existing form I now want to swap the standard AHMI component for my own version.

If it is not possible I am guessing I'll have to delete all references to the standard component and replace it with my own modified version - tedious as it involves re-entering all the PLCAddressValues.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5269
    • View Profile
    • AdvancedHMI
Re: Swapping toolbox components
« Reply #1 on: November 29, 2016, 01:14:13 PM »
This is possible, but must be done with great care because 1 mistake can destroy your project. The key to this is understanding a bit of what happens under the hood of Visual Studio. When you add a control to a form, VS is actually writing code for you. This code is put in a file that is normally not visible in Solution Explorer. At the top of Solution Explorer, there is an icon for "Show All Files". If you enable that, you can see the files created by VS. The one of interest is the designer file. Below is a step by step of replacing one type with another. I will use an example of replacing a type of BasicLabel with BasicLabel2.

Before doing this, make a backup copy of your solution!

- In Solution Explorer, enable the Show All Files icon
- Expand down the form you want to change the control type by clicking the + next to it
- Look for the file with designer in the name
- Right click that file and select view code
- Ctrl+F to open the search windows
- In the search window put in AdvancedHMIControls.BasicLabel
- At the left of the search window is a down arrow, click that to expand a replace
- In the replace field enter AdvancedHMIControls.BasicLabel2
- Change the scope of the search to Current Document
- Choose replace all
- Rebuild the solution

If everything went correct, your BasicLabels will now be BasicLabels2.

Smcuser

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Swapping toolbox components
« Reply #2 on: November 30, 2016, 10:12:32 AM »
The solution does not appear to be too difficult.

I was about to give it a go when I thought I better check that everything works before making changes. Sadly not -> the solution contains the original BasicLabel component plus an unused modified version of the BasicLabel component (with renamed public class).

The solution compiles OK but when run returns 'Check NumericFormat and variable type' msgs for all the monitored PLC I/O values. Odd thing is that I can still write to the PLC OK. If I revert back to an earlier solution containing only the original BasicLabel component it works without problem.

Still working on it.....

[Edit: I can see the exception message in BasicLabel.vb']
« Last Edit: November 30, 2016, 10:19:15 AM by Smcuser »

Smcuser

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Swapping toolbox components
« Reply #3 on: December 01, 2016, 06:38:23 AM »
Problems sorted, everything is now working the way I want it to. Easy when you know how and take care when making changes.

I have this question: is it possible to do tag aliasing within AHMI? I can't see how such a thing would be possible for this system

The tag names I am using are very long, sometimes containing 26 chars or more. It's easy to make a typing mistake or forget the tag naming convention. I would like to use a simple tag alias within AHMI which marries up with the tag alias name used in the Rockwell PLC.

For reference Siemens offer this when controlling their PLC from a web based application. The user application code contains an alias statement linking the tag names used in the code with those used by the PLC.   

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5269
    • View Profile
    • AdvancedHMI
Re: Swapping toolbox components
« Reply #4 on: December 01, 2016, 08:47:10 AM »
I have this question: is it possible to do tag aliasing within AHMI? I can't see how such a thing would be possible for this system

The tag names I am using are very long, sometimes containing 26 chars or more. It's easy to make a typing mistake or forget the tag naming convention. I would like to use a simple tag alias within AHMI which marries up with the tag alias name used in the Rockwell PLC.

For reference Siemens offer this when controlling their PLC from a web based application. The user application code contains an alias statement linking the tag names used in the code with those used by the PLC.
Try this:

- Add a BasicLabel to the form
- In the Properties Window look for (ApplicationSettings) at the very top and expand it down
- Click in the field for (PropertyBinding) and click the ellipsis (3 dots) button
- In the pop up window look for PLCAddressValue then click in the field and click the drop down arrow
- Click "New" and another window will pop up
- In the next pop up window enter something like "MyTagAlias" for the Name Property
- In DefaultValue enter the actual PLC address
- Click OK for both pop up windows to close them

You now have a tag alias that can be re-used in other objects with PLCAddressXXX properties by using the (ApplicationSettings)

Smcuser

  • Newbie
  • *
  • Posts: 14
    • View Profile
Re: Swapping toolbox components
« Reply #5 on: December 01, 2016, 11:30:01 AM »
See post in 'Tips & Tricks' for info on 'Tag Database': -

http://advancedhmi.com/forum/index.php?topic=943.0