xsienix

Citect Cicode| the 3 buttons and 3 lights question

5 posts in this topic

Hi all,

I need to make a traffic lights,
Each light (red/orange/green) have a corrsopondent button.

Is there a way to use one function to control the lights?
Is  there a way that the function knows wich button is pushed.

Cheers..

 

Share this post


Link to post
Share on other sites

Hi XSIENIX,

This exercise is not complicated. Regardless of the CitectSCADA version, the execution is the same.

The only thing that could be difficult is if you are not connected to a PLC.

CitectSCADA comes with standard symbols, one of which is "Lights".

The "buttons" objects is also self explanatory, and straight-forward to configure.

You might like to provide more detail about your situation, eg, How familiar are you with CitectSCADA? Do you know how to create a page in "Graphic Builder" and add objects? Can you compile and run project?

Regards, Paul.

Share this post


Link to post
Share on other sites

Hi Paul,

Thanls for you replay

I know to make pages and i understand the genies.
The system is setup complete, no worry's about that.

I make myself some nice buttons and lights to.

The only thing is, that i struggle with the cicode.
I have maneged to make a function so i can call this function, with the push of the button.
For now, i can do this only for one light. (getRedLight() )
There must be a way to avoid that i must make three fun


For instance:
In Python i can give arguments to a function.
 

Share this post


Link to post
Share on other sites

Hi xsienix,

I'm not sure what you are ultimately trying to achieve?

The action of turning the traffic light ON/OFF can be setup without the use of Cicode.

You can create a Button that toggles a bit. That bit is then used to change the symbol state (eg the "On" symbol is shown, and then the "Off" symbol is shown, depending on the bit state).

It's been a while since I last used CitectSCADA, but there is a "Toggle(bit)" command that can be directly tied to a pushbutton action.

If you are determined to use Cicode, then the cicode function can directly access normal tags without having to pass them as arguments.

 

Hope that helps.

Share this post


Link to post
Share on other sites

To use 1 function to control the lights, you would definately need to use arguments for the function.

Here is an example

Create in the Tag local variables 3 Digital tags. eg. button1, button2 & button3
You create a symbol set and select Array. Then select the lamp icons to suit.
eg. 0 = Black lamp (indicating off), 1=Red lamp, 2=Orange lamp, 3 =Green lamp.
In the Array Expression, enter your cicode function name. eg. ShowLights(button1, button2, button3)

Create the cicode function in a cicode file

//    Dependin on which button was pressed, returns a integer value of:
//                0 = All off
//                1 = Red
//                2 = Orange
//                3 = Green

INT
FUNCTION ShowLights(INT butt1, INT butt2, INT butt3)
    INT iret;
    iret = 0;
    IF butt1 = 1 AND butt2 = 0 AND butt3 = 0 THEN
        iret = 1;
    END
    IF butt1 = 0 AND butt2 = 1 AND butt3 = 0 THEN
        iret = 2;
    END
    IF butt1 = 0 AND butt2 = 0 AND butt3 = 1 THEN
        iret = 3;
    END
    RETURN iret;
END

Depending on which button is pressed, the correct light will illuminate.

 

 

Share this post


Link to post
Share on other sites

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