cicode

Rich101

Member
Join Date
Feb 2004
Posts
13
anyone knowing cicode please help me with the folling. I would like to combine the following reports into one large report called PLANT? Does anyone know how to do this?


// Logging Functions

FUNCTION
LOG1_TRIGGER();

// PLANT
INT hPLANTa=DevOpen("PLANTa",0);
DevAppend(hPLANTa);
DevSetField(hPLANTa,"Unit","Plant");
DevSetField(hPLANTa,"Date",DATE());
DevSetField(hPLANTa,"Time",TIME());
DevSetField(hPLANTa,"Sup_Temp",HTHW_Supply_Temp);
DevSetField(hPLANTa,"Sys_Press",HTHW_System_Press);
DevSetField(hPLANTa,"Outdoor",Outdoor_Temp);
DevSetField(hPLANTa,"Zone1_Tot",Zone1_Tot);
DevSetField(hPLANTa,"Zone2_Tot",Zone2_Tot);
DevSetField(hPLANTa,"Zone3_Tot",Zone3_Tot);
DevClose(hPLANTa);

// Generator 1
INT hGen1a=DevOpen("Gen1a",0);
DevAppend(hGen1a);
DevSetField(hGen1a,"Unit","Gen 1");
DevSetField(hGen1a,"Date",Date());
DevSetField(hGen1a,"Time",Time());
DevSetField(hGen1a,"Ret_Temp",Gen1_Inlet_Temp);
DevSetField(hGen1a,"HTHW_Tot",Gen1_HTHW_Tot);
DevSetField(hGen1a,"Oxygen",Gen1_Oxygen);
DevSetField(hGen1a,"Stack_Temp",Gen1_Stack_Temp);
DevSetField(hGen1a,"Gas_Total",Gen1_Gas_Tot);
DevSetField(hGen1a,"Oil_Total",Gen1_Oil_Tot);
DevClose(hGen1a);

// Generator 2
INT hGen2a=DevOpen("Gen2a",0);
DevAppend(hGen2a);
DevSetField(hGen2a,"Unit","Gen 2");
DevSetField(hGen2a,"Date",Date());
DevSetField(hGen2a,"Time",Time());
DevSetField(hGen2a,"Ret_Temp",Gen2_Inlet_Temp);
DevSetField(hGen2a,"HTHW_Tot",Gen2_HTHW_Tot);
DevSetField(hGen2a,"Oxygen",Gen2_Oxygen);
DevSetField(hGen2a,"Stack_Temp",Gen2_Stack_Temp);
DevSetField(hGen2a,"Gas_Total",Gen2_Gas_Tot);
DevSetField(hGen2a,"Oil_Total",Gen2_Oil_Tot);
DevClose(hGen2a);


// Generator 3
INT hGen3a=DevOpen("Gen3a",0);
DevAppend(hGen3a);
DevSetField(hGen3a,"Unit","Gen 3");
DevSetField(hGen3a,"Date",Date());
DevSetField(hGen3a,"Time",Time());
DevSetField(hGen3a,"Ret_Temp",Gen3_Inlet_Temp);
DevSetField(hGen3a,"HTHW_Tot",Gen3_HTHW_Tot);
DevSetField(hGen3a,"Oxygen",Gen3_Oxygen);
DevSetField(hGen3a,"Stack_Temp",Gen3_Stack_Temp);
DevSetField(hGen3a,"Gas_Total",Gen3_Gas_Tot);
DevSetField(hGen3a,"Oil_Total",Gen3_Oil_Tot);
DevClose(hGen3a);

Zone1_Tot=0;
Zone2_Tot=0;
Zone3_Tot=0;
Gen1_HTHW_Tot=0;
Gen1_Gas_Tot=0;
Gen1_Oil_Tot=0;
Gen2_HTHW_Tot=0;
Gen2_Gas_Tot=0;
Gen2_Oil_Tot=0;
Gen3_HTHW_Tot=0;
Gen3_Gas_Tot=0;
Gen3_Oil_Tot=0;

END
 
I presume you are gathering data from PLCs. Please confirm.

If so, why not setup a report in notepad to gather the information from the PLCs and print the report? Quite easy if you can do it this way.

beerchug
 
yes it is. Just was trying to use something thats already there. Its just that it prints four reports and only want one.
 
I am not 100% with the coding but the info that you require seems to be all there.....

ie
i assume that
[SECTION 1]
INT hPLANTa=DevOpen("PLANTa",0);
would mean open a file called "PLANTa" and assing a handle hPLANTa

then
[SECTION 2]
DevAppend(hPLANTa);
would mean to appen to the existing file

[SECTION 3]
The next lines add the data
DevSetField(hPLANTa,"Unit","Plant");
DevSetField(hPLANTa,"Date",DATE());
DevSetField(hPLANTa,"Time",TIME());
DevSetField(hPLANTa,"Sup_Temp",HTHW_Supply_Temp);
DevSetField(hPLANTa,"Sys_Press",HTHW_System_Press);
DevSetField(hPLANTa,"Outdoor",Outdoor_Temp);
DevSetField(hPLANTa,"Zone1_Tot",Zone1_Tot);
DevSetField(hPLANTa,"Zone2_Tot",Zone2_Tot);
DevSetField(hPLANTa,"Zone3_Tot",Zone3_Tot);

and of course
[SECTION 4]
DevClose(hPLANTa);
would close the file.......

Therfore to get one file just add the data from each action to copy to the [SECTION 3]

eg copy the [Section 3] should look like

DevSetField(hPLANTa,"Unit","Plant");
DevSetField(hPLANTa,"Date",DATE());
DevSetField(hPLANTa,"Time",TIME());
DevSetField(hPLANTa,"Sup_Temp",HTHW_Supply_Temp);
DevSetField(hPLANTa,"Sys_Press",HTHW_System_Press);
DevSetField(hPLANTa,"Outdoor",Outdoor_Temp);
DevSetField(hPLANTa,"Zone1_Tot",Zone1_Tot);
DevSetField(hPLANTa,"Zone2_Tot",Zone2_Tot);
DevSetField(hPLANTa,"Zone3_Tot",Zone3_Tot);
DevSetField(hGen1a,"Unit","Gen 1");
DevSetField(hGen1a,"Date",Date());
DevSetField(hGen1a,"Time",Time());
DevSetField(hGen1a,"Ret_Temp",Gen1_Inlet_Temp);
DevSetField(hGen1a,"HTHW_Tot",Gen1_HTHW_Tot);
DevSetField(hGen1a,"Oxygen",Gen1_Oxygen);
DevSetField(hGen1a,"Stack_Temp",Gen1_Stack_Temp);
DevSetField(hGen1a,"Gas_Total",Gen1_Gas_Tot);
DevSetField(hGen1a,"Oil_Total",Gen1_Oil_Tot);


etc get the picture...

To test this you can leave the oringal code as stands and simply comment out the lines that are not required.
 
Give me a little time and I will see if I have the correct version of Citect here to setup on my computer and extract a report format for you.
beerchug
 
Example of commenting out :

Use the "// " to comment out

// FUNCTION: DisplayHistoryFile
//
// DESCRIPTION: Calls Select History form then translates
// selected
// file from native to local text and
// displays it

FUNCTION DisplayHistoryFile(INT AN)STRING sFile;


Remember the [SECTION 4] code as in the example abouve would have to be the last section.......


Have a look at any *.ci file to inspect samples of cicode. you can open them in citect or in a simple package like notepad. Some examples can be found in the C:\Citect\User\Example directory

beerchug
 
Last edited:
Sorry to have taken so long but have been really busy.

Easiest way for a report from tags in the PLC is to set up a reort in the reports section under system. This report can operate on a time schedule or a button on the screen. I use both regularly. The reort following operates at 8AM each day and is a daily report. The description area on the left is just a descrition. The sections in brackets are the tags and print format that I am reading information from in the PLCs. The information for this report is extracted from 7 PLCs on the network. Printing a report from a button on the screen is also very easy. This project is a power station and they can print "snapshots" of all diesel engine data (temperatures, pressures, load etc) from a button on the screen. They find this method very usefull.

When you set up the reort, press the edit key and a window will open where you can type in what you want. I would suggest that you initially trigger the report from a button so that you can adjust the appearance of the reort instead of waiting for the time base to pass.

Sorry it is not exactly as required but the window for the post is a bit small for the data.

******************
DAILY REPORT
******************

{Time(1) } {Date(2) }

DISTILLATE BULK FUEL TANK TK-001 LITRES {SEQPV322}
DISTILLATE BULK FUEL TANK TK-002 LITRES {SEQPV323}
DISTILLATE BULK FUEL TANK TK-003 LITRES {SEQPV324}
DISTILLATE BULK FUEL TANK TK-004 LITRES {SEQPV325}
DISTILLATE BULK FUEL TANK TK-005 LITRES {SEQPV326}
CLEAN DISTILLATE BUOY TANK TK-006 LITRES {SEQPV327}

SMITH POINT FEEDER FD-008 MEGAWATT HOURS {FEEDER2MWH:#0###.###}
IRVINE HILL FEEDER FD-009 MEGAWATT HOURS {FEEDER1MWH:#0###.###}
SPARE FEEDER FD-010 MEGAWATT HOURS {FEEDER3MWH:#0###.###}
NORTH WEST POINT FEEDER FD-005 MEGAWATT HOURS {SEQANA75:#####.###}
MINE DRYERS FEEDER FD-004 MEGAWATT HOURS {SEQANA62:#####.###}
SPARE FEEDER FD-002 MEGAWATT HOURS {SEQANA38:#####.###}
DRUMSITE FEEDER FD-006 MEGAWATT HOURS {SEQANA88:#####.###}
STATION TRANSFORMER TX-001 MEGAWATT HOURS {SEQANA25:#####.###}
STATION TRANSFORMER TX-002 MEGAWATT HOURS {STTRAN2MWH:#0###.###}

DA-001 HOURS RUN {DA001PV5:##########}:{DA001PV4:#0}
DA-001 MEGAWATT HOURS {DA001PV11:########}
DA-001 HOURS RUN IN LAST 24 HOURS {D1HRS:###}:{D1MINS:#0}
DA-001 LUBE OIL USED IN LAST 24 HOURS {D1LUBE:#0##}
DA-001 FUEL USED IN LAST 24 HOURS {D1LFO:#0##}
DA-001 KILOWATT HOURS PRODUCED IN LAST 24 HOURS {D1KWH:#0##}
DA-001 FUEL USED TOTAL {DA001PV27:#####}{DA001PV26:#.#####} kLITRES
DA-001 FUEL ECONOMY {DA001PV32:##}.{DA001PV33:###} kWH/L

DA-002 HOURS RUN {DA002PV5:##########}:{DA002PV4:#0}
DA-002 MEGAWATT HOURS {DA002PV11:########}
DA-002 HOURS RUN IN LAST 24 HOURS {D2HRS:###}:{D2MINS:#0}
DA-002 LUBE OIL USED IN LAST 24 HOURS {D2LUBE:#0##}
DA-002 FUEL USED IN LAST 24 HOURS {D2LFO:#0##}
DA-002 KILOWATT HOURS PRODUCED IN LAST 24 HOURS {D2KWH:#0##}
DA-002 FUEL USED TOTAL {DA002PV27:#####}{DA002PV26:#.#####} kLITRES
DA-002 FUEL ECONOMY {DA002PV32:##}.{DA002PV33:###} kWH/L







DA-003 HOURS RUN {DA003PV5:##########}:{DA003PV4:#0}
DA-003 MEGAWATT HOURS {DA003PV11:########}
DA-003 HOURS RUN IN LAST 24 HOURS {D3HRS:###}:{D3MINS:#0}
DA-003 LUBE OIL USED IN LAST 24 HOURS {D3LUBE:#0##}
DA-003 FUEL USED IN LAST 24 HOURS {D3LFO:#0##}
DA-003 KILOWATT HOURS PRODUCED IN LAST 24 HOURS {D3KWH:#0##}
DA-003 FUEL USED TOTAL {DA003PV27:#####}{DA003PV26:#.#####} kLITRES
DA-003 FUEL ECONOMY {D324HRECON:#.###} kWH/L

DA-004 HOURS RUN {DA004PV26:##########}:{DA004PV25:#0}
DA-004 MEGAWATT HOURS {DA004PV32:########}
DA-004 HOURS RUN IN LAST 24 HOURS {D4HRS:#0}:{D4MINS:#0}
DA-004 LUBE OIL USED IN LAST 24 HOURS {D4LUBE:#0##}
DA-004 FUEL USED IN LAST 24 HOURS {D4LFO:#0##}
DA-004 KILOWATT HOURS PRODUCED IN LAST 24 HOURS {D4KWH:#0##}
DA-004 FUEL USED TOTAL {DA004PV35:######}{DA004PV34:#.#####} kLITRES
DA-004 FUEL ECONOMY {DA004PV40:##}.{DA004PV41:###} kWH/L

DA-005 HOURS RUN {DA005HRTOTHRS:##########}:{DA005HRTOTMIN:#0}
DA-005 MEGAWATT HOURS {DA005MWHTOT:#0####.###}
DA-005 HOURS RUN IN LAST 24 HOURS {D5HRS:###}:{D5MINS:#0}
DA-005 LUBE OIL USED IN LAST 24 HOURS {D5LUBE:#0##}
DA-005 LFO USED IN LAST 24 HOURS {D5LFO:#0##}
DA-005 KILOWATT HOURS PRODUCED IN LAST 24 HOURS {D5KWH:#0######}
DA-005 LFO FUEL USED TOTAL {DA005LFOLTOT:#0###.####} kLITRES
DA-005 FUEL ECONOMY {DA005PV1:##}.{DA005PV2:###} kWH/L

DA-006 HOURS RUN {DA006HRTOTHRS:##########}:{DA006HRTOTMIN:#0}
DA-006 MEGAWATT HOURS {DA006MWHTOT:#0####.###}
DA-006 HOURS RUN IN LAST 24 HOURS {D6HRS:###}:{D6MINS:#0}
DA-006 LUBE OIL USED IN LAST 24 HOURS {D6LUBE:#0##}
DA-006 LFO USED IN LAST 24 HOURS {D6LFO:#0##}
DA-006 KILOWATT HOURS PRODUCED IN LAST 24 HOURS {D6KWH:#0######}
DA-006 LFO FUEL USED TOTAL {DA006LFOLTOT:#0###.###} kLITRES
DA-006 FUEL ECONOMY {DA006PV1:##}.{DA001PV2:###} kWH/L

END OF REPORT

Hope this helps.

beerchug
 
Hi. To comment out a section of code try this

*/ code
code
code
code
/*

All the above code is commented out.
If your reports are really long and complicated or you want to get fancy then you can integrate Crystal Reports into the project.
It takes a fair amount of cicode (I am not talking about just using the "exec" function here) as you have to call/invoke (not sure of the terminology) the crystal dll.
Regards Alan Case
 
thanks , I will try all these suggestions. These reports here are going to excel and are printed out at the moment at midnight (4 seperate reports) automatically. Again thanks to all. Any other suggestions are most welcome. Rich
 
Well I handled the problem a different way. I put a button on the main screen to go to excel and then made a macro to retrieve all 4 reports and put them together and print automatically when button is pushed. Works great.

I appreciate the responses I got to help solve that problem.

Now the only thing I have to figure out is how to get the correct oil and gas reading to show up on the report. It use to work, now it shows 0's for both. On the main graphic its showing up and changing values for both every few seconds, just not on the reports.

Everything else shows up fine. Rich
 

Similar Topics

Hi All, Can anyone advise me on how to determine the AN of a genie instance I writing to. I have created a genie to display a valve and some text...
Replies
0
Views
101
I am trying to display a variable within a cicode function onto a graphics page. This function queries a SQL database. I can get the value onto a...
Replies
3
Views
346
Hi guys, its my first time progamming cicode and I need to do popups alarms, there are several digital alarms and in their rising edge transition...
Replies
0
Views
527
Hi all :) , I'm very new to CitectSCADA and Cicode programming, however have good programming experience in most major programming languages...
Replies
0
Views
1,259
Hi, all :)), I'm very new to CitectSCADA and Cicode programming, however have good programming experience in most major programming languages...
Replies
7
Views
3,651
Back
Top Bottom