Author Topic: Creating line animation  (Read 4572 times)

MrPike

  • Sr. Member
  • ****
  • Posts: 297
    • View Profile
Creating line animation
« on: December 19, 2014, 10:58:14 AM »
Hi all. I am using this to display an electrical distribution one-line and trying to create animation to show a switch position open and closed. It is easy to create horizontal or vertical bus using labels or picture boxes etc. i would like to rotate a control 45 degrees(from horz or vert) to show a switch open versus closed. Is this possible?  I can't find much on the Internet to help. I would even use a line draw feature if I must. Thanks all.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Creating line animation
« Reply #1 on: December 19, 2014, 08:54:02 PM »
You can probably do this with a GraphicIndicator. You can draw up 2 pictures showing the 2 different states, then use the GraphicIndicator to switch between the 2 images based on a bit value.

MrPike

  • Sr. Member
  • ****
  • Posts: 297
    • View Profile
Re: Creating line animation
« Reply #2 on: December 19, 2014, 09:00:59 PM »
Yes, that is my current tactic.  I was trying to duplicate some wonderware animation but found that it is not possible to rotate the actual control.  You can however rotate an image inside a picturebox.  I will post something if I can get it to work.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Creating line animation
« Reply #3 on: December 19, 2014, 09:10:27 PM »
How is it done in Wonderware? Do you specify a rotation angle and a bit value makes it rotate to that angle? Or is it more sophisticated like using an integer value to specify the angle to rotate?

I may be able to create something that mimics the behavior.

MrPike

  • Sr. Member
  • ****
  • Posts: 297
    • View Profile
Re: Creating line animation
« Reply #4 on: December 20, 2014, 09:41:46 PM »
In WW every object has several controls and orientation is one of them.  In this case if the tag expression "CPMainOnN" is =1 then the line rotates 0 degrees(horizontal) and 45 degrees CW if the tag = 0.  You can also select the pivot point of the line(center or end).  The closest i can come is to rotate an object within a picturebox but not the picturebox(or any control) itself. 

MrPike

  • Sr. Member
  • ****
  • Posts: 297
    • View Profile
Re: Creating line animation
« Reply #5 on: December 23, 2014, 12:26:15 AM »
I have got some of this working.  i am now able to draw a line at design time to my windows form.   i can also create simple code to control the line.  the problem Im having is how to reference the line so that it shows properly when I change the window size.  If I open the window as "normal" then the animation works fine, but if i change the screen size, the line coordinates change. The problem is because my code uses the original coordinates.  Ive also tried adding a value then subtracting it to return to the original position with no luck.  I am not versed enough with VB to know how to correct this. See images attached.  Anyone familiar with VS2013 able to provide some help?  Copy the link below into your browser to get powerpacks 12.0 for visual Studio 2013, then you will need to add Lineshape to your toolbox controls.  Thanks

http://go.microsoft.com/fwlink/?LinkId=321343

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Creating line animation
« Reply #6 on: December 23, 2014, 08:21:50 AM »
I just about have this WW feature mimicked. I will put the control in the next version that will be posted in a couple days.

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Creating line animation
« Reply #7 on: December 25, 2014, 09:56:25 PM »
Version 3.95 is now available. It has a new control named AnimatingPictureBox. This is the first go round, so it may be lacking some necessary features, but it is quite flexible. You can add 2 images, the BackgroundImage, which is static, and the Image, which is capable of being animated with the RotationValue, TranslateXValue, and TranslateYValue.

The trick is to use PNG files with a transparent background for the animated image. That will allow it to overlay the BackgroundImage. In your case, you would make an image that just contains the line of the switch, then the rest would go in the background image. Using RotationScale, PLCAddressRotationValue, TranslateXValue, TranslateYValue, you can create the animating switch you show in the previous posts.

Darrell

  • Full Member
  • ***
  • Posts: 198
  • Electrician / PLC Technician
    • View Profile
Re: Creating line animation
« Reply #8 on: December 26, 2014, 08:20:25 PM »
Another nice option you might want to  consider adding to Advanced HMI .
If you could use an animated Gif in the picture box , and use a plc address to start and stop the animation. there easy to make and could add a lot of neat looking animated graphics to your hmi.

Darrell

MrPike

  • Sr. Member
  • ****
  • Posts: 297
    • View Profile
Re: Creating line animation
« Reply #9 on: December 27, 2014, 09:11:24 AM »
I had some time to try out the animated picturebox.  It works nicely except that a few things like positioning the image can be tricky since there is no way to drag it to the spot.  You have to manually change the X and Y value to move it around.  i wasnt able to get the animated image to look right unless i cropped it to fit the space exactly first, I used .png images but may not be doing something right.  lastly and mostly this only allows for one animation per backroung image.  I typically have 4 switches per device as seen in the screenshot.  This screenshot is was created using the "LineShape" control and works nicely except you have to write code for all of it.  Is there anyway to add this to AHMI controls??  I am able to animate each switch independantly and also add color...but the "LineShape" can only be seen on the main form and cannot be brought to front thus it cannot be used on top of any other control.  I simply added my backround to the form itself to get my results.  Can this be added to AHMI controls???????   

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Creating line animation
« Reply #10 on: December 27, 2014, 10:37:34 AM »
I made some refinements that help make the scaling and positioning of the images a little easier. The next version will also let you animate not only rotation, but also translation and scaling.

Darrell.... I started looking into a GIF animation that can be started and stopped based on a PLC boolean.

MrPike

  • Sr. Member
  • ****
  • Posts: 297
    • View Profile
Re: Creating line animation
« Reply #11 on: December 27, 2014, 10:55:23 AM »
Thanks i look forward to it.

Darrell, I believe you can run a .gif in a picture box image if you add it to you resources.  Just need to point your code to it.   I run .wav files now and think .gif is the same concept. 

Archie

  • Administrator
  • Hero Member
  • *****
  • Posts: 5322
    • View Profile
    • AdvancedHMI
Re: Creating line animation
« Reply #12 on: January 11, 2015, 08:03:20 PM »
I added a walk through in the Tips and Tricks section to show how to use the AnimatedPictureBox