 Managing programs

The Program Management window shows the programs (also called modules or programming units) of the application and groups into its menus the available commands, to create the project architecture, run editors, compiler and debugger. This window is the workbench kernel during the development of an application. The Program Management window opens when running the "Open" command in the Project Management window.

The components of a project

Working with programs

Running the code generation tools

Other ISaGRAF tools

Adding commands to the Tools menu

Simulating and debugging the application


The components of a project

The components of a project are called programs. A program is a logical entity that describes one part of the control execution. Global variables (such as I/O variables) can be used by any program in the application. Local variables may be used by only one program. Programs are listed in a hierarchy tree, divided into different logical sections. The window shows the programs and the links between them. The "Top level" programs appear on the left side of the hierarchy tree.

Top level programs

Functions and function blocks

Sub-programs

Child SFC and FC programs

Links between programs and sub-programs:

Programming languages


Top level programs

The top level programs appear on the left side of the hierarchy tree. Top level programs of the three first sections are always active, and are executed in the following order, during the run time cycle (scan):

•	(Read inputs)

•	Execute the top level programs of the BEGIN section

•	Execute the top level programs of the SEQUENTIAL section

•	Execute the top level programs of the END section

•	(Refresh outputs)

The programs of the "Begin" or "End" sections describe cyclic operations. They are not dependent on Time. The programs of the "Sequential" section describe sequential operations, where the Time variable explicitly appears to distinguish basic operations. The main programs of the "Begin" section are systematically executed at the beginning of each run time cycle. The main programs of the "End" section are systematically executed at the end of each run time cycle. The main programs of the "Sequential" section are executed on the basis of the SFC or FC rules and must be written in SFC or FC language. The programs of the cyclic sections cannot be described in the SFC or FC language. Any program of any section may own one or more sub-programs.


Functions and function blocks

The programs of the "Functions" section can be called by any program of any section in the project. A function is an algorithm that process one output value from several input values. A function algorithm only works with volatile intermediate variables, erased from one call to the other. This implies that a function should never call a function block. A program of the "Functions" section cannot be described in the SFC or FC language.

Unlike functions, "Function blocks" associate an algorithm working on input values with hidden static data, which are copied (instanced) by the system on each different use of the function block. The programs of the "Function Blocks" section can be called by any program of any section in the project. They cannot be programmed in SFC or FC language.


Sub-programs

Sub-programs are functions dedicated to one (SFC, FC or other) father program. A sub-program can be executed (called) by its parent program only. Each program of each section may have one or more sub-programs. Any language apart from SFC and FC can be used to describe a sub-program.


Child SFC and FC programs

A child SFC program is a parallel program that can be started or killed by its parent program. The parent program and child program must both be described in SFC language.

When a parent program starts a child SFC program, it puts a SFC token into each initial step of the child program. When a parent program kills a child SFC program, it clears all the tokens existing in the steps of the child.

Any FC program of the sequential section may control other FC sub-programs. An FC father program is blocked (waits) during execution of an FC sub-program. It is not possible that simultaneous operations are done in father FC program and one of its FC sub-programs.


Links between programs and sub-programs:

Sub-programs and child programs are linked to their parent program by a line in the hierarchy tree. A link between an SFC program and an SFC child program is ended by an arrow. Note that such a link represents parallel operations.


Programming languages

Each program is described in only one language. This language, selected when the program is created, cannot be changed afterwards. However, FBD diagrams may include parts in LD, and LD diagrams may include function block calls. Available graphic languages are: SFC (Sequential Function Chart), FC (Flow Chart) FBD (Functional Block Diagram) and LD (Ladder Diagram). Available literal languages are: ST (Structured Text) and IL (Instruction List). SFC and FC languages are reserved for main and child programs of the sequential section. The language of each program is shown as an icon beside the program name in the Program Management window. Below are the icons used to represent the languages :

 SFC	Sequential Function Chart

 FC	Flow Chart

 FBD	Functional Block Diagram

 LD	Ladder Diagram (entered with Quick LD editor)

 ST	Structured Text

 IL	Instruction List


Working with programs

The "File" menu groups all the commands used to create, update or modify programs. It also launches appropriate editors to enter the contents of application programs.

Creating a new program

Entering comments for each program

Editing the contents of a program

Editing the "diary" file

The dictionary of variables

Parameters of a function, sub-program or function block

Moving a program in the hierarchy tree

Copying programs

Deleting programs

Other commands are available from the "Tools" menu:

Importing function or function block from library

Exporting function or function block to library


Creating a new program

The "New" function of the "File" menu allows the creation of top level, child or sub-programs into each program section. The first piece of information to be entered is the name of the new program according to the following naming rules:

•	the maximum length of a name is 8 characters

•	the first character must be a letter

•	the following characters must be letters, digits or '_' character

•	the naming of a program is case insensitive

Next, select the editing language chosen to describe the new program:

SFC	Sequential Function Chart

FC	Flow Chart

FBD	Functional Block Diagram (may include parts in LD)

LD	Ladder Diagram entered with Quick LD editor

ST	Structured Text

IL	Instruction List

Finally, select an execution style for the program:

Begin	top level of the "Begin" section

Sequential	top level of the "Sequential" section

End	top level of the "End" section

Function	in the "Functions" section

Function block	in the "Function Blocks" section

Child of...	SFC or FC child or sub-program of an existing program

By selecting one of the first five choices, the program is put at the top level of a Begin, End, Sequential, Functions or Function Blocks section. The selection of the latter indicates that the new program is an SFC child program or an FC sub-program or a sub-program. Remember that a top level sequential program must be described in the SFC or FC language, and that the SFC and FC languages cannot be used for cyclic programs and their sub-programs.


Entering comments for each program

ISaGRAF allows you to attach a description text to each program of the project. This comment text is displayed with smaller character font beside the name of the program. Use the "File / Program comment text" command to enter or change the comment attached to the selected program.


Editing the contents of a program

This command allows the modification of a program's contents. The editor used to enter a program depends on the language chosen for that program. Program editing is carried out in individual windows, so that it is possible to edit more than one program through parallel windows. Pressing the ENTER key allows the editing of the highlighted program. The user can also double click with the mouse on the name of the program to edit it.


Editing the "diary" file

A diary file is attached to each program. This is a text file which contains all the notes about the modifications made to the program during its lifetime. The diary file can be edited, freely modified or printed at any time. When leaving the editor used to modify the source code of a program, a window is automatically opened to enter notes for the diary list. Such notes are inserted with the correct date and time into the diary file.


The dictionary of variables

The "File / Dictionary" command runs the dictionary editor, where are declared the variables of the project. Variables may be global (known by any program in the project) or local to the selected program. The dictionary editor may also be used to declare defined words which are semantic aliases used to replace a name or an expression in the source code of a program.


Parameters of a function, sub-program or function block

The "File / Parameters" command allows the user to define the call and return parameters of the selected sub-program, function or function block. This command has no effect if a main program of the "Begin" or "End" section, or an SFC program is selected in the Program Management window.

Sub-programs, functions or function blocks may have up to 32 parameters (input or output). A function or sub-program always has one (and only one) return parameter, which must have the same name as the function, in order to conform with ST language writing conventions.

The list in the upper left side of the window shows the parameters, in the order of the calling model: first the calling parameters, last the return parameters. The lower part of the window shows the detailed description of the parameter currently selected in the list. Any of the ISaGRAF data types may be used for a parameter. The return parameters must be located after calling parameters in the list. Naming parameters must conform to the following rules:

•	the length of the name cannot exceed 16 characters

•	the first character must be a letter

•	the following characters must be letters, digits or underscore character

•	naming is case insensitive

The "Insert" command is used to insert a new parameter before the selected parameter. The "Delete" command is used to erase the selected parameter. The "Arrange" command automatically rearranges (sorts) the parameters, so that the return parameters are put at the end of the list.


Moving a program in the hierarchy tree

The "Rename/move" command of the "File" menu is used to change the name of a program, or to move it into another section of the hierarchy tree. However the description language of an existing program cannot be changed. When running this command, the same window as the one used for creating programs is opened, and all fields are set up with the attributes of the selected program. The name of a program can be modified, and another section or parent program selected to move it into the hierarchy tree.

The "Arrange programs" command of the "File" menu is used to give an explicit order between a list of programs with same level and father. If the selected program is at the top level, the command is used to arrange the top level programs of the selected section. If the selected program is at a lower level, the command arranges only the SFC children and sub-programs which have the same father as the selected one. When the "Arrange programs" dialog box is opened, select the program you want to move, and press the "Up" or "Down" button to move it in the list.


Copying programs

To make a copy of a program, select the source program from the list of programs, and run the "File / Copy" command. When running this command, the same window as that used for creating programs is opened, with all fields set up with the attributes of the selected program. Enter the name of the destination program and its location in the sections of the hierarchy tree. If the destination program does not exist, it is created at the specified location. If the destination program already exists, it is overwritten. All the local declarations and defined words are copied with the program. The description language of the destination program must be the same as the one used for the source program. Press the "OK" button to copy the program.

The "Copy to other project" command of the "File" menu copies the selected program into another project, with the same name. The child SFC programs and sub-programs of the selected program can be copied with it. The names of the selected program and its children must not be used in the target project. Programs cannot be overwritten by this command. All the attached local declarations and defined words are copied with the programs.


Deleting programs

To delete a program, first select it from the list of programs, and then run the "File / Delete" command. A program owning child or sub-programs cannot be deleted. In order to delete a program with child or sub-programs, the child or sub-programs must be deleted first. All the local declarations and defined words are deleted with the program.


Importing function or function block from library

The "Tools / Import from library" command is used to copy a function or a function block written in IEC language described in the library to the "Functions" or "Function blocks" section of the open project. Local variables and defined words attached to the imported function are copied with it. When a function has been correctly imported from the library, it can be placed in another section or another location in the hierarchy tree, using the "File / Rename/Move" command. In order to avoid naming clashes, the imported function or function block must be renamed when imported in the project area. Don't forget to rename also the return parameter in the case of a function.


Exporting function or function block to library

The "Tools / Export to library" command is used to send a program of the "Functions" or "Function blocks" section (in the open project) to the appropriate library. Local variables and defined words attached to the exported function or block are copied with it. The exported function or block will have to be re-compiled (verified) from the ISaGRAF Library Manager, to ensure that it can be used in a library environment. Functions and function blocks of the library cannot use global variables.


Running the code generation tools

The commands of the "Make" menu are used to run the code generator, and to enter options and additional data used when producing the application code. Refer to the chapter "Using the code generator" in this document for further information about these tools.

Make the application code

Verify the selected program

Simulating a modification

Application run-time options

Compiler options

Defining resources


Make the application code

The "Make" command starts the project code generation. The options for target code generation must be set correctly before running this command. Before generating the target code, any program that is still not verified is checked to detect the syntax errors. ISaGRAF includes an incremental compiler which does not re-compile programs which have already been compiled.


Verify the selected program

The "Verify" command allows the user to verify the syntax of the program currently selected in the list. When a program is verified, with no error detected, it is not re-verified during the code generation until its contents or dependent defined words or variables change.


Simulating a modification

The "Touch" command simulates a modification of each program so that all of them will be compiled again during the next code generation.


Application run-time options

This command opens a dialog box where are entered the main run-time parameters for the execution of the application. This includes the cycle timing programming, run time error management, the starting mode and the hardware implementation of retained variables. Refer to the chapter "Using the Code Generator" in this document for more explanations about this command.


Compiler options

This command is used to setup the options used by the ISaGRAF Code Generator to produce and optimize target code. Refer to the chapter "Using the Code Generator" in this document for more explanations about this command.


History of modifications

This command opens a dialog box where is displayed the history of modifications for the project. Refer to the chapter "Managing projects" in this document for more explanations about this command.


Defining resources

A "resource" is a user defined data (for example a file) which has to be merged with the target code so it can be downloaded with it. Refer to the section "Using the Code Generator" in this document for more explanations about the format of the resource definition file.


Other ISaGRAF tools

The "Project" menu groups the commands that run ISaGRAF tools for the selected project. Refer to the corresponding chapters in this document for more information about these tools.

Wiring I/O variables

Running the cross reference editor

Entering the project descriptor

Printing a complete document

History of modifications


Wiring I/O variables

The "IO connection" command runs the ISaGRAF I/O variable connection editor. This tool is used to establish the relationship between I/O variables declared in the project dictionary and corresponding I/O hardware.


Running the cross reference editor

The "Cross references" command allows the user to calculate, view or print the cross references of the project. The cross references show the user all the occurrences of each variable in the source code of the programs, in the entire project. This function is very useful to detect an access to a variable or any global resource, or to list all the occurrences of a global variable in the source code.


Entering the project descriptor

The "Project descriptor" command is used to edit the project text descriptor. This document fully identifies the project from the others on the project list. The project descriptor can also be used to record any remarks during the project lifetime. The project descriptor is the one displayed in the Project Manager window.


Printing a complete document

The "Print project document" command allows the user to build and print a complete document about the selected project. This document can group any component (program, variable, parameters...) of the selected project. To build a specific (non-complete) document, the user only has to define its table of contents.


Adding commands to the Tools menu

ISaGRAF provides the way to insert other commands in the "Tools" menu. User defined commands to be added are described in "\ISAWIN\COM\ISA.MNU" text file. You can add up to 10 commands. Comments may be inserted on any line, beginning with ";" character. Each command is described on two lines of text, according to the following syntax:

M=menu_string

C=command_line

The menu string is the text to be displayed in the "Tools" menu. The command line is any MS-DOS or Windows executable, and can be completed with arguments. In command line, you can use "%A" characters to replace the name of the open project, and "%P" characters to replace the name of the selected program. The following example runs "Notepad" to edit the selected program (to be used with ST and IL programs):

M=Edit with Notepad

C=Notepad.exe \isawin\apl\%A\%P.lsf


Simulating and debugging the application

The command of the "Debug" menu are used to run the ISaGRAF graphic debugger, either in simulation mode or in real connected mode.

Simulation

Real debugging

Preparing debug workspace

Link setup

Serial link setup

Ethernet link setup


Simulation

The "Simulate" command opens the debugger in simulation mode. In this mode, another window appears, called the simulator. This command is very useful to test any application when the target machine is unavailable. Starting the simulator closes the Program Management window. The Program Management window is then re-opened in debug mode after both debugger and simulation windows are opened. The simulator cannot be started if the target code has not been generated. The simulator cannot be started when child windows (editors, code generation, I/O connection...) are opened. Each of them must be closed before running this command. This command is also available from menus of ISaGRAF editors.


Real debugging

The "Debug" command opens the debugger main window, and closes the Program Management window. The Program Management window is then re-opened in debug mode as soon as communication is established between the debugger and the target application. The debugger cannot be started if the target code has not been generated. The debugger cannot be started when child windows (editors, code generation, I/O connection...) are opened. Each of them must be closed before running this command. This command is also available from menus of ISaGRAF editors.


Link setup

The "Link setup" command It enables the user to define the parameters of the link used for communication between the debugger on the host PC and the target ISaGRAF system.

The "Slave number" identifies the target ISaGRAF system or task. It can be from 1 to 255. Refer to the target supplier manual for the slave number of the target system used.

The "Communication port" identifies the hardware media between ISaGRAF workbench and target. It can be either the name of a serial port, or "Ethernet", reserved TCP-IP communication using the "Winsock" Version 1.1.

The "Time out" is the time left to the target system for its communication operations between the end of a debugger question and the beginning of its response. This time is set as a number in seconds. The "Retries" field is the number of automatic trials the debugger executes for a communication operation before detecting a communication error.


Serial link setup

When a serial port (COM1..4) is selected, the "Setup" button is used to access to other serial link communication parameters.

The transmission baud rate, parity and format may be selected. When the "hardware" choice is selected for "Flow Control", the ISaGRAF Workbench controls the CTS and DSR lines to enable hardware handshaking during exchanges.


Ethernet link setup

When "Ethernet" is selected as a communication port, the "Setup" button is used to enter the "Internet Address" and "Internet port" number, for TCP-IP communication.

These fields use the standard formats defined by the Socket interface. The Workbench uses the WINSOCK.DLL Version 1.1 library for TCP-IP communications. This file must be correctly installed on the hard disk. "1100" is the default port number used if not specified when running the ISaGRAF target.


Preparing debug workspace

The "Debug / Workspace" command enables you to define a list of documents for initial workspace. Such documents can be programs, SpotLight graphics, lists of variables. Graphics and lists of time diagrams from previous ISaGRAF versions are also listed with project documents. Documents defined in the initial workspace are automatically opened when simulation or On Line monitoring is launched.

The dialog box shows the existing documents of the project on the left, and documents selected for the initial workspace on the right. Use ">>" and "<<" push buttons to move documents from one list to the other. Each project has its own list of documents for initial workspace.