Extend PML with .NET

If we faced with situation, when we need some object and there is no such in standard PMLLIB.
We can extend it using .NET Library and PMLNetCallable Aveva Pdms layer.

architecture_overview

As an example we will extend PML with random number generator.
Here is C# Code:

using Aveva.PDMS.PMLNet;
namespace AVEVA.PDMS.NetRandom
{
[PMLNetCallable()]
public class NetRandom
{
private int _decim = 4;
[PMLNetCallable()]
public double Decimals
{
get { return _decim; }
set { _decim = (int)value; }
}
[PMLNetCallable()]
public NetRandom(){}
[PMLNetCallable()]
public void Assign(NetRandom that){}
[PMLNetCallable()]
public double GetRnd()
{
Random rnd = new Random();
return Math.Round(rnd.NextDouble(), (int)Decimals);
}
[PMLNetCallable()]
public double GetRnd(double min, double max)
{
Random rnd = new Random();
return Math.Round((int)min, (int)max);
}
}
}

Compile it as assembly and run such PML code:

import 'netrandom'
handle any
endhandle
using namespace 'Aveva.Pdms.Netrandom'
!x = object netRandom()
q var !x.getrnd()
q var !x.getrnd(10,20)

Written by RUAR

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.