Data points and enumerated types – Echelon LNS User Manual

Page 246

Advertising
background image

LNS Programmer's Guide

232

Set MyInterface = MyAppDevice.Interface
Set MyVariables = MyInterface.NetworkVariables
Set MyNV = MyVariables.Item(“Input One”)

3. Use

the

GetDataPoint()

method to create a

DataPoint

object for the

network variable. The

GetDataPoint()

method takes a single input

parameter that must be set to 0.

Set MyDataPoint = MyNV.GetDataPoint(0)

4. To set the value of the network variable through the

DataPoint

object,

set the

Value, RawValue,

or

FormattedValue

properties, and then

call the

Write()

method. You do not need to call

Write()

if the

DataPoint object’s

AutoWrite

property is set to

True

.

MyDataPoint.Value = 1000
MyDataPoint.Write()

5. To read the value of the network variable through the

DataPoint

object,

call the

Read()

method and then read the value via the

Value,

RawValue

or

FormattedValue

properties. You do not need to call

Read()

if the AutoRead property is set to

True

.

MyDataPoint.Read()
Dim Value as String
Value = MyDataPoint.FormattedValue

When reading the value of a

DataPoint

object, there are many ways for

an application to determine how the data will be displayed. For more

information on this, see Data Formatting on page 241. Consult the LNS
Object Server Reference
help file for a complete list of the properties and

methods of the

DataPoint

object.

The type of data that is stored in a network variable is determined by its base type. As of
LNS Turbo Edition, you can modify a network variable’s type by writing to its TypeSpec

property, as long as the network variable is on a device that supports changeable types.

For more information on this, see Changeable Network Variable Types on page 185.

Data Points and Enumerated Types

When reading or writing network variables and configuration properties with
DataPoint objects, you should note that some standard and user-defined types are

defined as enumerated data types in the resource files. A network variable or

configuration property that uses an enumerated type will only accept values that belong
to the enumeration referenced by the type it is using.

For example, the SNVT_defr_term type is based on the "defrost_term_t" enumeration

type. As defined in the standard LonMark resource files, the defrost_term_t enumeration

type contains values between -1 and 100. However, not all the values in this range are
associated with the type’s enumeration members. Values from 9 to 99 are illegal, since

there are no enumeration members associated with them. Each legal value is assigned an

enumeration name. If you have a network variable or configuration property that is
using an enumeration data type, you can only write the enumeration names defined for

that type to the object’s value.

Consider a case where you have acquired a data point for a network variable using the

SNVT_defr_term type. In this situation, you will only be able to write enumeration

Advertising