Using configuration properties, In a monitor and control, Application – Echelon LNS User Manual

Page 247

Advertising
background image

LNS Programmer's Guide

233

names defined for the SNVT_defr_term type, such as DFT_TERM_LAST, to the
FormattedValue property of the DataPoint. You should also note that this is the only
property that enforces range limits (i.e. the Value and RawValue properties do not

enforce these restrictions). You can use the Value property of the DataPoint to obtain

the numeric value associated with the enumerator, as shown in the following code

sample:

Dim MyFormatSpec as LcaFormatSpec

Dim MyDataPoint as LcaDataPoint

Set MyFormatSpec = MyDataPoint.FormatSpec

MyFormatSpec.FormatType = lcaFormatTypeNamed

MyFormatSpec.FormatName = “SNVT_defr_term”

Set MyDataPoint.FormatSpec = MyFormatSpec

MyDataPoint.FormattedValue = DFT_TERM_LAST

After executing the code shown above, the Value property would return 3 - the numeric

value that corresponds to the DFT_TERM_LAST enumeration. Remember that LNS will
not perform range checking on the Value property, and no exception will be thrown if

you try to write an illegal value to the property.

If you write an illegal value to the Value property at this point (i.e. a value that does not

correspond to one of the valid enumeration names for the type) and then read the
FormattedValue property, no exception will be thrown. However, the value will not be

converted to an enumeration name since there is no enumeration associated with the
value. However, if you attempt to write the illegal value to the FormattedValue

property at this point, an exception will be thrown.

You could expand the previous example to retrieve all the valid enumeration names that

can be assigned to a data point by adding the sample code shown below. You will need to
use the MinValue and MaxValue properties to perform this task. These properties

contain the maximum numeric value (i.e. the value stored in the Value property) that

can be applied to the data point. This code checks every value between the data point’s
minimum and maximum values. If the data stored in the Value property does not match

the data stored in the FormattedValue property, it indicates that the FormattedValue

property represents one of the valid enumeration names:
Dim i as Long

For i = MyDataPoint.MinValue To MyDataPoint.MaxValue

MyDataPoint.Value = i

IF MyDataPoint.FormattedValue <> MyDataPoint.Value THEN

cboEnumList.AddItem(MyDataPoint.FormattedValue)

END IF
Next

Using Configuration Properties In a Monitor and Control

Application

This section provides guidelines and instructions to follow when creating an LNS

application to monitor and control configuration property values. Configuration property

access is generally less efficient than network variable access, so for performance

reasons, you should only use LNS to monitor and control the values of configuration

Advertising