Works Process: If-Syntax

Forum Forums Visual Components 4.1 Academy Works Process: If-Syntax

This topic contains 7 replies, has 4 voices, and was last updated by zesty zesty 2 weeks, 5 days ago.

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #13196
    Avatar
    Ralf
    Participant

    Hi
    I would like to query the signal of another component with the “if” syntax,- not use the expression as counter as in the example.
    Is it possible ?

    Attachments:
    You must be logged in to view attached files.
    #16359
    horo
    horo
    Participant

    Hi,

    I would like that too. Did you manage to do that? Is it possible? Thanks in advance.

    #16437
    Quintan.E
    Quintan.E
    Participant

    Hello, About your question, I have the answer.

    If- Syntax

    Just Remember, first need define our Variables in the section UserVariables, with correct type, and this variables no restart automatically

    #16454
    Quintan.E
    Quintan.E
    Participant

    with WriteSignal you can use in one if and communicate with other works with waitsignal to start a new condition

    #16597
    horo
    horo
    Participant

    Thanks for your answer! Can you please explain it more clearly? I still don’t understand how can I use these two commands to make If with them.

    #16599
    zesty
    zesty
    Moderator

    Apologies. There was a delay in approving the first post of Quintan.E.

    The expression of the If task cannot refer to a signal in another component. There are workarounds.

    My suggestion:

    • Use a WaitSignal task instead of an If task to query the signal value of another component.
    • In the WaitSignal task SignalValue property, use a question mark (?) to make a conditional argument. That is, do something based on the signal value.
    • If you do not want the WaitSignal to listen for an event/trigger before evaluating the signal, set the WaitTrigger property of the WaitSignal task to false.

    Refer to WaitSignal task in the Works Task Reference Guide, found on this forum.

    https://forum.visualcomponents.com/forums/topic/works-library-tasks-reference-guide/

    The May 3, 2019 version of that guide has the task description on page 128.

    There appears to be interest in the ability to reference signal values in expressions for conditional tasks. Possibly a new feature or expression function for Works, e.g. If:signal(Works Process#2,SensorBooleanSignal):True?False. However, the WaitSignal task can do the job, and I think someone might have already modified an If task to do what you want. I do know others would like the ability to read robot IO, so let’s see where this goes.

    #16638
    horo
    horo
    Participant

    Hi zesty! Thanks for the tip! Unfortunately I didn’t have much succes with the WaitSignal, because I needed multiple conditional WaitSignals, but in value there can be only True?False, so signals from different components lead to same result. (or i did something wrong)

    Fortunately, I finally managed to make custom task for it. In the layout is custom Works Process with IfSignal task in it. Inputs are Component name, Signal name, Then and Else. If the signal value is True, “Then” executes, otherwise it executes “Else”. It should be working.

    Attachments:
    You must be logged in to view attached files.
    #16640
    zesty
    zesty
    Moderator

    I understand now. Yes, a WaitSignal task evaluates signal from one component. The conditional values can be numerous based on the signal type. With Boolean, true or false, but with strings and integers you have a bit more freedom. Good that you were able to make a custom task, and even better that you provided us with the example 🙂

Viewing 8 posts - 1 through 8 (of 8 total)

You must be logged in to reply to this topic.