esi-phdbridge

A library for communicating with the PHDBridge.

Requirements

A working Installation of PHDBridge is required.

Changes

version date description

1.72.0

2020-12-08

TFS code synchronisation

Dependencies

library version inmation core library

dkjson

2.5.0

yes

socket

3.0.0

yes

esi-variables

1.0.0

yes

Available functions

All functions have to be called according to the ESI standard, using colons, e.g. lib:FUNCTIONNAME(params)

Documentation

SETCONNECTION

SETCONNECTION configures TCP connection settings.

It should be called before any other PHD Bridge function.

Parameters

args

JSON object containing the following connection parameters.

.host

PHD-Bridge hostname, default localhost

.port

PHD-Bridge portnumber, default 6959

.timeout

PHD-Bridge timeout in seconds, default 3

.buffersize

PHD-Bridge TCP buffer size, default 2048

Usage

local lib = require("esi-phdbridge")
local connection = {}
connection.host = "127.0.0.1"
connection.port = 6959
connection.timeout = 3
connection.buffersize = 2048
lib:SETCONNECTION(connection)

GETSTATUS

GETSTATUS returns information about PHD Bridge service.

Returns

  • status["Version"] - version of the PHD Bridge Service.

  • status[".NET Version"] - .NET version of the PHD Bridge Service.

  • status["PhdServerHost"] - configuration of PHD Server host.

  • status["PhdServerPort"] - configuration of PHD Server port.

  • status["BufferSize"] - buffer size used to send data to the client.

  • status["TCPPortClient"] - TCP port used by clients.

  • status["MaxTCPConnectionQueues"] - the maximum length of the pending TCP connections queue.

  • status["TCPEndOfTransmissionSignal"] - client and server are sending this string at the end of the command.

  • status["ServiceName"] - name of the PHD Bridge service.

  • status["ServiceDisplayName"] - display name of the PHD Bridge service.

Usage

local lib = require("esi-phdbridge")
lib:SETCONNECTION({})
local res, err = lib:GETSTATUS()
return (require "esi-string"):STRING({res=res,err=err})

FETCHCURRENTDATA

FETCHCURRENTDATA returns the current data point.

For detailed explanation of all historian parameters see Uniformance PHD .NET wrapper documentation.

Parameters

tagname

Name of the tag.

historian

Settings of the PHDHistorian.

Usage

local lib = require("esi-phdbridge")
local PHDHistorian = {}
PHDHistorian.UTCDateTime = true
lib:SETCONNECTION({})
local result, exception = lib:FETCHCURRENTDATA("FC101.PV", PHDHistorian)
return (require "esi-string"):STRING({res=result,ex=exception})

FETCHDATA

FETCHDATA returns a list of data points.

For detailed explanation of all historian parameters see Uniformance PHD .NET wrapper documentation.

Parameters

tagname

Name of the tag.

historian

Settings of the PHDHistorian.

Usage

local lib = require("esi-phdbridge")
local PHDHistorian = {}
PHDHistorian.StartTime = "NOW-1H"
PHDHistorian.EndTime = "NOW"
lib:SETCONNECTION({})
local result, exception = lib:FETCHDATA("FC101.PV", PHDHistorian)
return (require "esi-string"):STRING({res=result,ex=exception})

FETCHROWDATA

FETCHROWDATA returns a list of data points.

For detailed explanation of all historian parameters see Uniformance PHD .NET wrapper documentation.

Parameters

tagnames

Collection of the tag names.

historian

Settings of the PHDHistorian.

Usage

local lib = require("esi-phdbridge")
local PHDHistorian = {}
PHDHistorian.StartTime = "NOW-1H"
PHDHistorian.EndTime = "NOW"
local tagNames = {}
tagNames[1] = "FC101.PV"
tagNames[2] = "FC102.PV"
lib:SETCONNECTION({})
local result, exception = lib:FETCHROWDATA(tagNames, PHDHistorian)
return (require "esi-string"):STRING({res=result,ex=exception})

TAGDFN

TAGDFN returns tag definitions of the tags collection.

Parameters

tagnames

Collection of the tag names.

Usage

local lib = require("esi-phdbridge")
local tagNames = {}
tagNames[1] = "FC101.PV"
tagNames[2] = "FC102.PV"
lib:SETCONNECTION({})
local result, exception = lib:TAGDFN(tagNames)
return (require "esi-string"):STRING({res=result,ex=exception})

BROWSINGTAGLIST

BROWSINGTAGLIST returns filtered list of tag data.

For detailed explanation see Uniformance PHD .NET wrapper documentation (BrowsingTagsList() method).

Parameters

maxtagcount

Maximum number of tags to be returned.

filter

Tag filter conditions.

Usage

local lib = require("esi-phdbridge")
local filter = {}
filter.DataType = "F"
filter.ScanRate = -1
filter.Collector = nil
filter.ParentTagname = nil
filter.SourceTagname = nil
filter.SourceUnits = nil
filter.Tagname = nil
filter.TagUnits = nil
lib:SETCONNECTION({})
local result, exception = lib:BROWSINGTAGLIST(100, filter)
return (require "esi-string"):STRING({res=result,ex=exception})