in
Creating Smarter Networks

Creating an 'Analog Fn Block' with VB.NET

Last post 02-03-2010 12:20 PM by jster23. 10 replies.
Page 1 of 1 (11 items)
Sort Posts: Previous Next
  • 01-11-2010 1:56 AM

    • lumatec
    • Top 10 Contributor
    • Joined on 04-29-2008
    • Posts 80
    • Points 1,135

    Creating an 'Analog Fn Block' with VB.NET

    Hello,

    we tried to adapt the example 'Creating a Data Logger' from the 'SmartServer 2.0 Programmer's Reference', in order to create an 'Analog Function Block'. But something is going wrong with the output data point.

    After creating the 'Analog Fn Block', we can find it in the 'iLON App' tree on the SmartServer's web page. The output data point is there too. But its 'Icon' is set to 'Dp_In_Out' instead of 'Out', and the 'General' view is available, but not the 'Driver' view. So whether the 'General' or 'Driver' is selected, we always see the 'Data Point Property', but never the 'Lon Data Point Property'. (If we add the data point manually on the web page, it works fine.)

    Here's the listing in VB.NET:

    Dim xSelect As New SmartServer.E_xSelect()

    xSelect.xSelect = "//Item[@xsi:type=""LON_Fb_Cfg""][contains(UCPTname,""Analog Fn Block"")][UCPThidden = ""1""]"

    Dim ItemColl As SmartServer.Item_Coll = SmartServer._iLON.List(xSelect)

    ItemColl.xSelect = "//Item[@xsi:type=""LON_Fb_Cfg""]"

    Dim ItemCfgColl__1 As SmartServer.Item_CfgColl = SmartServer._iLON.Get(ItemColl)

    'Create LON_Fb_Cfg item

    ItemCfgColl__1.Item(0).UCPThidden = 0

    ItemCfgColl__1.Item(0).UCPTname = "Net/LON/iLON App/Analog Fn Block[0]_OR"

    Dim ItemColl_SetReturn As SmartServer.Item_Coll = SmartServer._iLON.Set(ItemCfgColl__1)

    'create new Data Logger from existing one

    Dim myAnalogFB As SmartServer.UFPTanalogFunctionBlock_Cfg = New SmartServer.UFPTanalogFunctionBlock_Cfg()

    myAnalogFB.UCPTname = "Net/LON/iLON App/Analog Fn Block[0]_OR"

    myAnalogFB.UCPTannotation = "#8000010128000000[4].UFPTanalogFunctionBlock"

    myAnalogFB.UCPTuri = "8000010128000000[4].UFPTanalogFunctionBlock_Cfg.htm"

    myAnalogFB.UCPTcompFunction = New SmartServer.E_LonString()

    myAnalogFB.UCPTcompFunction.Value = "FN_GE"

    myAnalogFB.UCPTcompFunction.LonFormat = "UCPTcompFunction"

    myAnalogFB.UCPTtrueThreshold = New SmartServer.E_LonString()

    myAnalogFB.UCPTtrueThreshold.Value = "1"

    myAnalogFB.UCPTtrueThreshold.LonFormat = "UNVT_float"

    myAnalogFB.UCPToutputFunction = New SmartServer.E_LonString()

    myAnalogFB.UCPToutputFunction.Value = "FN_OR"

    myAnalogFB.UCPToutputFunction.LonFormat = "UCPToutputFunction"

    myAnalogFB.SCPTminRnge = New SmartServer.E_LonString()

    myAnalogFB.SCPTminRnge.Value = "0"

    myAnalogFB.SCPTminRnge.LonFormat = "UNVT_float"

    myAnalogFB.SCPTmaxRnge = New SmartServer.E_LonString()

    myAnalogFB.SCPTmaxRnge.Value = "0"

    myAnalogFB.SCPTmaxRnge.LonFormat = "UNVT_float"

    myAnalogFB.SCPTovrBehave = New SmartServer.E_LonString()

    myAnalogFB.SCPTovrBehave.Value = "OV_RETAIN"

    myAnalogFB.SCPTovrBehave.LonFormat = "SCPTovrBehave"

    myAnalogFB.UCPTpollOnResetDelay = 0

    myAnalogFB.UCPTcalculationInterval = 0

    myAnalogFB.UCPTmajorityValue = 100

    'create DP reference array containing input and output DPs of new Analog FB

    myAnalogFB.DataPoint = New SmartServer.E_DpRef(2) {}

    'specify Output DP

    Dim dataPointRef1 As New SmartServer.UFPTanalogFunctionBlock_DpRef()

    dataPointRef1.UCPTname = "Net/LON/iLON App/Analog Fn Block[0]_OR/Output"

    dataPointRef1.dpType = "Output"

    dataPointRef1.UCPTpollRate = 0

    dataPointRef1.UCPTpollRateSpecified = True

    dataPointRef1.discrim = SMARTConfigurator.SmartServer.DpRef_eDiscriminator.dir_out

    dataPointRef1.discrimSpecified = True

    'specify Input 1

    Dim dataPointRef2 As New SmartServer.UFPTanalogFunctionBlock_DpRef()

    dataPointRef2.UCPTname = "Net/LON/iLON App/Digital Output 2/nviClaValue_2"

    dataPointRef2.UCPTpollRate = 0

    dataPointRef2.UCPTpollRateSpecified = True

    dataPointRef2.dpType = "Input"

    dataPointRef2.discrim = SMARTConfigurator.SmartServer.DpRef_eDiscriminator.dir_in

    dataPointRef2.discrimSpecified = True

    'specify Input 2

    Dim dataPointRef3 As New SmartServer.UFPTanalogFunctionBlock_DpRef()

    dataPointRef3.UCPTname = "Net/LON/iLON App/Digital Output 1/nviClaValue_1"

    dataPointRef3.UCPTpollRate = 0

    dataPointRef3.UCPTpollRateSpecified = True

    dataPointRef3.dpType = "Input"

    dataPointRef3.discrim = SMARTConfigurator.SmartServer.DpRef_eDiscriminator.dir_in

    dataPointRef3.discrimSpecified = True

    myAnalogFB.DataPoint(0) = dataPointRef1

    myAnalogFB.DataPoint(1) = dataPointRef2

    myAnalogFB.DataPoint(2) = dataPointRef3

    'call Set function

    Dim itemCfgColl__2 As New SmartServer.Item_CfgColl()itemCfgColl__2.Item = New SmartServer.Item_Cfg(0) {}

    itemCfgColl__2.Item(0) = myAnalogFB

    Dim ItemColl_Set_DataLogger_Return As SmartServer.Item_Coll = SmartServer._iLON.Set(itemCfgColl__2)

     

    Can somebody tell us what we may be doing wrong? (Our SmartServer Software Version: 4.02.054)

    Thanks and best regards,

    Daniel

     

    • Post Points: 20
  • 01-12-2010 12:44 PM In reply to

    • jster23
    • Top 10 Contributor
    • Joined on 04-03-2008
    • Posts 38
    • Points 555

    Re: Creating an 'Analog Fn Block' with VB.NET

    Your input points are references to built-in data points on the SmartServer App device (the digital relay outputs), but maybe your output needs to be created, as I'm guessing that it does not exist yet. Have you created the "Net/LON/iLON App/Analog Fn Block[0]_OR/Output" data point prior to running this example. 

    Jonathan
    • Post Points: 20
  • 01-20-2010 8:15 AM In reply to

    • lumatec
    • Top 10 Contributor
    • Joined on 04-29-2008
    • Posts 80
    • Points 1,135

    Re: Creating an 'Analog Fn Block' with VB.NET

    Hello Jonathan,

    thanks for your prompt reply. Unfortunately I didn't get it by e-mail, although my e-mail subscription is enabled... So it took me some time to realise that somebody actually replied to my request.

    Actually I thought that by the following statement in my program, the Output DP has been created:

     'specify Output DP

    Dim dataPointRef1 As New SmartServer.UFPTanalogFunctionBlock_DpRef()

    dataPointRef1.UCPTname = "Net/LON/iLON App/Analog Fn Block[0]_OR/Output"

    dataPointRef1.dpType = "Output"

    dataPointRef1.UCPTpollRate = 0

    dataPointRef1.UCPTpollRateSpecified = True

    dataPointRef1.discrim = SMARTConfigurator.SmartServer.DpRef_eDiscriminator.dir_out

    dataPointRef1.discrimSpecified = True

     

    Apparently, that is not the case. Maybe there's a misunderstanding. What else do I have to do in order to add an output DP? (If I have a look at an xml file of a manually created Analog FB, with a manually added output DP, the above program should be o.k. But it isn't...)

    Best regards,

    Daniel

    • Post Points: 5
  • 01-21-2010 6:37 AM In reply to

    • lumatec
    • Top 10 Contributor
    • Joined on 04-29-2008
    • Posts 80
    • Points 1,135

    Re: Creating an 'Analog Fn Block' with VB.NET

    Maybe I have to ask it otherwise:

    How am I to create a dynamic data point on a functional block, with VB.NET ? (I thought it's with the '....._DpRef'. But that seems to be wrong.)

    Regards,

    Daniel

    • Post Points: 20
  • 01-21-2010 11:04 AM In reply to

    • jster23
    • Top 10 Contributor
    • Joined on 04-03-2008
    • Posts 38
    • Points 555

    Re: Creating an 'Analog Fn Block' with VB.NET

    Module Module1

    Public Sub Main()

    Dim SmartServer As iLON_SoapCalls = New iLON_SoapCalls

    SmartServer.BindClientToSmartServer()

    Try

    ' -------------- CREATING LONWORKS DATA POINT --------------

    'Create a new LON_LON_Dp_Cfg Item

    Dim my_LON_Dp1 As New iLON_SmartServer.LON_Dp_Cfg()

    'Create an ItemCfgColl to store the LON Dp we just created

    Dim ItemCfgColl As New iLON_SmartServer.Item_CfgColl()ItemCfgColl.Item = New iLON_SmartServer.Item_Cfg(1) {}

    ItemCfgColl.Item(0) = my_LON_Dp1

    '=====CREATING LON DATA POINT #1==================

    ' specify properties of new LON Dp #1

    my_LON_Dp1.UCPTname = "Net/LON/iLON App/Analog Fn Block[0]/Output"

    my_LON_Dp1.UCPTformatDescription = "#0000000000000000[0].SNVT_switch"

    my_LON_Dp1.UCPTdirection = New iLON_SmartServer.E_LonString()

    my_LON_Dp1.UCPTdirection.Value = "DIR_OUT"

    my_LON_Dp1.UCPTdynamic = New iLON_SmartServer.E_LonString()

    my_LON_Dp1.UCPTdynamic.Value = "DDT_DYNAMIC"

     

    'Call the Set() function

    Dim Dp_Return_ItemColl As iLON_SmartServer.Item_Coll = SmartServer._iLON.Set(ItemCfgColl)

    Dp_Return_ItemColl.xSelect = "//Item[@xsi:type=""LON_Dp_Cfg""][UCPTname=""Net/LON/iLON App/Analog Fn Block[0]/Output""]"

    If Dp_Return_ItemColl.UCPTfaultCount > 0 Then

    ' print out error and exit

    Console.Out.WriteLine("An error occurred:")

    For j As Integer = 0 To Dp_Return_ItemColl.Item.Length - 1

    If Dp_Return_ItemColl.Item(j).fault IsNot Nothing Then

    Console.Out.WriteLine(("Item: " & Dp_Return_ItemColl.Item(j).UCPTname & ", fault code: " & Dp_Return_ItemColl.Item(j).fault.faultcode.Value & ", fault string: ") & Dp_Return_ItemColl.Item(j).fault.faultstring)

    End If

    Next

    Else

    ItemCfgColl = SmartServer._iLON.Get(Dp_Return_ItemColl)

    For j As Integer = 0 To ItemCfgColl.Item.Length - 1

    Dim newDp As iLON_SmartServer.LON_Dp_Cfg = DirectCast(ItemCfgColl.Item(j), iLON_SmartServer.LON_Dp_Cfg)

    Console.WriteLine(("New Dp Created = " & newDp.UCPTname))

    Next

    End If

    Console.ReadLine()

    Finally

    SmartServer.CloseBindingToSmartServer()

    End Try

    End Sub

    End Module

    Jonathan
    • Post Points: 20
  • 01-26-2010 6:16 AM In reply to

    • lumatec
    • Top 10 Contributor
    • Joined on 04-29-2008
    • Posts 80
    • Points 1,135

    Re: Creating an 'Analog Fn Block' with VB.NET

    Thanks for that, Jonathan!

    This works, but we are still struggling a bit. When we create a Dp as in your example, it slightly differs from a Dp added manually on the SmartServer configuration web pages. When you add a dynamic variable ('SNVTswitch') manually and you look at it on the 'Configure - Data Point' web page, two 'units' are displayed (value and state). If you add the Dp with the SOAP message, that is not the case. (Even if you add the 'units' to the program above, they don't appear on the web page.)

    We understand, that this has to do with the fact that with the suggested SOAP calls, only the 'LON_Dp_Cfg' is configured, but not the 'Dp_Cfg'. Whether that is of any importance for our project, we don't know. But we'd like to better understand the difference between 'LON_Dp_Cfg' and 'Dp_Cfg'. If we want to add a Dp, do we have to configure both, the 'LON_Dp_Cfg' and the 'Dp_Cfg'? The Programmer's Reference is not very specific on that topic.

    Maybe somebody can provide us with some more information.

    Thanks, Daniel

     

    • Post Points: 20
  • 01-27-2010 7:50 AM In reply to

    Re: Creating an 'Analog Fn Block' with VB.NET

     Hi Daniel

    As far as I know the Dp_Cfg should always be synced with the LON_Dp_Cfg automatically (LON_Dp_Cfg overwrites Dp_Cfg, but not necessarily vice versa). The Dp_Cfg represents "generic" inormation about NVs. The generic information is similar regardless of whether it is a LON, a MOD, or another NV.

    That means you should only have to set the LON_Dp_Cfg (except if you want to edit Dp_Cfg-specific properties like the max value).  However, in this case there seems to be something wrong. If you create the FB first, the SmartServer might automatically create something for you that then conflicts with what you manually add later. Could you try setting the NVs first, wait for the SOAP call to return and then Set the FB?

          Regards

         Thorsten

    • Post Points: 20
  • 01-28-2010 4:20 AM In reply to

    • lumatec
    • Top 10 Contributor
    • Joined on 04-29-2008
    • Posts 80
    • Points 1,135

    Re: Creating an 'Analog Fn Block' with VB.NET

    Hello Thorsten,

    Thanks for your time. As you think the setting of the FB may cause the problem, we simplified the issue. We don't create a new FB, but only add a DP on a 'hidden' and 'never used before' FB. Even so, the problem remains.

    If we add a DP by SOAP calls, and another DP by the 'Web UI', the entries created in the 'Dp.xml' are different. The DP created by the program (as suggested by Jonathan) doesn't have units ('Field', 'Unit string').  That difference is also visible on the 'Configure - Data Point' page of the Web UI. The entries in the 'LON_Dp_Cfg.xml' are the same for both DPs.

    We don't know whether this is of any importance. But we can't feel comfortable about it, because we expect the SOAP calls to do exactly the same as the Web UI. As long as they don't, we suppose something is wrong with our .NET-application.

    Maybe Echelon can provide us with a VB.NET example, that shows:

    1.) How to create an Analog Fb

    2.) How to add an output DP to this Analog Fb

    3.) How to add an internal binding of that output DP to, let's say an nviDlEnable

    Most likely we will also need a sample of a TypeTranslator, and an AlarmNotifier. Of course, most of the configuration of the Fbs is very similar. But as all the Fbs have very specific properties and functions, it would be nice to have a sample for each type of Fb. That would so much speed up our work. Thanks!

    Best regards,

    Daniel

     

    • Post Points: 20
  • 02-02-2010 4:16 PM In reply to

    • jster23
    • Top 10 Contributor
    • Joined on 04-03-2008
    • Posts 38
    • Points 555

    Re: Creating an 'Analog Fn Block' with VB.NET

    Let's take these items one at a time:(1).  You've got good code already demonstrating how to create an Analog Functional Block. So need here to duplicate that effort.

    (2).  You need to explicitly specify the <UCPTunit> property in the LON_Dp_Cfg properties of the "Output" data point.  Here is my modified code example, which includes setting the <UCPTunit> property:

    Module Module1

    Public Sub Main()

    Dim SmartServer As iLON_SoapCalls = New iLON_SoapCalls

    SmartServer.BindClientToSmartServer()

    Try

    ' -------------- CREATING LONWORKS DATA POINT --------------

    'Create new LON_Dp_Cfg Item

    Dim my_LON_Dp1_LonDpCfg As New iLON_SmartServer.LON_Dp_Cfg()

    'Create ItemCfgColl to store the LON_Dp_Cfg we just created

    Dim ItemCfgColl As New iLON_SmartServer.Item_CfgColl()ItemCfgColl.Item = New iLON_SmartServer.Item_Cfg(1) {}

    ItemCfgColl.Item(0) = my_LON_Dp1_LonDpCfg

     

    '=====CREATING LON DATA POINT #1=================

    ' specify LON Driver properties of new Dp #1

    my_LON_Dp1_LonDpCfg.UCPTname = "Net/LON/iLON App/Analog Fn Block[0]/Output"

    my_LON_Dp1_LonDpCfg.UCPTformatDescription = "#0000000000000000[0].SNVT_switch"

    my_LON_Dp1_LonDpCfg.UCPTdirection = New iLON_SmartServer.E_LonString()

    my_LON_Dp1_LonDpCfg.UCPTdirection.Value = "DIR_OUT"

    my_LON_Dp1_LonDpCfg.UCPTdynamic = New iLON_SmartServer.E_LonString()

    my_LON_Dp1_LonDpCfg.UCPTdynamic.Value = "DDT_DYNAMIC"

    ' specify fields for new Dp #1

    my_LON_Dp1_LonDpCfg.UCPTunit = New iLON_SmartServer.E_Unit(2) {} my_LON_Dp1_LonDpCfg.UCPTunit(0) = New iLON_SmartServer.E_Unit()

    my_LON_Dp1_LonDpCfg.UCPTunit(0).field = "value"

    my_LON_Dp1_LonDpCfg.UCPTunit(0).Value = "% of full level"

    my_LON_Dp1_LonDpCfg.UCPTunit(1) = New iLON_SmartServer.E_Unit()

    my_LON_Dp1_LonDpCfg.UCPTunit(1).field = "state"

    my_LON_Dp1_LonDpCfg.UCPTunit(1).Value = "%state code"

     

    'Call the Set() function

    Dim Dp_Return_ItemColl As iLON_SmartServer.Item_Coll = SmartServer._iLON.Set(ItemCfgColl)

    Dp_Return_ItemColl.xSelect = "//Item[@xsi:type=""LON_Dp_Cfg""]"

    If Dp_Return_ItemColl.UCPTfaultCount > 0 Then

    ' print out error and exit

    Console.Out.WriteLine("An error occurred:") For j As Integer = 0 To Dp_Return_ItemColl.Item.Length - 1

    If Dp_Return_ItemColl.Item(j).fault IsNot Nothing Then

    Console.Out.WriteLine(("Item: " & Dp_Return_ItemColl.Item(j).UCPTname & ", fault code: " & Dp_Return_ItemColl.Item(j).fault.faultcode.Value & ", fault string: ") & Dp_Return_ItemColl.Item(j).fault.faultstring)

    End If

    Next

    Else

    ItemCfgColl = SmartServer._iLON.Get(Dp_Return_ItemColl)

    For j As Integer = 0 To ItemCfgColl.Item.Length - 1

    Dim newDp As iLON_SmartServer.LON_Dp_Cfg = DirectCast(ItemCfgColl.Item(j), iLON_SmartServer.LON_Dp_Cfg)

    Console.WriteLine(("New Dp Created = " & newDp.UCPTname))

    For x As Integer = 0 To newDp.UCPTunit().Length - 1

    Console.WriteLine(("Data Point field " & x + 1 & " summary: Field Name = " & newDp.UCPTunit(x).field & ". Field Value = " & newDp.UCPTunit(x).Value))

    Next

    Next

    End If

     

    Console.ReadLine()

    Finally

    SmartServer.CloseBindingToSmartServer()

    End Try

    End Sub

    End Module

    (3).  The WebBinder creation is fairly simple.  Please try following Section 4.4.3 of the Programmer's Reference to create the WebConnection.  If you have problems, I can help you.  Here is what I currently have, which was fairly easy, except I forgot set the UCPTpropagate property to 1.  I'll update this tomorrow.

     

    'Create Web connection

    '====================================================================================

    'Create new Dp_Ref Item

    Dim my_LON_Dp1_LonDpCfg_Binding As New iLON_SmartServer.Dp_Ref()

    'Create ItemCfgColl to store the Dp_Ref Item we just created

    Dim ItemCfgColl_Binding As New iLON_SmartServer.Item_CfgColl()ItemCfgColl_Binding.Item = New iLON_SmartServer.Item_Cfg(1) {}

    ItemCfgColl_Binding.Item(0) = my_LON_Dp1_LonDpCfg_Binding

    'specify source data point

    my_LON_Dp1_LonDpCfg_Binding.UCPTname = "Net/LON/iLON App/Analog Fn Block[0]/Output"

    'specify target data point

    my_LON_Dp1_LonDpCfg_Binding.DataPoint = New iLON_SmartServer.Dp_RefDataPoint(1) {}

    my_LON_Dp1_LonDpCfg_Binding.DataPoint(0) = New iLON_SmartServer.Dp_RefDataPoint()

    my_LON_Dp1_LonDpCfg_Binding.DataPoint(0).dpType = "Target"

    my_LON_Dp1_LonDpCfg_Binding.DataPoint(0).UCPTname = "Net/LON/iLON App/Digital Output 1/nviClaValue_1"

    'specify target SmartServer, which is the local SmartServer in this case

    my_LON_Dp1_LonDpCfg_Binding.DataPoint(0).UCPTservicePath = New iLON_SmartServer.E_Path()

    my_LON_Dp1_LonDpCfg_Binding.DataPoint(0).UCPTservicePath.Value = "//WebService[UCPTindex=0]"

    'Call the Set() function

    Dim Binding_Return_ItemColl As iLON_SmartServer.Item_Coll = SmartServer._iLON.Set(ItemCfgColl_Binding)

    Binding_Return_ItemColl.xSelect = "//Item[@xsi:type=""Dp_Ref""]"

    If Binding_Return_ItemColl.UCPTfaultCount > 0 Then

    ' print out error and exit

    Console.Out.WriteLine("An error occurred:")

    For j As Integer = 0 To Binding_Return_ItemColl.Item.Length - 1

    If Binding_Return_ItemColl.Item(j).fault IsNot Nothing Then

    Console.Out.WriteLine(("Item: " & Binding_Return_ItemColl.Item(j).UCPTname & ", fault code: " & Binding_Return_ItemColl.Item(j).fault.faultcode.Value & ", fault string: ") & Binding_Return_ItemColl.Item(j).fault.faultstring)

    End If

    Next

    Else

    ItemCfgColl_Binding = SmartServer._iLON.Get(Binding_Return_ItemColl)

    For j As Integer = 0 To ItemCfgColl_Binding.Item.Length - 1

    Dim newDpRef As iLON_SmartServer.Dp_Ref = DirectCast(ItemCfgColl_Binding.Item(j), iLON_SmartServer.Dp_Ref)

    Console.WriteLine(("New WebBinding Created. " & "Source Data Point = " & newDpRef.UCPTname & ". Target Data Point = " & newDpRef.DataPoint(0).UCPTname))

    Next

    End If

    Jonathan
    • Post Points: 20
  • 02-03-2010 1:55 AM In reply to

    • lumatec
    • Top 10 Contributor
    • Joined on 04-29-2008
    • Posts 80
    • Points 1,135

    Re: Creating an 'Analog Fn Block' with VB.NET

    Dear Jonathan,

    thanks for your patience. I marked this thread as 'Answered' now. The Analog FB with Binding works fine. For me the topic is closed.

    Maybe Echelon may still be interested in searching the reason, why the 'Units' still don't appear in the 'Configure - Data Point' web page. Adding the units as you suggested in your last answer ('specify units for new Dp#1'), doesn't change that. I already tried it some time ago.

    You may manually add a dynamic DP, and than have a look at the 'Configure - Data Point' web page, or have a look at the 'Dp.xml'. There is still a difference between the manually added DP and the DP added by SOAP-calls.

    Again, don't bother, for me the question is answered. Hope that Echelon will take care of the rest.

    Best regards, Daniel

     

    • Post Points: 20
  • 02-03-2010 12:20 PM In reply to

    • jster23
    • Top 10 Contributor
    • Joined on 04-03-2008
    • Posts 38
    • Points 555

    Re: Creating an 'Analog Fn Block' with VB.NET

    Originally, I created one Item Coll that contained two Items, one Dp_Cfg and one LON_Dp_Cfg, for the data point.  The Dp_Cfg contained the units definition, the LON_Dp_Cfg contained everything else.  The app did create the Dp with the Units property populated in the Configure - Data Points Web page.  The problem was that the Set would return a fault code 2 stating that LON could not process a Dp_Cfg item so I couldn't get the console to print out the fields.  Also, the Lon_Dp_Cfg item must be the first item in the Item Coll array, or else the Dp_Cfg will overwrite the Lon_Dp_Cfg and the data point will get deleted.  I changed my app so that the Units property was created in the Lon_Dp_Cfg item, which resolved the fault code; however, I mistakenly thought that the Units property was populated in the Configure - Data Points Web page.  So to populate the Web page with the Units property, follow my original steps.

    BTW, here is the complete, correct WebBinding solution:

    'Create Web connection

    '====================================================================================

    'Create new Dp_Ref Item

    Dim my_LON_Dp1_LonDpCfg_Binding As New iLON_SmartServer.Dp_Ref()

    'Create ItemCfgColl to store the Dp_Ref Item we just created

    Dim ItemCfgColl_Binding As New iLON_SmartServer.Item_CfgColl()ItemCfgColl_Binding.Item = New iLON_SmartServer.Item_Cfg(1) {}

    ItemCfgColl_Binding.Item(0) = my_LON_Dp1_LonDpCfg_Binding

    'specify source data point

    my_LON_Dp1_LonDpCfg_Binding.UCPTname = "Net/LON/iLON App/Analog Fn Block[0]/Output"

    'specify target data point

    my_LON_Dp1_LonDpCfg_Binding.DataPoint = New iLON_SmartServer.Dp_RefDataPoint(1) {}

    my_LON_Dp1_LonDpCfg_Binding.DataPoint(0) = New iLON_SmartServer.Dp_RefDataPoint()

    my_LON_Dp1_LonDpCfg_Binding.DataPoint(0).dpType = "Target"

    my_LON_Dp1_LonDpCfg_Binding.DataPoint(0).UCPTname = "Net/LON/iLON App/Digital Output 1/nviClaValue_1"

    my_LON_Dp1_LonDpCfg_Binding.DataPoint(0).UCPTpropagate = 1

    my_LON_Dp1_LonDpCfg_Binding.DataPoint(0).UCPTpropagateSpecified = True

    my_LON_Dp1_LonDpCfg_Binding.DataPoint(0).UCPTpriority = 250

    my_LON_Dp1_LonDpCfg_Binding.DataPoint(0).UCPTprioritySpecified = True

    'specify target SmartServer, which is the local SmartServer in this case

    my_LON_Dp1_LonDpCfg_Binding.DataPoint(0).UCPTservicePath = New iLON_SmartServer.E_Path()

    my_LON_Dp1_LonDpCfg_Binding.DataPoint(0).UCPTservicePath.Value = "//WebService[UCPTindex=2]"

    'Call the Set() function

    Dim Binding_Return_ItemColl As iLON_SmartServer.Item_Coll = SmartServer._iLON.Set(ItemCfgColl_Binding)

    Binding_Return_ItemColl.xSelect = "//Item[@xsi:type=""Dp_Ref""]"

    If Binding_Return_ItemColl.UCPTfaultCount > 0 Then

    ' print out error and exit

    Console.Out.WriteLine("An error occurred:")

    For j As Integer = 0 To Binding_Return_ItemColl.Item.Length - 1

    If Binding_Return_ItemColl.Item(j).fault IsNot Nothing Then

    Console.Out.WriteLine(("Item: " & Binding_Return_ItemColl.Item(j).UCPTname & ", fault code: " & Binding_Return_ItemColl.Item(j).fault.faultcode.Value & ", fault string: ") & Binding_Return_ItemColl.Item(j).fault.faultstring)

    End If

    Next

    Else

    ItemCfgColl_Binding = SmartServer._iLON.Get(Binding_Return_ItemColl)

    For j As Integer = 0 To ItemCfgColl_Binding.Item.Length - 1

    Dim newDpRef As iLON_SmartServer.Dp_Ref = DirectCast(ItemCfgColl_Binding.Item(j), iLON_SmartServer.Dp_Ref)

    Console.WriteLine(("New WebBinding Created. " & "Source Data Point = " & newDpRef.UCPTname & ". Target Data Point = " & newDpRef.DataPoint(0).UCPTname))

    Next

    End If

    Jonathan
    • Post Points: 5
Page 1 of 1 (11 items)
©2008 Echelon Corporation