KUKA behaviour for SWITCH CASE????????

  • LOGIC QUESTION IN KUKA SWITCH CASE


    *I am having a subprogram called a. In this, I am writing the conditions for subprograms selection, which i have used in main program called b. Note subprogram apple have no conditions.
    * I have used for ENUM for SWITCH CASE
    * I have used a LOOP i main program


    SUBPROGRAM a
    ......a()
    Wait 0.05 sec
    bag=#apple
    .
    ;writing conditions for selecting Subprogram
    .
    .
    Bag=#orange
    .Endif.
    .


    ;writing conditions for selection another subprogram
    .
    .
    Bag=#grapes
    Endif
    .


    E....


    MAIN PROGRAM b
    ....b()
    IOSTROm...
    .
    .
    LOOP
    .
    .


    switch bag
    case #apple
    apple() : a subprogram
    case #orange
    orange() : a subprogram
    case #grape
    grape() : a subprogram
    default
    asdf()
    En....


    END LOOP
    At the end of every subprogram I am calling subprogram 'a' to select my next suitable subprogram


    My Doubts


    1. Since apple has no conditions and written at the top, my bag variable will be loaded with apple. and the programe goes down and when certain conditions are met then orange or grape will be loaded in my variable bag.

    It is clear that when I have no conditions then apple subprogram will run because variable bag is loaded with apple


    a) when my condition are met for orange subprgram It will start only after apple subprogram. In my point of view the variable BAG is loaded with apple first so it will complete its apple task first because it is above orange(even though the conditions are met). ??????????????????????????????????????????? and will my orange subprogram will it run after apple????????????????? or who will it behave??????????????????????????:help: :help: :help: :help: NOTE my main programe 'b' is in loop.

    Edited once, last by kanna ().

  • AD
  • can you rephrase it? I find it very difficult to understand what you are asking. for example "who will it behave" instead of "how..", names are not unique, you have apple used as a variable and enumeration element, your code contains way too many dots obscuring real code, main program never calls the subprogram "a" etc.

    1) read pinned topic: READ FIRST...

    2) if you have an issue with robot, post question in the correct forum section... do NOT contact me directly

    3) read 1 and 2

  • Excuse me for making it hard for u to understand. i will again try to explain.


    In a DAT file
    Decl Global Enum fruits apple, orange, grapes, ......
    Decl Gobal fruits bag


    SUBPROGRAM a
    ......a()
    Wait 0.05 sec
    bag=#apple ; Note :No conditions for it
    .
    ;writing conditions for selecting Subprogram
    .
    .
    Bag=#orange
    .Endif.
    .


    ;writing conditions for selection another subprogram
    .
    .
    Bag=#grapes
    Endif
    .


    E....


    MAIN PROGRAM b
    ....b()
    IOSTROm...
    .
    .
    LOOP
    .
    a()


    switch bag
    case #apple
    apple() : a subprogram
    case #orange
    orange() : a subprogram
    case #grape
    grape() : a subprogram
    default
    asdf()
    En....


    END LOOP


    system here is :I am writing my conditions in my subprogram a() and using it inside my main program b() with a continuous loop. So according to the conditions the corresponding subprogram will be executed. Its a system by my customer. I would use a different system.


    My Doubts:
    In my subprogram I dont have any conditions for apple subprogram and its in the Top of the program. So my variable bag will be loaded with apple first.
    1. suppose if my conditions are met for orange().
    Then how will it behave??? will it do the apple subprogram first and then will it do the orange. Remember: main program b() is in loop. OR Organge() will not be done because we dont have any conditions for apple() and it above orange() OR only orange will be performed.


    2. suppose if no condtions are met?
    then is that apple will run or default prog asdf() will run. By according to switch rule, asdf must Run. BUT according to my customer model default prog is apple() because no condtions are there for it.


    If I have not made my quesion clear for you then please aske me?
    Thank you friends



    2.


    2.

    Edited once, last by kanna ().

  • After calling your subroutine a() 'bag' always has a value out of #apple,#orange,#grape (you made #apple for default)


    --> asdf() will never be called. It would be called if 'bag' has a value of #tomato
    --> if the value of 'bag' is #orange: only the part between 'case #orange' and the next following 'case ..' is executed.

  • how will it behave if the conditions for orange and grape are met. which one will executed first?

    Edited once, last by kanna ().

  • not sure what do you mean by first. only one sub is executed and that is dependent on bag value


    suppose the value assigned to bag was #orange. then when following code is reached, only sub orange() will be executed others will be skipped: apple(), grape() and asdf() and program continues after endswitch. actually all statements between "case #orange" and next "case" statement will be executed (in this case that is only one line calling sub orange())


    Code
    switch bag
    case #apple
    apple() : a subprogram
    case #orange
    orange() : a subprogram
    case #grape
    grape() : a subprogram
    default
    asdf()
    endswitch

    1) read pinned topic: READ FIRST...

    2) if you have an issue with robot, post question in the correct forum section... do NOT contact me directly

    3) read 1 and 2

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account
Sign up for a new account in our community. It's easy!
Register a new account
Sign in
Already have an account? Sign in here.
Sign in Now