Visualization using methods

ludecus
2020-06-22
2020-07-21
  • ludecus

    ludecus - 2020-06-22

    I tried many things but i didn't solved my issue.

    In an visualization frame i would like to run a method by the mouse click event.
    If the button is clicked, the method should run (multiply cycles) until the method returns a value.

    My issue is, that i can't find a way within the frame.
    Do i really use to have a POU which handles the cyclic call?
    Isn't there any code behind within the frame possible?

    An other way is to use a separate HMI project and map with data sources.
    How can i map also methods? Variables, properties and transitions are mappable, why doesn't work methods?

    Thanks for your help

     
  • loraul - 2020-07-09

    Hi,
    in visu properties you can replace a variable by a function call. For example, rectangle component has a "TextVariable" property where you can place a variable or a function call. This function call is executed every cycle in Visu task, and you can use to handle the mouse click through a visu local variable.

    In this post there is some example of how to use function calls in visu https://forge.codesys.com/forge/talk/Visualization/thread/ea04556dc9/

    But it's not a good practice because the code is hidden in a visu frame. I think, it's better if you use a FB associated to a visu frame.

    BR

     
  • ludecus

    ludecus - 2020-07-10

    Thank you for your response!

    Unfortunately this mouse click is - as all the other input configurations also - only an event. If the method or function runs more then one cycle, this wont work. Even if that would be bad while its hidden code. Or am i wrong?

    An other option would be, that the TextVariable would be linked to a cyclic called variable, e.g. Prg_Visu. There the variable could call a method or function until those is finished. But that will completely separate the functionality from the visualization.

     
    • loraul - 2020-07-13

      Hi,
      you can use an internal visu variable to handle the click mouse, and then in the function called from TextVariable property use this variable. Please find attahced project

       
      • ludecus

        ludecus - 2020-07-21

        Thank loraul for your sample.

        The method i would like to call is a method of a FB. Therefore your idea won't work.
        Okay, i could use a function as wrapper to call the method. But that's not a simple solution.

         
  • m.prestel - 2020-07-13

    Hello @ludecus,

    have you tried to use OnMouseDown and onMouseUp and toggle a bool, which then causes your method to be called multiple cycles (e.g. check in PLC_PRG if the bool is try and then call the method).

    Datasources only support values.

    Best regards,
    Marcel

     
    • ludecus

      ludecus - 2020-07-21

      Thanks for your response m.prestel.

      That's exactly what i need to do, but its not a good solution. The PLC_PRG would be just a helper, which i want to eliminate.

       

Log in to post a comment.