Switch to desktop version  

Ewon TechForum
Providing technical solutions to technical requests



Basic Script - Animate Motion
Dan.Redding
Junior Member
#1
Hi All! 

Would anybody on here be able to point me in the right direction  

My goal is to be able to increment a defined counter (Internal Tag) from a range of 0 - 100 when a tag (Boolean) within the ewon is triggered from "0" to "1"
This would allow me to display certain animations such as "Cogs" or moving objects on my pages rotation based on a boolean value.

My ewon tag is "DO_Transfer_Conveyor_Strt_Req" so therfore when this tag is equal to "1" I would like for an internal tag to increment up (Being clamped within a working range of 0-100)
Once the tag "DO_Transfer_Conveyor_Strt_Req" returns back to "0" then the internal tag can return back to 0.


Any advice would be very much appreciated.

Kind Regards


Attached Files Thumbnail(s)
       
Reply

alma
Administrator
#2
Hi Dan.

To do this I recommend you to use javascript.
The viewOn view is just an SVG object in an shtm file  that you can retrieve from your Ewon by FTP (in usr>viewOn)

In this file, you can add javacript and give an Id to your SVG object in order to modify it.

SVGs can handle these graphical transformations : https://developer.mozilla.org/en-US/docs/Web/SVG/Tutorial/Basic_Transformations

Reply

Dan.Redding
Junior Member
#3
 
Hi Alma,

firstly thank you for help.

As for the JavaScript were does this content get entered. You will have to forgive me as I'm new to java scripting
The example below does seem like something i could use ,however would this just rotate "My" object once by 45 degrees?
Code:
<svg width="31" height="31">
    <rect x="12" y="-10" width="20" height="20" transform="rotate(45)" />
</svg>

Also how does my tag tie in with the object I need to use and make it rotate continuously for the duration of my tag being on.

Kind Regards
Reply

alma
Administrator
#4
Sorry but I need to be sure of something. Is your question only about changing the value of your tag when your boolean changes ? Or do you also need explanations on how to make your image rotate ?
Reply

Dan.Redding
Junior Member
#5
My goal is to have an object rotating when a tag of mine becomes true.

This tag would be a Boolean type.
 e.g when "Output_1" is true, then is it possible to have a local Ewon tag defined that would increment up from 0 - 10.
This tag could then be used to rotate my objects.

So far I have managed to get objects to rotate in a circular motion based upon an integer tag being used from the PLC.

Hope this makes sence
Reply

alma
Administrator
#6
Ok sorry for the misunderstanding.

Then you can add this BASIC script in your Ewon to modify your rotation when your boolean changes :

Code:
ONCHANGE "YourBool" ,'@rotate' //Call rotate function when boolean is changed

FUNCTION rotate
Bool = GETIO "YourBool" //Your boolean tag
Rotate% = GETIO "YourRotation" //Tag which rotation is based on
Inc% = 1 //Step you want to add to your rotation value when boolean changes
NewValue% = Rotate% + Inc%
IF(Bool=1) THEN SETIO "YourRotation",NewValue% //Modify rotation only when bool passes from 0 to 1
ENDIF
ENDFN


Do you have any questions on this script ?
Reply

Dan.Redding
Junior Member
#7
When my PLC tag is true would the rotation value continue to count up from 0 - 10 then repeat if the tag was to remain on?

or is this script incrementing by a "%" that i give when this tag value changes from 0 - 1 or 1 - 0?
Reply

alma
Administrator
#8
(21-09-2021, 03:42 PM)Dan.Redding Wrote: When my PLC tag is true would the rotation value continue to count up from 0 - 10 then repeat if the tag was to remain on?

or is this script incrementing by a "%" that i give when this tag value changes from 0 - 1 or 1 - 0?

No because your rotation value is only updated when your bool is changed from 0 to 1.
Reply

Dan.Redding
Junior Member
#9
Could the "Rotation" tag be defined in the ewon and therefore e configured to increment from 0 - 10 lets say. (Rolling timer in the background)
Then this would allow for my animation to rotate when my tag becomes true.
Reply

alma
Administrator
#10
(21-09-2021, 04:05 PM)Dan.Redding Wrote: Could the "Rotation" tag be defined in the ewon and therefore e configured to increment from 0 - 10 lets say. (Rolling timer in the background)
Then this would allow for my animation to rotate when my tag becomes true.

Of course. And once defined you can modify it in your script as you want.
Reply




Possibly Related Threads…
18-07-2025, 07:22 AM
Last Post: LuisEnrique
05-06-2025, 12:23 PM
Last Post: simon
15-05-2025, 05:57 PM
Last Post: LuisEnrique
20-03-2025, 12:55 PM
Last Post: driesdebouver
25-02-2025, 03:56 PM
Last Post: ziozetti
21-11-2024, 03:03 PM
Last Post: simon
24-10-2024, 01:52 PM
Last Post: anas.rhouati
19-03-2024, 01:55 PM
Last Post: simon
  basic code not work Started by cantarol
1 Replies - 1.158 Views
06-03-2024, 03:26 PM
Last Post: ziozetti
18-01-2024, 12:09 AM
Last Post: jorisj



Users browsing this thread:
1 Guest(s)



Theme © Ewon 2019 - Forum software by © MyBB - Cookie policy