request = HistoryReadRawModifiedRequest(1)
    request.targets[0].address = doubleAddress
    
    # configure the request further:
    serviceSettings = HistoryReadRawModifiedSettings()
    serviceSettings.startTime         = DateTime(time.time() - 1)
    serviceSettings.endTime           = DateTime(time.time())
    serviceSettings.callTimeoutSec    = 2.0                        # optional of course
    serviceSettings.numValuesPerNode  = 100
    serviceSettings.maxAutoReadMore   = 10
    serviceSettings.isReadModified    = False                      # we want raw historical data
    request.serviceSettings = serviceSettings
    request.serviceSettingsGiven = True
    
    sessionSettings = SessionSettings()
    sessionSettings.sessionTimeoutSec = 600.0                      # optional of course
    request.sessionSettings = sessionSettings
    request.sessionSettingsGiven = True
    
    # process the request
    result = myClient.processRequest(request)
    
    # print the result
    print(str(result))
    
    # process the result in the same way as before
    
except UafError, e:
    print("Some error occurred: %s" %e)
    raise
#    defaultSessionSettings, but such a session exists already, so it can be reused!)
#  - the Write service will be invoked, with the defaultWriteSettings we configured before
myClient.write( [address0, address1] , [ UInt32(60), Boolean(True) ] )


# ==================================================================================================
# 2) Overriding the defaults
# ==================================================================================================

# If needed, you can also configure the settings for each service call, using the **kwargs arguments
# of read/write/call/...

# e.g. set some special session settings for a specific read() call:
mySessionSettings = SessionSettings()
mySessionSettings.connectTimeoutSec = 0.5
mySessionSettings.sessionTimeoutSec = 100.0
# simply mention 'sessionSettings = ...' to use these settings as a **kwarg:
myClient.read( [address0, address1], sessionSettings = mySessionSettings ) 

# e.g. set some special service settings for a specific read() call:
myReadSettings = ReadSettings()
myReadSettings.callTimeoutSec = 0.5
myReadSettings.maxAgeSec      = 1.0
# simply mention 'serviceSettings = ...' to use these settings as a **kwarg:
myClient.read( [address0, address1], serviceSettings = myReadSettings ) 
# or combine them:
myClient.read( [address0, address1], serviceSettings = myReadSettings, sessionSettings = mySessionSettings ) 

# e.g. set some special subscription settings for a specific createMonitoredData() call:
mySubscriptionSettings = SubscriptionSettings()
mySubscriptionSettings.publishingIntervalSec = 2.0
Пример #3
0
 
 # now browse the root node
 # (notice that there is also an argument called 'maxAutoBrowseNext', which we don't mention
 #  here because we can leave it at the default value (100), to make sure that BrowseNext is 
 # automatically being called for us as much as needed!)
 firstLevelBrowseResult = myClient.browse([rootNode])
 
 # Notice too that you can optionally provide a BrowseSettings and/or a SessionSettings argument
 # for more detailed configuration, like this:
 # OPTIONAL: let's specify a small call timeout, since the UaDemoServer is running 
 #           on the local machine anyway:
 browseSettings = BrowseSettings()
 browseSettings.callTimeoutSec = 2.0
 # OPTIONAL: and finally let's also specify that sessions should have a timeout of 600 seconds:
 sessionSettings = SessionSettings()
 sessionSettings.sessionTimeoutSec = 600.0
 # now call the browse() function:
 myClient.browse([rootNode], browseSettings = browseSettings, sessionSettings = sessionSettings)
 
 # print the result
 print(" - Browse result of the first level:")
 print("   ---------------------------------")
 print(firstLevelBrowseResult)
 
 # we don't expect that "manual" BrowseNext calls are still needed, as the UAF will
 # have done the BrowseNext calls up to 100 times automatically for us! If there would still be
 # some continuation points left, then we surely have some unexpected problem!
 assert len(firstLevelBrowseResult.targets[0].continuationPoint) == 0
 
 # we can now continue browsing the other nodes that we discovered, all simultaneously!!!
 noOfFoundReferences = len(firstLevelBrowseResult.targets[0].references)
    # now browse the root node
    # (notice that there is also an argument called 'maxAutoBrowseNext', which we don't mention
    #  here because we can leave it at the default value (100), to make sure that BrowseNext is
    # automatically being called for us as much as needed!)
    firstLevelBrowseResult = myClient.browse([rootNode])

    # Notice too that you can optionally provide a BrowseSettings and/or a SessionSettings argument
    # for more detailed configuration, like this:
    # OPTIONAL: let's specify a small call timeout, since the UaDemoServer is running
    #           on the local machine anyway:
    browseSettings = BrowseSettings()
    browseSettings.callTimeoutSec = 2.0
    # OPTIONAL: and finally let's also specify that sessions should have a timeout of 600 seconds:
    sessionSettings = SessionSettings()
    sessionSettings.sessionTimeoutSec = 600.0
    # now call the browse() function:
    myClient.browse([rootNode],
                    browseSettings=browseSettings,
                    sessionSettings=sessionSettings)

    # print the result
    print(" - Browse result of the first level:")
    print("   ---------------------------------")
    print(firstLevelBrowseResult)

    # we don't expect that "manual" BrowseNext calls are still needed, as the UAF will
    # have done the BrowseNext calls up to 100 times automatically for us! If there would still be
    # some continuation points left, then we surely have some unexpected problem!
    assert len(firstLevelBrowseResult.targets[0].continuationPoint) == 0
myClientSettings.defaultSubscriptionSettings.publishingIntervalSec = 0.5
myClientSettings.defaultSubscriptionSettings.lifeTimeCount         = 600
myClientSettings.defaultReadSettings.callTimeoutSec = 2.0
myClientSettings.defaultReadSettings.maxAgeSec      = 10.0
myClientSettings.defaultMethodCallSettings.callTimeoutSec = 2.0
myClientSettings.defaultWriteSettings.callTimeoutSec = 2.0
myClientSettings.defaultBrowseSettings.callTimeoutSec = 2.0
# and so on, and so on ...

# the clientSettings are in use as soon as you provide them again to the Client:
myClient.setClientSettings(myClientSettings)

# In case you want to choose different settings for specific read/write/... calls, then you can
# provide them also:
mySpecialSessionSettings = SessionSettings() 
mySpecialSessionSettings.sessionTimeoutSec = 500.0
mySpecialSessionSettings.connectTimeoutSec = 0.5
mySpecialReadSettings = ReadSettings()
mySpecialReadSettings.callTimeoutSec = 2.0
mySpecialReadSettings.maxAgeSec      = 10.0

result = myClient.read(addresses       = [address_TSetpoint, address_HeaterStatus],
                       attributeId     = pyuaf.util.attributeids.DisplayName,
                       sessionSettings = mySpecialSessionSettings,
                       serviceSettings = mySpecialReadSettings)



print("")
print("################################################################################################################")
print("Step 6: Learn how 'requests' and 'results' actually look like, and how you can configure them even more in detail")
#  - the session we created before will be reused (as we're requesting a session with the
#    defaultSessionSettings, but such a session exists already, so it can be reused!)
#  - the Write service will be invoked, with the defaultWriteSettings we configured before
myClient.write([address0, address1], [UInt32(60), Boolean(True)])

# ==================================================================================================
# 2) Overriding the defaults
# ==================================================================================================

# If needed, you can also configure the settings for each service call, using the **kwargs arguments
# of read/write/call/...

# e.g. set some special session settings for a specific read() call:
mySessionSettings = SessionSettings()
mySessionSettings.connectTimeoutSec = 0.5
mySessionSettings.sessionTimeoutSec = 100.0
# simply mention 'sessionSettings = ...' to use these settings as a **kwarg:
myClient.read([address0, address1], sessionSettings=mySessionSettings)

# e.g. set some special service settings for a specific read() call:
myReadSettings = ReadSettings()
myReadSettings.callTimeoutSec = 0.5
myReadSettings.maxAgeSec = 1.0
# simply mention 'serviceSettings = ...' to use these settings as a **kwarg:
myClient.read([address0, address1], serviceSettings=myReadSettings)
# or combine them:
myClient.read([address0, address1],
              serviceSettings=myReadSettings,
              sessionSettings=mySessionSettings)

# e.g. set some special subscription settings for a specific createMonitoredData() call:
Пример #7
0
myClientSettings.defaultSubscriptionSettings.publishingIntervalSec = 0.5
myClientSettings.defaultSubscriptionSettings.lifeTimeCount = 600
myClientSettings.defaultReadSettings.callTimeoutSec = 2.0
myClientSettings.defaultReadSettings.maxAgeSec = 10.0
myClientSettings.defaultMethodCallSettings.callTimeoutSec = 2.0
myClientSettings.defaultWriteSettings.callTimeoutSec = 2.0
myClientSettings.defaultBrowseSettings.callTimeoutSec = 2.0
# and so on, and so on ...

# the clientSettings are in use as soon as you provide them again to the Client:
myClient.setClientSettings(myClientSettings)

# In case you want to choose different settings for specific read/write/... calls, then you can
# provide them also:
mySpecialSessionSettings = SessionSettings()
mySpecialSessionSettings.sessionTimeoutSec = 500.0
mySpecialSessionSettings.connectTimeoutSec = 0.5
mySpecialReadSettings = ReadSettings()
mySpecialReadSettings.callTimeoutSec = 2.0
mySpecialReadSettings.maxAgeSec = 10.0

result = myClient.read(
    addresses=[address_TSetpoint, address_HeaterStatus],
    attributeId=pyuaf.util.attributeids.DisplayName,
    sessionSettings=mySpecialSessionSettings,
    serviceSettings=mySpecialReadSettings,
)


print("")
print(