Citect Functions

DJShardy

Member
Join Date
May 2018
Location
Melbourne
Posts
13
Hey,
Using Citect 6.1
I need to display a number to show how many days pumps have been turned off for.

How often will Ci-code get called to run if I place it inside a Genie?

I have written a Function to make this happen but I am having trouble using it. When I say the Argument is "pumpOn" that is coming from a PLC Tag.'


Code:
INT 
FUNCTION DaysPumpsTurnedOff(INT pumpOn)

INT timeSwitchedOff;
INT daysOff;

IF pumpOn = 0 THEN
	IF timeSwitchedOff = 0 THEN
		timeSwitchedOff = TimeCurrent;  // Capture when the pump was turned off	
	END						
	daysOff = DateSub(TimeCurrent,timeSwitchedOff) / 86400; //Find out the seconds between when the pump was turned off and now.
	
	RETURN daysOff;
ELSE
	daysOff = 0												// Reset to zero if the pump is on 
	timeSwitchedOff = 0;
END

I just want it to display a number on the Page and that's it.

Is it possible to display a Ci-code variable on a page?

Instead of a function can I perhaps modify that code and store the value in the PLC and place it straight into a text box on the page?

Cheers
 
Thanks for the speedy reply.

The plc is looking like an easier way todo it. RS 5 would have some kind of time keeping block I imagine? I could use then just write it to an int tag and simply display that on the scada page?
 
The trigger is optional, you can use the timer alone. The action is any Cicode function you want. You can set a Cicode function to return a value, and in your action say:

DAYS_RUNNING = Calculate_Days_Running(PUMP1_ON)

PUMP1_ON for example, would be the input to your Cicode function (Calculate_Days_Running), and you can assign the return value to a tag (ex: DAYS_RUNNING)
 
you can put a ciCode function in the Numeric expression box.
see Cicode below and picture


you need the "RETURN" statement at the end of the code



***************************************************************

REAL FUNCTION poll_precentage(REAL polls,REAL t_outs)
REAL percent;

IF polls > t_outs THEN
percent = ((polls - t_outs) / polls) * 100
ELSE
percent = 0
END


RETURN percent
END
*****************************************************
 

Similar Topics

Another Cicode question if i may. i have 2 Functions in cicode one function calls the other and i need to pass 2 Variables from one to the other...
Replies
7
Views
2,894
Hi everybody i am a bit new on scada but i hope you can help me. i need a turn counter that increases with 1 every time a number passes 360 and...
Replies
0
Views
1,993
Hi, I'm using VijeoCitect v7.1 with a local database Microsoft SQL Express. I make requests to that database using the PLUSADOCon.dll functions...
Replies
0
Views
2,644
Hi I'm trying to use the RTrim (trims newlines etc from strings), UCase (converts a string to uppercase) and Mid (accesses part of a string)...
Replies
9
Views
3,115
So i've been at this for a long while, i have Citect Scada 2018, i have full access to everything but i can't seem to find any option or...
Replies
0
Views
62
Back
Top Bottom