TM-1403 AVEVA Plant (12.1) PML Applied Rev 1.0 (Watermarked)
TM-1403 AVEVA Plant (12.1) PML Applied Rev 1.0 (Watermarked)
(12.1)
a
24 dr
TRAINING GUIDE
2/ ahin
Programmable Macro
29 . M
te: ech
Language:
/0
Da r: T
Applied
me
sto
Cu
TM-1403
www.aveva.com
AVEVA Plant (12.1)
Programmable Macro Language: Form Design - TM-1402
a
24 dr
2/ ahin
29 . M
te: ech
/0
Da r: T
me
sto
Cu
www.aveva.com
© Copyright 1974 to current year. 2
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Plant (12.1)
Programmable Macro Language: Form Design - TM-1402
Revision Log
Date Revision Description of Revision Author Reviewed Approved
04/01/2012 0.1 Issued for Review EJW
13/02/2012 0.2 Reviewed EJW SS
14/02/2012 1.0 Approved for Training PDMS 12.1.SP2 EJW SS NG
Updates
a
In general, all headings containing updated or new material will be highlighted. However, highlighting has
24 dr
not been employed at Revision 1.0 as this is the intial release of this training guide.
Suggestion / Problems
2/ ahin
If you have a suggestion about this manual or the system to which it refers, please report it to AVEVA
29 . M
Training & Product Support (TPS) at [email protected]
This manual provides documentation relating to products to which you may not have access or which may
te: ech
not be licensed to you. For further information on which products are licensed to you please refer to your
/0
licence conditions.
Da r: T
Disclaimer
me
1.1 AVEVA does not warrant that the use of the AVEVA software will be uninterrupted, error-free or free
sto
from viruses.
1.2 AVEVA shall not be liable for: loss of profits; loss of business; depletion of goodwill and/or similar losses;
Cu
loss of anticipated savings; loss of goods; loss of contract; loss of use; loss or corruption of data or
information; any special, indirect, consequential or pure economic loss, costs, damages, charges or
expenses which may be suffered by the user, including any loss suffered by the user resulting from the
inaccuracy or invalidity of any data created by the AVEVA software, irrespective of whether such losses are
suffered directly or indirectly, or arise in contract, tort (including negligence) or otherwise.
1.3 AVEVA shall have no liability in contract, tort (including negligence), or otherwise, arising in connection
with the performance of the AVEVA software where the faulty performance of the AVEVA software results
from a user's modification of the AVEVA software. User's rights to modify the AVEVA software are strictly
limited to those set out in the Customisation Manual.
1.4 AVEVA shall not be liable for any breach or infringement of a third party's intellectual property rights
where such breach results from a user's modification of the AVEVA software or associated documentation.
1.5 AVEVA's total liability in contract, tort (including negligence), or otherwise, arising in connection with the
performance of the AVEVA software shall be limited to 100% of the licence fees paid in the year in which the
user's claim is brought.
1.6 Clauses 1.1 to 1.5 shall apply to the fullest extent permissible at law.
www.aveva.com
© Copyright 1974 to current year. 3
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Plant (12.1)
Programmable Macro Language: Form Design - TM-1402
1.7. In the event of any conflict between the above clauses and the analogous clauses in the software
licence under which the AVEVA software was purchased, the clauses in the software licence shall take
precedence.
Trademarks
AVEVA and Tribon are registered trademarks of AVEVA Solutions Limited or its subsidiaries. Unauthorised
use of the AVEVA or Tribon trademarks is strictly forbidden.
AVEVA product/software names are trademarks or registered trademarks of AVEVA Solutions Limited or its
subsidiaries, registered in the UK, Europe and other countries (worldwide).
The copyright, trademark rights, or other intellectual property rights in any other product or software, its
name or logo belongs to its respective owner.
Copyright
Copyright and all other intellectual property rights in this manual and the associated software, and every part
a
of it (including source code, object code, any data contained in it, the manual and any other documentation
24 dr
supplied with it) belongs to, or is validly licensed by, AVEVA Solutions Limited or its subsidiaries.
2/ ahin
All rights are reserved to AVEVA Solutions Limited and its subsidiaries. The information contained in this
document is commercially sensitive, and shall not be copied, reproduced, stored in a retrieval system, or
transmitted without the prior written permission of AVEVA Solutions Limited. Where such permission is
granted, it expressly requires that this copyright notice, and the above disclaimer, is prominently displayed at
29 . M
the beginning of every copy that is made.
The manual and associated documentation may not be adapted, reproduced, or copied, in any material or
te: ech
electronic form, without the prior written permission of AVEVA Solutions Limited. Subject to the user's rights,
/0
as set out in the customisation manuals to amend PML software files contained in the PDMSUI and PMLLIB
folders and any configuration files, the user may not reverse engineer, decompile, copy, or adapt the
Da r: T
software. Neither the whole, nor part of the software described in this publication may be incorporated into
any third-party software, product, machine, or system without the prior written permission of AVEVA
Solutions Limited, save as permitted by law. Any such unauthorised action is strictly prohibited, and may
me
The AVEVA software described in this guide is to be installed and operated strictly in accordance with the
sto
terms and conditions of the respective software licences, and in accordance with the relevant User
Documentation.
Cu
Copyright 1974 to current year. AVEVA Solutions Limited and its subsidiaries. All rights reserved. AVEVA
shall not be liable for any breach or infringement of a third party's intellectual property rights where such
breach results from a user's modification of the AVEVA software or associated documentation.
AVEVA Solutions Limited, High Cross, Madingley Road, Cambridge, CB3 0HB, United Kingdom.
www.aveva.com
© Copyright 1974 to current year. 4
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
Contents
1 Introduction .............................................................................................................................................. 7
1.1 Aim..................................................................................................................................................... 7
1.2 Objectives ......................................................................................................................................... 7
1.3 Prerequisites .................................................................................................................................... 7
1.4 Course Structure .............................................................................................................................. 7
1.5 Using this Guide ............................................................................................................................... 7
2 PML Overview .......................................................................................................................................... 9
2.1 PML 1 – String Based Command Syntax ....................................................................................... 9
2.1.1 Example of a simple command syntax macro ........................................................................... 9
2.1.2 Examples of command syntax ................................................................................................... 9
2.1.3 Syntax graphs .......................................................................................................................... 10
2.2 PML 2 – Object-orientated programming .................................................................................... 11
2.2.1 Features of PML 2 .................................................................................................................... 11
2.2.2 Examples of object-orientated PML ......................................................................................... 11
2.2.3 Software Customisation Reference Manual ............................................................................. 11
2.3 PML Objects ................................................................................................................................... 12
a
2.3.1 Creating variables (instances of objects) ................................................................................. 12
24 dr
2.3.2 Naming conventions ................................................................................................................. 13
2.3.3 Using the members of an object .............................................................................................. 13
2.3.4
2.4
2.4.1
2/ ahin
Special objects used in PDMS ................................................................................................. 13
PML Functions and Methods ........................................................................................................ 14
Arguments of type ANY ............................................................................................................ 14
2.5 PML Forms...................................................................................................................................... 15
29 . M
a
24 dr
2/ ahin
29 . M
te: ech
/0
Da r: T
me
sto
Cu
www.aveva.com
© Copyright 1974 to current year. 6
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
CHAPTER 1
1 Introduction
This training guide is designed to give an introduction to the AVEVA Plant Programming Macro Language.
There is no intention to teach software programming but only provide instruction on how to customise PDMS
using Programmable Macro Language (PML) in AVEVA Plant.
This training guide is supported by the reference manuals available within the products installation
folder. References will be made to these manuals throughout the guide.
1.1 Aim
The following points need to be understood by the trainees:
a
Understand how to use the built-in objects of AVEVA Plant
24 dr
Understand the use of Addins to customise the environment.
1.2 Objectives
At the end of this training, you will have:
2/ ahin
29 . M
Knowledge of how Forms are created and how Form Gadgets and Form Members are defined
Understanding of Menus and Toolbars are defined with PML
te: ech
Understanding of Collections, Basic Event Driven Graphics, Error Tracing and PML Encryption
/0
1.3 Prerequisites
Da r: T
Completed an AVEVA Basic Design Course and have a familiarity with PDMS
Completed the PML: Macros & Functions Course or have familiarity with PML.
sto
Each trainee will be provided with some example files to support this guide. Each workstation will have a
training project, populated with model objects. This will be used by the trainees to practice their methods,
and complete the set exercises.
Menu pull downs and button press actions are indicated by bold dark turquoise text.
System prompts should be bold and italic in inverted commas i.e. 'Choose function'
Example files or inputs will be in the courier new font with colours and styles used as before.
www.aveva.com
7
© Copyright 1974 to current year.
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Plant (12.1)
Programmable Macro Language: Appied - TM-1403
a
24 dr
2/ ahin
29 . M
te: ech
/0
Da r: T
me
sto
Cu
www.aveva.com
© Copyright 1974 to current year. 8
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
CHAPTER 2
2 PML Overview
Programmable Macro Language (PML) is the customisation language used by AVEVA Plant and it provides
a mechanism for users to add their own functionality to the AVEVA Plant software family. This functionality
could be as simple as a re-naming macro, or as complex a complete user-defined application (and
everything in between).
PML is a coding language specific to AVEVA products based on the command syntax that is used to drive
PDMS. As the product develops, PML is also improved providing new functionality and bringing it closer to
other object-orientated programming languages, while still retaining the powerful command syntax.
Although it is one language, there are three distinct parts:
PML 1 the first version of PML based on command syntax. String based and provides IF
statement, loops, variables & error handling
PML 2 object oriented language extending the ability of PML. Use of functions, objects and
a
methods to process information (also covered in TM-1402 – Form Design)
24 dr
PML .NET provides the platform in PML to display and use objects created in other .NET
languages (covered in TM-1402 – Form Design)
A simple macro is likely to be written completely in command syntax and allows users to re-run popular
commands. Saved as an ASCII file, the macro can be run in PDMS through the command window (by
/0
The following is an example of a simple macro that can be used to create an Equipment element. As each
line is run in order, the same piece of equipment will be created each time the macro is run.
sto
Macros can be extended to include IF statements, DO loops, variables and error handling (explained further
later in the course) If additional information is typed onto the same line as the call for the macro, then these
become input parameters and are available for use within the macro.
In this example, the three numbers (100, 200 & 300) become the three parameters supplied to the macro.
To set a value to an attribute on the current element (for example XLEN), type XLEN 300
Manipulating the drawlist in DESIGN:
To add the current element to the drawlist, type ADD CE
To add a specific element below a piece of equipment, type ADD ONLY /E1301-S1
To remove all the elements from the drawlist, type REM ALL
a
To remove all number 1000 sphere aids, type AID CLEAR SPHERE 1000
24 dr
To remove all graphical aids, type AID CLEAR ALL
To move the current element 1000mm in a N45E direction, type MOVE N45E DIST 1000
/0
To move the current element E, until it is in line with /BOX, type MOVE E THRU /BOX
To rotate the current element around its origin (pointing up) by 45, type ROTATE BY 45 ABOUT U
Da r: T
To position & orientate the current element based on /EQUIP-N1, type CONNECT P2 TO P0 OF
/EQUIP-N1
To position & orientate the current element based on the previous, type CONNECT P3 TO P1 OF
sto
PREV
Many examples of command syntax are provided in the various reference manuals within the installation
folder of AVEVA Plant. For each a syntax graph is provided to show the various combinations of syntax
available:
The above syntax graph is for the ADD syntax (used to add elements to the drawlist). From the graph it can
be seen that only two words are required (e.g. ADD /PIPE) but others can be included (e.g. ADD ONLY
/PIPE1 /PIPE2 COL 3).
The $Q syntax can also tell you the next allowable part of the syntax. For example ADD $Q-10 would print
the 10 next available words that can follow the command ADD.
More examples of command syntax and the supporting syntax graphs can be found in the relevant
reference manuals provided with AVEVA Plant.
www.aveva.com
© Copyright 1974 to current year. 10
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Plant (12.1)
Programmable Macro Language: Appied - TM-1403
PML 2 provides for classes of built-in, system-defined and user-defined object types. Objects have members
(their own objects) and methods (their own functions). All PML variables instances of (1) built-in, (2) system-
defined or (3) user-defined objects.
Through the use of method concatenation, it is possible to achieve multi-operations in a single line of code.
This means that PML 2 methods are typically shorter and easier to read than the PML 1 equivalent. While
most PML 1 macros will still run within PDMS, PML 2 brings many new features that were previously
unavailable. If used together with command syntax it must be expressed as a string before use.
a
Global Functions supersede old style macros
24 dr
User Defined Object Types
PML Search Path (PMLLIB)
To find out how large an ARRAY variable is, type q var !arrayVariable.size()
To find out how long a STRING variable is, type q var !stringVariable.length()
Clearing an object
To empty an object, type !exampleObject.clear()
To delete an object that is no longer needed, type !exampleObject.delete()
For each of the members the name, type and purpose is provided
For each method the name, argument types, returned object type and purpose are provided.
Refer to the Software Customisation Reference Manual for more information about the major objects.
www.aveva.com
© Copyright 1974 to current year. 11
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Plant (12.1)
Programmable Macro Language: Appied - TM-1403
Refer to the Software Customisation Reference Manual for more examples of System-defined objects
When a variable is declared as a specific object type, it is given all the members (attributes) and methods of
the object definition. This means standard groupings can be setup to store data and that code repetition can
be avoided.
A user-defined object provides an opportunity to group data together for a specific purpose. Once grouped
as an object, it can be assigned to a variable and used as any other object. The following are examples of
two user-defined objects:
a
24 dr
define object FACTORY
member .name is STRING
member .workers is REAL
member .output is REAL
endobject
2/ ahin
29 . M
endobject
Da r: T
These objects would be defined as two separate object files (.pmlobj) and loaded into PDMS. You will
notice that the object PRODUCT is able to have a member which is another user-defined object. This
me
means that the PRODUCT object has access to all the members and methods of a FACTORY object.
There are two types of variables in PML (1) Local and (2) Global
Cu
The difference between the two is that global variables last for the whole PDMS session and can be
referenced directly from other PML routines. Local variables are only available within the routine which
defined them. The variables a declared with a single „!‟ for local and a double „!!‟ for global
It is also possible to define a variable as an object-type without an initial value. The value is therefore
UNSET
www.aveva.com
© Copyright 1974 to current year. 12
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Plant (12.1)
Programmable Macro Language: Appied - TM-1403
For example, the type might be WORKERS while the name of the variable might be numberOf Workers
Notice that to make the variable name more meaningful, full words are used with a mixture of upper and
lower case letters to make it readable.
Variable names should not start with a number or contain any spaces or full stops (full stops are used in
PML2 to indicate methods and members – explained later)
AVEVA uses a CD prefix on most of its global variables. Newer functionality does not use a prefix so
all new PML must be checked for name clashes. Using your own prefix could help avoid this.
a
example, to a local variable as a factory object:
24 dr
!newPlant = object FACTORY()
2/ ahin
After being declared as above (using the OBJECT keyword and ending with a double bracket, the local
variable !newPlant is now a FACTORY object and has the same members as the FACTORY object. These
29 . M
members are available to store information and can be assigned values in the following way:
!newPlant.name = |ProcessA|
te: ech
!newPlant.workers = 451
!newPlant.output = 2000
/0
Da r: T
Notice the use of a dot between the variable and its member. This works as long as the word after the
dot is a valid member of the variable object-type.
me
Once assigned a value, this value is available for use and can be recalled. For example:
sto
!numberOfWorkers = !newPlant.workers
This creates a new local real variable and assigns it the value 451
Cu
!!CE - a global DBREF object which tracks and represents the current element
!!ERROR - a global ERROR object which holds information about the last error
!!PML - used to obtain file path strings through the .getPathName() method
!!ALERT - used to provide popup feedback to users
!!AIDNUMBERS - used to manage aid graphics
!!APPDESMAIN - the form which represents the main DESIGN interface
www.aveva.com
© Copyright 1974 to current year. 13
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Plant (12.1)
Programmable Macro Language: Appied - TM-1403
A function and a method are written in the same style, the only difference is where the definition is stored
and how it is called. A function is a global method (stored in its own file) and can be called directly on the
command line (e.g. call !!exampleFunction() ) while a method is local to the object it is defined within (e.g.
!exampleObject.exampleMethod() )
Arguments become local variables within the function/method and the object-types need to be declared
within the definition. The returned object-type is also defined. For example:
a
In this example, the function !!area is expecting two real arguments. The two arguments are expressed as
24 dr
local variables which are multiplied together to calculate the local variable !area. Using the return keyword,
the variable !area is then returned. If the function was called in following way, the variable !area will have a
value of 2400:
When defining an argument within a method or function, you may declare it as an ANY object. This means
Da r: T
that the argument can be of any object-type, allowing any variable to be supplied to the function. As no
argument check is carried out, the function needs to be robust enough to cope with any argument. For this
reason, ANY should be used with special consideration:
me
return !type
endfunction
Cu
www.aveva.com
© Copyright 1974 to current year. 14
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Plant (12.1)
Programmable Macro Language: Appied - TM-1403
The above example is the definition of a form called nameCE. Saved within one file (.pmlfrm), it defines two
form members (a predefined member for the title and a new button gadget) and a form method.
a
24 dr
!this is a special local variable and using it replaces the need to reference the owning object directly. For
example, to call the method .print() from within the form, the call is !this.print() and to call the method from
anywhere else, it‟s !!nameCE.print()
2/ ahin
29 . M
te: ech
/0
Da r: T
me
sto
Cu
www.aveva.com
© Copyright 1974 to current year. 15
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Plant (12.1)
Programmable Macro Language: Appied - TM-1403
set PDMSUI=C:\AVEVA\Plant\PDMS12.1.1\pdmsui
The purpose of an environment variable is to reduce the length of the command used to call a macro. This
means that $M/%PDMSUI%\DES\PIPE\MPIPE can be typed instead of the full file path.
In standard product, this process is shortened further as all PML1 macros and forms are called using
synonyms. For example, the macros associated with piping are called using the synonym CALLP:
$S CALLP=$M/%PDMSUI%/DES/PIPE/$s1
CALLP MPIPE
If all synonyms are killed then PDMS will cease to function as normal
a
2.7 PMLLIB environment variable
24 dr
All PML 2 objects and functions are in a directory structure pointed at by the PDMS environment variable
2/ ahin
PMLLIB. As with the PDMSUI variable, this is set in the .bat file which runs PDMS. To set the environment
variable, the following line is needed in the .bat file:
set PMLLIB=C:\AVEVA\Plant\PDMS12.1.1\pmllib
29 . M
The PMLLIB environment variable differs because it can be searched dynamically. This means that the
individual files do not need to be referenced directly and can be called by name. This is possible because
te: ech
PDMS compiles a pml.index file which sits in the PMLLIB folder and provides the path to all suitable files
/0
within it. For example, to load and show a form the command is show !!exampleForm, there is no need to
reference the file path at all.
Da r: T
If a new file is created or the PMLLIB variable is changed then there is a need to update the pml.index file.
This can be done by typing PML REHASH onto the command window. If there are multiple paths that need
me
If a PML object has already been loaded into PDMS, but the file definition has changed then the object
sto
needs to be killed and reloaded before the changes can be seen. This can be done by typing either pml
reload form !!exampleForm or pml reload object EXAMPLEOBJECT
Cu
Although not necessary, it is good practice to organise the files below the PMLLIB folder. A standard PDMS
installation organises the files based on application and then on forms, functions, objects. This is normally a
good starting point for organising customisation.
www.aveva.com
© Copyright 1974 to current year. 16
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Plant (12.1)
Programmable Macro Language: Appied - TM-1403
It keeps the customisation separate from the standard install, so as subsequent versions are
installed there will not be a need to move the customised files.
If any standard files are modified then the originals are still available if required
If the customisation fails, the standard installation is available to go back to
Many local PDMS installations can reference the same customisation from a network address
Any changes to AVEVA standard product may cause PDMS to function inappropriately
It is possible to get PDMS to look in different places for PML and this is done by setting the environment
variables to multiple paths. This allows the standard install to be kept separate from user and company
customisation. This is done by updating the variable to include another path, for example:
a
set PMLLIB=C:\temp\pmllib %pmllib%
24 dr
This will put the additional file path in front of the standard (which would have already been defined in the
2/ ahin
.bat file). This change can also be checked in a PDMS session by typing q evar PDMSUI or q evar PMLLIB
onto the command window.
29 . M
1 Extract the provided files into the folder a suitable folder, for example C:\temp\
/0
Right –click on the icon that opens PDMS. Choose Open File Location
Da r: T
me
sto
Save the .bat as a new file to the computers desktop. This is now the icon you
will use to enter PDMS.
4 Confirm that the search paths have been correctly updated by typing q evar PDMSUI or q
evar PMLLIB into the command window.
www.aveva.com
© Copyright 1974 to current year. 17
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Plant (12.1)
Programmable Macro Language: Appied - TM-1403
a
24 dr
2/ ahin
29 . M
te: ech
/0
Da r: T
me
sto
Cu
www.aveva.com
© Copyright 1974 to current year. 18
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
CHAPTER 3
Object Members – the properties of the object, used to hold its definition
Object Methods – the actions available on the object
An object can be used to represent anything; consider the computer being used to complete this training
guide:
a
24 dr
Processor speed Turn the computer on
2/ ahin
Size of HDD Moving the mouse
Name of manufacturer Typing on the keyboard
List of perphirals Format disk
29 . M
PML objects are available across PDMS to standardise code. These objects include:
/0
To investigate these objects, type the following into the command window:
q var !!gphdrawlists.attributes()
q var !!gphdrawlists.methods()
These objects are defined by a .pmlobj file, stored within the %PMLLIB% environment variable. Browse to
find the files and look through their definition.
PML files can be located by passing the name of the object to the PMLDEFINITION function e.g.
www.aveva.com
!!pmldefinition(|gphline|)
19
© Copyright 1974 to current year.
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Plant (12.1)
Programmable Macro Language: Appied - TM-1403
PML objects can also be used to used to solve complex problems by representing actual objects in the real
world. Consider how a complex problem, such as particle motion could be solved by modelled wach particle
as an object.
As an example, consider the packet of information which is used to configure a graphical pick within PDMS.
Event Driven Graphics (EDG) are controlled by an EDGPACKET object, defining the required pick. The
detail of the EDGPACKET object is fully defined by a series of PML objects, each used to control and
configure different parts of the pick.
a
24 dr
2/ ahin
29 . M
te: ech
/0
Da r: T
me
sto
Cu
To investigate the object structure, type the following into the command window:
q var !packet.pickpacket
q var !packet.pickpacket.methods()
www.aveva.com
© Copyright 1974 to current year. 20
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Plant (12.1)
Programmable Macro Language: Appied - TM-1403
Model – the stored data or data model that will be interacted with by the user interface
View – provides the data stored in the model and passes it the interaction with the presenter
Presenter – receives data and displays data in the model and displays it in the view.
This technique is widely used in .NET languages when designing a user interface, allowing code to more
flexible and easier to maintain. It also means the model and view can be tested separately.
Consider the following arrangement. It is a PML application of MVP principle, allowing a user to modify a
PDMS element via a PML object:
a
24 dr
2/ ahin
29 . M
PDMS PML Form PML Object PDMS
User Database
te: ech
In this arrangement, the PDMS user interacts with the form to enter the required changes. The form
/0
methods supply the entered information to the PML object, which processes the information and updates the
PDMS element. Once updated, the new information is held by the object and sent back to the form to be
Da r: T
It allows the PML object to be created and tested separately from the PML form. It also means that the PML
object can be designed to work with muiltiple forms.
sto
www.aveva.com
© Copyright 1974 to current year. 21
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Plant (12.1)
Programmable Macro Language: Appied - TM-1403
2. The form performs the element collection within the form methods. An element collection is a generic
operation that could be used by multiple forms. Lets move the collection code to a separate object.
Create a new PML object file called elementcollection.pmlobj and add the following definition:
Save the file and type PML REHASH ALL into the command window to make the object available
3. Move the .collect() method from the form to the object and update it to refer to the object members.
For example,
a
!this.elementTypes.val becomes !this.elementTypes
24 dr
2/ ahin
Notice how the object member types are specific
Update the method so that it returns an array of the collected elements and also stores them as part of
the object. Remove the !this.fillGrid() call.
29 . M
!elementCollection.elementTypes[1] = |EQUI|
!elementCollection.scope = !!ce
Da r: T
q var !elementCollection.collect()
me
4. Add an ELEMENTCOLLECTION object to the form as a form member and call it .collection
sto
Add the following callbacks to the three textboxes on the PML form:
Cu
!this.collect.callback = |!this.fillGrid()|
Update the .fillGrid() method to call the collect method on the ELEMENTCOLLECTION object by
including the following:
!this.elements = !this.collection.collect()
5. Test the form with a range of collections and filters. How does the form react? How can the methods
be made more robust to prevent any errors?
www.aveva.com
© Copyright 1974 to current year. 22
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Plant (12.1)
Programmable Macro Language: Appied - TM-1403
If a user works with the same form regularly, they may wish for the form to remember the last values they
entered. Within the same PDMS session, this is already taken care of (as long as the form isn‟t reloaded),
but not between sessions.
To give forms the ability to remember values, develop a PML object called FORMVALUESTORE
.form is FORM
.gadgets is ARRAY
.values is ARRAY
.file is FILE
.formValueStore(!form is FORM)
.saveValues()
a
.loadValues()
24 dr
The constructor method receives an instance of the form so it knows which form to read from and load to.
2/ ahin
The .saveValues() method needs to do the following:
Loop through the members of the form and look for gadgets.
29 . M
Save the form name, gadget names and values to a settings file (using %PDMSUSER%)
/0
Loop through the stored information and place it into the form
Consider when the form should call the methods on the object? Would it be when it is loaded or unloaded?
sto
Shown or hidden?
Cu
.saveValues()
.loadValues()
www.aveva.com
© Copyright 1974 to current year. 23
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Plant (12.1)
Programmable Macro Language: Appied - TM-1403
a
24 dr
2/ ahin
29 . M
te: ech
/0
Da r: T
me
sto
Cu
www.aveva.com
© Copyright 1974 to current year. 24
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
CHAPTER 5
4 User Feedback
Anything which provides the users with information about an action they have just completed can be classed
as feedback. This might include:
a
Consider the following situation; feedback reinforces and enhances the use of a PML form. The more
24 dr
feedback provided, the more likely the form will be used correctly and successfully.
2/ ahin Required
29 . M
outcome
te: ech
PDMS
User
/0
Feedback
Da r: T
Working with PDMS, you will encounter feedback across the product. The following are some typical
examples taken from across the product set:
sto
The form locates the position using a set of axis and draws the volume of the current element. This aid
graphic information updates to show a preview of where the element will move to if Apply is clicked. This
feedback allows users to visually confirm the move, before committing to it.
A list allows PDMS elements to be grouped so they can be used together. On the form there is a “Highlight”
toggle which highlights the collected elements. This means the user can understand what is contained
within the list before using it.
a
In Paragon, Modify>Part Family…
24 dr
2/ ahin
29 . M
te: ech
/0
Da r: T
me
sto
Cu
A GPART element in the catalogue acts as a pointer element, linking the catalogue or template item to the
specification. The form uses a local 3D view to preview of the item being referenced by the GPART. This
means the user doesn‟t have to rely on the name of the item to understand what it is.
For example, to create an aid line between two points with a PML command:
When an aid graphic is created it can be assigned a number. This helps identify it, allowing it to be altered
or removed. For example, to create an number dashed aid line with a PML command:
To remove the numbered line aid graphics, the following command can be used:
Using this command will remove all aid graphics from the screen. If any aid graphics are being used be
another form, these will also be removed
For more information about the available commands and associated syntax graphcs, refer to the
Design Reference Manual : General Commands
a
To create a line aid graphic using a PML object, use the following
24 dr
!poss = object POSITION(|E 0 N 0 U 0 WRT /*|)
2/ ahin
!pose = object POSITION(|E 1000 N 0 U 0 WRT /*|)
!line = !poss.line(!pose)
!line.draw(100, 1, 1)
29 . M
The three REAL arguments to the .draw() method on a LINE object are:
te: ech
1 = solid
2 = dashed
Da r: T
3 = dotted
4 = chained
me
Once drawn, the aid graphic can be used with the PML command AID CLEAR LINE 100
sto
Other geometric PML objects have a .draw() method. Refer to the Software Customisation Reference
Cu
For example, to add colour to an element with a PML command, type the following:
ENHANCE CE COL 10
Where CE is a selection (i.e. current element) and 10 is the required colour (i.e. white)
Once an element has been highlighted, the colour can be removed, type the following:
UNENHANCE CE
UNENHANCE ALL
Running this command will remove all highlight, even if not created by the PML
To highlight an element using PML objects, there are methods available on the global drawlist object, use
the following:
Notice how a colour object can be used to work out what number a colour has.
If more drawlists are created and registered with the global drawlist object, they will be available for use. In
this case, the first drawlist is the drawlist to the main 3D view.
!!gphdrawlists.drawlists[1].unhighlight(!!ce)
a
24 dr
If an element is highlighted by PML, it is a good idea to store the element reference. This will make it
Feedback on a form can guide a user through the functionality. Rather than showing an alert box to instruct
the user of an issue, controlling active gadgets or displaying messages on a form may support the the
te: ech
workflow better.
/0
Da r: T
me
sto
Cu
2. Consider what parts of the workflow are important to ensure the form does not error. Lets add a method
that checks if the collection criteria has been provided.
Add a method to the form called .checkCriteria() and set it as the callback on the three criteria
text boxes. Move the current callbacks to the .fillGrid() method. Also add it to the form initialisation
callback.
www.aveva.com
© Copyright 1974 to current year. 28
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Plant (12.1)
Programmable Macro Language: Appied - TM-1403
3. The first check to make it that at least one of the text box has a value set. Update the method:
if !this.types.val.eq(||).and(!this.filter.val.eq(||)).and(!this.scope.val.eq(||)) then
!this.collect.active = FALSE
!this.message.val = |Please enter some collection criteria|
return
endif
endmethod
This method deactivates the Collect Elements button if no value has been entered and provides
feedback. Show the form and test the feedback.
4. Another check might be to confirm that the entered criteria is valid. For example, has the user entered
valid element types. Add the following code to the end of the .checkCriteria() method:
!errors = ||
a
do !type values !this.types.val.split()
!elementType = object ELEMENTTYPE(!type)
24 dr
!owners = !elementType.parentTypes()
if !owners.unset() then
2/ ahin
!errors = !errors & | | & !type
endif
enddo
if !errors.length().gt(0) then
29 . M
!this.collect.active = FALSE
!this.message.val = !errors & | - not valid element types|
return
endif
te: ech
/0
Notice how the ELEMENTTYPE object is used to check if an element is valid. The method builds a
string of the invalid element types and display s them to the user.
Da r: T
me
5. Test the form further and consider how the method can be extended to check the filter and scopes are
valid. What other messages could be given to the user (e.g. if no elements are found)?
sto
Cu
www.aveva.com
© Copyright 1974 to current year. 29
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Plant (12.1)
Programmable Macro Language: Appied - TM-1403
When elements are collected the list displays the names. To demonstrate these elements to the user, add a
method to the form that highlights collected elements in th drawlist.
The elements in the main drawlist can be obtained with the following:
!members = !!gphdrawlists.drawlists[1].members()
Add an ARRAY member to the form to store the elements that are highlighted
Before highlighting any elements, the method should check if any elements have been previously
highlighted and unhighlight them.
This method can be extended by also labelling the highlighted elements with the name.
Test the form and method to ensure the highlighting works correctly.
a
24 dr
Remember, if a form is closed it should remove any highlights it has made
2/ ahin
29 . M
te: ech
/0
Da r: T
me
sto
Cu
www.aveva.com
© Copyright 1974 to current year. 30
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
CHAPTER 5
At the beginning any new PML development, it is important to understand the reasons and requirements
behind it. The functionality will ultimately be for a specific user to aid their use of PDMS. Identifying the user
and their requirements first will help steer the development, ensuring it addresses the original need.
Who?
Who is the ultimate user of the development and whose requirements are being addressed?
What?
a
What are the requirements of the end user and what will they expect the new functionality to
24 dr
provide? Ultimately, what are they trying to achieve?
Why
2/ ahin
Why is the functionality needed? What benefits will it bring? Identifying this information will help
define the solution and will help create the test case scenario.
29 . M
The final user of the functionality is the most important person. This should be considered at every
stage of the development. Their involvement is important to ensure a successful development.
te: ech
1) Address the Who, What and Why of the proposed new development.
2) Document this information and supply it to the final user for comment. Make the user aware of what
me
functionality will be provided and how this functionality addresses their requirements.
3) Begin to develop a solution by making some initial decisions.
sto
a. Is a form required?
i. If a form is required, what will it display?
Cu
Getting the user to feed into the development process helps guide it and keeps it focussed on their
requirements. Visual mock-ups and test environments allow the user to experience what will be delivered
and should prevent any user-issues at the end. Instead of trying to guess what a user wants, get them
involved and incorporate their feedback.
www.aveva.com
31
© Copyright 1974 to current year.
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Plant (12.1)
Programmable Macro Language: Appied - TM-1403
The temptation might be to jump straight into writing PML, but a good sketch is quicker to produce and can
say more than writing a functionality specification.
As an example, there is a requirement to give a user the ability to look at the history of an element. Rather
than guessing what functionality is needed, the following quick sketch can start the discussion.
a
24 dr
2/ ahin
29 . M
te: ech
/0
Da r: T
me
sto
There are certain aspects of functionality that users may expect from the development, but may not explicitly
ask for. This expectation will be based on their experience with other programs, even standard Windows.
Not all of the following points will be relevant for every development, but it is worth considering them.
Lock/Fix/ Search/Locate
Protect Work information
Output Information Work Graphically
(automatically)
Reference data
and information
What do users always
Query/Report want to do? Modify
(Dynamically)
Share/Collaborate Clear/Delete
www.aveva.com
© Copyright 1974 to current year. 32
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Plant (12.1)
Programmable Macro Language: Appied - TM-1403
Although by definition a subjective topic, there are some aspects to form design that are always the case
and should be considered when developing any interface:
a
24 dr
2/ ahin
29 . M
te: ech
/0
Although a context menu will save space on a form, how many users would know to look for it? By moving
Da r: T
this menu onto the form, the functionality is obvious and is clearly available to the users.
Some parts of the forms may need to be complex, but this should be kept to a minimum and assistance
me
sto
The aim should be that a user will be able to use the basic form unctionality without guidance
There are many different ways to develop an interface. Different combinations of gadgets and feedback can
be used to achieve the same results.
For example, if the user has to make a choice from a set number of options this could be done with a list,
option or combo gadget. It could also be achived with toggles or radio toggles (within a frame).
The choice in gadget should reflect the user expectation and the required outcome. For a short list of fixed
choices consider using radio toggles. For longer variable lists, consider using list or combo gadget.
A combo gadget is good for long lists as a search mechanism could be written within its open callback.
The choice of which gadgets to use will be a trade-off between the desired user experience and the
programming effort to achieve it.
www.aveva.com
© Copyright 1974 to current year. 33
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Plant (12.1)
Programmable Macro Language: Appied - TM-1403
Consider the above three forms. They all provide the same set of multiple choices, but in different ways. As
the toggles are defined during form definition, the number is fixed in the first form, while the choices on the
others can be extended. However, the code required for the first two is considerably less than the third.
a
Which provides the greater user experience?
24 dr
5.5.3 Can the form be resized and have gadgets been anchored?
2/ ahin
If a form is designed to display information to the user then the available space should be considered. Is the
form big enough to display all the possible information? A resizeable form gives users the ability to resize a
form to suit its contents. However, allowing a form it resize is only half of the consideration:
29 . M
te: ech
/0
Da r: T
me
sto
Cu
If a form can be resized then how the gadgets are docked or anchored needs to be considered. A docked or
anchored gadget will resize or move with the resized form. This means that the above list would resize
making all the information visible.
www.aveva.com
© Copyright 1974 to current year. 34
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Plant (12.1)
Programmable Macro Language: Appied - TM-1403
Progressive – secondary or additional functionality (i.e. settings) are stored on additional forms or
panels on the form. These are usually accessed by buttons from the main form.
Staged – a “wizard-style” approach to progression through a form. The user is only presented with
functionality as it is required, effectively stepping them through a process. This can be achieved by
controlling the visibility of gadgets on the form, or by sequentially stepping through a series of forms.
For an example of progressive disclosure refer to the “Graphics Settings” form (from Settings>Graphics…
within PDMS Design). Options are available within the tabs, with the more advanced options found on
secondary forms (e.g. “Advanced…” under the Representation tab)
a
24 dr
2/ ahin
29 . M
te: ech
/0
Da r: T
me
sto
For an example of staged disclosure refer to the “Create DEPT” form (from Create>Department… in within
PDMS Draft). A series of forms are shown in sequence allowing the user to create a Draft hierarchy down to
VIEW level. At any time the user can break the process, or use progressive disclosure to update attributes.
Cu
Although not applicable in every development, disclosure allows the user to be guided through a form. If the
functionality has a sequence of predefined steps or a set of advanced settings, consider disclosure to tidy up
the interface.
5.5.5 How many mouse clicks are required to use the form?
If a user has to make too many choices or interact with lots of form gadgets, this can interrupt the workflow
and reduce the user experience.
www.aveva.com
© Copyright 1974 to current year. 35
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Plant (12.1)
Programmable Macro Language: Appied - TM-1403
Consider a form that has many options the user can choose. The user cannot progress with the form until
they have worked through each option.
Does the user need to make every choice? A set of default values would allow the user to proceed straight
away, or update the choices if required. This could be taken further by writing the users choices to file
during the close event so they are available for next session.
a
become annoying and disrupt the workflow.
24 dr
Consider the action of exiting PDMS. If work has not been saved it is appropriate to prompt the user asking
if they wish to save their work.
2/ ahin
29 . M
te: ech
/0
Da r: T
Alert boxes are useful if you want to disrupt the workflow of the form, but consider whether there are better
me
ways of addressing the issue. For example, consider the following form. If the user has not made a choice,
they receive a message telling to do so.
sto
Cu
A more appropriate approach could be to prevent the Apply button from being clicked before a choice has
been made. Additional feedback on the form would be necessary to direct the user.
www.aveva.com
© Copyright 1974 to current year. 36
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Plant (12.1)
Programmable Macro Language: Appied - TM-1403
It can be tempting to try a make an alert box fit the question that the user needs to answer. A better solution
would be to use a developed child form specifically for the question. This will avoid the classic “click Yes for
Up” and give more control over its appearance and functionality.
The flow through a form could be assisted with the use of titles and “steps”. Coupled with the staged
a
activation of gadgets, the users can be led through the for.
24 dr
2/ ahin
29 . M
te: ech
/0
Da r: T
me
sto
While a form is being used, the most relevant information should always be available to the user. This could
include an appropriate tooltip on a pixmap gadget or highlighting and tagging elements in the graphical view.
www.aveva.com
© Copyright 1974 to current year. 37
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Plant (12.1)
Programmable Macro Language: Appied - TM-1403
It is good practice that for every assumption made in the code, there should be an appropriate check and
feedback. Do not wait until the “Apply” button is clicked to check the users inputs
a
Within standard PDMS, it is now common to see functionality appear on right docking forms with a “refresh”
24 dr
button at the top and “Tasks” at the bottom.
This will include the style of icons used, the type and location of
/0
The following exercises have been provided as a starting point for some new PML developments. They will
Cu
For each, the who, what and why have already been addressed, along with some additional points to
consider while developing a solution.
If there is a specific development that you would like to address instead of these exercises, please
discuss this will the course tutor.
PDMS Designer
www.aveva.com
© Copyright 1974 to current year. 38
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Plant (12.1)
Programmable Macro Language: Appied - TM-1403
1. Consider the Who, What and Why of the request and develop this as a requirement spec. Identify what
functionality is required to address the problem
2. Develop a wireline sketch to outline your proposed development. Highlight the major pieces of
functionality and add notes to justify what is being provided
a
24 dr
2/ ahin
29 . M
te: ech
/0
Da r: T
4. Finish the development by creating some user documentation to describe its use. How will the
me
PDMS Checker
1. Consider the Who, What and Why of the request and develop this as a requirement spec. Identify what
functionality is required to address the problem
2. Develop a wireline sketch to outline your proposed development. Highlight the major pieces of
functionality and add notes to justify what is being provided
www.aveva.com
© Copyright 1974 to current year. 39
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Plant (12.1)
Programmable Macro Language: Appied - TM-1403
a
24 dr
the used of colour, or icons help.
What sort of checks could be
2/ ahin
supplied as default? For
example:
o If the element is a
29 . M
SCTN, is the SPREF set
o If the element is a
HVAC, are the DESP
te: ech
set
/0
4. Finish the development by creating some user documentation to describe its use. How will the
development be considered a success?
Cu
Project Manager
1. Consider the Who, What and Why of the request and develop this as a requirement spec. Identify what
functionality is required to address the problem
2. Develop a wireline sketch to outline your proposed development. Highlight the major pieces of
www.aveva.com
© Copyright 1974 to current year. 40
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Plant (12.1)
Programmable Macro Language: Appied - TM-1403
a
24 dr
2/ ahin
29 . M
te: ech
/0
Da r: T
me
sto
4. Finish the development by creating some user documentation to describe its use. How will the
development be considered a success?
Cu
www.aveva.com
© Copyright 1974 to current year. 41
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
Appendix A
a
-- Object definition --
----------------------------------------------------------------------------------------------------
24 dr
setup form !!c3ex2 dialog resiz
2/ ahin
-- Load the required .dll for the explorer .NET gadget
import 'GridControl'
handle ANY
-- Handle all errors, incase its already been loaded
endhandle
29 . M
using namespace 'Aveva.Pdms.Presentation'
container .frame NOBOX PMLNETCONTROL 'grid' at xmin ymax anchor all width 30 height 9
exit
----------------------------------------------------------------------------------------------------
-- Default CONSTRUCTOR method - Setup the grid and set the callback on the collect button --
----------------------------------------------------------------------------------------------------
define method .c3ex2()
endmethod
www.aveva.com
42
© Copyright 1974 to current year.
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Plant (12.1)
Programmable Macro Language: Appied - TM-1403
----------------------------------------------------------------------------------------------------
-- Method .collect() - Collect the elements based on the criteria --
----------------------------------------------------------------------------------------------------
define method .collect()
a
24 dr
-- Fill the grid with the collected elements
!this.fillGrid()
2/ ahin
endmethod
----------------------------------------------------------------------------------------------------
-- Method .fillGrid() - Fill the grid with the collected elements --
----------------------------------------------------------------------------------------------------
define method .fillGrid()
29 . M
-- Create headings
/0
!headings = |Name|
-- Get the collected elements as STRING objects (required for the grid)
Da r: T
endmethod
sto
----------------------------------------------------------------------------------------------------
-- Method .setupGrid() - Format the grid as required --
----------------------------------------------------------------------------------------------------
define method .setupGrid()
Cu
!this.grid.columnExcelFilter(FALSE)
!this.grid.setNameColumnImage()
!this.grid.outlookGroupStyle(FALSE)
!this.grid.fixedHeaders(FALSE)
!this.grid.fixedRows(FALSE)
!this.grid.columnSummaries(FALSE)
!this.grid.autoFitColumns()
!this.grid.editableGrid(FALSE)
endmethod
----------------------------------------------------------------------------------------------------
-- End of form !!c3ex2 definition --
----------------------------------------------------------------------------------------------------
-- (c) Copyright 2011 to Current Year AVEVA Solutions Limited --
----------------------------------------------------------------------------------------------------
www.aveva.com
© Copyright 1974 to current year. 43
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Plant (12.1)
Programmable Macro Language: Appied - TM-1403
----------------------------------------------------------------------------------------------------
-- --
-- (c) Copyright 2011 to Current Year AVEVA Solutions Limited --
-- --
-- File: elementCollection.pmlobj --
-- --
-- Description: --
-- An object collect and store PDMS elements --
-- --
-- This object represents a solution to worked example 2 in TM1403 --
-- --
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
-- Object definition --
----------------------------------------------------------------------------------------------------
define object elementcollection
member .elementTypes is ARRAY
member .filter is EXPRESSION
member .scope is DBREF
member .elements is ARRAY
endobject
----------------------------------------------------------------------------------------------------
-- Method .collect() ARRAY - Collect the elements as defined in the object --
a
----------------------------------------------------------------------------------------------------
24 dr
define method .collect() is ARRAY
2/ ahin
if !this.elementTypes.size().eq(0) then
return
endif
if !this.filter.set() then
/0
!collection.filter(!this.filter)
endif
Da r: T
return !this.elements
endmethod
----------------------------------------------------------------------------------------------------
Cu
www.aveva.com
© Copyright 1974 to current year. 44
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Plant (12.1)
Programmable Macro Language: Appied - TM-1403
----------------------------------------------------------------------------------------------------
-- --
-- (c) Copyright 2011 to Current Year AVEVA Solutions Limited --
-- --
-- File: formValueStore.pmlobj --
-- --
-- Description: --
-- An object to save and restore values from a PML form --
-- --
-- This object represents a solution to worked example 2 in TM1403 --
-- --
----------------------------------------------------------------------------------------------------
----------------------------------------------------------------------------------------------------
-- Object definition --
----------------------------------------------------------------------------------------------------
define object FORMVALUESTORE
member .form is FORM
member .gadgets is ARRAY
member .values is ARRAY
member .file is FILE
endobject
----------------------------------------------------------------------------------------------------
-- Default CONSTRUCTOR method - Not used directly --
a
----------------------------------------------------------------------------------------------------
24 dr
define method .formValueStore()
endmethod
----------------------------------------------------------------------------------------------------
2/ ahin
-- Overloaded CONSTRUCTOR method - Setup the object with a form and populate the information --
----------------------------------------------------------------------------------------------------
define method .formValueStore(!form is FORM)
-- Populate the object with the information and try to populate the form
!this.loadValues()
me
endmethod
----------------------------------------------------------------------------------------------------
-- Method .saveValues() - Save the values to the object and the settings file --
sto
----------------------------------------------------------------------------------------------------
define method .saveValues()
!this.values.clear()
endmethod
--(Continue on the next page)
www.aveva.com
© Copyright 1974 to current year. 45
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Plant (12.1)
Programmable Macro Language: Appied - TM-1403
----------------------------------------------------------------------------------------------------
-- Method .loadValues() - load the values from the settings file to the form and object --
----------------------------------------------------------------------------------------------------
define method .loadValues()
endmethod
----------------------------------------------------------------------------------------------------
-- End of object FORMVALUESTORE definition --
a
----------------------------------------------------------------------------------------------------
24 dr
-- (c) Copyright 2011 to Current Year AVEVA Solutions Limited --
----------------------------------------------------------------------------------------------------
2/ ahin
29 . M
te: ech
/0
Da r: T
me
sto
Cu
www.aveva.com
© Copyright 1974 to current year. 46
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Plant (12.1)
Programmable Macro Language: Appied - TM-1403
!this.initCall = |!this.checkCriteria()|
!this.types.callback = |!this.checkCriteria()|
!this.filter.callback = |!this.checkCriteria()|
!this.scope.callback = |!this.checkCriteria()|
!this.collect.active = TRUE
!this.message.val = ||
if !this.types.val.eq(||).and(!this.filter.val.eq(||)).and(!this.scope.val.eq(||)) then
!this.collect.active = FALSE
!this.message.val = |Please enter some collection criteria|
a
return
24 dr
endif
!errors = ||
2/ ahin
do !type values !this.types.val.split()
!elementType = object ELEMENTTYPE(!type)
!owners = !elementType.parentTypes()
if !owners.unset() then
!errors = !errors & | | & !type
29 . M
endif
enddo
if !errors.length().gt(0) then
te: ech
!this.collect.active = FALSE
!this.message.val = !errors & | - not valid element types|
/0
return
endif
Da r: T
endmethod
me
sto
Cu
www.aveva.com
© Copyright 1974 to current year. 47
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Plant (12.1)
Programmable Macro Language: Appied - TM-1403
!this.quitCall = |!this.tidy()|
member .highlighted is ARRAY
!this.highlightElements()
a
24 dr
endmethod
!this.tidy()
!name = !element.name
te: ech
!pos = !element.position
handle ANY
/0
!pos = !element.hpos
handle ANY
Da r: T
enddo
sto
endmethod
Cu
www.aveva.com
© Copyright 1974 to current year. 48
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Plant (12.1)
Programmable Macro Language: Appied - TM-1403
a
track |DESICE| call |!this.track()|
24 dr
-- Set the standard icon size
!pix = |pixmap wid 16 hei 16|
limits auto
isometric 3
exit
exit
me
toggle .addConn |Add Connected Elements| tagwid 20 at xmin ymax-0.1 anchor b+l+r
toggle .clip |Clipbox| tagwidth 5 at xmin.trackCE ymax-0.1 anchor b+l
exit
----------------------------------------------------------------------------------------------------
-- CONSTRUCTOR Method - Set up the form and gadgets --
----------------------------------------------------------------------------------------------------
define method .elementPreviewer()
!this.axis.val = TRUE
!this.trackce.val = TRUE
!this.message.visible = FALSE
!this.messageIcon.visible = FALSE
!dtext[1] = ||
!dtext[2] = |Clear|
!this.searchBox.dtext = !dtext
endmethod
----------------------------------------------------------------------------------------------------
-- First Shown Method - Register the view gadget and attach the drawlist --
----------------------------------------------------------------------------------------------------
define method .firstShown()
-- Add 3D view to view system
!!gphViews.add(!this.volumeView)
-- Add local drawlist add to 3D view
!!gphDrawlists.attachView(!this.drawlist, !this.volumeView)
a
endmethod
24 dr
----------------------------------------------------------------------------------------------------
-- Initialisation Method - Update the drawlist and active the view --
----------------------------------------------------------------------------------------------------
2/ ahin
define method .init()
-- Active the volume view
!this.volumeView.active = TRUE
-- Turn on holes drawn
!!gphDrawlists.drawlists[!this.drawlist].holes(TRUE)
29 . M
!this.setDrawList(!!ce)
endmethod
----------------------------------------------------------------------------------------------------
te: ech
endmethod
----------------------------------------------------------------------------------------------------
-- Method .track() - If we are tracking the current element, refresh the drawlist --
me
----------------------------------------------------------------------------------------------------
define method .track()
if !this.trackCe.val then
!this.setDrawlist(!!ce)
sto
endif
endmethod
----------------------------------------------------------------------------------------------------
-- Method .setDrawlist(DBREF) - Display the supplied element in the View --
Cu
----------------------------------------------------------------------------------------------------
define method .setDrawlist(!element is DBREF)
-- Add the required element to the drawlist, and update the title
!drawlist.add(!element)
!this.title.val = |Element: | & !element.flnn
-- Continues p.t.o
www.aveva.com
© Copyright 1974 to current year. 50
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Plant (12.1)
Programmable Macro Language: Appied - TM-1403
-- Loop through the collected elements and add the connected to the drawlist
do !conn values !collection.results()
!drawlist.add(!conn.attribute(|cref|))
enddo
else
endif
a
-- Refresh the limits of the view
24 dr
!this.limitsCE()
endmethod
2/ ahin
----------------------------------------------------------------------------------------------------
-- Method .limitsCE() - Refresh the limits of the view to the stored element --
----------------------------------------------------------------------------------------------------
define method .limitsCE()
-- Refresh the limits of the view to ensure the element can be seen
29 . M
!!gphViews.limits(!this.volumeView, !this.element)
!this.limits = !this.volumeView.limits
endmethod
te: ech
----------------------------------------------------------------------------------------------------
-- Method .walkDrawlist() - Walk to the elements in the drawlist --
/0
----------------------------------------------------------------------------------------------------
define method .walkDrawlist()
-- Get the drawlist associated with the view
Da r: T
!drawlist = !!gphDrawlists.drawlist(!this.drawlist)
-- Derive a volume object from the members of the drawlist
!volume = object VOLUME(!drawlist.members())
me
!limits[4] = !volume.to.north
!limits[5] = !volume.from.up
!limits[6] = !volume.to.up
-- Apply the limits to the volume view
Cu
!this.volumeView.limits = !limits
handle ANY
-- Incase the drawlist is empty or has no volume
endhandle
endmethod
----------------------------------------------------------------------------------------------------
-- Method .addConnected() - Update the form based on the add connected toggle --
----------------------------------------------------------------------------------------------------
define method .addConnected()
-- If adding connected, activate the clip toggle (and maybe the slider)
!this.clip.active = !this.addConn.val
!this.slider.active = !this.addConn.val.and(!this.clip.val)
a
-- Method .search() - Open callback from the combo gadget --
24 dr
----------------------------------------------------------------------------------------------------
define method .search(!gadget is GADGET, !string is STRING)
2/ ahin
-- If the user has typed in...
if !string.eq(|VALIDATE|) then
!elementCheck = !suppliedName.dbref()
handle ANY
-- Any problem, show the error message
te: ech
!this.message.visible = TRUE
!this.messageIcon.visible = TRUE
/0
!this.message.val = !!error.text
elsehandle NONE
-- If no problems, add the element name as second in the list and update the view
Da r: T
!dtext = !gadget.dtext
!dtext.insert(2, !suppliedName)
!gadget.dtext = !dtext
me
!this.setDrawlist(!elementCheck)
!gadget.val = 1
-- Ensure the error message is not visible
!this.message.visible = FALSE
sto
!this.messageIcon.visible = FALSE
endhandle
if !gadget.val.eq(1) then
-- If they picked the first one, do nothing (its blank)
elseif !gadget.val.eq(!gadget.dtext.size()) then
-- If they choose the last one, clear the list
!dtext[1] = ||
!dtext[2] = |Clear|
!gadget.dtext = !dtext
!gadget.val = 1
else
-- Otherwise, update the form with the chosen element
!elementName = !gadget.dtext[!gadget.val]
!this.setDrawlist(!elementName.dbref())
!gadget.val = 1
endif
endif
endmethod
----------------------------------------------------------------------------------------------------
-- Method .setUpClipBox() - Update the size of the clip box based on the stored element --
----------------------------------------------------------------------------------------------------
define method .setUpClipBox()
www.aveva.com
© Copyright 1974 to current year. 52
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Plant (12.1)
Programmable Macro Language: Appied - TM-1403
!this.clipbox.active = FALSE
!this.clipbox.set()
!this.clipbox.active = TRUE
!this.volumeView.clipping = TRUE
!this.slide()
endmethod
----------------------------------------------------------------------------------------------------
-- Method .clipBox() - Active and refresh the clip box slider --
----------------------------------------------------------------------------------------------------
define method .clipBox()
!this.slider.active = !this.clip.val
if !this.clip.val then
!this.setUpClipBox()
else
!this.clipbox.active = FALSE
!this.volumeView.clipping = FALSE
endif
endmethod
----------------------------------------------------------------------------------------------------
-- Method .setIcons() - Update the icons on the pixmap gadgets --
----------------------------------------------------------------------------------------------------
define method .setIcons()
!this.limitsCe .addPixmap(!!pml.getPathName(|autocepopupicon.png|))
!this.walkDrawlist.addPixmap(!!pml.getPathName(|ng_zoomtodrawlist.png|))
!this.axis .addPixmap(!!pml.getPathName(|worldaxes16.png|))
a
!this.searchIcon .addPixmap(!!pml.getPathName(|id_search.png|))
24 dr
!this.messageIcon .addPixmap(!!pml.getPathName(|exclamation-16.png|))
endmethod
----------------------------------------------------------------------------------------------------
2/ ahin
-- Method .setTooltips() - Update the tooltips on the pixmap buttons --
----------------------------------------------------------------------------------------------------
define method .setTooltips()
!this.limitsCe .setTooltip(|Limits CE|)
!this.walkDrawlist.setTooltip(|Walk to drawlist|)
29 . M
!this.clip.callback = |!this.clipBox()|
!this.slider.callback = |!this.slide()|
!this.searchBox.callback = |!this.search(|
endmethod
sto
----------------------------------------------------------------------------------------------------
-- Method .setUpView() - Define the properties of the view and setup the clip box --
----------------------------------------------------------------------------------------------------
define method .setUpView()
Cu
endmethod
----------------------------------------------------------------------------------------------------
-- End of Form definition and methods --
----------------------------------------------------------------------------------------------------
-- (c) Copyright 2011 to Current Year AVEVA Solutions Limited --
----------------------------------------------------------------------------------------------------
www.aveva.com
© Copyright 1974 to current year. 53
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
Appendix B
a
Runs the command “PML REHASH”
24 dr
Runs the command “PML REHASH ALL”
2/ ahin
The available methods of finding available PML forms
The available forms to be reloaded, views or opened
29 . M
Runs the command “PML RELOAD FORM” for the selected form
Runs the command “SHOW” for the selected form
te: ech
This form will display the available colours within the PDMS session.
Dynamically built, it will always be correct for the current session.
www.aveva.com
54
© Copyright 1974 to current year.
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.
AVEVA Plant (12.1)
Programmable Macro Language: Appied - TM-1403
This form will search the chosen PMLLIB search path for .png image
files and display them in the grid control gadget. A preview of the
image will be displayed and it will be possible to gain a larger preview
from the context menu
As the PMLLIB search paths could be large and contain many images,
it is possible to only search specific sub folders. Standard grid control
functionality is also available to help filter the search results.
The purpose of the form is to visualise all the images available in the
PMLLIB search path. As the images are within the search path, these
images are therefore available for use in any customisation.
Depending on the size of teh pml.index file, this form can take a
while to collect and display all the information.
a
24 dr
Appendix B.4 – Training Examples form
2/ ahin
This form will provide quick access to all the training examples supplied
as part of this course. Split into types, each example can be shown
29 . M
inside PDMS or opened in the default Windows Program.
The form builds itself based on the contents of a .xls file saved within
te: ech
As you attend further courses, more of the options across the top will be
available.
www.aveva.com
© Copyright 1974 to current year. 55
AVEVA Solutions Limited and its subsidiaries.
All rights reserved.