Sunteți pe pagina 1din 8

5/24/2015

SCADA

Nguyễn Đức Hoàng

Introducing Cicode
• Cicode is a programming language designed for use in CitectSCADA to
monitor and control plant equipment.
• It is a structured language similar to Visual Basic or 'C'.

1
5/24/2015

Writing Functions

• A Cicode function is a small program: a collection of statements,


variables, operators, conditional executors, and other functions.

Cicode Function Structure

FUNCTION
FunctionName ( )
! The exclamation point indicates that the rest of this line
contains a comment.
! Further Cicode statements go here, between the function name
and the END.
END

2
5/24/2015

Example of Cicode Function


FUNCTION
IncCounter ( )
IF COUNTER < 100 THEN
COUNTER = COUNTER + 1;
ELSE
COUNTER = 0;
END
END

Declaring the Return Data Type


<ReturnDataType>
FUNCTION
FunctionName ( <Arguments> )
<Statement> ;
<Statement> ;
<Statement> ;
END

3
5/24/2015

Example of Cicode Function

INT ! declare return value as integer


FUNCTION
FunctionName ( )
REAL Status = 5; ! declare variable as a REAL number
RETURN Status; ! returned as an integer number
END

4
5/24/2015

SCADA

Nguyễn Đức Hoàng

Exchanging Data with Other Applications


• You can transfer data between CitectSCADA and other software for
storage, analysis, and post processing, or to control and tune your
CitectSCADA system.
• CitectSCADA uses the following methods to exchange data:
• dynamic data exchange (DDE), where CitectSCADA can act as a:
• DDE server providing tag values to requesting clients
• l DDE client to request data from other applications.
• open database connectivity (ODBC), where CitectSCADA functions as an ODBC
server, allowing other applications to read CitectSCADA variables directly.
• By using a common external database, where CitectSCADA and other
applications use the same database to store and share information.

1
5/24/2015

Exchanging Data with Other Applications

• Microsoft Windows DDE allows the continuous and automatic


exchange of data between different Windows applications on the
same machine without the need for any user intervention.

• Dynamic Data Exchange occurs between a DDE client application


(which requests the data or service) and a DDE server application
(which provides the data or service).

Exchanging Data with Other Applications

• The DDE Client starts the exchange by establishing a conversation


with the DDE server, and requesting data or services.
• The DDE server responds to these requests by providing the data or
services to the DDE Client.
• The DDE Client terminates the conversation when it no longer needs
the DDE server's data or services.
• As the DDE protocol is not designed for high-speed data transfer, the
use of DDE is only appropriate when data communication speed is
not critical.

2
5/24/2015

DDE conversations and client syntax


• Two applications participating in Dynamic Data Exchange are said to
be engaged in a DDEconversation.
• The application that initiates the conversation is the DDE Client, and
the application that responds to the DDE Client is the DDE server.

DDE conversations and client syntax


<DDE server application name>|<DDE Topic name>!<DDE Data item name>

• <DDE server applicationname> : the DDE server application.


• <DDE Topic name> : the context of the data.
• <DDE Data item name> : the data item that a DDE server can pass to
a DDE Client during a DDE transaction.

• Ex: Citect|Variable!Pump_Speed

3
5/24/2015

Writing values to a DDE application


• Use the Cicode DDEWrite() function.
• Ex:
! Write PV1 to Excel
! Assumes the existence of Sheet1
DDEWrite("Excel", "Sheet1", "R1C1", PV1);

Reading values from a DDE application


• Use the Cicode DDERead() function.
• Ex:
! Write PV1 to Excel
! Assumes the existence of Sheet1
PV1 = DDERead("Excel", "[Book1]Sheet1", “R1C1”);

S-ar putea să vă placă și