Академический Документы
Профессиональный Документы
Культура Документы
Данный справочник предназначен для тех, кто использует системы AVEVA PDMS/Marine в повседневной работе и
хочет узнать систему больше и глубже, а также автоматизировать различные рутинные действия и настроить свой
собственный рабочий процесс.
Это также для начинающих специалистов, кто не знаком с программированием вообще, и для тех, кто уже умеет
выполнять базовые операции. Опытные PML-программисты возможно тоже найдут для себя несколько интересных
моментов
И конечно, этот справочник предназначен для администраторов AVEVA, специалистов, которые обязаны иметь эти
знания, чтобы выполнять свою работу на профессиональном уровне.
Этот справочник не должен быть использован как учебное руководство. Он дает только базовые представления о
том, что такое PML и простейших конструкциях языка. Специалист должен пройти учебный курс AVEVA M33,
посвященный подробному изучению свойств языка PML.
Введение
PML (Programmable Macro Language) или макроязык систем AVEVA PDMS/Marine
является встроенным языком программирования, который:
Выполняет действия, которые пользователь выбирает с помощью интерфейса
системы. Это функции расположены в месте установки системы в папках
PMLLIB и PDMSUI и не должны подвергаться изменению пользователем. К
примеру, когда пользователь нажимает какую-либо кнопку на форме, это
значит, что будет выполнен некий PML код, связанный с этой кнопкой.
Используется в любых пользовательских макросах или функциях, которые
могут быть разработаны любым пользователем с минимальными знаниями
программирования. Пользовательские макросы или функции, как правило
реализуют различные задачи, которые базово не включены в набор функций
системы, то есть своего рода расширение функционала для конкретных
задач. К примеру, пользователь может создать свой собственный интерфейс
в виде набора форм, специальных функций и т.д)
Может автоматизировать практически любые действия, которые повторяются
пользователем из дня в день и занимают время (далее по тексту, такие
макросы будут называться «Быстрый Макрос или БМ)
Любой пользователь может изучить PML, так как при изучении не требуется
профессиональных знаний программирования, а только понимание следующего:
Концепция иерархии базы данных AVEVA - Dabacon
Типизация элементов AVEVA внутри Dabacon
Атрибутивная составляющая элементов AVEVA, зависимости и ссылки
Общая терминология AVEVA и наиболее часто используемые сокращения и
термины (см. Приложение 1)
Существует две версии языка PML – PML 1 и PML2. Не вдаваясь глубоко в детали,
хотим сказать, что в отличии от PML1, PML2 является объектно-ориентированным
языком, то есть общается с элементами модели, как с объектами. В данном
справочнике, будет основной акцент сделан именно на конструкция языка PML2,
учитывая его большую актуальность и тот факт, что основной интерфейс системы
написан именно на PML2. В тоже самое время в справочнике могут встречаться
конструкции, которые принадлежат PML. Такие конструкции будут выделены
отдельно.
By analogy, the variable could be interpreted as a ‘box’ where you put something to or take something
from. And this ‘box’ has a name to clearly identify what is stored inside. And boxes with same type of
content could interact to each other.
Names of variables in PML should start with ‘!’ symbol and have meaningful name.
Examples:
!boxHeight
!boxDescription
!equipName
etc
To assign a value to variable (to put something in a ‘box’) you have to decide what
type of data it will be.
Most used types are:
<STRING> - the value should be put within single quotes or vertical bars, could
not be used in arithmetical expressions unless converted to <REAL>
<REAL> - any integer value, could be used I arithmetical expressions. Could not
be used in string operations unless converted to <STRING>
<DBREF> - this is a special PDMS type pointed to an object in database with all
its attributes
!equipName = /E1201
Here we created variable called !equipName and assign a value /E1201 with no single quotes but with a slash in front,
so it means variable !equipName will have a <DBREF> type
NB. Pointing the slash as a first symbol will automatically give to the system a signal that you try to refer to some item
with this name. So if there is no item with such name then it will be an error.
Now we have three variables of different types. So what can we do with them? Lets
review some arithmetical operations… Like it was said before only variables with type
<REAL> can be involved into these operations. All others should be converted to
<REAL> (if possible) before.
The following example will be used to find a volume (V) of a box with known different
sides (a,b,c)
V = a*b*c
!aSide = 1000
!bSide = 500
!cSide = 300
Now we have to create an arithmetical expression for calculation and result should be
stored in another variable. Normally it could be done like:
!aSide = 1000
!bSide = 500
!cSide = 300
q var !boxVolume
The last command means to query (q) early-defined variable (var) with some name.
Result of querying will be output to PDMS’s command line.
Now try to run this. Open command line and type - $M/path_to_your_file
In my case it will be - $M/C:\temp\pmlexamples\lsaPML1.pmlmac
Alert – is a message popping up on a screen and asking user to interact. In our case we
will use Input dialog. Let see how it works.
Imagine the situation when our volume has 2 constant sides (a,b) and one which could
vary by user input. Then our code will look like:
!aSide = 1000
!bSide = 500
!aSide = 1000
!bSide = 500
!cSide = !!Alert.Input(‘Please input the C-side’,’300’)
q var !boxVolume
Save this code to next macro file and run in PDMS like it was done previously with $M/
Using ‘.’ and some method we can do some operation applying it to variables of
different type. In example we used method .Real() applied to <STRING> variable to
convert it into <REAL>. Full list of methods listed in Software Customisation Reference
Guide
2.IF statements
IF statement is used to let the system compare two values and by the result of
comparison we can select what to do.
Normally values of variables are compared.
<REAL> should be compared with <REAL>, <STRING> with <STRING> etc.
By analogy, remember our ‘variable-box’? Imagine that one ‘box’ contains an apple and other ‘box’
contains a peach. You want to eat an apple but you don’t know which ‘box’ stores it. You have to check.
So you put your arm into one box and IF you find an apple THEN you eat it ELSE (peach) you do nothing.
Now we will compare the value of the input with 2. Not forgetting to convert input to
<REAL>
If (!userVariable.Real() EQ 2) then
!!Alert.Message(‘You have input correct value’)
Else
!!Alert.Message(‘You have input incorrect value. Please put 2’)
RETURN
endif
Here we used IF statement to check if our input variable is EQual to 2. We have used EQ operator to check for equality.
If result of statement is FALSE then we un another message and quir from the program execution by using command
RETURN. We user another type of Alert – Message to output a simple message on a screen)
RETURN
endif
Save this code to next macro file and run in PDMS like it was done previously with $M/
3.DO LOOP
DO LOOP is used to perform actions over multiple (collection) items
Usually collection is an ARRAY variable each cell of which contains some data of
particular type like ARRAY of <STRING>s or ARRAY of <REAL>s.
By analogy, remember our ‘variable-box’? Imagine that this ‘box’ contains 10 apples and we have to check
if all ten are fresh. We can do it by picking them up one by one and do check. DO LOOP is doing the same
– you have a collection and one by one you doing same actions on each item in collection
As a result, you will get 5 messages on a screen. One by one until DO LOOP ends on 5
4.COMBINATIONS
You can now combine IF statement and DO LOOP.
!digitArray[1] = 1
!digitArray[2] = 2
!digitArray[3] = 3
!digitArray[4] = 4
!digitArray[5] = 5
--To get the Size we will introduce another variable for storing this values can use a method called .Size() applied to
earlier defined ARRAY
--Here it is:
!digitArraySize = !digitArray.Size()
Do !x from 1 to !digitArraySize
--To understand if the value is even or odd we have to take value and try to divide by 2
--if result of the division will contain a decimal point then value was odd otherwise it was even
--lets do it
--first make a division (remember in each iteration !x will have a next value) and this is <REAL> type
!resultOfDivision = !x / 2
--check for point. We will use MATCHWILD method which is applied to STRING object to find if there something we’d
like to find
--so we also will be converting result of division stored in previous variable to <STRING> type
!isThereAPoint = !resultOfDivision.String().Matchwild(‘*.*’)
--so previous variable will store TRUE if variable !resultOfDivision contain point and FALSE – if not
Enddo
!digitArraySize = !digitArray.Size()
Do !x from 1 to !digitArraySize
!resultOfDivision = !x / 2
!isThereAPoint = !resultOfDivision.String().Matchwild('*.*')
Enddo
Do !x from 1 to !digitArray.Size()
!resultOfDivision = !x / 2
!isThereAPoint = !resultOfDivision.String().Matchwild('*.*')
If (!resultOfDivision.String().Matchwild('*.*').Not()) THEN
!!Alert.Message('Value is ' + !x.String() + ' and its even.')
Else
SKIP
endif
Enddo
Or even shorter
--put number in a <STRING> then split it and get array
!stringNumber = ‘1 2 3 4 5’
!digitArray = !stringNumber.Split()
Do !x from 1 to !digitArray.Size()
!resultOfDivision = !x / 2
!isThereAPoint = !resultOfDivision.String().Matchwild('*.*')
If (!resultOfDivision.String().Matchwild('*.*').Not()) THEN
!!Alert.Message('Value is ' + !x.String() + ' and its even.')
Else
SKIP
endif
Enddo
TO BE CONTINUED…